[Script] WME Panel Swap

Hi all! This was a quick script I wrote after a discussion with some of the Southern California editors (special thanks to Ottonomy for the idea!). I thought it might be useful for many of you - so I’m sharing it! Feedback welcome!

Description:
This script allows a user to switch between the segment side-panel and the user side-panel (the one with all your tabs) while there are segments selected. This allows you to utilize scripts that have their UI in the side-panel, but might work with selected segments.

Current version: 0.1.7

Installation:
Get the script here. You will need GreaseMonkey (Firefox) or TamperMonkey (Chrome) before you can install the script.

To use:
Once you have a segment selected - you can click the small icon in the top right of your WME side-panel to toggle between the segment and user side-panels. Adding or removing selected segments will reset the view per normal WME behavior. This is particularly useful for scripts like WME Route Speeds that act on segments, but have their UI in the side-panel.

This is going to save me a lot of time. I hate losing a carefully made selection because I’ve forgotten to first toggle a setting in a script. THANK YOU!!!

You are an awesome human being.

This is one of those why-isnt-this-default-in-the-WME kinda question!
Very, very nice. Thank you :slight_smile:

This seems to be broken for me.
OS-X, FF

Actually, sometimes it there, sometimes not. Is it a load order issue?

I suspect this to be the issue. I’m trying to track this problem down.

It usually does not display when you open a PL with a segment selected. Have you tried clicking a segment on and off a couple of times?

Ah, thanks for pointing this out - it helped me track down an issue. I had two issues that I believe I’ve fixed. Timing seems to be a bit different in Firefox than in Chrome, but I think I’ve tested both pretty well now. Hopefully the problems are resolved.

1.) I wasn’t doing sufficient checking in my bootstrap code to ensure everything was loaded (thanks SAR85 for letting me steal your bootstrap logic!)
2.) I was only responding to changes in selection, so if you loaded a PL with selection already in place, it could fail to show the panel button - depending on the timing of how Waze fired up.

The production WME code update on Tuesday seems to have disabled the panel swapper. Or is it just me?

I’m not seeing the swap button either.

Indeed, Panel Swap is broken. JJohnston84 has been really busy with work lately, so we may not see him stop in here, but tonestertm believes he has isolated the problem, and has passed it on to someone who was working with Jacob in development. There is hope that we’ll have this back soon.

Looks like this script was an easy fix. Bootstrap function was looking within Waze object for properties that no longer exist, yet were not needed to make the script work. I think jjohnson has already released the fix (thanks!).

On another note, is it possible to bind a modifiable shortcut key? That would be awesome. :slight_smile:

Has the fix been posted?

I must have thought he fixed it when I had gone into the code to fix it myself. Oops! lol

In any case, the fix is actually quite simple here… Just remove some of the checks in the bootstrap function (wmeps_bootstrap())… now i forget what it use to say, but any of the checks that have something after Waze.appPresenter.sidebar.editPanel.??? (replace ??? with other stuff) can be removed… WME Panel Swap never uses them.

The result should look something like this… tho I’m not sure if it actually needs to check all the parents of editPanel <shrug>:

if (undefined !== typeof Waze &&
  Waze.appPresenter && Waze.appPresenter.sidebar && Waze.appPresenter.sidebar.editPanel &&
  Waze.appPresenter.sidebar && Waze.appPresenter.sidebar.editPanel ) {

I’ll make it simpler…

Replace the stuff after // Bootstrap and before function wmeps_int() { with the following:

  function wmeps_bootstrap() {
    'use strict';
    wmeps_bootstrapCount++;
    if (undefined !== typeof Waze &&
      Waze.appPresenter && Waze.appPresenter.sidebar && Waze.appPresenter.sidebar.editPanel &&
      Waze.appPresenter.sidebar && Waze.appPresenter.sidebar.editPanel ) {
      console.debug('WME Panel Swap: Initializing...');
      window.setTimeout(wmeps_init, 100);
    } else if (wmeps_bootstrapCount &lt; 15) {
      console.debug('WME Panel Swap: Bootstrap failed. Trying again...');
      window.setTimeout(wmeps_bootstrap, 1000);
    } else {
      console.debug('WME Panel Swap: Bootstrap error.');
    }
  }
  console.debug('WME Panel Swap: Bootstrapping');
  window.setTimeout(wmeps_bootstrap, 100);

I just added the /* and */ below (end of third line before last &&, and end of fifth line before the closing parenthesis):

    if (undefined !== typeof Waze &&
      Waze.appPresenter && Waze.appPresenter.sidebar && Waze.appPresenter.sidebar.editPanel &&
      Waze.appPresenter.sidebar && Waze.appPresenter.sidebar.editPanel /* &&
      Waze.appPresenter.sidebar.editPanel.typeToEditorClass &&
      Waze.appPresenter.sidebar.editPanel.typeToEditorClass.segment */) {

Off-topic - I saw somewhere that there’s a way to get validator to appear at the bottom of the sidebar instead of the top, but can’t find teh reference. Anyone want to point me in the right direction?

Another fix, as I’ve been informed by SAR85, is as follows:
Because the property,
“typeToEditorClass”
of
Waze.appPresenter.sidebar.editPanel
has been renamed or replaced with
“TYPE_TO_EDITOR_CLASS”
in the model, simply changing the two instances of the former to the latter gets it running again, and leaves the checks intact.

It’s in the Validator settings

KuniaKid,

I don’t see it.