Список разделов › foobar2000 › Секреты foobar2000
Добавляем строку, вверху:seriousstas:(Поиск И DSP) полупрозрачными ?
function RGBA(r,g,b,a) { return ((a << 24) | (r << 16) | (g << 8) | (b)); }
kgena_ua:А для чего currentTime.getMilliseconds()/1000;.
Фон в итоге получается бледным , но не прозрачным .kgena_ua:seriousstas писал(а):(Поиск И DSP) полупрозрачными ?Добавляем строку, вверху:Код: Выделить всёfunction RGBA(r,g,b,a) { return ((a << 24) | (r << 16) | (g << 8) | (b)); } Ставим галочку в пункте Pseudo Transparent.Строку вывода цвета фона: gr.FillSolidRect (0, 0, ww, wh, RGB(30,30,30)); меняем на: gr.FillSolidRect (0, 0, ww, wh, RGBA(30,30,30,150)); где, для примера, 150 - прозрачность.
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)); }
var font = gdi.Font("arial",52);
var font2 = gdi.Font("arial",30);
var ww = window.Width;
var wh = window.Height;
DT_CENTER = 0x00000001;
DT_RIGHT = 0x00000002;
DT_SINGLELINE = 0x00000020;
DT_VCENTER = 0x00000004;
var t_color = RGB(205,51,51);
var m_color = RGB(210,180,140);
var sel_color = RGB(250,250,250);
var sel_bg_color = RGB(100,100,100);
var t_row = 1, t_row1, t_row2, t_row3, t_height;
var string = "", search_query;
var tag_search = window.GetProperty("tag_search", 1);
var previous_pll = plman.ActivePlaylist;
var sort = "%album artist%|%date%|%album%|%discnumber%|%tracknumber%|%title%";
var on_mouse = false;
var ab, ab1, ab2;
var ab_I, ab_C, ab_F, ab_M;
var it, it1, it2, itM;
var line1 = false, line2 = false, line3 = false;
var lang = 1;
function on_paint(gr) {
gr.FillSolidRect (0, 0, ww, wh, RGBA(40,30,20,150));
seriousstas, значение можно менять в диапазоне 0 - 255. 0 - полностью прозрачный и .т.д.seriousstas:Фон в итоге получается бледным , но не прозрачным
Панель не весь экран и текст ограничен шириной кнопки , переназвание , как в основном скрипте - было-бы полезным.создаем (блокнотом) в корне фубара пустой файл м именем dsp_txt_ (т.к. FileExists не понимает '*')
меняем (зачем нам разные тексты)
var fso = new ActiveXObject("Scripting.FileSystemObject");
folder_path = fb.FoobarPath+"\\"+"wsh_data";
if(!fso.FolderExists(folder_path))
fso.CreateFolder(folder_path);
if(!fso.FolderExists(folder_path + "\\"+"artists"))
fso.CreateFolder(folder_path + "\\"+"artists");
if(!fso.FileExists(folder_path + "\\del_artists.js")){
var data = "var fso = new ActiveXObject(\"Scripting.FileSystemObject\");\r\n"
+ "function clear_wsh_data_artists(path)\r\n"
+ "{\r\n"
+ " folder_path = path;\r\n"
+ " try{\r\n"
+ " if(fso.FolderExists(folder_path))\r\n"
+ " {\r\n"
+ " fso.DeleteFolder(folder_path);\r\n"
+ " }\r\n"
+ " }catch(err){\r\n"
+ " return false;\r\n"
+ " }\r\n"
+ " return true;\r\n"
+ "}\r\n"
+ "clear_wsh_data_artists(WScript.arguments(0));";
var file = fso.CreateTextFile(folder_path + "\\\\del_artists.js", true,65001);
file.WriteLine(data);
file.Close();
}
function clear_wsh_data(folder) {
if (folder != "") {
folder_path = fb.FoobarPath+"\wsh_data";
file_path = folder_path+"\\del_artists.js";
if (fso.FileExists(file_path))
{ //jscript del folder
var command = "wscript /E:jscript " + file_path + " \"" + folder_path + "\\" + folder + "\"";
//fb.trace(command);
WshShell.Run(command,false,false);
return true;
}
}
}
clear_wsh_data("artists");
var fso = new ActiveXObject("Scripting.FileSystemObject");
function clear_wsh_data_artists(path)
{
folder_path = path;
try{
if(fso.FolderExists(folder_path))
{
fso.DeleteFolder(folder_path);
}
}catch(err){
return false;
}
return true;
}
clear_wsh_data_artists(WScript.arguments(0));
seriousstas, необходимо, чтобы панель WSH была над плейлистом (выше в списке), можно изменить в Preferencesseriousstas:панель на фоне плейлиста не прозрачна при любых значения
Сделаем.переназвание , как в основном скрипте - было-бы полезным.
Будет.отступ только текста от верха панели
Я это сразу понял, но панель висит под своим отдельным сплиттером (наверное в этом дело), а плейлист в корне (под основным)необходимо, чтобы панель WSH была над плейлистом (выше в списке)
И с этим уже столкнулся, когда открывал панель поверх peakmeter spectrumТолько есть один недостаток. Панель которая расположена под WSH должна быть статична
спасибо!Сделаем.
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
var font = gdi.Font("Arial",12,1);
var ww,wh;
var file_path, file_name, file_name_ext, attributes;
var txt;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var g_metadb;
on_item_focus_change();
function on_paint(gr){
gr.FillSolidRect (0, 0, ww, wh, RGB(50,50,50));
switch (attributes) {
case 32:
txt = "READ WRITE"; break;
case 33:
txt = "READ ONLY"; break;
}
gr.GdiDrawText( file_name, font, RGB(255,255,220), 10, 2, ww - 20, wh, 0x00000000|0x00040000 );
gr.DrawString( attributes + " - " + txt, font, RGB(255,255,220), 10, 20, ww - 20, wh, 0 );
}
function on_item_focus_change() {
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (g_metadb) on_metadb_changed();
}
function on_metadb_changed() {
if (g_metadb) {
file_path = fb.Titleformat("%path%").EvalWithMetadb(g_metadb);
file_name = fb.Titleformat("%filename_ext%").EvalWithMetadb(g_metadb);
file_name_ext = fb.Titleformat("$ext([%filename_ext%])").EvalWithMetadb(g_metadb);
file = fso.GetFile(file_path);
attributes = file.Attributes;
}
window.Repaint();
}
function on_playback_new_track(g_metadb) {
on_item_focus_change();
}
function on_selection_changed(g_metadb) {
on_item_focus_change();
}
function on_mouse_lbtn_up (x, y){
var _menu = window.CreatePopupMenu();
var i = 1;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
RO = attributes == 33 ? MF_ENABLED : MF_GRAYED;
RW = attributes == 32 ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(RO, i++, "read write");
_menu.AppendMenuItem(RW, i++, "read only");
ret = _menu.TrackPopupMenu(x, y);
if (ret == 0) return;
switch (ret) {
case 1:
file.Attributes = 32;
on_item_focus_change();
break;
case 2:
file.Attributes = 33;
on_item_focus_change();
break;
}
_menu.Dispose();
return true;
}
function on_size(){
ww = window.Width;
wh = window.Height;
}
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)); }
var font = gdi.Font("arial",15,1);
var ww = window.Width;
var wh = window.Height;
DT_CENTER = 0x00000001;
DT_RIGHT = 0x00000002;
DT_SINGLELINE = 0x00000020;
DT_VCENTER = 0x00000004;
var t_color = RGB(180,180,180);
var m_color = RGB(120,120,120);
var sel_color = RGB(250,250,250);
var sel_bg_color = RGB(80,80,80);
var shift = 20;
var dsp = window.GetProperty("dsp", 1);
var on_mouse = false;
var dsp_m = Array("Без DSP","Минимальная","Оптимальная","Стерео в 5.1","Стерео в 5.0","Стерео в 4.0","iZOzone","Наушники Bauer","ЭХО","МОЙ","Показать DSP");
var dsp_b_txt = Array("DSP OFF","Minimum","Optimal","2.0 in 5.1","2.0 in 5.0","2.0 in 4.0","iZOzone","Headphone Bauer","ECHO","- MY -","DSP");
var it = dsp_m.length;
var sel_dsp;
var fso = new ActiveXObject("Scripting.FileSystemObject");
//var set_path = fb.ProfilePath + "\\settings\\";
//if(!fso.FolderExists(fb.ProfilePath + "\\settings")) {fso.CreateFolder(fb.ProfilePath + "\\settings"); fso.CreateTextFile( set_path + "dsp_txt_")};
var set_path = fb.ProfilePath;
if(!fso.FileExists( set_path + "dsp_off_0") && !fso.FileExists( set_path + "dsp_off_1")) fso.CreateTextFile( set_path + "dsp_off_1", true);
function on_paint(gr) {
gr.FillSolidRect (0, 0, ww, wh, RGBA(30,30,30,255));
t_height = gr.CalcTextheight("abc", font) + 10;
for (var i = 0; i < it; i = i + 1) {
if (y_row > t_height * i + shift && y_row <= t_height * (i + 1) + shift) {
gr.FillSolidRect (0, t_height * i + shift, ww, t_height, sel_bg_color);
}
}
for (var i = 0; i < it; i = i + 1) {
color = (y_row > t_height * i + shift && y_row <= t_height * (i + 1) + shift) || dsp == i + 1 ? sel_color : m_color;;
gr.GdiDrawText(dsp_m[i], font, color, 0, t_height * i + shift, ww, t_height, DT_CENTER |DT_SINGLELINE | DT_VCENTER);
}
// gr.GdiDrawText(dsp, font, RGB(200,200,200), 0, 5, ww - 10 , wh, DT_RIGHT);
}
function on_mouse_lbtn_up (x, y){
for (var i = 0; i < it; i = i + 1) {
if (y > t_height * i + shift && y < t_height * (i + 1) + shift) sel_dsp = i + 1;
}
if (sel_dsp != it) {dsp = sel_dsp; window.SetProperty("dsp", sel_dsp)};
dsp_set();
}
function dsp_set(){
switch (sel_dsp) {
case 1:
fb.RunMainMenuCommand("Playback/DSP settings/OFF");break;
case 2:
fb.RunMainMenuCommand("Playback/DSP settings/Min");break;
case 3:
fb.RunMainMenuCommand("Playback/DSP settings/Optim");break;
case 4:
fb.RunMainMenuCommand("Playback/DSP settings/51");break;
case 5:
fb.RunMainMenuCommand("Playback/DSP settings/50");break;
case 6:
fb.RunMainMenuCommand("Playback/DSP settings/40");break;
case 7:
fb.RunMainMenuCommand("Playback/DSP settings/iZOzone");break;
case 8:
fb.RunMainMenuCommand("Playback/DSP settings/Resampler");break;
case 9:
fb.RunMainMenuCommand("Playback/DSP settings/ECHO");break;
case 10:
fb.RunMainMenuCommand("Playback/DSP settings/Default");break;
case 11:
fb.RunMainMenuCommand("Playback/DSP settings/Preferences");break;
}
if (sel_dsp != it) close_panel();
}
var y_row;
function on_mouse_move(x,y) {
window.SetCursor(32649);
y_row = y;
on_mouse = true;
window.Repaint();
}
function on_mouse_leave() {
window.SetCursor(32512);
on_mouse = false;
window.Repaint();
}
function on_size(){
ww = window.Width;
wh = window.Height;
}
function close_panel() {
fso.deleteFile( set_path + "dsp_off_" + "*" );
fso.CreateTextFile( set_path + "dsp_off_0" );
fso.deleteFile( set_path + "dsp_txt_" + "*" );
fso.CreateTextFile( set_path + "dsp_txt_" + dsp_b_txt[sel_dsp - 1] );
RefreshPSS();
clear_flag();
}
var g_timer;
function clear_flag(){
g_timer = window.SetTimeout(function() {
if(fso.FileExists( set_path + "dsp_off_0")) {
fso.deleteFile( set_path + "dsp_off_" + "*" );
fso.CreateTextFile( set_path + "dsp_off_1" )
window.ClearTimeout(g_timer);
}
}, 20);
}
function RefreshPSS() {
if (fb.IsPlaying || fb.IsPaused) {
fb.RunMainMenuCommand("Playback/Play or Pause");
fb.RunMainMenuCommand("Playback/Play or Pause");
} else {
fb.RunMainMenuCommand("Playback/Play");
fb.RunMainMenuCommand("Playback/Stop");
}
}
для получения названий радиостанций, где входным файлом является список "только url-ов, радиостанций" в формате *.txt.Написал чекер и получил название;ссылка;битрейт
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
var font = gdi.Font("Arial",12,1);
var ww,wh;
function on_size(){
ww = window.Width;
wh = window.Height;
}
var fso = new ActiveXObject("Scripting.FileSystemObject");
if(!fso.FolderExists( fb.ProfilePath + "output")) {fso.CreateFolder( fb.ProfilePath + "output" )};
var file_path = fb.ProfilePath + "\\output\\";
var tag = Array("path");
var separator = " -- ";
var metadb;
on_item_focus_change();
function on_paint(gr){
gr.FillSolidRect (0, 0, ww, wh, RGB(50,50,50));
}
function CreateTextFile(){
plist_name = plman.GetPlaylistName(plman.ActivePlaylist);
plist_name = plist_name.replace(/[\/\:\*\?\"\<\>\|]/g,'')
if(fso.FileExists( file_path + "plist " + plist_name + ".txt")) {
fso.deleteFile( file_path + "plist " + plist_name + ".txt" );
}
if(metadb){
var file = fso.CreateTextFile( file_path + "plist " + plist_name + ".txt" )
for (var i = 0; i < fb.GetSelections().Count; i++) {
var item = metadb.Item(i);
var text = [];
for (var j = 0; j < tag.length; j++) {
text.push(fb.TitleFormat("%" + tag[j] + "%").EvalWithMetadb(item));
var string = text.join(separator);
}
file.WriteLine(string);
}
}
file.Close();
}
function on_item_focus_change() {
metadb = fb.GetSelections();
}
function on_selection_changed(g_metadb) {
on_item_focus_change();
}
function on_mouse_lbtn_up (x, y){
var _menu = window.CreatePopupMenu();
var i = 1;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
_menu.AppendMenuItem(MF_ENABLED, i++, "create text file");
ret = _menu.TrackPopupMenu(x, y);
if (ret == 0) return;
switch (ret) {
case 1:
CreateTextFile();
break;
}
_menu.Dispose();
return true;
}
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
var font = gdi.Font("Arial",11,1);
var ww,wh;
function on_size(){
ww = window.Width;
wh = window.Height;
}
var fso = new ActiveXObject("Scripting.FileSystemObject");
if(!fso.FolderExists( fb.ProfilePath + "output")) {fso.CreateFolder( fb.ProfilePath + "output" )};
var output_path = fb.ProfilePath + "\\output\\";
var tag = Array("%album%","%album artist%","%artist%","%genre%","%date%","%discnumber%","%tracknumber%","%title%","%length%","%path%","$info(encoding)","%codec%","$info(codec_profile)","$info(bitrate)","$info(samplerate)","$info(bitspersample)");
var outtag = [];
var separator = Array(" - ","\t");
for (var j = 0; j < tag.length; j++) {
window.GetProperty(j + 1,0);
}
window.GetProperty("ext",0);
function on_paint(gr){
gr.FillSolidRect (0, 0, ww, wh, RGB(50,50,50));
}
function create_output_array() {
outtag = [];
for (var j = 0; j < tag.length; j++) {
selected = window.GetProperty(j + 1);
if ( selected == 1 ) {outtag.push(tag[j])};
}
createTextFile();
}
function createTextFile(){
if ( fb.GetSelections().Count == 0 || outtag.length ==0 ) return;
plist_name = plman.GetPlaylistName(plman.ActivePlaylist);
plist_name = plist_name.replace(/[\/\:\*\?\"\<\>\|]/g,'')
if (window.GetProperty("ext") == 0) {
output_file = output_path + "plist " + plist_name + ".txt";
} else {
output_file = output_path + "plist " + plist_name + ".xls";
}
try {
file = fso.CreateTextFile( output_file );
}
catch(e) {
if (e.number == -2146828218) return; // permission denied
}
for (var i = 0; i < fb.GetSelections().Count; i++) {
item = fb.GetSelections().Item(i);
text = [];
for (var j = 0; j < outtag.length; j++) {
select = fb.TitleFormat("[" + outtag[j] + "]").EvalWithMetadb(item);
if (select != "" ) {
var t = "";
if (outtag[j] == "$info(bitrate)") t = " kbps";
if (outtag[j] == "$info(samplerate)") t = " Hz";
if (outtag[j] == "$info(bitspersample)") t = " bps";
text.push(select + t);
}
var string = text.join(separator[window.GetProperty("ext")]);
}
window.SetProperty("string", string);
window.SetProperty("qqq", i + 1);
try {
file.WriteLine(string);
}
catch(e) {
if (e.number == -2146828283) { };
}
}
file.Close();
}
function on_mouse_lbtn_up (x, y){
var _menu = window.CreatePopupMenu();
var i = 1;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
_menu.AppendMenuItem(MF_ENABLED, i++, " create text file");
_menu.AppendMenuItem(0x00000800, 0, 0);
for (var j = 0; j < tag.length; j++) {
n = tag[j].replace(/[%\_\(\)]/g ,' ');
n = n.replace('$info','')
_menu.AppendMenuItem(MF_ENABLED, i++, n);
_menu.CheckMenuItem(i-1, window.GetProperty(i - 2));
}
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 100, " txt");
_menu.AppendMenuItem(MF_ENABLED, 101, " xls");
_menu.CheckMenuRadioItem(100, 101, 100 + window.GetProperty("ext"));
_menu.EnableMenuItem(100 + window.GetProperty("ext"), 1);
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 102, " clear all");
ret = _menu.TrackPopupMenu(x, y);
if (ret == 1 ) {
create_output_array();
}
else if (ret >= 2 && ret <= tag.length + 1) {
s = window.GetProperty(ret - 1);
window.SetProperty(ret - 1, s == 0 ? 1 : 0);
on_mouse_lbtn_up (x, y);
}
else if (ret == 100) {
window.SetProperty("ext", 0);
on_mouse_lbtn_up (x, y);
}
else if (ret == 101) {
window.SetProperty("ext", 1);
on_mouse_lbtn_up (x, y);
}
else if (ret == 102) {
for (var j = 1; j < tag.length + 1; j++) {
window.SetProperty(j, 0);
}
on_mouse_lbtn_up (x, y);
}
_menu.Dispose();
return true;
}
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
var font = gdi.Font("Arial",12,1);
var ww,wh;
var file_path, file_name, file_name_ext, attributes;
var txt;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var g_metadb;
on_item_focus_change();
function on_paint(gr){
gr.FillSolidRect (0, 0, ww, wh, RGB(50,50,50));
switch (attributes) {
case 32:
txt = "READ WRITE"; break;
case 33:
txt = "READ ONLY"; break;
}
gr.GdiDrawText( file_name, font, RGB(255,255,220), 10, 2, ww - 20, wh, 0x00000000|0x00040000 );
gr.DrawString( "file is " + txt, font, RGB(255,255,220), 10, 20, ww - 20, wh, 0 );
}
function on_item_focus_change() {
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
if (g_metadb) on_metadb_changed();
}
function on_metadb_changed() {
if (g_metadb) {
file_path = fb.Titleformat("%path%").EvalWithMetadb(g_metadb);
file_name = fb.Titleformat("%filename_ext%").EvalWithMetadb(g_metadb);
file_name_ext = fb.Titleformat("$ext([%filename_ext%])").EvalWithMetadb(g_metadb);
try {
file = fso.GetFile(file_path);
attributes = file.Attributes;
} catch(e) {};
}
window.Repaint();
}
function on_playback_new_track(g_metadb) {
on_item_focus_change();
}
function on_selection_changed(g_metadb) {
on_item_focus_change();
}
function on_mouse_lbtn_up (x, y){
var _menu = window.CreatePopupMenu();
var i = 1;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
RO = attributes == 33 ? MF_ENABLED : MF_GRAYED;
RW = attributes == 32 ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(RO, i++, "read write");
_menu.AppendMenuItem(RW, i++, "read only");
ret = _menu.TrackPopupMenu(x, y);
if (ret == 0) return;
switch (ret) {
case 1:
file.Attributes = 32;
on_item_focus_change();
break;
case 2:
file.Attributes = 33;
on_item_focus_change();
break;
}
_menu.Dispose();
return true;
}
function on_size(){
ww = window.Width;
wh = window.Height;
}
// ==PREPROCESSOR==
// @name "Touch Library Viewer"
// @version "1.0"
// @author "Terro"
// @feature "watch-metadb"
// @tooltip "custom-paint"
// ==/PREPROCESSOR==
var lbdn = 0;
var y_start = 0;
var y_end = 0;
var y_delta = 0;
var form_text = "",
form_text_b = "",
form_text_b_ = "",
form_his = [],
form_his_ = [];
var char_index = [],
playlist = [],
playlist_dr = [],
index_search = [],
index_path = [],
list = plman.GetPlaylistItems(-1),
list_;
var m_x = 0,m_y = 0,
ww = 0,wh = 0,
bold_start = 0,bold_end = 0,
mm_x = 0,mm_y =0,m_tam = -1,
idx_idx = 0, scroll = 0,scroll_ = 0,
mouse_index = -1,
form_text_cusor = 0,
form_text_cusor_x = 0,
repaint_visible = 0;
var g_time000 = window.CreateTimerInterval(16);
var time111 = (new Date().getTime()),
time222 = time111,
time333 = time111;
var fso = new ActiveXObject("Scripting.FileSystemObject"),
WshShell = new ActiveXObject("WScript.Shell"),
htmlfile = new ActiveXObject('htmlfile'),
vbe = new ActiveXObject('ScriptControl');
var time_h = fb.CreateProfiler(),
time_repaint = fb.CreateProfiler(),
time200 = fb.CreateProfiler("aaaa"),
time_s = fb.CreateProfiler();
var mouse_l_hold = false,mouse_l_hold_f = false,
window_visible = false,on_form = false,
mouse_hold = false,mouse_drag = false,
hold_shift = false,hold_ctrl = false,
hold_scroll = false,mouse_in = false,
repaint_f1 = false,repaint_f2 = false,repaint_f = false,
repaint_main = true,repaint_main1 = true,repaint_main2 = true,
form_text_cusor_hiden = true;
var shift_index = 0,
last_choose = -1,
selected_cusor = 0;
var grouph_by = window.GetProperty("Grouph by",0),
auto_colapse = window.GetProperty("auto colapse",false),
auto_exppant = window.GetProperty("auto exppant",false),
show_scripts = window.GetProperty("show_scripts",false),
grouph_option = window.GetProperty("grouph_option",""),
search_async = window.GetProperty("search_async",true),
font_size = window.GetProperty("font_size",11),
library_path = window.GetProperty("Library path",""),
istranparent = window.GetProperty("tranparent",true),
heigh_row = window.GetProperty("heigh_row",18),
Tooltip = window.GetProperty("Tooltip",true);
var g_tooltip = window.CreateTooltip(),
time_tooltip = fb.CreateProfiler("Time tooltip"),
tooltip_state = false,time_tooltip_ = 0;
g_tooltip.Text = " ";
g_tooltip.SetDelayTime(3, 0);
var library_path_ = library_path.split(";");
var choose_playlist = plman.GetPlaylistItems(-1);
var time_debug = [],time_c = 0;
var color_text = 0x00BEB4B4; //-------------text color
var background_color = 0xff000000;
var choose_background_color = 0xff0099ff;
var art_alb_sort = "\\%album artist%|%album%|%track number%|%title%";
var g_font = gdi.Font("Segoe UI", font_size, 0),
g_font2 = gdi.Font("Segoe UI", font_size, 1),
g_font3 = gdi.Font("Segoe UI", font_size, 2),
g_font_marker = gdi.Font("Courier New", font_size, 1);
var grouph_opt = grouph_option.split("|");
var exppant_,
research = false,
search_done = false,
research_k = 0;
vbe.Language = 'VBScript';
window.DlgCode = 0x0081 ;
var lib_search = "";
function indexer(){
var total = list.Count;
index_search = [];
index_path = [];
var TitleFormat = "%title% ^^ %album artist% ^^ %album% ^^ %genre% ^^ %path% ^^ %composer% ^^ %performer% ^^ %comment%";
var string = "", count = 0;
for(var i = 0;i < total;i++){
string = fb.TitleFormat(TitleFormat).EvalWithMetadb(list.Item(i));
index_search[count] = string;
count++;
}
switch(grouph_by){
case 0:
for(var i = 0;i < total;i++){
string = index_search[i].split(" ^^ ")[4];
for(var j = 0;j < library_path_.length;j++)
string = string.replace(library_path_[j],"");
index_path[i] = string.split("\\")[0];
}
break;
case 1:
for(var i = 0;i < total;i++){
string = index_search[i].split(" ^^ ")[1];
index_path[i] = (string.length < 2)?"Unknow Artist":string;
}
break;
case 2:
for(var i = 0;i < total;i++){
string = index_search[i].split(" ^^ ")[2];
index_path[i] = (string.length < 2)?"Unknow Album":string;
}
break;
case 3:
for(var i = 0;i < total;i++){
index_path[i] = fb.TitleFormat(grouph_opt[0]).EvalWithMetadb(list.Item(i));
}
break;
}
}
function get_library(reload){
var Time_library = fb.CreateProfiler("Time Out Refresh library");
var pl_name = "", pl_idx = -1,list_;
for(var i=0; i < plman.PlaylistCount; i++) {
pl_name = plman.GetPlaylistName(i);
if(pl_name == "WSH Library Filter") {
pl_idx = i;
break;
}
}
if(pl_idx < 0) {
pl_idx = plman.PlaylistCount;
fb.CreateAutoPlaylist(pl_idx,"WSH Library Filter","ALL","");
list = plman.GetPlaylistItems(pl_idx);
(grouph_by == 0) && list.OrderByRelativePath();
(grouph_by > 0) && list.OrderByFormat(fb.TitleFormat((grouph_by == 3)?grouph_option:art_alb_sort), 1);
plman.RemovePlaylist(pl_idx);
plman.CreatePlaylist(pl_idx,"WSH Library Filter");
plman.InsertPlaylistItems(pl_idx,0,list);
}else if(reload == 1){
fb.RemovePlaylist(pl_idx);
fb.CreateAutoPlaylist(pl_idx,"WSH Library Filter","ALL","");
list = plman.GetPlaylistItems(pl_idx);
(grouph_by == 0) && list.OrderByRelativePath();
(grouph_by > 0) && list.OrderByFormat(fb.TitleFormat((grouph_by == 3)?grouph_option:art_alb_sort), 1);
plman.RemovePlaylist(pl_idx);
plman.CreatePlaylist(pl_idx,"WSH Library Filter");
plman.InsertPlaylistItems(pl_idx,0,list);
}else if(reload == 2){
(grouph_by == 0) && list.OrderByRelativePath();
(grouph_by > 0) && list.OrderByFormat(fb.TitleFormat((grouph_by == 3)?grouph_option:art_alb_sort), 1);
plman.RemovePlaylist(pl_idx);
plman.CreatePlaylist(pl_idx,"WSH Library Filter");
plman.InsertPlaylistItems(pl_idx,0,list);
}else
list = plman.GetPlaylistItems(pl_idx);
indexer();
Time_library.Print();
}
function match(input, str){
input = input.toLowerCase();
for(var i in str){
if(input.indexOf(str[i]) < 0)
return false;
}
return true;
}
function prcess_string(str){
str_ = [];
str = str.toLowerCase();
while(str !=(temp = str.replace(" "," ")))
str = temp;
var str = str.split(" ").sort();
for(var i in str){
if(str[i] != "")
str_[str_.length] = str[i];
}
return str_;
}
var timeaaaa = fb.CreateProfiler();
function get_pl_tree(start,string_,force){
var Time = fb.CreateProfiler();
if(start == null){
scroll = 0;start = 0;form_text_b_ = form_text;
string_ = form_text;
playlist = [];
list_ = plman.GetPlaylistItems(-1);
timeaaaa.Reset();
}else if(form_text_b_ != form_text){
//fb.trace("Break -- -- -- -- Form text change");
return;
}
var i = playlist.length,k = start,temp = "";
str = prcess_string(form_text);
var path = "",string_add = "",temp = "",string = "",total = list.Count,count = 0;
var string_compare = (i > 0)?(playlist[i-1].name):"123456789123456789";
while(k < total){
count = 0;
while(count < 200 && k < total){
count++;
string = index_search[k];
if(!match(string,str)){
k++;continue;
}
temp = index_path[k];
if(string_compare.toUpperCase() != temp.toUpperCase()){
string_compare = temp;
playlist[i] = new Object();
playlist[i].name = temp;
playlist[i].alpha = 0;
playlist[i].child = [];
playlist[i].pl = plman.GetPlaylistItems(-1);
playlist[i].pl.Add(list.Item(k));
i++;
}else{
playlist[i-1].pl.Add(list.Item(k));
}
k++;
}
if(!force && Time.Time > 30){
research = true;
research_k = k;
fb.trace("Timeout break : " + Time.Time);
return;
}
}
repaint_main1 = repaint_main2;
fb.trace("Timeout break : " + Time.Time);
fb.trace("Timeout Searching Done : " + timeaaaa.Time);
tree_to_list(playlist,0);
if(auto_exppant && playlist.length == 1)
tree_expant(playlist[0]);
}
function tree_minimum(obj){
obj.child = [];
tree_to_list(playlist,0);
}
function tree_collasp(obj){
var child_ = 0;
if(obj.lv == 0){
for(var i = 0;i < playlist.length;i++){
child_ += playlist[i].child.length;
playlist[i].child = [];
}
}else{
var parrent = playlist_dr[obj.pr];
for(var i = 0;i < parrent.child.length;i++){
child_ += parrent.child[i].child.length;
parrent.child[i].child = [];
}
}
return child_;
}
function sorrt(a,b){
return (a.name > b.name)?1:-1;
}
function tree_expant(obj){
var i = 0,j = 0,k = 0;
var path = "",string_compare = "123456789123456798",string_add = "",temp = "",meta,album_artist = "",title = "",item__ = false,track = "";
while(k < obj.pl.Count){
path = get_fol_path(obj.pl.Item(k),obj.lv+1);
if(obj.leaf){
k++;
continue;
}
item__ = false;
if(path == "aaaaaa"){
path = fb.TitleFormat(" $caps([$num(%track number%,2). ] %title% [- %album artist%])").EvalWithMetadb(obj.pl.Item(k));
item__ = true;
}
if(string_compare.toUpperCase() != path.toUpperCase()){
string_compare= path;
obj.child[i] = new Object();
obj.child[i].name = path;
obj.child[i].alpha = 0;
obj.child[i].child = [];
obj.child[i].leaf = item__;
obj.child[i].pl = plman.GetPlaylistItems(-1);
obj.child[i].pl.Add(obj.pl.Item(k));
i++;
}else{
obj.child[i-1].pl.Add(obj.pl.Item(k));
}
k++;
}
obj.child.sort(sorrt);
tree_to_list(playlist,0);
if(auto_exppant && obj.child.length == 1 && !obj.child[0].leaf){
tree_expant(obj.child[0]);
}
}
function tree_to_list(obj,lv){
var parrent = playlist_dr.length - 1;
if(lv == 0)
playlist_dr = [];
for(var i = 0;i < obj.length;i++){
var idx = playlist_dr.length;
playlist_dr[idx] = obj[i];
playlist_dr[idx].lv = lv;
playlist_dr[idx].pr = parrent;
playlist_dr[idx].choose = false;
if(exppant_ == obj[i])
scroll = (idx- Math.round(m_y/heigh_row-1.5))*heigh_row;
if(obj[i].child.length > 0){
tree_to_list(obj[i].child,lv+1);
}
}
}
function get_fol_path(item,lv){
switch(grouph_by){
case 0:
var string = item.Path;
for(var i = 0;i < library_path_.length;i++)
string = string.replace(library_path_[i],"");
for(var i = 0;i < lv && string.indexOf("\\") != -1;i++)
string = string.substr(string.indexOf("\\")+1);
return (string.indexOf("\\") == -1)?("aaaaaa"):(string.substring(0,string.indexOf("\\")));
break;
case 1:
switch(lv){
case 0:
return fb.TitleFormat("$caps($if(%album artist%,%album artist%,Unknow Artist))").EvalWithMetadb(item);
case 1:
return fb.TitleFormat("$caps($if(%album%,%album%,Unknow Album))").EvalWithMetadb(item);
default:
return "aaaaaa";
}
break;
case 2:
if(lv == 0){
return fb.TitleFormat("$caps($if(%album artist%,%album artist%,Unknow Artist) - $if(%album%,%album%,Unknow Album))").EvalWithMetadb(item);
}else
return "aaaaaa";
break;
case 3:
if(lv < grouph_opt.length){
return fb.TitleFormat(grouph_opt[lv]).EvalWithMetadb(item);
}else
return "aaaaaa";
break;
}
}
function on_size(){
ww = window.Width;
wh = window.Height;
scroll_++;
repaint_main1 = repaint_main2;
repaint_f1 = repaint_f2;
}
function get_cusor_index(x){
var result = form_text.length;
while(char_index[result] > x )
result--;
return (result > 0)?result:0;
}
function refresh_char_index(gr){
char_index = [];
for(var i = 0;i < form_text.length + 1;i++)
char_index[i] = gr.EstimateLineWrap(form_text.substr(0,i),g_font,ww).toArray()[1];
}
function on_mouse_lbtn_up(x,y,mask){
lbdn = 0;
y_start = y;
if(mouse_drag && x > ww)
add_playlist(choose_playlist);
mouse_drag = mouse_hold = mouse_l_hold = mouse_l_hold_f = hold_scroll = false;
var tam = Math.round((y + scroll - heigh_row * 1.5)/heigh_row);
if(y > heigh_row && tam < playlist_dr.length && tam >= 0 && check_item(playlist_dr[tam],x,y)){
(mm_x == x && mm_y == y) && on_chose(tam,!(mm_x == x && mm_y == y));
}
}
function on_mouse_lbtn_dblclk(x,y,mask){
var tam = Math.round((y + scroll - heigh_row*1.5)/heigh_row);
if(y > heigh_row && tam < playlist_dr.length && tam >= 0 && check_item(playlist_dr[tam],x,y))
apply_playlist(playlist_dr[tam].pl);
else if(y < heigh_row)
on_mouse_lbtn_down(x,y,1.5);
else
on_mouse_lbtn_down(x,y,mask);
}
function check_item(obj,x,y){
if(!obj) return false;
return (x > (heigh_row * (obj.lv + 1)) && x < (heigh_row * (obj.lv + 1) + obj.rg));
}
function on_mouse_lbtn_down(x,y,mask){
lbdn = 1;
y_start = y;
g_drag = true;
mouse_l_hold_f = on_form = (y < heigh_row);
mouse_l_hold = !mouse_l_hold_f;
if(y < heigh_row){
if(x < ww - heigh_row){
form_text_cusor = get_cusor_index(x);
repaint_f1 = repaint_f2;
form_text_cusor_hiden = true;
time111 = (new Date()).getTime();
if(mask == 1.5){
bold_start = (" " + form_text + " ").lastIndexOf(" ",form_text_cusor);
bold_end = (" " + form_text + " ").indexOf(" ",form_text_cusor+1)-1;
}else
bold_start = bold_end = form_text_cusor;
}else if(x > ww - heigh_row){
bold_start = bold_end = form_text_cusor = 0;
form_text = "";
time333 = (new Date()).getTime() + 800;
}
return;
}
if(y > heigh_row ){
var tam = Math.round((y + scroll - heigh_row * 1.5)/heigh_row);
if(tam < playlist_dr.length && tam >= 0){
var playlist_tmp = playlist_dr[tam];
if(heigh_row * (playlist_tmp.lv + 1)> x && heigh_row * playlist_tmp.lv < x){
//TREE EXPANT OR COLAPSE
if(playlist_tmp.child.length > 0){
tree_minimum(playlist_tmp);
}else{
exppant_ = playlist_tmp;
auto_colapse && tree_collasp(playlist_tmp);
tree_expant(playlist_tmp);
}
}else if(check_item(playlist_tmp,x,y)){
//ITEM CHOOSE
mm_x = x;mm_y = y;
mouse_drag = true;
if(!playlist_tmp.choose){
on_chose(tam,playlist_tmp.choose);
selected_cusor = tam;
mouse_hold = true;
}
}else
on_chose(-1);
repaint_main1 = repaint_main2;
repaint_f1 = repaint_f2;
}else
on_chose(-1);
}
if(playlist_dr.length * heigh_row > wh && x > ww - 8){
hold_scroll = true;
scroll = Math.round((((y - heigh_row) * (playlist_dr.length * heigh_row ) / (wh - heigh_row)) - (wh - heigh_row)/2)/heigh_row-0.5)*heigh_row;
}
}
function on_chose(index,mouse_up){
repaint_main1 = repaint_main2;
if(index == -1){
for(var k = 0;k < playlist_dr.length;k++)
playlist_dr[k].choose = false;
}else if((utils.IsKeyPressed(0x10) || mouse_hold)&& last_choose > -1){
choose_playlist = plman.GetPlaylistItems(-1);
var dd = (index > last_choose)?1:-1;
if(!utils.IsKeyPressed(0x11)){
for(var k = 0;k < playlist_dr.length;k++)
playlist_dr[k].choose = false;
}
for(var k = last_choose; ;k += dd){
playlist_dr[k].choose = true;
choose_playlist.AddRange(playlist_dr[k].pl);
if(k==index)
break;
}
repaint_main1 = repaint_main2;
}else if(utils.IsKeyPressed(0x11)){
playlist_dr[index].choose = !playlist_dr[index].choose;
playlist_dr[index].choose && choose_playlist.AddRange(playlist_dr[index].pl);
last_choose = index;
}else if(!mouse_up){
choose_playlist = plman.GetPlaylistItems(-1);
for(var k = 0;k < playlist_dr.length;k++)
playlist_dr[k].choose = false;
playlist_dr[index].choose = true;
choose_playlist.AddRange(playlist_dr[index].pl);
last_choose = index;
}
}
function check_playlist(name){
var pl_name = "", pl_idx = -1;
for(var i=0; i < plman.PlaylistCount; i++) {
pl_name = plman.GetPlaylistName(i);
if(pl_name == name) {
pl_idx = i;
break;
}
}
return pl_idx;
}
function on_char(code){
time333 = (new Date()).getTime();
if(on_form){
form_text_cusor_hiden = true;
selected_cusor = -1;
var input = String.fromCharCode(code);
switch(code){
case 13://ENTER
if(form_text.length < 3)
break;
str = prcess_string(form_text);
var total = list.Count;
var pltemp = plman.GetPlaylistItems(-1);
for(var i = 0;i < total;i++)
if(match(index_search[i],str))
pltemp.Add(list.Item(i));
apply_playlist(pltemp);
pltemp.Dispose();
break;
case 25:
form_his.push(form_text);
if(form_his.length > 30) form_his.shift();
if(form_his_.length > 0) form_text = form_his_.pop() + "";
break;
case 26:
form_his_.push(form_text);
if(form_his_.length > 30) form_his.shift();
if(form_his.length > 0) form_text = form_his.pop() + "";
break;
case 1://CTRL + A
bold_start = 0;
bold_end = form_text.length;
break;
case 3: // COPPY
(bold_start != bold_end) && htmlfile.parentWindow.clipboardData.setData('text',form_text.substring(bold_start,bold_end));
break;
case 24://CUT
(bold_start != bold_end) && htmlfile.parentWindow.clipboardData.setData('text',form_text.substring(bold_start,bold_end));
case 8://DELETE
save_form_his();
if(bold_start == bold_end){
form_text = form_text.substring(0,form_text_cusor-1) + form_text.substring(form_text_cusor,200);
if(form_text_cusor > 0)
form_text_cusor--;
bold_end = bold_start = form_text_cusor;
}else{
form_text = form_text.substring(0,bold_start) + form_text.substring(bold_end,200);
form_text_cusor = bold_start;
bold_end = bold_start;
}
break;
case 22://CTRL + V//PASTE
input = htmlfile.parentWindow.clipboardData.getData('text');
default: //CHAR
save_form_his();
if(char_index[form_text.length] + heigh_row >= ww - 10)
break;
if(bold_start == bold_end){
form_text = form_text.substring(0,form_text_cusor) + input + form_text.substring(form_text_cusor,200);
form_text_cusor += input.length;
bold_end = bold_start = form_text_cusor;
}else{
form_text = form_text.substring(0,bold_start) + input + form_text.substring(bold_end,200);
form_text_cusor = bold_start + input.length;
bold_end = bold_start;
}
break;
}
repaint_f1 = repaint_f2;
}
}
function save_form_his(){
if(time_h.Time < 100)
return;
form_his.push(form_text);
form_his_ = [];
if(form_his.length > 30) form_his.shift();
time_h.Reset();
}
function on_key_down(vkey) {
switch(vkey){
case 0x25:case 0x27:
if(!on_form)return;
if(vkey == 0x25 && form_text_cusor > 0)
form_text_cusor--;
if(vkey == 0x27 && form_text_cusor < form_text.length)
form_text_cusor++;
if(hold_shift){
bold_start = Math.min(form_text_cusor,shift_index);
bold_end = Math.max(form_text_cusor,shift_index);
}else
bold_start = bold_end = form_text_cusor;
break;
case 0x10:
hold_shift = true;
shift_index = form_text_cusor;
break;
case 0x11:
hold_ctrl = true;
break;
case 13:
if(on_form)return;
if(choose_playlist.Count == 0) return;
//apply_playlist(choose_playlist);
add_playlist(choose_playlist);//---------------add to playlist
break;
case 40:case 38:
if(playlist_dr.length == 0)
break;
(vkey == 40) && selected_cusor++;
(vkey == 38) && selected_cusor--;
selected_cusor = (selected_cusor + playlist_dr.length)% playlist_dr.length;
if((selected_cusor + 2) * heigh_row - (scroll + wh - heigh_row) > 0)
scroll = (selected_cusor + 3) * heigh_row - Math.round(wh / heigh_row - 1)* heigh_row;
else if((selected_cusor - 1) * heigh_row - scroll < 0)
scroll = (selected_cusor - 1) * heigh_row;
on_chose(selected_cusor);
repaint_main1 = repaint_main2;
break;
case 46:
on_key_down(39);
on_char(8);
break;
}
repaint_f1 = repaint_f2;
form_text_cusor_hiden = true;
}
function on_key_up(vkey){
switch(vkey){
case 0x10:
hold_shift = false;
shift_index = form_text_cusor;
break;
case 0x11:
hold_ctrl = false;
break;
}
}
function on_mouse_move(x,y){
if (lbdn) {
y_end = y;
y_delta = (y_end - y_start);
if (x < ww){
if (y_delta > wh/25) {
on_mouse_wheel(1);
window.Repaint()
y_start = y_end;
}
if (y_delta < -wh/25) {
on_mouse_wheel(-1)
window.Repaint()
y_start = y_end;
};
}
}
if(x==m_x && y==m_y) return true;
//}
//if(m_x == x && m_y == y)
//return;
mouse_in = true;
if(y < heigh_row && x < ww - heigh_row)
window.SetCursor(32513);
else
window.SetCursor(32512);
if(y < heigh_row && mouse_l_hold_f){
bold_start = form_text_cusor;
bold_end = get_cusor_index(x);
if(bold_start > bold_end){
var tam = bold_start;
bold_start = bold_end;
bold_end = tam;
}
repaint_f1 = repaint_f2;
}
if(m_x > ww-heigh_row && m_y < heigh_row)
//repaint_f1 = repaint_f2;
m_x = x;m_y = y;
var tam = Math.round((y - heigh_row*1.5)/heigh_row);
if(tam < playlist_dr.length && tam >= 0){
repaint_main1 = repaint_main2;
}
if(hold_scroll){
scroll = Math.round((((y - heigh_row) * (playlist_dr.length * heigh_row ) / (wh - heigh_row)) - (wh - heigh_row)/2)/heigh_row-0.5)*heigh_row;
}
time_tooltip.Reset();
}
function on_mouse_leave(){
m_x = x_y = 0;
mouse_drag = mouse_hold = mouse_in = false;
}
function apply_playlist(playlist){
var pl_idx = check_playlist("Library view");
if(pl_idx == -1){
pl_idx = fb.PlaylistCount;
fb.CreatePlaylist(pl_idx,"Library view");
}else{
fb.ActivePlaylist = pl_idx;
fb.RunMainMenuCommand("Edit/Clear");
}
fb.ActivePlaylist = pl_idx;
var playlist_ = playlist.Clone();
playlist_.OrderByFormat(fb.TitleFormat("$if([%album artist%],%album artist%,zzzz)|$if([%album%],[%date%]%album%,zzzz)|$if(%track number%,%track number%,zzzz)|$sub(5,%rating%)|%title%"),1);
plman.InsertPlaylistItems(pl_idx,1,playlist_);
fb.ActivePlaylist = pl_idx;
plman.ExecutePlaylistDefaultAction(pl_idx,0);
fb.RunMainMenuCommand("Edit/Remove Duplicates");
}
function add_playlist(playlist){
playlist.OrderByFormat(fb.TitleFormat("$if([%album artist%],%album artist%,zzzz)|$if([%album%],[%date%]%album%,zzzz)|$if(%track number%,%track number%,zzzz)|$sub(5,%rating%)|%title%"),1);
plman.InsertPlaylistItems(fb.ActivePlaylist,plman.PlaylistItemCount(fb.ActivePlaylist),playlist);
fb.RunMainMenuCommand("Edit/Remove Duplicates");
}
function on_mouse_mbtn_down(x,y,mask){
var tam = Math.round((y + scroll - heigh_row*1.5)/heigh_row);
if(y > heigh_row && tam < playlist_dr.length && tam >= 0)
check_item(playlist_dr[tam],x,y) && add_playlist(playlist_dr[tam].pl);
}
function on_paint(gr){
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, 0xff000000);
if(!repaint_main && !repaint_f)
repaint_main = repaint_f = true;
if(repaint_main){
repaint_main = false;
var index = 0,j = 0,start_ = 0,end_ = 0,alpha = 0;
var count_,head_,name_,width_,left_mg;
var width_aaa = gr.CalcTextWidth("(+) ",g_font);
start_ = Math.round(scroll_/heigh_row + 0.4);
end_ = Math.round((scroll_ + wh)/heigh_row - 0.5);
end_ = (playlist_dr.length < end_)?playlist_dr.length:end_;
for(var i = start_;i < end_;i++){
alpha = (playlist_dr[i].alpha<<24)|0xffffff;
count_ = (playlist_dr[i].pl.Count >1)?(" (" +playlist_dr[i].pl.Count + ")"):("");
head_ = playlist_dr[i].leaf?"✚ ":((playlist_dr[i].child.length < 1)?"(+) ":"(--) ");
name_= head_ + playlist_dr[i].name + count_ + "";
width_ = gr.CalcTextWidth(name_,g_font) - (playlist_dr[i].leaf?0:width_aaa) + heigh_row * 0.2;
playlist_dr[i].rg = width_ - (playlist_dr[i].leaf?heigh_row:0);
playlist_dr[i].choose ?(playlist_dr[i].alpha = Math.min(playlist_dr[i].alpha + 40,255))
:((mouse_index != i) && (playlist_dr[i].alpha = Math.max(playlist_dr[i].alpha - 15,0)));
(playlist_dr[i].alpha % 255 !=0) && (repaint_main1 = repaint_main2);
(playlist_dr[i].alpha > 0) && gr.FillSolidRect((heigh_row * playlist_dr[i].lv) + (playlist_dr[i].leaf?0:width_aaa),(i + 1)* heigh_row - scroll_ + 0.5,width_,heigh_row*0.95,(0xFFDC143C & alpha));//---select color
left_mg = heigh_row * (playlist_dr[i].lv + 0.1);
gr.GdiDrawText(name_, g_font, color_text,left_mg,heigh_row * (i + 1.1)- scroll_-5, ww - left_mg, heigh_row, 0x800);
}
if(playlist_dr.length * heigh_row > wh - heigh_row){
var hei = playlist_dr.length * heigh_row;
//gr.FillGradRect(ww-7,heigh_row,7,wh-heigh_row,0,0x60000000,0x60000000);
gr.FillGradRect(ww-6,heigh_row + (scroll_*(wh-heigh_row)/hei),5,((wh-heigh_row)*(wh-heigh_row)/hei)-1,0,0xa0ffffff,0xa0ffffff);
}
}
if(repaint_f){
repaint_f = false;
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, heigh_row, 0x80555555);
!window.IsTransparent && gr.DrawRect(0, 0, ww, heigh_row, 1,0x70ffffff);
refresh_char_index(gr);
bold_start = Math.max(bold_start,0);
bold_end = Math.max(bold_end,0);
form_text_cusor = Math.max(form_text_cusor,0);
bold_start = Math.min(bold_start,form_text.length);
bold_end = Math.min(bold_end,form_text.length);
form_text_cusor = Math.min(form_text_cusor,form_text.length);
gr.DrawLine(0,heigh_row/2,ww,heigh_row/2,heigh_row,0x60000000);
on_form && form_text_cusor_hiden && (bold_start == bold_end) && gr.DrawLine(char_index[form_text_cusor] + heigh_row/10,heigh_row/10,char_index[form_text_cusor] + heigh_row/10,heigh_row*0.9,1,color_text);
bold_end = (bold_end < form_text.length)?bold_end:form_text.length;
(bold_start != bold_end) && gr.DrawLine(char_index[bold_start] + heigh_row/10,heigh_row/2,char_index[bold_end] + heigh_row/10,heigh_row/2,heigh_row-3,choose_background_color);
gr.GdiDrawText(form_text, g_font, color_text, heigh_row/10, heigh_row/10, ww, heigh_row, 0);
(form_text == "") && gr.GdiDrawText("Tap and type to Search", g_font3, 0x55888888, heigh_row/10, heigh_row/10, ww, heigh_row, 0);
gr.DrawLine(ww-heigh_row*0.8,heigh_row*0.8,ww - heigh_row*0.2,heigh_row*0.2,heigh_row/10,(m_x > ww-heigh_row && m_y < heigh_row)?0xf0ffffff:0x60ffffff);
gr.DrawLine(ww-heigh_row*0.8,heigh_row*0.2,ww - heigh_row*0.2,heigh_row*0.8,heigh_row/10,(m_x > ww-heigh_row && m_y < heigh_row)?0xf0ffffff:0x60ffffff);
}
}
function on_timer(g_time333){
if(!window.IsVisible)
return;
on_timer_(g_time333);
}
function on_timer_(g_time333){
var repaint_1 = false,repaint_2 = false;
var time_dl = time_s.Time;
if(research){
research = false;
get_pl_tree(research_k,form_text);
return;
}
var d = new Date();
if(d.getTime() - time222 < 15)
return
else
time222 = d.getTime();
if(d.getTime() - time333 > 200 && on_form && form_text_b != form_text){
time333 = d.getTime();
form_text_b = form_text;
lib_search = form_text;
get_pl_tree();
}
mouse_index = -1;
var tam = check_item_index(m_x,m_y);
if(tam != -1){
playlist_dr[tam].alpha = Math.min(playlist_dr[tam].alpha + 40,255);
if(m_tam != tam){
mouse_hold && on_chose(tam);
deactive_tooltip();
}else{
Tooltip && (time_tooltip_ += time_dl);
}
if(Tooltip && time_tooltip_ > 3000 && !tooltip_state && (heigh_row * (playlist_dr[tam].lv + 1) + playlist_dr[tam].rg) > ww && playlist_dr[tam].alpha > 250){
g_tooltip.Width = playlist_dr[tam].rg;
g_tooltip.Height = heigh_row;
active_tooltip();
g_tooltip.TrackPosition(heigh_row * (playlist_dr[tam].lv + 1), Math.floor((m_y+1) / heigh_row) * heigh_row - 1);
g_tooltip.Text = " ";
}else
deactive_tooltip();
mouse_index = tam;
m_tam = tam;
}
if(time_tooltip.Time > 7000){
deactive_tooltip();
}
if(d.getTime() - time111 > 600 && on_form){
form_text_cusor_hiden = !form_text_cusor_hiden;
time111 = d.getTime();
repaint_1 = true;
}
if(repaint_f1 == repaint_f2){
repaint_f2 = !repaint_f1;
repaint_1 = true;
}
if(repaint_main1 == repaint_main2){
repaint_main2 = !repaint_main1;
repaint_2 = true;
}
scroll = check_scroll(scroll);
if(scroll - scroll_ < -1 || scroll - scroll_ > 1){
scroll_ += (scroll - scroll_)/7;
time_tooltip.Reset();
repaint_2 = true;
}
if(repaint_1 && repaint_2){
time_s.Reset();
repaint_main = true;
repaint_f = true;
window.Repaint();
}else if(repaint_1){
repaint_f = true;
window.RepaintRect(0,0,ww,heigh_row,true);
}else if(repaint_2){
repaint_main = true;
time_s.Reset();
window.RepaintRect(0,heigh_row,ww,wh-heigh_row,true);
}
}
function check_item_index(x,y){
var tam = Math.round((y + scroll_ - heigh_row*1.5)/heigh_row);
if(playlist_dr.length > tam && tam >= 0 && x < ww -10 && y > heigh_row && check_item(playlist_dr[tam],x,y))
return tam;
else return -1;
}
function on_mouse_wheel(step){
if(utils.IsKeyPressed(0x11)){
font_size += step;
if(font_size > 40)
font_size = 40;
else if(font_size < 10)
font_size = 10;
window.SetProperty("font_size",font_size);
g_font = gdi.Font("Segoe UI", font_size, 0);
g_font2 = gdi.Font("Segoe UI", font_size, 1);
g_font3 = gdi.Font("Segoe UI", font_size, 2);
g_font_marker = gdi.Font("Courier New", font_size, 1);
heigh_row = Math.floor(font_size*16/11);
window.SetProperty("heigh_row",heigh_row);
repaint_f1 = repaint_f2;repaint_main1 = repaint_main2;
return;
}
scroll -= step*heigh_row*1;
scroll = check_scroll(scroll);
}
function check_scroll(scroll___){
scroll___ = Math.round(scroll___ / heigh_row ) * heigh_row;
if(scroll___ > ((playlist_dr.length + 2 )* heigh_row - wh ))
scroll___ = Math.round(((playlist_dr.length + 2 )* heigh_row - wh )/heigh_row - 0.5)*heigh_row;
if(playlist_dr.length*heigh_row < wh - heigh_row)
scroll___ = 0;
if(scroll___ < 0)
scroll___ = 0;
return scroll___;
}
function on_mouse_rbtn_up(x, y){
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var _menu = window.CreatePopupMenu();
var _menu1 = window.CreatePopupMenu();
var Context = fb.CreateContextMenuManager();
var con_ = false,time_111,idx;
_menu1.AppendMenuItem(MF_STRING, 2, "Grouph by Path");
_menu1.AppendMenuItem(MF_STRING, 3, "Grouph by Artist - Album");
_menu1.AppendMenuItem(MF_STRING, 4, "Grouph by Album");
_menu1.AppendMenuItem(MF_STRING, 5, "Grouph by User");
_menu1.AppendMenuSeparator();
_menu1.AppendMenuItem(MF_STRING, 11, "Auto Exppant");
_menu1.AppendMenuItem(MF_STRING, 12, "Auto Collapse");
_menu1.AppendMenuItem(MF_STRING, 15, "Tooltip");
_menu1.AppendMenuSeparator();
_menu1.AppendMenuItem(MF_STRING, 9, "Reefresh Library");
_menu1.AppendMenuItem(MF_STRING, 13, "Configure Library Path");
show_scripts && _menu1.AppendMenuItem(MF_STRING, 1, "Show Configure Scripts");
_menu1.AppendMenuItem(MF_STRING, 100, "Show Properties");
_menu1.CheckMenuRadioItem(2, 5,grouph_by + 2);
_menu1.CheckMenuItem(11,auto_exppant);
_menu1.CheckMenuItem(12,auto_colapse);
_menu1.CheckMenuItem(15,Tooltip);
var tam = Math.round((y + scroll_ - heigh_row*1.5)/heigh_row);
if(y > heigh_row && playlist_dr.length > tam && tam >= 0 && x < ww - heigh_row/2 && check_item(playlist_dr[tam],x,y)){
!playlist_dr[tam].choose && on_chose(tam);
_menu.AppendMenuItem(MF_STRING, 21, "Send to Playing Playlist");
_menu.AppendMenuItem(MF_STRING, 22, "Add to Playing Playlist");
con_ = true;
} else
on_chose(-1);
_menu1.AppendTo(_menu,MF_STRING, "Preferences");
if(con_){
_menu.AppendMenuSeparator();
Context.InitContext(choose_playlist);
Context.BuildMenu(_menu, 30, -1);
}
idx = _menu.TrackPopupMenu(x,y);
switch(idx) {
case 1:
window.ShowConfigure();
break;
case 2:case 3:case 4:case 5:
grouph_by = idx-2;
window.SetProperty("Grouph by",grouph_by);
get_library(2);
get_pl_tree();
repaint_f1 = repaint_f2;
repaint_main1 = repaint_main2;
break;
case 9:
get_library(1);
get_pl_tree();
repaint_f1 = repaint_f2;
repaint_main1 = repaint_main2;
break;
case 11:
auto_exppant = !auto_exppant;
window.SetProperty("auto exppant",auto_exppant);
get_pl_tree();
repaint_f1 = repaint_f2;
repaint_main1 = repaint_main2;
break;
case 12:
auto_colapse = !auto_colapse;
window.SetProperty("auto colapse",auto_colapse);
get_pl_tree();
repaint_f1 = repaint_f2;
repaint_main1 = repaint_main2;
break;
case 13:
var lib_filter = vbe.eval("InputBox(\"Example : \" + chr(10) + \"D:\\music\\;D:\\lossless\\\" + chr(10) + \"NULL to reset default\",\"Edit library Path\",\"" + library_path + "\")");
if(lib_filter == "NULL" || lib_filter == "null")
library_path = "E:\\music\\lossless\\;E:\\music\\lossly\\320kps\\";
else if(lib_filter)
library_path = lib_filter;
library_path_ = library_path.split(";");
window.SetProperty("Library path",library_path);
get_library(1);
get_pl_tree();
repaint_f1 = repaint_f2;
repaint_main1 = repaint_main2;
break;
case 15:
Tooltip = !Tooltip;
window.SetProperty("Tooltip",Tooltip);
break;
case 21:
apply_playlist(choose_playlist);
break;
case 22:
add_playlist(choose_playlist);
break;
case 100:
window.ShowProperties();
break;
default:
con_ && Context.ExecuteByID(idx-30);
break;
}
_menu.Dispose();
_menu1.Dispose();
Context.Dispose();
return true;
}
function active_tooltip(){
if(!tooltip_state){
tooltip_state = true;
g_tooltip.Activate();
g_tooltip.TrackActivate = true;
}
}
function deactive_tooltip(){
if(tooltip_state){
tooltip_state = false;
g_tooltip.TrackActivate = false;
g_tooltip.Deactivate();
time_tooltip_ = 0;
time_tooltip.Reset();
}
}
var a000001 = window.SetTimeout(function(){
get_library();
if(form_text == ""){
get_pl_tree();
repaint_f1 = repaint_f2;
repaint_main1 = repaint_main2;
}
window.ClearTimeout(a000001);
},500);
function on_tooltip_custom_paint(gr){
var tam = check_item_index(m_x,m_y);
var dr_str = playlist_dr[tam].name + (playlist_dr[tam].leaf?(""):(" (" + playlist_dr[tam].pl.Count + ")"));
gr.GdiDrawText(dr_str, g_font, 0xaa333333,font_size * 0.2,heigh_row * 0.1,playlist_dr[tam].rg, heigh_row, 0x804);
}
понятно , хотя выглядит он при старте весьма скромно - одна строчка вверху на чёрном фоне :)тут я вряд-ли помогу. Скрипт для меня сложный
с JSPlaylist - можно легко вызвать проблему - выбрав что-то из библиотеки , затем(переключится в плейлист)без полного понимания что-то исправлять (добавлять)
Вернуться в Секреты foobar2000