Version without the rating problem ( just strictly text )
I also cleaned it up a bit
Clicking through playlists seems much smoother without the rating stars problem
// ==PREPROCESSOR==
// @import "%fb2k_path%scripts\utils.js"
// @import "%fb2k_path%scripts\marc2003\v2\common.js"
// ==/PREPROCESSOR==
var bw = 13;
var bh = 13;
var left_margin = 48;
var top_margin = 89;
var Buttons;
var g_metadb;
var section = "SIMILARPANEL";
var rating;
var nrating;
var lrating;
var img;
var g_drag = 0;
var g_tfo = fb.TitleFormat("%rating%");
var artist = ""
var album = ""
var title = ""
var codec = ""
var bitrate = ""
var played = ""
var codecprofile = ""
var played = ""
var genre = ""
var lastartist = ""
var lastplay = ""
var rating = ""
var last1 = ""
var last2 = ""
var last3 = ""
var last4 = ""
var playing = "0"
var playcount = "0";
var year = 0;
var date = 0;
var difyear = 0;
var date2 = 0;
var avgdate = 0;
var difdate = 0;
var today = 0;
var ar_days = 0;
var ar_years = 0;
var ar_days2 = 0;
var ar_years2 = 0;
var ar_days3 = 0;
var ar_years3 = 0;
var ar_days4 = 0;
var ar_years4 = 0;
var bitrate = 0;
var days = 0;
var hours = 0;
var minutes = 0;
var seconds = 0;
var on_playback_new_track2 = 0;
var playcount = "0";
var playcount2 = 0;
var playcount3 = 0;
var playcount4 = 0;
var avgplaycount = 0;
var minplaycount = 0;
var maxplaycount = 0;
var ranplaycount = 0;
var devplaycount = 0;
var test = 0;
var test2 = 0;
var dui = window.InstanceType;
var g_font = dui == 1 ? window.GetFontDUI(0) : window.GetFontCUI(0);
//var color = RGB(200,0,0);
var color = dui == 1 ? window.GetColorDUI(2) : RGB(200,0,0);
//var color2 = RGB(0,0,0);
var color2 = dui == 1 ? window.GetColorDUI(0) : window.GetColorCUI(0);
var color3 = RGB(255,99,71);
//global Variables for text field
var DT_TOP = 0x00000000;
var DT_LEFT = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_RIGHT = 0x00000002;
var DT_VCENTER = 0x00000004;
var DT_BOTTOM = 0x00000008;
var DT_WORDBREAK = 0x00000010;
var DT_SINGLELINE = 0x00000020;
var DT_EXPANDTABS = 0x00000040;
var DT_TABSTOP = 0x00000080;
var DT_NOCLIP = 0x00000100;
var DT_EXTERNALLEADING = 0x00000200;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;
var DT_INTERNAL = 0x00001000;
var DT_EDITCONTROL = 0x00002000;
var DT_PATH_ELLIPSIS = 0x00004000;
var DT_END_ELLIPSIS = 0x00008000;
var DT_MODIFYSTRING = 0x00010000;
var DT_RTLREADING = 0x00020000;
var DT_WORD_ELLIPSIS = 0x00040000;
var DT_NOFULLWIDTHCHARBREAK = 0x00080000;
var DT_HIDEPREFIX = 0x00100000;
var DT_PREFIXONLY = 0x00200000;
var defaultartistimage = "";
var lastfmdatapath = "";
var g_tooltip = window.CreateTooltip();
var g_down = false;
var timer = null;
var btn_down = null;
var cur_btn = null;
var ww = window.Width;
var wh = window.Height;
window.GetProperty("currentArtists", "");
window.GetProperty("bio_played", "");
function reloadConf(inipath)
{
skinpath = translatePath(utils.ReadINI(inipath, "SKIN", "imgpath", ""),true);
window.GetProperty("buttons.show", utils.ReadINI(inipath, section, "showbuttons", "0"));
window.GetProperty("buttons.list", utils.ReadINI(inipath, section, "buttons", ""));
window.GetProperty("font.name", utils.ReadINI(inipath, section, "fontname", "Segoe UI"));
window.GetProperty("font.size", utils.ReadINI(inipath, section, "fontsize", "10"));
window.GetProperty("buttons.width", utils.ReadINI(inipath, section, "buttonswidth", "110"));
window.GetProperty("buttons.height", utils.ReadINI(inipath, section, "buttonsheight", "38"));
lastfmdatapath = translatePath(utils.ReadINI(inipath, "LASTFM", "datapath"),true);
updateButtons() ;
}
reloadConf(inipath);
function on_script_unload()
{
utils.WriteINI(inipath, section, "showbuttons", window.GetProperty("buttons.show"));
utils.WriteINI(inipath, section, "buttons", window.GetProperty("buttons.list"));
utils.WriteINI(inipath, section, "fontname", window.GetProperty("font.name"));
utils.WriteINI(inipath, section, "fontsize", window.GetProperty("font.size"));
utils.WriteINI(inipath, section, "buttonswidth", window.GetProperty("buttons.width"));
utils.WriteINI(inipath, section, "buttonsheight", window.GetProperty("buttons.height"));
}
function ArtistButton(x, y, w, h, img, func, tiptext, url) {
this.left = x;
this.top = y;
this.w = w;
this.h = h;
this.right = x + w;
this.bottom = y + h;
this.func = func;
this.tiptext = tiptext;
this.url = url;
this.font = gdi.Font(window.GetProperty("font.name"), window.GetProperty("font.size"), 0);
this.color = RGB(255,255,255);
this.state = ButtonStates.normal;
this.img= img;
this.lastfmcommand = url;
this.alterImage = function(img_src) {
this.img= img_src ? gdi.Image(img_src) : null;
this.changeState(this.state);
}
this.traceMouse = function (x, y) {
var b = (this.left < x) && (x < this.right) && (this.top < y) && (y < this.bottom);
if (b)
g_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover);
else
this.changeState(ButtonStates.normal);
return b;
}
this.changeState = function (newstate) {
if (newstate != this.state)
window.RepaintRect(this.left, this.top, this.w, this.h);
this.state = newstate;
switch (this.state)
{
case ButtonStates.normal:
this.font = gdi.Font(window.GetProperty("font.name"), window.GetProperty("font.size"), 0);
this.color = RGB(255,255,255);
break;
case ButtonStates.hover:
case ButtonStates.down:
this.font = gdi.Font(window.GetProperty("font.name"), window.GetProperty("font.size"), 4);
this.color = RGB(0,92,185);
break;
default:
this.img = null;
}
}
this.draw = function (gr) {
gr.DrawRect(this.left, this.top, this.h, this.h, 1.0, RGB(170,170,170));
this.img && gr.DrawImage(this.img, this.left + 2, this.top + 2, this.h -3, this.h -3, 0, 0, Math.min(this.img.Width, this.img.Height), Math.min(this.img.Width, this.img.Height));
gr.GdiDrawText(this.tiptext, this.font, this.color, this.left + this.h + 3, this.top + 3, this.w - this.h - 3 , this.h -3, DT_VCENTER | DT_NOPREFIX | DT_WORDBREAK|DT_END_ELLIPSIS);
}
this.onClick = function () {
this.func && this.func(x,y);
}
this.onRightClick = function (x,y)
{
var _menu = window.CreatePopupMenu();
var idx;
var buttontocreate = window.GetProperty("buttons.list").split(";");
var numbersearchengines = 0;
if (buttontocreate != null)
{
for (var i in buttontocreate)
{
var text = getWebServiceName(buttontocreate[i], this.tiptext);
if (text != "")
{
_menu.AppendMenuItem(MF_STRING, numbersearchengines +1, text);
numbersearchengines += 1 ;
}
}
numbersearchengines += 1 ;
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
}
_menu.AppendMenuItem(MF_STRING, numbersearchengines + 1, "Update LastFM data");
_menu.AppendMenuItem(MF_SEPARATOR, numbersearchengines + 2, 0);
_menu.AppendMenuItem(MF_STRING, numbersearchengines + 3, getWebServiceName("lastfmsimilarradio", this.tiptext));
_menu.AppendMenuItem(MF_SEPARATOR, numbersearchengines + 4, 0);
_menu.AppendMenuItem(MF_STRING, numbersearchengines +5, "Properties");
//_menu.AppendMenuItem(MF_STRING, 7, "Configure...");
idx = _menu.TrackPopupMenu(x, y);
if (idx <= numbersearchengines)
{
launchWebService(buttontocreate[idx - 1], this.tiptext);
}
else if (idx == numbersearchengines + 1)
{
window.NotifyOthers("ask_lastfm_data", "");
}
else if (idx == numbersearchengines + 3)
{
launchWebService("lastfmsimilarradio", this.tiptext);
}
else
{
window.ShowProperties();
}
_menu.Dispose();
}
this.onMouseIn = function() {
g_tooltip.Text = this.tiptext;
g_tooltip.Activate();
}
this.onMouseOut = function() {
g_tooltip.Deactivate();
}
}
function buttonsDraw(gr) {
for (i in Buttons) {
Buttons[i].draw(gr);
}
}
function buttonsTraceMouse(x, y) {
var btn = null;
for (i in Buttons) {
if (Buttons[i].traceMouse(x, y) && !btn)
btn = Buttons[i];
}
return btn;
}
function on_timer(id) {
if (timer && id==timer.ID) {
updateButtons() ;
timer && window.KillTimer(timer);
timer = null;
CollectGarbage(); // Release memory.
}
}
function on_mouse_move(x, y) {
var btn = buttonsTraceMouse(x, y);
if (btn != cur_btn) {
cur_btn && cur_btn.onMouseOut();
btn && btn.onMouseIn();
}
cur_btn = btn;
}
function on_mouse_lbtn_down(x, y) {
g_down = true;
btn_down = cur_btn;
if (cur_btn) {
cur_btn.changeState(ButtonStates.down);
}
}
function on_mouse_lbtn_up(x, y, mask) {
if (mask & MK_SHIFT)
{
window.ShowConfigure();
}
else
{
if (cur_btn) {
cur_btn.changeState(ButtonStates.hover);
if( btn_down == cur_btn )
cur_btn.onClick(x, y);
}
g_down = false;
}
}
//function on_mouse_lbtn_up(x,y){
// if (lrating !=rating && g_metadb) bool = fb.RunContextCommandWithMetadb("Rating/"+((lrating==0) ? "<not set>" : lrating),g_metadb);
// }
// function on_mouse_move(x, y) {
// if (g_metadb) {
// g_drag = 1;
// nrating = Math.ceil((x - left_margin) / bw);
// if (nrating > 5) nrating = 5;
// if (nrating != lrating) {
// lrating = nrating;
// window.Repaint();
// }
// }
// }
function on_mouse_leave() {
// on_metadb_changed()
if (cur_btn) {
cur_btn.changeState(ButtonStates.normal);
}
}
function on_mouse_rbtn_down(x, y)
{
on_mouse_move(x, y);
if (cur_btn)
{
cur_btn.changeState(ButtonStates.hover);
cur_btn.onRightClick(x, y);
}
else
{
var _menu = window.CreatePopupMenu();
var idx;
_menu.AppendMenuItem(MF_STRING, 1, "Refresh");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 2, "Properties");
_menu.AppendMenuItem(MF_STRING, 3, "Configure...");
idx = _menu.TrackPopupMenu(x, y);
switch(idx) {
case 1:
updateButtons() ;
break;
case 2:
window.ShowProperties();
break;
case 3:
window.ShowConfigure();
break;
}
_menu.Dispose();
}
return true;
}
function on_size() {
ww = window.Width;
wh = window.Height;
updateButtons();
}
//function on_metadb_changed() {
// g_drag = 0;
// rating = g_tfo.EvalWithMetadb(g_metadb);
// if (rating == "?") rating = 0;
// lrating = rating;
// window.Repaint();
//}
function on_paint(gr) {
// Background
gr.FillSolidRect(0, 0, ww, wh, RGB(0,0,0));
//buttons_background(gr);
//if (g_metadb) {
// for (i = 1; i < 6; i++) {
// img = gdi.image(images_path + ((i > (g_drag ? lrating : rating)) ? "off.png" : "on.png"));
// gr.DrawImage(img, left_margin + bw * (i-1), top_margin, bw, bh, 0, 0, img.Width, img.Height);
// }
// }
buttonsDraw(gr);
gr.GdiDrawText("Artist: " + artist, g_font, color, 5, 5, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
gr.GdiDrawText("Title: " + title, g_font, color, 5, 25, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
if (playing === 1){
gr.GdiDrawText("Album: " + album +" " + "("+ date + ")", g_font, color, 5, 45, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
else{
gr.GdiDrawText("Album:", g_font, color, 5, 45, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
gr.GdiDrawText("Genre: " + genre, g_font, color2, 5, 65, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
gr.GdiDrawText("Rating: "+ rating , g_font, color2, 5, 85, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
if (playing === 1){
if (playcount === 0){
gr.GdiDrawText("Played: never", g_font, color2, 5, 105, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
else{
if (playcount === 1){
gr.GdiDrawText("Played: " + playcount + " time", g_font, color2, 5, 105, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
else{
gr.GdiDrawText("Played: " + playcount + " times", g_font, color2, 5, 105, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}}}
else{
gr.GdiDrawText("Played:", g_font, color2, 5, 105, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
if (playing === 1){
gr.GdiDrawText("Codec: " + codec +"-"+ codecprofile + " -- " + bitrate+" "+"Kbit/s", g_font, color2, 5, 125, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
else{
gr.GdiDrawText("Codec:", g_font, color2, 5, 125, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
if (playing === 1) {
if (Math.floor(ar_years) === 0) {
gr.GdiDrawText("Added: " + ar_days, g_font, color2, 5, 145, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
else{
gr.GdiDrawText("Added: " + ar_days + " (" + Math.floor(ar_years) + " years)", g_font, color2, 5, 145, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
}
else{
gr.GdiDrawText("Added:", g_font, color2, 5, 145, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
if (playing === 1){
if (playcount === 0) {
gr.GdiDrawText("First Played: never", g_font, color2, 5, 165, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
gr.GdiDrawText("Last Played: never", g_font, color2, 5, 185, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
else{
if (Math.floor(ar_years2) === 0) {
gr.GdiDrawText("First Played: " + ar_days2, g_font, color2, 5, 165, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
else{
gr.GdiDrawText("First Played: " + ar_days2 + " (" + Math.floor(ar_years2) + " years) ", g_font, color2, 5, 165, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
if (Math.floor(ar_years3) === 0) {
gr.GdiDrawText("Last Played: "+ ar_days3, g_font, color2, 5, 185, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
else{
gr.GdiDrawText("Last Played: "+ ar_days3 + " (" + Math.floor(ar_years3) + " years) ", g_font, color2, 5, 185, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
}}
else{
gr.GdiDrawText("First Played:", g_font, color2, 5, 165, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
gr.GdiDrawText("Last Played:", g_font, color2, 5, 185, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
// gr.GdiDrawText("Artist Playcount: " + last1, g_font, color2, 5, 205, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
gr.GdiDrawText("Artist Listeners: " + last2, g_font, color2, 5, 235, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
gr.GdiDrawText("Album Playcount: " + last3, g_font, color2, 5, 255, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
if (playing === 1){
gr.GdiDrawText("Artist Played: " + window.GetProperty("bio_played")+ " times", g_font, color2, 5, 205, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
else{
gr.GdiDrawText("Artist Played:", g_font, color2, 5, 205, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
gr.GdiDrawText("Similiar Artists:", g_font, color2, 5, 285, window.Width - 10, window.Height, DT_TOP | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
function on_notify_data(name, info)
{
switch (name)
{
case "lastfm_similarArtists":
window.SetProperty("currentArtists", info);
updateButtons();
break;
case "config_updated":
reloadConf(info);
break;
case "lastfm_bio":
var res = info.split("%separator%");
window.SetProperty("bio_played", res[2]);
if ( window.GetProperty("bio_played") == "")
{
window.SetProperty("bio_played","0");
}
window.Repaint();
default:
break;
}
}
function updateButtons() {
delete Buttons;
Buttons = null;
CollectGarbage(); // Release memory.
if(window.GetProperty("currentArtists") != "")
{
var x = 10;
var y = 310;
varartistsArray = window.GetProperty("currentArtists").split(";");
Buttons = new Array (varartistsArray.length);
var currentartist = "";
for (var i in varartistsArray)
{
switch (i % 2)
{
case 0:
currentartist = varartistsArray[i];
break;
case 1:
//skinpath
var currentartisturl = varartistsArray[i];
if (currentartist != "")
{
var img = gdi.Image(lastfmdatapath + ansi(currentartist) + "_small.jpg");
if(img == null)
{
img = gdi.Image(lastfmdatapath + ansi(currentartist) + "_small.png");
if(img == null)
{
img= gdi.Image(lastfmdatapath + ansi(currentartist) + "_small.gif");
if(img == null)
{
img= gdi.Image(skinpath + "Last.fm.small.png");
}
}
}
Buttons[i] = new ArtistButton(x, y, parseInt(window.GetProperty("buttons.width")), parseInt(window.GetProperty("buttons.height")), img, function(){WshShell.run(this.lastfmcommand);}, currentartist, currentartisturl) ;
if (x + 2*window.GetProperty("buttons.width") + 5 > ww)
{
y = y + parseInt(window.GetProperty("buttons.height")) + 5;
x = 10 ;
}
else
{
x = x + parseInt(window.GetProperty("buttons.width")) + 5;
}
}
break;
}
}
}
window.Repaint();
}
function on_playback_new_track() {
on_playback_new_track2++;
artist = fb.Titleformat("%artist%").Eval();
album = fb.TitleFormat("%album%").Eval();
title = fb.TitleFormat("%title%").Eval();
genre = fb.Titleformat("%genre%").Eval();
codec = fb.Titleformat("%codec%").Eval();
bitrate = fb.Titleformat("%bitrate%").EvalWithMetadb(g_metadb);
codecprofile = fb.Titleformat("%codec_profile%").Eval();
rating = fb.TitleFormat("$if(%rating%,$repeat($char(9733),%rating%),)").Eval();
last1 = fb.Titleformat("%lastfm_artist_playcount%").EvalWithMetadb(g_metadb);
last2 = fb.Titleformat("%lastfm_artist_listeners%").EvalWithMetadb(g_metadb);
last3 = fb.Titleformat("%lastfm_album_playcount%").EvalWithMetadb(g_metadb);
last4 = fb.Titleformat("%lastfm_album_listeners%").EvalWithMetadb(g_metadb);
playing = 1;
playcount = fb.TitleFormat("%play_count%");
playcount = playcount.Eval();
playcount = parseInt(playcount);
playcount2 += playcount;
playcount4 += playcount;
playcount3 += (playcount * playcount);
if (on_playback_new_track2 === 1) {
minplaycount = playcount;
maxplaycount = playcount;
}
window.GetProperty("bio_played")
last1 = addCommas(last1)
last2 = addCommas(last2)
last3 = addCommas(last3)
last4 = addCommas(last4)
date = fb.TitleFormat("%date%");
date = date.Eval();
date = parseInt(date);
dt = new Date();
year = dt.getFullYear();
difyear = year - date;
date2 = date2 + date;
if (on_playback_new_track2 >= 2) {
avgdate = date2 / on_playback_new_track2;
avgdate = Math.round(avgdate);
difdate = year - avgdate;
}
today = new Date();
var fpy = fb.TitleFormat("$year(%added%)").Eval();
var fpm = fb.TitleFormat("$sub($month(%added%),1)").Eval();
var fpd = fb.TitleFormat("$day_of_month(%added%)").Eval();
var fday = new Date(fpy, fpm, fpd);
var one_day = 1000 * 60 * 60 * 24;
if (fday > 0) {
ar_days = Math.floor((today.getTime() - fday.getTime()) / one_day);
ar_years = ar_days / 365;
}
fpy = fb.TitleFormat("$year(%first_played%)").Eval();
fpm = fb.TitleFormat("$sub($month(%first_played%),1)").Eval();
fpd = fb.TitleFormat("$day_of_month(%first_played%)").Eval();
fday = new Date(fpy, fpm, fpd);
one_day = 1000 * 60 * 60 * 24;
if (fday > 0) {
ar_days2 = Math.floor((today.getTime() - fday.getTime()) / one_day);
ar_years2 = ar_days2 / 365;
} else {
ar_days2 = 0;
}
fpy = fb.TitleFormat("$year(%last_played%)").Eval();
fpm = fb.TitleFormat("$sub($month(%last_played%),1)").Eval();
fpd = fb.TitleFormat("$day_of_month(%last_played%)").Eval();
fday = new Date(fpy, fpm, fpd);
one_day = 1000 * 60 * 60 * 24;
if (fday > 0) {
ar_days3 = Math.floor((today.getTime() - fday.getTime()) / one_day);
ar_years3 = ar_days3 / 365;
} else {
ar_days3 = 0;
}
fpy = fb.TitleFormat("$year(%last_modified%)").Eval();
fpm = fb.TitleFormat("$sub($month(%last_modified%),1)").Eval();
fpd = fb.TitleFormat("$day_of_month(%last_modified%)").Eval();
fday = new Date(fpy, fpm, fpd);
one_day = 1000 * 60 * 60 * 24;
if (fday > 0) {
ar_days4 = Math.floor((today.getTime() - fday.getTime()) / one_day);
ar_years4 = ar_days4 / 365;
} else {
ar_days4 = 0;
}
if (ar_days === 0) {
ar_days = "today"
}
if (ar_days === 1) {
ar_days = "yesterday"
}
if (ar_days >>> 1) {
ar_days = ar_days + " days ago"
}
if (ar_days2 === 0) {
ar_days2 = "today"
}
if (ar_days2 === 1) {
ar_days2 = "yesterday"
}
if (ar_days2 >>> 1) {
ar_days2 = ar_days2 + " days ago"
}
if (ar_days3 === 0) {
ar_days3 = "today"
}
if (ar_days3 === 1) {
ar_days3 = "yesterday"
}
if (ar_days3 >>> 1) {
ar_days3 = ar_days3 + " days ago"
}
window.Repaint();
}
function on_playback_stop() {
artist = ""
album = ""
title = ""
genre = ""
ar_days = 0;
ar_days2 = 0;
ar_days3 = 0;
ar_days4 = 0;
ar_years = 0;
ar_years2 = 0;
ar_years3 = 0;
ar_years4 = 0;
date = 0;
difyear = 0;
playcount = "";
last1 = "";
last2 = "";
last3 = "";
last4 = "";
rating = "";
bitrate = 0;
playing = 0;
window.Repaint();
}
function on_item_played() {
playcount++;
playcount4++;
if (on_playback_new_track2 === 1) {
minplaycount = playcount;
maxplaycount = playcount;
}
var test = window.GetProperty("bio_played")
var test = parseInt(test)
var test2 = test + 1
window.SetProperty("bio_played",test2);
ar_years3 = 0;
if (ar_days2 === 0) {
ar_days2 = "today"
}
if (ar_days2 === 1) {
ar_days2 = "yesterday"
}
if (ar_days2 >>> 1) {
ar_days2 = ar_days2 + " days ago"
}
ar_days3 = 0;
if (ar_days3 === 0) {
ar_days3 = "today"
}
window.Repaint();
}
function on_playlist_switch() {
window.Repaint();
}