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 811260 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

WSH Panel Mod

Reply #675
you didn't remove this bit. did you?

Code: [Select]
xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            //on success do something
        } else {
            fb.trace(xmlhttp.responsetext);
        }
    }
}


you have to wait for it to complete and this can take a few seconds if the remote server is being slow.

No no i didnt. This code works perfectly. THe only thing is taht i didnt see the error. Was hard to debug. And i just thought it might be good to report.
But now everyhing works flwalessly

WSH Panel Mod

Reply #676
i have a problem with objects in jscript.
I have an object buttons.
That object has a funtcion isUnderXY.

ANd i want to do a if(!buttons.isUnderXY(x,y))
but i get an error everytime.
Any help?

WSH Panel Mod

Reply #677
Thanks T.P. for all your work! This component is powerfull!

I've a newbie question : We can just use functions which are in the interface.api and the jscript.api or all jscript function can be use?
I can't see all i can do with this component.

Sorry for my english and my silly question and/or if the answer is already post.


WSH Panel Mod

Reply #678
@TP Wang:
i have a problem with fb.titleformat. And i am not sure if the problem comes from wsh or foobar.

I have that string
Code: [Select]
"C:/Program Files/AlbumArtDownloader/AlbumArt.exe" /ar "%artist%" /mn 400 /sources "LastFM Artist" /mx 1000 /path "D:/Martin/My Documents/My Music/LastFmData/World's End Girlfriend.jpg"

That i want to titleformat
but as a result i get that
Code: [Select]
"C:/Program Files/AlbumArtDownloader/AlbumArt.exe" /ar "World's End Girlfriend" /mn 400 /sources "LastFM Artist" /mx 1000 /path "D:/Martin/My Documents/My Music/LastFmData/World

As you can see it cuts the path arguments when encountering a '.
Any idea where it comes from?
I looked at the file operation conventions and they dont do anything when finding a '

WSH Panel Mod

Reply #679
Code: [Select]
cmd /k "C:/Program..............


should show you exactly where it's going wrong. you probably need to escape the quotes.

WSH Panel Mod

Reply #680
Code: [Select]
cmd /k "C:/Program..............


should show you exactly where it's going wrong. you probably need to escape the quotes.

the problem is not with the command itself but with fb.titleformat. i use fb.trace to keep track of my string.
As you can see fb.titleformat worked well with the ' at the beginning of the string where there is jsut the name of the artist. But it didnt go well with the last '. It just truncated my string!

WSH Panel Mod

Reply #681
edit2:

Code: [Select]
artist = fb.titleformat("%artist%").EvalWithMetadb(g_metadb);
WshShell.run("\"C:/Program Files/AlbumArtDownloader/AlbumArt.exe\" /ar \"" + artist + "\" /mn 400 /sources \"LastFM Artist\" /mx 1000 /path \"D:/Martin/My Documents/My Music/LastFmData/" + artist + ".jpg");


probably full of typos but you get the idea.

WSH Panel Mod

Reply #682
I installed this plugin and used the MainMenuManager All-In-One sample so I can access the entire foobar menu just by clicking the panel.  My question is, how do I make the wsh panel look better by making it display "Menu" or an icon button?

WSH Panel Mod

Reply #683
@TP Wang:
i was wondering what exactly did titleformat did internally? does it call a foobar api function that titleformat?
I ask the question because i am facing quite a problem.
I want to use titleformat on a string like that "$replace(%_path%,%_filename_ext%,)%artist%.jpg"
to create that file.
But to create that file i need to apply the rules in that page
http://wiki.hydrogenaudio.org/index.php?ti...File_operations
which are replace of unrecognized characters .
And i dont see how to do it.
So i was wondering if it was possible in wsh to write a function that titleformat while applying those replacing rules that are used for the renaming function of foobar.

Or maybe you see another solution to that. Right now i dont.

Thanks again for that plugin, i use it to its full extent

WSH Panel Mod

Reply #684
Quote
$replace(%_path%,%_filename_ext%,)%artist%.jpg


if you're placing the file inside the music folder, why can't you name it artist.jpg? you can't access it without the path so the filename becomes irrelevant.

WSH Panel Mod

Reply #685
Quote
$replace(%_path%,%_filename_ext%,)%artist%.jpg


if you're placing the file inside the music folder, why can't you name it artist.jpg? you can't access it without the path so the filename becomes irrelevant.

It was an example marc2003    I actually dont use that type of scheme at all! But when i develop something i want it to work for every single configuration. So i am thinking about as much as i can.


WSH Panel Mod

Reply #687
ok... for the 3rd (and last time). 

just write your own replace function then. it's not like windows file naming conventions are going to change any time soon, is it?



ok and i already said that i already did that  but i would like to be able to use other foobar scripting functions, and i dont want to rewrite them all

WSH Panel Mod

Reply #688
you do realise you're completely wasting your time. the filename scheme using by file operations is completely Peter's own thinking. there's no rhyme or reason to it other than his personal choice. no other components use this. you can't load files without using the same title formatting string that you'd use to save files. so what's the point? what are you trying to do?

WSH Panel Mod

Reply #689
you do realise you're completely wasting your time. the filename scheme using by file operations is completely Peter's own thinking. there's no rhyme or reason to it other than his personal choice. no other components use this. you can't load files without using the same title formatting string that you'd use to save files. so what's the point? what are you trying to do?

Yes and what convention do you think the foobar 1.0 artreader uses?
If i use "D:\Martin\My Documents\My Music\LastFmData\%artist%.jpg" in the artreader for an artist like "*shels"
the the artreader will look for xshels.jpg. So if use another convention to save that image when i download it, the artreader will just not see it!!
That s kind of the all point of what i am doing

