Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: WSH Panel Mod (Read 801587 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

WSH Panel Mod

Reply #575
maybe the error is on line 159 on one of your imported scripts?

Except for the flags.txt and helpers.txt that are the same ones that came with version 1.2.1, the only imported script that has that number of lines is inputobjects.js:
Code: [Select]
function Buttons(h, margin) {
this.type = "eb";
this.x1 = 0;
this.x2 = 0;
this.y = 10;
this.w1 = 0;
this.w2 = 0;
this.h = 0;
this.fh = eval(h);
this.margin = eval(margin);
this.colourkw = RGB(229, 229, 229);
this.colourkwb = RGB(0, 0, 0);
this.colourkwh = RGB(255, 255, 200);
this.colourkwbh = RGB(0, 0, 0);
this.colourkws = RGB(229, 229, 229);
this.colourkwsb = RGB(104, 104, 104);
this.colourkwsh = RGB(255, 255, 200);
this.colourkwsbh = RGB(104, 104, 104);
this.colourd = RGB(255, 255, 255);
this.hover1 = false;
this.hover2 = false;
this.gfont = gdi.Font("Arial Unicode MS", this.fh, 0);

this.resize = function () {
this.fh = eval(h);
this.margin = eval(margin);
}

this.redraw = function () {
window.RepaintRect (this.x1, this.y, this.w1 + this.margin + this.w2, this.h);
}

this.draw = function (gr) {
nfo1 = gr.MeasureString("P", this.gfont, 0, 0, 10000, 100, DT_CALCRECT);
nfo2 = gr.MeasureString("EDIT", this.gfont, 0, 0, 10000, 100, DT_CALCRECT);
this.x1 = window.Width - nfo1.Width - nfo2.Width - 11 - 7 * this.margin;
this.x2 = window.Width - nfo2.Width - 11 - 3 * this.margin;
this.w1 = nfo1.Width + 3 * this.margin;
this.w2 = nfo2.Width + 3 * this.margin;
this.h = nfo1.Height + 2 * this.margin;

if (this.hover1) {
colourback1 = this.colourkwbh;
colour1 = this.colourkwh;
}
else {
colourback1 = this.colourkwb;
colour1 = this.colourkw;
}
if (edit) {
if (this.hover2) {
colourback2 = this.colourkwsbh;
colour2 = this.colourkwsh;
}
else {
colourback2 = this.colourkwsb;
colour2 = this.colourkws;
}
}
else {
if (this.hover2) {
colourback2 = this.colourkwbh;
colour2 = this.colourkwh;
}
else {
colourback2 = this.colourkwb;
colour2 = this.colourkw;
}
}
gr.FillRoundRect(this.x1, this.y, this.w1, this.h, 8, 8, colourback1);
gr.DrawRoundRect(this.x1, this.y, this.w1, this.h, 8, 8, 3, colour1);
gr.DrawString("P", this.gfont, colour1, this.x1, this.y, this.w1, this.h, StringFormat(1, 1));
gr.FillRoundRect(this.x2, this.y, this.w2, this.h, 8, 8, colourback2);
gr.DrawRoundRect(this.x2, this.y, this.w2, this.h, 8, 8, 3, colour2);
gr.DrawString("EDIT", this.gfont, colour2, this.x2, this.y, this.w2, this.h, StringFormat(1, 1));
}

this.onMove = function (x, y) {
hv1 = this.hover1;
hv2 = this.hover2;
if ((this.x1 < x) && (x < (this.x1 + this.w1)) && (this.y < y) && (y < (this.y + this.h))) {
this.hover1 = true;
cursorhover = true
} else
this.hover1 = false;
if ((this.x2 < x) && (x < (this.x2 + this.w2)) && (this.y < y) && (y < (this.y + this.h))) {
this.hover2 = true;
cursorhover = true
} else
this.hover2 = false;
if (hv1 != this.hover1 || hv2 != this.hover2) this.redraw();
}

this.onClick = function (x, y) {
if (this.hover1) fb.RunContextCommandWithMetadb("Properties", g_handle);
if (this.hover2) {
if (edit) {
edit = false;
inputobjectsSave();
}
else {
edit = true;
}
inputobjectsRedraw();
}
}

this.load = function () {
}

this.save = function () {
}
}

function ShowMultiLine(title, tag, x, y, tw, tbw, tbh, h, margin) {
this.type = "sml";
this.title = title;
this.tag = tag;
this.content = "";
this.contentbak = "";
this.contentlines = new Array();
this.nrlines = 1;
this.tleft = eval(x);
this.left = eval(x) + eval(tw);
this.top = eval(y);
this.tw = eval(tw);
this.w = eval(tbw);
this.th = eval(tbh);
this.fh = eval(h);
this.margin = eval(margin);
this.h = 0;
this.scroll = 0;
this.scrollubut = false;
this.scrolldbut = false;
this.colourkw = RGB(229, 229, 229);
this.colourkwh = RGB(255, 255, 200);
this.colourb = RGB(255, 255, 255);
this.colourba = RGB(255, 255, 200);
this.colourd = RGB(255, 255, 255);
this.colourt = RGB(192, 192, 192);
this.colourttb = RGB(0, 0, 0);
this.hover = false;
this.splitagain = false;
this.gfont = gdi.Font("Arial Unicode MS", this.fh, 0);
this.gfontt = gdi.Font("Arial Unicode MS", 2 * this.fh / 4, 0);

this.resize = function () {
this.tleft = eval(x);
this.left = eval(x) + eval(tw);
this.top = eval(y);
this.tw = eval(tw);
this.w = eval(tbw);
this.th = eval(tbh);
this.fh = eval(h);
this.margin = eval(margin);
}

this.redraw = function () {
window.RepaintRect (this.left, this.top, this.w, this.th * this.h);
}

this.draw = function (gr) {
this.h = nfo.Height;
this.splitcontent(gr);

//title
gr.DrawString(this.title, this.gfontt, this.colourt, this.tleft, this.top, this.tw - this.margin, this.h, StringFormat(2, 2));

//content
for (n = this.scroll; n < (this.th + this.scroll); n++) {
if (n >= this.nrlines) break;
gr.GdiDrawText(this.contentlines[n], this.gfont, this.colourd, this.left + this.margin, this.top + (n - this.scroll) * this.h, this.w - this.margin, this.h, DT_NOPREFIX);
}

//scrollbar
if ((this.hover) && ((this.scroll > 0) || (this.scroll < (this.nrlines - this.th)))) {
if (this.scrollubut) colour = this.colourkwh; else colour = this.colourkw;
gr.DrawRect(this.left + this.w - this.h / 2, this.top, this.h / 2 - 1, this.h / 2 - 1, 1, colour);
gr.GdiDrawText("▲", this.gfont, colour, this.left + this.w - this.h / 2, this.top - this.h / 4, this.h / 2, this.h, DT_NOPREFIX | DT_CENTER);
if (this.scrolldbut) colour = this.colourkwh; else colour = this.colourkw;
gr.DrawRect(this.left + this.w - this.h / 2, this.top + (this.th - 0.5) * this.h, this.h / 2 - 1, this.h / 2 - 1, 1, colour);
gr.GdiDrawText("▼", this.gfont, colour, this.left + this.w - this.h / 2, this.top + (this.th - 0.75) * this.h, this.h / 2, this.h, DT_NOPREFIX | DT_CENTER);
gr.DrawLine(this.left + this.w - this.h / 2, this.top + this.h / 2 + this.scroll / (this.nrlines - this.th) * ((this.th - 1) * this.h - 5) + 2, this.left + this.w, this.top + this.h / 2 + this.scroll / (this.nrlines - this.th) * ((this.th - 1) * this.h - 5) + 2, 3, this.colourkw);
}
}

this.onMove = function (x, y) {
hv = this.hover;
hvu = this.scrollubut;
hvd = this.scrolldbut;
if ((this.left < x) && (x < (this.left + this.w)) && (this.top < y) && (y < (this.top + this.th * this.h)))
this.hover = true
else
this.hover = false;
if ((this.left + this.w - this.h / 2 < x) && (x < (this.left + this.w)) && (this.top < y) && (y < (this.top + this.h / 2)) && (this.scroll > 0)) {
this.scrollubut = true;
cursorhover = true
}
else
this.scrollubut = false;
if ((this.left + this.w - this.h / 2 < x) && (x < (this.left + this.w)) && ((this.top + (this.th - 0.5) * this.h) < y) && (y < (this.top + this.th * this.h)) && (this.scroll < (this.nrlines - this.th))) {
this.scrolldbut = true;
cursorhover = true
}
else
this.scrolldbut = false;
if (hv != this.hover || hvu != this.scrollubut || hvd != this.scrolldbut) this.redraw();
}

this.onClick = function (x, y) {
if (this.scrollubut) this.scroll -= 1;
if (this.scrolldbut) this.scroll += 1;
this.redraw;
}

this.splitcontent = function (gr) {
this.contentbak = this.content;
n = 0;
tmpstr = this.content;
while (tmpstr.length > 0) {
oldtmpstr = tmpstr;
tmpinfo = gr.MeasureString(tmpstr, this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
while (tmpinfo.width > (this.w - 2 * this.margin)) {
tmpstr = tmpstr.slice(0, -1);
while ((tmpstr.slice(-1) != " ") && (tmpstr.length > 0)) {
tmpstr = tmpstr.slice(0, -1);
}
tmpinfo = gr.MeasureString(tmpstr, this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
}
this.contentlines[n] = tmpstr;
tmpstr = oldtmpstr.slice(tmpstr.length);
n++;
}
this.nrlines = n;
}

this.load = function () {
idx = metadata.MetaFind(this.tag);
if (idx > metadata.MetaCount) this.content = ""; else this.content = metadata.MetaValue(idx, 0);
this.splitagain = true;
}

this.save = function () {
}
}

function SplitterInputBox(title, tag, splittertag, x, y, tw, tbw, h, margin) {
this.type = "ib";
this.title = title;
this.tag = tag;
this.splittertag = splittertag;
this.editsep = ";";
this.content = new Array();
this.contentedit = "";
this.contenteditbak = "";
this.nrvalues = 0;
this.tleft = eval(x);
this.left = eval(x) + eval(tw);
this.top = eval(y);
this.tw = eval(tw);
this.w = eval(tbw);
this.fh = eval(h);
this.margin = eval(margin);
this.h = 0;
this.colourb = RGB(255, 255, 255);
this.colourba = RGB(255, 255, 200);
this.colourd = RGB(255, 255, 255);
this.colourt = RGB(192, 192, 192);
this.colourttb = RGB(0, 0, 0);
this.active = false;
this.hover = false;
this.specialchar = "";
this.gfont = gdi.Font("Arial Unicode MS", this.fh, 0);
this.gfontt = gdi.Font("Arial Unicode MS", 2 * this.fh / 4, 0);

this.resize = function () {
this.tleft = eval(x);
this.left = eval(x) + eval(tw);
this.top = eval(y);
this.tw = eval(tw);
this.w = eval(tbw);
this.fh = eval(h);
this.margin = eval(margin);
}

this.redraw = function () {
window.RepaintRect (this.left, this.top, this.w, this.h);
}

this.draw = function (gr) {
sepcolour = RGB(127, 127, 127);
nfo = gr.MeasureString("n", this.gfont, 0, 0, 10000, 100, DT_CALCRECT);
sepinfo = gr.MeasureString(this.editsep, this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
this.h = nfo.Height;

//title
gr.DrawString(this.title, this.gfontt, this.colourt, this.tleft, this.top, this.tw - this.margin, this.h, StringFormat(2, 2));

if (!this.active) {
if (this.hover) gr.DrawRect(this.left, this.top, this.w - 1, this.h - 1, 1, this.colourba);

//content not active
pos = 0;
tmpstr = "";
for (n = 0 ; n < this.nrvalues; n++) {

if ((n % 2) == 1) {
if (this.content[n] == "")
sep = this.editsep;
else
sep = this.content[n];
pos += 0.5*nfo.Width;
switch (sep){
case ",": pos -= 0.5*nfo.Width; break;
case ":": pos -= 0.5*nfo.Width; break;
case ";": pos -= 0.5*nfo.Width; break;
}
tmpstr += this.sep;
if (pos < (this.w - 2 * this.margin)) gr.GdiDrawText(sep, this.gfont, sepcolour, this.left + this.margin + pos, this.top, this.w - 2 * this.margin - pos, this.h, DT_NOPREFIX);
info = gr.MeasureString(sep, this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
pos += info.Width;
pos += 0.5*nfo.Width;
}
else {
tmpstr += this.content[n];
if (pos < (this.w - 2 * this.margin)) gr.GdiDrawText(this.content[n], this.gfont, this.colourd, this.left + this.margin + pos, this.top, this.w - 2 * this.margin - pos, this.h, DT_NOPREFIX);
info = gr.MeasureString(this.content[n], this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
pos += info.Width;
}
}
}
else {
gr.FillSolidRect(this.left, this.top, this.w, this.h - 1, this.colourb);

//content active
info = gr.MeasureString(this.contentedit, this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
flg = DT_NOPREFIX;
befcur = this.contentedit.slice(0, this.cursor);
tbw = this.w
cursorinfo = gr.MeasureString(befcur, this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
cend = false;
drwtxt = this.contentedit;
if (cursorinfo.Width > (this.w - this.margin - nfo.Width)) {
flg = DT_NOPREFIX | DT_RIGHT;
cend = true;
drwtxt = befcur;
tbw -= 0.5 * nfo.Width;
}
gr.GdiDrawText(drwtxt, this.gfont, this.colourttb, this.left + this.margin, this.top, tbw - 2 * this.margin, this.h, flg);

//cursor
if (cend)  {
gr.FillSolidRect(this.left + tbw - this.margin, this.top + 1.1 * this.fh, 0.5 * nfo.Width, 2, this.colourttb);
}
else {
cursorinfo=gr.MeasureString(this.contentedit.slice(0, this.cursor), this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
gr.FillSolidRect(this.left + this.margin + cursorinfo.Width, this.top + 1.1 * this.fh, 0.5 * nfo.Width, 2, this.colourttb);
}
}
}

this.onMove = function (x, y) {
hv = this.hover;
if ((this.left < x) && (x < (this.left + this.w)) && (this.top < y) && (y < (this.top + this.h)) && edit) {
this.hover = true;
cursorhover = true;
}
else
this.hover = false;
if (hv != this.hover) this.redraw();
}

this.onClick = function (x, y) {
if (this.hover) {
if (!this.active) {
this.active = true;
this.cursor = this.contentedit.length;
this.special = false;
}
}
else {
this.save();
}
}

this.loadeditstr = function () {
this.contenteditbak = this.contentedit;
this.contentedit = this.content.join(";");
}

this.spliteditstr = function () {
tmparr = new Array ();
tmpstr = this.contentedit;
editseptrim = this.editsep;
if (editseptrim.slice(0, 1) == " ") editseptrim = editsepttrim.slice(1);
if (editseptrim.slice(-1) == " ") editseptrim = editseptrim.slice(0, editseptrim.length - 1);
m = 0;
do {
seppos = tmpstr.indexOf(editseptrim);
if (seppos == -1) {
tmparr[m] = tmpstr;
}
else {
tmparr[m] = tmpstr.slice(0, seppos);
tmpstr = tmpstr.slice(seppos + 1);
if (tmpstr.slice(0, 1) == " ") tmpstr = tmpstr.slice(1);
}
if (tmparr[m].slice(-1) == " ") tmparr[m] = tmparr[m].slice(0, tmparr[m].Length - 1);
m++;
} while (seppos != -1);
this.content = tmparr;
this.nrvalues = m;
}

this.load = function () {
this.content.length = 0;
idx1 = metadata.MetaFind(this.tag);
idx2 = metadata.MetaFind(this.splittertag);
if (idx1 > metadata.MetaCount)
this.nrvalues = 0;
else {
this.nrvalues = metadata.MetaValueCount(idx1);
if (this.nrvalues > 1) this.nrvalues = (2 * this.nrvalues) - 1;
}
if (idx2 > metadata.MetaCount)
splitters = 0;
else {
splitters = metadata.MetaValueCount(idx2);
}
for (n = 0 ; n < this.nrvalues; n++) {
if ((n % 2) == 0)
this.content[n] = metadata.MetaValue(idx1, n / 2);
else
if (n < (splitters * 2))
this.content[n] = metadata.MetaValue(idx2, Math.floor(n / 2));
else
this.content[n] = "";
}
this.active = false;
this.loadeditstr();
}

this.save = function () {
if (this.contentedit != this.contenteditbak && this.active) {
this.spliteditstr();
metadata.MetaRemoveField(this.tag);
metadata.MetaRemoveField(this.splittertag);
idx1 = metadata.MetaAdd(this.tag, this.content[this.nrvalues - 1]);
if (this.nrvalues > 1) idx2 = metadata.MetaAdd(this.splittertag, this.content[this.nrvalues - 2]);
for (n = this.nrvalues - 3 ; n > -1; n--) {
if ((n % 2) == 0)
metadata.MetaInsertValue(idx1, 0, this.content[n]);
else
if (this.nrvalues > 1) metadata.MetaInsertValue(idx2, 0, this.content[n]);
}
g_handle.UpdateFileInfo(metadata);
this.active = false;
this.loadeditstr();
reload = true;
window.Repaint();
}
else
this.active = false;
}

this.escape = function () {
this.contentedit = tb.contenteditbak;
this.cursor = tb.contentedit.length;
}
}

function InputBox(title, tag, multivalue, x, y, tw, tbw, h, margin) {
this.type = "ib";
this.title = title;
this.tag = tag;
this.multivalue = multivalue;
this.editsep = "; ";
this.content = new Array();
this.contentedit = "";
this.contenteditbak = "";
this.nrvalues = 0;
this.tleft = eval(x);
this.left = eval(x) + eval(tw);
this.top = eval(y);
this.tw = eval(tw);
this.w = eval(tbw);
this.fh = eval(h);
this.margin = eval(margin);
this.h = 0;
this.colourb = RGB(255, 255, 255);
this.colourba = RGB(255, 255, 200);
this.colourd = RGB(255, 255, 255);
this.colourt = RGB(192, 192, 192);
this.colourttb = RGB(0, 0, 0);
this.active = false;
this.hover = false;
this.specialchar = "";
this.gfont = gdi.Font("Arial Unicode MS", this.fh, 0);
this.gfontt = gdi.Font("Arial Unicode MS", 2 * this.fh / 4, 0);

this.resize = function () {
this.tleft = eval(x);
this.left = eval(x) + eval(tw);
this.top = eval(y);
this.tw = eval(tw);
this.w = eval(tbw);
this.fh = eval(h);
this.margin = eval(margin);
}

this.redraw = function () {
window.RepaintRect (this.left, this.top, this.w, this.h);
}

this.draw = function (gr) {
this.left = this.tleft + this.tw;
sepcolour = RGB(127, 127, 127);
nfo = gr.MeasureString("n", this.gfont, 0, 0, 10000, 100, DT_CALCRECT);
sepinfo = gr.MeasureString(this.editsep, this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
this.h = nfo.Height;

//title
gr.DrawString(this.title, this.gfontt, this.colourt, this.tleft, this.top, this.tw - this.margin, this.h, StringFormat(2, 2));

if (!this.active) {
if (this.hover) gr.DrawRect(this.left, this.top, this.w - 1, this.h - 1, 1, this.colourba);

//content not active
pos = 0;
tmpstr = "";
for (n = 0 ; n < this.nrvalues; n++) {
if (n != 0) {
tmpstr += this.editsep;
if (pos < (this.w - 2 * this.margin)) gr.GdiDrawText(this.editsep, this.gfont, sepcolour, this.left + this.margin + pos, this.top, this.w - 2 * this.margin - pos, this.h, DT_NOPREFIX);
info = gr.MeasureString(this.editsep, this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
pos += info.Width;
}
tmpstr += this.content[n];
if (pos < (this.w - 2 * this.margin)) gr.GdiDrawText(this.content[n], this.gfont, this.colourd, this.left + this.margin + pos, this.top, this.w - 2 * this.margin - pos, this.h, DT_NOPREFIX);
info = gr.MeasureString(this.content[n], this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
pos += info.Width;
}
}
else {
gr.FillSolidRect(this.left, this.top, this.w, this.h - 1, this.colourb);

//content active
info = gr.MeasureString(this.contentedit, this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
flg = DT_NOPREFIX;
befcur = this.contentedit.slice(0, this.cursor);
tbw = this.w
cursorinfo = gr.MeasureString(befcur, this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
cend = false;
drwtxt = this.contentedit;
if (cursorinfo.Width > (this.w - this.margin - nfo.Width)) {
flg = DT_NOPREFIX | DT_RIGHT;
cend = true;
drwtxt = befcur;
tbw -= 0.5 * nfo.Width;
}
gr.GdiDrawText(drwtxt, this.gfont, this.colourttb, this.left + this.margin, this.top, tbw - 2 * this.margin, this.h, flg);

//cursor
if (cend)  {
gr.FillSolidRect(this.left + tbw - this.margin, this.top + 1.1 * this.fh, 0.5 * nfo.Width, 2, this.colourttb);
}
else {
cursorinfo=gr.MeasureString(this.contentedit.slice(0, this.cursor), this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
gr.FillSolidRect(this.left + this.margin + cursorinfo.Width, this.top + 1.1 * this.fh, 0.5 * nfo.Width, 2, this.colourttb);
}
}
}

this.onMove = function (x, y) {
hv = this.hover;
if ((this.left < x) && (x < (this.left + this.w)) && (this.top < y) && (y < (this.top + this.h)) && edit) {
this.hover = true;
cursorhover = true
}
else
this.hover = false;
if (hv != this.hover) this.redraw();
}

this.onClick = function (x, y) {
if (this.hover) {
if (!this.active) {
this.active = true;
this.cursor = this.contentedit.length;
this.special = false;
}
}
else {
this.save();
}
}

this.loadeditstr = function () {
this.contenteditbak = this.contentedit;
this.contentedit = this.content.join(";");
}

this.spliteditstr = function () {
if (this.multivalue) {
tmparr = new Array ();
tmpstr = this.contentedit;
editseptrim = this.editsep;
if (editseptrim.slice(0, 1) == " ") editseptrim = editsepttrim.slice(1);
if (editseptrim.slice(-1) == " ") editseptrim = editseptrim.slice(0, editseptrim.length - 1);
m = 0;
do {
seppos = tmpstr.indexOf(editseptrim);
if (seppos == -1) {
tmparr[m] = tmpstr;
}
else {
tmparr[m] = tmpstr.slice(0, seppos);
tmpstr = tmpstr.slice(seppos + 1);
if (tmpstr.slice(0, 1) == " ") tmpstr = tmpstr.slice(1);
}
if (tmparr[m].slice(-1) == " ") tmparr[m] = tmparr[m].slice(0, tmparr[m].Length - 1);
m++;
} while (seppos != -1);
this.content = tmparr;
this.nrvalues = m;
}
else
this.content[0] = this.contentedit;
}

this.load = function () {
this.content.length = 0;
idx = metadata.MetaFind(this.tag);
if (idx > metadata.MetaCount) this.nrvalues = 0; else this.nrvalues = metadata.MetaValueCount(idx);
for (n = 0 ; n < this.nrvalues; n++) this.content[n] = metadata.MetaValue(idx, n);
this.active = false;
this.loadeditstr();
}

this.save = function () {
if (this.contentedit != this.contenteditbak && this.active) {
this.spliteditstr();
if (this.multivalue) {
metadata.MetaRemoveField(this.tag);
idx = metadata.MetaAdd(this.tag, this.content[this.nrvalues -1]);
for (n = this.nrvalues - 2 ; n > -1; n--) {
metadata.MetaInsertValue(idx, 0, this.content[n]);
}
}
else
metadata.MetaSet (this.tag, this.content[0]);
g_handle.UpdateFileInfo(metadata);
this.active = false;
this.loadeditstr();
reload = true;
window.Repaint();
}
else
this.active = false;
}

this.escape = function () {
this.contentedit = tb.contenteditbak;
this.cursor = tb.contentedit.length;
}
}

function Keywords(title, tag, list, listlong, x, y, tw, kw, h, margin) {
this.type = "kw";
this.title = title;
this.tag = tag;
this.list = list;
this.listlong = listlong;
this.content = new Array();
this.changed = false;
this.errorstr = "";
this.errorcontent = new Array();
this.nrvalues = 0;
this.tleft = eval(x);
this.top = eval(y);
this.tw = eval(tw);
this.kw = eval(kw);
this.fh = eval(h);
this.margin = eval(margin);
this.left = new Array();
this.width = new Array();
this.h = 0;
this.scroll = 0;
this.maxscroll = 0;
this.scrollpbut = false;
this.scrollnbut = false;
this.colourkw = RGB(229, 229, 229);
this.colourkwh = RGB(255, 255, 200);
this.colourd = RGB(255, 255, 255);
this.colourt = RGB(192, 192, 192);
this.hover = -1;
this.hoverbut = -1;
this.emptyhover = false;
this.emptyhoverbut = false;
this.gfont = gdi.Font("Arial Unicode MS", this.fh, 0);
this.gfontt = gdi.Font("Arial Unicode MS", 2 * this.fh / 4, 0);
this.gfontbut = gdi.Font("Arial Unicode MS", this.fh / 1.3, 0);

this.resize = function () {
this.tleft = eval(x);
this.top = eval(y);
this.tw = eval(tw);
this.kw = eval(kw);
this.fh = eval(h);
this.margin = eval(margin);
}

this.redraw = function () {
window.RepaintRect (this.tleft + this.tw, this.top, this.kw, this.h);
}

this.draw = function (gr) {
nfo = gr.MeasureString("n", this.gfont, 0, 0, 10000, 100, DT_CALCRECT);
nfob = gr.MeasureString("◀", this.gfontbut, 0, 0, 10000, 100, DT_CALCRECT);
nfof = gr.MeasureString("▶", this.gfontbut, 0, 0, 10000, 100, DT_CALCRECT);
nfop = gr.MeasureString("+", this.gfontbut, 0, 0, 10000, 100, DT_CALCRECT);
nfom = gr.MeasureString("−", this.gfontbut, 0, 0, 10000, 100, DT_CALCRECT);
this.h = nfo.Height;

//title
gr.DrawString(this.title, this.gfontt, this.colourt, this.tleft, this.top, this.tw - this.margin, this.h, StringFormat(2, 2));

//values
leftstart = this.tleft + this.tw + this.margin;
pos = 0;
for (i = 0 ; i < this.nrvalues; i++) {
this.left[i] = leftstart + pos;
info = gr.MeasureString(this.content[i], this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
this.width[i] = info.Width;
if (this.width[i] < (4 * this.h / 3)) this.width[i] = 4* this.h / 3;
pos += this.width[i];
this.maxscroll = pos - this.kw;
if (this.hover == i) colour = this.colourkwh; else colour = this.colourkw;
if (this.errorcontent[i]) colour = RGB(255, 0, 0);
this.left[i] -= this.scroll;
flg = DT_NOPREFIX;
if (this.left[i] < leftstart) {
flg = DT_NOPREFIX | DT_RIGHT;
this.width[i] += this.left[i] - leftstart;
this.left[i] = leftstart;
}
if ((this.left[i] + this.width[i]) > (leftstart + this.kw)) this.width[i] = leftstart + this.kw - this.left[i];
if (this.width[i] >= 0) {
gr.GdiDrawText(this.content[i], this.gfont, colour, this.left[i], this.top, this.width[i], this.h, flg);
}
pos += nfo.Width + this.margin;
}

//menu
if (this.hover != -1 && !this.scrollpbut && !this.scrollnbut) {
gr.DrawLine(this.left[this.hover], this.top, this.left[this.hover] + this.width[this.hover], this.top, 1, this.colourkwh);
if (this.hoverbut == 0) {
gr.DrawRect(this.left[this.hover], this.top, this.h / 3 - 1, this.h / 3 - 1, 1, this.colourkwh);
colour = this.colourkwh;
}
else
colour = this.colourkw;
gr.DrawLine(this.left[this.hover], this.top, this.left[this.hover] + this.h / 3, this.top, 1, this.colourkwh);
gr.DrawString("◀", this.gfontbut, colour, this.left[this.hover] + (this.h / 3 - nfob.width) / 2, this.top - 1, this.h / 3, this.h / 3, StringFormat(1, 1));
if (this.hoverbut == 1) {
gr.DrawRect(this.left[this.hover] + this.h / 3, this.top, this.h / 3 - 1, this.h / 3 - 1, 1, this.colourkwh);
colour = this.colourkwh;
}
else
colour = this.colourkw;
gr.DrawLine(this.left[this.hover] + this.h / 3, this.top, this.left[this.hover] + 2 * this.h / 3, this.top, 1, this.colourkwh);
gr.DrawString("▶", this.gfontbut, colour, this.left[this.hover] + this.h / 3 + (this.h / 3 - nfof.width) / 2, this.top - 1, this.h / 3, this.h / 3, StringFormat(1, 1));
if (this.hoverbut == 2) {
gr.DrawRect(this.left[this.hover] + this.width[this.hover] - 2 * this.h / 3, this.top, this.h / 3 - 1, this.h / 3 - 1, 1, this.colourkwh);
colour = this.colourkwh;
}
else
colour = this.colourkw;
gr.DrawLine(this.left[this.hover] + this.width[this.hover] - 2 * this.h / 3, this.top, this.left[this.hover] + this.width[this.hover] - this.h / 3, this.top, 1, this.colourkwh);
gr.DrawString("+", this.gfontbut, colour, this.left[this.hover] + this.width[this.hover]  - 2 * this.h / 3 + (this.h / 3 - nfop.width) / 2, this.top - 1, this.h / 3, this.h / 3, StringFormat(1, 1));
if (this.hoverbut == 3) {
gr.DrawRect(this.left[this.hover] + this.width[this.hover] - this.h / 3, this.top, this.h / 3 - 1, this.h / 3 - 1, 1, this.colourkwh);
colour = this.colourkwh;
}
else
colour = this.colourkw;
gr.DrawLine(this.left[this.hover] + this.width[this.hover] - this.h / 3, this.top, this.left[this.hover] + this.width[this.hover], this.top, 1, this.colourkwh);
gr.DrawString("−", this.gfontbut, colour, this.left[this.hover] + this.width[this.hover]  -  this.h / 3 + (this.h / 3 - nfom.width) / 2, this.top - 1, this.h / 3, this.h / 3, StringFormat(1, 1));
}

//scroll buttons
if (this.scrollpbut) {
gr.DrawRect(leftstart, this.top + this.h / 4, this.h / 2 - 1, this.h / 2 - 1, 1, this.colourkwh);
gr.GdiDrawText("◀", this.gfont, this.colourkwh, leftstart, this.top, this.h / 2, this.h, DT_NOPREFIX | DT_CENTER);
}
if (this.scrollnbut) {
gr.DrawRect(leftstart + this.kw - this.h / 2, this.top + this.h / 4, this.h / 2 - 1, this.h / 2 - 1, 1, this.colourkwh);
gr.GdiDrawText("▶", this.gfont, this.colourkwh, leftstart + this.kw - this.h / 2, this.top, this.h / 2, this.h, DT_NOPREFIX | DT_CENTER);
}

//empty
if (this.emptyhover) {
gr.DrawLine(leftstart + this.margin, this.top, leftstart + this.kw - this.margin, this.top, 1, this.colourkwh);

if (this.emptyhoverbut == 0)
colour = this.colourkw;
else {
gr.DrawRect(leftstart, this.top, this.h / 3 - 1, this.h / 3 - 1, 1, this.colourkwh);
colour = this.colourkwh;
}
gr.DrawLine(leftstart, this.top, leftstart + this.margin, this.top, 1, this.colourkwh);
gr.DrawString("+", this.gfontbut, colour, leftstart + (this.margin - nfop.width) / 2 + 2, this.top - 1, this.h / 3, this.h / 3, StringFormat(1, 1));
}
}

this.onMove = function (x, y) {
if (edit) {
hv = this.hover;
hvb = this.hoverbut;
hvsp = this.scrollpbut;
hvsn = this.scrollnbut;
hve = this.emptyhover;
hveb = this.emptyhoverbut;
this.hover = -1;
this.hoverbut = -1;
this.emptyhover = false;
this.emptyhoverbut = false;
for (i = 0 ; i < this.nrvalues; i++) {
if (this.width[i] >= 0) {
if ((this.left[i] < x) && (x < (this.left[i] + this.width[i])) && (this.top < y) && (y < (this.top + this.h))) {
this.hover = i;
if ((this.left[i] < x) && (x < (this.left[i] + this.h / 3)) && (this.top < y) && (y < (this.top + this.h / 3))) {
this.hoverbut = 0;
cursorhover = true
}
if (((this.left[i] + this.h / 3) < x) && (x < (this.left[i] + 2* this.h / 3) ) && (this.top < y) && (y < (this.top + this.h / 3))) {
this.hoverbut = 1;
cursorhover = true
}
if (((this.left[i] + this.width[i] - 2* this.h / 3) < x) && (x < (this.left[i] + this.width[i]) ) && (this.top < y) && (y < (this.top + this.h / 3))) {
this.hoverbut = 2;
cursorhover = true
}
if (((this.left[i] + this.width[i] - this.h / 3) < x) && (x < (this.left[i] + this.width[i]) ) && (this.top < y) && (y < (this.top + this.h / 3))) {
this.hoverbut = 3;
cursorhover = true
}
}
}
}

if (((this.tleft + this.tw) < x) && (x < (this.tleft + this.tw + this.h / 2)) && ((this.top + this.h / 4) < y) && (y < (this.top + 3 * this.h / 4)) && (this.scroll > 0))  {
this.scrollpbut = true;
this.hover = -1;
this.hoverbut = -1;
cursorhover = true
}
else
this.scrollpbut = false;
if (((this.tleft + this.tw + this.kw - this.h / 2) < x) && (x < (this.tleft + this.tw + this.kw)) && ((this.top + this.h / 4) < y) && (y < (this.top + 3 * this.h / 4)) && (this.scroll < this.maxscroll))  {
this.scrollnbut = true;
this.hover = -1;
this.hoverbut = -1;
cursorhover = true
}
else
this.scrollnbut = false;

if (((this.tleft + this.tw + margin) < x) && (x < (this.tleft + this.tw + margin + this.kw)) && (this.top < y) && (y < (this.top + this.h)) && (this.nrvalues == 0))
this.emptyhover = true;
if (((this.tleft + this.tw + margin) < x) && (x < (this.tleft + this.tw + margin + this.h / 3)) && (this.top < y) && (y < (this.top + this.h / 3)) && (this.nrvalues == 0)) {
this.emptyhoverbut = true;
cursorhover = true
}

if ((hv != this.hover) || (hvb != this.hoverbut) || (hvsp != this.scrollpbut) || (hvsn != this.scrollnbut) || (hve != this.emptyhover) || (hveb != this.emptyhoverbut)) this.redraw();
}
}

this.onClick = function (x, y) {
if (this.hover > -1) {
tmparr1 = new Array ();
tmparr2 = new Array ();
for (i = 0 ; i < this.nrvalues; i++) {
if (this.hover == i) {

// <
if ((this.hoverbut == 0) && (i != 0)) {
for (j = 0 ; j < this.nrvalues; j++) {
tmparr1[j] = this.content[j];
tmparr2[j] = this.errorcontent[j];
}
tmparr1[i - 1] = this.content[i];
tmparr2[i - 1] = this.errorcontent[i];
tmparr1[i] = this.content[i - 1];
tmparr2[i] = this.errorcontent[i - 1];
for (j = 0 ; j < this.nrvalues; j++) {
this.content[j] = tmparr1[j];
this.errorcontent[j] = tmparr2[j];
}
this.changed = true;
this.save();
}

// >
if ((this.hoverbut == 1) && (i < this.nrvalues - 1)) {
for (j = 0 ; j < this.nrvalues; j++) {
tmparr1[j] = this.content[j];
tmparr2[j] = this.errorcontent[j];
}
tmparr1[i + 1] = this.content[i];
tmparr2[i + 1] = this.errorcontent[i];
tmparr1[i] = this.content[i + 1];
tmparr2[i] = this.errorcontent[i + 1];
for (j = 0 ; j < this.nrvalues; j++) {
this.content[j] = tmparr1[j];
this.errorcontent[j] = tmparr2[j];
}
this.changed = true;
this.save();
}

// +
if (this.hoverbut == 2) {
var popupmenu = window.CreatePopupMenu();
for (j in this.list) {
popupmenu.AppendMenuItem(0, parseInt(j) + 1, this.listlong[j]);
}
menuret = popupmenu.TrackPopupMenu(x, y);
if (menuret != 0) {
this.nrvalues += 1;
for (j = 0 ; j < this.nrvalues; j++) {
if (j <= i) {
tmparr1[j] = this.content[j];
tmparr2[j] = this.errorcontent[j];
}
if (j == (i + 1)) {
tmparr1[j] = this.listlong[menuret - 1];
tmparr2[j] = false;
}
if (j > (i + 1)) {
tmparr1[j] = this.content[j - 1];
tmparr2[j] = this.errorcontent[j - 1];
}
}
for (j = 0 ; j < this.nrvalues; j++) {
this.content[j] = tmparr1[j];
this.errorcontent[j] = tmparr2[j];
}
}
this.changed = true;
this.save();
}

// x
if (this.hoverbut == 3) {
this.nrvalues -= 1;
for (j = 0 ; j < this.nrvalues; j++) {
if (j >= i) tmparr1[j] = this.content[j + 1]; else tmparr1[j] = this.content[j];
if (j >= i) tmparr2[j] = this.errorcontent[j + 1]; else tmparr2[j] = this.errorcontent[j];
}
for (j = 0 ; j < this.nrvalues; j++) {
this.content[j] = tmparr1[j];
this.errorcontent[j] = tmparr2[j];
}
this.changed = true;
this.save();
}
}
}
}

// <<
if (this.scrollpbut) {
this.scroll -= this.h;
if (this.scroll < 0) this.scroll = 0;
this.redraw;
}

// >>
if (this.scrollnbut) {
this.scroll += this.h;
if (this.scroll > this.maxscroll) this.scroll = this.maxscroll;
this.redraw;
}

// +
if (this.emptyhoverbut) {
var popupmenu = window.CreatePopupMenu();
for (j in this.list) {
popupmenu.AppendMenuItem(0, parseInt(j) + 1, this.listlong[j]);
}
menuret = popupmenu.TrackPopupMenu(x, y);
if (menuret != 0) {
this.nrvalues += 1;
this.content[0] = this.listlong[menuret - 1];
this.changed = true;
this.save();
}
}
}

this.loadkeywords = function () {
for (i = 0 ; i < this.nrvalues; i++) {
this.errorcontent[i] = true;
for (j in this.list) {
if (this.content[i] == this.list[j]) {
this.content[i] = this.listlong[j];
this.errorcontent[i] = false;
}
}
}
}

this.load = function () {
this.content.length = 0;
idx = metadata.MetaFind(this.tag);
if (idx > metadata.MetaCount) this.nrvalues = 0; else this.nrvalues = metadata.MetaValueCount(idx);
for (n = 0 ; n < this.nrvalues; n++) this.content[n] = metadata.MetaValue(idx, n);
this.loadkeywords();
this.changed = false;
}

this.save = function () {
if (this.changed) {
this.changed = false;
metadata.MetaRemoveField(this.tag);
writestr = this.content[this.nrvalues - 1];
if (!this.errorcontent[this.nrvalues -1]) {
for (j in this.list) {
if (this.content[this.nrvalues -1] == this.listlong[j]) writestr = this.list[j];
}
}
if (this.nrvalues != 0) idx = metadata.MetaAdd(this.tag, writestr);
for (n = this.nrvalues - 2 ; n > -1; n--) {
writestr = this.content[n];
if (!this.errorcontent[n]) {
for (j in this.list) {
if (this.content[n] == this.listlong[j]) writestr = this.list[j];
}
}
metadata.MetaInsertValue(idx, 0, writestr);
}
g_handle.UpdateFileInfo(metadata);
reload = true;
window.Repaint();
}
}
}

function CheckBox(title, tag, x, y, tw, h, margin) {
this.type = "cb";
this.title = title;
this.tag = tag;
this.content = 0;
this.changed = false;
this.tleft = eval(x);
this.top = eval(y);
this.tw = eval(tw);
this.fh = eval(h);
this.margin = eval(margin);
this.left = 0;
this.h = 0;
this.colourkw = RGB(229, 229, 229);
this.colourkwb = RGB(0, 0, 0);
this.colourkwh = RGB(255, 255, 200);
this.colourkwbh = RGB(0, 0, 0);
this.colourkws = RGB(229, 229, 229);
this.colourkwsb = RGB(104, 104, 104);
this.colourkwsh = RGB(255, 255, 200);
this.colourkwsbh = RGB(104, 104, 104);
this.colourd = RGB(255, 255, 255);
this.colourt = RGB(192, 192, 192);
this.hover = false;
this.gfont = gdi.Font("Arial Unicode MS", this.fh, 0);
this.gfontt = gdi.Font("Arial Unicode MS", 2 * this.fh / 4, 0);

this.resize = function () {
this.tleft = eval(x);
this.top = eval(y);
this.tw = eval(tw);
this.fh = eval(h);
this.margin = eval(margin);
}

this.redraw = function () {
window.RepaintRect (this.left, this.top, this.h, this.h);
}

this.draw = function (gr) {
this.left = this.tleft + this.tw + this.margin;
nfo = gr.MeasureString("n", this.gfont, 0, 0, 10000, 100, DT_CALCRECT);
this.h = nfo.Height;

//title
gr.DrawString(this.title, this.gfontt, this.colourt, this.tleft, this.top, this.tw - this.margin, this.h, StringFormat(2, 2));

//checkbox
if (this.hover) {
colourback = RGB(255, 0, 0);
colour = this.colourkwh;
txt = "";
if (this.content == 0) {
colourback = this.colourkwbh;
colour = this.colourkwh;
txt = "";
}
if (this.content == 1) {
colourback = this.colourkwsbh;
colour = this.colourkwsh;
txt = "✕";
}
}
else {
colourback = RGB(255, 0, 0);
colour = this.colourkw;
txt = "";
if (this.content == 0) {
colourback = this.colourkwb;
colour = this.colourkw;
txt = "";
}
if (this.content == 1) {
colourback = this.colourkwsb;
colour = this.colourkws;
txt = "✕";
}
}
gr.FillEllipse(this.left, this.top, this.h - 1, this.h - 1, colourback);
gr.DrawEllipse(this.left, this.top, this.h - 1, this.h - 1, 1, colour);
gr.DrawString(txt, this.gfont, colour, this.left, this.top, this.h, this.h, StringFormat(1, 1));
}

this.onMove = function (x, y) {
hv = this.hover;
if ((this.left < x) && (x < (this.left + this.h)) && (this.top < y) && (y < (this.top + this.h)) && edit) {
this.hover = true;
cursorhover = true
}
else
this.hover = false;
if (hv != this.hover) this.redraw();
}

this.onClick = function (x, y) {
if (this.hover) {
if (this.content == 0)
this.content = 1;
else if (this.content == 1)
this.content = 0;
else
this.content = 1;
this.changed = true;
this.save();
}
}

this.load = function () {
idx = metadata.MetaFind(this.tag);
if (idx > metadata.MetaCount) this.content = 0; else this.content = metadata.MetaValue(idx, 0);
this.changed = false;
}

this.save = function () {
if (this.changed) {
this.changed = false;
metadata.MetaSet (this.tag, this.content);
g_handle.UpdateFileInfo(metadata);
reload = true;
window.Repaint();
}
}
}

function RadioBox(title, tag, list, listlong, x, y, tw, rw, h, margin, showall) {
this.type = "rb";
this.title = title;
this.tag = tag;
this.list = list;
this.listlong = listlong;
this.content = 0;
this.contenterror = false;
this.changed = false;
this.tleft = eval(x);
this.top = eval(y);
this.tw = eval(tw);
this.rw = eval(rw);
this.fh = eval(h);
this.margin = eval(margin);
this.left = new Array ();
this.width = new Array();
this.h = 0;
this.colourkw = RGB(229, 229, 229);
this.colourkwb = RGB(0, 0, 0);
this.colourkwh = RGB(255, 255, 200);
this.colourkwbh = RGB(0, 0, 0);
this.colourkws = RGB(229, 229, 229);
this.colourkwsb = RGB(104, 104, 104);
this.colourkwsh = RGB(255, 255, 200);
this.colourkwsbh = RGB(104, 104, 104);
this.colourd = RGB(255, 255, 255);
this.colourt = RGB(192, 192, 192);
this.showall = showall;
this.hover = -1;
this.gfont = gdi.Font("Arial Unicode MS", this.fh, 0);
this.gfontt = gdi.Font("Arial Unicode MS", 2 * this.fh / 4, 0);
this.gfontbut = gdi.Font("Arial Unicode MS", this.fh / 1.3, 0);

this.resize = function () {
this.tleft = eval(x);
this.top = eval(y);
this.tw = eval(tw);
this.rw = eval(rw);
this.fh = eval(h);
this.margin = eval(margin);
}

this.redraw = function () {
window.RepaintRect (this.tleft + this.tw, this.top, this.rw, this.h);
}

this.draw = function (gr) {
nfo = gr.MeasureString("n", this.gfont, 0, 0, 10000, 100, DT_CALCRECT);
nfod = gr.MeasureString("▾", this.gfontbut, 0, 0, 10000, 100, DT_CALCRECT);
this.h = nfo.Height;

//title
gr.DrawString(this.title, this.gfontt, this.colourt, this.tleft, this.top, this.tw - this.margin, this.h, StringFormat(2, 2));

leftstart = this.tleft + this.tw + this.margin;
if (showall) {

//values
pos = 0;
for (i in this.list) {
this.left[i] = leftstart + pos;
info = gr.MeasureString(this.listlong[i], this.gfont, 0, 0, 10000, 100, DT_NOPREFIX | DT_CALCRECT);
this.width[i] = info.Width;
pos += this.width[i];
if (this.hover == i) {
if (this.content == this.listlong[i]) {
colourback = this.colourkwsbh;
colourl = this.colourkwsh;
colour = this.colourkwsh;
tstsel = true
}
else {
colourback = this.colourkwbh;
colourl = this.colourkwbh;
colour = this.colourkwh;
tstsel = false;
}
}
else {
if (this.content == this.listlong[i]) {
colourback = this.colourkwsb;
colourl = this.colourkws;
colour = this.colourkws;
tstsel = true;
}
else {
colourback = this.colourkwb;
colourl = this.colourkwb;
colour = this.colourkw;
tstsel = false;
}
}
// if (tstsel) {
// this.left[i] += this.margin;
// pos += this.margin;
// }
if (this.contenterror) colour = RGB(255, 0, 0);
if (tstsel) {
gr.FillSolidRect(this.left[i] - this.margin, this.top, this.width[i] + 2 * this.margin, this.h, colourback);
gr.DrawRect(this.left[i] - this.margin, this.top, this.width[i] + 2 * this.margin - 1, this.h - 1, 1, colourl);
}
gr.GdiDrawText(this.listlong[i], this.gfont, colour, this.left[i], this.top, this.width[i], this.h, DT_NOPREFIX);
pos += nfo.Width + this.margin;
}
this.rw = this.left[i] + this.width[i];
if (tstsel) this.rw += this.margin;
}
else {

//value
if (this.hover == -1) colour = this.colourkw; else colour = this.colourkwh;
if (this.contenterror) colour = RGB(255, 0, 0);
if (this.content == "") {
str = "[none]";
colour = RGB(127, 127, 127);
}
else
str = this.content;
gr.GdiDrawText(str, this.gfont, colour, leftstart, this.top, this.rw, this.h, DT_NOPREFIX);

//menu
if (this.hover != -1) {
gr.DrawLine(leftstart, this.top, leftstart + this.rw, this.top, 1, this.colourkwh);
gr.DrawString("▾", this.gfontbut, this.colourkwh, leftstart + this.rw -  this.h / 3 + (this.h / 3 - nfom.width) / 2, this.top - 1, this.h / 3, this.h / 1, StringFormat(1, 1));
}
}
}

this.onMove = function (x, y) {
if (edit) {
hv = this.hover;
if (showall) {
this.hover = -1;
for (i in this.list) {
if ((this.left[i] < x) && (x < (this.left[i] + this.width[i])) && (this.top < y) && (y < (this.top + this.h))) {
this.hover = i;
cursorhover = true
}
}
}
else {
if (((this.tleft + this.tw) < x) && (x < (this.tleft + this.tw + this. rw)) && (this.top < y) && (y < (this.top + this.h))) {
this.hover = 0;
cursorhover = true
}
else
this.hover = -1;
}
if (hv != this.hover) this.redraw();
}
}

this.onClick = function (x, y) {
if (this.hover != -1) {
if (showall) {
if (this.content == this.listlong[this.hover])
this.content = "";
else
this.content = this.listlong[this.hover];
this.contenterror = false;
this.changed = true;
this.save();
}
else {
var popupmenu = window.CreatePopupMenu();
popupmenu.AppendMenuItem(0, 1, "[none]");
for (j in this.list) {
popupmenu.AppendMenuItem(0, parseInt(j) + 2, this.listlong[j]);
}
menuret = popupmenu.TrackPopupMenu(x, y);
if (menuret != 0) {
this.content = this.listlong[menuret - 2];
this.contenterror = false;
this.changed = true;
this.save();
}
}
}
}

this.load = function () {
idx = metadata.MetaFind(this.tag);
if (idx > metadata.MetaCount) {
this.content = "";
this.contenterror = false;
}
else {
str = metadata.MetaValue(idx, 0);
this.contenterror = true;
for (i in this.list) {
if (str == this.list[i]) {
this.content = this.listlong[i];
this.contenterror = false;
}
}
if (this.contenterror) this.content = str;
if (str == "") this.contenterror = false;
}
this.changed = false;
}

this.save = function () {
if (this.changed) {
this.changed = false;
for (i in this.list) {
if (this.content == this.listlong[i]) this.content = this.list[i];
}
metadata.MetaSet (this.tag, this.content);
g_handle.UpdateFileInfo(metadata);
reload = true;
window.Repaint();
}
}
}

function InputRating(title, tag, max, x, y, tw, h, margin) {
this.type = "ra";
this.title = title;
this.tag = tag;
this.max = max;
this.content = 0;
this.contenterror = false;
this.changed = false;
this.tleft = eval(x);
this.top = eval(y);
this.tw = eval(tw);
this.fh = eval(h);
this.margin = eval(margin);
this.left = 0;
this.h = 0;
this.colourkw = RGB(229, 229, 229);
this.colourkwh = RGB(255, 255, 200);
this.colourd = RGB(255, 255, 255);
this.colourt = RGB(192, 192, 192);
this.hover = -1;
this.gfont = gdi.Font("Arial Unicode MS", this.fh, 0);
this.gfontt = gdi.Font("Arial Unicode MS", 2 * this.fh / 4, 0);
this.gfontbut = gdi.Font("Arial Unicode MS", this.fh / 1.3, 0);

this.resize = function () {
this.tleft = eval(x);
this.top = eval(y);
this.tw = eval(tw);
this.fh = eval(h);
this.margin = eval(margin);
}

this.redraw = function () {
window.RepaintRect (this.tleft, this.top, this.max * this.h + this.tw + this.margin, this.h);
}

this.draw = function (gr) {
this.left = this.tleft + this.tw + this.margin;
nfo = gr.MeasureString("n", this.gfont, 0, 0, 10000, 100, DT_CALCRECT);
nfom = gr.MeasureString("−", this.gfontbut, 0, 0, 10000, 100, DT_CALCRECT);
this.h = nfo.Height;

//title
gr.DrawString(this.title, this.gfontt, this.colourt, this.tleft, this.top, this.tw - this.margin, this.h, StringFormat(2, 2));

//rating
for (i = 1; i <= this.max; i++) {
if (i <= this.content) {
str = "★";
if (this.hover == i) colour = this.colourkwh; else colour = this.colourkw;
}
else {
str = "☆"
if (this.hover == i) colour = this.colourkwh; else colour = RGB(127, 127, 127);
}
if (this.contenterror) colour = RGB(255, 0, 0);
gr.GdiDrawText(str, this.gfont, colour, this.left + (i - 1) * this.h, this.top, this.h, this.h, DT_NOPREFIX);
}

//menu
if (this.hover != -1) {
gr.DrawLine(this.left, this.top, this.left + this.max * this.h - 1, this.top, 1, this.colourkwh);
if (this.hover == 0) {
gr.DrawRect(this.left + this.max * this.h - this.h / 3, this.top, this.h / 3 - 1, this.h / 3 - 1, 1, this.colourkwh);
colour = this.colourkwh;
}
else
colour = this.colourkw;
gr.DrawString("−", this.gfontbut, colour, this.left + this.max * this.h -  this.h / 3 + (this.h / 3 - nfom.width) / 2, this.top - 1, this.h / 3, this.h / 3, StringFormat(1,1));
}
}

this.onMove = function (x, y) {
if (edit) {
hv = this.hover;
this.hover = -1;
for (i = 0; i < this.max; i++) {
if (((this.left + i * this.h) < x) && (x < (this.left + (i + 1) * this.h)) && (this.top < y) && (y < (this.top + this.h))) {
this.hover = i + 1;
cursorhover = true
}
}
if (((this.left + this.max * this.h - this.h / 3) < x) && (x < (this.left + this.max * this.h)) && (this.top < y) && (y < (this.top + this.h))) {
this.hover = 0;
cursorhover = true
}
if (hv != this.hover) this.redraw();
}
}

this.onClick = function (x, y) {
if (this.hover >= 0) {
this.content = this.hover;
this.contenterror = false;
this.changed = true;
this.save();
}
}

this.load = function () {
idx = metadata.MetaFind(this.tag);
if (idx > metadata.MetaCount)
this.content = 0;
else {
str = metadata.MetaValue(idx, 0);
this.contenterror = true;
for (i = 0; i <= this.max; i ++) {
if (str == i) {
this.content = i;
this.contenterror = false;
}
if (this.contenterror) this.content = 0;
}
}
this.changed = false;
}

this.save = function () {
if (this.changed) {
this.changed = false;
metadata.MetaSet (this.tag, this.content);
g_handle.UpdateFileInfo(metadata);
reload = true;
window.Repaint();
}
}
}

Here line 159 is a window.RepaintRect(...) function call. The change log doesn't say anything about a changed behaviour of that function...

WSH Panel Mod

Reply #576
How about add following line:
Code: [Select]
fb.trace("Trace before window.RepaintRect():", this.left, this.top, this.w, this.th * this.h);

before:
Code: [Select]
window.RepaintRect (this.left, this.top, this.w, this.th * this.h);


And see what happens (in your console).

However, when runtime Error 'Overflow' occured, your stack may be messed up, so that error info is useless, in that case, send your whole scripts to me, I may take a look.

WSH Panel Mod

Reply #577
I found out it is my own fault: it is indeed in this repaint action, but things go wrong if one of my elements falls outside of the panel (so I have to introduce a check for that) and I just changed to a new wide screen laptop, which has less pixels in height than were my configuration was made for.
In short: the problem was that the height of the repaint area was negative and the difference between the two versions came from that I had not yet turned off the status bar in the new one.

Anyway: thanks for your (trying to) help and of course thanks for this nice component!

WSH Panel Mod

Reply #578
out of boredom i've made a replacement artwork panel for CUI/DUI.

features:
-if you edit/add artwork for the currently playing track, use the "Refresh" context menu item to see the changes without having to restart playback.
-changes made in the foobar display preferences also take effect immediately if you use the "Refresh" command. currently, the DUI/CUI artwork panels require a foobar restart for those changes to take effect.
-displays artwork for the previously played/selected track on foobar startup.
-you can lock the panel size in pixels. no more messing around locking splitters. both CUI and DUI obey the limits set in the panel.
-tooltip to show if the artwork is embedded or not. it also shows the actual image dimensions plus the currently displayed size.
-it has the usual context menu options you would expect to set front/back/cover/artist/etc

screenshot

Code: [Select]
//edit this line or comment it out if you don't want a fixed panel size....
//editing this value works immediately in DUI. CUI may require a restart after changes.
window.MinWidth = window.MinHeight = window.MaxWidth = window.MaxHeight = 375;
//a little tweak is needed if you're using DUI. so set 1 for DUI, 0 for CUI
var dui = 1;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//no need to edit anything below here///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var g_metadb = fb.GetFocusItem();
var g_img, new_width, new_height = null;

var g_tooltip = window.CreateTooltip();
var hover = null;
window.GetProperty("aspect",1);
window.GetProperty("id",0);

function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}

function on_size() {
ww = window.Width;
wh = window.Height;
}

function on_paint(gr) {
if (g_img) {
if(window.GetProperty("aspect") == 1) {
var scale_w = ww / g_img.Width;
var scale_h = wh / g_img.Height;
scale = Math.min(scale_w, scale_h);
var pos_x = 0, pos_y = 0;
if (scale_w < scale_h)
pos_y = (wh - g_img.height * scale) / 2;
else if (scale_w > scale_h)
pos_x = (ww - g_img.Width * scale) / 2;
new_width = g_img.Width * scale;
new_height = g_img.Height * scale
} else {
pos_x = 0;
pos_y = 0;
new_width = ww;
new_height = wh;
}
gr.DrawImage(g_img, pos_x, pos_y, new_width, new_height, 0, 0, g_img.Width, g_img.Height);
}
    if(dui == 1) gr.DrawRect(0,0, window.Width, window.Height, 1.0, RGB(160,160,160));
}

function on_item_focus_change() {
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
is_embedded = "No";
if(g_metadb) {
type = window.GetProperty("id");
g_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, type);
if(g_img) {
is_embedded = "Yes";
} else {
g_img = utils.GetAlbumArtV2(g_metadb, type);
}
window.Repaint();
}
}

function on_playback_new_track() {
on_item_focus_change();
}

on_item_focus_change();

function on_mouse_move(x,y) {
if(!hover && g_img) {
g_tooltip.Text = "Embedded image: " + is_embedded + ". Actual size: " + g_img.Width + " x " + g_img.Height + ". Current size: " + Math.round(new_width) + " x " + Math.round(new_height) + ".";
g_tooltip.Activate();
hover = true;
}
}

function on_mouse_leave() {
g_tooltip.Deactivate();
hover = null;
}

function on_mouse_rbtn_up(x, y) {
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var _menu = window.CreatePopupMenu();
var idx;
_menu.AppendMenuItem(MF_STRING, 1, "Refresh");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 2, "Correct Aspect Ratio");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 4, "Front Cover");
_menu.AppendMenuItem(MF_STRING, 5, "Back Cover");
_menu.AppendMenuItem(MF_STRING, 6, "Disc");
_menu.AppendMenuItem(MF_STRING, 7, "Icon");
_menu.AppendMenuItem(MF_STRING, 8, "Artist");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
//_menu.AppendMenuItem(MF_STRING, 9, "Properties");
_menu.AppendMenuItem(MF_STRING, 10, "Configure...");
_menu.CheckMenuItem(2, window.GetProperty("aspect") == 0 ? 0x0 : 0x8);
_menu.CheckMenuRadioItem(4, 8, window.GetProperty("id")+4);
idx = _menu.TrackPopupMenu(x, y);
switch(idx) {
case 1:
on_item_focus_change();
break;
case 2:
window.GetProperty("aspect") == 0 ? window.SetProperty("aspect", 1) : window.SetProperty("aspect", 0);
window.Repaint();
break;
case 4:
case 5:
case 6:
case 7:
case 8:
window.SetProperty("id", idx-4);
on_item_focus_change();
break;
case 9:
window.ShowProperties();
break;
case 10:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}

WSH Panel Mod

Reply #579
WSH Panel Mod 1.3.0 Beta 4 uploaded (1.2.2 version number is now changed to 1.3.0)
Note that he major change is the "safe mode" is enabled by default now.
For other changes, read ChangeLog.txt

WSH Panel Mod

Reply #580
the new stuff to get the colours and detect UI is awesome. thanks.

updated version of above artwork panel using these new features:

Code: [Select]
//edit this line or comment it out if you don't a fixed size....
window.MinWidth = window.MinHeight = window.MaxWidth = window.MaxHeight = 375;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//no need to edit anything below here///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var g_metadb = fb.GetFocusItem();
var g_img, new_width, new_height = null;

var g_tooltip = window.CreateTooltip();
var hover = null;
var dui = window.InstanceType;
window.GetProperty("aspect",1);
window.GetProperty("id",0);

function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}

function on_size() {
ww = window.Width;
wh = window.Height;
}

function on_colors_changed() {
    window.Repaint();
}

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    if (g_img) {
if(window.GetProperty("aspect") == 1) {
var scale_w = ww / g_img.Width;
var scale_h = wh / g_img.Height;
scale = Math.min(scale_w, scale_h);
var pos_x = 0, pos_y = 0;
if (scale_w < scale_h)
pos_y = (wh - g_img.height * scale) / 2;
else if (scale_w > scale_h)
pos_x = (ww - g_img.Width * scale) / 2;
new_width = g_img.Width * scale;
new_height = g_img.Height * scale
} else {
pos_x = 0;
pos_y = 0;
new_width = ww;
new_height = wh;
}
gr.DrawImage(g_img, pos_x, pos_y, new_width, new_height, 0, 0, g_img.Width, g_img.Height);
}
    if(dui == 1) gr.DrawRect(0,0, window.Width, window.Height, 1.0, RGB(160,160,160));
}

function on_item_focus_change() {
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
is_embedded = "No";
if(g_metadb) {
type = window.GetProperty("id");
g_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, type);
if(g_img) {
is_embedded = "Yes";
} else {
g_img = utils.GetAlbumArtV2(g_metadb, type);
}
window.Repaint();
}
}

function on_playback_new_track() {
on_item_focus_change();
}

on_item_focus_change();

function on_mouse_move(x,y) {
if(!hover && g_img) {
g_tooltip.Text = "Embedded image: " + is_embedded + ". Actual size: " + g_img.Width + " x " + g_img.Height + ". Current size: " + Math.round(new_width) + " x " + Math.round(new_height) + ".";
g_tooltip.Activate();
hover = true;
}
}

function on_mouse_leave() {
g_tooltip.Deactivate();
hover = null;
}

function on_mouse_rbtn_up(x, y) {
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var _menu = window.CreatePopupMenu();
var idx;
_menu.AppendMenuItem(MF_STRING, 1, "Refresh");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 2, "Correct Aspect Ratio");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 4, "Front Cover");
_menu.AppendMenuItem(MF_STRING, 5, "Back Cover");
_menu.AppendMenuItem(MF_STRING, 6, "Disc");
_menu.AppendMenuItem(MF_STRING, 7, "Icon");
_menu.AppendMenuItem(MF_STRING, 8, "Artist");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
//_menu.AppendMenuItem(MF_STRING, 9, "Properties");
_menu.AppendMenuItem(MF_STRING, 10, "Configure...");
_menu.CheckMenuItem(2, window.GetProperty("aspect") == 0 ? 0x0 : 0x8);
_menu.CheckMenuRadioItem(4, 8, window.GetProperty("id")+4);
idx = _menu.TrackPopupMenu(x, y);
switch(idx) {
case 1:
on_item_focus_change();
break;
case 2:
window.GetProperty("aspect") == 0 ? window.SetProperty("aspect", 1) : window.SetProperty("aspect", 0);
window.Repaint();
break;
case 4:
case 5:
case 6:
case 7:
case 8:
window.SetProperty("id", idx-4);
on_item_focus_change();
break;
case 9:
window.ShowProperties();
break;
case 10:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}

WSH Panel Mod

Reply #581
One of my panel doesnt work anymore with the latest version.
This code doesnt work anymore
Code: [Select]
this.Panel.FSO = new ActiveXObject("Scripting.FileSystemObject");

Is there an alternative?

Thanks for the latest version anyway

WSH Panel Mod

Reply #582
T.P did mention it above. safe mode is enabled by default so you need to turn it off.

WSH Panel Mod

Reply #583
oh sorry didnt know it had anything to do witht the safe mode :s

WSH Panel Mod

Reply #584
Hi,

I'm new at this WSH Panel Mod and I want to have a Trackinfo-Panel. Is there an example how to display %artist%, %title%, %album%, etc. for the now-playing track? And how can I set font-color from system? An example of how centering text, etc. would be very nice, too

Thanks in advance.


WSH Panel Mod

Reply #586
And how can I set font-color from system? An example of how centering text, etc. would be very nice, too


the sample code in the latest version already has a working example of those features.

WSH Panel Mod

Reply #587
the new stuff to get the colours and detect UI is awesome. thanks.

updated version of above artwork panel using these new features:

Code: [Select]
//edit this line or comment it out if you don't a fixed size....
window.MinWidth = window.MinHeight = window.MaxWidth = window.MaxHeight = 375;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//no need to edit anything below here///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var g_metadb = fb.GetFocusItem();
var g_img, new_width, new_height = null;

var g_tooltip = window.CreateTooltip();
var hover = null;
var dui = window.InstanceType;
window.GetProperty("aspect",1);
window.GetProperty("id",0);

function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}

function on_size() {
ww = window.Width;
wh = window.Height;
}

function on_colors_changed() {
    window.Repaint();
}

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    if (g_img) {
if(window.GetProperty("aspect") == 1) {
var scale_w = ww / g_img.Width;
var scale_h = wh / g_img.Height;
scale = Math.min(scale_w, scale_h);
var pos_x = 0, pos_y = 0;
if (scale_w < scale_h)
pos_y = (wh - g_img.height * scale) / 2;
else if (scale_w > scale_h)
pos_x = (ww - g_img.Width * scale) / 2;
new_width = g_img.Width * scale;
new_height = g_img.Height * scale
} else {
pos_x = 0;
pos_y = 0;
new_width = ww;
new_height = wh;
}
gr.DrawImage(g_img, pos_x, pos_y, new_width, new_height, 0, 0, g_img.Width, g_img.Height);
}
    if(dui == 1) gr.DrawRect(0,0, window.Width, window.Height, 1.0, RGB(160,160,160));
}

function on_item_focus_change() {
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
is_embedded = "No";
if(g_metadb) {
type = window.GetProperty("id");
g_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, type);
if(g_img) {
is_embedded = "Yes";
} else {
g_img = utils.GetAlbumArtV2(g_metadb, type);
}
window.Repaint();
}
}

function on_playback_new_track() {
on_item_focus_change();
}

on_item_focus_change();

function on_mouse_move(x,y) {
if(!hover && g_img) {
g_tooltip.Text = "Embedded image: " + is_embedded + ". Actual size: " + g_img.Width + " x " + g_img.Height + ". Current size: " + Math.round(new_width) + " x " + Math.round(new_height) + ".";
g_tooltip.Activate();
hover = true;
}
}

function on_mouse_leave() {
g_tooltip.Deactivate();
hover = null;
}

function on_mouse_rbtn_up(x, y) {
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var _menu = window.CreatePopupMenu();
var idx;
_menu.AppendMenuItem(MF_STRING, 1, "Refresh");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 2, "Correct Aspect Ratio");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 4, "Front Cover");
_menu.AppendMenuItem(MF_STRING, 5, "Back Cover");
_menu.AppendMenuItem(MF_STRING, 6, "Disc");
_menu.AppendMenuItem(MF_STRING, 7, "Icon");
_menu.AppendMenuItem(MF_STRING, 8, "Artist");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
//_menu.AppendMenuItem(MF_STRING, 9, "Properties");
_menu.AppendMenuItem(MF_STRING, 10, "Configure...");
_menu.CheckMenuItem(2, window.GetProperty("aspect") == 0 ? 0x0 : 0x8);
_menu.CheckMenuRadioItem(4, 8, window.GetProperty("id")+4);
idx = _menu.TrackPopupMenu(x, y);
switch(idx) {
case 1:
on_item_focus_change();
break;
case 2:
window.GetProperty("aspect") == 0 ? window.SetProperty("aspect", 1) : window.SetProperty("aspect", 0);
window.Repaint();
break;
case 4:
case 5:
case 6:
case 7:
case 8:
window.SetProperty("id", idx-4);
on_item_focus_change();
break;
case 9:
window.ShowProperties();
break;
case 10:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}
I love what you have done. I am currently trying to add a fading effect to it when switching art but it doesnt see to be that easy :s

WSH Panel Mod

Reply #588
I am getting an error on a previously working script also.
Popup:
Code: [Select]
Scripting Engine Initialization Failed (GUID: 88656871-8566-4E3D-A572-2EEC8047E257, CODE: 0x80020101)
Check the console for more detailed information (Always caused by unexcepted script error).

Console:
Code: [Select]
[12:51:41] Error: WSH Panel Mod (GUID: 88656871-8566-4E3D-A572-2EEC8047E257): Microsoft JScript runtime error:
Automation server can't create object
Ln: 38, Col: 1
<no source text available>

The script in my case is your last.fm syncro script, marc2003

WSH Panel Mod

Reply #589
same problem/solution as above. turn off safe mode. the WSH panel mod preferences are now found under tools in the main preferences.

WSH Panel Mod

Reply #590
apologies, a dozen replies happened as I was typing *chuckle*

WSH Panel Mod

Reply #591
Thanks for the update, great to have it as a DUI Element.
Windows 10 Pro x64 // foobar2000 1.3.10

WSH Panel Mod

Reply #592
the new stuff to get the colours and detect UI is awesome. thanks.

updated version of above artwork panel using these new features:

Code: [Select]
//edit this line or comment it out if you don't a fixed size....
window.MinWidth = window.MinHeight = window.MaxWidth = window.MaxHeight = 375;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//no need to edit anything below here///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var g_metadb = fb.GetFocusItem();
var g_img, new_width, new_height = null;

var g_tooltip = window.CreateTooltip();
var hover = null;
var dui = window.InstanceType;
window.GetProperty("aspect",1);
window.GetProperty("id",0);

function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}

function on_size() {
ww = window.Width;
wh = window.Height;
}

function on_colors_changed() {
    window.Repaint();
}

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    if (g_img) {
if(window.GetProperty("aspect") == 1) {
var scale_w = ww / g_img.Width;
var scale_h = wh / g_img.Height;
scale = Math.min(scale_w, scale_h);
var pos_x = 0, pos_y = 0;
if (scale_w < scale_h)
pos_y = (wh - g_img.height * scale) / 2;
else if (scale_w > scale_h)
pos_x = (ww - g_img.Width * scale) / 2;
new_width = g_img.Width * scale;
new_height = g_img.Height * scale
} else {
pos_x = 0;
pos_y = 0;
new_width = ww;
new_height = wh;
}
gr.DrawImage(g_img, pos_x, pos_y, new_width, new_height, 0, 0, g_img.Width, g_img.Height);
}
    if(dui == 1) gr.DrawRect(0,0, window.Width, window.Height, 1.0, RGB(160,160,160));
}

function on_item_focus_change() {
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
is_embedded = "No";
if(g_metadb) {
type = window.GetProperty("id");
g_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, type);
if(g_img) {
is_embedded = "Yes";
} else {
g_img = utils.GetAlbumArtV2(g_metadb, type);
}
window.Repaint();
}
}

function on_playback_new_track() {
on_item_focus_change();
}

on_item_focus_change();

function on_mouse_move(x,y) {
if(!hover && g_img) {
g_tooltip.Text = "Embedded image: " + is_embedded + ". Actual size: " + g_img.Width + " x " + g_img.Height + ". Current size: " + Math.round(new_width) + " x " + Math.round(new_height) + ".";
g_tooltip.Activate();
hover = true;
}
}

function on_mouse_leave() {
g_tooltip.Deactivate();
hover = null;
}

function on_mouse_rbtn_up(x, y) {
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var _menu = window.CreatePopupMenu();
var idx;
_menu.AppendMenuItem(MF_STRING, 1, "Refresh");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 2, "Correct Aspect Ratio");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 4, "Front Cover");
_menu.AppendMenuItem(MF_STRING, 5, "Back Cover");
_menu.AppendMenuItem(MF_STRING, 6, "Disc");
_menu.AppendMenuItem(MF_STRING, 7, "Icon");
_menu.AppendMenuItem(MF_STRING, 8, "Artist");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
//_menu.AppendMenuItem(MF_STRING, 9, "Properties");
_menu.AppendMenuItem(MF_STRING, 10, "Configure...");
_menu.CheckMenuItem(2, window.GetProperty("aspect") == 0 ? 0x0 : 0x8);
_menu.CheckMenuRadioItem(4, 8, window.GetProperty("id")+4);
idx = _menu.TrackPopupMenu(x, y);
switch(idx) {
case 1:
on_item_focus_change();
break;
case 2:
window.GetProperty("aspect") == 0 ? window.SetProperty("aspect", 1) : window.SetProperty("aspect", 0);
window.Repaint();
break;
case 4:
case 5:
case 6:
case 7:
case 8:
window.SetProperty("id", idx-4);
on_item_focus_change();
break;
case 9:
window.ShowProperties();
break;
case 10:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}

if anyone s interested i modified it to get fading effect during track transition
Code: [Select]
//edit this line or comment it out if you don't a fixed size....
//window.MinWidth = window.MinHeight = window.MaxWidth = window.MaxHeight = 200;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//no need to edit anything below here///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var g_metadb = fb.GetFocusItem();
var NewImage, CurImage, new_width, new_height = null;
var CurSize = null;
var NewSize = null;
var ww = window.Width;
var wh = window.Height;
var opacity = 255;
var RefreshInterval = 50;
var step = Math.min(Math.ceil(255*RefreshInterval/300),255);
var timer = null;


var g_tooltip = window.CreateTooltip();
var hover = null;
var dui = window.InstanceType;
window.GetProperty("aspect",1);
window.GetProperty("id",0);

function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}

