Skip to content

Commit

Permalink
Fix shortcut for Validator using WazeWrap
Browse files Browse the repository at this point in the history
This fixes  the shortcut not working for us. There is a lot of code involved for adding the shortcut in a good way, so I propose using WazeWrap for add the shortcut. In the future we could utilize WazeWrap for more things?
  • Loading branch information
davidakachaos committed Nov 5, 2018
1 parent 87c1750 commit a807f6a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions meta/meta-begin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// @match https://beta.waze.com/*editor*
// @match https://www.waze.com/*editor*
// @exclude https://www.waze.com/*user/*editor/*
// @require https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js
// @grant none
// @icon https://raw.githubusercontent.com/WMEValidator/release/master/img/WV-icon96.png
// @namespace a
Expand Down
11 changes: 11 additions & 0 deletions meta/wme-externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ var I18n = {
currentLocale: function () { },
}

///////////////////////////////////////////////////////////////////////////
// WazeWrap Namespace
/** @type {Object} */
var WazeWrap = {
Interface: {
Shortcut: {
add: function () { },
}
}
}

///////////////////////////////////////////////////////////////////////////
// OpenLayers Namespace
/** @type {Object} */
Expand Down
9 changes: 9 additions & 0 deletions src/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,3 +738,12 @@ function onChangeIsImperial() {
_RT.$isMapChanged = true;
async(F_LOGIN);
}

/**
* Toggle WME Validator from shortcut
*/
function onToggleValidator(){
// switch Validator on/off
_RT.$switchValidator = true;
async(F_UPDATEUI);
}
3 changes: 3 additions & 0 deletions src/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,9 @@ function F_LOGIN() {
$('#user-tabs+div.tab-content').append(
'<div class="tab-pane" id="sidepanel-' + ID_PREFIX + '"></div>'
);
// Create Shortcut
new WazeWrap.Interface.Shortcut(GL_LAYERACCEL, 'Toggle WME Validator',
'wmevalidator', 'WME Validator', GL_LAYERSHORTCUT, onToggleValidator, null).add();
// append user interface after the details or ad the bottom
_THUI.appendUI(document.getElementById("sidepanel-" + ID_PREFIX),
_UI, "i" + ID_PREFIX);
Expand Down
2 changes: 1 addition & 1 deletion src/other.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ function F_INIT() {
WM = nW.map;
WMo = nW.model;
WC = nW.controller;
if (!Wa || !WLM || !WSM || !WM || !WMo || !WC || !$("#user-tabs")) {
if (!Wa || !WLM || !WSM || !WM || !WMo || !WC || !WazeWrap || !$("#user-tabs")) {
log("waiting for WME...")
async(F_INIT, null, 1e3);
return;
Expand Down

0 comments on commit a807f6a

Please sign in to comment.