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 script discussion/help (Read 1378824 times) previous topic - next topic
0 Members and 4 Guests are viewing this topic.

WSH Panel Mod script discussion/help

Reply #4175
@Spanky Monkey, my button scripts only support normal and hover states which is ok for your SAC button but you won't be able to add buttons with down states unless you hack it.

extract this zip into your foobar profile folder.

https://dl.dropboxusercontent.com/u/22801321/wsh2015.zip <<there are a few other basic scripts inside for album art, seekbar, volume, playback buttons and rating.

then place this script inside a panel. modify the folder path if you need to.

Code: [Select]
// ==PREPROCESSOR==
// @name "SAC Button"
// @author "marc2003"
// @import "%fb2k_profile_path%wsh_marc2003\js\lodash.min.js"
// @import "%fb2k_profile_path%wsh_marc2003\js\helpers.js"
// @import "%fb2k_profile_path%wsh_marc2003\js\panel.js"
// ==/PREPROCESSOR==

folders.images = fb.ProfilePath + "buttons_gfx\\";

var panel = new _.panel("SAC Button", ["custom_background"]);
var buttons = new _.buttons();

buttons.update = function () {
if (fb.StopAfterCurrent)
//if the hover image is the same as the normal, you can just leave it out
this.buttons.sac = new _.button(0, 0, 36, 36, {normal : "SACon_n_36.png"}, function () { fb.StopAfterCurrent = !fb.StopAfterCurrent; }, "Disable Stop After Current");
else
this.buttons.sac = new _.button(0, 0, 36, 36, {normal : "SACoff_n_36.png", hover : "SACoff_h_36.png"}, function () { fb.StopAfterCurrent = !fb.StopAfterCurrent; }, "Enable Stop After Current");
window.RepaintRect(this.buttons.sac.x, this.buttons.sac.y, this.buttons.sac.w, this.buttons.sac.h);
}

function on_playlist_stop_after_current_changed() {
buttons.update();
}

function on_size() {
panel.size();
buttons.update();
}

function on_paint(gr) {
panel.paint(gr);
buttons.paint(gr);
}

function on_mouse_move(x, y) {
buttons.move(x, y);
}

function on_mouse_leave() {
buttons.leave();
}

function on_mouse_lbtn_up(x, y) {
buttons.lbtn_up(x, y);
}

function on_mouse_rbtn_up(x, y) {
return panel.rbtn_up(x, y);
}

@incifinci, use [codebox ] tags instead of [code ]

as for your script error, just delete this as it's not even used.

Code: [Select]
var info = g_focus_metadb.GetFileInfo();

