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: JScript Panel script discussion/help (Read 301332 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Re: JScript Panel script discussion/help

Reply #200
can I recall PSS global variable values in the jscript panel?

Short answer: no
Longer answer: with lots of script hacking it may me possible. Basically you'd use $movepanel in PSS to resize the Jscript Panel based on the value of your global variable. JScript Panel can then detect its own height/width and adjust the command accordingly. I don't really have the time or inclination to spell it all out though.

I actually found out all I need to do is put a jscript panel as a child in each of the PSS panels, with a different quicksearch command for each of them. You really made my day! Now my set up is almost perfect, thanks again.
I'm late

Re: JScript Panel script discussion/help

Reply #201
You do realise all code in each panel will be executed at once? This is going to trigger your quicksearch command 3 times if the previous post about genre, artist and album was correct. If that was your intention, you can do it from a single panel/function.

Re: JScript Panel script discussion/help

Reply #202
You do realise all code in each panel will be executed at once? [...] If that was your intention, you can do it from a single panel/function.

I just did and nope, that was not my intention.
I'm late

Re: JScript Panel script discussion/help

Reply #203
Longer answer: with lots of script hacking it may me possible. Basically you'd use $movepanel in PSS to resize the Jscript Panel based on the value of your global variable. JScript Panel can then detect its own height/width and adjust the command accordingly. I don't really have the time or inclination to spell it all out though.

Let me see if I got this right: you mean I could write a conditional statement in the jscript panel which outputs a different quicksearch command according to the size of the panel?
I'm late

Re: JScript Panel script discussion/help

Reply #204
You can use window.Width and window.Height.

Code: [Select]
if (window.Height == 1)

or

Code: [Select]
switch (window.Height) {
case 1:
    //do something
   break;
case 2:
   //do something else
   break;
}

Re: JScript Panel script discussion/help

Reply #205
I managed!  :))  Excellent! Thanks a lot marc!
I'm late

Re: JScript Panel script discussion/help

Reply #206
@marc2003

When creating a volume object ...
Code: [Select]
var volume = new _.volume(0, 0, 0, 0);
... do the arguments take only numbers, i.e., are variables not allowed?

Re: JScript Panel script discussion/help

Reply #207
Of course you can use variables - so long as they are numbers.

Code: [Select]
var a = 200; //right
var b = "boo"; //wrong
var c = false; //wrong

 Just remember that x,y,w,h set there can only be fixed values. If you need position/size relative to the overall panel size then you update in the on_size callback like my sample already does.

Code: [Select]
function on_size() {
volume.w = window.Width;
volume.h = window.Height;
}

If you want it to float in the bottom right of the panel, you can do something like this...

Code: [Select]
function on_size() {
volume.x = window.Width - 200;
volume.y = window.Height - 20;
volume.w = 195;
volume.h = 15;
}





Re: JScript Panel script discussion/help

Reply #208
That makes sense, but why shouldn't this work...
Code: [Select]
var vx = (panel.w - panel.h) - 27;
var volume = new _.volume(vx, 70, 10, 110);
//vx result is 27 but should be 759
...while this does?
Code: [Select]
var vx = 759;
var volume = new _.volume(vx, 70, 10, 110);
I'm missing something.


Re: JScript Panel script discussion/help

Reply #210
But there is in 'track info + seekbar + buttons', which is the basis of this project. And this works:

Code: [Select]
function on_size() {
panel.size();
seekbar.x = 100;
seekbar.w = panel.w - panel.h - 300;
seekbar.y = (panel.h - 20) / 2;
    volume.x = panel.w - panel.h - 27; //no problem
buttons.update();
}

I edited my last reply; you may need to re-read it. Oh, and the result for vx is -27, not 27. Has on_size not run yet?


Re: JScript Panel script discussion/help

