AHAPXICT, что должно происходить при паузе и при команде стоп.AHAPXICT:прицепить команду для режима паузы и стоп
Список разделов › foobar2000 › Секреты foobar2000
AHAPXICT, что должно происходить при паузе и при команде стоп.AHAPXICT:прицепить команду для режима паузы и стоп
// ==PREPROCESSOR==
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
var font = gdi.Font("DarkOne", 38, 0);
var ww,wh;
ColorTypeCUI = { background: 7,};
var bgcolor = window.GetColorCUI(ColorTypeCUI.background);
DT_LEFT = 0x00000000;
DT_RIGHT = 0x00000002;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
DT_WORD_ELLIPSIS = 0x00040000;
function on_paint(gr){
// !window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
var color1 = window.GetProperty("on_off") == "Воспроизвести" ? RGB(0,155,0): RGB(205,67,0);
gr.FillSolidRect (0, 0, ww, wh, s_play > 0 && s_play <= 3 && timer_started ? color1 : bgcolor);
var color2 = window.GetProperty("on_off") == "Воспроизвести" ? RGB(0,255,0) : RGB(255,175,89);
gr.GdiDrawText(sec2time(s_play), font, timer_started ? s_play > 3 ? color2 : RGB(255,255,255) : RGB(128,192,255), 0, 0, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
}
var ttttt = 0;
var set_time = 0;
var s_play = 0;
var timer_started = false;
var stop_timer = false;
window.GetProperty("on_off", "Воспроизвести");
function timer_play() {
if ((fb.IsPlaying && window.GetProperty("on_off") == "Воспроизвести") || (!fb.IsPlaying && window.GetProperty("on_off") == "Остановить")) {
s_play = 0;
set_time = 0;
return;
};
timer_started = true;
stop_timer = false;
window.ClearInterval(timer);
var timer = window.SetInterval(function() {
s_play = s_play - 1;
window.Repaint();
if (s_play <= 0 || stop_timer) {
window.ClearInterval(timer);
s_play = 0;
set_time = 0;
timer_started = false;
if (stop_timer) return;
if ((!fb.IsPlaying || fb.IsPaused) && window.GetProperty("on_off") == "Воспроизвести") {
fb.Play();
};
if (fb.IsPlaying && window.GetProperty("on_off") == "Остановить") {
fb.Stop();
};
};
}, 1000 );
}
var m2 = ["Секунды","Минуты","Часы"];
window.GetProperty("m2","Секунды");
var m3f, m3l
choice_s_m_h();
function choice_s_m_h() {
var m3 = [];
for (var i = 0; i < m2.length; i++) {
if(m2[i] != window.GetProperty("m2")) m3.push(m2[i]);
}
m3f = m3[0];
m3l = m3[1];
}
var step1, step_2;
set_step();
function set_step() { // if ShiftDown pressed
if (window.GetProperty("m2") == "Секунды") {step1 = 1; step2 = 10};
if (window.GetProperty("m2") == "Минуты") {step1 = 60; step2 = 600};
if (window.GetProperty("m2") == "Часы") {step1 = 3600; step2 = 3600};
}
function sec2time(sec) {
var h, m, s;
h = Math.floor(sec / 3600);
m = Math.floor((sec - h * 3600) / 60);
s = sec - h * 3600 - m * 60;
if ( m < 10 && h != 0) m = "0" + m;
if ( s < 10) s = "0" + s;
return (window.GetProperty("on_off") + " через " + (h == 0 ? "" : h + ":") + m + ":" + s);
}
function on_mouse_lbtn_up (x, y){
set_step();
set_time = set_time <= 0 ? 0 : set_time;
set_time = set_time >= 86400 ? 86400 : set_time;
if (!timer_started) s_play = set_time;
window.Repaint();
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
var _menu = window.CreatePopupMenu();
var i = 1;
MF_STATE1 = set_time == 0 || set_time == 86400 ? MF_GRAYED : MF_ENABLED;
_menu.AppendMenuItem(MF_STATE1, i++, timer_started ? "Таймер..." : sec2time(set_time));
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(0x00000000, i++, window.GetProperty("m2") + " + (с Shift шаг 10 для мин/сек)");
_menu.AppendMenuItem(0x00000000, i++, window.GetProperty("m2") + " - (с Shift шаг 10 для мин/сек)");
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(0x00000000, i++, m3f);
_menu.AppendMenuItem(0x00000000, i++, m3l);
_menu.AppendMenuItem(0x00000800, 0, 0);
MF_STATE2 = timer_started ? MF_GRAYED : MF_ENABLED;
_menu.AppendMenuItem(MF_STATE2, i++, window.GetProperty("on_off"));
if (timer_started) {
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(0x00000000, i++, "Сбросить таймер");
}
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
ret = _menu.TrackPopupMenu(x, y);
if (ret == 0) return;
switch (ret) {
case 1:
if (set_time > 0) {s_play = set_time; timer_play()};
break;
case 2:
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
set_time = set_time + (ShiftDown ? step2 : step1);
on_mouse_lbtn_up (x, y);
break;
case 3:
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
set_time = set_time - (ShiftDown ? step2 : step1);
on_mouse_lbtn_up(x,y);
break;
case 4:
window.SetProperty("m2",m3f);
choice_s_m_h();
set_step();
on_mouse_lbtn_up(x,y);
break;
case 5:
window.SetProperty("m2",m3l);
choice_s_m_h();
set_step();
on_mouse_lbtn_up(x,y);
break;
case 6:
window.GetProperty("on_off") == "Воспроизвести" ? window.SetProperty("on_off","Остановить") : window.SetProperty("on_off","Воспроизвести");
on_mouse_lbtn_up(x,y);
break;
case 7:
stop_timer = true;
timer_started = false;
break;
}
_menu.Dispose();
if (!timer_started) set_time = 0;
window.SetProperty("m2","Секунды");
choice_s_m_h();
}
function on_mouse_move(x, y) {
on_mouse = true;
window.SetCursor(32649);
window.Repaint();
}
function on_mouse_leave() {
on_mouse = false;
window.SetCursor(32512);
window.Repaint();
}
function on_size(){
ww = window.Width;
wh = window.Height;
}
AHAPXICT, вот так должно работать, вставить перед вычислением ширины строк:AHAPXICT:При паузе надписи из text1 и text2 заменяются на - PAUSE
скрин делал с одним размером шрифта, потом его поменял, а переделывать уже не охота...AHAPXICT:а чего верх текста обрезан?(Понял это только на скрине)
Эти "претензии" к kgena_ua.AHAPXICT:Только нужно // ==PREPROCESSOR== заполнить указать все авторские права и т.д. и т.п.
Так надо было снять галочку в меню "Отключить питание при срабатывании таймера"...AHAPXICT:таймер "сработал" так что во всём доме свет пропал
// ==PREPROCESSOR==
// @name "WSH Timer"
// @author "kgena_ua"
// ==/PREPROCESSOR==
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
var font = gdi.Font("Arial",12,1);
var ww,wh;
ColorTypeCUI = { background: 3,};
var bgcolor = window.GetColorCUI(ColorTypeCUI.background);
DT_LEFT = 0x00000000;
DT_RIGHT = 0x00000002;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
DT_WORD_ELLIPSIS = 0x00040000;
var txt = "timer";
function on_paint(gr){
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
gr.FillSolidRect (0, 0, ww, wh, bgcolor);
var txt_color = window.GetProperty("on_off") == "play" ? RGB(128,255,128) : RGB(255,175,89);
txt = timer_started ? sec2time(s_play) : txt;
if (blinking == 1) {
gr.GdiDrawText(txt, font, timer_started ? txt_color : RGB(200,200,200), 0, 0, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
}
gr.GdiDrawText("", font, RGB(255,255,255), 10, 10, ww, wh, DT_LEFT | DT_WORD_ELLIPSIS );
gr.GdiDrawText("", font, RGB(255,255,255), 10, 30, ww, wh, DT_LEFT | DT_WORD_ELLIPSIS );
}
var set_time = 0;
var s_play = 0;
var timer_started = false;
var stop_timer = false;
window.GetProperty("on_off", "play");
function timer_play() {
// if ((fb.IsPlaying && window.GetProperty("on_off") == "play") || (!fb.IsPlaying && window.GetProperty("on_off") == "stop")) {
// s_play = 0;
// set_time = 0;
// return;
// };
timer_started = true;
stop_timer = false;
text_blinking();
window.ClearInterval(timer);
var timer = window.SetInterval(function() {
s_play = s_play - 1;
window.Repaint();
if (s_play <= 0 || stop_timer) {
window.ClearInterval(timer);
s_play = 0;
set_time = 0;
timer_started = false;
txt = "timer";
if (stop_timer) return;
if ((!fb.IsPlaying || fb.IsPaused) && window.GetProperty("on_off") == "play") {
v_state = fb.Volume;
fb.Volume = -100;
fb.Play();
Vol(1);
};
if (fb.IsPlaying && window.GetProperty("on_off") == "stop") {
v_state = fb.Volume;
Vol(0);
Vol(1);
};
};
}, 1000 );
}
var m2 = ["seconds","minute","hour"];
window.GetProperty("m2","seconds");
var m3f, m3l
choice_s_m_h();
function choice_s_m_h() {
var m3 = [];
for (var i = 0; i < m2.length; i++) {
if(m2[i] != window.GetProperty("m2")) m3.push(m2[i]);
}
m3f = m3[0];
m3l = m3[1];
}
var step1, step_2;
set_step();
function set_step() { // if ShiftDown pressed
if (window.GetProperty("m2") == "seconds") {step1 = 1; step2 = 10};
if (window.GetProperty("m2") == "minute") {step1 = 60; step2 = 600};
if (window.GetProperty("m2") == "hour") {step1 = 3600; step2 = 3600};
}
function sec2time(sec) {
var h, m, s;
h = Math.floor(sec / 3600);
m = Math.floor((sec - h * 3600) / 60);
s = sec - h * 3600 - m * 60;
if ( m < 10 && h != 0) m = "0" + m;
if ( s < 10) s = "0" + s;
return (h == 0 ? "" : h + " : ") + m + " : " + s;
}
function on_mouse_lbtn_up (x, y){
set_step();
window.SetProperty("on_off", fb.IsPlaying ? "stop" : "play");
// set_time = set_time <= 0 ? 0 : set_time;
set_time = set_time >= 86400 ? 86400 : set_time;
/// if (!timer_started) s_play = set_time;
window.Repaint();
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
var _menu = window.CreatePopupMenu();
var i = 1;
MF_STATE1 = set_time == 0 || set_time == 86400 || timer_started ? MF_GRAYED : MF_ENABLED;
_menu.AppendMenuItem(MF_STATE1, i++, timer_started ? "timer ..." : sec2time(set_time));
MF_STATE2 = timer_started ? MF_GRAYED : MF_ENABLED;
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(MF_STATE2, i++, window.GetProperty("m2") + " +");
_menu.AppendMenuItem(MF_STATE2, i++, window.GetProperty("m2") + " -");
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(0x00000000, i++, m3f);
_menu.AppendMenuItem(0x00000000, i++, m3l);
_menu.AppendMenuItem(0x00000800, 0, 0);
// MF_STATE3 = timer_started ? MF_GRAYED : MF_ENABLED;
_menu.AppendMenuItem(0x00000000, i++, window.GetProperty("on_off"));
if (timer_started) {
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(0x00000000, i++, "clear timer");
}
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
ret = _menu.TrackPopupMenu(x, y);
if (ret == 0) return;
switch (ret) {
case 1:
if (set_time > 0) {s_play = set_time; timer_play()};
break;
case 2:
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
set_time = set_time + (ShiftDown ? step2 : step1);
on_mouse_lbtn_up (x, y);
break;
case 3:
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
set_time = set_time - (ShiftDown ? step2 : step1);
set_time = set_time < 0 ? 0 : set_time;
on_mouse_lbtn_up(x,y);
break;
case 4:
window.SetProperty("m2",m3f);
choice_s_m_h();
set_step();
on_mouse_lbtn_up(x,y);
break;
case 5:
window.SetProperty("m2",m3l);
choice_s_m_h();
set_step();
on_mouse_lbtn_up(x,y);
break;
case 6:
/// window.GetProperty("on_off") == "play" ? window.SetProperty("on_off","stop") : window.SetProperty("on_off","play");
on_mouse_lbtn_up(x,y);
break;
case 7:
stop_timer = true;
// timer_started = false;
s_play = 0;
set_time = 0;
window.Repaint();
break;
}
_menu.Dispose();
// if (!timer_started) set_time = 0;
window.SetProperty("m2","seconds");
choice_s_m_h();
}
function on_mouse_move(x, y) {
on_mouse = true;
window.SetCursor(32649);
window.Repaint();
}
function on_mouse_leave() {
on_mouse = false;
window.SetCursor(32512);
window.Repaint();
}
function on_size(){
ww = window.Width;
wh = window.Height;
}
var blinking = 1;
var i = 0;
function text_blinking() {
window.ClearInterval(timer2);
var timer2 = window.SetInterval(function() {
if (s_play <= 10) {
i = i + 100;
if (i <= 900) {blinking = 1}
if (i > 900 && i <= 1000) {blinking = 0}
if (i >= 1000) {i = 0}
window.Repaint();
}
if (!timer_started) {
blinking = 1;
i = 0;
window.ClearInterval(timer2);
};
}, 100 );
}
var v_on_off = 0;
var v_state = fb.Volume;
var v_flag = 0;
function Vol(v_on_off) {
var v_timer = window.SetInterval(function(){
if (v_on_off == 1) {
v_flag == 1 ? "" : txt = "play";
fb.Volume++;
if (fb.Volume >= v_state ) {txt = "timer"; window.ClearInterval(v_timer); v_flag = 0};
window.Repaint();
}
if (v_on_off == 0) {
v_flag = 1;
txt = "stop";
fb.Volume--;
if (fb.Volume <= -100 ) {fb.Stop(); txt = "timer"; window.ClearInterval(v_timer); Vol(1);};
window.Repaint();
}
},10);
}
Попробовал этот вариант, у меня, при быстром возврате регулятора громкости, прерванная концовка трека "вскрикивает", такое же замечал при интервале 10. Возможно это связанно с не стандартным Размером буфера на выводе. Поэтому думаю лучше оставить как было...kgena_ua:Хотя еще можно заменить с стр. 262 Vol(1); на fb.Volume = v_state;, т.е. после плавного снижения уровня громкости, резкий возврат уровня громкости до исходного состояния.
В таких вопросах зарекаться нельзя, возможно этот маленький таймер вырастет до целого будильника Эта мысль родилась когда интегрировал ваш скрипт в часы, так что бы всё было на одном экране. Но это время покажет.kgena_ua:Я думаю скрипт закончен
// ==PREPROCESSOR==
// @name "Volume"
// @author "T.P Wang"
// "change color" script by kgena_ua
// "Digital Clock" script by Hunter
// modifed AHAPXICT
// ==/PREPROCESSOR==
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
MF_SEPARATOR = 0x00000800;
MF_STRING = 0x00000000;
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 g_font = gdi.Font("Tahoma", 14, 1); //===FONT===//
var g_drag = 0;
var currentTime = new Date();
var clock_time = window.SetInterval(on_timer, 1000);
var v_change = false;
var v_timer = null;
get_color();
window.MinWidth = 72;
// ========DRAW======== //
function on_paint(gr){
var ww = window.Width;
var wh = window.Height;
var volume = fb.Volume;
var pos = window.Width * ((100+volume*1)/100);
var txt = volume.toFixed(2) + "dB";
var currentHours = currentTime.getHours ( );
var currentMinutes = currentTime.getMinutes ( );
var currentSeconds = currentTime.getSeconds ( );
currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
gr.FillSolidRect(0, 0, ww, wh, back_rgb);
gr.FillGradRect(0, 0, pos, wh, 90, font_rgb, back_rgb,1.0);
gr.FillGradRect(pos, 0, ww - pos, wh, 90, RGBA(255,255,255,150), back_rgb,1.0);
if (v_change) gr.GdiDrawText(fb.Volume.toFixed(2) + "dB", g_font, font_rgb, 0, 0, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
else {
gr.GdiDrawText( currentHours + ":" + currentMinutes + ":" + currentSeconds, g_font, font_rgb, 0, 0, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
}
// ========MENU======== //
function on_mouse_rbtn_up(x, y) {
var _menu = window.CreatePopupMenu();
_menu.AppendMenuItem(MF_STRING, 1, "Default");
_menu.AppendMenuItem(MF_STRING, 2, "Blue");
_menu.AppendMenuItem(MF_STRING, 3, "Green");
_menu.AppendMenuItem(MF_STRING, 4, "Red");
_menu.AppendMenuItem(MF_STRING, 5, "White");
_menu.AppendMenuItem(MF_STRING, 6, "Yellow")
_menu.AppendMenuItem(MF_STRING, 7, "Grey")
_menu.CheckMenuRadioItem(1, 7, window.GetProperty("Color", 1));
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0)
_menu.AppendMenuItem(MF_STRING, 8, "Properties...");
_menu.AppendMenuItem(MF_STRING, 9, "Configure...");
idx = _menu.TrackPopupMenu(x, y);
switch (idx) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
ch_color(idx);
break;
case 8:
window.ShowProperties();
break;
case 9:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true
}
//=======================//
var back_rgb, font_rgb;
function get_color() {
if (window.GetProperty("Color") == 1) font_rgb = RGB(191,228,255), back_rgb = RGB(24, 37, 46); //Default
if (window.GetProperty("Color") == 2) font_rgb = RGB(128,192,255), back_rgb = RGB(22, 36, 46); //Blue
if (window.GetProperty("Color") == 3) font_rgb = RGB(0,255,0), back_rgb = RGB(18, 38, 38); //Green
if (window.GetProperty("Color") == 4) font_rgb = RGB(255,0,0), back_rgb = RGB(38, 26, 34); //Red
if (window.GetProperty("Color") == 5) font_rgb = RGB(255,255,255), back_rgb = RGB(26, 38, 46); //White
if (window.GetProperty("Color") == 6) font_rgb = RGB(255,255,0), back_rgb = RGB(26, 38, 38); //Yellow
if (window.GetProperty("Color") == 7) font_rgb = RGB(76,121,153), back_rgb = RGB(22, 36, 45); //Grey
}
function getRed(color) {
return ((color >> 16) & 0xff);
}
function getGreen(color) {
return ((color >> 8) & 0xff);
}
function getBlue(color) {
return (color & 0xff);
}
var g_timer;
function ch_color(idx) {
get_color();
old_R = getRed(font_rgb);
old_G = getGreen(font_rgb);
old_B = getBlue(font_rgb);
window.SetProperty("Color", idx);
get_color();
new_R = getRed(font_rgb);
new_G = getGreen(font_rgb);
new_B = getBlue(font_rgb);
step_R = (new_R - old_R)/255; step_G = (new_G - old_G)/255; step_B = (new_B - old_B)/255;
g_timer = window.SetInterval(function() {
old_R = old_R + step_R; old_G = old_G + step_G; old_B = old_B + step_B;
R = old_R; G = old_G; B = old_B;
font_rgb = RGB(R,G,B)
window.Repaint();
if (
step_R < 0 && R <= new_R || step_G < 0 && G <= new_G || step_B < 0 && B <= new_B ||
step_R > 0 && R >= new_R || step_G > 0 && G >= new_G || step_B > 0 && B >= new_B
) {window.ClearInterval(g_timer); R = new_R; G = new_G; B = new_B; font_rgb = RGB(R,G,B)};
}, 5);
}
//==========MOUSE===========//
function on_mouse_lbtn_down(x,y){
g_drag = 1;
}
function on_mouse_lbtn_up(x,y){
on_mouse_move(x,y);
g_drag = 0;
}
function on_mouse_move(x,y){
if(g_drag){
var v = x / window.Width;
v = (v<0) ? 0 : (v<1) ? v : 1;
v = -100/1 * (1-v);
if(fb.Volume != v)
fb.Volume = v;
}
}
function on_mouse_wheel(delta){
if(delta>0)
fb.VolumeUp();
else
fb.VolumeDown();
}
function on_volume_change(val) {
var ww = window.Width;
var wh = window.Height;
if (v_timer) {
window.ClearTimeout(v_timer);
v_timer = null;
}
v_timer = window.SetTimeout(
function () {
window.RepaintRect(0, 0, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
window.ClearTimeout(v_timer);
v_timer = null;
v_change = false;
}, 3000);
v_change = true;
window.RepaintRect(0, 0, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
function on_timer(id){
currentTime = new Date();
window.Repaint();
}
//EOF
// ==PREPROCESSOR==
// @name "WSH Timer & Alarm clock"
// @author "kgena_ua"
// ==/PREPROCESSOR==
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
var font = gdi.Font("Arial",12,1);
var ww,wh;
ColorTypeCUI = { background: 3,};
var bgcolor = window.GetColorCUI(ColorTypeCUI.background);
var p_color = RGB(128,255,128);
var s_color = RGB(255,175,89);
var n_color = RGB(100,100,100);
var h_color = RGB(150,150,150);
var on_mouse = false;
DT_LEFT = 0x00000000;
DT_RIGHT = 0x00000002;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
DT_WORD_ELLIPSIS = 0x00040000;
var txt = "timer";
function on_paint(gr){
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
gr.FillSolidRect (0, 0, ww, wh, bgcolor);
var txt_color = window.GetProperty("on_off") == "play" ? p_color : s_color;
txt = timer_started ? sec2time(set_timer) : txt;
if (blinking == 1) {
gr.GdiDrawText(txt, font, timer_started || v_color ? txt_color : on_mouse ? h_color : n_color, 0, 0, ww, wh, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
}
// gr.GdiDrawText(sec2time(s_date) + " " + s_date + " set_timer " + set_timer , font, RGB(255,255,255), 10, 10, ww, wh, DT_LEFT | DT_WORD_ELLIPSIS );
// gr.GdiDrawText(timer_started, font, RGB(255,255,255), 10, 30, ww, wh, DT_LEFT | DT_WORD_ELLIPSIS );
}
var set_timer = 0;
var s_play = 0;
var timer_started = false;
var stop_timer = false;
window.GetProperty("on_off", "play");
window.GetProperty("ti_ac", "clock");
var check_ti_ac = window.GetProperty("ti_ac") == "timer" ? 0 : 1;
function timer_play() {
timer_started = true;
if (window.GetProperty("ti_ac") == "clock") {
d_timer();
}
stop_timer = false;
text_blinking();
window.ClearInterval(timer);
var timer = window.SetInterval(function() {
if (window.GetProperty("ti_ac") == "clock") {
//
} else {
set_timer = set_timer - 1;
}
window.Repaint();
if (set_timer <= 0 || Math.abs(s_date - set_timer) <= 0 || stop_timer) {
window.ClearInterval(timer);
set_timer = 0;
timer_started = false;
if (stop_timer) {txt = "timer"; return};
if (window.GetProperty("on_off") == "play") {
if (fb.IsPlaying && window.GetProperty("ti_ac") == "clock") {txt = "timer"; return};
v_state = fb.Volume;
fb.Volume = -100;
fb.Play();
Vol(1);
};
if (window.GetProperty("on_off") == "stop") {
if (!fb.IsPlaying && window.GetProperty("ti_ac") == "clock") {txt = "timer"; return};
v_state = fb.Volume;
Vol(0);
};
};
}, 1000 );
}
var smh = ["hour","minute","seconds",];
window.GetProperty("smh","hour");
var m3f, m3l;
choice_s_m_h();
function choice_s_m_h() {
var m3 = [];
for (var i = 0; i < smh.length; i++) {
if(smh[i] != window.GetProperty("smh")) m3.push(smh[i]);
}
m3f = m3[0];
m3l = m3[1];
}
var step1, step_2;
set_step();
function set_step() { // if ShiftDown pressed
if (window.GetProperty("smh") == "seconds") {step1 = 1; step2 = 10};
if (window.GetProperty("smh") == "minute") {step1 = 60; step2 = 600};
if (window.GetProperty("smh") == "hour") {step1 = 3600; step2 = 3600};
}
function sec2time(sec) {
var h, m, s;
h = Math.floor(sec / 3600);
m = Math.floor((sec - h * 3600) / 60);
s = sec - h * 3600 - m * 60;
if ( m < 10 && h != 0) m = "0" + m;
if ( s < 10) s = "0" + s;
return (h == 0 ? "" : h + " : ") + m + " : " + s;
}
function sec2time_2(sec) {
var h, m, s;
h = Math.floor(sec / 3600);
m = Math.floor((sec - h * 3600) / 60);
s = sec - h * 3600 - m * 60;
if ( h < 10 ) h = "0" + h;
if ( m < 10 ) m = "0" + m;
if ( s < 10 ) s = "0" + s;
return h + " : " + m + " : " + s;
}
function on_mouse_lbtn_up (x, y){
set_step();
if (window.GetProperty("ti_ac") == "timer") {
window.SetProperty("on_off", fb.IsPlaying ? "stop" : "play");
}
set_timer = set_timer >= 86400 ? 86400 : set_timer;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
MF_CHECKED = 0x00000008;
var _menu = window.CreatePopupMenu();
var i = 1;
MF_STATE1 = timer_started ? MF_GRAYED : MF_ENABLED;
_menu.AppendMenuItem(MF_ENABLED, i++, timer_started ? "timer ..." : sec2time_2(set_timer));
MF_STATE2 = timer_started ? MF_GRAYED : MF_ENABLED;
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(MF_STATE2, i++, window.GetProperty("smh") + " +"); // 2
_menu.AppendMenuItem(MF_STATE2, i++, window.GetProperty("smh") + " -"); // 3
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(MF_STATE2, i++, m3f); // 4
_menu.AppendMenuItem(MF_STATE2, i++, m3l); // 5
_menu.AppendMenuItem(0x00000800, 0, 0);
MF_STATE3 = window.GetProperty("ti_ac") == "clock" ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(MF_STATE3, i++, window.GetProperty("on_off")); // 6
_menu.AppendMenuItem(0x00000800, 0, 0);
MF_STATE4 = check_ti_ac == 0 ? MF_CHECKED : MF_ENABLED;
_menu.AppendMenuItem(MF_STATE4, i++, "timer"); // 7
MF_STATE5 = check_ti_ac == 1 ? MF_CHECKED : MF_ENABLED;
_menu.AppendMenuItem(MF_STATE5, i++, "alarm clock"); // 8
if (timer_started) {
_menu.AppendMenuItem(0x00000800, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, i++, "clear timer"); // 9
}
ret = _menu.TrackPopupMenu(x, y);
if (ret == 0) return;
switch (ret) {
case 1:
if (set_timer > 0) {timer_play()};
break;
case 2:
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
set_timer = set_timer + (ShiftDown ? step2 : step1);
set_timer = set_timer >= 86400 ? set_timer - 86400 : set_timer;
on_mouse_lbtn_up (x, y);
break;
case 3:
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
set_timer = set_timer - (ShiftDown ? step2 : step1);
set_timer = set_timer < 0 ? Math.abs(set_timer + 86400) : set_timer;
on_mouse_lbtn_up(x,y);
break;
case 4:
window.SetProperty("smh",m3f);
choice_s_m_h();
// set_step();
on_mouse_lbtn_up(x,y);
break;
case 5:
window.SetProperty("smh",m3l);
choice_s_m_h();
// set_step();
on_mouse_lbtn_up(x,y);
break;
case 6:
if (window.GetProperty("ti_ac") == "clock") {
window.GetProperty("on_off") == "play" ? window.SetProperty("on_off","stop") : window.SetProperty("on_off","play");
}
on_mouse_lbtn_up(x,y);
break;
case 7:
window.SetProperty("ti_ac","timer");
check_ti_ac = 0;
set_timer = 0;
on_mouse_lbtn_up(x,y);
break;
case 8:
window.SetProperty("ti_ac","clock");
check_ti_ac = 1;
set_timer = 0;
on_mouse_lbtn_up(x,y);
break;
case 9: // clear timer
stop_timer = true;
// timer_started = false;
// s_play = 0;
// set_timer = 0;
window.Repaint();
break;
}
_menu.Dispose();
if (!timer_started) {set_timer = 0; n_s = 0};
window.SetProperty("smh","hour");
choice_s_m_h();
}
function on_mouse_move(x, y) {
on_mouse = true;
window.SetCursor(32649);
window.Repaint();
}
function on_mouse_leave() {
on_mouse = false;
window.SetCursor(32512);
window.Repaint();
}
function on_size(){
ww = window.Width;
wh = window.Height;
}
var blinking = 1;
var i = 0;
function text_blinking() {
window.ClearInterval(timer2);
var timer2 = window.SetInterval(function() {
if (set_timer <= 10 || Math.abs(set_timer - s_date) <= 10) {
i = i + 100;
if (i <= 900) {blinking = 1}
if (i > 900 && i <= 1000) {blinking = 0}
if (i >= 1000) {i = 0}
window.Repaint();
}
if (!timer_started) {
blinking = 1;
i = 0;
window.ClearInterval(timer2);
};
}, 100 );
}
var v_on_off = 0;
var v_state = fb.Volume;
var v_flag = 0;
var v_color = false;
function Vol(v_on_off) {
v_color = true;
var v_timer = window.SetInterval(function(){
v_color = true;
if (v_on_off == 1) {
if (v_flag == 1) {txt = "timer"; v_color = false;} else {txt = "PLAY"};
fb.Volume++;
if (fb.Volume >= v_state ) {txt = "timer"; window.ClearInterval(v_timer); v_flag = 0; v_color = false;};
window.Repaint();
}
if (v_on_off == 0) {
v_flag = 1;
txt = "STOP";
fb.Volume--;
if (fb.Volume <= -100 ) {fb.Stop(); txt = "timer"; window.ClearInterval(v_timer); Vol(1); v_color = false;};
window.Repaint();
}
},20);
}
var d = new Date();
var s_date;
function d_timer() {
var clock_timer = window.SetInterval(function() {
d = new Date();
s_date = (d.getHours() * 3600) + (d.getMinutes() * 60) + d.getSeconds();
window.Repaint()
if (!timer_started) window.ClearInterval(clock_timer);
}, 1000);
}
/*
function clock(sec) {
var h, m, s;
h = Math.floor(sec / 3600);
m = Math.floor((sec - h * 3600) / 60);
s = sec - h * 3600 - m * 60;
if ( s < 10) s = "0" + s;
return h + " : " + (m < 10 ? "0" + m : m);
}
*/
Вернуться в Секреты foobar2000