Let me explain a bit.
My AudioControl file had all code for 11 different buttons and thus had 600 lines of code. You can call this function with var b_single 0 and the panel will display all buttons. You can also choose a single button to display. In the user interface there is a setupmode in which you can either disable or enable (previously disabled) buttons. I have two full sets of separate buttons and 1 panel that shows them all (test/debug panel). The last one needs to be enabled by changing one line of PSS code, so is typically not accessible for a user.
Until now everytime I changed one tiny thing in the code I had to reload the whole thing 23x by copy/paste, changing one line per panel to say what button was to be displayed and apply.
So now I have changed the whole thing (except for the setting of two variables) to something I can include via the preprocessor.
The code that is placed in the panels itself is static (see attachment). It has the b_single variable which identifies the button I want to see and whether I want transparency (for now always 1). And now in order to be able to test this functionality also contains the on_notify_data. That's it.
I highly value the idea to have 1 set of code for all panels with only a single var defined at the top that changes functionality.
If I would want to apply what you mention before Edit 2 that means I have to include a new unique var in all of those panels and also have to keep track of which unique values I've used. That doesn't work for me.
Ad Edit 2 will work, but which one? Normally one full set of buttons and the test/debug full set are hidden. So the most obvious one would be the non-hidden menu button. I still don't like the idea of introducing an extra var to define which panel will be the publisher.
Choices for activating Reload for all panels with AudioControls available:
1) Leave it on mouse middle click; publish available on all AudioControl buttons (already tested & implemented)
2) Assigning the publish function based on on_script_unload to only one single AudioControl button (already tested & implemented)
3) Regor's method with txtfile or a timing check. Both beyond my JS3 capabilities
4) Adding an extra command to SHIFT-WinKey-Rightclick on all AudioControl buttons
For now and awaiting Marc2k3's answer on option 4 I've implemented both 1 & 2.
EDIT: Thanks for the on_script_unload tip.
// ==PREPROCESSOR==
// @name "Playback Buttons - Menu, Stop, Play/Pause, Previous, Next, PBO, RandomizeSelection, QueueSelection, ReplayGain, DSPpreset, OutputDevice - All with rightbutton extras"
// @author "marc2003, modified by Defender"
// @import "%fb2k_component_path%helpers.txt"
// @import "%fb2k_component_path%samples\js\lodash.min.js"
// @import "%fb2k_component_path%samples\js\common.js"
// @import "%fb2k_component_path%samples\js\panel.js"
// @import "%fb2k_profile_path%cui-configs\Defender\JS3\JS3_AudioControls.js"
// ==/PREPROCESSOR==
//////////////////////////////////////
var b_single = 1; // 0=Select multiple buttons Otherwise single button: 1=Menu 2=Stop 3=Play/Pause 4=Previous 5=Next 6=PBO 7=RandomizeSelection 8=QueueSelection 9=ReplayGain 10=DSPpreset 11=OutputDevice
if (b_single==0) {
// Select multiple buttons 0=OFF 1=ON. Make sure panel has enough width otherwise hover can stay activated with mouseovers
// Button Left click Right click
b_menu = 1; // 1 Main Menu - Help Menu
b_stop = 1; // 2 Stop - Stop After Current
b_play = 1; // 3 Play/Pause - Random - PBO will not be changed
b_prev = 1; // 4 Previous - Seek Back 10 sec
b_next = 1; // 5 Next - Seek Ahead 10 sec
b_pbo = 1; // 6 PBO Dropdown - Reset to Default
b_rsel = 1; // 7 Randomize Selection - Randomize Selection and Play
b_qsel = 1; // 8 Queue Selection - UnQueue Selection
b_rg = 1; // 9 ReplayGain Dropdown - Reset to Track
b_dsp = 1; // 10 DSP Preset Dropdown - Reset to first found DSP preset or Preferences
b_odev = 1; // 11 OutputDevice Dropdown - Reset to second outputdevice in list (should be standard Primary Sound Driver) or Preferences
}
var transparant = 1; // 0=OFF paint background 1=ON do not paint background
/////////////////////////////////////
var publisher = 0; // Only one instance of all AudioControl panels can have publisher set to 1
function on_script_unload() {
if (publisher == 1) window.NotifyOthers('AC.RELOAD', 'Reload all other AudioControl panels');
}
function on_notify_data(name, info) {
if (name === 'AC.RELOAD') window.Reload();
}