No_mad:неактивен и окошко не вызывается
No_mad, в "09042016" этой функции пока нет - пункт меню есть .
Я только сегодня закончил скрипт для копирования, тестирую.
Скрипт может и не совсем сложный, только всякие там проверки, предусмотреть ситуации.
Список разделов › foobar2000 › Секреты foobar2000
No_mad:неактивен и окошко не вызывается
// ==PREPROCESSOR==
// @name "Biography Text && Picture. www.last.fm"
// @author "kgena_ua"
// @version "11042016"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
function RGBA(r,g,b,a) { return ((a << 24) | (r << 16) | (g << 8) | (b)); }
function getRed(color) {return ((color >> 16) & 0xff);};
function getGreen(color) {return ((color >> 8) & 0xff);};
function getBlue(color) {return (color & 0xff);};
DT_LEFT = 0x00000000;
DT_RIGHT = 0x00000002;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
DT_WORD_ELLIPSIS = 0x00040000;
DT_WORDBREAK = 0x00000010;
DT_CALCRECT = 0x00000400;
DT_NOPREFIX = 0x00000800;
var ww,wh;
var font_name_a = window.GetProperty("font name: artist", "Arial");
var font_name_b = window.GetProperty("font name: biography", "Arial");
var font_size_a_d = window.GetProperty("font size: artist (delta)", 0);
var font_size_b = window.GetProperty("font size: biography", 12);
var a_font_style = window.GetProperty("font style: artist", 1);
var b_font_style = window.GetProperty("font style: biography", 0);
var min_font_size = 10;
var max_font_size = 16;
var a_font, b_font;
get_font();
function get_font(){
a_font = gdi.Font(font_name_a, font_size_b + font_size_a_d, a_font_style);
b_font = gdi.Font(font_name_b, font_size_b, b_font_style);
}
/*
ColorTypeCUI = {
text: 0,
selection_text: 1,
inactive_selection_text: 2,
background: 3,
selection_background: 4,
inactive_selection_background: 5,
active_item_frame: 6
};
function get_color(){
bgcolor = window.GetColorCUI(ColorTypeCUI.background);
a_color = window.GetColorCUI(ColorTypeCUI.text);
b_color = window.GetColorCUI(ColorTypeCUI.inactive_selection_text);
}
get_color();
function on_colors_changed(){
get_color();
}
*/
var bgcolor = RGB(31,41,48);
var a_color = RGB(220,220,220);
var b_color = RGB(255,255,230);
var transparent = 200;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var tmp_b_path = fb.ProfilePath + "\\tmp_Biography\\";
if (!fso.FolderExists(tmp_b_path)) {fso.CreateFolder(tmp_b_path)};
var script_path = tmp_b_path + "_download\\";
if (!fso.FolderExists(script_path)) {fso.CreateFolder(script_path)};
if (!fso.FileExists(script_path + "download.vbs")) {create_download_file()};
var doc = new ActiveXObject("htmlfile");
var WshShell = new ActiveXObject("WScript.Shell");
var vbs = "cscript //nologo \"" + script_path + "download.vbs\"";
var nocover_path = window.GetProperty("nocover path",".\\nocover\\nocover.png");
var nocover = window.GetProperty("nocover image", false);
var nocover_transparent = window.GetProperty("nocover transparent (0-255)", 100);
load_last_fm_logo();
var logo_img = gdi.Image(script_path + "last_fm_logo.jpg");
var artist, old_artis;
var path, directory_path;
function clean_name(n) {
return n.replace(/[\/\:\*\?\"\<\>\|]/g,' ');
}
function artist_folder_path(n) {
return tmp_b_path + clean_name(n);
}
function check_folder(n) {
if(!fso.FolderExists(n)) {fso.CreateFolder(n)};
}
var g_img = null;
var p_margin = window.GetProperty("margin: picture", 10);
var align_mode_a = new Array("adjust", "adjust top - center", "adjust top - left", "centre", "centre - top", "stretch");
var align_mode = window.GetProperty("align mode", 0);
var selected = 0;
var files = [];
var images = [];
var found = 0;
var save_images = window.GetProperty("save images", false);
var limit = window.GetProperty("download limit",5);
var cycle = window.GetProperty("auto cycle (sec)", 0);
if (cycle > 0) set_cycle_timer();
var fader = 255;
var fade_effect = window.GetProperty("fade effect", false);
var fade_step = window.GetProperty("fade step", 5);
var on_pic = false;
var scrollbar = window.GetProperty("scrollbar", true);
var scrollbar_k;
var sb_posy = 0;
var on_sb = false;
var on_sb_down = false;
var t_margin = window.GetProperty("margin: text", 10);
var txt_x = window.GetProperty("txt_x", window.Width / 2);
var txt_y = window.GetProperty("txt_y", window.Height / 2);
var delta_x, delta_y;
var a_x, a_y;
var b_x, b_y;
var text = "";
var s_text = 0;
var old_string_width = 0;
var a_text_row_height = 0;
var b_text_row_height = 0;
var b_text_rows = 0;
var b_text_visable_rows = 0;
var b_text_visable_height = 0;
var b_text_array = [];
var on_artist = false;
var on_text = false;
var on_text_down = false;
var abc_lang = new Array("", "ru/");
var abc = window.GetProperty("abc", 0);
var if_not_found = new Array(". . .", ". . .");
var select_p_a = window.GetProperty("pictures/albums", 0);
var p_a = new Array("images", "albums");
var selection_mode = window.GetProperty("selection mode", 0);
var metadb;
on_item_focus_change();
function on_paint(gr){
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
paint(gr);
if(set_cycle){
gr.FillSolidRect(0, 0, ww, wh, RGBA(getRed(bgcolor),getGreen(bgcolor),getBlue(bgcolor),transparent));
var txt_cycle = cycle == 0 ? "off" : cycle + " sec";
set_cycle && gr.GdiDrawText("auto cycle \n" + txt_cycle, b_font, b_color, 15, 15, ww, wh, DT_LEFT | DT_WORD_ELLIPSIS );
} else{
gr.FillSolidRect(txt_x, txt_y, ww - txt_x, wh - txt_y, RGBA(getRed(bgcolor),getGreen(bgcolor),getBlue(bgcolor),transparent));
}
gr.GdiDrawText(artist, a_font, RGB(0,0,0), a_x + 1, a_y + 2, ww - a_x - t_margin, wh, DT_LEFT | DT_WORD_ELLIPSIS | DT_NOPREFIX );
gr.GdiDrawText(artist, a_font, a_color, a_x, a_y, ww - a_x - t_margin, wh, DT_LEFT | DT_WORD_ELLIPSIS | DT_NOPREFIX );
for (var i = 0; i < b_text_visable_rows * 2; i += 2) {
try {
gr.GdiDrawText(b_text_array[i + s_text * 2].replace(/^\s+|\s+$/g, ""), b_font, RGB(0,0,0), b_x + 1, b_y + b_text_row_height * i / 2 + 2, ww, wh, DT_LEFT | DT_NOPREFIX );
gr.GdiDrawText(b_text_array[i + s_text * 2].replace(/^\s+|\s+$/g, ""), b_font, b_color, b_x, b_y + b_text_row_height * i / 2 , ww, wh, DT_LEFT | DT_NOPREFIX );
} catch(e) {}
}
scrollbar && draw_scrollbar(gr);
}
function paint(gr){
if (g_img){
var size = calc_img_size(g_img);
gr.DrawImage(g_img, size.x, size.y, size.width, size.height, size.cx, size.cy, size.cwidth, size.cheight, 0, images.length > 0 ? fader : nocover_transparent);
}
if (logo_img && images.length == 0 && !nocover){
gr.DrawImage(logo_img, p_margin, p_margin, logo_img.Width * 0.8, logo_img.Height * 0.8, 0, 0, logo_img.Width, logo_img.Height, 0, 255);
}
if (images.length == 0 && nocover){
try {
nc_img = gdi.Image(nocover_path);
var size = calc_img_size(nc_img);
gr.DrawImage(nc_img, size.x, size.y, size.width, size.height, size.cx, size.cy, size.cwidth, size.cheight, 0, nocover_transparent);
} catch(e) {};
}
}
function draw_scrollbar(gr){
scrollbar_h = b_text_rows > b_text_visable_rows ? b_text_visable_height * (b_text_visable_rows / b_text_rows) : 0;
if (b_text_rows > b_text_visable_rows){ scrollbar_h = Math.max(5, scrollbar_h)}
scrollbar_y = s_text > 0 ? s_text * scrollbar_k : 0;
gr.FillSolidRect(ww - 4, b_y + scrollbar_y, 2, scrollbar_h, a_color);
}
function on_playlist_switch() {
on_item_focus_change();
}
function on_playback_new_track() {
on_item_focus_change();
}
function on_playback_dynamic_info_track() {
on_item_focus_change();
}
function on_playback_stop() {
on_item_focus_change();
}
function on_selection_changed(metadb) {
on_item_focus_change();
}
function on_item_focus_change() {
switch (selection_mode) {
case 0:
metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
break;
case 1:
metadb = fb.GetFocusItem();
break;
}
if (metadb) on_metadb_changed();
}
function Eval(field) {
if (!metadb) return;
path = fb.Titleformat("%path%").EvalWithMetadb(metadb);
directory_path = fb.Titleformat("$directory_path(%path%)").EvalWithMetadb(metadb);
return path.indexOf('://') > 0 ? fb.TitleFormat("[" + field + "]").Eval() : fb.TitleFormat("[" + field + "]").EvalWithMetadb(metadb);
//return fb.Titleformat("[" + field + "]").EvalWithMetadb(metadb) ? fb.TitleFormat("[" + field + "]").EvalWithMetadb(metadb) : fb.TitleFormat("[" + field + "]").Eval(true);
}
function on_metadb_changed() {
if (!metadb) return;
artist = Eval("%artist%").replace(/^\s+|\s+$/g, "");
if (artist != old_artis){
if (!save_images) del_folders();
s_text = 0;
text = "";
old_string_width = 0;
get_b_text_array()
get_lastFM_b_text();
//get_text();
g_img = null;
files = [];
images = [];
found = 0;
selected = 0;
get_pic();
old_artis = artist;
}
}
function get_pic() {
if (!artist) return;
check_folder(artist_folder_path(artist));
get_files_from_dir(artist_folder_path(artist));
if (!g_img && images.length > 0) {
next_image(0);
} else {
get_lastFM_pic(artist_folder_path(artist));
}
}
var q, qq;
function get_lastFM_pic(p){
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP");
url1 = ("http://www.last.fm/music/" + encodeURIComponent(artist) + "/+" + p_a[select_p_a]);
xmlhttp1.open("GET", url1, true);
xmlhttp1.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
xmlhttp1.send(null);
xmlhttp1.onreadystatechange = function () {
if (xmlhttp1.readyState == 4) {
if (xmlhttp1.status == 200) {
doc.open();
var div = doc.createElement("div");
div.innerHTML = xmlhttp1.responsetext;
var data = div.getElementsByTagName("img");
var data2 = div.getElementsByTagName("div");
var urls = [];
for (i = 0; i < data.length; i++) {
if (data[i].className == "image-list-image" && select_p_a == 0){
if (data[i].src.indexOf("http://img2-ak.lst.fm/i/u/avatar170s") == 0) {
urls.push(data[i].src.replace("avatar170s", "770x0"));
}
}
if (data[i].className == "album-grid-album-art" && select_p_a == 1){
if (data[i].src.indexOf("http://img2-ak.lst.fm/i/u/300") == 0 && data[i].src.indexOf("c6f59c1e5e7240a4c0d427abd71f3dbb") < 0) {
urls.push(data[i].src.replace("300", ""))
}
}
}
found = Math.min(urls.length, limit); window.Repaint();
for (i = 0; i < Math.min(urls.length, limit); i++) {
file = "\"" + p + "\\" + clean_name(artist) + "_" + i + "_" + p_a[select_p_a] + ".jpg" + "\"";
WshShell.Run(vbs + " " + urls[i] + " " + file, false);
}
doc.close();
if (found > 0) get_files_if_loaded();
}
}
}
}
function get_files_from_dir(p) {
if (!artist) return;
p = p + "\\";
//files = [];
images = [];
files = utils.Glob(p + "*.*").toArray();
for (i in files) {
if (files[i].indexOf(clean_name(artist)) > 0 && files[i].indexOf(p_a[select_p_a]) > 0){
try {
images.push(get_images(gdi.Image(files[i])));
} catch(e) {}
}
}
}
function next_image(d){
fader = fade_effect ? 0 : 255;
if (d < 0) {selected = selected <= 0 ? images.length - 1 : selected = selected - 1};
if (d > 0) {selected = selected >= images.length - 1 ? 0 : selected = selected + 1};
g_img = images[selected];
if (g_img && fade_effect) fader_timer();
window.Repaint();
}
function get_images(img){
if (!img) return;
var scale_w = (window.Width - p_margin * 2) / img.Width;
var scale_h = (window.Height - p_margin * 2) / img.Height;
var scale = Math.min(scale_w, scale_h);
var nww = img.Width * scale;
var nwh = img.Height * scale
var temp_bmp = gdi.CreateImage(nww, nwh);
var temp_gr = temp_bmp.GetGraphics();
temp_gr.SetSmoothingMode(2);
temp_gr.SetInterpolationMode(7);
temp_gr.DrawImage(img, 0, 0, nww, nwh, 0, 0, img.width, img.height);
temp_bmp.ReleaseGraphics(temp_gr);
CollectGarbage();
return temp_bmp;
temp_bmp.Dispose();
temp_gr = null;
temp_bmp = null;
}
function get_lastFM_b_text(){
xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
url2 = ("http://www.last.fm/" + abc_lang[abc] + "music/" + encodeURIComponent(artist) + "/+wiki");
xmlhttp2.open("GET", url2, true);
xmlhttp2.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
xmlhttp2.send(null);
xmlhttp2.onreadystatechange = function () {
if (xmlhttp2.readyState == 4) {
if (xmlhttp2.status == 200) {
doc.open();
var div = doc.createElement("div");
div.innerHTML = xmlhttp2.responsetext;
var data = div.getElementsByTagName("div");
for (i = 0; i < data.length; i++) {
if (data[i].className == "wiki-content") {
text = strip_tags(data[i].innerHTML);
break;
}
}
doc.close();
}
if (text == "") text = if_not_found[abc];
old_string_width = 0;
get_b_text_array();
//save_biography_file(text);
}
}
}
function strip_tags(t) {
doc.open();
var div = doc.createElement("div");
div.innerHTML = t.replace(/<[Pp][^>]*>/g, "").replace(/<\/[Pp]>/g, "<br>").replace(/\n/g, "<br>");
var text = div.innerText;
doc.close();
return text;
}
function get_b_text_array() {
a_x = txt_x + t_margin;
a_y = txt_y + t_margin;
temp_bmp = gdi.CreateImage(1, 1);
temp_gr = temp_bmp.GetGraphics();
a_text_row_height = temp_gr.CalcTextHeight("text", a_font);
b_text_row_height = temp_gr.CalcTextHeight("text", b_font);
b_x = txt_x + t_margin;
b_y = a_y + a_text_row_height + b_text_row_height;
string_width = Math.max(ww - b_x - t_margin, 0);
if (old_string_width != string_width){
b_text_array = [];
if (text) b_text_array = temp_gr.EstimateLineWrap(text, b_font, string_width).toArray();
old_string_width = string_width;
}
b_text_rows = b_text_array.length / 2;
b_text_visable_height = Math.round(Math.max(0, wh - t_margin - b_y));
b_text_visable_rows = Math.round(b_text_visable_height / b_text_row_height);
if (b_text_visable_rows + s_text > b_text_rows && s_text > 0) {
s_text = (b_text_rows - b_text_visable_rows);
};
scrollbar_k = b_text_visable_height / b_text_rows;
temp_bmp.ReleaseGraphics(temp_gr);
temp_bmp.Dispose();
temp_gr = null;
temp_bmp = null;
window.Repaint();
}
function on_mouse_rbtn_up (x, y){
var _menu = window.CreatePopupMenu();
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
MF_SEPARATOR = 0x00000800;
_menu.AppendMenuItem(MF_ENABLED, 10, "EN text");
_menu.AppendMenuItem(MF_ENABLED, 11, "RU text");
_menu.CheckMenuRadioItem(10, 11, abc + 10);
_menu.EnableMenuItem(abc + 10, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 12, "Prefer now playing");
_menu.AppendMenuItem(MF_ENABLED, 13, "Follow selected track");
_menu.CheckMenuRadioItem(12, 13 , selection_mode + 12);
_menu.EnableMenuItem(selection_mode + 12, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 14, "Artist pictures");
_menu.AppendMenuItem(MF_ENABLED, 15, "Albums pictures");
_menu.CheckMenuRadioItem(14, 15 , select_p_a + 14);
_menu.EnableMenuItem(select_p_a + 14, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
var is_artist = artist ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(is_artist, 16, "last.fm Artist");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 17, "Fade effect");
_menu.CheckMenuItem(17, fade_effect);
var _firstgroup = window.CreatePopupMenu();
_firstgroup.AppendTo(_menu,MF_ENABLED, "Align : " + align_mode_a[align_mode]);
_firstgroup.AppendMenuItem(MF_ENABLED, 20, align_mode_a[0]);
_firstgroup.AppendMenuItem(MF_ENABLED, 21, align_mode_a[1]);
_firstgroup.AppendMenuItem(MF_ENABLED, 22, align_mode_a[2]);
_firstgroup.AppendMenuItem(MF_ENABLED, 23, align_mode_a[3]);
_firstgroup.AppendMenuItem(MF_ENABLED, 24, align_mode_a[4]);
_firstgroup.CheckMenuRadioItem(20, 24, align_mode + 20);
_firstgroup.EnableMenuItem(align_mode + 20, 1);
var MF_ = images.length > 0 ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_, 30, "Copy to folder containing track...");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 40, "Save images");
_menu.CheckMenuItem(40, save_images);
// if (ShiftDown) {
//_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
//_menu.AppendMenuItem(MF_ENABLED, 100, "Reload");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 110, "Properties");
_menu.AppendMenuItem(MF_ENABLED, 120, "Configure ...");
// }
ret = _menu.TrackPopupMenu(x,y);
switch (ret) {
case 10:
abc = 0;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_lastFM_b_text();
break;
case 11:
abc = 1;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_lastFM_b_text();
break;
case 12:
selection_mode = 0;
window.SetProperty("selection mode", selection_mode);
on_item_focus_change();
break;
case 13:
selection_mode = 1;
window.SetProperty("selection mode", selection_mode);
on_item_focus_change();
break;
case 14:
select_p_a = 0;
window.SetProperty("pictures/albums", select_p_a);
g_img = null;
files = [];
images = [];
found = 0;
selected = 0;
window.Repaint();
get_pic();
break;
case 15:
select_p_a = 1;
window.SetProperty("pictures/albums", select_p_a);
g_img = null;
files = [];
images = [];
found = 0;
selected = 0;
window.Repaint();
get_pic();
break;
case 16:
WshShell.run("http://www.last.fm/" + abc_lang[abc] + "music/" + encodeURIComponent(artist));
break;
case 17:
window.SetProperty("fade effect", !fade_effect);
fade_effect = window.GetProperty("fade effect");
break;
case 20:
case 21:
case 22:
case 23:
case 24:
align_mode = ret - 20;
window.SetProperty("align mode", align_mode);
window.Repaint();
break;
case 30:
copy_files();
break;
case 40:
window.SetProperty("Save images", !save_images);
save_images = window.GetProperty("Save images");
break;
case 100:
//window.Reload();
break;
case 110:
window.ShowProperties();
break;
case 120:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}
var timer;
var fff = 0;
function get_files_if_loaded(){
fff = 0;
timer && window.ClearInterval(timer);
timer = window.SetInterval(function() {
get_files_from_dir(artist_folder_path(artist));
if (!g_img && images.length > 0) next_image(0);
if (found > 0 && images.length == found && g_img) {
window.ClearInterval(timer);
}
fff = fff + 1;
window.Repaint();
}, 500 );
}
var set_cycle = false;
function on_key_down(vkey) {
if (vkey == 16){
set_cycle = true;
dis_set();
window.Repaint();
}
}
var cycle_timer, step = 0;
function set_cycle_timer(){
cycle_timer && window.ClearInterval(cycle_timer);
cycle_timer = window.SetInterval(function() {
step = set_cycle ? 0 : step + 1;
if (cycle > 0 && step >= cycle){
if (images.length > 1){
next_image(1);
window.Repaint();
step = 0;
}
}
window.Repaint();
}, 1000 );
}
var dis_timer, dis = 0;
function dis_set(){
dis = 0;
dis_timer && window.ClearInterval(dis_timer);
dis_timer = window.SetInterval(function() {
if (set_cycle) {
dis++;
if(dis == 1) {
set_cycle = false;
if (cycle > 0) set_cycle_timer();
if (cycle == 0) window.ClearInterval(cycle_timer);
window.ClearInterval(dis_timer)
window.Repaint();
};
}
}, 1000 );
}
var delay = false;
function fdelay(){
var delay_timer = window.SetTimeout(function() {
delay = false;
window.ClearTimeout(delay_timer);
}, 200);
}
var ftimer;
function fader_timer(){
fader = 0;
ftimer && window.ClearInterval(ftimer);
ftimer = window.SetInterval(function() {
fader = fader + fade_step;
if (fader >= 255) {
fader= 255;
window.ClearInterval(ftimer);
}
window.Repaint();
}, 10 );
}
function load_last_fm_logo(){
if(!fso.FileExists(script_path + "last_fm_logo.jpg")) {
var url = "http://www.last.fm/static/images/logo_beta.png?eb6d3ca20e73"
var file = "\"" + script_path + "last_fm_logo.jpg" + "\"";
WshShell.Run(vbs + " " + url + " " + file, false);
var url = "http://static-web.last.fm/static/images/favicon.702b239b6194.ico"
var file = "\"" + script_path + "last_fm_ico.ico" + "\"";
WshShell.Run(vbs + " " + url + " " + file, false);
}
}
function create_download_file() {
try {
file = fso.CreateTextFile(script_path + "download.vbs" )
var text =
"If (WScript.Arguments.Count <> 2) Then" + "\n\r" +
" WScript.Quit" + "\n\r" +
"End If" + "\n\r" + "\n\r" +
"url = WScript.Arguments(0)" + "\n\r" +
"file = WScript.Arguments(1)" + "\n\r" + "\n\r" +
"Set objFSO = Createobject(" + '"Scripting.FileSystemObject"' + ")" + "\n\r" +
"If objFSO.Fileexists(file) Then" + "\n\r" +
" Set objFSO = Nothing" + "\n\r" +
" WScript.Quit" + "\n\r" +
"End If" + "\n\r" + "\n\r" +
"Set objXMLHTTP = CreateObject(" + '"MSXML2.XMLHTTP"' + ")" + "\n\r" +
"objXMLHTTP.open " + '"GET"' + ", url,false" + "\n\r" +
"objXMLHTTP.send()" + "\n\r" + "\n\r" +
"If objXMLHTTP.Status = 200 Then" + "\n\r" +
" Set objADOStream = CreateObject(" + '"ADODB.Stream"' + ")" + "\n\r" +
" objADOStream.Open" + "\n\r" +
" objADOStream.Type = 1" + "\n\r" +
" objADOStream.Write objXMLHTTP.ResponseBody" + "\n\r" +
" objADOStream.Position = 0" + "\n\r" +
" objADOStream.SaveToFile file" + "\n\r" +
" objADOStream.Close" + "\n\r" +
" Set objADOStream = Nothing" + "\n\r" +
"End If" + "\n\r" + "\n\r" +
"Set objFSO = Nothing" + "\n\r" +
"Set objXMLHTTP = Nothing"
;
file.WriteLine(text);
file.Close();
} catch(e) {};
}
function on_mouse_move(x, y) {
window.SetCursor(32649);
on_text = x >= txt_x && x < ww - 20 && y >= txt_y ? true : false;
on_sb = x > ww - 20 && y >= txt_y ? true : false;
on_pic = !on_text && !on_sb ? true : false;
//if (on_pic && c_selected == selected){ //****
// delay = true; //****
// fdelay(); //****
// if (x > pic_posx) next_image(1); //****
// if (x < pic_posx) next_image(-1); //****
// if (cycle > 0) step = 0; //****
//} //****
if (on_text_down){
txt_x = x - delta_x;
txt_y = y - delta_y;
txt_x = txt_x <= 0 ? 0 : txt_x >= ww - 50 ? ww - 50: txt_x;
txt_y = txt_y <= 0 ? 0 : txt_y >= wh - (a_text_row_height + t_margin * 2) ? wh - (a_text_row_height + t_margin * 2) : txt_y;
get_b_text_array();
}
if (on_sb_down && scrollbar && b_text_rows > b_text_visable_rows){
sb_posy = y + delta_y;
s_text = y + delta_y >= 0 ? y + delta_y <= (b_text_rows - b_text_visable_rows) * scrollbar_k ? Math.round(sb_posy / scrollbar_k) : b_text_rows - b_text_visable_rows : 0;
window.Repaint();
}
}
function on_mouse_wheel(delta) {
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
if (on_pic && !ShiftDown && !delay && images.length > 1){
delay = true;
fdelay();
next_image(delta);
if (cycle > 0) step = 0;
}
if (on_text && !ShiftDown){
if (b_text_rows > b_text_visable_rows){
if (delta < 0) {s_text = b_text_rows - s_text <= b_text_visable_rows ? b_text_rows - b_text_visable_rows : s_text += 1}
if (delta > 0) {s_text = s_text <= 0 ? 0 : s_text -= 1}
}
}
if (on_text && ShiftDown && !delay){
delay = true;
fdelay();
if (delta < 0) {font_size_b = font_size_b <= min_font_size ? min_font_size : font_size_b - 2;};
if (delta > 0) {font_size_b = font_size_b >= max_font_size ? max_font_size : font_size_b + 2;};
window.SetProperty("font size: biography", font_size_b);
get_font();
old_string_width = 0;
get_b_text_array();
}
if (set_cycle && on_pic) {
if (delta < 0) {cycle = cycle <= 0 ? 0 : cycle - 5;};
if (delta > 0) {cycle = cycle >= 60 ? 60 : cycle + 5;};
window.SetProperty("auto cycle (sec)", cycle);
}
window.Repaint();
}
//var pic_posx = 0; //****
//var c_selected; //****
function on_mouse_lbtn_down(x,y){
//on_text = x >= txt_x && x < ww && y >= txt_y && y <= b_y ? true : false; //****
//on_sb = x >= txt_x && x < ww && y >= b_y ? true : false; //****
//on_pic = !on_text && !on_sb ? true : false; //****
//if (on_pic){ //****
// pic_posx = x; //****
// c_selected = selected; //****
//} //****
if (on_text){
on_text_down = true;
delta_x = x - txt_x;
delta_y = y - txt_y;
}
if (on_sb){
on_sb_down = true;
sb_posy = s_text * scrollbar_k;
delta_y = sb_posy - y;
}
}
function on_mouse_lbtn_up(x,y){
window.SetProperty("txt_x", txt_x);
window.SetProperty("txt_y", txt_y);
on_text_down = false;
on_sb_down = false;
//on_pic = false; //****
}
function on_mouse_lbtn_dblclk (x,y){
if (on_text){
abc = abc == 1 ? 0 : 1;
window.SetProperty("abc", abc);
s_text = 0;
b_text_array = [];
text = "";
get_lastFM_b_text();
}
try {
if (on_pic && images[selected]) WshShell.run( '"' + artist_folder_path(artist)+ "\\" + clean_name(artist) + "_" + selected + "_" + p_a[select_p_a] + ".jpg" + '"' );
} catch(e) {}
}
function on_mouse_leave() {
window.SetCursor(32512);
}
function on_size(){
ww = window.Width;
wh = window.Height;
txt_x = window.GetProperty("txt_x");
txt_y = window.GetProperty("txt_y");
txt_x = txt_x >= ww - 50 && txt_x >= 0 ? ww - 50 : txt_x;
txt_y = txt_y >= wh - (a_text_row_height + t_margin * 2) && txt_y >= 0 ? wh - (a_text_row_height + t_margin * 2) : txt_y;
get_b_text_array();
}
function del_folders(){
dir = fso.GetFolder(tmp_b_path);
var e = new Enumerator( dir.SubFolders );
try {
for(; !e.atEnd(); e.moveNext() ) {
var name = e.item().Name;
if (name.indexOf("_download") < 0){
if (name.indexOf(clean_name(artist)) < 0){
fso.deleteFolder(tmp_b_path + name);
}
}
}
} catch(e) {};
}
function calc_img_size(img){
var size = {x:0, y:0, width:0, height:0, cx:0, cy:0, cwidth:0, cheight:0};
switch(align_mode) {
case 0: // adjust
var sw = ww / img.Width;
var sh = wh / img.Height;
var s = Math.min(sw, sh);
var x = 0;
var y = 0;
if (sw > sh) x = (ww - img.Width * s) / 2;
else if (sw < sh) y = (wh - img.height * s) / 2;
var width = img.Width * s;
var height = img.Height * s;
var cx = 0;
var cy = 0;
var cwidth = img.Width;
var cheight = img.Height;
break;
case 1: // adjust top - center
var sw = ww / img.Width;
var sh = wh / img.Height;
var s = Math.min(sw, sh);
var x = 0;
if (sw > sh) x = (ww - img.Width * s) / 2;
var y = 0;
var width = img.Width * s;
var height = img.Height * s;
var cx = 0;
var cy = 0;
var cwidth = img.Width;
var cheight = img.Height;
break;
case 2: // adjust top - left
var sw = ww / img.Width;
var sh = wh / img.Height;
var s = Math.min(sw, sh);
var x = 0;
var y = 0;
var width = img.Width * s;
var height = img.Height * s;
var cx = 0;
var cy = 0;
var cwidth = img.Width;
var cheight = img.Height;
break;
case 3: // centre
var sr = img.Width / img.Height;
var dr = ww / wh;
if (sr < dr) {
var r = img.Width / ww;
var cheight = wh * r;
var cy = Math.round((img.Height - cheight) / 2);
var cwidth = img.Width;
var cx = 0;
} else {
var r = img.Height / wh;
var cwidth = ww * r;
var cx = Math.round((img.Width - cwidth) / 2);
var cheight = img.Height;
var cy = 0;
}
var x = 0;
var y = 0;
var width = ww;
var height = wh;
break;
case 4: // centre - top
var sr = img.Width / img.Height;
var dr = ww / wh;
if (sr < dr) {
var r = img.Width / ww;
var cheight = wh * r;
var cy = 0;
var cwidth = img.Width;
var cx = 0;
} else {
var r = img.Height / wh;
var cwidth = ww * r;
var cx = Math.round((img.Width - cwidth) / 2);
var cheight = img.Height;
var cy = 0;
}
var x = 0;
var y = 0;
var width = ww;
var height = wh;
break;
case 5: // stretch
var x = 0;
var y = 0;
var width = ww;
var height = wh;
var cx = 0;
var cy = 0;
var cwidth = img.Width;
var cheight = img.Height;
break;
}
size.x = x + p_margin;
size.y = y + p_margin;
size.width = width - p_margin * 2;
size.height = height - p_margin * 2;
size.cx = cx;
size.cy = cy;
size.cwidth = cwidth;
size.cheight = cheight;
return size;
}
function copy_files(){
var save_images_state = save_images;
if (!save_images_state) save_images = true;
var tmp_files = files;
var tmp_artist = artist;
var tmp_p_a = p_a[select_p_a];
var tmp_directory_path;
if (path.indexOf('://') > 0 || path.indexOf('youtube') == 0 || path.indexOf('cdda') == 0) {
tmp_directory_path = fb.ProfilePath + tmp_p_a + "\\";
} else {
tmp_directory_path = directory_path + "\\" + tmp_p_a + "\\";
}
var nl = "\" + chr(10) + \"";
var input_box_text = "Copy " + nl + nl + tmp_artist + " " + tmp_p_a + nl + "files to";
var destination_folder = input_box(input_box_text, tmp_directory_path, "Copy files...");
if (destination_folder){
destination_folder = clean_path_name(destination_folder);
ppp = destination_folder;
folder_exists(destination_folder);
copy_files_to_folder(destination_folder, tmp_files, tmp_p_a);
}
save_images = save_images_state;
}
function copy_files_to_folder(p, f, pa){
if (p.length != "\\"){p = p + "\\"}
for (i in f) {
if (f[i].indexOf(pa) > 0){
try {
fso.CopyFile (f[i], p , 1 );
} catch(e) {}
}
}
}
function input_box(p_text, d_text, w_title){
vbe = new ActiveXObject('ScriptControl');
vbe.Language = 'VBScript';
return vbe.eval( "InputBox(\"" + p_text + "\",\"" + w_title + "\",\"" + d_text + "\")");
}
function clean_path_name(n) {
return n.replace(/[\/\*\?\"\<\>\|]/g,'');
}
function folder_exists(n) {
if (n.length != "\\"){n = n + "\\"}
for (var i = 3; i < n.length; i += 1) {
if (n[i] == "\\"){
if(!fso.FolderExists(n.substr(0, i))) {fso.CreateFolder(n.substr(0, i))};
}
}
}
а строкаSatansoft:не функционален
//@import "D:\Program Files\foobar2000\skins\ZiX+\Scrollbar\scrollbar.js"
если нужен относительный, то при установленном foo_ui_hacks попробуй записатьSatansoft:абсолютного пути
// ==PREPROCESSOR==
// @name "Biography Text && Picture. www.last.fm"
// @author "kgena_ua"
// @version "09042016"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==
//San_dr edition
DT_LEFT = 0x00000000;
DT_RIGHT = 0x00000002;
DT_CENTER = 0x00000001;
DT_WORD_ELLIPSIS = 0x00040000;
DT_CALCRECT = 0x00000400;
DT_NOPREFIX = 0x00000800;
var ww,wh;
var a_font = gdi.Font("Arial",13, 1);
var b_font = gdi.Font("tahoma",14);
var cycle = window.GetProperty("auto cycle (sec)", 10);
var b_color = 0, t_color = 0, s_color = 0;
var g_is_default_ui = window.InstanceType;
function get_colors() {
s_color = utils.GetSysColor(15);
if (g_is_default_ui) { // DUI
t_color = window.GetColorDUI(0);
b_color = window.GetColorDUI(1);
hi_color = window.GetColorDUI(2);
sel_color = window.GetColorDUI(3);
} else { // CUI
t_color = window.GetColorCUI(0);
b_color = window.GetColorCUI(3);
hi_color = window.GetColorCUI(6);
sel_color = window.GetColorCUI(1);
}
}
get_colors();
function on_colors_changed() {
get_colors();
window.Repaint();
}
var fso = new ActiveXObject("Scripting.FileSystemObject");
var tmp_b_path = fb.ProfilePath + "\\tmp_Biography\\";
if (!fso.FolderExists(tmp_b_path)) {fso.CreateFolder(tmp_b_path)};
var script_path = tmp_b_path + "_download\\";
if (!fso.FolderExists(script_path)) {fso.CreateFolder(script_path)};
if (!fso.FileExists(script_path + "download.vbs")) {create_download_file()};
var doc = new ActiveXObject("htmlfile");
var WshShell = new ActiveXObject("WScript.Shell");
var vbs = "cscript //nologo \"" + script_path + "download.vbs\"";
var nocover_path = window.GetProperty("nocover path",".\\images\\No cover.png");
var n_img = gdi.Image(".\\images\\wait cover.png");
var nocover = window.GetProperty("nocover image", false);
var panel_Art = 16;
var logo_img = gdi.Image(script_path + "last_fm_logo.jpg");
var artist, old_artis;
var path, directory_path;
var g_img = null;
var align_mode = window.GetProperty("align mode", 0);
var info = window.GetProperty("info", false);
var selected = 0;
var files = [];
var images = [];
var found = 0;
var save_images = window.GetProperty("save images", false);
var limit = window.GetProperty("download limit",6);
var cycle = window.GetProperty("auto cycle (sec)", 15);
set_cycle_timer();
var fader = 5;
var fade_effect = window.GetProperty("fade effect", true);
var fade_step = window.GetProperty("fade step", 5);
var on_pic = false;
var scrollbar_k;
var sb_posy = 0;
var on_sb = false;
var on_sb_down = false;
var text = "";
var s_text = 0;
var old_string_width = 0;
var b_text_row_height = 0;
var b_text_rows = 0;
var b_text_visable_rows = 0;
var b_text_visable_height = 0;
var b_text_array = [];
var on_artist = false;
var on_text = false;
var abc_lang = new Array("", "ru/");
var abc;
var if_not_found = new Array(". . .", ". . .");
var select_p_a = window.GetProperty("pictures/albums", 0);
var p_a = new Array("images", "albums");
var selection_mode = window.GetProperty("selection mode", 0);
var metadb;
on_item_focus_change();
function clean_name(n) {
return n.replace(/[\/\:\*\?\"\<\>\|]/g,' ');
}
function artist_folder_path(n) {
return tmp_b_path + clean_name(n);
}
function check_folder(n) {
if(!fso.FolderExists(n)) {fso.CreateFolder(n)};
}
function on_paint(gr){
gr.FillGradRect(0, 0, ww, window.Height, 120,0x77708040,0xccf0eebb,.4);
gr.FillGradRect(0, 0, ww-10, window.Height, -90,0x00000000,0x60faeebb);
gr.FillGradRect(ww-16,0,16,window.Height,0,0x00000000,0x40441600);
gr.FillSolidRect(ww-16,0,1,window.Height,0x60faeebb);
gr.FillSolidRect(0,0,ww,15,0x77304022)
gr.FillSolidRect(ww-29,0,22,13,t_color);
if(abc==1) {
gr.FillSolidRect(0,0,23,15,0xffa04000),
gr.GdiDrawText(" РУ", b_font, s_color, -5, -1, ww, 20, DT_LEFT | DT_CALCRECT);
} else
gr.FillSolidRect(0,0,23,15,t_color),
gr.GdiDrawText(" EN", b_font, s_color, -5, -1, ww, 20, DT_LEFT | DT_CALCRECT);
gr.GdiDrawText("— " + artist + " —", a_font, t_color,-1, 0, ww, 18, DT_CENTER | DT_CALCRECT);
gr.GdiDrawText("— " + artist + " —", a_font, t_color,-1, -2, ww, 16, DT_CENTER | DT_CALCRECT);
gr.GdiDrawText("— " + artist + " —", a_font, t_color,+1, 0, ww, 16, DT_CENTER | DT_CALCRECT);
gr.GdiDrawText("— " + artist + " —", a_font, t_color,+1, -2, ww, 16, DT_CENTER | DT_CALCRECT);
gr.GdiDrawText("— " + artist + " —", a_font, s_color,0, -1, ww, 16, DT_CENTER | DT_CALCRECT);
if (select_p_a <1){
gr.GdiDrawText("Art ", b_font, s_color,-2, -1, ww, 16, DT_RIGHT | DT_CALCRECT);
} else
gr.GdiDrawText("Alb ", b_font, s_color,-2, -1, ww, 16, DT_RIGHT | DT_CALCRECT);
paint(gr);
draw_scrollbar(gr);
}
function paint(gr){
if (g_img){
var size = calc_img_size(g_img);
var scale_w = (ww - 6) / g_img.Width;
var scale_h = wh / g_img.Height;
var scale = Math.min(scale_w, scale_h);
var x_txt = 2*ww/3-8;
var DXT = ww-x_txt;
IH=g_img.Height * scale;
IW=g_img.Width * scale;
gr.FillSolidRect(0, panel_Art,align_mode>0 ? ww-6 : IW , align_mode>0 ? wh : IH,0xb0000000);
gr.DrawImage(g_img, 0, panel_Art, size.width, size.height, size.cx, size.cy, size.cwidth, size.cheight, 0, images.length > 0 ? fader : 90);
if (b_text_rows>0 && IW>2*ww/3-13){
gr.FillSolidRect(2*ww/3-10, panel_Art, align_mode > 0 ? ww : IW-2*ww/3+10, align_mode>0 ? wh : IH<b_text_row_height*b_text_rows+4 ?IH:b_text_row_height*b_text_rows+14 , 0xb0fcffcf);
for (var i = 0; i < b_text_visable_rows * 2; i += 2) {
try {
txt=b_text_array[i + s_text * 2].replace(/^\s+|\s+$/g, "");
y_txt=panel_Art + b_text_row_height * i/2;
gr.GdiDrawText(txt, b_font, s_color, x_txt+2, y_txt , DXT, IH, DT_LEFT | DT_NOPREFIX ),
gr.GdiDrawText(txt, b_font, s_color, x_txt-2, y_txt , DXT, IH, DT_LEFT | DT_NOPREFIX ),
gr.GdiDrawText(txt, b_font, s_color, x_txt, y_txt -2, DXT, IH, DT_LEFT | DT_NOPREFIX ),
gr.GdiDrawText(txt, b_font, s_color, x_txt+1, y_txt -1, DXT, IH, DT_LEFT | DT_NOPREFIX ),
gr.GdiDrawText(txt, b_font, s_color, x_txt-1, y_txt -1, DXT, IH, DT_LEFT | DT_NOPREFIX ),
gr.GdiDrawText(txt, b_font, s_color, x_txt, y_txt +2, DXT, IH, DT_LEFT | DT_NOPREFIX ),
gr.GdiDrawText(txt, b_font, s_color, x_txt+1, y_txt +1, DXT, IH, DT_LEFT | DT_NOPREFIX ),
gr.GdiDrawText(txt, b_font, s_color, x_txt-1, y_txt +1, DXT, IH, DT_LEFT | DT_NOPREFIX ),
gr.GdiDrawText(txt, b_font, 0xff000000, x_txt, y_txt , DXT, wh, DT_LEFT | DT_NOPREFIX );
gr.GdiDrawText(txt, b_font, 0xff000000, x_txt, y_txt , DXT, wh, DT_LEFT | DT_NOPREFIX );
} catch(e) {}
}
}else if (b_text_rows>0){
align_mode > 0 ? gr.FillSolidRect(2*ww/3-10, panel_Art, ww/3, wh , 0xb0fcffcf) : "";
for (var i = 0; i < b_text_visable_rows * 2; i += 2) {
gr.GdiDrawText(b_text_array[i+ s_text * 2], b_font, 0xff000000, x_txt, panel_Art + b_text_row_height * i/2 , DXT, wh, DT_LEFT | DT_NOPREFIX );
}
}
}
if (images.length == 0 && !nocover){
gr.DrawImage(logo_img, 92, panel_Art+132, logo_img.Width * 3, logo_img.Height * 3, 0, 0, logo_img.Width, logo_img.Height, 0, 80);
}
if (images.length == 0 && nocover){
try {
nc_img = gdi.Image(nocover_path);
if (b_text_rows > b_text_visable_rows)gr.DrawImage(n_img, 0, panel_Art, ww, window.Height, 0, 0, nc_img.Width, nc_img.Height, 0, 80);
else gr.DrawImage(nc_img, 0, panel_Art, ww, window.Height, 0, 0, nc_img.Width, nc_img.Height, 0, 80);
} catch(e) {};
}
}
function draw_scrollbar(gr){
scrollbar_h = b_text_rows > b_text_visable_rows ? b_text_visable_height * (b_text_visable_rows / b_text_rows) : 0;
if (b_text_rows > b_text_visable_rows){ scrollbar_h = Math.max(7, scrollbar_h)}
scrollbar_y = s_text > 0 ? s_text * scrollbar_k : 0;
gr.FillGradRect(ww - 7, b_y + scrollbar_y, 5, scrollbar_h, 90,t_color,s_color,.5);
}
function on_playlist_switch() {
on_item_focus_change();
}
function on_playback_new_track() {
on_item_focus_change();
}
function on_playback_dynamic_info_track() {
on_item_focus_change();
}
function on_playback_stop() {
on_item_focus_change();
}
function on_selection_changed(metadb) {
on_item_focus_change();
}
function on_item_focus_change() {
switch (selection_mode) {
case 0:
metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
break;
case 1:
metadb = fb.GetFocusItem();
break;
}
if (metadb) on_metadb_changed();
abc=1,t=0;
}
function Eval(field) {
if (!metadb) return;
path = fb.Titleformat("%path%").EvalWithMetadb(metadb);
directory_path = fb.Titleformat("$directory_path(%path%)").EvalWithMetadb(metadb);
return path.indexOf('://') > 0 ? fb.TitleFormat("[" + field + "]").Eval() : fb.TitleFormat("[" + field + "]").EvalWithMetadb(metadb);
//return fb.Titleformat("[" + field + "]").EvalWithMetadb(metadb) ? fb.TitleFormat("[" + field + "]").EvalWithMetadb(metadb) : fb.TitleFormat("[" + field + "]").Eval(true);
}
function on_metadb_changed() {
if (!metadb) return;
artist = Eval("%artist%").replace(/^\s+|\s+$/g, "");
if (artist != old_artis){
if (!save_images) del_folders();
s_text = 0;
text = "";
old_string_width = 0;
get_b_text_array()
get_lastFM_b_text();
//get_text();
g_img = null;
files = [];
images = [];
found = 0;
selected = 0;
get_pic();
old_artis = artist;
}
}
function get_pic() {
if (!artist) return;
check_folder(artist_folder_path(artist));
get_files_from_dir(artist_folder_path(artist));
if (!g_img && images.length > 0) {
next_image(0);
} else {
get_lastFM_pic(artist_folder_path(artist));
}
}
function get_lastFM_pic(p){
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP");
url1 = ("http://www.last.fm/music/" + encodeURIComponent(artist) + "/+" + p_a[select_p_a]);
xmlhttp1.open("GET", url1, true);
xmlhttp1.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
xmlhttp1.send(null);
xmlhttp1.onreadystatechange = function () {
if (xmlhttp1.readyState == 4) {
if (xmlhttp1.status == 200) {
doc.open();
var div = doc.createElement("div");
div.innerHTML = xmlhttp1.responsetext;
var data = div.getElementsByTagName("img");
var data2 = div.getElementsByTagName("div");
var urls = [];
for (i = 0; i < data.length; i++) {
if (data[i].className == "image-list-image" && select_p_a == 0){
if (data[i].src.indexOf("http://img2-ak.lst.fm/i/u/avatar170s") == 0) {
urls.push(data[i].src.replace("avatar170s", "770x0"));
}
}
if (data[i].className == "album-grid-album-art" && select_p_a == 1){
if (data[i].src.indexOf("http://img2-ak.lst.fm/i/u/300") == 0 && data[i].src.indexOf("c6f59c1e5e7240a4c0d427abd71f3dbb") < 0) {
urls.push(data[i].src.replace("300", ""))
}
}
}
found = Math.min(urls.length, limit); window.Repaint();
for (i = 0; i < Math.min(urls.length, limit); i++) {
file = "\"" + p + "\\" + clean_name(artist) + "_" + i + "_" + p_a[select_p_a] + ".jpg" + "\"";
WshShell.Run(vbs + " " + urls[i] + " " + file, false);
}
doc.close();
if (found > 0) get_files_if_loaded();
}
}
}
}
function get_files_from_dir(p) {
if (!artist) return;
p = p + "\\";
images = [];
files = utils.Glob(p + "*.*").toArray();
for (i in files) {
if (files[i].indexOf(clean_name(artist)) > 0 && files[i].indexOf(p_a[select_p_a]) > 0){
try {
images.push(get_images(gdi.Image(files[i])));
} catch(e) {}
}
}
}
function next_image(d){
fader = 5;
if (d < 0) {selected = selected <= 0 ? images.length - 1 : selected = selected - 1};
if (d > 0) {selected = selected >= images.length - 1 ? 0 : selected = selected + 1};
g_img = images[selected];
if (g_img) fader_timer();
window.Repaint();
}
function get_images(img){
if (!img) return;
var scale_w = (window.Width - 7) / img.Width;
var scale_h = (window.Height - panel_Art) / img.Height;
var scale = Math.min(scale_w, scale_h);
var nww = img.Width * scale;
var nwh = img.Height * scale
var temp_bmp = gdi.CreateImage(nww, nwh);
var temp_gr = temp_bmp.GetGraphics();
temp_gr.SetSmoothingMode(2);
temp_gr.SetInterpolationMode(7);
temp_gr.DrawImage(img, 0, 0, nww, nwh, 0, 0, img.width, img.height);
temp_bmp.ReleaseGraphics(temp_gr);
CollectGarbage();
return temp_bmp;
temp_bmp.Dispose();
temp_gr = null;
temp_bmp = null;
}
t=0;
function get_lastFM_b_text(){
xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
url2 = ("http://www.last.fm/" + abc_lang[abc] + "music/" + encodeURIComponent(artist) + "/+wiki");
xmlhttp2.open("GET", url2, true);
xmlhttp2.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
xmlhttp2.send(null);
xmlhttp2.onreadystatechange = function () {
if (xmlhttp2.readyState == 4) {
if (xmlhttp2.status == 200) {
doc.open();
var div = doc.createElement("div");
div.innerHTML = xmlhttp2.responsetext;
var data = div.getElementsByTagName("div");
for (i = 0; i < data.length; i++) {
if (data[i].className == "wiki-content") {
text = strip_tags(data[i].innerHTML);
break;
}
}
doc.close();
}
if (text == "" && t==0) {
abc = abc == 1 ? 0 : 1;
s_text = 0;
b_text_array = [];
text = "";
get_lastFM_b_text();
old_string_width = 0;
t = 1;
}
old_string_width = 0;
get_b_text_array();
}
}
t=0;
}
function strip_tags(t) {
doc.open();
var div = doc.createElement("div");
div.innerHTML = t.replace(/<[Pp][^>]*>/g, "").replace(/<\/[Pp]>/g, "<br>").replace(/\n/g, "<br>");
var text = div.innerText;
doc.close();
return text;
}
function get_b_text_array() {
temp_bmp = gdi.CreateImage(1, 1);
temp_gr = temp_bmp.GetGraphics();
b_text_row_height = temp_gr.CalcTextHeight("text", b_font);
b_y = b_text_row_height;
string_width = ww/3+2;
if (old_string_width != string_width){
b_text_array = [];
if (text) b_text_array = temp_gr.EstimateLineWrap(text, b_font, string_width).toArray();
old_string_width = string_width;
}
b_text_rows = b_text_array.length / 2;
b_text_visable_height = Math.round(Math.max(0, wh - b_y))+9;
b_text_visable_rows = Math.round(b_text_visable_height / b_text_row_height);
if (b_text_visable_rows + s_text > b_text_rows && s_text > 0) {
s_text = (b_text_rows - b_text_visable_rows);
};
scrollbar_k = b_text_visable_height / b_text_rows;
temp_bmp.ReleaseGraphics(temp_gr);
temp_bmp.Dispose();
temp_gr = null;
temp_bmp = null;
window.Repaint();
}
function on_mouse_rbtn_up (x, y){
var _menu = window.CreatePopupMenu();
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
MF_SEPARATOR = 0x00000800;
_menu.AppendMenuItem(MF_ENABLED, 10, "EN text");
_menu.AppendMenuItem(MF_ENABLED, 11, "РУ текст");
_menu.CheckMenuRadioItem(10, 11, abc + 10);
_menu.EnableMenuItem(abc + 10, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 12, "Предпочитать воспроизводимый трек");
_menu.AppendMenuItem(MF_ENABLED, 13, "Следовать за выбранным треком");
_menu.CheckMenuRadioItem(12, 13 , selection_mode + 12);
_menu.EnableMenuItem(selection_mode + 12, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 14, "Фото исполнителя");
_menu.AppendMenuItem(MF_ENABLED, 15, "Обложки альбома");
_menu.CheckMenuRadioItem(14, 15 , select_p_a + 14);
_menu.EnableMenuItem(select_p_a + 14, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
var is_artist = artist ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(is_artist, 16, "last.fm Artist");
var _firstgroup = window.CreatePopupMenu();
_menu.AppendMenuItem(MF_ENABLED, 20, "Как есть");
_menu.AppendMenuItem(MF_ENABLED, 21, "Во всю ширину");
_menu.CheckMenuRadioItem(20, 21 , align_mode + 20);
_menu.EnableMenuItem(align_mode + 20,1);
var MF_ = images.length > 0 ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_, 30, "Скопировать в папку трека...");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 40, "Сохранять изображения");
_menu.CheckMenuItem(40, save_images);
//_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 100, "Перезапустить");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 110, "Уставки");
_menu.AppendMenuItem(MF_ENABLED, 120, "Редактировать скрипт...");
ret = _menu.TrackPopupMenu(x,y);
switch (ret) {
case 10:
abc = 0;
window.SetProperty("EN/РУ", abc);
s_text = 0;
text = "";
get_lastFM_b_text();
break;
case 11:
abc = 1;
window.SetProperty("EN/РУ", abc);
s_text = 0;
text = "";
get_lastFM_b_text();
break;
case 12:
selection_mode = 0;
window.SetProperty("selection mode", selection_mode);
on_item_focus_change();
break;
case 13:
selection_mode = 1;
window.SetProperty("selection mode", selection_mode);
on_item_focus_change();
break;
case 14:
select_p_a = 0;
window.SetProperty("pictures/albums", select_p_a);
g_img = null;
files = [];
images = [];
found = 0;
selected = 0;
window.Repaint();
get_pic();
break;
case 15:
select_p_a = 1;
window.SetProperty("pictures/albums", select_p_a);
g_img = null;
files = [];
images = [];
found = 0;
selected = 0;
window.Repaint();
get_pic();
break;
case 16:
WshShell.run("http://www.last.fm/" + abc_lang[abc] + "music/" + encodeURIComponent(artist));
break;
case 20:
case 21:
align_mode = ret - 20;
window.SetProperty("align mode", align_mode);
window.Repaint();
break;
case 30:
copy_files();
break;
case 40:
window.SetProperty("Save images", !save_images);
save_images = window.GetProperty("Save images");
break;
case 100:
break;
case 110:
window.ShowProperties();
break;
case 120:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}
var timer;
function get_files_if_loaded(){
timer && window.ClearInterval(timer);
timer = window.SetInterval(function() {
get_files_from_dir(artist_folder_path(artist));
if (!g_img && images.length > 0) next_image(0);
if (found > 0 && images.length == found) {
window.ClearInterval(timer);
}
window.Repaint();
}, 500 );
}
var set_cycle = false;
var cycle_timer, step = 0;
function set_cycle_timer(){
cycle_timer && window.ClearInterval(cycle_timer);
cycle_timer = window.SetInterval(function() {
step = step + 1;
if ( step >= cycle){
if (images.length > 1){
next_image(1);
window.Repaint();
step = 0;
}
}
window.Repaint();
}, 1000 );
}
var delay = false;
function fdelay(){
var delay_timer = window.SetTimeout(function() {
delay = false;
window.ClearTimeout(delay_timer);
}, 200);
}
var ftimer;
function fader_timer(){
fader = 0;
ftimer && window.ClearInterval(ftimer);
ftimer = window.SetInterval(function() {
fader = fader + 5;
if (fader >= 255) {
fader= 255;
window.ClearInterval(ftimer);
}
window.Repaint();
}, 10 );
}
function load_last_fm_logo(){
if(!fso.FileExists(script_path + "last_fm_logo.jpg")) {
var url = "http://www.last.fm/static/images/logo_beta.png?eb6d3ca20e73"
var file = "\"" + script_path + "last_fm_logo.jpg" + "\"";
WshShell.Run(vbs + " " + url + " " + file, false);
var url = "http://static-web.last.fm/static/images/favicon.702b239b6194.ico"
var file = "\"" + script_path + "last_fm_ico.ico" + "\"";
WshShell.Run(vbs + " " + url + " " + file, false);
}
}
function create_download_file() {
try {
file = fso.CreateTextFile(script_path + "download.vbs" )
var text =
"If (WScript.Arguments.Count <> 2) Then" + "\n\r" +
" WScript.Quit" + "\n\r" +
"End If" + "\n\r" + "\n\r" +
"url = WScript.Arguments(0)" + "\n\r" +
"file = WScript.Arguments(1)" + "\n\r" + "\n\r" +
"Set objFSO = Createobject(" + '"Scripting.FileSystemObject"' + ")" + "\n\r" +
"If objFSO.Fileexists(file) Then" + "\n\r" +
" Set objFSO = Nothing" + "\n\r" +
" WScript.Quit" + "\n\r" +
"End If" + "\n\r" + "\n\r" +
"Set objXMLHTTP = CreateObject(" + '"MSXML2.XMLHTTP"' + ")" + "\n\r" +
"objXMLHTTP.open " + '"GET"' + ", url,false" + "\n\r" +
"objXMLHTTP.send()" + "\n\r" + "\n\r" +
"If objXMLHTTP.Status = 200 Then" + "\n\r" +
" Set objADOStream = CreateObject(" + '"ADODB.Stream"' + ")" + "\n\r" +
" objADOStream.Open" + "\n\r" +
" objADOStream.Type = 1" + "\n\r" +
" objADOStream.Write objXMLHTTP.ResponseBody" + "\n\r" +
" objADOStream.Position = 0" + "\n\r" +
" objADOStream.SaveToFile file" + "\n\r" +
" objADOStream.Close" + "\n\r" +
" Set objADOStream = Nothing" + "\n\r" +
"End If" + "\n\r" + "\n\r" +
"Set objFSO = Nothing" + "\n\r" +
"Set objXMLHTTP = Nothing"
;
file.WriteLine(text);
file.Close();
} catch(e) {};
}
function on_mouse_move(x, y) {
window.SetCursor(32649);
on_text = x >= 2*ww/3 && x < ww - 20 && y >= panel_Art ? true : false;
on_sb = x > ww - 20 && y >= panel_Art ? true : false;
on_pic = !on_text && !on_sb ? true : false;
if (on_sb_down && b_text_rows > b_text_visable_rows){
sb_posy = y + delta_y;
s_text = y + delta_y >= 0 ? y + delta_y <= (b_text_rows - b_text_visable_rows) * scrollbar_k ? Math.round(sb_posy / scrollbar_k) : b_text_rows - b_text_visable_rows : 0;
window.Repaint();
}
}
function on_mouse_wheel(delta) {
if (on_pic && !delay && images.length > 1){
delay = true;
fdelay();
next_image(delta);
step = 0;
}
if (on_text){
if (b_text_rows > b_text_visable_rows){
if (delta < 0) {s_text = b_text_rows - s_text <= b_text_visable_rows ? b_text_rows - b_text_visable_rows : s_text += 1}
if (delta > 0) {s_text = s_text <= 0 ? 0 : s_text -= 1}
}
}
window.Repaint();
}
function on_mouse_lbtn_down(x,y){
if (on_sb){
on_sb_down = true;
sb_posy = s_text * scrollbar_k;
delta_y = sb_posy - y;
}
}
function on_mouse_lbtn_up(x,y){
on_sb_down = false;
}
function on_mouse_lbtn_dblclk (x,y){
/* if (on_text){
abc = abc == 1 ? 0 : 1;
window.SetProperty("EN/РУ", abc);
s_text = 0;
b_text_array = [];
text = "";
get_lastFM_b_text();
}*/
try {
if (on_pic && images[selected]) WshShell.run( '"' + artist_folder_path(artist)+ "\\" + clean_name(artist) + "_" + selected + "_" + p_a[select_p_a] + ".jpg" + '"' );
} catch(e) {}
}
function on_mouse_leave() {
window.SetCursor(32512);
}
function on_size(){
ww = window.Width;
wh = window.Height-panel_Art;
get_b_text_array();
}
function del_folders(){
dir = fso.GetFolder(tmp_b_path);
var e = new Enumerator( dir.SubFolders );
try {
for(; !e.atEnd(); e.moveNext() ) {
var name = e.item().Name;
if (name.indexOf("_download") < 0){
if (name.indexOf(clean_name(artist)) < 0){
fso.deleteFolder(tmp_b_path + name);
}
}
}
} catch(e) {};
}
function calc_img_size(img){
var size = {x:0, y:0, width:0, height:0, cx:0, cy:0, cwidth:0, cheight:0};
switch(align_mode) {
case 0: // adjust
var sw = ww-6 / img.Width;
var sh = wh / img.Height;
var s = Math.min(sw, sh);
if (sw > sh) x = (ww-6 - img.Width * s) / 2;
else if (sw < sh) y = (wh - img.height * s) / 2;
var width = img.Width * s;
var height = img.Height * s;
var cx = 0;
var cy = 0;
var cwidth = img.Width;
var cheight = img.Height;
break
case 1: // centre - top
var sr = img.Width / img.Height;
var dr = (ww-6) / wh;
if (sr < dr) {
var r = img.Width / (ww-6);
var cheight = wh * r;
var cy = 0;
var cwidth = img.Width;
var cx = 0;
} else {
var r = img.Height / wh;
var cwidth = (ww-6) * r;
var cx = Math.round((img.Width - cwidth) / 2);
var cheight = img.Height;
var cy = 0;
}
var width = (ww-6);
var height = wh;
break;
}
size.width = width;
size.height = height;
size.cx = cx;
size.cy = cy;
size.cwidth = cwidth;
size.cheight = cheight;
return size;
}
function copy_files(){
var save_images_state = save_images;
if (!save_images_state) save_images = true;
var tmp_files = files;
var tmp_artist = artist;
var tmp_p_a = p_a[select_p_a];
var tmp_directory_path;
if (path.indexOf('://') > 0 || path.indexOf('youtube') == 0 || path.indexOf('cdda') == 0) {
tmp_directory_path = fb.ProfilePath + tmp_p_a + "\\";
} else {
tmp_directory_path = directory_path + "\\" + tmp_p_a + "\\";
}
var nl = "\" + chr(10) + \"";
var input_box_text = "Copy " + nl + nl + tmp_artist + " " + tmp_p_a + nl + "files to";
var destination_folder = input_box(input_box_text, tmp_directory_path, "Copy files...");
if (destination_folder){
destination_folder = clean_path_name(destination_folder);
ppp = destination_folder;
folder_exists(destination_folder);
copy_files_to_folder(destination_folder, tmp_files, tmp_p_a);
}
save_images = save_images_state;
}
function copy_files_to_folder(p, f, pa){
if (p.length != "\\"){p = p + "\\"}
for (i in f) {
if (f[i].indexOf(pa) > 0){
try {
fso.CopyFile (f[i], p , 1 );
} catch(e) {}
}
}
}
function input_box(p_text, d_text, w_title){
vbe = new ActiveXObject('ScriptControl');
vbe.Language = 'VBScript';
return vbe.eval( "InputBox(\"" + p_text + "\",\"" + w_title + "\",\"" + d_text + "\")");
}
function clean_path_name(n) {
return n.replace(/[\/\*\?\"\<\>\|]/g,'');
}
function folder_exists(n) {
if (n.length != "\\"){n = n + "\\"}
for (var i = 3; i < n.length; i += 1) {
if (n[i] == "\\"){
if(!fso.FolderExists(n.substr(0, i))) {fso.CreateFolder(n.substr(0, i))};
}
}
}
// ==PREPROCESSOR==
// @name "Get Covers (Artwork)"
// @author "kgena_ua"
// @version "22032016"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==
//San_dr edition
var font = gdi.Font("Arial",12, 0);
var a_font = gdi.Font("Arial",12, 1);
var b_font = gdi.Font("Arial",12, 0);
var ww,wh;
DT_LEFT = 0x00000000;
DT_RIGHT = 0x00000002;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
DT_WORD_ELLIPSIS = 0x00040000;
var b_color = 0, t_color = 0, s_color = 0;
function get_colors() { ///DUI
t_color = window.GetColorDUI(0);
b_color = window.GetColorDUI(1);
s_color = utils.GetSysColor(15);
}
get_colors();
function on_colors_changed(){
get_colors();
}
function on_size(){
ww = window.Width;
wh = window.Height;
}
var fso = new ActiveXObject("Scripting.FileSystemObject");
var WshShell = new ActiveXObject("WScript.Shell");
var dir_name, album;
var old_dir_name, old_album;
var g_img = null
var cover_name;
var cover_size;
var nocover_path = window.GetProperty("nocover path",".\\images\\no cover.png");
var nocover = window.GetProperty("nocover image", false);
var nocover_transparent = window.GetProperty("nocover transparent (0-255)", 100);
var covers_external = [];
var covers_dir = [];
var covers_root = [];
var covers_root_subs = [];
var covers_dir_subs = [];
var external = [];
var embedded = [];
var covers = [];
var covernumber = 0;
var root_folders = new Array("cover", "covers", "scan", "scans", "artwork", "artworks", "images");
var info = window.GetProperty("info", true);
var set_external = window.GetProperty("external", 1);
var set_embedded = window.GetProperty("embedded", 1);
var set_priority = window.GetProperty("set_priority", 0);
var cycle = window.GetProperty("auto cycle (sec)", 10);
var set_cycle = true;
set_cycle_timer(),fader_timer();
var file_operation = false;
var vbe = new ActiveXObject('ScriptControl');
vbe.Language = 'VBScript';
var delay = false;
var cycle_timer;
var fader = 0;
var selection_mode = window.GetProperty("selection_mode", 0);
var metadb;
on_item_focus_change();
function on_paint(gr) {
// !window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
gr.FillGradRect(0, 0, ww, window.Height, 120,0x77708040,0xccf0eebb,.4);
gr.FillGradRect(0, 0, ww-10, window.Height, -90,0x00000000,0x60faeebb);
gr.FillGradRect(0,0,16,window.Height,0,0x44302040,0x00000000);
gr.FillGradRect(ww-16,0,16,window.Height,0,0x00000000,0x40441600);
gr.FillSolidRect(ww-16,0,1,window.Height,0x50dfdfbf);
paint(gr);
}
function on_playlist_switch() {
on_item_focus_change();
}
function on_playback_new_track() {
on_item_focus_change();
}
function on_playback_dynamic_info_track() {
on_item_focus_change();
}
function on_playback_stop() {
on_item_focus_change();
}
function on_selection_changed(metadb) {
on_item_focus_change();
}
function on_item_focus_change() {
switch (selection_mode) {
case 0:
metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
break;
case 1:
metadb = fb.GetFocusItem();
break;
}
if (metadb) on_metadb_changed();
}
function on_metadb_changed() {
if (metadb){
dir_name = fb.Titleformat("$directory_path(%path%)").EvalWithMetadb(metadb);
album = fb.Titleformat("%album%").EvalWithMetadb(metadb);
if (dir_name != old_dir_name || album != old_album){
covernumber = 0;
old_dir_name = dir_name;
old_album = album
get_covers();
}
}
}
function get_covers() {
g_img = null;
cover_name = "";
cover_size = "";
get_embedded_covers();
get_external_covers(dir_name);
embedded = set_embedded == 1 ? embedded : [];
external = set_external == 1 ? external : [];
covers = [];
if (set_priority == 0) {
covers = covers.concat(external, embedded);
} else {
covers = covers.concat(embedded, external);
}
window.Repaint();
}
function get_embedded_covers() {
embedded = [];
if ( metadb ) {
for (var i = 0; i < 5; i++) {
//0 - front, 1 - back, 2 - disc, 3 - icon, 4 - artist
var temp = utils.GetAlbumArtEmbedded(metadb.RawPath, i);
if (temp) embedded.push(temp);
}
}
}
function get_external_covers(path) {
covers_dir = [];
covers_root = [];
covers_dir_subs = [];
covers_root_subs = [];
covers_external = [];
external = [];
try {
dir = fso.GetFolder(path);
get_covers_from_dir(covers_dir, dir);
root = dir.ParentFolder;
get_covers_from_dir(covers_root, root);
var e = new Enumerator( dir.SubFolders );
for(; !e.atEnd(); e.moveNext() ) {
get_covers_from_dir(covers_dir_subs, e.item() );
}
var e = new Enumerator( root.SubFolders );
for(; !e.atEnd(); e.moveNext() ) {
var name = e.item().Path;
var sub_root_name = name.substr(name.lastIndexOf("\\") + 1, name.length);
for (i in root_folders) {
if (sub_root_name.toLowerCase() == root_folders[i].toLowerCase()) {
get_covers_from_dir(covers_root_subs, e.item() );
}
}
}
} catch(e) {};
covers_external = covers_external.concat(covers_dir, covers_root, covers_dir_subs, covers_root_subs);
if (covers_external.length > 0) {
for (i in covers_external) {
var name = covers_external[i];
if (get_file_name(name).toLowerCase() == album.toLowerCase() || name.match(/.*(cover|front|folder|album).*\.(jpg|jpeg|gif|png)$/i )) {
external.push(name);
covers_external[i] = null;
}
}
for (i in covers_external) {
if (typeof(covers_external[i]) == 'string' ) external.push(covers_external[i]);
}
}
}
function get_covers_from_dir(array, dir) {
var e = new Enumerator( dir.Files );
while (!e.atEnd()) {
var name = e.item().Name;
if (name.match(/\.(jpg|jpeg|png|gif|bmp|tiff)$/i)) {
array.push( e.item().Path );
}
e.moveNext();
}
}
function get_file_name(n) {
if (!n) return;
var file_name_ext = n.substr(n.lastIndexOf("\\") + 1, n.length);
var file_name = file_name_ext.substr(0, file_name_ext.length - 4);
return file_name;
}
function Eval(field) {
if (!metadb) return;
path = fb.Titleformat("%path%").EvalWithMetadb(metadb);
//return path.indexOf('://') > 0 ? fb.TitleFormat("[" + field + "]").Eval() : fb.TitleFormat("[" + field + "]").EvalWithMetadb(metadb);
return fb.Titleformat("[" + field + "]").EvalWithMetadb(metadb) ? fb.TitleFormat("[" + field + "]").EvalWithMetadb(metadb) : fb.TitleFormat("[" + field + "]").Eval(true);
}
function paint(gr){
if (typeof covers[covernumber] == 'object' ) {
g_img = covers[covernumber];
} else {
g_img = gdi.Image(covers[covernumber]);
}
if (g_img){
var scale_w = ww / g_img.Width;
var scale_h = wh / g_img.Height;
var scale = Math.min(scale_w, scale_h);
var pos_x = 0, pos_y = 0;
if (scale_w < scale_h) pos_y = (wh - g_img.height * scale) / 2;
else if (scale_w > scale_h) pos_x = (ww - g_img.Width * scale) / 2;
gr.FillSolidRect(pos_x, 0, g_img.Width * scale, g_img.Height * scale,0xa0000000);
gr.DrawImage(g_img, pos_x, 0, g_img.Width * scale, g_img.Height * scale, 0, 0, g_img.Width, g_img.Height, 0, covers.length>1 ? fader : 255);
var txt_cycle = cycle == 0 ? "off" : cycle + " sec";
gr.DrawRoundRect(pos_x, 0, g_img.Width * scale, g_img.Height * scale, 1, 1, 1,s_color);
} else g_img = gdi.Image(nocover_path), gr.DrawImage(g_img, 0, 0, window.Width, window.Height, 0, 0, g_img.Width, g_img.Height,0,90);
var text_h = gr.CalcTextHeight("00", font)-1.5;
var text_y = wh - text_h * 3 - 3;
if(info){
!set_cycle
if (covers[covernumber]) {
gr.FillRoundRect(140, text_y , ww-280, wh - text_y, 5, 5, 0x77000000);
if (typeof covers[covernumber] != 'object'){
cover_name = covers[covernumber].substring(covers[covernumber].lastIndexOf("\\") + 1);
}
if (typeof covers[covernumber] == 'object'){
cover_name = "вшитая";
}
gr.GdiDrawText(cover_name, font, b_color, 0, text_y, ww, wh, DT_CENTER | DT_WORD_ELLIPSIS );
try {
cover_size = Math.round( fso.GetFile( covers[covernumber]).size / 1024) + " KB ";
} catch(e) { cover_size = ""};
if (g_img&&covers.length>1) gr.GdiDrawText(g_img.Width + " x " + g_img.Height + " " + cover_size+"auto cycle: " + txt_cycle, font, b_color, 0, text_y + text_h, ww, wh, DT_CENTER | DT_WORD_ELLIPSIS );
else if (g_img)gr.GdiDrawText(g_img.Width + " x " + g_img.Height + " " + cover_size, font, b_color, 0, text_y + text_h, ww, wh, DT_CENTER | DT_WORD_ELLIPSIS );
if (covers.length>1) {
Emb=embedded.length==0 ? "" :embedded.length==1 ? " вшитая" :embedded.length>1 ? " вшитых" :"";
embed=embedded.length==0 ? "" : embedded.length;
Ext=external.length==0 ? "" :external.length==1 ? " внешняя " : " внешних ";
extern=external.length==0 ? "" : external.length;
gr.GdiDrawText(covernumber + 1 + " из " + covers.length + " " + extern + Ext + embed + Emb, font, b_color, 0, text_y + text_h * 2, ww, wh, DT_CENTER | DT_WORD_ELLIPSIS );
}
}
}
}
function on_mouse_lbtn_dblclk (x,y){
if (typeof covers[covernumber] != 'object' ) {
if (covers[covernumber]) WshShell.run( '"' + covers[covernumber] + '"' );
}
}
function on_mouse_wheel(delta) {
if (!delay){
delay = true;
fdelay();
if (delta < 0) {covernumber = covernumber <= 0 ? covers.length - 1 : covernumber = covernumber - 1};
if (delta > 0) {covernumber = covernumber >= covers.length - 1 ? 0 : covernumber = covernumber + 1};
}
window.Repaint();
}
function fdelay(){
var delay_timer = window.SetTimeout(function() {
delay = false;
window.ClearTimeout(delay_timer);
}, 250);
}
function set_cycle_timer(){
window.ClearInterval(cycle_timer);
cycle_timer = window.SetInterval(function() {
fader_timer();
on_mouse_wheel(1);
window.Repaint();
}, 1000*cycle );
}
var ftimer;
function fader_timer(){
fader = 0;
ftimer && window.ClearInterval(ftimer);
ftimer = window.SetInterval(function() {
fader = fader + 5;
if (fader >= 255) {
fader= 255;
window.ClearInterval(ftimer);
}
window.Repaint();
}, 10 );
}
function change_filename(){
var c_file_name = get_file_name(covers[covernumber]);
var n_file_name = vbe.eval("InputBox(\"Enter new file name\",\"Foobar 2000\",\"" + c_file_name + "\")");
if (n_file_name) {
try {
var dir = covers[covernumber].replace(/\\([^\\]*)$/g, '');
var ext = covers[covernumber].replace(/(.*)\.([^\.]*)$/,'$2');
fso.MoveFile( covers[covernumber], dir + "\\" + n_file_name + "." + ext );
get_covers();
for (var i = 0; i < covers.length; i++) {
var name = covers[i];
if (get_file_name(name) == n_file_name) {
covernumber = i;
window.Repaint();
}
}
} catch(e) {}
}
file_operation = false;
}
function delete_file(){
var source = covers[covernumber];
var button_type = is_read_write(source) ? 0x3 : 0x5;
var icon_type = is_read_write(source) ? 0x20 : 0x10;
var second_button_is_default = 0x100;
var btn = WshShell.Popup("Delete file:\n\n" + source, 0, "Foobar 2000", button_type + icon_type + second_button_is_default);
switch (btn) {
case 6:
try{
fso.DeleteFile(source);
covernumber = covernumber == covers.length - 1 ? 0 : covernumber;
get_covers();
window.Repaint();
} catch(e) {}
break;
case 2:
case 7:
break;
case 4:
delete_file();
break;
}
file_operation = false;
}
function change_file_attributes(){
var source = covers[covernumber];
var txt = is_read_write(source) ? "file is \nREAD-WRITE" : "file is \nREAD-ONLY";
var button_type = 0x3;
var icon_type = 0x40;
var btn = WshShell.Popup(source + "\n\n" + txt + "\nchange file attributes ?", 0, "Foobar 2000", button_type + icon_type);
switch (btn) {
case 6:
try{
var file = fso.GetFile(source);
file.Attributes = is_read_write(source) ? 33 : 32;
} catch(e) {}
break;
case 2:
case 7:
break;
}
file_operation = false;
}
function is_read_write(f){
if(fso.FileExists(f)) {
var file = fso.GetFile(f);
var file_attributes = file.Attributes;
return file_attributes == 32 ? true : false;
}
}
function on_mouse_rbtn_up (x, y){
menu = true;
var _menu = window.CreatePopupMenu();
var i = 1;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
MF_SEPARATOR = 0x00000800;
_menu.AppendMenuItem(MF_ENABLED, i++, "External covers");
_menu.CheckMenuItem(i - 1, set_external);
_menu.AppendMenuItem(MF_ENABLED, i++, "Embedded covers");
_menu.CheckMenuItem(i - 1, set_embedded);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, i++, "Priority external");
_menu.AppendMenuItem(MF_ENABLED, i++, "Priority embedded");
_menu.CheckMenuRadioItem(i - 2, i , set_priority + 3);
_menu.EnableMenuItem(set_priority + 3, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, i++, "Prefer now playing");
_menu.AppendMenuItem(MF_ENABLED, i++, "Follow selected track");
_menu.CheckMenuRadioItem(i - 2, i , selection_mode + 5);
_menu.EnableMenuItem(selection_mode + 5, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, i++, "Info");
_menu.CheckMenuItem(i - 1, info);
var MF_ = covers[covernumber] && typeof covers[covernumber] != 'object' ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_, i++, "Open folder");
_menu.AppendMenuItem(MF_, i++, "Rename file");
_menu.AppendMenuItem(MF_, i++, "Delete file");
_menu.AppendMenuItem(MF_, i++, "Change file attributes");
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
// if (ShiftDown) {
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 50, "Reload");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 60, "Properties");
_menu.AppendMenuItem(MF_ENABLED, 70, "Configure ...");
// }
ret = _menu.TrackPopupMenu(x,y);
switch (ret) {
case 1:
set_external = set_external == 0 ? 1 : set_embedded == 0 ? 1 : 0;
window.SetProperty("external", set_external);
get_covers();
break;
case 2:
set_embedded = set_embedded == 0 ? 1 : set_external == 0 ? 1 : 0; ;
window.GetProperty("embedded", set_embedded);
get_covers();
break;
case 3:
set_priority = 0;
window.SetProperty("set_priority", set_priority);
get_covers();
break;
case 4:
set_priority = 1;
window.SetProperty("set_priority", set_priority);
get_covers();
break;
case 5:
selection_mode = 0;
window.SetProperty("selection_mode", selection_mode);
on_item_focus_change();
break;
case 6:
selection_mode = 1;
window.SetProperty("selection_mode", selection_mode);
on_item_focus_change();
break;
case 7:
window.SetProperty("info", !info);
info = window.GetProperty("info");
break;
case 8:
if (covers[covernumber] && typeof covers[covernumber] != 'object') WshShell.run( '"' + covers[covernumber].substring(0, covers[covernumber].lastIndexOf("\\")) + '"' );
break;
case 9:
file_operation = true;
change_filename();
break;
case 10:
file_operation = true;
delete_file();
break;
case 11:
file_operation = true;
change_file_attributes();
break;
case 50:
window.Reload();
break;
case 60:
window.ShowProperties();
break;
case 70:
window.ShowConfigure();
break;
}
_menu.Dispose();
menu = false;
return true;
}
Долго боролся со скриптом Марка, пока не уламал его -убрал все привязки к вспомогательным скриптам, кроме зубодробительного lodash.js. Теперь могу менять фон (у меня светлая тема для DUI).maklaud:меняющихся в зависимости от статуса/позиции курсора?
// ==PREPROCESSOR==
// @name "Playback Buttons"
// @author "marc2003"
// @import "%fb2k_profile_path%js_marc2003\js\lodash.js"
// ==/PREPROCESSOR==
//San_dr edition
window.MaxWidth=window.MinWidth=190;//only
window.MaxHeight=window.MinHeight=54;//only
var bs = 34;
var fon_img = gdi.Image(fb.ProfilePath + "\\images\\fon_2.png");
var stop_img = gdi.Image(fb.ProfilePath + "\\images\\stop_.png");
var tooltip = window.CreateTooltip();
_.mixin({
img : function (value) {
return gdi.Image(value);
},
drawImage : function (gr, img, src_x, src_y, src_w, src_h, aspect, border, alpha) {
if (!img)
return [];
gr.DrawImage(img, src_x, src_y, src_w, src_h, 0, 0, img.Width, img.Height, 0, alpha || 255);
return [src_x, src_y, src_w, src_h];
},
tt : function (value) {
tooltip.Text = value;
tooltip.Activate();
},
button : function (x, y, w, h, img_src, fn, tiptext) {
this.paint = function (gr) {
_.drawImage(gr, this.img, this.x, this.y, this.w, this.h);
}
this.trace = function (x, y) {
return x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h;
}
this.lbtn_up = function (x, y) {
this.fn(x, y);
}
this.cs = function (s) {
if (s == "hover") {
_.tt(this.tiptext);
} else {
this.img = this.img_normal;
}
window.RepaintRect(10,17,22,22);
}
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.fn = fn;
this.tiptext = tiptext;
this.img = _.img(img_src.normal);
},
buttons : function () {
this.paint = function (gr) {
_.forEach(this.buttons, function (item) {
item.paint(gr);
});
}
this.move = function (x, y) {
var temp_btn = null;
_.forEach(this.buttons, function (item, i) {
if (item.trace(x, y))
temp_btn = i;
});
if (this.btn == temp_btn)
return this.btn;
if (temp_btn)
this.buttons[temp_btn].cs("hover");
else
_.tt("");
this.btn = temp_btn;
return this.btn;
}
this.leave = function (x, y) {
_.tt("");
}
this.lbtn_up = function (x, y) {
if (this.btn) {
this.buttons[this.btn].lbtn_up(x, y);
return true;
} else {
return false;
}
}
this.buttons = {};
this.btn = null;
}
});
var buttons = new _.buttons();
buttons.buttons.stop = new _.button(2, 10, bs, bs, {}, function () { fb.Stop(); }, "Стоп");
buttons.buttons.play = new _.button(32, 10, 34, 34, {normal : fb.IsPaused ? "" : "images//pause.png"}, function () { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? "Играть" : "Пауза");
buttons.buttons.previous = new _.button(bs * 2, 10, bs, bs, {}, function () { fb.Prev(); }, "Предыдущий");
buttons.buttons.next = new _.button(bs * 3, 10, bs, bs, {}, function () { fb.Next(); }, "Следующий");
buttons.buttons.random = new _.button(bs * 4, 2, bs, bs, {}, function () { fb.Random(); }, "Играть случайный трек");
buttons.buttons.runMainMenuCommand = new _.button(bs * 5, 2, bs, bs, {}, function () { fb.RunMainMenuCommand("View/Выделить проигрываемый"); }, "Выделить проигрываемый трек");
buttons.buttons.runContextCommand = new _.button(bs * 4, 31, bs, bs, {}, function () { fb.RunContextCommand("Open containing folder"); }, "Открыть папку с файлом");
buttons.buttons.runMainMenuCommand1 = new _.button(bs * 5, 31, bs, bs, {}, function () { fb.RunMainMenuCommand("View/Playlist Search"); }, "Поиск в плейлисте");
buttons.update = function () {
this.buttons.play = new _.button(32, 10, 34, 34, {normal : fb.IsPaused ? "" : "images\\pause.png"}, function () { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? "Играть" : "Пауза");
window.Repaint();
}
function on_playlist_stop_after_current_changed() {
buttons.update();
}
function on_paint(gr) {
gr.DrawImage(fon_img,0, 0, 190, 54, 0, 0, 190, 54, 0, 255);
if (fb.StopAfterCurrent) gr.FillSolidRect(12,20,15,15,0xeeffaa00);
buttons.paint(gr);
if (!(fb.IsPaused || fb.IsPlaying)) gr.DrawImage(stop_img,32, 10, 34, 34, 0, 0, 34, 34, 0, 255);
}
function on_playback_stop() {
buttons.update();
}
function on_playback_pause() {
buttons.update();
}
function on_playback_starting() {
buttons.update();
}
function on_mouse_move(x, y) {
buttons.move(x, y);
}
function on_mouse_leave() {
buttons.leave();
}
function on_mouse_lbtn_up(x, y) {
buttons.lbtn_up(x, y);
}
function on_mouse_rbtn_up(x, y) {
if (buttons.buttons.stop.trace(x, y)) {
var MF_STRING = 0x00000000;
var m = window.CreatePopupMenu();
m.AppendMenuItem(MF_STRING, 1, "Стоп после текущего");
m.CheckMenuItem(1, fb.StopAfterCurrent);
m.AppendMenuSeparator();
m.AppendMenuItem(MF_STRING, 2, "Редактировать скрипт...");
var idx = m.TrackPopupMenu(x, y);
if (idx == 1)
fb.StopAfterCurrent = !fb.StopAfterCurrent;
else if (idx == 2)
window.ShowConfigure();
m.Dispose();
return true;
}
}
fb.RunContextCommand("Open containing folder") на fb.RunContextCommand("Открыть папку с файлом")
fb.RunMainMenuCommand("View/Playlist Search") на function () { fb.RunMainMenuCommand("Вид/Playlist Search")
Есть вариант намного проще без использования скриптов Марка...Попадался кому нибудь скрипт кнопочек (плей, пауза, стоп и т.д.), в котором сами кнопки состоят из нескольких изображений,
да ващще проект foobar он же под иконкой инопланетянина, так что всё возможно, гыmaklaud:этот вспомогательный скрипт вообще человек писал?
Думаю что можно, как и с дальнейшими эффектами как ты описал... Проблема только в том как это описать в кодеКак думаете, реально ли сделать более трёх картинок для кнопки?
maklaud:как сделать "супер крутенские" кнопки с анимацией на WSH ?
Вернуться в Секреты foobar2000