function on_timer(id) {
    if (timer && id==timer.ID) {
        if (opacity>0) {
            opacity = Math.max(opacity-step,0);
            window.Repaint();
        } else {
            CurImage = NewImage;
            CurSize = NewSize;
            NewImage = null;
            NewSize = null;
            opacity = 255;
            timer && window.KillTimer(timer);
            timer = null;
            CollectGarbage(); // Release memory.
            //window.RepaintRect(this.x, this.y, this.width, this.height);
        }
    }
}

function on_size() {
ww = window.Width;
wh = window.Height;
}

function on_colors_changed() {
window.Repaint();
}

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    var Img, size;
    if (Img = CurImage) {
        currentopacity = opacity;
        size = CurSize;
        gr.DrawImage(Img, size.x, size.y, size.width, size.height, 0, 0, Img.width, Img.height, 0, opacity);
    }
        fb.trace("test:  ");
    if (Img = NewImage) {
        currentopacity = 255-opacity;
        size = NewSize;
        gr.DrawImage(Img, size.x, size.y, size.width, size.height, 0, 0, Img.width, Img.height, 0, 255-opacity);
  }

    //gr.DrawImage(g_img, pos_x, pos_y, new_width, new_height, 0, 0, g_img.Width, g_img.Height);

    if(dui == 1) gr.DrawRect(0,0, window.Width, window.Height, 1.0, RGB(160,160,160));
}