WSH Panel Mod

Reply #690
so tell me again why using $replace on illegal filename characters or $crc32(%artist%) won't work? you'd use exactly the same title formatting in the artreader options.

WSH Panel Mod

Reply #691
so tell me again why using $replace on illegal filename characters or $crc32(%artist%) won't work? you'd use exactly the same title formatting in the artreader options.

Ok so $replace doesnt replace illegals characters. If you want it to, you need to write the replace for all illegal characters.
As i said before i want it to be easy! Not for me but for the users who will use my coming release.
Take that string for example "?lastfmdatapath?%artist%.jpg"(dont look at ?? that s a feature of my config).
I want to use that string with fb.titleformat. And i dont want the user to have to write "?lastfmdatapath?$replace(%artist%, ...allillegal ....).jpg" as he doesnt know the illegal characters.
Now i could (and i do if necessary) dom in my wsh codem a replace of %artist% by a "cleaned" version of the artist value. But then there is 2 problems:
- you have to deal with all foobar variables(already solved)
- You cant use $replace and fb.titleformat afterwards. Why? let s say you use that string "$replace(%_path%,%_filename_ext%,)%artist%.jpg" . First you replace %artist%, %_path% and  %_filename_ext% by their value. let s say you get that "$replace(c:\toto [2009]\track.mp3,track.mp3,)xshels.jpg". Good you have solved the illegal characters problem! But then when you want to apply the $replace thing (or anything else like $ifequal or whatever) you must use fb.titleformat. But then everything fails. For example in the string i gave the "[2009]" will just disappear!!!! And there are other problems like that.

If i want to use ALL available functions in the foobar title formatting syntax and still deal with illegal characters, it s just not possible right now!

WSH Panel Mod

Reply #692
what? 

forget the technicalities. just try and explain your "feature" to the average end user.

WSH Panel Mod

Reply #693
@carmenm
I don't know what you want to do exactly but if you really want to use a titleformatting string with fb.TitleFormat to replace all illegal characters like foobar2000 file operations does, use this:
fb.TitleFormat("$directory_path(%path%)\\$replace(%artist%,/,-,\\,-,|,-,:,-,*,x,\",'''',?,_,<,_,>,_)");
That should work.

WSH Panel Mod

Reply #694
@carmenm
I don't know what you want to do exactly but if you really want to use a titleformatting string with fb.TitleFormat to replace all illegal characters like foobar2000 file operations does, use this:
fb.TitleFormat("$directory_path(%path%)\\$replace(%artist%,/,-,\\,-,|,-,:,-,*,x,\",'''',?,_,<,_,>,_)");
That should work.

That s right tedgo, that is the exact replace. But this is not really practical, and i think it would be a good to have a function which does that. But yeah for my personal need that s what i use

WSH Panel Mod

Reply #695
Quote
But this is not really practical, and i think it would be a good to have a function which does that.


Code: [Select]
function cleanString (string) {
    return fb.TitleFormat("$replace(" + string + ",/,-,\\,-,|,-,:,-,*,x,\",'''',?,_,<,_,>,_)");
}


... or make your own ...
<insert signature here>

WSH Panel Mod

Reply #696
Or maybe this:
Code: [Select]
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
};

function pathClean(path) {
var arr = path.trim().replace(/^\s+|\s+$/m, '').split(/[\\\/]/);
var start = 0;

// Drive Letter?
if (arr[0].match(/\w:/)) {
start = 1;
}

for (var i = start; i < arr.length; ++i) {
var temp = arr[i].trim().replace(/[\/\\|:]/g, '-');
temp = temp.replace(/\*/g, 'x');
temp = temp.replace(/"/g, "''");
temp = temp.replace(/[?<>]/g, '_');
arr[i] = temp;
    }

return arr.join('\\');
}

WSH Panel Mod

Reply #697
But this is not really practical


which is why i've been saying use $crc32 all along.

Code: [Select]
var filename = fb.TitleFormat("$directory_path(%path%)\\$crc32(%artist%).jpg").EvalWithMetadb(g_metadb);


artreader preferences:

Code: [Select]
$crc32(%artist%).jpg


now please explain why this isn't good enough. i would have thought the filename is irrelevant. all that matters is that it's valid and you can use foobar to display it.

WSH Panel Mod

Reply #698
Or maybe this:
Code: [Select]
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
};

function pathClean(path) {
var arr = path.trim().replace(/^\s+|\s+$/m, '').split(/[\\\/]/);
var start = 0;

// Drive Letter?
if (arr[0].match(/\w:/)) {
start = 1;
}

for (var i = start; i < arr.length; ++i) {
var temp = arr[i].trim().replace(/[\/\\|:]/g, '-');
temp = temp.replace(/\*/g, 'x');
temp = temp.replace(/"/g, "''");
temp = temp.replace(/[?<>]/g, '_');
arr[i] = temp;
    }

return arr.join('\\');
}
Thanks a lot TPWang, That s what i was missing. I was having a problem when using it on full blown path(as you must have figured out) And your function is what i need.
So thanks a lot!

EDIT: still doesnt work in one case. Some artist in lastfm are like that "test \ test2". That will be a problem as it will be split as directory!
That s the reason why here i as making the illegal character replace first. But then the $replace would break a lot of other cases ...
Will have to find a solution. THanks anyway that s a good start

@marc2003: You MUST understand that i dont want user to change their config to suit my config. I want MY panels to suit their config!

@TPWang: i mentioned in PSS forum a redraw bug. SardonicWrath gave a very plausible explanation. Could you just confirm it please.
Then i could go and try to find another solution.

THanks a lot

WSH Panel Mod

Reply #699
@carmenm:
Not a bug, because it's pseudo transparent. Avoid overlapping each other.