and you might as well use foo_textdisplay (DUI) for displaying file tags or item details (CUI - it's built in)

@samithaj,

looking at the code on line 1166 might be a start. you should know better by now....

does my unmodified script also crash? if so, tough... i can't do anything to troubleshoot as i don't have my own computer. if it's your mods, then you fix it...

you can always put the code inside try/catch like this

Code: [Select]
try {
//some dodgy code
} catch(e) {
//something went wrong but at least the script didn't crash
}

WSH Panel Mod script discussion/help

Reply #4176
@Spanky Monkey, my button scripts only support normal and hover states which is ok for your SAC button but you won't be able to add buttons with down states unless you hack it.

extract this zip into your foobar profile folder.

https://dl.dropboxusercontent.com/u/22801321/wsh2015.zip <<there are a few other basic scripts inside for album art, seekbar, volume, playback buttons and rating.

then place this script inside a panel. modify the folder path if you need to.


Thanks ever so much for looking into this.  I apologise for the dropbox link.  Dropbox used be more solid, but lately it's been temperamental, and the ad doesn't instil much confidence for the person clicking the link.  I used that hosting because it allows for 30 days until expiry, I should take a look for something better that doesn't require singing up.

That script works fine as it's own panel.  I initially had an error come up regarding line 36 in the helper.js (all the activeX stuff), which I just commented out to make it behave.
I can see that it would be nightmarish to try and integrate the two scripts together into just one panel (one can't just treat it like German nouns and ram them together to make a new word "Hand" + "Schuh" = "Handschuh" otherwise known as a glove to English speakers).

Actually, because of the inability to get the 'down' state to work, it's very similar, albeit a better way to do it, than when I mashed a little of Delphi's script in and just used the hover graphic for the button.  So the graphic for the on/off state is being made in window.repaint() - which is probably incorrect to do, whilst the hover outer border is being drawn by buttons.js script.  However, your script gives a nice tool tip as well, which couldn't be done the way I was ham-fistedly going at it.
This'll do just fine and I can modify the script to facilitate indicators of other things (playback mode etc).

Thanks again Marc, that's helpful stuff and I can take a good look at the other scripts knocking around in there too.
All the best.

WSH Panel Mod script discussion/help

Reply #4177
looking at the code on line 1166 might be a start. you should know better by now....


Actually i looked at 1166 line(I didn't make changes to common8.js file)
It's on
panel.rbtn_up

Code: [Select]
this.is_stream = function() {
        //support m-TAGS (foo_tags.dll)
        var path = tf("$if2(%__@%,%path%)", this.metadb);   // 1166 line
        switch(true) {
            case path.indexOf("http") == 0:
            case path.indexOf("mms") == 0:
                return true;
            default:
                return false;
        }
    }


I don't think p.rbtn_up even get called(In my knowledge, since this is part of a huge code i don't understand ). I got this error by just changing the tracks

But your unmodified script doesn't crash.

I guess i have have to clean up my own mess
I'll try with putting try catch blocks
thanks marc!

BTW

your new scripts are working well ,Thank you for this marc!!!
except for the ones in extras folder, i think couple of js files are missing
Nice work including lodash.min.js , I guess this improves efficiency

edit: putting try catch blocks  to all p.rbtn_up stopped the crashing

WSH Panel Mod script discussion/help

Reply #4178
That script works fine as it's own panel.  I initially had an error come up regarding line 36 in the helper.js (all the activeX stuff), which I just commented out to make it behave.


i should have mentioned you need to disable safe mode (file>preferences>tools>wsh panel mod)

edit: readme inside zip file has now been updated.

WSH Panel Mod script discussion/help

Reply #4179
Now, I'm using WSH Panel Mod to toggle one of my panels.
When the toggle is 'on', the panel width=349
and
when the toggle is 'off'', the panel width =1.

Code: [Select]
var COLOR_BTNFACE = 15;
var toggle = window.GetProperty("toggle", false);
var ww = 0, wh = 0;
var COLOR_BTNFACE = 15;
var g_syscolor = 0;

function get_colors() {
    g_syscolor = utils.GetSysColor(COLOR_BTNFACE);
}
get_colors();

// START
function on_size() {
    ww = window.Width;
    wh = window.Height;
    if(toggle) {
        window.MinWidth = 349;
        window.MaxWidth = 349;
    } else {
        window.MinWidth = 1;
        window.MaxWidth = 1;
    };
    window.MinHeight = 4;
    window.MaxHeight = 4;
}

function on_paint(gr) {
    gr.FillSolidRect(0, 0, ww, wh, g_syscolor);
}

function on_mouse_lbtn_up(x, y) {
    toggle = !toggle;
    window.SetProperty("toggle", toggle);
    if(toggle) {
        window.MinWidth = 349;
        window.MaxWidth = 349;
    } else {
        window.MinWidth = 1;
        window.MaxWidth = 1;
    };
}

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

function on_notify_data(name, info) {
    switch(name) {
        case "center_pane":
            toggle = !toggle;
            window.SetProperty("toggle", toggle);
            if(toggle) {
                window.MinWidth = 349;
                window.MaxWidth = 349;
            } else {
                window.MinWidth = 1;
                window.MaxWidth = 1;
            };
            break;
    }
}

function on_mouse_rbtn_up(x, y) {
    return true;
}


From this code, I can't reduce the panel size to "0".
It looks like that "window.MinWidth = 0" doesn't work.
Is there any method to make the panel disappear completely when the toggle is 'off"?

WSH Panel Mod script discussion/help

Reply #4180
Quote
It looks like that "window.MinWidth = 0" doesn't work.


yup, just tried that myself. there's nothing you can do about that. if using columns UI, you can show/hide panels with panel stack splitter.

WSH Panel Mod script discussion/help

Reply #4181
Hello, marc2003. I've just tried to send you a private message, but it seems you disabled them.
So, I've started customizing my foobar2k and it seems that most of the WSH scripts were made by you. Unfortunately, all the links are already dead. I would appreciate it, if you could share your scripts. Especially Playcount Sync and Bio/Art viewer.

WSH Panel Mod script discussion/help

Reply #4182
sorry but i'm no longer sharing any scripts that access online services. there might be some old versions lurking around as part of people's themes on deviantart.

WSH Panel Mod script discussion/help

Reply #4183
i'm know i'm going to regret this (  ) but i've put most of my scripts back online here: https://github.com/19379/wsh_marc2003

pay special attention to the readme, especially this last part...

Quote
I'm not taking feature requests and I'm not restoring any scripts or features missing from previous packages. Genuine bugs can be reported here:

https://github.com/19379/wsh_marc2003/issues


most notably, playcount sync and thumbs are missing because they were the biggest headaches... and people who already have working scripts don't really need this. it's more for people who missed out before.

edit: i forgot to include a required font inside the zip so it has been updated.

WSH Panel Mod script discussion/help

Reply #4184
Quote
I'm not taking feature requests and I'm not restoring any scripts or features missing from previous packages.


Wisdom 

WSH Panel Mod script discussion/help

Reply #4185
^how is your JSbrowser coming along? i did see your preview on DA but it seems you've been on holiday or something?


WSH Panel Mod script discussion/help

Reply #4186
Yay! Thank you so much!

Also I've managed to get Playcount script from one of the fb2k themes. I've changed the API key and the secret and it works just fine. Autolove feature is great.
But if you don't mind could you help me with one little thing? Is it possible to unlove a track when I change its rating from 5 to 1-4? Pretty please. And I will never ask you about playcount sync again. :3
P.S. I have common8.js version.

WSH Panel Mod script discussion/help

Reply #4187
Ok, I added additional IF statements in two places:

Code: [Select]
if (this.time_elapsed == 3 && this.auto_love && tfe(this.auto_love_tf) == 0 && this.old_userloved == 1) {
            p.console("Automatically unloving this track....");
            this.love_track();
}

and
Code: [Select]
if (this.auto_love && tfe(this.auto_love_tf) == 0 && this.old_userloved == 1 && this.auto_love_count == 1) {
            this.auto_love_count = 0;
            p.console("Automatically unloving this track....");
            this.love_track();
}

So, the tracks are loved/unloved based on rating and console doesn't show any errors. I've also recreated customdb_sqlite.db to check if the records are deleted when I unlove the tracks - everything is fine. Now I'm happy. :)
But please, let me know if there are any errors.

WSH Panel Mod script discussion/help

Reply #4188
i don't think the 2nd snippet will run because you're checking that this.auto_love_count == 1 but its value is 0 when a new track begins. i think i put it in to prevent multiple requests by people messing with their ratings but now you're using your own last.fm API KEY, you can just remove it.

Code: [Select]
if (this.auto_love && tfe(this.auto_love_tf) == 0 && this.old_userloved == 1) {
            p.console("Automatically unloving this track....");
            this.love_track();
}

WSH Panel Mod script discussion/help

Reply #4189
Thank you! Yes, it seems without this.auto_love_count the code runs 2 times in a row. I mean with this.auto_love_count console shows this on love/unlove a song:
Code: [Select]
Last.fm Playcount Sync: Automatically loving this track.... 
Last.fm Playcount Sync: Attempting to love "Naval" by "Yann Tiersen"
Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: Track loved successfully.
Last.fm Playcount Sync: Automatically unloving this track....
Last.fm Playcount Sync: Attempting to unlove "Naval" by "Yann Tiersen"
Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: Track unloved successfully.
[/size]
But with your code (without this.auto_love_count) it shows this:
Code: [Select]
Last.fm Playcount Sync: Automatically loving this track.... 
Last.fm Playcount Sync: Attempting to love "Naval" by "Yann Tiersen"
Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: Track loved successfully.
Last.fm Playcount Sync: Automatically loving this track....
Last.fm Playcount Sync: Attempting to love "Naval" by "Yann Tiersen"
Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: Track loved successfully.
Last.fm Playcount Sync: Automatically unloving this track....
Last.fm Playcount Sync: Attempting to unlove "Naval" by "Yann Tiersen"
Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: Track unloved successfully.
Last.fm Playcount Sync: Automatically unloving this track....
Last.fm Playcount Sync: Attempting to unlove "Naval" by "Yann Tiersen"
Last.fm Playcount Sync: Contacting Last.fm....
Last.fm Playcount Sync: Track unloved successfully.
[/size]
Although I don't quite understand why we need it. ¯\_(ツ)_/¯

WSH Panel Mod script discussion/help

Reply #4190
i guess that's the real reason i kept track of the number of attempts. it'll need restoring...

Code: [Select]
    this.playback_edited = function() {
        if (!this.auto_love || this.auto_love_count == 1)
            return;
        this.auto_love_count = 1;
        if (tfe(this.auto_love_tf) == 1 && this.old_userloved == 0) {
            p.console("Automatically loving this track....");
            this.love_track();
        } else if (tfe(this.auto_love_tf) == 0 && this.old_userloved == 1) {
            p.console("Automatically unloving this track....");
            this.love_track();
        }
    }


i didn't even test what i posted previously because i don't have this feature in my own scripts.

WSH Panel Mod script discussion/help

Reply #4191
Auto unloving doesn't work with this code. I think you've also made other changes in common8.js. But whatever, I'll just stick with 2 snippets I've posted above, because everything works fine with them.

Thank you for your awesome scripts!

WSH Panel Mod script discussion/help

Reply #4192
it should have worked but... whatever. the whole point of that last change was to prevent it running more than once to prevent the double server requests. this also means you can't rate something to 5 (and have the love action trigger) and then unrate it immediately expecting the unlove action to work because it won't. that shouldn't be an issue under normal usage but might not be desirable when testing.

WSH Panel Mod script discussion/help

Reply #4193
i've noticed that last.fm are edging closer to making their beta site go live which will break my last.fm bio script. if they were to flip the switch right now and my script checked a file that was more than a day old, the good data would be wiped which isn't too clever. this version disables checking for updates when existing data already exists.

https://github.com/19379/wsh_marc2003/releases

just extracting the wsh_marc2003 folder while foobar is closed should be good enough.


WSH Panel Mod script discussion/help

Reply #4195
marc2003, so, playcount sync will stop working too? That's a shame. I haven't had enough time to enjoy it. ~_~

Btw, I've captured the video where I'm testing different code snippets: https://my.mixtape.moe/binfgr.webm
Maybe someone modified common8.js before me and that's why your snippets don't work as expected. Or maybe I've placed them in a wrong part of the code, lol.
EDIT: Forgot to remove the second instance of this.auto_love_count in the first video. Here is a video of double loving/unloving: https://my.mixtape.moe/mtuowd.webm

WSH Panel Mod script discussion/help

Reply #4196
no, playcount sync will continue to work. it's just the bio script that will stop. i could probably make it work with the beta right now but i'm not doing anything until it goes final.

for people who have old copies of my thumbs script kicking around, that will also stop working when the new site goes live.

WSH Panel Mod script discussion/help

Reply #4197
Ok, cool. Too bad that Thumbs will stop working. I use it in combination with Biography script. Actually, every other theme contains this script, because foo_uie_biography doesn't show more than 1 image, and the biography text is truncated to 300 characters.
Any chance you will bring it back? For example, without your own API key and via the super-secret password protected link. :]

WSH Panel Mod script discussion/help

Reply #4198
just posting to say last.fm are currently in the process of breaking their API...hopefully just temporarily 

artist top tags / artist top tracks (api key is fine on other feeds)
Code: [Select]
{"error":{"code":10,"message":"Invalid API key - You must be granted a valid key by last.fm"}}


artist top albums
Code: [Select]
{"error":{"code":3,"message":"Invalid Method - No method with that name in this package"}}


i'm also seeing playcount discrepancies between library.gettracks (used by playcount sync import) and track.getinfo (used when updating playcounts during playback).

WSH Panel Mod script discussion/help

Reply #4199
https://github.com/19379/wsh_marc2003/releases

Quote
Last.fm Bio: Should now handle the switch to the new Last.fm website when it goes live.
User Recommendations: Fix overlapping text on narrow panels.