function CalcNewImgSize(img) {
    var size = {x:0, y:0, width:ww, height:wh};
    if (img) {
        if(window.GetProperty("aspect") == 1) {
            var scale_w = ww / img.Width;
            var scale_h = wh / img.Height;
            scale = Math.min(scale_w, scale_h);
            if (scale_w < scale_h)
                size.y = (wh - g_img.height * scale) / 2;
            else if (scale_w > scale_h)
                size.x = (ww - img.Width * scale) / 2;
                size.width = img.Width * scale;
                size.height = img.Height * scale
            }
    }
    return size;
}

function on_playback_new_track(){
    changeImage();
}

function changeImage() {
    g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();

    is_embedded = "No";
if(g_metadb) {
    type = window.GetProperty("id");
    g_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, type);
    if(g_img) {
        is_embedded = "Yes";
    } else {
        g_img = utils.GetAlbumArtV2(g_metadb, type);
    }     
        if (NewImage) {
CurImage = NewImage;
                CurSize = NewSize;
opacity = 255;
}
NewImage = g_img;
            NewSize = CalcNewImgSize(NewImage);
if (!timer) timer = window.CreateTimerInterval(RefreshInterval);

    window.Repaint();
    }

    //if ( fb.IsPlaying) return;

}

changeImage();

