[Script] WazeWrap

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.

Moderators: Unholy, bextein, Glodenox, JustinS83

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.

Re: [Script] WazeWrap

Postby JustinS83 » Sat Feb 02, 2019 5:35 am

Update released - 2019.02.01.01

A Script Updates interface is finally here! Holy moly I put that off for over a year...but now we have a way for scripts to publish update information in a consistent manner, and most importantly - no ridiculous alert() boxes interrupting the page loading and forcing focus to the tab.

Special thanks to falco_sparverius for the elegant design work - if it was left up to me it would have been an eyesore. Nice work :D

This update window will allow multiple scripts to display update information at once - so we do not have 2, 3, 4+ scripts popping up windows to announce their update. Each script that has an update to announce will get its own tab on the left side of the dialog. The right side will contain the update information with the new version at the top, followed by the update description and links to the Greasyfork and forum thread (optional).

Image

For devs:

Code: Select all
WazeWrap.Interface.ShowScriptUpdate("Script Name", ScriptVersion, "Update description", "Greasyfork Link", "Forum Link");


I would recommend using
Code: Select all
GM_info.script.version
for the script version so it is automatically pulled from the script and does not have to be updated. The Greasyfork link and forum link are not required - you can pass empty strings for these if you do not wish for the links to be displayed.

The Script Update function will track the script name and version so you can call it with the same name and version but it will only display the update the first time - the version must be different on subsequent runs for the update to display again.
Last edited by JustinS83 on Sat Feb 02, 2019 2:19 pm, edited 1 time in total.
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1350
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2397 times

Re: [Script] WazeWrap

Postby JustinS83 » Sat Feb 02, 2019 2:17 pm

jm6087 wrote:WOW, super nice and so clean looking.

I can take no credit for the aesthestics - all credit goes to falco_sparverius. She took my initial turd of a design and cleaned it up.
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1350
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2397 times

Re: [Script] WazeWrap

Postby JustinS83 » Sat Feb 02, 2019 8:43 pm

dBsooner wrote:Thank you, Justin! Good stuff! Is the update content capable of being HTML encode?

Yes, you can pass html for the content. Just don't do anything to crazy and change the look of the window or I'll have to start sanitizing the css and that's no fun :)
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1350
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2397 times

Re: [Script] WazeWrap

Postby JustinS83 » Tue Feb 12, 2019 2:31 pm

crazycaveman wrote:I haven't seen that problem (regarding page never finishing loading) with the new update dialog, editor loads fine whether an update log is shown or not. However, regarding the update log, if there are several scripts that update and produce a scroll bar, I am unable to scroll the list with the mouse (in Chrome and Firefox, have to click and drag the bar). Would it be possible to make the list scrollable with the mouse wheel?


I noticed the scroll wheel was not working when I was developing it but I don't see a reason for it to not work. I tried forcing it and still no-go. Not sure what is going on to be honest.
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1350
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2397 times

Re: [Script] WazeWrap

Postby JustinS83 » Mon Feb 18, 2019 8:46 pm

Update released - 2019.02.18.01

Added an Events class. This class is designed to add extra, simple error handling when hooking WME events. All scripts that hook any of the WME events should add in their own error handling, but many do not, to prevent WME updates from breaking multiple scripts - even if there is only an error in one.

If one script breaks after hooking one of the events and the error that is thrown is not caught, the rest of the event handling queue is not executed so other scripts can/will be affected. Changing to use the WW events will prevent other scripts from being affected if there is an issue. Additional error handling should be done in the script, but switching to these events is a quick and easy way to protect your script, and others, in case of an error.

The following events are supported:
Code: Select all
moveend
zoomend
mousemove
changelayer
selectionchanged
change:editingHouseNumbers
afterundoaction
afterclearactions
afteraction


Implement virtually the same as when hooking native events.
Native:
Code: Select all
W.selectionManager.events.register("selectionchanged", null, handler);
W.model.actionManager.events.register("afterundoaction",null, handler);
W.model.actionManager.events.register("afterclearactions",null, handler);
W.model.actionManager.events.register("afteraction",null, handler);


