// ==UserScript==
// @name WME Fix UI
// @namespace https://greatest.deepsurf.us/en/users/46070
// @description Allows alterations to the WME UI to fix things screwed up or ignored by Waze
// @include https://www.waze.com/editor/*
// @include https://www.waze.com/*/editor/*
// @include https://editor-beta.waze.com/*
// @exclude https://www.waze.com/user/editor/*
// @supportURL https://www.waze.com/forum/viewtopic.php?f=819&t=191178
// @version 1.1
// @grant none
// ==/UserScript==
// Thanks to (in no particular order) Bellhouse, Twister-UK, Timbones, Dave2084, Rickzabel, Glodenox
(function()
{
// global variables
var wmefu_version = "1.1";
var tabAttempts = 0;
var wmeFUAddon;
var debug = false;
function init1() {
console.group("WMEFU initialising...");
console.time("WMEFU initialisation time");
logit("Starting init1","debug");
// go round again if map container isn't there yet
if(!window.Waze.map) {
logit("waiting for WME...","warning");
setTimeout(init1, 200);
return;
}
// create tab content and store it
wmeFUAddon = createAddon();
// insert the content as a tab
addMyTab(null,0);
//pass control to init2
init2();
}
function init2() {
logit("Starting init2","debug");
//go round again if my tab isn't there yet
if (!getId('sidepanel-FixUI')) {
logit("Waiting for my tab to appear...","warning");
setTimeout(init2, 200);
return;
}
// setup event handlers for user actions:
getId('_cbMoveZoomBar').onclick = moveZoomBar;
getId('_cbShrinkBlackBar').onclick = shrinkBlackBar;
getId('_cbHideUserInfo').onclick = hideUserInfo;
getId('_cbCompressSegmentTab').onclick = compressSegmentTab;
getId('_cbRestyleReports').onclick = restyleReports;
getId('_cbDisableMapBlocker').onclick = disableMapBlocker;
getId('_cbNarrowSidePanel').onclick = narrowSidePanel;
getId('_cbHideAveSpeedControls').onclick = hideAveSpeedControls;
getId('_cbAddZoomIndicator').onclick = addZoomIndicator;
// set event to recreate my tab when MTE mode is exited
Waze.app.modeController.model.bind('change:mode', addMyTab);
//events for Aerial Shifter
Waze.map.events.register("zoomend", null, shiftAerials);
Waze.map.events.register("moveend", null, shiftAerials);
Waze.map.baseLayer.events.register("loadend", null, shiftAerials);
getId("_inpASX").onchange = shiftAerials;
getId("_inpASX").onwheel = shiftAerials;
getId("_inpASY").onchange = shiftAerials;
getId("_inpASY").onwheel = shiftAerials;
getId("_inpASO").onchange = shiftAerials;
getId("_inpASO").onwheel = shiftAerials;
getId("_resetAS").onclick = function() {
_inpASX.value = 0;
_inpASY.value = 0;
shiftAerials();
};
// restore saved settings
if (localStorage.WMEFixUI) {
logit("loading options from local storage");
options = JSON.parse(localStorage.WMEFixUI);
getId('_cbMoveZoomBar').checked = options[1];
getId('_cbShrinkBlackBar').checked = options[2];
getId('_cbHideUserInfo').checked = options[3];
getId('_cbCompressSegmentTab').checked = options[4];
getId('_cbRestyleReports').checked = options[5];
getId('_cbDisableMapBlocker').checked = options[6];
getId('_cbNarrowSidePanel').checked = options[7];
getId('_cbHideAveSpeedControls').checked = options[8];
getId('_cbAddZoomIndicator').checked = options[9];
if (typeof(options[10]) === "undefined") {
//define sensible values for AS if none are stored
logit("setting new AS values","debug");
options[10] = 0;
options[11] = 0;
options[12] = 100;
}
getId('_inpASX').value = options[10];
getId('_inpASY').value = options[11];
getId('_inpASO').value = options[12];
} else {
// default values for first installation
logit("no options in local storage - setting defaults");
getId('_cbMoveZoomBar').checked = true;
getId('_cbShrinkBlackBar').checked = true;
getId('_cbHideUserInfo').checked = true;
getId('_cbCompressSegmentTab').checked = true;
getId('_cbRestyleReports').checked = true;
getId('_cbDisableMapBlocker').checked = false;
getId('_cbNarrowSidePanel').checked = false;
getId('_cbHideAveSpeedControls').checked = false;
getId('_cbAddZoomIndicator').checked = true;
getId('_inpASX').value = 0;
getId('_inpASY').value = 0;
getId('_inpASO').value = 100;
}
// Adds an extra checkbox so I can test segment panel changes easily
if (Waze.loginManager.user.userName == 'iainhouse') {
logit("creating segment detail debug checkbox","info");
var brand = getId('brand');
extraCBSection = document.createElement('p');
extraCBSection.innerHTML = '<input type="checkbox" id="_cbextraCBSection" />';
brand.appendChild(extraCBSection);
getId('_cbextraCBSection').onclick = FALSEcompressSegmentTab;
_cbextraCBSection.checked = _cbCompressSegmentTab.checked;
}
// overload the WME exit function to save my settings
saveOptions = function() {
if (localStorage) {
logit("saving options to local storage");
var options = [];
// preserve previous options which may get lost after logout
if (localStorage.WMEFixUI)
options = JSON.parse(localStorage.WMEFixUI);
options[1] = getId('_cbMoveZoomBar').checked;
options[2] = getId('_cbShrinkBlackBar').checked;
options[3] = getId('_cbHideUserInfo').checked;
options[4] = getId('_cbCompressSegmentTab').checked;
options[5] = getId('_cbRestyleReports').checked;
options[6] = getId('_cbDisableMapBlocker').checked;
options[7] = getId('_cbNarrowSidePanel').checked;
options[8] = getId('_cbHideAveSpeedControls').checked;
options[9] = getId('_cbAddZoomIndicator').checked;
options[10] = getId('_inpASX').value;
options[11] = getId('_inpASY').value;
options[12] = getId('_inpASO').value;
localStorage.WMEFixUI = JSON.stringify(options);
}
};
window.addEventListener("beforeunload", saveOptions, false);
// apply the settings
shiftAerials();
setTimeout(applyAllSettings, 2000);
logit("Initialisation complete");
console.timeEnd("WMEFU initialisation time");
console.groupEnd();
}
function createAddon() {
//create the contents of my side-panel tab
var addon = document.createElement('section');
var section = document.createElement('p');
addon.id = "sidepanel-FixUI";
section.style.paddingTop = "0px";
section.id = "fuContent";
section.innerHTML = '<b>UI Fixes</b><br>';
section.innerHTML += '<input type="checkbox" id="_cbMoveZoomBar" /> ' +
'<span title="Because nobody likes a pointless UI change that breaks your workflow, imposed by idiots who rarely use the editor and don\'t listen to feedback">Move zoom bar to left <sup>*</sup></span><br>';
section.innerHTML += '<input type="checkbox" id="_cbAddZoomIndicator" /> ' +
'<span title="Yes - I stole the idea from WME Toolbox. But mine is clearer and takes up no extra room ;)">Add zoom level indicator to zoom bar</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbHideUserInfo" /> ' +
'<span title="Because we can earn points quicker without a massive chunk of space wasted on telling us how many we earnt up to yesterday">Hide user info in the side panel</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbShrinkBlackBar" /> ' +
'<span title="Because we can\'t afford to waste screen space on stuff we didn\'t ask for and don\'t want">Shrink the black bar above the map</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbCompressSegmentTab" /> ' +
'<span title="Because I\'m sick of having to scroll the side panel because of oversized fonts and wasted space">Compress the contents of the side panel</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbRestyleReports" /> ' +
'<span title="Another UI element configured for developers with massive screens instead of normal users">Change formatting for report panels (UR/MP)</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbDisableMapBlocker" /> ' +
'<span title="As if the crappy interface wasn\'t making life hard enough, now they force us to wait for an arbitrary time after every save!">Disable map blocking during/after saving.</span><span title="Use at your own risk. We don\'t know why it\'s there. Maybe there\'s a good reason but Waze can\'t be arsed to tell us what it is." style="font-size: 16px; color: red;">⚠</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbNarrowSidePanel" /> ' +
'<span title="If you have a netbook, Waze isn\'t interested in your experience. You need every bit of map space you can get - so have a present from me!">Reduce width of the side panel</span><span title="This will definitely interfere with scripts that rely on a fixed width for their tab contents." style="font-size: 16px; color: red;">⚠</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbHideAveSpeedControls" /> ' +
'<span title="If you don\'t have these in your country, YOU\'RE LUCKY! But don\'t forget you\'ve disabled this - they\'ll be coming soon!">Hide average speed camera controls</span><br>';
section.innerHTML += '<br>';
var tbHackStr = '<sup>* If you have WME Toolbox installed, make sure the setting "Move zoom control to left" is ';
if (document.body.dir != "rtl") {
tbHackStr += 'OFF';
} else {
tbHackStr += 'ON';
}
tbHackStr += '.</sup><br>';
section.innerHTML += tbHackStr;
section.innerHTML += '<br>';
section.innerHTML += '<b title="Shift aerial images layer to match GPS tracks and reduce image opacity">Aerial Shifter</b> ';
section.innerHTML += '<span class="fa fa-power-off" id="_resetAS" title="Clear X/Y offsets"></span><br>';
section.innerHTML += '<div style="display:inline-block"><input type="number" id="_inpASX" title="horizontal shift" max=100 min=-100 step=5 style="height:20px; width:47px;text-align:right;"/><b>m</b><span class="fa fa-arrow-right"></span></div>';
section.innerHTML += '<div id="as2" style="display:inline-block;padding:0 5px;"><input type="number" id="_inpASY" title="vertical shift" max=100 min=-100 step=5 style="height:20px; width:47px;text-align:right;"/><b>m</b><span class="fa fa-arrow-up"></span></div>';
section.innerHTML += '<div id="as3" style="display:inline-block"><input type="number" id="_inpASO" title="opacity" max=100 min=0 step=10 style="height:20px; width:44px;text-align:right;"/><b>%</b><span class="fa fa-adjust"></span></div>';
section.innerHTML += '<br>';
section.innerHTML += '<br>';
section.innerHTML += '<b><a href="https://www.waze.com/forum/viewtopic.php?f=819&t=191178" title="Forum topic" target="_blank"><u>' +
'WME Fix UI</u></a></b> v' + wmefu_version;
addon.appendChild(section);
addon.className = "tab-pane";
return addon;
}
function addMyTab(model,modeID) {
if (modeID === 0) {
logit("entering default mode, so creating tab");
tabAttempts = 0;
tabsLooper();
} else {
logit("entering event mode, so not initialising");
return;
}
}
function tabsLooper() {
tabAttempts += 1;
if (tabAttempts > 20) {
// tried 20 times to create tab without luck
logit("unable to create my tab after 20 attempts","error");
return;
}
var userTabs = getId('user-info');
var navTabs = getElementsByClassName('nav-tabs', userTabs)[0];
if (typeof navTabs === "undefined") {
//the basic tabs aren't there yet, so I can't add mine
logit("waiting for NavTabs","warning");
setTimeout(tabsLooper, 200);
} else{
var tabContent = getElementsByClassName('tab-content', userTabs)[0];
newtab = document.createElement('li');
newtab.innerHTML = '<a href="#sidepanel-FixUI" data-toggle="tab" title="Fix UI">FU</a>';
navTabs.appendChild(newtab);
tabContent.appendChild(wmeFUAddon);
}
}
function applyAllSettings() {
// logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
console.group("WMEFU: applying all settings");
moveZoomBar();
shrinkBlackBar();
hideUserInfo();
compressSegmentTab();
restyleReports();
disableMapBlocker();
narrowSidePanel();
hideAveSpeedControls();
addZoomIndicator();
console.groupEnd();
}
function moveZoomBar() {
logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
var reportPanel = getId('panel-container');
reportPanel.style.position = "absolute";
if (_cbMoveZoomBar.checked) {
addGlobalStyle('.olControlPanZoomBar { left: 10px; width: 30px; right: inherit; }');
addGlobalStyle('#WMETB_ZoomLevelIndicator { left: 43px !important; right: inherit !important; }');
if (document.body.dir != "rtl") {
addGlobalStyle('.panel { left: 40px; }');
} else {
addGlobalStyle('.panel { right: inherit; }');
}
} else {
addGlobalStyle('.olControlPanZoomBar { left: inherit; width: 30px; right: 10px; }');
addGlobalStyle('#WMETB_ZoomLevelIndicator { left: inherit !important; right: 43px !important; }');
if (document.body.dir != "rtl") {
addGlobalStyle('.panel { left: inherit; }');
} else {
addGlobalStyle('.panel { right: 40px; }');
}
}
}
function hideUserInfo() {
logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
// WME Panel Swap buttons - move them up if user info is hidden
var PSButton1 = getId('WMEPS_UIButton');
var PSButton2 = getId('WMEPS_EditButton');
if (_cbHideUserInfo.checked) {
addGlobalStyle('#sidebar #user-info #user-box { padding: 0px; }');
addGlobalStyle('#sidebar #user-details .user-profile { display: none !important; }');
if (PSButton1) PSButton1.style.top = '-27px';
if (PSButton2) PSButton2.style.top = '-27px';
// Keep My Layers toggle - move up if user info is hidden
addGlobalStyle('.kml-toggle-container { top: -25px; }');
} else {
addGlobalStyle('#sidebar #user-info #user-box { padding: 20px; }');
addGlobalStyle('#sidebar #user-details .user-profile { display: inherit !important; }');
if (PSButton1) PSButton1.style.top = '0px';
if (PSButton2) PSButton2.style.top = '0px';
// Keep My Layers toggle - move back down if user info is shown
addGlobalStyle('.kml-toggle-container { top: 13px; }');
}
}
function shrinkBlackBar() {
logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
var wm = getId('WazeMap');
if (_cbShrinkBlackBar.checked) {
addGlobalStyle('.topbar { height: 20px; line-height: 20px; }');
addGlobalStyle('.topbar .location-info { font-size: 12px; }');
} else {
addGlobalStyle('.topbar { height: 30px; line-height: 30px; }');
addGlobalStyle('.topbar .location-info { font-size: 15px; }');
}
window.dispatchEvent(new Event('resize'));
}
function FALSEcompressSegmentTab() {
_cbCompressSegmentTab.checked = _cbextraCBSection.checked;
compressSegmentTab();
}
function compressSegmentTab() {
logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
var ep=getId('edit-panel');
if (_cbCompressSegmentTab.checked) {
// shrink address
addGlobalStyle('#edit-panel .primary-street { font-size: 14px; line-height: 15px; font-weight: 600; color: black; }');
addGlobalStyle('#edit-panel .address-edit-view .preview .address-edit-btn:not(.disabled) { background-color: #FFF9C4; }');
addGlobalStyle('#edit-panel .segment .address-edit-view, .edit-panel .segment .address-edit-view { margin-bottom: 5px; }');
//shrink tabs
addGlobalStyle('#sidebar .nav-tabs li a { padding: 4px; }');
addGlobalStyle('#sidebar .nav-tabs { margin-bottom: 5px; }');
//reduce some vertical margins
addGlobalStyle('#edit-panel .contents { padding-top: 0px; }');
addGlobalStyle('#edit-panel .form-group { margin-bottom: 2px; line-height: 1; font-size: 11px; }');
addGlobalStyle('#edit-panel .selection { margin-bottom: 5px; }');
addGlobalStyle('#sidebar .side-panel-section:not(:last-child) { margin-bottom: 2px; }');
addGlobalStyle('#sidebar .side-panel-section:not(:last-child)::after { margin-top: 5px; margin-bottom: 2px; }');
addGlobalStyle('#edit-panel .control-label { margin-bottom: 1px; }');
addGlobalStyle('#sidebar .controls-container { padding-top: 2px; }');
addGlobalStyle('#edit-panel .segment .speed-limit label { margin-bottom: 0px; }');
addGlobalStyle('#edit-panel .more-actions { padding-top: 2px; }');
addGlobalStyle('#edit-panel .segment .speed-limit .direction-label, #edit-panel .segment .speed-limit .unit-label { line-height: 2.1em; }');
//shrink dropdown controls & buttons
addGlobalStyle('#edit-panel button, #edit-panel select, #edit-panel .form-control { font-size: 11px; height: 22px; padding: 0px 4px; }');
addGlobalStyle('#edit-panel .more-actions button:not(:last-of-type) { margin-bottom: 2px; }');
addGlobalStyle('.edit-closure .input-group-addon { padding: 2px 8px; }');
//fit road property checkboxes on one line for all three (if text length allows)
addGlobalStyle('#edit-panel .controls-container { display: inline-block; }');
addGlobalStyle('#edit-panel .controls-container label { font-size: 12px; line-height: 18px; padding-left: 22px; }');
addGlobalStyle('#edit-panel .select-entire-street { width: 49%; overflow: hidden; }');
addGlobalStyle('#edit-panel .edit-house-numbers { width: 49%; overflow: hidden; }');
addGlobalStyle('#edit-panel .action-button { color: black; }');
} else {
//enlarge address
addGlobalStyle('#edit-panel .primary-street { font-size: 18px; line-height: 24px; font-weight: inherit; color: inherit; }');
addGlobalStyle('#edit-panel .address-edit-view .preview .address-edit-btn:not(.disabled) { background-color: inherit; }');
addGlobalStyle('#edit-panel .segment .address-edit-view, .edit-panel .segment .address-edit-view { margin-bottom: 20px; }');
//enlarge tabs
addGlobalStyle('#sidebar .nav-tabs li a { padding: 5px 15px; }');
addGlobalStyle('#sidebar .nav-tabs { margin-bottom: 20px; }');
//restore vertical margins
addGlobalStyle('#edit-panel .contents { padding-top: 20px; }');
addGlobalStyle('#edit-panel .form-group { margin-bottom: 10px; line-height: 1.43; font-size: 13px; }');
addGlobalStyle('#edit-panel .selection { margin-bottom: 20px; }');
addGlobalStyle('#sidebar .side-panel-section:not(:last-child) { margin-bottom: 21px; }');
addGlobalStyle('#sidebar .side-panel-section:not(:last-child)::after { margin-top: 21px; margin-bottom: 21px; }');
addGlobalStyle('#edit-panel .control-label { margin-bottom: 5px; }');
addGlobalStyle('#sidebar .controls-container { padding-top: 7px; }');
addGlobalStyle('#edit-panel .segment .speed-limit label { margin-bottom: 5px; }');
addGlobalStyle('#edit-panel .more-actions { padding-top: 10px; }');
addGlobalStyle('#edit-panel .segment .speed-limit .direction-label, #edit-panel .segment .speed-limit .unit-label { line-height: 2.5em; }');
//enlarge dropdown controls & buttons
addGlobalStyle('#edit-panel button, #edit-panel select, #edit-panel .form-control { font-size: 13px; height: 32px; padding: 6px 12px; }');
addGlobalStyle('#edit-panel .more-actions button:not(:last-of-type) { margin-bottom: 10px; }');
addGlobalStyle('.edit-closure .input-group-addon { padding: 6px 8px; }');
//restore road property checkboxes to one line per item
addGlobalStyle('#edit-panel .controls-container { display: inherit; }');
addGlobalStyle('#edit-panel .controls-container label { font-size: inherit; line-height: inherit; padding-left: 25px; }');
addGlobalStyle('#edit-panel .select-entire-street { width: 100%; overflow: inherit; }');
addGlobalStyle('#edit-panel .edit-house-numbers { width: 100%; overflow: inherit; }');
addGlobalStyle('#edit-panel .action-button { color: inherit; }');
}
//tweak required for Speedhelper script
addGlobalStyle('div[id^="spd_"] { line-height: 1.43; }');
}
function restyleReports() {
logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
if (_cbRestyleReports.checked) {
addGlobalStyle('#panel-container .panel { font-size: 12px; line-height: 15px; }');
addGlobalStyle('#panel-container .problem-edit .header { padding: 5px; line-height: 15px; }');
addGlobalStyle('#panel-container .problem-edit .problem-data .title { line-height: 22px; }');
addGlobalStyle('#panel-container .problem-edit .section .title { padding: 0 5px; }');
addGlobalStyle('#panel-container .problem-edit .section .content { padding: 5px; }');
addGlobalStyle('#WMEFP-UR-ALLPM { top: -2px !important; }');
addGlobalStyle('#panel-container .problem-edit .conversation.section .comment .comment-content { padding: 0 5px; }');
addGlobalStyle('#panel-container .problem-edit .conversation.section .no-comments { padding: 0; }');
addGlobalStyle('#panel-container .problem-edit .conversation.section .new-comment-form { padding: 0; }');
addGlobalStyle('#panel-container .problem-edit .conversation.section .new-comment-form textarea { resize: vertical; height: 110px; margin-bottom: 5px; padding: 3px 5px; font-size: 12px; }');
addGlobalStyle('#panel-container .btn { height: 20px; padding: 0px 10px;}');
addGlobalStyle('#panel-container .problem-edit .actions .content { padding: 2px 5px;}');
addGlobalStyle('#panel-container .problem-edit .actions .controls-container label { margin-bottom: 0px; line-height: 22px }');
addGlobalStyle('#panel-container .problem-edit .actions .navigation { margin-top: 5px;}');
addGlobalStyle('#panel-container .problem-edit .actions .controls-container { display: inline-flex; flex-wrap: wrap; margin-left: -3px; }');
} else {
addGlobalStyle('#panel-container .panel { font-size: inherit; line-height: inherit; }');
addGlobalStyle('#panel-container .problem-edit .header { padding: 10px 15px; line-height: 21px; }');
addGlobalStyle('#panel-container .problem-edit .problem-data .title { line-height: 40px; }');
addGlobalStyle('#panel-container .problem-edit .section .title { padding: 0 15px; }');
addGlobalStyle('#panel-container .problem-edit .section .content { padding: 15px; }');
addGlobalStyle('#WMEFP-UR-ALLPM { top: 10px !important; }');
addGlobalStyle('#panel-container .problem-edit .conversation.section .comment .comment-content { padding: 10px 15px 10px 15px; }');
addGlobalStyle('#panel-container .problem-edit .conversation.section .no-comments { padding: 15px; }');
addGlobalStyle('#panel-container .problem-edit .conversation.section .new-comment-form { padding: 15px 15px 10px 15px; }');
addGlobalStyle('#panel-container .problem-edit .conversation.section .new-comment-form textarea { resize: none; height: 70px; margin-bottom: 10px; padding: 6px 10px; font-size: 13px; }');
addGlobalStyle('#panel-container .btn { height: inherit; padding: 6px 20px;}');
addGlobalStyle('#panel-container .problem-edit .actions .content { padding: 15px;}');
addGlobalStyle('#panel-container .problem-edit .actions .controls-container label { margin-bottom: 12px; line-height: inherit; }');
addGlobalStyle('#panel-container .problem-edit .actions .navigation { margin-top: 10px;}');
addGlobalStyle('#panel-container .problem-edit .actions .controls-container { display: inherit; flex-wrap: inherit; margin-left: inherit; }');
}
}
function disableMapBlocker() {
logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
if (_cbDisableMapBlocker.checked) {
addGlobalStyle('#popup-overlay { width: 0%; height: 0%; }');
} else {
addGlobalStyle('#popup-overlay { width: 100%; height: 100%; }');
}
}
function narrowSidePanel() {
logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
if (_cbNarrowSidePanel.checked) {
addGlobalStyle('.row-fluid #sidebar { width: 250px; }');
addGlobalStyle('.col-fixed-330 { width: 250px; }');
if (document.body.dir != "rtl") {
addGlobalStyle('.show-sidebar .row-fluid .fluid-fixed { margin-left: 250px; }');
addGlobalStyle('.col-offset-330 { padding-left: 250px; }');
} else {
addGlobalStyle('.show-sidebar .row-fluid .fluid-fixed { margin-right: 250px; }');
addGlobalStyle('.col-offset-330 { padding-right: 250px; }');
}
addGlobalStyle('.edit-closure .form { padding: 2px; }');
addGlobalStyle('.edit-closure .date-input-group { width: 56%; }');
} else {
addGlobalStyle('.row-fluid #sidebar { width: 330px; }');
addGlobalStyle('.col-fixed-330 { width: 330px; }');
if (document.body.dir != "rtl") {
addGlobalStyle('.show-sidebar .row-fluid .fluid-fixed { margin-left: 330px; }');
addGlobalStyle('.col-offset-330 { padding-left: 330px; }');
} else {
addGlobalStyle('.show-sidebar .row-fluid .fluid-fixed { margin-right: 330px; }');
addGlobalStyle('.col-offset-330 { padding-right: 330px; }');
}
addGlobalStyle('.edit-closure .form { padding 15px; }');
addGlobalStyle('.edit-closure .date-input-group { width: 62%; }');
}
window.dispatchEvent(new Event('resize'));
}
function hideAveSpeedControls() {
logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
var controlPosition = 4;
if (window.location.hostname.startsWith('editor-beta')) controlPosition = 5;
if (_cbHideAveSpeedControls.checked) {
addGlobalStyle('#segment-edit-general > .side-panel-section.attributes-form > .form-group:nth-of-type(' + controlPosition + ') { display: none; }');
}else {
addGlobalStyle('#segment-edit-general > .side-panel-section.attributes-form > .form-group:nth-of-type(' + controlPosition + ') { display: inherit; }');
}
}
function addZoomIndicator() {
logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
if (_cbAddZoomIndicator.checked) {
addGlobalStyle('.slider { font-size: 15px; font-weight: 900; line-height: 1; height: 18px; margin-top: 23px; padding-top: 2px; text-align: center; }');
ZLI();
Waze.map.events.register("zoomend", null, ZLI);
} else {
addGlobalStyle('.slider { font-size: inherit; font-weight: inherit; line-height: inherit; height: 10px; margin-top: 27px; padding-top: inherit; text-align: inherit; }');
Waze.map.events.unregister("zoomend", null, ZLI);
slider.innerText = "";
slider.title = "";
}
}
function ZLI() {
var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
slider.innerText = Waze.map.zoom;
slider.title = "Zoom level indicator by WMEFU";
}
function shiftAerials() {
logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
// calculate meters/pixel for current map view
var ipu = OpenLayers.INCHES_PER_UNIT;
var metersPerPixel = Waze.map.getResolution() * ipu['m'] / ipu[Waze.map.getUnits()];
// Apply the shift and opacity
Waze.map.baseLayer.div.style.left = Math.round(getId("_inpASX").value / metersPerPixel) + 'px';
Waze.map.baseLayer.div.style.top = Math.round(- getId("_inpASY").value / metersPerPixel) + 'px';
Waze.map.baseLayer.div.style.opacity = getId("_inpASO").value/100;
}
//Helper functions
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) {
return;
}
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
function getElementsByClassName(classname, node) {
if(!node) node = document.getElementsByTagName("body")[0];
var a = [];
var re = new RegExp('\\b' + classname + '\\b');
var els = node.getElementsByTagName("*");
for (var i=0,j=els.length; i<j; i++)
if (re.test(els[i].className)) a.push(els[i]);
return a;
}
function getId(node) {
return document.getElementById(node);
}
function logit(msg, typ) {
if (!typ) {
console.log("WMEFU: " + msg);
} else {
switch(typ) {
case "error":
console.error("WMEFU: " + msg);
break;
case "warning":
console.warn("WMEFU: " + msg);
break;
case "info":
console.info("WMEFU: " + msg);
break;
case "info":
console.info("WMEFU: " + msg);
break;
case "debug":
if (debug) {
console.debug("WMEFU: " + msg);
}
break;
case "default":
console.log("WMEFU unknown message type: " + msg);
}
}
}
// Start it running
setTimeout(init1, 200);
})();