function on_mouse_move(x,y) {
if(!hover && NewImage) {
g_tooltip.Text = "Embedded image: " + is_embedded + ". Actual size: " + g_img.Width + " x " + g_img.Height + ". Current size: " + Math.round(new_width) + " x " + Math.round(new_height) + ".";
g_tooltip.Activate();
hover = true;
}
}

function on_mouse_leave() {
g_tooltip.Deactivate();
hover = null;
}

function on_mouse_rbtn_up(x, y) {
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var _menu = window.CreatePopupMenu();
var idx;
_menu.AppendMenuItem(MF_STRING, 1, "Refresh");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 2, "Correct Aspect Ratio");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 4, "Front Cover");
_menu.AppendMenuItem(MF_STRING, 5, "Back Cover");
_menu.AppendMenuItem(MF_STRING, 6, "Disc");
_menu.AppendMenuItem(MF_STRING, 7, "Icon");
_menu.AppendMenuItem(MF_STRING, 8, "Artist");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
//_menu.AppendMenuItem(MF_STRING, 9, "Properties");
_menu.AppendMenuItem(MF_STRING, 10, "Configure...");
_menu.CheckMenuItem(2, window.GetProperty("aspect") == 0 ? 0x0 : 0x8);
_menu.CheckMenuRadioItem(4, 8, window.GetProperty("id")+4);
idx = _menu.TrackPopupMenu(x, y);
switch(idx) {
case 1:
on_item_focus_change();
break;
case 2:
window.GetProperty("aspect") == 0 ? window.SetProperty("aspect", 1) : window.SetProperty("aspect", 0);
window.Repaint();
break;
case 4:
case 5:
case 6:
case 7:
case 8:
window.SetProperty("id", idx-4);
on_item_focus_change();
break;
case 9:
window.ShowProperties();
break;
case 10:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}