Reply #212
I read that a while ago; I should probably review it every so often. Like daily.  :-[ 

Thanks!

Re: JScript Panel script discussion/help

Reply #213
I'm trying your samples scripts and I have a little question.

The Allmusic review looks for the album review: can I change it to look for the title review?
And also for the Allmusic categories for the title?

Thanks.

Re: JScript Panel script discussion/help

Reply #214
I had a quick look at the underlying html of the song search results and it's quite different to the album results so it would require a good bit of work to get it done. I might have a look when I have more time.

Re: JScript Panel script discussion/help

Reply #215
Using the const statement results in an error:

Code: [Select]
JavaScript compilation error:
Syntax error
File: <main>
Line: 66, Col: 1
const ppd = "■";

The const keyword highlights in blue in the editor as expected. Using ASCII characters or numbers as opposed to the char shown produces the same result.

I understand the const statement is a relatively new addition to JavaScript. Is it not supported by the version used for JScript Panel?

Re: JScript Panel script discussion/help

Reply #216
It probably uses Windows Scripting Host, which probably won't be updated for ES2015, which is required for the const keyword.

So, expect whatever level of JavaScript capability that will work with the version of Internet Explorer or cscript/wscript on your machine.

Re: JScript Panel script discussion/help

Reply #217
We're basically stuck with windows script host which is IE8 levels of Javascript support.

However, you can use libraries like lodash or underscore which provides all sorts of neat ES5 features like filter, map, bind, foreach etc. I already bundle lodash with my sample scripts and full docs for it can be found here...

https://github.com/lodash/lodash/blob/3.10.1/doc/README.md

 

Re: JScript Panel script discussion/help

Reply #218
Because it's included by your script I'm using as a base, I looked at lodash.js in Notepad++ () and found it rather dense, to say the least. I didn't think to search for it online, although that results in information overload. So many thanks for the link; it's exactly what I needed.

I see from a Microsoft support page that their browsers (including Edge) support const. Too bad they haven't extended that to WSH. Being a long-time user of VBA (and thus const), I'm kind of peeved about that.

Re: JScript Panel script discussion/help

Reply #219
Microsofts JavaScript engine Chakra has its own set of APIs which are incompatible with WSH. There are good reasons for that. With the COM based API of WSH some modern JavaScript features are hard* or impossible to implement or just plain slow**. With the new engine you gain a lot at the cost of settling for a single language.

You can embed the new engine in your own applications (see JavaScript Runtime Hosting, JSRT). However this is not an option for foo_jscript_panel. The differences between JSRT and WSH are just too big, regarding both the APIs for embedding and the APIs available to scripts.

*: Try to store a function of the standard JS objects in a variable, e.g. Math.sin. Now do the same for a function implement by this component. It would be a hell of a lot of work to make this possible. With JSRT it is trivial.
**: An array in a WSH script is really a dictionary where the keys are the lexical representations of the indices. This means anArray[myIndex] is really the same as anArray[myIndex.toString()].

Re: JScript Panel script discussion/help

Reply #220
Well, I'll just have to take what I'm given and like it then! Fortunately, I do, even without const. Thanks for the explanation.

As to arrays, are they so slow that they should be avoided in JScript Panel scripts?

Re: JScript Panel script discussion/help

Reply #221
I looked at lodash.js in Notepad++ () and found it rather dense,

You missed a key part of the filename. It is lodash.min.js which indicates it has been minified!

I should add that you should only refer to the document I linked to. Do not look at the current lodash website/docs as WSH is no longer supported and there have been significant changes to their API which don't apply to the version we're using.

As for arrays, I use them extensively when using web services or scraping websites. No one has complained about the milliseconds it takes to parse being too slow.

Re: JScript Panel script discussion/help

Reply #222
Yes, you got me--I missed the .min. But now I know what that signifies, so I've proven I can learn from my mistakes. And I won't make the mistake of deviating from the linked doc because I'd just confuse myself all the more. Thanks again.

Re: JScript Panel script discussion/help

Reply #223
I'm trying to switch to this from Biography View plugin, someone can point me out to a script similar to Thumbs but for automatically download ALBUM art from last.fm?

Re: JScript Panel script discussion/help

Reply #224
I'm not aware of any. I've never bothered myself because the quality is pretty bad. Although the same can be said of some artist images, there is some decent stuff to be found.

IIRC, the image functionality of that other component still works so there's no reason not to continue using it.