Discussion for the unofficial, community-developed addons, extensions and scripts built for the Waze Map Editor.

The official index of these tools is the Community Plugins, Extensions and Tools wiki page.

Post Reply
Forum rules
Discussion for the unofficial, community-developed addons, extensions and scripts built for the Waze Map Editor.

DO NOT START a new thread unless it is about a new idea. Keep discussion of existing tools within the main thread for that tool.

The official index of these tools is the Community Plugins, Extensions and Tools wiki page.

To Script Editors: Changes to Events Mechanism in Scripts

Post by Cardyin
Hi all,

I know that many script editors are struggling with getting their scripts updated to work in the latest version of the WME.

Looking at the debug console in Chrome, many of the scripts all suffer from the same problem, which is that Waze changed the way they handle events. So, if you have a hook in your code to execute your function when things change, save, load, etc, it's probably broken. Usually this is done by calling the "register" or "registerPriority" method of the events collection.

For example:
W.model.venues.events.register
W.model.mapUpdateRequests.events.register
...

If you have this type of call in your code, you will have to use the new "on" syntax to make this hook.

Old Code

Code: Select all

W.model.mapUpdateRequests.events.register("objectschanged", null, URComments.urcUREvent_onObjectsAdded('mapUpdateRequests objectschanged'));
New Code

Code: Select all

W.model.mapUpdateRequests.on("objectschanged", URComments.urcUREvent_onObjectsAdded('mapUpdateRequests objectschanged'));
It's a simple change that should fix a lot of script issues out there.

Also, the new WME renamed or reclassed lots of objects (as usual). You'll just have to use the new names to refer to your objects. Here is an example for the code to actually click the save button from your code:

Old Code

Code: Select all

$('#toolbar #edit-buttons .WazeControlSave').trigger('click');
New Code

Code: Select all

$('.toolbar-button.waze-icon-save').trigger('click');
I'm really not good at coding new things, but I'm very strong in reading/hacking/optimizing other people's code. If any of you need help in debugging your scripts, I'll be glad to offer my assistance, please feel free to send me a PM.

Cardyin
Cardyin
Map Editor - Level 4
Map Editor - Level 4
Posts: 59
Has thanked: 16 times
Been thanked: 71 times

POSTER_ID:17080483

1

Send a message