@TP Wang:
What does that mean?
- ADD: First attempt to implement UI element support.
Do you mean the interface you added with CUI or DUI?

WSH Panel Mod

Reply #593
if anyone s interested i modified it to get fading effect during track transition
Code: [Select]
//edit this line or comment it out if you don't a fixed size....
//window.MinWidth = window.MinHeight = window.MaxWidth = window.MaxHeight = 200;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//no need to edit anything below here///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var g_metadb = fb.GetFocusItem();
var NewImage, CurImage, new_width, new_height = null;
var CurSize = null;
var NewSize = null;
var ww = window.Width;
var wh = window.Height;
var opacity = 255;
var RefreshInterval = 50;
var step = Math.min(Math.ceil(255*RefreshInterval/300),255);
var timer = null;


var g_tooltip = window.CreateTooltip();
var hover = null;
var dui = window.InstanceType;
window.GetProperty("aspect",1);
window.GetProperty("id",0);

function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}

function on_timer(id) {
    if (timer && id==timer.ID) {
        if (opacity>0) {
            opacity = Math.max(opacity-step,0);
            window.Repaint();
        } else {
            CurImage = NewImage;
            CurSize = NewSize;
            NewImage = null;
            NewSize = null;
            opacity = 255;
            timer && window.KillTimer(timer);
            timer = null;
            CollectGarbage(); // Release memory.
            //window.RepaintRect(this.x, this.y, this.width, this.height);
        }
    }
}

