тоже временно (может наведет на мысль ..)Пока не знаю.
тут, что добавил.
- Спойлер
- Код: Выделить всё
// ==PREPROCESSOR==
// @name "Get Covers (Artwork)"
// @author "kgena_ua"
// @version "18012017"
// @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);};
String.prototype.repeat = function(n) {
return new Array(n + 1).join(this);
}
window.SetProperty(" - user:", "");
if (window.GetProperty(" - user:") != "" ) window.SetProperty(" - user:", "");
window.SetProperty("-".repeat(50), "");
if (window.GetProperty("-".repeat(50)) != "" ) window.SetProperty("-".repeat(50), "");
var font_name = window.GetProperty(" font name", "Arial");
var font_name2 = window.GetProperty(" font name2", "Arial");
var font_size = window.GetProperty(" font size", 12);
var font_size2 = window.GetProperty(" font size2", 22);
var font_style = window.GetProperty(" font style", 0);
var font_style2 = window.GetProperty(" font style2", 1);
var font = gdi.Font(font_name, font_size, font_style);
var font2 = gdi.Font(font_name2, font_size2, font_style2);
var ww = 600, wh = 600;
var pic_posx = 0;
var lbdn = 0;
DT_LEFT = 0x00000000;
DT_RIGHT = 0x00000002;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
DT_WORD_ELLIPSIS = 0x00040000;
DT_NOPREFIX = 0x00000800;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
MF_SEPARATOR = 0x00000800;
ColorTypeCUI = {
text: 0,
selection_text: 1,
inactive_selection_text: 2,
background: 3,
selection_background: 4,
inactive_selection_background: 5,
active_item_frame: 6
}
ColorTypeDUI = {
text: 0,
background: 1,
highlight: 2,
selection: 3
}
function get_color(){
if (window.InstanceType == 0){
bgcolor = window.GetColorCUI(ColorTypeCUI.background);
a_color = window.GetColorCUI(ColorTypeCUI.text);
b_color = window.GetColorCUI(ColorTypeCUI.inactive_selection_text);
} else if (window.InstanceType == 1) {
bgcolor = window.GetColorDUI(ColorTypeDUI.background);
a_color = window.GetColorDUI(ColorTypeDUI.text);
b_color = window.GetColorDUI(ColorTypeDUI.highlight);
}
window.Repaint();
}
get_color();
function on_colors_changed(){
get_color();
}
var transparent = window.GetProperty(" bg transparent (0-255)", 200);
var fso = new ActiveXObject("Scripting.FileSystemObject");
var WshShell = new ActiveXObject("WScript.Shell");
var dir_name, album, artist;
var old_dir_name, old_album;
var g_img = null
var с_img = null
var cover_name;
var cover_size;
var cover_width;
var cover_height;
var cover_dim;
var nocover_path = window.GetProperty(" nocover path",".\\themes\\stub.png");
var nocover = window.GetProperty(" nocover image", true);
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 attached_p_name = ["front cover", "back cover", "disc", "icon", "artist"];
var embedded_p_name = [];
var root_folders = new Array("cover", "covers", "scan", "scans", "art", "artwork", "artworks", "images", "pic");
var set_external = window.GetProperty("external", true);
var set_embedded = window.GetProperty("embedded", true);
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", true);
var artist_txt = window.GetProperty("artist_txt", true);
var infoset = window.GetProperty("Infoset", 1);
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;
var mode_1 = window.GetProperty("Mode 1", true);
var mode_2 = window.GetProperty("Mode 2", false);
var panel_on = true;
function on_paint(gr) {
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
draw_image(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 );
gr.GdiDrawText( "", gdi.Font("Arial",12, 0), b_color, 10, 30, ww, wh, DT_LEFT | DT_WORD_ELLIPSIS );
gr.GdiDrawText( "", gdi.Font("Arial",12, 0), b_color, 10, 50, 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() {
c_img = get_album_art(fb.GetNowPlaying());
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){
t1 = fb.TitleFormat("$upper([%artist%])").Eval();
dir_name = fb.Titleformat("$directory_path(%path%)").EvalWithMetadb(metadb);
album = fb.Titleformat("%album%").EvalWithMetadb(metadb);
artist = fb.Titleformat("%artist%").EvalWithMetadb(metadb);
if (dir_name != old_dir_name || album != old_album){
covernumber = 0;
get_covers();
old_dir_name = dir_name;
old_album = album
}
}
window.Repaint();
}
function get_album_art(metadb) {
z = 0;
if (metadb)
return utils.GetAlbumArtV2(metadb, z);
}
function get_covers() {
g_img = null;
get_external_covers(dir_name);
get_embedded_covers();
external = set_external ? external : [];
embedded = set_embedded ? embedded : [];
covers = [];
if (set_priority == 0) {
covers = covers.concat(external, embedded);
}
if (set_priority == 1) {
covers = covers.concat(embedded, external);
}
if (mode_2){
images = []; // *************** v 2
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])));
}
}
}
window.Repaint();
next_image(0);
}
function get_embedded_covers() { //0 - front cover, 1 - back cover, 2 - disc, 3 - icon, 4 - artist
embedded = [];
embedded_p_name = [];
if ( metadb ) {
for (var i = 0; i < 5; i++) {
var temp = utils.GetAlbumArtEmbedded(metadb.RawPath, i);
if (temp) embedded.push(temp);
if (temp) embedded_p_name.push(attached_p_name[i]);
}
}
}
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_dir_subs, covers_root, covers_root_subs);
if (covers_external.length > 0) {
if (external.length == 0){
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 ( get_fn(name).toLowerCase() == artist.toLowerCase() ) {
external.push(name);
covers_external[i] = null;
}
}
}
if (external.length == 0){
for (i in covers_external) {
var name = covers_external[i];
if ( clear_n(get_fn(name)).toLowerCase() == clear_n(artist).toLowerCase() + clear_n(album).toLowerCase() ) {
external.push(name);
covers_external[i] = null;
}
}
}
if (external.length == 0){
for (i in covers_external) {
var name = covers_external[i];
if (get_fnext(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};
if (mode_1){
if (typeof covers[covernumber] == 'object' ) { // *************** v 1
g_img = covers[covernumber]; // *************** v 1
} else { // *************** v 1
g_img = resize_image(gdi.Image(covers[covernumber])); // *************** v 1
} // *************** v 1
}
if (mode_2) g_img = images[covernumber]; // *************** v 2
if (g_img && fade_effect) fader_timer();
}
function resize_image(img){
if (!img || !ww || !wh) return;
var scale_w = ww / img.Width;
var scale_h = wh / img.Height;
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 draw_image(gr){
if (g_img){
var size = calc_img_size(g_img);
gr.DrawRect(size.x, size.y, size.width, size.height, 1, RGBA(getRed(bgcolor),getGreen(bgcolor),getBlue(bgcolor),fader));
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 (!g_img){
try {
var size = calc_img_size(c_img);
gr.DrawImage(c_img, size.x, size.y, size.width, size.height, size.cx, size.cy, size.cwidth, size.cheight, 0, covers.length > 0 ? fader : nocover_transparent);
} catch (e) {};
}
if (covers.length == 0 && nocover && fb.PlaybackLength > 0){
//*
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) {};
} else if (covers.length == 0 && nocover && fb.PlaybackLength <= 0 && typeof size != "object"){
try {
nc_img = gdi.Image(".\\themes\\radio_stub.png");
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, 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 - text_h / 3 - p_margin;
if(info ){
!set_cycle && gr.FillSolidRect(0, text_y - text_h / 3, ww, wh - text_y + text_h / 3, 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 = formatFileSize(fso.GetFile(covers[covernumber]).size);
cover_dim = cover_width + " x " + cover_height + " " + cover_size;
}
}
if (typeof covers[covernumber] == 'object'){
cover_name = get_embedded_p_name(covernumber);
cover_dim = "embedded";
}
!artist_txt && cover_name && gr.GdiDrawText( cover_name, font, b_color, 0, text_y-2, ww, wh, DT_CENTER | DT_WORD_ELLIPSIS | DT_NOPREFIX );
!artist_txt && gr.GdiDrawText( cover_dim, font, a_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";
!artist_txt && gr.GdiDrawText( info_text, font, a_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 );
//}
artist_txt && gr.GdiDrawText(t1, font2, b_color, 0, text_y-5 + text_h, ww, wh, DT_CENTER | DT_WORD_ELLIPSIS );
}
function on_mouse_lbtn_down(x,y){
pic_posx = x;
lbdn = 1
}
function on_mouse_lbtn_up(x,y){
//infoset = window.GetProperty("Infoset");
infoset++;
if (infoset > 3)
infoset = 1;
window.SetProperty("Infoset",infoset);
if (pic_posx == x) {
if (infoset == 1){
artist_txt = true;
window.SetProperty("artist_txt", artist_txt)
info = true;
window.SetProperty("info", info); }
if (infoset == 2){
info = true;
window.SetProperty("info", info);
artist_txt = false;
window.SetProperty("artist_txt", artist_txt)}
if (infoset == 3){
artist_txt = false;
window.SetProperty("artist_txt", artist_txt)
info = false;
window.SetProperty("info", info)}
window.Repaint();
}
lbdn = 0;
}
function on_mouse_lbtn_dblclk (x,y){
/*if (typeof covers[covernumber] != 'object' ) {
if(!fso.FileExists(covers[covernumber]))return;
if (covers[covernumber]) WshShell.run( '"' + covers[covernumber] + '"' );
}*/
}
function on_mouse_wheel(delta) {
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
if (!delay && !set_cycle && 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) {
if (cycle > 0)
step = 0;
if (lbdn) {
if (x > pic_posx+30) {
next_image(1);
lbdn = 0;
window.Repaint();
}
if (x < pic_posx-30 ) {
next_image(-1);
lbdn = 0;
window.Repaint();
}
}
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();
}
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);
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 get_embedded_p_name(n){
if (set_priority == 0) {
idx = n - external.length;
}
if (set_priority == 1) {
idx = n ;
}
return embedded_p_name[idx];
}
function on_mouse_rbtn_up (x, y){
var _menu = window.CreatePopupMenu();
_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, 41, "Artist txt");
_menu.CheckMenuItem(41, artist_txt);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 50, "Fade effect");
_menu.CheckMenuItem(50, fade_effect);
_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);
MF_STRING = covers[covernumber] && typeof covers[covernumber] != 'object' ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 70, "Open folder");
_menu.AppendMenuItem(MF_STRING, 71, "Rename file");
_menu.AppendMenuItem(MF_STRING, 72, "Delete file");
_menu.AppendMenuItem(MF_STRING, 73, "Change file attributes");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
MF_STRING = mode_2 ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(MF_STRING, 80, "Mode 1");
_menu.CheckMenuItem(80, mode_1);
MF_STRING = mode_1 ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(MF_STRING, 81, "Mode 2");
_menu.CheckMenuItem(81, mode_2);
_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 == false ? true : set_embedded == false ? true : false;
window.SetProperty("external", set_external);
covernumber = 0;
get_covers();
break;
case 11:
set_embedded = set_embedded == false ? true : set_external == false ? true : false;
window.SetProperty("embedded", set_embedded);
covernumber = 0;
get_covers();
break;
case 20:
case 21:
set_priority = ret - 20;
window.SetProperty("set_priority", set_priority);
covernumber = 0;
get_covers();
break;
case 30:
case 31:
selection_mode = ret - 30;
window.SetProperty("selection_mode", selection_mode);
on_item_focus_change();
break;
case 40:
info = !info
window.SetProperty("info", info);
if (info == false){
artist_txt = false;
window.SetProperty("artist_txt", artist_txt)}
window.Repaint();
break;
case 41:
artist_txt = !artist_txt
window.SetProperty("artist_txt", artist_txt);
if (artist_txt == true){
info = true;
window.SetProperty("info", 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 80:
case 81:
window.SetProperty("Mode 1", !mode_1);
mode_1 = window.GetProperty("Mode 1");
window.SetProperty("Mode 2", !mode_1);
mode_2 = window.GetProperty("Mode 2");
covernumber = 0;
get_covers();
break;
case 100:
try {
window.Reload();
} catch(e) {};
break;
case 110:
window.ShowProperties();
break;
case 120:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}
function get_fnext(p) {
if (!p) return;
return p.replace(/.*\\/g,'');
}
function get_fn(p) {
if (!p) return;
return p.replace(/.*\\|\.[^.]+$/g,'')
}
function get_fext(p) {
if (!p) return;
return p.replace(/.*\./g,'');
}
function get_dp(p) {
if (!p) return;
return p.replace(/(.*)\\.*/g,'$1');
}
function clear_n(p) {
if (!p) return;
return p.replace(/[^a-zA-Zа-яА-ЯёЁ0-9]/g,'');
}
function formatFileSize(b){
if (b > 1024 * 1024){
b = Math.round(b / 1024 / 1024 * 100) / 100 + " MB"
} else if (b > 1024){
b = Math.round(b / 1024 * 100 ) / 100 + " KB"
} else {
b = b + " Bytes";
}
return b;
}