Skip to main content
Topic: Spider Monkey Panel (foo_spider_monkey_panel) (Read 45738 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #75
I just noticed the stats show up twice in the properties tab. I still have JScript panel installed of course. It's not a problem, I just wonder why this happens:

Spoiler (click to show/hide)

Now, in the picture above you will also notice the custom database tags. I don't know how SMP statistics work, but if the values are pinned to primary tags or a combination of primary tags, like the official playback statistics component does, than this is potentially a custom database replacement. I've seen a previous request by @loz for custom tags, but I did not understand if they're planned to be implemented. Anyway I definitely second that request.
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #76
Eventually I ran into a problem. I use some text files to share layout settings between jscript panels and panel stack splitter. I have a script which deletes a specific file when triggered, using the FileSystemObject DeleteFile method. It's a very simple script and it always worked with JScript Panel, but since migrating to Spider Monkey Panel the delete action is denied because the file is in use by foobar2000. I cannot even delete the file manually.
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #77
For now though I just have a minor, issue / question / request. (An issquesest?) If one (me) did not want to see the SMP Playback Statistics in track properties, how could one (I) turn display of them off? Might it please be possible? (We looked for options)

The thing is with 'Selection Properties' (DUI) element, all stats are lumped / jumbled together under 'Other' along with official Playback Statistics (foo_playcount) component. So I guess that is limitation of the element. However the original PS 'Rating' (displayed as stars) is gone altogether, replaced by SMP 'Rating' (with no stars, because not using it) - not very complementary. I'd prefer to see my original ratings.
Not sure if I can do anything about it (apart from renaming the metatag, which I won't do :P).
@Peter : could you help us out, please? Is there a way to hide and/or reorder the priority of the metadata provided by components?

I just noticed the stats show up twice in the properties tab. I still have JScript panel installed of course. It's not a problem, I just wonder why this happens:
That is the intended behaviour: SMP and JSP use different (internal) tags to avoid potential compatibility issues.

I've seen a previous request by @loz for custom tags, but I did not understand if they're planned to be implemented. Anyway I definitely second that request.
This is something I'm planning to look into (that is the ability to add customs tags via SMP API), but it's rather low on my priority list.

Eventually I ran into a problem. I use some text files to share layout settings between jscript panels and panel stack splitter. I have a script which deletes a specific file when triggered, using the FileSystemObject DeleteFile method. It's a very simple script and it always worked with JScript Panel, but since migrating to Spider Monkey Panel the delete action is denied because the file is in use by foobar2000. I cannot even delete the file manually.
Could you provide the script (or it's relevant parts)?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #78
Eventually I ran into a problem. I use some text files to share layout settings between jscript panels and panel stack splitter. I have a script which deletes a specific file when triggered, using the FileSystemObject DeleteFile method. It's a very simple script and it always worked with JScript Panel, but since migrating to Spider Monkey Panel the delete action is denied because the file is in use by foobar2000. I cannot even delete the file manually.
Could you provide the script (or it's relevant parts)?

Sure, as I said it's a pretty simple one. The panel is resized via PSS (panel stack splitter) and this triggers either a delete or a create file action.
Code: [Select]
function on_size(){
    switch (window.Height){
        case 0:
        if (fso.FileExists(SettingsPath + "PlaylistVisible")) fso.DeleteFile(SettingsPath + "PlaylistVisible");
        RefreshPSS();
        break;
        case 1:
        if (!fso.FileExists(SettingsPath + "PlaylistVisible")) fso.CreateTextFile(SettingsPath + "PlaylistVisible");
        RefreshPSS();
        break;  
        case 2:
        if (fso.FileExists(SettingsPath + "PlaylistVisible")) fso.DeleteFile(SettingsPath + "PlaylistVisible");
        RefreshPSS();
        break;
    }

Here's also the relevant code from another script, included in the preprocessor:
Code: [Select]
var fso = new ActiveXObject("Scripting.FileSystemObject"); 
var SettingsPath = fb.ProfilePath + "settings\\";

function RefreshPSS() {
var Refresh_sys = window.GetProperty("Refresh_sys",true);
 if (Refresh_sys < true) {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
} else {
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
}
} else {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("Playback/Play or Pause");
fb.RunMainMenuCommand("Playback/Play or Pause");
} else {
fb.RunMainMenuCommand("Playback/Play");
fb.RunMainMenuCommand("Playback/Stop");
}
}
}

The script seems to work for a few times right after foobar2000 start up, but eventually something happens which blocks the file, and I can't figure out what it could even be.
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #79
I just noticed the stats show up twice in the properties tab. I still have JScript panel installed of course. It's not a problem, I just wonder why this happens:
That is the intended behaviour: SMP and JSP use different (internal) tags to avoid potential compatibility issues.

I see, I never noticed before that JScript panel had its own! I though it was reading Spider Monkey Panel statistics.  :))
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #80
The script seems to work for a few times right after foobar2000 start up, but eventually something happens which blocks the file, and I can't figure out what it could even be.

TLDR: Use the following code fso.CreateTextFile(path).Close(); or let file = fso.CreateTextFile(path); file.Close();

Full story: the problem is caused by your usage of fso.CreateTextFile: CreateTextFile returns a file object, which contains an open handle to the file, which will be closed only in two cases - when object is destroyed and when it's closed manually. The lifetime of JS objects is variable, i.e. objects might not be immediately destroyed when there are no references to them, so in your case: object is alive & not closed > handle remains open > file remains locked.

PS: Plz, don't over-quote =)

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #81
TLDR: Use the following code fso.CreateTextFile(path).Close(); or let file = fso.CreateTextFile(path); file.Close();

Full story: the problem is caused by your usage of fso.CreateTextFile: CreateTextFile returns a file object, which contains an open handle to the file, which will be closed only in two cases - when object is destroyed and when it's closed manually. The lifetime of JS objects is variable, i.e. objects might not be immediately destroyed when there are no references to them, so in your case: object is alive & not closed > handle remains open > file remains locked.

Thanks, that was it. So, the real question is: why did it work with JScript panel?
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #82
Thanks, that was it. So, the real question is: why did it work with JScript panel?
Because GC behaves differently in JScript and SMP (Microsoft's jscript is quite outdated in that way).

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #83
Hi,
after installing Spider Monkey Panel in perfect working fb2k v1.3.20 on W7 x64 - and not making any use of it, i only installed it - I can't write rating tags to foo_playcount's database anymore. Modifying already existing rating tags stored in the database isn't possible either. Writing rating tags direct to files is still working. After uninstalling Spider Monkey Panel everything is working as before and writing and modifying rating tags in files or in the database is possible again without any issue !

Seems Spider Monkey Panel and the official Playback Statistics (foo_playcount) can't work together without making trouble.

Any ideas or suggestion?


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #85
Hi TheQwertiest,
sorry for duplicate posting, but I'm not very experienced in posting + "forum behaviour". Till now reading alone helped me over the years to solve my problems with foobar.

"Replied on GitHub"
means you noticed my post and are aware of the problem, but not that you have answered to it, right ? Stupid question, I know, but after "closing Github post by accident" and reopening and not seeing an answer after that in Github I'm really unsecure about this. Or I'm making something wrong again?

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #86
I'm not sure if it's a system specific, user  :-[ , script or Spider Monkey Panel problem but:
- mouse-on and double click functions of "album art" sample stopped working. They used to work with SMP and work fine with JScript Panel.

- tested on clean portable install, Foobar 1.4.2, default components + Spider Monkey Panel 1.1.5, default path, Windows 7
- as far as I noticed script did not change

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #87
I'm not sure if it's a system specific, user  :-[ , script or Spider Monkey Panel problem but:
- mouse-on and double click functions of "album art" sample stopped working. They used to work with SMP and work fine with JScript Panel.

Thanks for the bug report! Will be fixed in the next version (kudos to marc2003).
In the mean time you can apply the fix manually - https://github.com/marc2k3/smp_2003/commit/c12b44f25fb5b810a7c92366e324191a2a0ce5bf


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #89
I was wondering if anyone else was having this problem with the SMP thumbs panel.  It works fine except when displaying the thumbs in a grid.  They display fine initially, but when clicking on a specific thumb to display it I get the following error.  Any ideas?

Error: Spider Monkey Panel v1.1.5 (Thumbs by marc2003)
_.drawOverlay is not a function

File: thumbs.js
Line: 100, Column: 5

Stack trace:
  _thumbs/this.paint@thumbs.js:100:5
  on_paint@<main>:58:2

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #90
I was wondering if anyone else was having this problem with the SMP thumbs panel.  It works fine except when displaying the thumbs in a grid.  They display fine initially, but when clicking on a specific thumb to display it I get the following error.  Any ideas?

Error: Spider Monkey Panel v1.1.5 (Thumbs by marc2003)
_.drawOverlay is not a function

File: thumbs.js
Line: 100, Column: 5

Stack trace:
  _thumbs/this.paint@thumbs.js:100:5
  on_paint@<main>:58:2
Yup, that's a bug =) Will be fixed in the next version (again kudos to marc2003).
In the mean time you can apply the fix manually - https://github.com/marc2k3/smp_2003/commit/a0e578ec06211b1d4b01f529962142bf50a75da5

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #91
Thank you both very much.  That fixed it.  Amazing what one little period can do, isn't it?  I was a COBOL programmer for over 35 years so I understand how much damage one little typo can do.  At least you don't have to deal with hard copies, punch cards and 4 hour compile times like I had to in the beginning.  Debugging was a total nightmare.


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #93
Hello!
Anybody knows if somebody already did a JS better than the default Album List DUI component?
The default Album List is "too slow" for me and many time starves.
I just need something providing a consolidated by folder structure view (as does Album List DUI) and some capability for searching the dBase by usual search patterns.
If I would be capable of programming in Java I would try myself, but I am not.
Thanks and regards, Andrea


Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #95
Hi Always.beta, many thanks!
Regards, Andrea

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #96
From what I gather, the strict mode defined in the panel does not apply to the scripts processed with the include statement. Is this an intended behaviour?
BTW, is the strict mode kind of mandatory with SMP or is it just a scrpting suggestion by the developers? or is it merely the common practice with the latest ECMA versions?
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #97
 I have been experiencing an error on start up in Foobar related to the JS Smooth Browser sample script  in Spider Monkey Panel v1.1.5. See below:

Error: Spider Monkey Panel v1.1.5 (JS Smooth Browser by Br3tt aka Falstaff)
Resize failed:
Failed to create GdiPlus object (0x0: No error

File: jssb.js
Line: 3500, Column: 24

Stack trace:
  get_images@jssb.js:3500:24
  oBrowser/this.update@jssb.js:1526:3
  oBrowser/this.setSize@jssb.js:1548:3
  on_size@jssb.js:3120:3



If I reload the script it work's fine. The error only occurs at startup.

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #98
So far I managed to upgrade all my scripts, but I still have a very old one by marc2003 that I can't get working on Spider Monkey Panel. The script is "Last.fm Album Art Downloader" with some little modifications I made over time and it still works perfectly on JScript Panel 2.1.4.

This is the script that works in JScript Panel:
Code: [Select]
// ==PREPROCESSOR==
// @name "Last.fm Album Art Downloader"
// @author "marc2003"
// @import "%fb2k_component_path%samples\complete\js\lodash.min.js"
// @import "%fb2k_component_path%samples\complete\js\helpers.js"
// @import "%fb2k_component_path%samples\complete\js\panel.js"
// ==/PREPROCESSOR==


var SettingsPath = fb.ProfilePath + "settings\\";
var library_tracks_only = false;
var folder_tf = fb.TitleFormat("$puts(folder,$trim($replace($lower($directory(%path%)),disc,,cd,)))$replace($directory_path(%path%),$ifequal($strstr($get(folder),$num($get(folder),$len($get(folder)))),1,\\%directoryname%,),)\\");
var filename_tf = fb.TitleFormat("front.jpg");

var panel = new _.panel("Last.fm Album Art Downloader", ["metadb", "custom_background"]);
var x = new ActiveXObject("Microsoft.XMLHTTP");
var ini = SettingsPath + "album-art.ini";
_.createFolder(SettingsPath);

panel.item_focus_change();

function on_metadb_changed() {
var np = fb.GetNowPlaying();
if (panel.metadb && np && np.Compare(panel.metadb) && np.RawPath.indexOf("file://") == 0 && (!library_tracks_only || fb.IsMetadbInMediaLibrary(np))) {
var ar = panel.tf("%album artist%");
var al = panel.tf("%album%");
var f = folder_tf.EvalWithMetadb(panel.metadb) + _.fbSanitise(filename_tf.EvalWithMetadb(panel.metadb));
var tmp = _.q(_.fbSanitise(ar + al));
var n = _.round(_.now() / 1000);
var t = utils.ReadINI(ini, "Timestamps", tmp, 0);

switch (true) {
case !_.tagged(ar):
case !_.tagged(al):
case _.isFile(f):
case n - t < ONE_DAY:
break;
default:
utils.WriteINI(ini, "Timestamps", tmp, n);
x.open("GET", "https://www.last.fm/music/" + encodeURIComponent(ar) + "/" + encodeURIComponent(al) + "/+images", true);
x.setRequestHeader("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT");
x.send();
x.onreadystatechange = function () {
if (x.readyState == 4) {
if (x.status == 200) {
var o = _.first(_.filter(_.getElementsByTagName(x.responsetext, "img"), {"className" : "image-list-image"}));
if (o) {
var u = o.src.replace("avatar170s", "ar0");
_.runCmd("cscript //nologo " + _.q(fb.ProfilePath + "scripts\\JSP\\download.vbs") + " " + _.q(u) + " " + _.q(f), false);
window.SetTimeout(function () {
panel.item_focus_change();
}, 3000);
}
} else {
console.log("HTTP error: " + x.status);
}
}
}           
break;
}
}
RefreshPSS();
}

function RefreshPSS() {
var Refresh_sys = window.GetProperty("Refresh_sys",true);
 if (Refresh_sys < true) {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
} else {
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
}
} else {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("Playback/Play or Pause");
fb.RunMainMenuCommand("Playback/Play or Pause");
} else {
fb.RunMainMenuCommand("Playback/Play");
fb.RunMainMenuCommand("Playback/Stop");
}
}

}

...and this is my attempt to upgrade it for Spider Monkey Panel:
Code: [Select]
'use strict';

window.DefinePanel('Last.fm Album Art Downloader', {author:'marc2003'});
include(fb.ComponentPath + 'samples\\complete\\js\\lodash.min.js');
include(fb.ComponentPath + 'samples\\complete\\js\\helpers.js')
include(fb.ComponentPath + 'samples\\complete\\js\\panel.js');


var SettingsPath = fb.ProfilePath + "settings\\";
var library_tracks_only = false;
var folder_tf = fb.TitleFormat("$puts(folder,$trim($replace($lower($directory(%path%)),disc,,cd,)))$replace($directory_path(%path%),$ifequal($strstr($get(folder),$num($get(folder),$len($get(folder)))),1,\\%directoryname%,),)\\");
var filename_tf = fb.TitleFormat("front.jpg");

let panel = new _panel("Last.fm Album Art Downloader", ["metadb", "custom_background"]);
var x = new ActiveXObject("Microsoft.XMLHTTP");
var ini = SettingsPath + "album-art.ini";
_createFolder(SettingsPath);

panel.item_focus_change();

function on_metadb_changed() {
var np = fb.GetNowPlaying();
if (panel.metadb && np && np.Compare(panel.metadb) && np.RawPath.indexOf("file://") == 0 && (!library_tracks_only || fb.IsMetadbInMediaLibrary(np))) {
var ar = panel.tf("%album artist%");
var al = panel.tf("%album%");
var f = folder_tf.EvalWithMetadb(panel.metadb) + _fbSanitise(filename_tf.EvalWithMetadb(panel.metadb));
var tmp = _q(_fbSanitise(ar + al));
var n = _.round(_.now() / 1000);
var t = utils.ReadINI(ini, "Timestamps", tmp, 0);

switch (true) {
case !_tagged(ar):
case !_tagged(al):
case _isFile(f):
case n - t < ONE_DAY:
break;
default:
utils.WriteINI(ini, "Timestamps", tmp, n);
x.open("GET", "https://www.last.fm/music/" + encodeURIComponent(ar) + "/" + encodeURIComponent(al) + "/+images", true);
x.setRequestHeader("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT");
x.send();
x.onreadystatechange = function () {
if (x.readyState == 4) {
if (x.status == 200) {
var o = _first(_filter(_getElementsByTagName(x.responsetext, "img"), {"className" : "image-list-image"}));
if (o) {
var u = o.src.replace("avatar170s", "ar0");
_runCmd("cscript //nologo " + _q(fb.ProfilePath + "scripts\\SMP\\download.vbs") + " " + _q(u) + " " + _q(f), false);
window.SetTimeout(function () {
panel.item_focus_change();
}, 3000);
}
} else {
console.log("HTTP error: " + x.status);
}
}
}
break;
}
}
RefreshPSS();
}

function RefreshPSS() {
var Refresh_sys = window.GetProperty("Refresh_sys",true);
 if (Refresh_sys < true) {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
} else {
fb.RunMainMenuCommand("View/Show status bar");
fb.RunMainMenuCommand("View/Show status bar");
}
} else {
if (fb.IsPlaying || fb.IsPaused) { 
fb.RunMainMenuCommand("Playback/Play or Pause");
fb.RunMainMenuCommand("Playback/Play or Pause");
} else {
fb.RunMainMenuCommand("Playback/Play");
fb.RunMainMenuCommand("Playback/Stop");
}
}

}

Unfortunately it doesn't crash, therefore I have no idea where the problem is, but it does not download the album cover (doubled checked with the JScript panel version).
Any insight will be much appreciated.
I'm late

Re: Spider Monkey Panel (foo_spider_monkey_panel)

Reply #99
@davideleo

Replace line 45 with

Code: [Select]
var o = _.first(_.filter(_getElementsByTagName(x.responseText, "img"), {"className" : "image-list-image"}));

_.first and _.filter are from lodash.js
_getElementsByTagName is from helpers.js

x.responseText is valid (not x.responsetext)




 
SimplePortal 1.0.0 RC1 © 2008-2019