function on_size() {
ww = window.Width;
wh = window.Height;
}

function on_colors_changed() {
window.Repaint();
}

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    var Img, size;
    if (Img = CurImage) {
        currentopacity = opacity;
        size = CurSize;
        gr.DrawImage(Img, size.x, size.y, size.width, size.height, 0, 0, Img.width, Img.height, 0, opacity);
    }
        fb.trace("test:  ");
    if (Img = NewImage) {
        currentopacity = 255-opacity;
        size = NewSize;
        gr.DrawImage(Img, size.x, size.y, size.width, size.height, 0, 0, Img.width, Img.height, 0, 255-opacity);
  }

    //gr.DrawImage(g_img, pos_x, pos_y, new_width, new_height, 0, 0, g_img.Width, g_img.Height);

    if(dui == 1) gr.DrawRect(0,0, window.Width, window.Height, 1.0, RGB(160,160,160));
}

function CalcNewImgSize(img) {
    var size = {x:0, y:0, width:ww, height:wh};
    if (img) {
        if(window.GetProperty("aspect") == 1) {
            var scale_w = ww / img.Width;
            var scale_h = wh / img.Height;
            scale = Math.min(scale_w, scale_h);
            if (scale_w < scale_h)
                size.y = (wh - g_img.height * scale) / 2;
            else if (scale_w > scale_h)
                size.x = (ww - img.Width * scale) / 2;
                size.width = img.Width * scale;
                size.height = img.Height * scale
            }
    }
    return size;
}

