Список разделов › foobar2000 › Секреты foobar2000
[b]AHAPXICT[/b], через "лайаут", не знаю. Это скрипт для кнопки переключения размера окна. А затем создается переменная (по window.Width) для PSS, в зависимости от которой ........AHAPXICT:Изменять размер окна при переключении "лайаутов".
var min_width = 800;
var max_width = 1050;
var window_x,window_y,window_width,window_height;
var autoItX3;
var class_name;
var view_mode;
autoItX3 = new ActiveXObject("AutoItX3.Control");
function Xywh(){
class_name = "[CLASS:{E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8}]";
window_x = autoItX3.WinGetPosX(class_name);
window_y = autoItX3.WinGetPosY(class_name);
window_width = autoItX3.WinGetPosWidth(class_name);
window_height = autoItX3.WinGetPosHeight(class_name);
}
function move_window(interface_name, x, y, w, h) {
class_name = "[CLASS:{E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8}]";
autoItX3.WinMove(class_name, "", x, y, w, h);
}
function on_mouse_rbtn_up (x, y){
view_mode = window.GetProperty("view mode");
var _menu = window.CreatePopupMenu();
var i = 1;
var MF_ENABLED = 0x00000000;
var MF_GRAYED = 0x00000001;
_menu.AppendMenuItem((view_mode ==1) ? MF_ENABLED : MF_GRAYED, i++, " increase ");
_menu.AppendMenuItem((view_mode ==0) ? MF_ENABLED : MF_GRAYED, i++, " decrease ");
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(0x00000000, 10, "Configure...");
ret = _menu.TrackPopupMenu(x, y);
if (ret == 0) return;
switch (ret) {
case 1:
Xywh();
move_window("CUI", window_x, window_y, max_width, window_height);
window.SetProperty("view mode", 0);
break;
case 2:
Xywh();
move_window("CUI", window_x, window_y, min_width, window_height);
window.SetProperty("view mode", 1);
break;
case 10:
window.ShowConfigure();
break
}
return true;
}
function on_mouse_wheel(delta) {
Xywh();
if (delta > 0) {
move_window("CUI", window_x, window_y, max_width, window_height);
window.SetProperty("view mode", 0);
};
if (delta < 0) {
move_window("CUI", window_x,window_y, min_width, window_height);
window.SetProperty("view mode", 1);
};
}
$imagebutton($get(btn.o),102,58,14,%do.images%\SmallNormal.png,%do.images%\SmallHover.png,COMMAND:View/Layout/CompactOne v1.0;WINDOWSIZE:360:504;REFRESH,,)
$imagebutton($add($div(%ps_width%,2),109),5,30,30,%co.buttons%Square.png,%co.buttons%SquareMH.png,COMMAND:View/Layout/DarkOne v4.0;WINDOWSIZE:1366:728;REFRESH,,)
// ----- CREATE MENUS LAYOUT -----
var l_arr = new Array("DarkOne v4.0", "CompactOne v1.0", "DarkOne v3.1");
function getMainMenuViewLayout(x, y) {
x = Buttons.LAYOUT.left;
y = Buttons.LAYOUT.top;
var a = window.CreatePopupMenu();
var p;
for (var l = 0; l < l_arr.length; l++) {
a.AppendMenuItem(0, 1 + l, l_arr[l]);
}
a.CheckMenuRadioItem(1, 3, fb.RunMainMenuCommand("View/Layout") + 2);
p = a.TrackPopupMenu(x, y);
switch (p)
{
case 1:
fb.RunMainMenuCommand("View/Layout/DarkOne v4.0"), fb.RunMainMenuCommand("View/Maximize/Restore")
break;
case 2:
fb.RunMainMenuCommand("View/Layout/CompactOne v1.0")
break;
case 3:
fb.RunMainMenuCommand("View/Layout/DarkOne v3.1"), fb.RunMainMenuCommand("View/Maximize/Restore")
break;
}
a.Dispose();
}
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_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;
}
}
Да похоже это то что нужно, спасибо большое пойду пробовать.Я вот перенес (и изменил) переключение переменных
по картинкам просто прокручивание их назад/вперед как колесом мыши... т.е. например ведешь палец влево переключаешь картинки назад, ведешь палец вправо переключаешь картинки вперед.По картинкам. Я так понимаю нужно нажать и сместить положение.
И я сделалduzzy:Переключение картинок я сделал
JScript Panel (Biography Text && Picture. www.last.fm v23022016-09032016 by kgena_ua): Ошибка выполнения Microsoft JScript:
'undefined' - есть null или не является объектом
File: <main>
Line: 104, Col: 5
<source text only available at compile time>
102 //Remove false string from file names
103 function clean_filename(filename) {
104 return filename.replace(/[\/\:\*\?\"\<\>\|\s]/g,'_');
105 }
Понял.pois22ple:Если запускать foobar с активным пустым плейлистом
function get_files_from_dir() {
if (!artist) return;
files = [];
var e = new Enumerator( fso.GetFolder(tmp_b_path).Files );
while ( !e.atEnd() ) {
var name = e.item().Name;
if (name.indexOf(clean_filename(artist)) == 0){
files.push(tmp_b_path + name);
}
e.moveNext();
}
}
// ==PREPROCESSOR==
// @name "Biography Text && Picture. www.last.fm"
// @author "kgena_ua"
// @version "13032016"
// @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 doc = new ActiveXObject("htmlfile");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var WshShell = new ActiveXObject("WScript.Shell");
var script_path = fb.ProfilePath + "\\tmp_Biography\\download\\";
var vbs = "cscript //nologo \"" + script_path + "download.vbs\"";
var tmp_b_path = fb.ProfilePath + "\\tmp_Biography\\";
if(!fso.FolderExists(tmp_b_path)) {fso.CreateFolder(tmp_b_path)};
if(!fso.FolderExists(tmp_b_path + "\\download\\")) {fso.CreateFolder(tmp_b_path + "\\download\\")};
if(!fso.FileExists(tmp_b_path + "\\download\\" + "download.vbs")) {create_download_file()};
var nocover_path = window.GetProperty("nocover path",".\\nocover\\nocover.png");
var nocover = window.GetProperty("nocover image", false);
load_last_fm_logo();
var logo_img = gdi.Image(tmp_b_path + "\\download\\" + "last_fm_logo.jpg");
var artist, old_artis, filename;
function clean_filename(filename) {
return filename.replace(/[\/\:\*\?\"\<\>\|\s]/g,'_');
}
var g_img = null;
var p_margin = window.GetProperty("margin: picture", 10);
var files = [], selected = 0;
var limit = window.GetProperty("download limit",5);
var cycle = window.GetProperty("auto cycle (sec)", 0);
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 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_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; i++) {
gr.GdiDrawText(b_text_array[i + s_text], b_font, RGB(0,0,0), b_x + 1, b_y + b_text_row_height * i + 2, ww, wh, DT_LEFT | DT_NOPREFIX );
gr.GdiDrawText(b_text_array[i + s_text], b_font, b_color, b_x, b_y + b_text_row_height * i, ww, wh, DT_LEFT | DT_NOPREFIX );
}
scrollbar && draw_scrollbar(gr);
gr.GdiDrawText("", gdi.Font("Arial",12, 0), b_color, 15, 0, ww, wh, DT_LEFT | DT_WORD_ELLIPSIS );
}
function paint(gr){
g_img = gdi.Image(files[selected]);
if (!g_img && nocover){
try {
g_img = gdi.Image(nocover_path);
} catch(e) {};
}
if (g_img){
var scale_w = (ww - p_margin * 2) / g_img.Width;
var scale_h = (wh - p_margin * 2) / g_img.Height;
var scale = Math.min(scale_w, scale_h);
if (files.length > 0){
g_img = g_img.CreateRawBitmap();
gr.GdiDrawBitmap(g_img, p_margin, p_margin, g_img.Width * scale, g_img.Height * scale, 0, 0, g_img.Width, g_img.Height);
} else {
gr.DrawImage(g_img, p_margin, p_margin, g_img.Width * scale, g_img.Height * scale, 0, 0, g_img.Width, g_img.Height, 0, 100);
}
}
if (logo_img && files.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);
}
}
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);
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%");
if (artist != old_artis){
CollectGarbage();
g_img = null;
s_text = 0;
text = "";
get_b_text_array()
get_b_text();
del_files_from_dir();
files = [];
selected = 0;
get_pic();
old_artis = artist;
}
}
function get_pic(){
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 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", ""))
}
}
}
for (i = 0; i < Math.min(urls.length, limit); i++) {
file = "\"" + tmp_b_path + clean_filename(artist) + "_" + i + "_" + p_a[select_p_a] + ".jpg" + "\"";
WshShell.Run(vbs + " " + urls[i] + " " + file, false);
}
doc.close();
}
}
}
}
function get_files_from_dir() {
if (!artist) return;
files = [];
var e = new Enumerator( fso.GetFolder(tmp_b_path).Files );
while ( !e.atEnd() ) {
var name = e.item().Name;
if (name.indexOf(clean_filename(artist)) == 0){
files.push(tmp_b_path + name);
}
e.moveNext();
}
}
function get_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];
get_b_text_array();
}
}
}
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;
var strings_array = [];
b_text_array = [];
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;
var string_width = Math.max(ww - b_x - 10, 0);
if (text) strings_array = temp_gr.EstimateLineWrap(text, b_font, string_width).toArray();
for (var i = 0; i < strings_array.length; i += 2) {
b_text_array.push(strings_array[i].replace(/^\s+|\s+$/g, ""));
}
b_text_rows = b_text_array.length;
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);
temp_bmp.ReleaseGraphics(temp_gr);
temp_bmp.Dispose();
temp_gr = null;
temp_bmp = null;
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;
window.Repaint();
}
function on_mouse_rbtn_up (x, y){
var _menu = window.CreatePopupMenu();
var i = 1;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
MF_SEPARATOR = 0x00000800;
_menu.AppendMenuItem(MF_ENABLED, i++, "EN text");
_menu.AppendMenuItem(MF_ENABLED, i++, "RU text");
_menu.CheckMenuRadioItem(1, i, abc + 1);
_menu.EnableMenuItem(abc + 1, 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 + 3);
_menu.EnableMenuItem(selection_mode + 3, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, i++, "Artist pictures");
_menu.AppendMenuItem(MF_ENABLED, i++, "Albums pictures");
_menu.CheckMenuRadioItem(i - 2, i , select_p_a + 5);
_menu.EnableMenuItem(select_p_a + 5, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
var is_artist = artist ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(is_artist, i++, "last.fm Artist");
// if (ShiftDown) {
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 10, "Reload");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 20, "Properties");
_menu.AppendMenuItem(MF_ENABLED, 30, "Configure ...");
// }
ret = _menu.TrackPopupMenu(x,y);
switch (ret) {
case 1:
abc = 0;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_b_text();
break;
case 2:
abc = 1;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_b_text();
break;
case 3:
selection_mode = 0;
window.SetProperty("selection mode", selection_mode);
on_item_focus_change();
break;
case 4:
selection_mode = 1;
window.SetProperty("selection mode", selection_mode);
on_item_focus_change();
break;
case 5:
select_p_a = 0;
window.SetProperty("pictures/albums", select_p_a);
del_files_from_dir();
files = [];
selected = 0;
get_pic();
break;
case 6:
select_p_a = 1;
window.SetProperty("pictures/albums", select_p_a);
del_files_from_dir();
files = [];
selected = 0;
get_pic();
break;
case 7:
WshShell.run("http://www.last.fm/" + abc_lang[abc] + "music/" + encodeURIComponent(artist));
break;
case 10:
window.Reload();
break;
case 20:
window.ShowProperties();
break;
case 30:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}
var timer = window.SetInterval(on_timer, 1000);
var step = 0;
var set_cycle = false;
var dis_timer, dis = 0;
function on_timer(id) {
step = set_cycle || cycle == 0 ? 0 : step + 1;
if (files.length == 0) {
get_files_from_dir();
window.Repaint();
};
if (cycle > 0 && step >= cycle){
selected = selected >= files.length - 1 ? 0 : selected = selected + 1;
window.Repaint();
step = 0;
}
}
function on_key_down(vkey) {
if (vkey == 16){
set_cycle = true;
dis_set();
window.Repaint();
}
}
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;
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);
}
function del_files_from_dir() {
var del_files = [];
var e = new Enumerator( fso.GetFolder(tmp_b_path).Files );
while ( !e.atEnd() ) {
var name = e.item().Name;
try {
fso.deleteFile(tmp_b_path + name );
} catch(e) {};
e.moveNext();
}
}
function load_last_fm_logo(){
if(!fso.FileExists(tmp_b_path + "\\download\\" + "last_fm_logo.jpg")) {
var url = "http://www.last.fm/static/images/logo_beta.png?eb6d3ca20e73"
var file = "\"" + tmp_b_path + "\\download\\" + "last_fm_logo.jpg" + "\"";
WshShell.Run(vbs + " " + url + " " + file, false);
var url = "http://static-web.last.fm/static/images/favicon.702b239b6194.ico"
var file = "\"" + tmp_b_path + "\\download\\" + "last_fm_ico.ico" + "\"";
WshShell.Run(vbs + " " + url + " " + file, false);
}
}
function create_download_file() {
try {
file = fso.CreateTextFile(tmp_b_path + "\\download\\" + "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_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){
delay = true;
fdelay();
get_files_from_dir();
if (delta < 0) {selected = selected <= 0 ? files.length - 1 : selected = selected - 1};
if (delta > 0) {selected = selected >= files.length - 1 ? 0 : selected = selected + 1};
}
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();
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();
}
function on_mouse_lbtn_down(x,y){
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;
}
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_b_text();
}
if (on_pic && files[selected]) WshShell.run( '"' + files[selected] + '"' );
}
function on_mouse_leave() {
window.SetCursor(32512);
window.Repaint();
}
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();
}
// ==PREPROCESSOR==
// @name "Biography Text && Picture. www.last.fm"
// @author "kgena_ua XXX Mod for multilanguage"
// @version "13032016"
// @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("字体名称: 艺术家", "Arial");
var font_name_b = window.GetProperty("字体名称: 简介", "Arial");
var font_size_a_d = window.GetProperty("字体大小: 艺术家 (delta)", 0);
var font_size_b = window.GetProperty("字体大小: 简介", 12);
var a_font_style = window.GetProperty("字体样式: 艺术家", 1);
var b_font_style = window.GetProperty("字体样式: 简介", 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 doc = new ActiveXObject("htmlfile");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var WshShell = new ActiveXObject("WScript.Shell");
var script_path = fb.ProfilePath + "\\tmp_Biography\\download\\";
var vbs = "cscript //nologo \"" + script_path + "download.vbs\"";
var tmp_b_path = fb.ProfilePath + "\\tmp_Biography\\";
if(!fso.FolderExists(tmp_b_path)) {fso.CreateFolder(tmp_b_path)};
if(!fso.FolderExists(tmp_b_path + "\\download\\")) {fso.CreateFolder(tmp_b_path + "\\download\\")};
if(!fso.FileExists(tmp_b_path + "\\download\\" + "download.vbs")) {create_download_file()};
var nocover_path = window.GetProperty("无封面图像路径",".\\nocover\\nocover.png");
var nocover = window.GetProperty("无封面图像", false);
load_last_fm_logo();
var logo_img = gdi.Image(tmp_b_path + "\\download\\" + "last_fm_logo.jpg");
var artist, old_artis, filename;
function clean_filename(filename) {
return filename.replace(/[\/\:\*\?\"\<\>\|\s]/g,'_');
}
var g_img = null;
var p_margin = window.GetProperty("margin: 图像", 10);
var files = [], selected = 0;
var limit = window.GetProperty("下载限制",5);
var cycle = window.GetProperty("自动循环 (秒)", 0);
var on_pic = false;
var scrollbar = window.GetProperty("滚动条", true);
var scrollbar_k;
var sb_posy = 0;
var on_sb = false;
var on_sb_down = false;
var t_margin = window.GetProperty("margin: 文本", 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 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_text = false;
var on_text_down = false;
var abc_lang = new Array("", "ru/", "es/", "fr/", "it/", "ja/", "pl/", "pt/", "de/", "sv/", "tr/", "zh/");
var abc = window.GetProperty("abc", 0);
var if_not_found = new Array("Nothing found", "Ничего не найдено", "Nothing found", "Nothing found", "Nothing found", "Nothing found", "Nothing found", "Nothing found", "Nothing found", "Nothing found", "Nothing found", "Nothing found"); // var if_not_found = new Array(_("Nothing found"), _("Nothing found"));
var select_p_a = window.GetProperty("图像/专辑", 0);
var p_a = new Array("images", "albums");
var selection_mode = window.GetProperty("选择模式", 0);
var metadb;
function _(s) {
switch (abc) {
case 1:
if (typeof(ru) != 'undefined' && ru[s]) {
return ru[s];
}
return s;
break;
case 2:
if (typeof(es) != 'undefined' && es[s]) {
return es[s];
}
return s;
break;
case 3:
if (typeof(fr) != 'undefined' && fr[s]) {
return fr[s];
}
return s;
break;
case 4:
if (typeof(it) != 'undefined' && it[s]) {
return it[s];
}
return s;
break;
case 5:
if (typeof(ja) != 'undefined' && ja[s]) {
return ja[s];
}
return s;
break;
case 6:
if (typeof(pl) != 'undefined' && pl[s]) {
return pl[s];
}
return s;
break;
case 7:
if (typeof(pt) != 'undefined' && pt[s]) {
return pt[s];
}
return s;
break;
case 8:
if (typeof(de) != 'undefined' && de[s]) {
return de[s];
}
return s;
break;
case 9:
if (typeof(sv) != 'undefined' && sv[s]) {
return sv[s];
}
return s;
break;
case 10:
if (typeof(tr) != 'undefined' && tr[s]) {
return tr[s];
}
return s;
break;
case 11:
if (typeof(zh) != 'undefined' && zh[s]) {
return zh[s];
}
return s;
break;
default:
return s;
}
}
var ru = {
"Nothing found" : "Ничего не найдено",
"off" : "Отключено",
"sec" : "сек",
"auto cycle" : "Зацикливание изображений",
"Prefer now playing" : "Предпочитать воспроизводимый",
"Follow selected track" : "Следовать за выбранным треком",
"Artist pictures" : "Фото исполнителя",
"Albums pictures" : "Обложка альбома",
"last.fm Artist" : "Страничка исполнителя на Last.fm",
"Reload" : "Перезагрузить",
"Properties" : "Свойства WSH",
"Configure..." : "Настройки WSH..."
};
var es = {
"Nothing found" : "",
"off" : "",
"sec" : "",
"auto cycle" : "",
"Prefer now playing" : "",
"Follow selected track" : "",
"Artist pictures" : "",
"Albums pictures" : "",
"last.fm Artist" : "",
"Reload" : "",
"Properties" : "",
"Configure..." : ""
};
var fr = {
"Nothing found" : "",
"off" : "",
"sec" : "",
"auto cycle" : "",
"Prefer now playing" : "",
"Follow selected track" : "",
"Artist pictures" : "",
"Albums pictures" : "",
"last.fm Artist" : "",
"Reload" : "",
"Properties" : "",
"Configure..." : ""
};
var it = {
"Nothing found" : "",
"off" : "",
"sec" : "",
"auto cycle" : "",
"Prefer now playing" : "",
"Follow selected track" : "",
"Artist pictures" : "",
"Albums pictures" : "",
"last.fm Artist" : "",
"Reload" : "",
"Properties" : "",
"Configure..." : ""
};
var ja = {
"Nothing found" : "",
"off" : "",
"sec" : "",
"auto cycle" : "",
"Prefer now playing" : "",
"Follow selected track" : "",
"Artist pictures" : "",
"Albums pictures" : "",
"last.fm Artist" : "",
"Reload" : "",
"Properties" : "",
"Configure..." : ""
};
var pl = {
"Nothing found" : "",
"off" : "",
"sec" : "",
"auto cycle" : "",
"Prefer now playing" : "",
"Follow selected track" : "",
"Artist pictures" : "",
"Albums pictures" : "",
"last.fm Artist" : "",
"Reload" : "",
"Properties" : "",
"Configure..." : ""
};
var pt = {
"Nothing found" : "",
"off" : "",
"sec" : "",
"auto cycle" : "",
"Prefer now playing" : "",
"Follow selected track" : "",
"Artist pictures" : "",
"Albums pictures" : "",
"last.fm Artist" : "",
"Reload" : "",
"Properties" : "",
"Configure..." : ""
};
var de = {
"Nothing found" : "",
"off" : "",
"sec" : "",
"auto cycle" : "",
"Prefer now playing" : "",
"Follow selected track" : "",
"Artist pictures" : "",
"Albums pictures" : "",
"last.fm Artist" : "",
"Reload" : "",
"Properties" : "",
"Configure..." : ""
};
var sv = {
"Nothing found" : "",
"off" : "",
"sec" : "",
"auto cycle" : "",
"Prefer now playing" : "",
"Follow selected track" : "",
"Artist pictures" : "",
"Albums pictures" : "",
"last.fm Artist" : "",
"Reload" : "",
"Properties" : "",
"Configure..." : ""
};
var tr = {
"Nothing found" : "",
"off" : "",
"sec" : "",
"auto cycle" : "",
"Prefer now playing" : "",
"Follow selected track" : "",
"Artist pictures" : "",
"Albums pictures" : "",
"last.fm Artist" : "",
"Reload" : "",
"Properties" : "",
"Configure..." : ""
};
var zh = {
"Nothing found" : "",
"off" : "",
"sec" : "",
"auto cycle" : "",
"Prefer now playing" : "",
"Follow selected track" : "",
"Artist pictures" : "",
"Albums pictures" : "",
"last.fm Artist" : "",
"Reload" : "",
"Properties" : "",
"Configure..." : ""
};
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; i++) {
gr.GdiDrawText(b_text_array[i + s_text], b_font, RGB(0,0,0), b_x + 1, b_y + b_text_row_height * i + 2, ww, wh, DT_LEFT | DT_NOPREFIX );
gr.GdiDrawText(b_text_array[i + s_text], b_font, b_color, b_x, b_y + b_text_row_height * i, ww, wh, DT_LEFT | DT_NOPREFIX );
}
scrollbar && draw_scrollbar(gr);
gr.GdiDrawText("", gdi.Font("Arial",12, 0), b_color, 15, 0, ww, wh, DT_LEFT | DT_WORD_ELLIPSIS );
}
function paint(gr){
g_img = gdi.Image(files[selected]);
if (!g_img && nocover){
try {
g_img = gdi.Image(nocover_path);
} catch(e) {};
}
if (g_img){
var scale_w = (ww - p_margin * 2) / g_img.Width;
var scale_h = (wh - p_margin * 2) / g_img.Height;
var scale = Math.min(scale_w, scale_h);
if (files.length > 0){
g_img = g_img.CreateRawBitmap();
gr.GdiDrawBitmap(g_img, p_margin, p_margin, g_img.Width * scale, g_img.Height * scale, 0, 0, g_img.Width, g_img.Height);
} else {
gr.DrawImage(g_img, p_margin, p_margin, g_img.Width * scale, g_img.Height * scale, 0, 0, g_img.Width, g_img.Height, 0, 100);
}
}
if (logo_img && files.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);
}
}
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);
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%");
if (artist != old_artis){
CollectGarbage();
g_img = null;
s_text = 0;
text = "";
get_b_text_array()
get_b_text();
del_files_from_dir();
files = [];
selected = 0;
get_pic();
old_artis = artist;
}
}
function get_pic(){
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 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", ""))
}
}
}
for (i = 0; i < Math.min(urls.length, limit); i++) {
file = "\"" + tmp_b_path + clean_filename(artist) + "_" + i + "_" + p_a[select_p_a] + ".jpg" + "\"";
WshShell.Run(vbs + " " + urls[i] + " " + file, false);
}
doc.close();
}
}
}
}
function get_files_from_dir() {
if (!artist) return;
files = [];
var e = new Enumerator( fso.GetFolder(tmp_b_path).Files );
while ( !e.atEnd() ) {
var name = e.item().Name;
if (name.indexOf(clean_filename(artist)) == 0){
files.push(tmp_b_path + name);
}
e.moveNext();
}
}
function get_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];
get_b_text_array();
}
}
}
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;
var strings_array = [];
b_text_array = [];
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;
var string_width = Math.max(ww - b_x - 10, 0);
if (text) strings_array = temp_gr.EstimateLineWrap(text, b_font, string_width).toArray();
for (var i = 0; i < strings_array.length; i += 2) {
b_text_array.push(strings_array[i].replace(/^\s+|\s+$/g, ""));
}
b_text_rows = b_text_array.length;
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);
temp_bmp.ReleaseGraphics(temp_gr);
temp_bmp.Dispose();
temp_gr = null;
temp_bmp = null;
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;
window.Repaint();
}
function on_mouse_rbtn_up(x, y) {
var _menu = window.CreatePopupMenu();
var _firstgroup = window.CreatePopupMenu();
var i = 1;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
MF_SEPARATOR = 0x00000800;
_firstgroup.AppendTo( _menu, MF_ENABLED, "Language / Язык");
_firstgroup.AppendMenuItem(MF_ENABLED, 101, "EN - English");
_firstgroup.AppendMenuItem(MF_ENABLED, 102, "RU - Русский");
_firstgroup.AppendMenuItem(MF_ENABLED, 103, "ES - Español");
_firstgroup.AppendMenuItem(MF_ENABLED, 104, "FR - Français");
_firstgroup.AppendMenuItem(MF_ENABLED, 105, "IT - Italiano");
_firstgroup.AppendMenuItem(MF_ENABLED, 106, "JA - 日本語");
_firstgroup.AppendMenuItem(MF_ENABLED, 107, "PL - Polski");
_firstgroup.AppendMenuItem(MF_ENABLED, 108, "PT - Português");
_firstgroup.AppendMenuItem(MF_ENABLED, 109, "DE - Deutsch");
_firstgroup.AppendMenuItem(MF_ENABLED, 110, "SV - Svenska");
_firstgroup.AppendMenuItem(MF_ENABLED, 111, "TR - Türkçe");
_firstgroup.AppendMenuItem(MF_ENABLED, 112, "ZH - 中国人");
_menu.CheckMenuRadioItem(101, 112, abc + 101);
_menu.EnableMenuItem(abc + 101, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 3, _("优先正在播放"));
_menu.AppendMenuItem(MF_ENABLED, 4, _("跟随选定音轨"));
_menu.CheckMenuRadioItem(3, 4, selection_mode + 3);
_menu.EnableMenuItem(selection_mode + 3, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 5, _("艺术家图像"));
_menu.AppendMenuItem(MF_ENABLED, 6, _("专辑图像"));
_menu.CheckMenuRadioItem(5, 6, select_p_a + 5);
_menu.EnableMenuItem(select_p_a + 5, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
var is_artist = artist ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(is_artist, 7, _("Last.Fm 艺术家"));
// if (ShiftDown) {
if (("Reload" in window)) {
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 10, _("重新载入"));
}
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 20, _("属性"));
_menu.AppendMenuItem(MF_ENABLED, 30, _("配置..."));
// }
ret = _menu.TrackPopupMenu(x, y);
switch (ret) {
case 101:
abc = 0;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_b_text();
break;
case 102:
abc = 1;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_b_text();
break;
case 103:
abc = 2;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_b_text();
break;
case 104:
abc = 3;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_b_text();
break;
case 105:
abc = 4;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_b_text();
break;
case 106:
abc = 5;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_b_text();
break;
case 107:
abc = 6;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_b_text();
break;
case 108:
abc = 7;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_b_text();
break;
case 109:
abc = 8;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_b_text();
break;
case 110:
abc = 9;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_b_text();
break;
case 111:
abc = 10;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_b_text();
break;
case 112:
abc = 11;
window.SetProperty("abc", abc);
s_text = 0;
text = "";
get_b_text();
break;
case 3:
selection_mode = 0;
window.SetProperty("选择模式", selection_mode);
on_item_focus_change();
break;
case 4:
selection_mode = 1;
window.SetProperty("选择模式", selection_mode);
on_item_focus_change();
break;
case 5:
select_p_a = 0;
window.SetProperty("图像/专辑", select_p_a);
on_metadb_changed();
break;
case 6:
select_p_a = 1;
window.SetProperty("图像/专辑", select_p_a);
on_metadb_changed();
break;
case 7:
WshShell.run("http://www.last.fm/" + abc_lang[abc] + "music/" + encodeURIComponent(artist));
break;
case 10:
window.Reload();
break;
case 20:
window.ShowProperties();
break;
case 30:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}
var timer = window.SetInterval(on_timer, 1000);
var step = 0;
var set_cycle = false;
var dis_timer, dis = 0;
function on_timer(id) {
step = set_cycle || cycle == 0 ? 0 : step + 1;
if (files.length == 0) {
get_files_from_dir();
window.Repaint();
};
if (cycle > 0 && step >= cycle){
selected = selected >= files.length - 1 ? 0 : selected = selected + 1;
window.Repaint();
step = 0;
}
}
function on_key_down(vkey) {
if (vkey == 16){
set_cycle = true;
dis_set();
window.Repaint();
}
}
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;
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);
}
function del_files_from_dir() {
var del_files = [];
var e = new Enumerator( fso.GetFolder(tmp_b_path).Files );
while ( !e.atEnd() ) {
var name = e.item().Name;
try {
fso.deleteFile(tmp_b_path + name );
} catch(e) {};
e.moveNext();
}
}
function load_last_fm_logo(){
if(!fso.FileExists(tmp_b_path + "\\download\\" + "last_fm_logo.jpg")) {
var url = "http://www.last.fm/static/images/logo_beta.png?eb6d3ca20e73"
var file = "\"" + tmp_b_path + "\\download\\" + "last_fm_logo.jpg" + "\"";
WshShell.Run(vbs + " " + url + " " + file, false);
var url = "http://static-web.last.fm/static/images/favicon.702b239b6194.ico"
var file = "\"" + tmp_b_path + "\\download\\" + "last_fm_ico.ico" + "\"";
WshShell.Run(vbs + " " + url + " " + file, false);
}
}
function create_download_file() {
try {
file = fso.CreateTextFile(tmp_b_path + "\\download\\" + "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_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){
delay = true;
fdelay();
get_files_from_dir();
if (delta < 0) {selected = selected <= 0 ? files.length - 1 : selected = selected - 1};
if (delta > 0) {selected = selected >= files.length - 1 ? 0 : selected = selected + 1};
}
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_b);
get_font();
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("自动循环 (秒)", cycle);
}
window.Repaint();
}
function on_mouse_lbtn_down(x,y){
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;
}
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_b_text();
}
if (on_pic && files[selected]) WshShell.run( '"' + files[selected] + '"' );
}
function on_mouse_leave() {
window.SetCursor(32512);
window.Repaint();
}
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();
}
var zh = {
"Nothing found" : "",
"off" : "",
"sec" : "",
"auto cycle" : "",
"Prefer now playing" : "",
"Follow selected track" : "",
"Artist pictures" : "",
"Albums pictures" : "",
"last.fm Artist" : "",
"Reload" : "",
"Properties" : "",
"Configure..." : ""
};
var ru = {
"Nothing found" : "Ничего не найдено",
"off" : "Отключено",
"sec" : "сек",
"auto cycle" : "Зацикливание изображений",
"Prefer now playing" : "Предпочитать воспроизводимый",
"Follow selected track" : "Следовать за выбранным треком",
"Artist pictures" : "Фото исполнителя",
"Albums pictures" : "Обложка альбома",
"last.fm Artist" : "Страничка исполнителя на Last.fm",
"Reload" : "Перезагрузить",
"Properties" : "Свойства WSH",
"Configure..." : "Настройки WSH..."
};
// ==PREPROCESSOR==
// @name "Get Covers (Artwork)"
// @author "kgena_ua"
// @version "18032016"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==
function RGBA(r, g, b, a) { return ((a << 24) | (r << 16) | (g << 8) | (b)); }
function RGB(r, g, b) { return (0xff000000 | (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);};
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;
/*
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(255,255,230);
var b_color = RGB(255,255,230);
var transparent = 200;
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",".\\nocover\\nocover.png");
var nocover = window.GetProperty("nocover image", false);
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 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)", 0);
if (cycle > 0) set_cycle_timer();
var info = window.GetProperty("info", false);
var file_operation = false;
var vbe = new ActiveXObject('ScriptControl');
vbe.Language = 'VBScript';
var delay = false;
var set_cycle = false;
var cycle_timer, step = 0;
var dis_timer, dis = 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);
paint(gr);
draw_set(gr);
draw_info(gr);
gr.GdiDrawText("" , font, a_color, 10, 10, ww, wh, DT_LEFT | DT_WORD_ELLIPSIS );
}
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 get_covers_from_dir_2(array, dir) {
var tmp = utils.Glob(dir + "*.*").toArray();
for (i in tmp) {
var name = tmp[i];
if ( name.match(/\.(jpg|jpeg|png|gif|bmp|tiff)$/i) ) {
array.push(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 && nocover){
try {
g_img = gdi.Image(nocover_path);
} catch(e) {};
}
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.DrawImage(g_img, pos_x, pos_y, g_img.Width * scale, g_img.Height * scale, 0, 0, g_img.Width, g_img.Height, 0, covers.length > 0 ? 255 : 100);
gr.DrawRoundRect(pos_x, pos_y, g_img.Width * scale, g_img.Height * scale, 1, 1, 1,bgcolor);
}
}
function draw_set(gr){
var text_x = ww * 0.1;
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";
gr.GdiDrawText("auto cycle: " + txt_cycle, b_font, b_color, text_x, 20, ww - text_x, wh, DT_LEFT | DT_WORD_ELLIPSIS );
}
}
function draw_info(gr){
var text_x = ww * 0.1;
var text_h = gr.CalcTextHeight("00", font);
var text_y = wh - text_h * 3 - 4;
if(info){
!set_cycle && gr.FillSolidRect(0, text_y - 5, ww, wh - text_y + 5, RGBA(getRed(bgcolor),getGreen(bgcolor),getBlue(bgcolor),transparent));
if (covers[covernumber]) {
if (typeof covers[covernumber] != 'object'){
cover_name = covers[covernumber].substring(covers[covernumber].lastIndexOf("\\") + 1);
}
if (typeof covers[covernumber] == 'object'){
cover_name = "embedded";
}
gr.GdiDrawText(cover_name, font, b_color, text_x, text_y, ww - text_x, wh - text_x, DT_LEFT | DT_WORD_ELLIPSIS );
try {
cover_size = Math.round( fso.GetFile( covers[covernumber]).size / 1024) + " KB";
} catch(e) { cover_size = ""};
if (g_img) gr.GdiDrawText(g_img.Width + " x " + g_img.Height + " " + cover_size, font, b_color, text_x, text_y + text_h, ww - text_x, wh, DT_LEFT | DT_WORD_ELLIPSIS );
gr.GdiDrawText(covernumber + 1 + " (" + covers.length + ") " + external.length + " external " + embedded.length + " embedded", font, b_color, text_x, text_y + text_h * 2, ww - text_x, wh, DT_LEFT | DT_WORD_ELLIPSIS );
}
}
if (!g_img) {
gr.GdiDrawText("no image", font, a_color, 0, 0, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
}
}
function on_mouse_move(x, y) {
window.SetCursor(32649);
window.Repaint();
}
function on_mouse_leave() {
window.SetCursor(32512);
window.Repaint();
}
function on_mouse_lbtn_dblclk (x,y){
if (typeof covers[covernumber] != 'object' ) {
if (covers[covernumber]) WshShell.run( '"' + covers[covernumber] + '"' );
}
}
function on_mouse_wheel(delta) {
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
if (!delay && !ShiftDown){
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};
}
if (ShiftDown) {
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();
}
function fdelay(){
var delay_timer = window.SetTimeout(function() {
delay = false;
window.ClearTimeout(delay_timer);
}, 250);
}
function on_key_down(vkey) {
if (vkey == 16){
set_cycle = true;
dis_set();
window.Repaint();
}
}
function set_cycle_timer(){
cycle_timer && window.ClearInterval(cycle_timer);
cycle_timer = window.SetInterval(function() {
step = set_cycle || file_operation ? 0 : step + 1;
if (cycle > 0 && step >= cycle){
on_mouse_wheel(1);
step = 0;
}
window.Repaint();
}, 1000 );
}
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 );
}
function change_file_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 file = fso.GetFile(source);
var button_type = 0x3;
var icon_types = 0x20;
var btn = WshShell.Popup("Delete file: \n" + source, 0, "Foobar 2000", button_type + icon_types);
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 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");
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_file_filename();
break;
case 10:
file_operation = true;
delete_file();
break;
case 50:
window.Reload();
break;
case 60:
window.ShowProperties();
break;
case 70:
window.ShowConfigure();
break;
}
_menu.Dispose();
menu = false;
return true;
}
Вернуться в Секреты foobar2000