Using WazeWrap:
Code: Select all
WazeWrap.Events.register("selectionchanged", null, handler);
WazeWrap.Events.register("afterundoaction",null, handler);
WazeWrap.Events.register("afterclearactions",null, handler);
WazeWrap.Events.register("afteraction",null, handler);


It is possible to pass an error handling method to the WazeWrap.Events.register() method as well if you want to try and recover from any error that occurs.
Code: Select all
WazeWrap.Events.register("selectionchanged", null, handler, errorHandler);

If no error handling method is passed then the error will be logged to the console, including the method name that threw the error.

To unregister the events, it is again essentially the same as unregistering natively
Code: Select all
WazeWrap.Events.unregister("selectionchanged", null, handler);
WazeWrap.Events.unregister("afterundoaction",null, handler);
WazeWrap.Events.unregister("afterclearactions",null, handler);
WazeWrap.Events.unregister("afteraction",null, handler);


Registering/unregistering for entering/exiting house number edit mode is the only one that is different, but you continue to use the same syntax as registering the other events with WazeWrap.Events
Native:
Code: Select all
W.editingMediator.on('change:editingHouseNumbers', handler);
W.editingMediator.off('change:editingHouseNumbers', handler);

WazeWrap:
Code: Select all
WazeWrap.Events.register("change:editingHouseNumbers", null, handler);
WazeWrap.Events.unregister("change:editingHouseNumbers", null, handler);


Note that when using the WazeWrap.Events.register for these you must pass a null value as the 2nd parameter - this is to keep the usage in line with all of the other register calls, despite the native registrations only taking two parameters.
Last edited by JustinS83 on Wed Mar 06, 2019 6:43 pm, edited 1 time in total.
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1350
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2397 times

Re: [Script] WazeWrap

Postby JustinS83 » Tue Feb 19, 2019 12:52 am

dBsooner wrote:Found an interesting z-index issue tonight. I can't seem to get the z-index high enough to be on-top of the UR Panel, but going to 10000 instead of 1000 gets above the turn restriction arrows. I found this by going directly to a UR in the URL (while I left my disabled turns enabled).

EDIT: Yep and I see a bug with URC-E too. LOL.

2019_02_18_18_34_55_Waze_Map_Editor.png


I wasn't going to mess with the zindex to get on top of that stuff but people won't stop pointing it out. So. FINE.
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1350
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2397 times

Re: [Script] WazeWrap

Postby JustinS83 » Mon Apr 29, 2019 9:09 pm

Update released - 2019.04.29.02

Added an alerts interface - this provides replacements for alert, prompt, confirm and some additional messages.

One of the main purposes of this update is to eliminate the use of the blocking messages alert, prompt and confirm. This also adds some other message types that allow a script to convey some information, warnings or debug messages to the user.

Example:
This is an error from WME Place Interface Enhancements that was previously an alert box that is now displayed as an error message:

Image

The message will time out in 6 seconds so you do not have to click anything to continue interacting with WME. If you messed the message, or just want to review previous messages, an alert history is provided. All info, warning, error and success messages are entered into the history when they are displayed.

All alerts will display at the top center of the WME window so they are clearly visible.

Image
The alert history is an orange box with a triangle and exclamation mark, that defaults in the top left corner. This is draggable to another location if you desire (although the list only expands down so do not move it to the bottom of the map). This will display all alerts in the current WME session, with the latest being on top.

The alerts are accessed via: WazeWrap.Alerts.
Code: Select all
WazeWrap.Alerts.info(GM_info.script.name, "message");
WazeWrap.Alerts.warning(GM_info.script.name, "message");
WazeWrap.Alerts.error(GM_info.script.name, "message");
WazeWrap.Alerts.success(GM_info.script.name, "message");
WazeWrap.Alerts.prompt(GM_info.script.name, "message", default_inputbox_text (can be blank), okFunctionCallback, cancelFunctionCallback);
WazeWrap.Alerts.confirm(GM_info.script.name, "message", okFunctionCallback, cancelFunctionCallback, ok_button_text (default is "Ok"), cancel_button_text (default is cancel));
WazeWrap.Alerts.debug(GM_info.script.name, "message");