function on_playback_new_track(){
    changeImage();
}

function changeImage() {
    g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();

    is_embedded = "No";
if(g_metadb) {
    type = window.GetProperty("id");
    g_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, type);
    if(g_img) {
        is_embedded = "Yes";
    } else {
        g_img = utils.GetAlbumArtV2(g_metadb, type);
    }     
        if (NewImage) {
CurImage = NewImage;
                CurSize = NewSize;
opacity = 255;
}
NewImage = g_img;
            NewSize = CalcNewImgSize(NewImage);
if (!timer) timer = window.CreateTimerInterval(RefreshInterval);

    window.Repaint();
    }

    //if ( fb.IsPlaying) return;

}

changeImage();

function on_mouse_move(x,y) {
if(!hover && NewImage) {
g_tooltip.Text = "Embedded image: " + is_embedded + ". Actual size: " + g_img.Width + " x " + g_img.Height + ". Current size: " + Math.round(new_width) + " x " + Math.round(new_height) + ".";
g_tooltip.Activate();
hover = true;
}
}

function on_mouse_leave() {
g_tooltip.Deactivate();
hover = null;
}

function on_mouse_rbtn_up(x, y) {
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var _menu = window.CreatePopupMenu();
var idx;
_menu.AppendMenuItem(MF_STRING, 1, "Refresh");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 2, "Correct Aspect Ratio");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 4, "Front Cover");
_menu.AppendMenuItem(MF_STRING, 5, "Back Cover");
_menu.AppendMenuItem(MF_STRING, 6, "Disc");
_menu.AppendMenuItem(MF_STRING, 7, "Icon");
_menu.AppendMenuItem(MF_STRING, 8, "Artist");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
//_menu.AppendMenuItem(MF_STRING, 9, "Properties");
_menu.AppendMenuItem(MF_STRING, 10, "Configure...");
_menu.CheckMenuItem(2, window.GetProperty("aspect") == 0 ? 0x0 : 0x8);
_menu.CheckMenuRadioItem(4, 8, window.GetProperty("id")+4);
idx = _menu.TrackPopupMenu(x, y);
switch(idx) {
case 1:
on_item_focus_change();
break;
case 2:
window.GetProperty("aspect") == 0 ? window.SetProperty("aspect", 1) : window.SetProperty("aspect", 0);
window.Repaint();
break;
case 4:
case 5:
case 6:
case 7:
case 8:
window.SetProperty("id", idx-4);
on_item_focus_change();
break;
case 9:
window.ShowProperties();
break;
case 10:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}

