Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==PREPROCESSOR==
- // @name "WSH Last.fm panel"
- // @import "%fb2k_path%\skins\\strigUI\\lib\\common.js"
- // ==/PREPROCESSOR==
- // reworked version of LastFM panel by so_kindly
- // Variables {{
- var FontStyle = {
- Regular: 0,
- Bold: 1,
- Italic: 2,
- BoldItalic: 3,
- Underline: 4,
- Strikeout: 8
- };
- var StringAlignment = {
- Near: 0,
- Center: 1,
- Far: 2
- };
- var StringTrimming = {
- None: 0,
- Character: 1,
- Word: 2,
- EllipsisCharacter: 3,
- EllipsisWord: 4,
- EllipsisPath: 5
- };
- var StringFormatFlags = {
- DirectionRightToLeft: 0x00000001,
- DirectionVertical: 0x00000002,
- NoFitBlackBox: 0x00000004,
- DisplayFormatControl: 0x00000020,
- NoFontFallback: 0x00000400,
- MeasureTrailingSpaces: 0x00000800,
- NoWrap: 0x00001000,
- LineLimit: 0x00002000,
- NoClip: 0x00004000,
- BypassGDI: 0x80000000
- }
- var FOCUSFLAG;
- var CursorFollowMode = {
- OnlyStopped: 2,
- Always: 3
- }
- // globals
- var ww = 0;
- var wh = 0;
- var Properties = new GetProperties();
- var MetaDB;
- //margins
- var lm = 5;
- var rm = 5;
- var tm = 5;
- var bm = 0;
- var font_label = gdi.Font("Segoe UI", 12, FontStyles.Bold);
- var font_num = gdi.Font("Segoe UI", 11, FontStyles.Bold);
- var font_normal = gdi.Font("Segoe UI", 13, FontStyles.Regular);
- var font_header = gdi.Font("Segoe UI", 15, FontStyles.Bold);
- var font_gui = gdi.Font("Web Symbols", 13, FontStyles.Regular);
- var normal_color = RGB(80, 80, 80);
- var hover_color = RGB(0, 120, 255);
- var LineStrFmt = StringFormat(StringAlignment.Near,StringAlignment.Near,StringTrimming.None,StringFormatFlags.LineLimit);
- var settings_dir = fb.ProfilePath + "u_settings\\";
- //img vars
- var images_path = fb.FoobarPath + "skins\\strigUI\\WSH LastFM\\";
- var img_lastfm_logo_red = gdi.Image(images_path + "lastfm_logo_red.jpg");
- var img_lastfm_flip = gdi.Image(images_path + "scrobbleflip.png");
- var ava_width = 100;
- // Register here: http://www.last.fm/api/account
- var api_key = '';
- var username = '';
- var opt_api_key = read_option("lastfm_api_key", "");
- var opt_username = read_option("lastfm_username", "");
- //var opt_api_key = api_key
- //var opt_username = username
- //var CurrentMode = parseInt( utils.ReadINI(fb.FoobarPath + '_cfg.ini', 'love', 'fav_track_mode', 1) );
- //update_option("lastfm_username", opt_username);
- //update_option("lastfm_username", opt_username);
- var WshShell = new ActiveXObject("WScript.Shell");
- var lastfm_data = new Array();
- var lastfm_xmlhttp = new Array();
- var lastfm_xmlDoc = new Array();
- var wait = 1;
- var lastfm_status = 0;
- var error_count = 0;
- var loved_track = false;
- var Y_OFFSET = 0;
- var sum_height = 0;
- var text_H = 0;
- var text_W = 0;
- var mouse_x = 0;
- var mouse_y = 0;
- var regdate_error = false;
- var text_Hs = new Array();
- var text_Ws = new Array();
- var TL_ys = new Array();
- var TL_xs = new Array();
- var np = [fb.TitleFormat("%artist%").Eval(true), fb.TitleFormat("%album%").Eval(true), fb.TitleFormat("%title%").Eval(true)];
- var spcounter = 0;
- var charcounter = 0;
- var longeststr = "";
- var linecounter = 1;
- var WaitTimerID;
- var StopTimerID;
- var CorrectedData = []; //artist - album - track
- // text buttons array [artist, album, track, tag1, tag2, tag3, tag4, tag5, similar1, similar2, similar3, similar4, similar5]
- var TLs = new Array(
- TL1 = new TextLink(0, 0, 0, 0, function () {}, "", ""),
- TL2 = new TextLink(0, 0, 0, 0, function () {}, "", ""),
- TL3 = new TextLink(0, 0, 0, 0, function () {}, "", ""),
- TLtag1 = new TextLink(0, 0, 0, 0, function () {}, "", ""),
- TLtag2 = new TextLink(0, 0, 0, 0, function () {}, "", ""),
- TLtag3 = new TextLink(0, 0, 0, 0, function () {}, "", ""),
- TLtag4 = new TextLink(0, 0, 0, 0, function () {}, "", ""),
- TLtag5 = new TextLink(0, 0, 0, 0, function () {}, "", ""),
- TLsimilar1 = new TextLink(0, 0, 0, 0, function () {}, "", ""),
- TLsimilar2 = new TextLink(0, 0, 0, 0, function () {}, "", ""),
- TLsimilar3 = new TextLink(0, 0, 0, 0, function () {}, "", ""),
- TLsimilar4 = new TextLink(0, 0, 0, 0, function () {}, "", ""),
- TLsimilar5 = new TextLink(0, 0, 0, 0, function () {}, "", ""),
- TLheart = new TextLink(0, 0, 25, 25, function () {}, "♥", "Loved Track"));
- var Tooltip = window.CreateTooltip();
- var TLAnimationTimerID;
- var TLAnimationTimer;
- var EnableTooltip = true;
- var MaxRange;
- var h_link, d_link;
- // Variables}}
- function reset_lastfm_data() {
- for (id = 0; id <= 4; id++) {
- lastfm_data[id] = new Array(4);
- }
- for (id = 0; id <= 3; id++) {
- for (n = 0; n <= 5; n++) {
- lastfm_data[id][n] = 0;
- }
- }
- lastfm_data[1][3] = new Array();
- lastfm_data[1][4] = new Array();
- for (i = 0; i < 5; i++) {
- lastfm_data[1][3][i] = "0";
- lastfm_data[1][4][i] = "0";
- }
- }
- function get_lastfm_data() {
- if (opt_username.length == 0 || opt_api_key.length != 32) {
- window.Repaint();
- } else { //lastfm_status counts here
- contact_lastfm("user.getinfo", 0);
- contact_lastfm("artist.getinfo&artist=" + encodeURIComponent(np[0]) + "&autocorrect=1", 1);
- contact_lastfm("album.getinfo&artist=" + encodeURIComponent(np[0]) + "&album=" + encodeURIComponent(np[1]), 2);
- contact_lastfm("track.getinfo&artist=" + encodeURIComponent(np[0]) + "&track=" + encodeURIComponent(np[2]) + "&autocorrect=1", 3);
- }
- }
- function contact_lastfm(method, id) {
- lastfm_xmlhttp[id] = new ActiveXObject("Microsoft.XMLHTTP");
- lastfm_xmlhttp[id].open("GET", "http://ws.audioscrobbler.com/2.0?api_key=" + opt_api_key + "&username=" + opt_username + "&user=" + opt_username + "&method=" + method + "&s=" + Math.random(), true);
- lastfm_xmlhttp[id].setRequestHeader('User-Agent', "foo_silk_mod");
- lastfm_xmlhttp[id].send();
- lastfm_xmlhttp[id].onreadystatechange = function () {
- if (lastfm_xmlhttp[id].readyState == 4) { // 'DONE' state
- if (lastfm_xmlhttp[id].status == 200) { //success
- lastfm_status++;
- wait_lastfm_data();
- }
- if (lastfm_xmlhttp[id].status >= 400) { //error statuses
- error_count++;
- lastfm_status++;
- wait_lastfm_data();
- }
- }
- }
- }
- function wait_lastfm_data() {
- if (lastfm_status == 4 && error_count < 4) {
- process_lastfm_data();
- lastfm_status = wait = 0;
- Y_OFFSET = 0;
- error_count = 0;
- return;
- } else if (lastfm_status < 4) {
- wait = 1;
- } else if (error_count == 4) {
- wait = -1;
- error_count = 0;
- window.Repaint();
- }
- }
- function process_lastfm_data() {
- for (id = 0; id < 4; id++) {
- lastfm_xmlDoc[id] = lastfm_xmlhttp[id].responseXML;
- try {
- error = "last.fm API error: " + lastfm_xmlDoc[id].getElementsByTagName("error")[0].childNodes[0].nodeValue;
- } catch (e) {
- error = null;
- }
- }
- // Userinfo
- try {
- lastfm_data[0][0] = lastfm_xmlDoc[0].getElementsByTagName("playcount")[0].childNodes[0].nodeValue;
- username = lastfm_xmlDoc[0].getElementsByTagName("name")[0].childNodes[0].nodeValue;
- } catch (e) {
- lastfm_data[0][0] = "0";
- }
- try {
- lastfm_data[0][4] = lastfm_xmlDoc[0].getElementsByTagName("registered")[0].childNodes[0].nodeValue;
- regdate_error = false;
- } catch (e) {
- regdate_error = true;
- lastfm_data[0][4] = "";
- }
- date = new Date().getTime() / 1;
- if (!regdate_error) {
- try {
- utc = Date.UTC(lastfm_data[0][4].substring(0, 4), (lastfm_data[0][4].substring(5, 7) - 1), lastfm_data[0][4].substring(8, 10), 0, 0, 0);
- } catch (e) {
- utc = 0;
- }
- try {
- lastfm_data[0][1] = "" + Math.round((lastfm_data[0][0] / ((date - utc) / 86400000)) * 100) / 100;
- lastfm_data[0][1] = lastfm_data[0][1].replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');
- } catch (e) {
- lastfm_data[0][1] = "0";
- };
- try {
- lastfm_data[0][2] = "" + Math.round((lastfm_data[0][0] / ((date - utc) / 604800000)) * 10) / 10;
- lastfm_data[0][2] = lastfm_data[0][2].replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');
- } catch (e) {
- lastfm_data[0][2] = "0";
- };
- try {
- lastfm_data[0][3] = "" + Math.round((lastfm_data[0][0] / ((date - utc) / 2629743000)) * 1) / 1;
- lastfm_data[0][3] = lastfm_data[0][3].replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');
- } catch (e) {
- lastfm_data[0][3] = "0";
- };
- } else {
- lastfm_data[0][1] = "0";
- lastfm_data[0][2] = "0";
- lastfm_data[0][3] = "0";
- }
- try {
- lastfm_data[0][0] = lastfm_data[0][0].replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');
- } catch (e) {
- lastfm_data[0][0] = "0";
- }
- // Artistinfo - Albuminfo - Trackinfo
- for (id = 1; id <= 3; id++) {
- try {
- lastfm_data[id][0] = lastfm_xmlDoc[id].getElementsByTagName("playcount")[0].childNodes[0].nodeValue;
- lastfm_data[id][0] = lastfm_data[id][0].replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');
- } catch (e) {
- lastfm_data[id][0] = "0";
- }
- try {
- lastfm_data[id][1] = lastfm_xmlDoc[id].getElementsByTagName("userplaycount")[0].childNodes[0].nodeValue;
- lastfm_data[id][1] = lastfm_data[id][1].replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');
- } catch (e) {
- lastfm_data[id][1] = "0";
- }
- try {
- lastfm_data[id][2] = lastfm_xmlDoc[id].getElementsByTagName("listeners")[0].childNodes[0].nodeValue;
- lastfm_data[id][2] = lastfm_data[id][2].replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');
- } catch (e) {
- lastfm_data[id][2] = "0";
- }
- switch (id) {
- case 1:
- try {
- CorrectedData[id] = lastfm_xmlDoc[id].getElementsByTagName("name")[0].childNodes[0].nodeValue;
- for (i = 0; i < 5; i++) {
- try {
- lastfm_data[id][3][i] = lastfm_xmlDoc[id].getElementsByTagName("tag")[i].childNodes[0].childNodes[0].nodeValue; //artist tags
- } catch (e) {
- lastfm_data[id][3][i] = "";
- }
- try {
- lastfm_data[id][4][i] = lastfm_xmlDoc[id].getElementsByTagName("artist")[i + 1].childNodes[0].childNodes[0].nodeValue; //similar artists
- } catch (e) {
- lastfm_data[id][4][i] = "no data";
- }
- }
- } catch (e) {
- CorrectedData[id] = "~no data";
- }
- break;
- case 2:
- try {
- CorrectedData[id] = lastfm_xmlDoc[id].getElementsByTagName("name")[0].childNodes[0].nodeValue;
- } catch (e) {
- CorrectedData[id] = "~no data";
- }
- break;
- case 3:
- try {
- CorrectedData[id] = lastfm_xmlDoc[id].getElementsByTagName("name")[0].childNodes[0].nodeValue;
- } catch (e) {
- CorrectedData[id] = "~no data";
- }
- try {
- lastfm_data[id][3] = lastfm_xmlDoc[id].getElementsByTagName("userloved")[0].childNodes[0].nodeValue;
- } catch (e) {
- lastfm_data[id][3] = "0";
- }
- break;
- }
- }
- for (i = 0; i < TLs.length; i++) {
- TLs[i].NeedReset = true;
- }
- window.Repaint();
- }
- //lfm end
- //============================================================================================================
- //Properties
- function GetProperties() {
- this.Panel = {
- CursorFollowMode: window.GetProperty("B01.Panel.CursorFollowMode", CursorFollowMode.OnlyStopped),
- }
- this.Panel.CursorFollowMode = Math.max(this.Panel.CursorFollowMode, CursorFollowMode.OnlyStopped);
- this.Panel.CursorFollowMode = Math.min(this.Panel.CursorFollowMode, CursorFollowMode.Always);
- window.SetProperty("B01.Panel.CursorFollowMode", this.Panel.CursorFollowMode);
- }
- //============================================================================================================
- //timers
- function c_WaitTimer() {
- this.Stop = function () {
- if (WaitTimerID) {
- window.ClearTimeout(WaitTimerID);
- WaitTimerID = null;
- //window.Repaint();
- }
- }
- this.Start = function () {
- WaitTimerID = window.SetTimeout(function () {
- WaitTimerID = null;
- lastfm_status = 0;
- wait = 1;
- MetaDB = fb.GetFocusItem();
- FOCUSFLAG = true;
- if (MetaDB){
- np = [fb.TitleFormat("%artist%").EvalWithMetadb(MetaDB), fb.TitleFormat("%album%").EvalWithMetadb(MetaDB), fb.TitleFormat("%title%").EvalWithMetadb(MetaDB)]
- if (np[0] == "?" && np[1] == "?") {
- wait = -2;
- window.Repaint();
- return;
- }
- lastfm_status = 0;
- wait = 1;
- window.Repaint();
- get_lastfm_data();
- } else {
- wait = -2;
- window.Repaint();
- }
- }, 400);
- }
- }
- function c_ButtonAnimationTimer() {
- this.Stop = function () {
- if (TLAnimationTimerID) {
- window.ClearInterval(TLAnimationTimerID);
- TLAnimationTimerID = null;
- }
- }
- this.Start = function () {
- TLAnimationTimerID = window.SetInterval(function () {
- var NeedRepaint = 0;
- for (var i = 0; i < TLs.length; i++) {
- if (TLs[i].NeedRefresh) {
- TLs[i].RefreshOpacity();
- NeedRepaint += 1;
- Onlybtn = TLs[i]; // If only one button need to be repainted.
- }
- }
- if (NeedRepaint) {
- if (NeedRepaint == 1) window.RepaintRect(Onlybtn.x, Onlybtn.y + Y_OFFSET, Onlybtn.width, Onlybtn.height);
- else window.RepaintRect(MaxRange.x, MaxRange.y, MaxRange.width, MaxRange.height); // This is range of buttons.
- } else {
- TLAnimationTimer.Stop();
- }
- }, 50)
- }
- }
- // VB wrapper {{
- var vb = {};
- vb.Function = function (func) {
- return function () {
- return vb.Function.eval.call(this, func, arguments);
- }
- };
- vb.Function.eval = function (func) {
- var args = Array.prototype.slice.call(arguments[1]);
- for (var i = 0; i < args.length; i++) {
- if (typeof args[i] != 'string') continue;
- args[i] = '"' + args[i].replace(/"/g, '" + Chr(34) + "') + '"';
- }
- var vbe;
- vbe = new ActiveXObject('ScriptControl');
- vbe.Language = 'VBScript';
- return vbe.eval(func + '(' + args.join(', ') + ')');
- };
- var InputBox = vb.Function('InputBox');
- var MsgBox = vb.Function('MsgBox');
- // VB wrapper}}
- //============================================================================================================
- // Options engine {{
- function update_option(optname, optvalue) {
- var ini_ = utils.ReadINI(fb.FoobarPath + '_cfg.ini', 'LFMPanel', optname);
- if ( optname ) utils.WriteINI( fb.FoobarPath + '_cfg.ini', 'LFMPanel', optname, optvalue);
- else if ( !optname && ini_ ) optname = ini_;
- //else if ( !optname && !ini_) optname = optvalue;
- else optname = optvalue;
- }
- function read_option(optname, initvalue) {
- var ini_ = utils.ReadINI(fb.FoobarPath + '_cfg.ini', 'LFMPanel', optname);
- return ini_
- }
- // Options engine }}
- // Cursor follow tools {{
- function SetCursorFollowMode(FollowMode) {
- if (FollowMode != Properties.Panel.CursorFollowMode) {
- Properties.Panel.CursorFollowMode = FollowMode;
- window.SetProperty("B01.Panel.CursorFollowMode", FollowMode);
- CursorFollow(FollowMode);
- }
- }
- function CursorFollow(FollowMode) {
- switch (FollowMode) {
- case CursorFollowMode.OnlyStopped:
- if (fb.IsPlaying) on_playback_new_track();
- else on_item_focus_change();
- break;
- case CursorFollowMode.Always:
- on_item_focus_change();
- break;
- }
- }
- // Cursor follow tools }}
- //context menu
- function show_context_menu(x, y) {
- var _menu = window.CreatePopupMenu();
- //var _avatar = window.CreatePopupMenu();
- var _followMode = window.CreatePopupMenu();
- var ret;
- if (opt_username.length == 0 || opt_api_key.length != 32) {
- _menu.AppendMenuItem(MF_STRING, 10, "Set your Last.fm username...");
- _menu.AppendMenuItem(MF_STRING, 11, "Set your API KEY...");
- } else {
- _menu.AppendMenuItem(opt_username.length > 0 && opt_api_key.length == 32 ? MF_STRING : MF_GRAYED, 1, "Update Last.fm Data");
- _menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
- _followMode.AppendMenuItem(MF_STRING, 2, "Only Stopped");
- _followMode.AppendMenuItem(MF_STRING, 3, "Always");
- _followMode.CheckMenuRadioItem(2, 3, Properties.Panel.CursorFollowMode);
- _followMode.AppendTo(_menu, MF_STRING, "Cursor follow mode");
- _menu.AppendMenuItem(MF_STRING, 6, "Change username");
- _menu.AppendMenuItem(MF_STRING, 7, "Change API Key");
- _menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
- _menu.AppendMenuItem(MF_STRING, 8, "Properties");
- }
- ret = _menu.TrackPopupMenu(x, y);
- switch (ret) {
- case 1:
- lastfm_status = 0;
- wait = 1;
- window.Repaint();
- CursorFollow(Properties.Panel.CursorFollowMode);
- break;
- case 2:
- SetCursorFollowMode(CursorFollowMode.OnlyStopped);
- break;
- case 3:
- SetCursorFollowMode(CursorFollowMode.Always);
- break;
- case 6:
- opt_username = InputBox("Please enter your Last.fm username", "Last.fm panel", opt_username);
- if (!opt_username) opt_username = "";
- update_option("lastfm_username", opt_username);
- //avatar_need_refresh = true;
- CursorFollow(Properties.Panel.CursorFollowMode);
- break;
- case 7:
- opt_api_key = InputBox("Please enter your Last.fm API KEY (http://www.last.fm/api/account)", "Last.fm panel", opt_api_key);
- if (!opt_api_key) opt_api_key = "";
- update_option("lastfm_api_key", opt_api_key);
- CursorFollow(Properties.Panel.CursorFollowMode);
- break;
- case 8:
- window.ShowProperties();
- break;
- case 10:
- opt_username = InputBox("Please enter your Last.fm username", "Last.fm panel", opt_username);
- if (!opt_username) opt_username = "";
- update_option("lastfm_username", opt_username);
- //avatar_need_refresh = true;
- CursorFollow(Properties.Panel.CursorFollowMode);
- break;
- case 11:
- opt_api_key = InputBox("Please enter your Last.fm API KEY (http://www.last.fm/api/account)", "Last.fm panel", opt_api_key);
- if (!opt_api_key) opt_api_key = "";
- update_option("lastfm_api_key", opt_api_key);
- CursorFollow(Properties.Panel.CursorFollowMode);
- break;
- }
- _menu.Dispose();
- //_avatar.Dispose();
- _followMode.Dispose();
- return true;
- }
- // button class
- function TextLink(x, y, width, height, fn_onclick, label, tiptext) {
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
- this.label = label;
- this.tiptext = tiptext;
- this.TestProp = "";
- this.NeedRefresh = 0;
- this.oldstate = 0; // 0=normal, 1=hover, 2=down.
- this.state = 0;
- this.opacity = 0; // Opacity of new state image.
- this.step = 0;
- this.show = true;
- this.NeedReset = false;
- this.OnClick = fn_onclick;
- this.ChangeState = function (s) {
- this.oldstate = this.state;
- this.state = s;
- this.opacity = 0;
- this.NeedRefresh = 1;
- switch (s) {
- case 0:
- this.step = 40; // Step of changing to normal state.
- Tooltip.Deactivate();
- Tooltip.Text = "";
- break;
- case 1:
- this.step = 75; // hover state.
- if (EnableTooltip) {
- Tooltip.Text = this.tiptext;
- Tooltip.Activate();
- }
- break;
- case 2:
- this.step = 85; // down state.
- Tooltip.Deactivate();
- Tooltip.Text = "";
- break;
- }
- if (!TLAnimationTimerID) // start animation
- TLAnimationTimer.Start();
- }
- this.isXYok = function (x2, y2) {
- return (x2 >= this.x && y2 >= this.y + Y_OFFSET && x2 <= this.x + this.width && y2 <= this.y + Y_OFFSET + this.height) ? true : false;
- }
- this.Draw = function (x2, y2, gr) {
- x2 = this.x; //disabled
- y2 = this.y; //disabled
- if (this.opacity < 100) {
- switch (this.oldstate) {
- case 0:
- //gr.FillSolidRect(this.x, this.y + Y_OFFSET, this.width, this.height, RGBA(0, 120, 220, 100));
- gr.DrawString(this.label, font_normal, normal_color, this.x + 4, this.y + Y_OFFSET, this.width - 4, this.height, LineStrFmt);
- break;
- case 1:
- //gr.FillSolidRect(this.x, this.y + Y_OFFSET, this.width, this.height, RGBA(0, 130, 230, 100));
- gr.DrawString(this.label, font_normal, hover_color, this.x + 4, this.y + Y_OFFSET, this.width - 4, this.height, LineStrFmt);
- break;
- case 2:
- //gr.FillSolidRect(this.x, this.y + Y_OFFSET, this.width, this.height, RGBA(0, 136, 236, 100));
- gr.DrawString(this.label, font_normal, hover_color, this.x + 4, this.y + Y_OFFSET, this.width - 4, this.height, LineStrFmt);
- break;
- default:
- break;
- }
- }
- if (this.opacity) {
- switch (this.state) {
- case 0:
- //gr.FillSolidRect(this.x, this.y + Y_OFFSET, this.width, this.height, RGBA(0, 120, 220, this.opacity));
- gr.DrawString(this.label, font_normal, normal_color, this.x + 4, this.y + Y_OFFSET, this.width, this.height, LineStrFmt);
- break;
- case 1:
- //gr.FillSolidRect(this.x, this.y + Y_OFFSET, this.width, this.height, RGBA(0, 130, 230, this.opacity));
- gr.DrawString(this.label, font_normal, hover_color, this.x + 4, this.y + Y_OFFSET, this.width, this.height, LineStrFmt);
- break;
- case 2:
- //gr.FillSolidRect(this.x, this.y + Y_OFFSET, this.width, this.height, RGBA(0, 136, 236, this.opacity));
- gr.DrawString(this.label, font_normal, hover_color, this.x + 4, this.y + Y_OFFSET, this.width, this.height, LineStrFmt);
- break;
- }
- }
- }
- this.RefreshOpacity = function (fn) {
- if (this.opacity < 100) this.opacity = Math.min(this.opacity + this.step, 100);
- else {
- this.oldstate = this.state;
- this.opacity = 0;
- this.NeedRefresh = 0;
- }
- }
- }
- function GetCoordinates() {
- // Calculate the max range of buttons, for increasing refresh speed.
- MaxRange = {
- x: TLs[0].x,
- y: TLs[0].y + Y_OFFSET,
- width: TLs[0].width,
- height: TLs[0].height
- }
- for (var i = 1; i < TLs.length - 1; i++) {
- if (TLs[i].show) {
- MaxRange.x = Math.min(TLs[i].x, MaxRange.x);
- MaxRange.y = Math.min(TLs[i].y + Y_OFFSET, MaxRange.y);
- MaxRange.width = Math.max(TLs[i].x + TLs[i].width - MaxRange.x, MaxRange.width);
- MaxRange.height = Math.max(TLs[i].y + Y_OFFSET + TLs[i].height - MaxRange.y, MaxRange.height);
- }
- }
- }
- //===================================================================================================================================================
- //===================================================================================================================================================
- function on_init() {
- //Scrollbar = new V_SCROLLBAR(20, 45);
- WaitTimer = new c_WaitTimer();
- TLAnimationTimer = new c_ButtonAnimationTimer();
- //update_option("lastfm_api_key", "179b25d95e633097ec682c58b4a993ec");
- reset_lastfm_data();
- //WaitTimer.Start();
- }
- on_init();
- function on_size() {
- if (!window.Width || !window.Height) return;
- ww = window.Width;
- wh = window.Height;
- GetCoordinates();
- CursorFollow(Properties.Panel.CursorFollowMode);
- }
- function on_paint(gr) {
- sum_height = 0;
- gr.SetTextRenderingHint(5);
- if (opt_username.length == 0 || opt_api_key.length != 32) {
- gr.GdiDrawText("Last.fm panel \n Please enter your username \n and API key with context menu", font_normal, normal_color, 0, 0, ww, wh, DT_CENTER | DT_VCENTER | DT_CALCRECT | DT_NOPREFIX);
- return;
- }
- if (wait == 0) {
- //draw last.fm logo
- gr.FillSolidRect(ww/2, tm + Y_OFFSET, ww, 30, RGBA(210, 19, 9, 255));
- gr.DrawImage(img_lastfm_logo_red, (ww - 110), tm + Y_OFFSET, 100, 30, 0, 0, 900, 269);
- //draw user avatar
- /* gr.DrawImage(img_avatar, lm, tm + 30 + tm + Y_OFFSET, ava_width, ava_height, 0, 0, img_avatar.width, img_avatar.height);
- sum_height += ava_height < 100 ? tm + 30 + tm + 100 : tm + 30 + tm + ava_height;
- gr.DrawRect(lm, tm + 30 + tm + Y_OFFSET, ava_width, ava_height, 2, normal_color); */
- sum_height += 5;
- //draw username
- /*if (ww >= 175 + ava_width) {
- gr.GdiDrawText(username != "" ? username : opt_username, font_header, normal_color, lm + ava_width + 15, 45 + Y_OFFSET, ww, wh);
- } else {
- gr.GdiDrawText(username != "" ? username : opt_username, font_header, normal_color, lm, sum_height + 5 + Y_OFFSET, ww, wh);
- sum_height += font_header.height + 9;
- }*/
- // plays ========================================================================================================================================================================================
- for (i = 0; i <= 3; i++) {
- charcounter = 0;
- spcounter = 0;
- switch (i) {
- case 0:
- txt_plays = " plays";
- break;
- case 1:
- txt_plays = " per day";
- break;
- case 2:
- txt_plays = " per week";
- break;
- case 3:
- txt_plays = " per month";
- break;
- }
- if (longeststr.length < lastfm_data[0][i].length) longeststr = lastfm_data[0][i];
- if (ww >= 175 + ava_width) {
- for (j = 0; j < lastfm_data[0][i].length; j++) {
- if (lastfm_data[0][i].substring((j), j + 1) != " ") {
- gr.DrawImage(img_lastfm_flip, lm + ava_width + 15 + charcounter * 11 + spcounter * 5, 70 + (i * 15) + Y_OFFSET, img_lastfm_flip.width, img_lastfm_flip.height, 0, 0, img_lastfm_flip.width, img_lastfm_flip.height);
- charcounter++;
- } else {
- spcounter++;
- }
- gr.GdiDrawText(lastfm_data[0][i].substring((j), j + 1), font_num, RGB(255, 255, 255), lm + ava_width + 17 + (charcounter - 1) * 11 + spcounter * 5, 69 + (i * 15) + Y_OFFSET, ww, wh, DT_TOP | DT_LEFT);
- }
- gr.GdiDrawText(txt_plays, font_num, normal_color, lm + ava_width + 15 + charcounter * 11 + spcounter * 5 + 3, 69 + (i * 15) + Y_OFFSET, ww, wh, DT_TOP | DT_LEFT);
- } else {
- for (j = 0; j < lastfm_data[0][i].length; j++) {
- if (lastfm_data[0][i].substring((j), j + 1) != " ") {
- gr.DrawImage(img_lastfm_flip, lm + charcounter * 11 + spcounter * 5, sum_height + Y_OFFSET, img_lastfm_flip.width, img_lastfm_flip.height, 0, 0, img_lastfm_flip.width, img_lastfm_flip.height);
- charcounter++;
- } else {
- spcounter++;
- }
- gr.GdiDrawText(lastfm_data[0][i].substring((j), j + 1), font_num, RGB(255, 255, 255), lm + 2 + (charcounter - 1) * 11 + spcounter * 5, sum_height - 1 + Y_OFFSET, ww, wh, DT_TOP | DT_LEFT);
- }
- gr.GdiDrawText(txt_plays, font_num, normal_color, lm + charcounter * 11 + spcounter * 5 + 3, sum_height - 1 + Y_OFFSET, ww, wh, DT_TOP | DT_LEFT);
- sum_height += img_lastfm_flip.height + 3;
- }
- }
- //========================================================================================================================================================================================
- gr.GdiDrawText("Current track", font_header, normal_color, lm, sum_height + 6 + Y_OFFSET, ww, wh);
- // artist - album - track ========================================================================================================================================================================================
- if (lastfm_data[3][3] == "1") { //userloved
- TLs[13].x = 105;
- TLs[13].y = sum_height + 6;
- TLs[13].Draw = function (gr) {
- gr.GdiDrawText(TLs[13].label, font_gui, normal_color, TLs[13].x, TLs[13].y + Y_OFFSET, TLs[13].width, TLs[13].height);
- }
- TLs[13].Draw(gr);
- } else {
- TLs[13].x = ww + 10;
- }
- sum_height += font_header.height + 17;
- for (i = 0; i < 3; i++) {
- TLs[i].y = sum_height;
- if (TLs[i].NeedReset) {
- if (CorrectedData[i + 1] != "~no data") {
- text_Ws[i] = Math.ceil(gr.MeasureString(CorrectedData[i + 1] == np[i] ? np[i] : CorrectedData[i + 1] + " [*]", font_normal, 0, 0, ww - 50 - lm - rm - 20, wh, LineStrFmt).Width);
- text_Hs[i] = Math.ceil(gr.MeasureString(CorrectedData[i + 1] == np[i] ? np[i] : CorrectedData[i + 1] + " [*]", font_normal, 0, 0, ww - 50 - lm - rm - 20, wh, LineStrFmt).Height);
- switch (i) {
- case 0:
- TLs[i].OnClick = function () {
- WshShell.run("http://www.last.fm/music/" + encodeURIComponent(CorrectedData[1]))
- };
- break;
- case 1:
- TLs[i].OnClick = function () {
- WshShell.run("http://www.last.fm/music/" + encodeURIComponent(CorrectedData[1]) + "/" + encodeURIComponent(CorrectedData[2]))
- };
- break;
- case 2:
- TLs[i].OnClick = function () {
- WshShell.run("http://www.last.fm/music/" + encodeURIComponent(CorrectedData[1]) + "/" + encodeURIComponent(CorrectedData[2]) + "/" + encodeURIComponent(CorrectedData[3]))
- };
- break;
- }
- TLs[i].x = 50 + lm;
- TLs[i].width = text_Ws[i] + 8;
- TLs[i].height = text_Hs[i];
- TLs[i].label = CorrectedData[i + 1] == np[i] ? np[i] : CorrectedData[i + 1] + " [*]";
- TLs[i].tiptext = CorrectedData[i + 1] == np[i] ? "" : "Auto-corrected from: " + "'" + np[i] + "'";
- TLs[i].NeedReset = false;
- } else {
- text_Ws[i] = Math.ceil(gr.MeasureString(np[i], font_normal, 0, 0, ww - 50 - lm - rm - 20, wh, LineStrFmt).Width);
- text_Hs[i] = Math.ceil(gr.MeasureString(np[i], font_normal, 0, 0, ww - 50 - lm - rm - 20, wh, LineStrFmt).Height);
- switch (i) {
- case 0:
- TLs[i].OnClick = function () {
- WshShell.run("http://www.last.fm/music/" + encodeURIComponent(np[0]))
- };
- break;
- case 1:
- TLs[i].OnClick = function () {
- WshShell.run("http://www.last.fm/music/" + encodeURIComponent(np[0]) + "/" + encodeURIComponent(np[1]))
- };
- break;
- case 2:
- TLs[i].OnClick = function () {
- WshShell.run("http://www.last.fm/music/" + encodeURIComponent(np[0]) + "/" + encodeURIComponent(np[1]) + "/" + encodeURIComponent(np[2]))
- };
- break;
- }
- TLs[i].x = 50 + lm;
- TLs[i].width = text_Ws[i] + 8;
- TLs[i].height = text_Hs[i];
- TLs[i].label = np[i];
- TLs[i].tiptext = "";
- TLs[i].NeedReset = false;
- }
- }
- TLs[i].Draw(this.x, this.y, gr);
- switch (i) {
- case 0:
- txt_t = "Artist:";
- break;
- case 1:
- txt_t = "Album:";
- break;
- case 2:
- txt_t = "Track:";
- break;
- }
- gr.GdiDrawText(txt_t, font_label, normal_color, lm, sum_height + 2 + Y_OFFSET, 50, wh);
- sum_height += text_Hs[i] + 3;
- }
- sum_height += 3;
- // tags ========================================================================================================================================================================================
- gr.GdiDrawText("Artist", font_label, normal_color, lm, sum_height + 2 + Y_OFFSET, 50, wh);
- gr.GdiDrawText("tags:", font_label, normal_color, lm, sum_height + 2 + font_label.height + Y_OFFSET, 50, wh);
- linecounter = 1;
- if (lastfm_data[1][3][0] != "no data") {
- for (i = 0; i < 5; i++) {
- text_Ws[i + 3] = Math.ceil(gr.MeasureString(lastfm_data[1][3][i], font_normal, 0, 0, ww - 50 - lm - rm - 20, wh, LineStrFmt).Width);
- text_Hs[i + 3] = Math.ceil(gr.MeasureString(lastfm_data[1][3][i], font_normal, 0, 0, ww - 50 - lm - rm - 20, wh, LineStrFmt).Height);
- TLs[i + 3].x = i == 0 ? 50 + lm : (TLs[i + 2].x + text_Ws[i + 2] + 8 + text_Ws[i + 3] + 8 + 1 < ww - rm - 20 ? TLs[i + 2].x + text_Ws[i + 2] + 11 : 50 + lm);
- TLs[i + 3].y = i == 0 ? sum_height : (TLs[i + 2].x + text_Ws[i + 2] + 8 + text_Ws[i + 3] + 8 + 1 < ww - rm - 20 ? TLs[i + 2].y : sum_height + font_normal.height + 3);
- linecounter += (TLs[i + 2].x + text_Ws[i + 2] + 8 + text_Ws[i + 3] + 8 + 1 < ww - rm - 20) || i == 0 ? 0 : 1;
- if (TLs[i + 3].NeedReset) {
- switch (i) {
- case 0:
- TLs[i + 3].OnClick = function () {
- WshShell.run("http://www.last.fm/tag/" + encodeURIComponent(lastfm_data[1][3][0]))
- };
- break;
- case 1:
- TLs[i + 3].OnClick = function () {
- WshShell.run("http://www.last.fm/tag/" + encodeURIComponent(lastfm_data[1][3][1]))
- };
- break;
- case 2:
- TLs[i + 3].OnClick = function () {
- WshShell.run("http://www.last.fm/tag/" + encodeURIComponent(lastfm_data[1][3][2]))
- };
- break;
- case 3:
- TLs[i + 3].OnClick = function () {
- WshShell.run("http://www.last.fm/tag/" + encodeURIComponent(lastfm_data[1][3][3]))
- };
- break;
- case 4:
- TLs[i + 3].OnClick = function () {
- WshShell.run("http://www.last.fm/tag/" + encodeURIComponent(lastfm_data[1][3][4]))
- };
- break;
- }
- TLs[i + 3].width = text_Ws[i + 3] + 8;
- TLs[i + 3].height = text_Hs[i + 3];
- TLs[i + 3].label = lastfm_data[1][3][i];
- TLs[i + 3].tiptext = "";
- TLs[i + 3].NeedReset = false;
- }
- TLs[i + 3].Draw(0, 0, gr);
- if (i == 0) sum_height += gr.MeasureString(lastfm_data[1][3][i], font_normal, 0, 0, ww - 50 - lm - rm - 20, wh, LineStrFmt).lines > 1 ? text_Hs[i + 3] - font_normal.height : 0;
- else sum_height += (TLs[i + 2].x + text_Ws[i + 2] + 8 + text_Ws[i + 3] + 8 + 1 < ww - rm - 20) ? 0 : text_Hs[i + 3] + 3;
- }
- } else {
- for (i = 0; i < 5; i++) {
- TLs[i + 3].show = false;
- }
- gr.GdiDrawText("Tags did not recieved", font_normal, normal_color, lm + 50, sum_height + 2 + Y_OFFSET, ww, wh);
- }
- sum_height += linecounter == 1 ? font_normal.height * 2 + 6 : font_normal.height + 6;
- // similar ========================================================================================================================================================================================
- gr.GdiDrawText("Similar", font_label, normal_color, lm, sum_height + 2 + Y_OFFSET, 50, wh);
- gr.GdiDrawText("artists:", font_label, normal_color, lm, sum_height + 2 + font_label.height + Y_OFFSET, 50, wh);
- linecounter = 1;
- if (lastfm_data[1][4][0] != "no data") {
- for (i = 0; i < 5; i++) {
- text_Ws[i + 8] = Math.ceil(gr.MeasureString(lastfm_data[1][4][i], font_normal, 0, 0, ww - 50 - lm - rm - 20, wh, LineStrFmt).Width);
- text_Hs[i + 8] = Math.ceil(gr.MeasureString(lastfm_data[1][4][i], font_normal, 0, 0, ww - 50 - lm - rm - 20, wh, LineStrFmt).Height);
- TLs[i + 8].x = i == 0 ? 50 + lm : (TLs[i + 7].x + text_Ws[i + 7] + 8 + text_Ws[i + 8] + 8 + 1 < ww - rm - 20 ? TLs[i + 7].x + text_Ws[i + 7] + 11 : 50 + lm);
- TLs[i + 8].y = i == 0 ? sum_height : (TLs[i + 7].x + text_Ws[i + 7] + 8 + text_Ws[i + 8] + 8 + 1 < ww - rm - 20 ? TLs[i + 7].y : sum_height + font_normal.height + 3);
- linecounter += (TLs[i + 7].x + text_Ws[i + 7] + 8 + text_Ws[i + 8] + 8 + 1 < ww - rm - 20) || i == 0 ? 0 : 1;
- if (TLs[i + 8].NeedReset) {
- switch (i) {
- case 0:
- TLs[i + 8].OnClick = function () {
- WshShell.run("http://www.last.fm/music/" + encodeURIComponent(lastfm_data[1][4][0]))
- };
- break;
- case 1:
- TLs[i + 8].OnClick = function () {
- WshShell.run("http://www.last.fm/music/" + encodeURIComponent(lastfm_data[1][4][1]))
- };
- break;
- case 2:
- TLs[i + 8].OnClick = function () {
- WshShell.run("http://www.last.fm/music/" + encodeURIComponent(lastfm_data[1][4][2]))
- };
- break;
- case 3:
- TLs[i + 8].OnClick = function () {
- WshShell.run("http://www.last.fm/music/" + encodeURIComponent(lastfm_data[1][4][3]))
- };
- break;
- case 4:
- TLs[i + 8].OnClick = function () {
- WshShell.run("http://www.last.fm/music/" + encodeURIComponent(lastfm_data[1][4][4]))
- };
- break;
- }
- TLs[i + 8].width = text_Ws[i + 8] + 8;
- TLs[i + 8].height = text_Hs[i + 8];
- TLs[i + 8].label = lastfm_data[1][4][i];
- TLs[i + 8].tiptext = "";
- TLs[i + 8].NeedReset = false;
- }
- TLs[i + 8].Draw(0, 0, gr);
- if (i == 0) sum_height += gr.MeasureString(lastfm_data[1][4][i], font_normal, 0, 0, ww - 50 - lm - rm - 20, wh, LineStrFmt).lines > 1 ? text_Hs[i + 8] - font_normal.height : 0;
- else sum_height += (TLs[i + 7].x + text_Ws[i + 7] + 8 + text_Ws[i + 8] + 8 + 1 < ww - rm - 20) ? 0 : text_Hs[i + 8] + 3;
- }
- } else {
- for (i = 0; i < 5; i++) {
- TLs[i + 8].show = false;
- }
- gr.GdiDrawText("Artists did not recieved", font_normal, normal_color, lm + 50, sum_height + 2 + Y_OFFSET, ww, wh);
- }
- sum_height += linecounter == 1 ? font_normal.height * 2 + 2 : font_normal.height + 2;
- GetCoordinates(); //run this when all buttons are resetted
- // listeners ========================================================================================================================================================================================
- /* gr.GdiDrawText("Listeners", font_header, normal_color, lm, sum_height + Y_OFFSET, ww, wh);
- sum_height += font_header.height + 5;
- for (id = 1; id <= 3; id++) {
- charcounter = 0;
- spcounter = 0;
- for (j = 0; j < lastfm_data[id][2].length; j++) {
- if (lastfm_data[id][2].substring((j), j + 1) != " ") {
- gr.DrawImage(img_lastfm_flip, lm + 50 + charcounter * 11 + spcounter * 5, sum_height + Y_OFFSET, img_lastfm_flip.width, img_lastfm_flip.height, 0, 0, img_lastfm_flip.width, img_lastfm_flip.height);
- charcounter++;
- } else {
- spcounter++;
- }
- gr.GdiDrawText(lastfm_data[id][2].substring((j), j + 1), font_num, RGB(255, 255, 255), lm + (charcounter - 1) * 11 + spcounter * 5 + 2 + 50, sum_height - 1 + Y_OFFSET, ww, wh);
- }
- switch (id) {
- case 1:
- txt_t = "Artist:";
- break;
- case 2:
- txt_t = "Album:";
- break;
- case 3:
- txt_t = "Track:";
- break;
- }
- gr.GdiDrawText(txt_t, font_label, normal_color, lm, sum_height - 1 + Y_OFFSET, ww, wh);
- sum_height += 18;
- } */
- // plays ========================================================================================================================================================================================
- /* gr.GdiDrawText("Plays", font_header, normal_color, lm, sum_height + Y_OFFSET, ww, wh);
- sum_height += font_header.height + 5;
- for (id = 1; id <= 3; id++) {
- charcounter = 0;
- spcounter = 0;
- for (j = 0; j < lastfm_data[id][0].length; j++) {
- if (lastfm_data[id][0].substring((j), j + 1) != " ") {
- gr.DrawImage(img_lastfm_flip, lm + 50 + charcounter * 11 + spcounter * 5, sum_height + Y_OFFSET, img_lastfm_flip.width, img_lastfm_flip.height, 0, 0, img_lastfm_flip.width, img_lastfm_flip.height);
- charcounter++;
- } else {
- spcounter++;
- }
- gr.GdiDrawText(lastfm_data[id][0].substring((j), j + 1), font_num, RGB(255, 255, 255), lm + (charcounter - 1) * 11 + spcounter * 5 + 2 + 50, sum_height - 1 + Y_OFFSET, ww, wh);
- }
- switch (id) {
- case 1:
- txt_tt = "Artist:";
- break;
- case 2:
- txt_tt = "Album:";
- break;
- case 3:
- txt_tt = "Track:";
- break;
- }
- gr.GdiDrawText(txt_tt, font_label, normal_color, lm, sum_height - 1 + Y_OFFSET, ww, wh);
- sum_height += 18;
- } */
- // by user ========================================================================================================================================================================================
- //gr.GdiDrawText(username != "" ? "Plays by " + username : "Plays by " + opt_username, font_header, normal_color, lm, sum_height + Y_OFFSET, ww, wh);
- gr.GdiDrawText("Plays by user", font_header, normal_color, lm, sum_height + Y_OFFSET, ww, wh);
- sum_height += font_header.height + 10;
- for (id = 1; id <= 3; id++) {
- charcounter = 0;
- spcounter = 0;
- for (j = 0; j < lastfm_data[id][1].length; j++) {
- if (lastfm_data[id][1].substring((j), j + 1) != " ") {
- gr.DrawImage(img_lastfm_flip, lm + 50 + charcounter * 11 + spcounter * 5, sum_height + Y_OFFSET, img_lastfm_flip.width, img_lastfm_flip.height, 0, 0, img_lastfm_flip.width, img_lastfm_flip.height);
- charcounter++;
- } else {
- spcounter++;
- }
- gr.GdiDrawText(lastfm_data[id][1].substring((j), j + 1), font_num, RGB(255, 255, 255), lm + (charcounter - 1) * 11 + spcounter * 5 + 2 + 50, sum_height - 1 + Y_OFFSET, ww, wh);
- }
- switch (id) {
- case 1:
- txt_tt = "Artist:";
- break;
- case 2:
- txt_tt = "Album:";
- break;
- case 3:
- txt_tt = "Track:";
- break;
- }
- gr.GdiDrawText(txt_tt, font_label, normal_color, lm, sum_height - 1 + Y_OFFSET, ww, wh);
- sum_height += 18;
- }
- } else if (wait == 1) {
- gr.GdiDrawText("Grabbing last.fm data.\n Hold on!", font_normal, normal_color, 0, 0, ww, wh, DT_CENTER | DT_VCENTER | DT_CALCRECT | DT_NOPREFIX);
- return;
- } else if (wait == -1) {
- gr.GdiDrawText("Artist: " + np[0] + "\n Album: " + np[1] + "\n Track: " + np[2] + "\n \n Something went wrong :( \n Data did not recieved.", font_normal, normal_color, 0, 0, ww, wh, DT_CENTER | DT_VCENTER | DT_CALCRECT | DT_NOPREFIX);
- } else if (wait == -2) {
- gr.GdiDrawText("No track specified", font_normal, normal_color, 0, 0, ww, wh, DT_CENTER | DT_VCENTER | DT_CALCRECT | DT_NOPREFIX);
- }
- }
- function on_playback_new_track() {
- if(Properties.Panel.CursorFollowMode == CursorFollowMode.OnlyStopped){
- WaitTimer.Stop();
- MetaDB = fb.GetNowPlaying();
- FOCUSFLAG = false;
- np = [fb.TitleFormat("%artist%").EvalWithMetadb(MetaDB), fb.TitleFormat("%album%").EvalWithMetadb(MetaDB), fb.TitleFormat("%title%").EvalWithMetadb(MetaDB)]
- if (np[0] == "?" && np[1] == "?") {
- wait = -2;
- window.Repaint();
- return;
- }
- lastfm_status = 0;
- wait = 1;
- window.Repaint();
- get_lastfm_data();
- }
- }
- function on_item_focus_change() {
- if(Properties.Panel.CursorFollowMode == CursorFollowMode.Always || (Properties.Panel.CursorFollowMode == CursorFollowMode.OnlyStopped && !fb.IsPlaying && !fb.IsPaused)){
- WaitTimer.Stop();
- WaitTimer.Start();
- }
- }
- function on_playback_stop(reason) {
- if (!reason || reason == 1) {
- if(Properties.Panel.CursorFollowMode == CursorFollowMode.OnlyStopped && !FOCUSFLAG){
- WaitTimer.Stop();
- WaitTimer.Start();
- }
- }
- }
- function on_mouse_move(x, y) {
- if (window.Width < 185 || window.Height < 100) return;
- if (wait != 0) return;
- if (d_link) {
- if (d_link.isXYok(x, y)) {
- if (d_link.state != 2) d_link.ChangeState(2);
- } else if (d_link.state != 1) d_link.ChangeState(1);
- } else {
- for (var i = 0; i < TLs.length; i++)
- if (TLs[i].isXYok(x, y) && TLs[i].show) {
- if (h_link != TLs[i]) {
- if (h_link) h_link.ChangeState(0);
- h_link = TLs[i];
- if (h_link != TLs[13]) window.SetCursor(IDC_HAND);
- h_link.ChangeState(1);
- }
- break;
- }
- if (i == TLs.length) {
- if (h_link) {
- if (h_link) h_link.ChangeState(0);
- h_link = undefined;
- window.SetCursor(IDC_ARROW);
- }
- }
- }
- }
- function on_mouse_lbtn_down(x, y) {
- if (window.Width < 185 || window.Height < 100) return;
- if (h_link && !d_link) {
- d_link = h_link;
- d_link.ChangeState(2);
- }
- }
- function on_mouse_lbtn_up(x, y) {
- if (window.Width < 185 || window.Height < 100) return;
- if (d_link) {
- if (d_link.state == 2) {
- d_link.OnClick();
- }
- d_link = undefined;
- on_mouse_move(x, y);
- }
- }
- function on_mouse_leave() {
- if (window.Width < 185 || window.Height < 100) return;
- if (h_link) {
- h_link.ChangeState(0);
- h_link = undefined;
- window.SetCursor(IDC_ARROW);
- }
- Tooltip.Text = "";
- }
- function on_mouse_rbtn_down(x, y, vkey) {
- rbtnDown = true;
- }
- function on_mouse_rbtn_up(x, y, vkey) {
- if (window.Width < 185 || window.Height < 100) return false;
- if (rbtnDown) {
- rbtnDown = false;
- if (vkey == MK_SHIFT) {
- return false; // if shift button pressed, show default context menu.
- } else {
- show_context_menu(x, y);
- return true;
- }
- }
- }
- function on_playlist_items_removed(playlist, new_count) {
- on_playlists_changed();
- }
- function on_playlist_switch() {
- on_playlists_changed();
- }
- function on_playlists_changed() {
- on_item_focus_change();
- }
- //EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement