Список разделов › foobar2000 › Секреты foobar2000
Как я понял, если заменить WSH на JS Panel, то на ней будет работать старый скрипт. Так?MC Web:megane68, плюнь ты на эти обновления WSH панели Самая стабильная 1.5.6. Более поздние версии сплошные "глюки". Там Марк уже упражнялся-изгалялся. Помимо того, что добавлял новые функции, он умудрился подчистить (удалить) старые. Поэтому старые скрипты на поздних версиях могут не работать. Что бы отойти от этого он и "создал" JScript Panel.
Нет, не так.megane68:Как я понял, если заменить WSH на JS Panel, то на ней будет работать старый скрипт. Так?
Я не понял, что то не так объяснил...megane68:Да это просто танцы с бубном какие- то.
не-не... Всё такMC Web:Я не понял, что то не так объяснил...
Да - нужно немного приложить руки и ранее не решаемая задача уже позади..начинаются громкие высказывания мол это у вас г...но, не работает, настроить не возможно, постоянно ошибки и т.д и т.п.
Ты на ПСКар приводил пример наложения одной панели на другую - тут оказалось тоже дело в работающий таймерах . Если правильно обнулятьнасколько я понимаю нужно просто правильно организовывать работу таймеров(не делать их глобальными) и все будет нормально работать
duzzy делал видео для полных (каким был и я) чайников . Панель позволяет быстро создать "сборку мечты" ;)мега панель сплиттер, где я даже ни одной кнопочки не могу убрать или заменить
Сегодня сделаю не большой апдейт (последний на ближайшее время) .Твоя крайняя сборка заняла у меня место основной
как в машине, так и дома.
Похоже мы не поняли друг друга.megane68:не-не... Всё так
Это я про установку всего, чтобы старые скрипты работали.
Не стоит того.
я имел ввиду компоненты: foo_uie_wsh_panel_mod.dl и foo_jscript_panel.dll, которые должны быть установлены.MC Web:Панель WSH остается и добавляется еще JScript Panel
тут оказалось тоже дело в работающий таймерах .
В редактор попасть можно так же как и раньше через Shift + правая кнопка мыши на панели со скриптом. Авторы так и ранее прятали вызов редактора.После добавления скрипта Library True, Configure нет в меню. Приходится через настройки Layout заходить.
Дякую!duzzy:В редактор попасть можно так же как и раньше через Shift + правая кнопка мыши на панели со скриптом. Авторы так и ранее прятали вызов редактора.
самому не верится , что эта "махина" получилась юзабельной ..Молодцом, особенно радует рестарт у тебя в сборке
// ==PREPROCESSOR==
// @name "Get Covers (Artwork)"
// @author "kgena_ua"
// @version "01072016"
// @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 = 200, wh = 200;
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;
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 cover_width;
var cover_height;
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);
var covers_external = [];
var covers_dir = [];
var covers_root = [];
var covers_root_subs = [];
var covers_dir_subs = [];
var external = [];
var embedded = [];
var covers = [];
var images = [];
var covernumber = 0;
var root_folders = new Array("cover", "covers", "scan", "scans", "artwork", "artworks", "images", "pic");
var set_external = window.GetProperty("external", 1);
var set_embedded = window.GetProperty("embedded", 1);
var set_priority = window.GetProperty("set_priority", 0);
var selection_mode = window.GetProperty("selection_mode", 0);
var cycle = window.GetProperty("auto cycle (sec)", 0);
if (cycle > 0) set_cycle_timer();
var info = window.GetProperty("info", false);
var fader = 255;
var fade_effect = window.GetProperty("fade effect", false);
var fade_step = window.GetProperty("fade step", 25);
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 p_margin = window.GetProperty("margin", 0);
var file_operation = false;
var delay = false;
var set_cycle = false;
var cycle_timer, step = 0;
var dis_timer, dis = 0;
function on_paint(gr) {
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
paint(gr);
draw_set(gr);
draw_info(gr);
gr.GdiDrawText("", font, b_color, 10, 0, ww, wh, DT_LEFT | DT_WORD_ELLIPSIS );
}
var metadb;
on_item_focus_change();
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;
get_covers();
old_dir_name = dir_name;
old_album = album
}
}
}
function get_covers() {
g_img = null;
get_external_covers(dir_name);
get_embedded_covers();
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);
}
images = [];
for (var i = 0; i < covers.length; i++) {
if (typeof covers[i] == 'object' ) {
images.push(covers[i]);
} else {
images.push(resize_image(gdi.Image(covers[i])));
}
}
next_image(0);
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) {
var name = covers_external[i];
if (get_file_name(name).toLowerCase() == album.toLowerCase()) {
external.push(name);
covers_external[i] = null;
}
}
if (external.length == 0){
for (i in covers_external) {
var name = covers_external[i];
if (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 next_image(d){
fader = fade_effect ? 0 : 255;
if (d < 0) {covernumber = covernumber <= 0 ? covers.length - 1 : covernumber = covernumber - 1};
if (d > 0) {covernumber = covernumber >= covers.length - 1 ? 0 : covernumber = covernumber + 1};
/*if (typeof covers[covernumber] == 'object' ) {
g_img = covers[covernumber];
} else {
g_img = resize_image(gdi.Image(covers[covernumber]));
}
*/
g_img = images[covernumber];
if (g_img && fade_effect) fader_timer();
}
function resize_image(img){
if (!img) return;
var scale_w = ww / img.Width;
var scale_h = wh / img.Height;
//var scale = Math.min(scale_w, scale_h);
var scale = Math.max(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 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, covers.length > 0 ? fader : nocover_transparent);
}
if (covers.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_set(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";
gr.GdiDrawText("auto cycle: " + txt_cycle, b_font, b_color, 0, 20, ww, wh, DT_CENTER | DT_WORD_ELLIPSIS );
}
}
function draw_info(gr){
var text_h = gr.CalcTextHeight("00", font);
var text_y = wh - text_h * 3 - 5;
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);
cover_width = gdi.Image(covers[covernumber]).width;
cover_height = gdi.Image(covers[covernumber]).Height;
cover_size = fso.GetFile( covers[covernumber]).size;
if (cover_size > 1024 * 1024){
cover_size = Math.round(cover_size / 1024 / 1024 * 100) / 100 + " MB"
} else if (cover_size > 1024){
cover_size = Math.round(cover_size / 1024 * 100 ) / 100 + " KB"
} else {
cover_size = cover_size + " Bytes";
}
cover_size = " " + cover_size;
}
if (typeof covers[covernumber] == 'object'){
cover_name = "embedded";
cover_width = covers[covernumber].width;
cover_height = covers[covernumber].Height;
cover_size = "";
}
gr.GdiDrawText(cover_name, font, b_color, 0, text_y, ww, wh, DT_CENTER | DT_WORD_ELLIPSIS );
gr.GdiDrawText(cover_width + " x " + cover_height + "" + cover_size, font, b_color, 0, text_y + text_h, ww, wh, DT_CENTER | DT_WORD_ELLIPSIS );
info_text = covernumber + 1 + " (" + covers.length + ") " + external.length + " external " + embedded.length + " embedded";
gr.GdiDrawText(info_text, font, b_color, 0, text_y + text_h * 2, ww, wh, DT_CENTER | 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_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 && covers.length > 1){
delay = true;
fdelay();
next_image(delta);
}
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 on_mouse_move(x, y) {
window.SetCursor(32649);
}
function on_mouse_leave() {
window.SetCursor(32512);
}
function fdelay(){
var delay_timer = window.SetTimeout(function() {
delay = false;
window.ClearTimeout(delay_timer);
}, 200);
}
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){
if ( covers.length > 1) next_image(1);
window.Repaint();
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 );
}
var ftimer;
function fader_timer(){
ftimer && window.ClearInterval(ftimer);
ftimer = window.SetInterval(function() {
fader = fader + fade_step;
if (fader >= 255) {
fader= 255;
window.ClearInterval(ftimer);
}
window.Repaint();
}, 50 );
}
function change_filename(){
var c_file_name = get_file_name(covers[covernumber]);
var nl = "\" + chr(10) + \"";
var input_box_text = nl + "Enter new file name";
var n_file_name = input_box(input_box_text, c_file_name, "Foobar 2000");
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();
} 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 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 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_size(){
ww = window.Width;
wh = window.Height;
}
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 on_mouse_rbtn_up (x, y){
var _menu = window.CreatePopupMenu();
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
MF_SEPARATOR = 0x00000800;
_menu.AppendMenuItem(MF_ENABLED, 10, "External covers");
_menu.CheckMenuItem(10, set_external);
_menu.AppendMenuItem(MF_ENABLED, 11, "Embedded covers");
_menu.CheckMenuItem(11, set_embedded);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 20, "Priority external");
_menu.AppendMenuItem(MF_ENABLED, 21, "Priority embedded");
_menu.CheckMenuRadioItem(20, 21 , set_priority + 20);
_menu.EnableMenuItem(set_priority + 20, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 30, "Prefer now playing");
_menu.AppendMenuItem(MF_ENABLED, 31, "Follow selected track");
_menu.CheckMenuRadioItem(30, 31 , selection_mode + 30);
_menu.EnableMenuItem(selection_mode + 30, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 40, "Info");
_menu.CheckMenuItem(40, info);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 50, "Fade effect");
_menu.CheckMenuItem(50, fade_effect);
var _firstgroup = window.CreatePopupMenu();
_firstgroup.AppendTo(_menu, MF_ENABLED, "Align : " + align_mode_a[align_mode]);
_firstgroup.AppendMenuItem(MF_ENABLED, 60, align_mode_a[0]);
_firstgroup.AppendMenuItem(MF_ENABLED, 61, align_mode_a[1]);
_firstgroup.AppendMenuItem(MF_ENABLED, 62, align_mode_a[2]);
_firstgroup.AppendMenuItem(MF_ENABLED, 63, align_mode_a[3]);
_firstgroup.AppendMenuItem(MF_ENABLED, 64, align_mode_a[4]);
_firstgroup.AppendMenuItem(MF_ENABLED, 65, align_mode_a[5]);
_firstgroup.CheckMenuRadioItem(60, 65, align_mode + 60);
_firstgroup.EnableMenuItem(align_mode + 60, 1);
var MF_ = covers[covernumber] && typeof covers[covernumber] != 'object' ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_, 70, "Open folder");
_menu.AppendMenuItem(MF_, 71, "Rename file");
_menu.AppendMenuItem(MF_, 72, "Delete file");
_menu.AppendMenuItem(MF_, 73, "Change file attributes");
_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:
set_external = set_external == 0 ? 1 : set_embedded == 0 ? 1 : 0;
window.SetProperty("external", set_external);
get_covers();
break;
case 11:
set_embedded = set_embedded == 0 ? 1 : set_external == 0 ? 1 : 0; ;
window.GetProperty("embedded", set_embedded);
get_covers();
break;
case 20:
set_priority = 0;
window.SetProperty("set_priority", set_priority);
get_covers();
break;
case 21:
set_priority = 1;
window.SetProperty("set_priority", set_priority);
get_covers();
break;
case 30:
selection_mode = 0;
window.SetProperty("selection_mode", selection_mode);
on_item_focus_change();
break;
case 31:
selection_mode = 1;
window.SetProperty("selection_mode", selection_mode);
on_item_focus_change();
break;
case 40:
window.SetProperty("info", !info);
info = window.GetProperty("info");
window.Repaint();
break;
case 50:
window.SetProperty("fade effect", !fade_effect);
fade_effect = window.GetProperty("fade effect");
break;
case 60:
case 61:
case 62:
case 63:
case 64:
case 65:
align_mode = ret - 60;
window.SetProperty("align mode", align_mode);
window.Repaint();
break;
case 70:
if (covers[covernumber] && typeof covers[covernumber] != 'object') WshShell.run( '"' + covers[covernumber].substring(0, covers[covernumber].lastIndexOf("\\")) + '"' );
break;
case 71:
file_operation = true;
change_filename();
break;
case 72:
file_operation = true;
delete_file();
break;
case 73:
file_operation = true;
change_file_attributes();
break;
case 100:
//window.Reload();
break;
case 110:
window.ShowProperties();
break;
case 120:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}
// ==PREPROCESSOR==
// @name "Get Covers (Artwork)"
// @author "kgena_ua"
// @version "14072016"
// @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 = 200, wh = 200;
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;
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 cover_width;
var cover_height;
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);
var covers_external = [];
var covers_dir = [];
var covers_root = [];
var covers_root_subs = [];
var covers_dir_subs = [];
var external = [];
var embedded = [];
var covers = [];
var images = [];
var covernumber = 0;
var root_folders = new Array("cover", "covers", "scan", "scans", "artwork", "artworks", "images", "pic");
var set_external = window.GetProperty("external", 1);
var set_embedded = window.GetProperty("embedded", 1);
var set_priority = window.GetProperty("set_priority", 0);
var selection_mode = window.GetProperty("selection_mode", 0);
var cycle = window.GetProperty("auto cycle (sec)", 0);
if (cycle > 0) set_cycle_timer();
var info = window.GetProperty("info", false);
var fader = 255;
var fade_effect = window.GetProperty("fade effect", false);
var fade_step = window.GetProperty("fade step", 25);
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 p_margin = window.GetProperty("margin", 0);
var file_operation = false;
var delay = false;
var set_cycle = false;
var cycle_timer, step = 0;
var dis_timer, dis = 0;
function on_paint(gr) {
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
paint(gr);
draw_set(gr);
draw_info(gr);
gr.GdiDrawText( "", gdi.Font("Arial",12, 0), b_color, 10, 0, ww, wh, DT_LEFT | DT_WORD_ELLIPSIS );
}
var metadb;
on_item_focus_change();
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;
get_covers();
old_dir_name = dir_name;
old_album = album
}
}
}
function get_covers() {
g_img = null;
get_external_covers(dir_name);
get_embedded_covers();
embedded = set_embedded == 1 ? embedded : [];
external = set_external == 1 ? external : [];
covers = [];
if (set_priority == 0) {
covers = covers.concat(external, embedded);
}
if (set_priority == 1) {
covers = covers.concat(embedded, external);
}
images = [];
for (var i = 0; i < covers.length; i++) {
if (typeof covers[i] == 'object' ) {
images.push(covers[i]);
} else {
images.push(resize_image(gdi.Image(covers[i])));
}
}
next_image(0);
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) {
var name = covers_external[i];
if (get_fn(name).toLowerCase() == album.toLowerCase()) {
external.push(name);
covers_external[i] = null;
}
}
if (external.length == 0){
for (i in covers_external) {
var name = covers_external[i];
if (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 next_image(d){
fader = fade_effect ? 0 : 255;
if (d < 0) {covernumber = covernumber <= 0 ? covers.length - 1 : covernumber = covernumber - 1};
if (d > 0) {covernumber = covernumber >= covers.length - 1 ? 0 : covernumber = covernumber + 1};
g_img = images[covernumber];
if (g_img && fade_effect) fader_timer();
}
function resize_image(img){
if (!img) return;
var scale_w = ww / img.Width;
var scale_h = wh / img.Height;
//var scale = Math.min(scale_w, scale_h);
var scale = Math.max(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 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, covers.length > 0 ? fader : nocover_transparent);
}
if (covers.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_set(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";
gr.GdiDrawText("auto cycle: " + txt_cycle, b_font, b_color, 0, 20, ww, wh, DT_CENTER | DT_WORD_ELLIPSIS );
}
}
function draw_info(gr){
var text_h = gr.CalcTextHeight("00", font);
var text_y = wh - text_h * 3 - 5;
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'){
if(fso.FileExists(covers[covernumber])){
cover_name = get_fnext(covers[covernumber]);
cover_width = gdi.Image(covers[covernumber]).width;
cover_height = gdi.Image(covers[covernumber]).Height;
cover_size = fso.GetFile( covers[covernumber]).size;
if (cover_size > 1024 * 1024){
cover_size = Math.round(cover_size / 1024 / 1024 * 100) / 100 + " MB"
} else if (cover_size > 1024){
cover_size = Math.round(cover_size / 1024 * 100 ) / 100 + " KB"
} else {
cover_size = cover_size + " Bytes";
}
cover_size = " " + cover_size;
}
}
if (typeof covers[covernumber] == 'object'){
cover_name = "embedded";
cover_width = covers[covernumber].width;
cover_height = covers[covernumber].Height;
cover_size = "";
}
cover_name && gr.GdiDrawText(cover_name, font, b_color, 0, text_y, ww, wh, DT_CENTER | DT_WORD_ELLIPSIS );
cover_width && cover_height && cover_size && gr.GdiDrawText(cover_width + " x " + cover_height + "" + cover_size, font, b_color, 0, text_y + text_h, ww, wh, DT_CENTER | DT_WORD_ELLIPSIS );
info_text = covernumber + 1 + " (" + covers.length + ") " + external.length + " external " + embedded.length + " embedded";
gr.GdiDrawText(info_text, font, b_color, 0, text_y + text_h * 2, ww, wh, DT_CENTER | 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_lbtn_dblclk (x,y){
if(!fso.FileExists(covers[covernumber]))return;
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 && covers.length > 1){
delay = true;
fdelay();
next_image(delta);
}
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 on_mouse_move(x, y) {
window.SetCursor(32649);
}
function on_mouse_leave() {
window.SetCursor(32512);
}
function fdelay(){
var delay_timer = window.SetTimeout(function() {
delay = false;
window.ClearTimeout(delay_timer);
}, 200);
}
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){
if ( covers.length > 1) next_image(1);
window.Repaint();
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 );
}
var ftimer;
function fader_timer(){
ftimer && window.ClearInterval(ftimer);
ftimer = window.SetInterval(function() {
fader = fader + fade_step;
if (fader >= 255) {
fader= 255;
window.ClearInterval(ftimer);
}
window.Repaint();
}, 50 );
}
function change_filename(){
if(!fso.FileExists(covers[covernumber]))return;
var c_file_name = get_fn(covers[covernumber]);
var nl = "\" + chr(10) + \"";
var input_box_text = nl + "Enter new file name";
var n_file_name = input_box(input_box_text, c_file_name, "Foobar 2000");
if (n_file_name) {
var dir = get_dp(covers[covernumber]);
var ext = get_fext(covers[covernumber]);
try {
fso.MoveFile( covers[covernumber], dir + "\\" + n_file_name + "." + ext );
get_covers();
for (var i = 0; i < covers.length; i++) {
if (get_fn(covers[i]) == n_file_name) {
covernumber = i;
}
}
} catch(e) {}
}
file_operation = false;
}
function delete_file(){
if(!fso.FileExists(covers[covernumber]))return;
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();
} catch(e) {}
break;
case 2:
case 7:
break;
case 4:
delete_file();
break;
}
file_operation = false;
}
function change_file_attributes(){
if(!fso.FileExists(covers[covernumber]))return;
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 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 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_size(){
ww = window.Width;
wh = window.Height;
}
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 on_mouse_rbtn_up (x, y){
var _menu = window.CreatePopupMenu();
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
MF_SEPARATOR = 0x00000800;
_menu.AppendMenuItem(MF_ENABLED, 10, "External covers");
_menu.CheckMenuItem(10, set_external);
_menu.AppendMenuItem(MF_ENABLED, 11, "Embedded covers");
_menu.CheckMenuItem(11, set_embedded);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 20, "Priority external");
_menu.AppendMenuItem(MF_ENABLED, 21, "Priority embedded");
_menu.CheckMenuRadioItem(20, 21 , set_priority + 20);
_menu.EnableMenuItem(set_priority + 20, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 30, "Prefer now playing");
_menu.AppendMenuItem(MF_ENABLED, 31, "Follow selected track");
_menu.CheckMenuRadioItem(30, 31 , selection_mode + 30);
_menu.EnableMenuItem(selection_mode + 30, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 40, "Info");
_menu.CheckMenuItem(40, info);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 50, "Fade effect");
_menu.CheckMenuItem(50, fade_effect);
var _firstgroup = window.CreatePopupMenu();
_firstgroup.AppendTo(_menu, MF_ENABLED, "Align : " + align_mode_a[align_mode]);
_firstgroup.AppendMenuItem(MF_ENABLED, 60, align_mode_a[0]);
_firstgroup.AppendMenuItem(MF_ENABLED, 61, align_mode_a[1]);
_firstgroup.AppendMenuItem(MF_ENABLED, 62, align_mode_a[2]);
_firstgroup.AppendMenuItem(MF_ENABLED, 63, align_mode_a[3]);
_firstgroup.AppendMenuItem(MF_ENABLED, 64, align_mode_a[4]);
_firstgroup.AppendMenuItem(MF_ENABLED, 65, align_mode_a[5]);
_firstgroup.CheckMenuRadioItem(60, 65, align_mode + 60);
_firstgroup.EnableMenuItem(align_mode + 60, 1);
var MF_ = covers[covernumber] && typeof covers[covernumber] != 'object' ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_, 70, "Open folder");
_menu.AppendMenuItem(MF_, 71, "Rename file");
_menu.AppendMenuItem(MF_, 72, "Delete file");
_menu.AppendMenuItem(MF_, 73, "Change file attributes");
_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:
set_external = set_external == 0 ? 1 : set_embedded == 0 ? 1 : 0;
window.SetProperty("external", set_external);
covernumber = 0;
get_covers();
break;
case 11:
set_embedded = set_embedded == 0 ? 1 : set_external == 0 ? 1 : 0; ;
window.SetProperty("embedded", set_embedded);
covernumber = 0;
get_covers();
break;
case 20:
set_priority = 0;
window.SetProperty("set_priority", set_priority);
covernumber = 0;
get_covers();
break;
case 21:
set_priority = 1;
window.SetProperty("set_priority", set_priority);
covernumber = 0;
get_covers();
break;
case 30:
selection_mode = 0;
window.SetProperty("selection_mode", selection_mode);
on_item_focus_change();
break;
case 31:
selection_mode = 1;
window.SetProperty("selection_mode", selection_mode);
on_item_focus_change();
break;
case 40:
window.SetProperty("info", !info);
info = window.GetProperty("info");
window.Repaint();
break;
case 50:
window.SetProperty("fade effect", !fade_effect);
fade_effect = window.GetProperty("fade effect");
break;
case 60:
case 61:
case 62:
case 63:
case 64:
case 65:
align_mode = ret - 60;
window.SetProperty("align mode", align_mode);
window.Repaint();
break;
case 70:
if (covers[covernumber] && typeof covers[covernumber] != 'object') WshShell.run( '"' + covers[covernumber].substring(0, covers[covernumber].lastIndexOf("\\")) + '"' );
break;
case 71:
file_operation = true;
change_filename();
break;
case 72:
file_operation = true;
delete_file();
break;
case 73:
file_operation = true;
change_file_attributes();
break;
case 100:
//window.Reload();
break;
case 110:
window.ShowProperties();
break;
case 120:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}
function get_fnext(p) {
var temp = p.replace(/.*\\/g,'');
return temp;
}
function get_fn(p) {
var temp = p.replace(/.*\\|\..*/g,'');
return temp;
}
function get_fext(p) {
var temp = p.replace(/.*\./g,'');
return temp;
}
function get_dp(p) {
var temp = p.replace(/(.*)\\.*/g,'$1');
return temp;
}
Вернуться в Секреты foobar2000