info, warning, error and success prompts just accept the script name (which can be automatically pulled using GM_info.script.name) and the message you want to display.

prompt - this is a replacement for alert boxes. You pass the script name and your message, just like the other boxes. In addition to that you can pass default text to fill in the input box in the prompt; if you do not wish to, just pass an empty string. You then pass callback functions for if the user pressed the ok or cancel button. If you only want to handle one or the other, only pass that one and pass null for the other.

confirm works much the same as prompt in that you pass the callbacks for the ok and cancel buttons, but you can also customize the text of these buttons.

debug messages are more for script debugging and not for use to send to end users. These boxes will display larger (700px wide instead of 500px) and they will allow scrolling.

Examples of the other alert types:
Image
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1350
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2397 times

Re: [Script] WazeWrap

Postby JustinS83 » Tue Apr 30, 2019 1:11 am

bz2012 wrote:We have the 'History' icon showing but it doesn't do anything when I click on it (except allow me to move it around).

Also WMEPH and WMEPH-beta have disappeared.

Obviously not the place to report WMEPH issues.

See the previous post about how history works.
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1350
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2397 times

Re: [Script] WazeWrap

Postby JustinS83 » Thu May 02, 2019 3:43 pm

karlcr9911 wrote:Definitely need some better indication as to what this is via a tooltip, click-behavior to tell me what it is when no alerts are present...just something, so the daily (multiple times a day) questions in Discord will subside.

I love the concept but something more to let users know what script this is from, that nothing is actually wrong if no alerts are present, etc. would be most helpful in my opinion.

Thank you!

Yes, it is on my list. I've seen the confusion :)

Trying to make some changes to how the library loads so it doesn't fully load with every script that uses it so we don't have multiple versions floating around, elements loading 20+ times, etc.
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1350
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2397 times

Re: [Script] WazeWrap

Postby JustinS83 » Wed Jun 12, 2019 5:41 pm

Update released! 2019.06.12.01

Features added: WW tab for WazeWrap settings.

Image

WazeWrap settings (currently) includes two options: Editor PIN and Show alerts history.
Show alerts history is what it sounds like - when enabled the Script Alert History icon will be present on the map.

The Editor PIN is a value that you choose, and it should be protected (not shared) just like a password. When set, this allows scripts to be able to save your script settings to a server so you can have the same script settings across all computers that you work on. You enter the same PIN on all the PCs and they will use the settings retrieved from the WazeDev server. This PIN is what protects someone from reading/overwriting your settings so please do not share it (this is why it is hidden in the WW tab). Mousing over the eye icon will show you your PIN in case you forget it.

It is possible to change the PIN used on your local machine (Change PIN button that will appear after setting a PIN and refreshing your page). If you need to change/look up the PIN associated with your account you will need to contact me to do so.

Scripters

To use this feature you must be saving all of your settings into a single object that can be stringified.

To save and retrieve the settings from the server you use the following calls:

Code: Select all
WazeWrap.Remote.RetrieveSettings("Script Name");
WazeWrap.Remote.SaveSettings("Script Name", settingsObject);


The script name used must be unique and should never change. If you ever change this, the script settings already stored on the server will be orphaned and all your users will not be able to access them. Don't do this. Think of the users.

Both of these calls should be called using async/await since they are hitting a server, in order to preserve your program flow. You can use normal promise callbacks if you want...but why complicate your life?

How you implement using/saving the settings is completely up to you. I would recommend saving a lastSaved date/time in your settings object so you can compare local settings against the server settings so you know which one should be used.

If the user has not set a PIN or your script has not saved settings to the server before, the RetrieveSettings will return null. SaveSettings will return true/false depending on if the save was successful (will return null if the user has not set a PIN).
JustinS83
Waze Global Champs
Waze Global Champs
 
Posts: 1350
Joined: Wed Dec 03, 2014 4:33 am
Location: Franklin, OH
Has thanked: 341 times
Been thanked: 2397 times

PreviousNext

Return to Addons, Extensions, and Scripts

Who is online

Users browsing this forum: buckeyemondo, jm6087, Mythdraug