The fading effect works great, I love it.  I'm experiencing some issues with your updated version that aren't present in Marc's original.  For starters, the "refresh" option is broken.  Secondly, the tooltips don't always work.  Third, when playback is stopped, the album art doesn't follow the selected item.

WSH Panel Mod

Reply #594
@TP Wang:
I have two requests for wsh panel mod:

First of all, to repeat myself, to have an interface for a form style kind of input box.

Secondly, and more important, for a change of behaviour of the pop-up menu. Now if it is to long to fit on the screen it shows an arrow indicating that there is more - so far so good. The problem is that one can only scroll it line by line - every mouse click one line - which is very annoying if one has to scroll a lot of lines. So my request is to change this behaviour into either keep scrolling as long as the mouse button is down, or scroll if the cursor hovers over the arrow.

Thanks a lot!

WSH Panel Mod

Reply #595
I'm experiencing some issues with your updated version that aren't present in Marc's original.

try my mod instead...

Code: [Select]
//edit this line or comment it out if you don't a fixed size....
window.MinWidth = window.MinHeight = window.MaxWidth = window.MaxHeight = 375;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//no need to edit anything below here///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var g_metadb = fb.GetFocusItem();
var g_timer, g_img, new_width, new_height = null;
var refresh = 1;
var op =0;


var g_tooltip = window.CreateTooltip();
var hover = null;
var dui = window.InstanceType;
window.GetProperty("aspect",1);
window.GetProperty("id",0);

function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}

function on_size() {
ww = window.Width;
wh = window.Height;
}

function on_colors_changed() {
    window.Repaint();
}

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    if (g_img) {
if(window.GetProperty("aspect") == 1) {
var scale_w = ww / g_img.Width;
var scale_h = wh / g_img.Height;
scale = Math.min(scale_w, scale_h);
var pos_x = 0, pos_y = 0;
if (scale_w < scale_h)
pos_y = (wh - g_img.height * scale) / 2;
else if (scale_w > scale_h)
pos_x = (ww - g_img.Width * scale) / 2;
new_width = g_img.Width * scale;
new_height = g_img.Height * scale
} else {
pos_x = 0;
pos_y = 0;
new_width = ww;
new_height = wh;
}
        op+=40;
        if(op >=255) {op = 255; window.KillTimer(g_timer);}
gr.DrawImage(g_img, pos_x, pos_y, new_width, new_height, 0, 0, g_img.Width, g_img.Height,0,op);
}
    if(dui == 1) gr.DrawRect(0,0, window.Width, window.Height, 1.0, RGB(160,160,160));
}

function on_item_focus_change() {
    if(refresh == 0) return;
    if(fb.IsPlaying) refresh = 0;
    op = 0;
    g_timer = window.CreateTimerInterval(10);
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
is_embedded = "No";
if(g_metadb) {
type = window.GetProperty("id");
g_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, type);
if(g_img) {
is_embedded = "Yes";
} else {
g_img = utils.GetAlbumArtV2(g_metadb, type);
}
window.Repaint();
}
}

function on_playback_new_track() {
    refresh = 1;
on_item_focus_change();
}

function on_playback_stop() {
    refresh = 1;
}

function on_timer() {
    window.Repaint();
}

on_item_focus_change();

function on_mouse_move(x,y) {
if(!hover && g_img) {
g_tooltip.Text = "Embedded image: " + is_embedded + ". Actual size: " + g_img.Width + " x " + g_img.Height + ". Current size: " + Math.round(new_width) + " x " + Math.round(new_height) + ".";
g_tooltip.Activate();
hover = true;
}
}

function on_mouse_leave() {
g_tooltip.Deactivate();
hover = null;
}

function on_mouse_rbtn_up(x, y) {
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var _menu = window.CreatePopupMenu();
var idx;
_menu.AppendMenuItem(MF_STRING, 1, "Refresh");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 2, "Correct Aspect Ratio");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 4, "Front Cover");
_menu.AppendMenuItem(MF_STRING, 5, "Back Cover");
_menu.AppendMenuItem(MF_STRING, 6, "Disc");
_menu.AppendMenuItem(MF_STRING, 7, "Icon");
_menu.AppendMenuItem(MF_STRING, 8, "Artist");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
//_menu.AppendMenuItem(MF_STRING, 9, "Properties");
_menu.AppendMenuItem(MF_STRING, 10, "Configure...");
_menu.CheckMenuItem(2, window.GetProperty("aspect") );
_menu.CheckMenuRadioItem(4, 8, window.GetProperty("id")+4);
idx = _menu.TrackPopupMenu(x, y);
switch(idx) {
case 1:
            refresh = 1;
on_item_focus_change();
break;
case 2:
window.GetProperty("aspect") == 0 ? window.SetProperty("aspect", 1) : window.SetProperty("aspect", 0);
window.Repaint();
break;
case 4:
case 5:
case 6:
case 7:
case 8:
window.SetProperty("id", idx-4);
            refresh = 1;
on_item_focus_change();
break;
case 9:
window.ShowProperties();
break;
case 10:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}

 

WSH Panel Mod

Reply #596
A semi-offtopic suggestion:
Maybe the script exchange business could take place elsewhere, so this topic would be left for the general component discussion only? By that I mean information about new releases, feature requests, bug reports and other support, while the creations of the users and stories about the others struggling to use them would be kept separate.

Also I suppose using some pastebin (with the "forever" time limit, of course) and posting just links to the code would be nicer too. To name a few advantages:
  • Easier to select and copy or download than in the scrolling codebox here
  • Has proper JavaScript syntax highlighting
  • You can highlight individual lines to pay attention to
  • Conveniently displays line numbers
  • Allows nicely displaying the differences (as long as the new code is posted as a change/reply to the previous)
  • Saves people from the quoting madness
Full-quoting makes you scroll past the same junk over and over.



WSH Panel Mod

Reply #599
I'm experiencing some issues with your updated version that aren't present in Marc's original.

try my mod instead...

Code: [Select]
//edit this line or comment it out if you don't a fixed size....
window.MinWidth = window.MinHeight = window.MaxWidth = window.MaxHeight = 375;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//no need to edit anything below here///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var g_metadb = fb.GetFocusItem();
var g_timer, g_img, new_width, new_height = null;
var refresh = 1;
var op =0;


var g_tooltip = window.CreateTooltip();
var hover = null;
var dui = window.InstanceType;
window.GetProperty("aspect",1);
window.GetProperty("id",0);

function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}

function on_size() {
ww = window.Width;
wh = window.Height;
}

function on_colors_changed() {
    window.Repaint();
}

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
    if (g_img) {
if(window.GetProperty("aspect") == 1) {
var scale_w = ww / g_img.Width;
var scale_h = wh / g_img.Height;
scale = Math.min(scale_w, scale_h);
var pos_x = 0, pos_y = 0;
if (scale_w < scale_h)
pos_y = (wh - g_img.height * scale) / 2;
else if (scale_w > scale_h)
pos_x = (ww - g_img.Width * scale) / 2;
new_width = g_img.Width * scale;
new_height = g_img.Height * scale
} else {
pos_x = 0;
pos_y = 0;
new_width = ww;
new_height = wh;
}
        op+=40;
        if(op >=255) {op = 255; window.KillTimer(g_timer);}
gr.DrawImage(g_img, pos_x, pos_y, new_width, new_height, 0, 0, g_img.Width, g_img.Height,0,op);
}
    if(dui == 1) gr.DrawRect(0,0, window.Width, window.Height, 1.0, RGB(160,160,160));
}

function on_item_focus_change() {
    if(refresh == 0) return;
    if(fb.IsPlaying) refresh = 0;
    op = 0;
    g_timer = window.CreateTimerInterval(10);
g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
is_embedded = "No";
if(g_metadb) {
type = window.GetProperty("id");
g_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, type);
if(g_img) {
is_embedded = "Yes";
} else {
g_img = utils.GetAlbumArtV2(g_metadb, type);
}
window.Repaint();
}
}

function on_playback_new_track() {
    refresh = 1;
on_item_focus_change();
}

function on_playback_stop() {
    refresh = 1;
}

function on_timer() {
    window.Repaint();
}

on_item_focus_change();

function on_mouse_move(x,y) {
if(!hover && g_img) {
g_tooltip.Text = "Embedded image: " + is_embedded + ". Actual size: " + g_img.Width + " x " + g_img.Height + ". Current size: " + Math.round(new_width) + " x " + Math.round(new_height) + ".";
g_tooltip.Activate();
hover = true;
}
}

function on_mouse_leave() {
g_tooltip.Deactivate();
hover = null;
}

function on_mouse_rbtn_up(x, y) {
var MF_SEPARATOR = 0x00000800;
var MF_STRING = 0x00000000;
var _menu = window.CreatePopupMenu();
var idx;
_menu.AppendMenuItem(MF_STRING, 1, "Refresh");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 2, "Correct Aspect Ratio");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_STRING, 4, "Front Cover");
_menu.AppendMenuItem(MF_STRING, 5, "Back Cover");
_menu.AppendMenuItem(MF_STRING, 6, "Disc");
_menu.AppendMenuItem(MF_STRING, 7, "Icon");
_menu.AppendMenuItem(MF_STRING, 8, "Artist");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
//_menu.AppendMenuItem(MF_STRING, 9, "Properties");
_menu.AppendMenuItem(MF_STRING, 10, "Configure...");
_menu.CheckMenuItem(2, window.GetProperty("aspect") );
_menu.CheckMenuRadioItem(4, 8, window.GetProperty("id")+4);
idx = _menu.TrackPopupMenu(x, y);
switch(idx) {
case 1:
            refresh = 1;
on_item_focus_change();
break;
case 2:
window.GetProperty("aspect") == 0 ? window.SetProperty("aspect", 1) : window.SetProperty("aspect", 0);
window.Repaint();
break;
case 4:
case 5:
case 6:
case 7:
case 8:
window.SetProperty("id", idx-4);
            refresh = 1;
on_item_focus_change();
break;
case 9:
window.ShowProperties();
break;
case 10:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}

This is not the same fading effect. You fade from white to the cover. Not what i have done or what i want.

@Hitchhiker427: will correct all that and post it here