// ==UserScript==
// @name WME Fix UI
// @namespace https://greasyfork.org/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://beta.waze.com/editor*
// @include https://beta.waze.com/*/editor*
// @exclude https://www.waze.com/*user/editor/*
// @supportURL https://www.waze.com/forum/viewtopic.php?f=819&t=191178
// @version 2.6.1
// @grant none
// ==/UserScript==
// Thanks to (in no particular order)
// Bellhouse, Twister-UK, Timbones, Dave2084, Rickzabel, Glodenox,
// JJohnston84, SAR85, Cardyin, JustinS83, berestovskyy
(function()
{
// global variables
var wmefu_version = "2.6.1";
var oldVersion;
var prefix = "WMEFU";
var tabAttempts = 0;
var wmeFUAddon;
var debug = false;
var wmeFUinitialising = true;
var URLSegments;
var URLSegmentCount;
var UIver;
//Mutation Observer to re-hack buttons
var buttonObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
//do something
if ($(mutation.target).hasClass('waze-icon-reload')){
$('.waze-icon-reload').removeClass('reload');
$('.waze-icon-reload span').addClass('fa fa-refresh fa-lg');
$('.waze-icon-reload span')[0].innerHTML = "";
}
else if($(mutation.target).hasClass('waze-icon-undo')){
$('.waze-icon-undo').removeClass('undo');
$('.waze-icon-undo span').addClass('fa fa-undo fa-lg');
$('.waze-icon-undo span')[0].innerHTML = "";
}
else if($(mutation.target).hasClass('waze-icon-redo')){
$('.waze-icon-redo').removeClass('redo');
$('.waze-icon-redo span').addClass('fa fa-repeat fa-lg');
$('.waze-icon-redo span')[0].innerHTML = "";
}
else if($(mutation.target).is('#wecm-count')){
$('#wecm-count')[0].parentElement.style.marginTop = ['11px','5px','-1px'][_inpUICompression.value];
}
});
});
//Fix for date/time formats in WME released Oct/Nov 2016 - provided by Glodenox
I18n.translations[I18n.currentLocale()].time = {};
I18n.translations[I18n.currentLocale()].time.formats = {};
I18n.translations[I18n.currentLocale()].time.formats.long = "%a %b %d %Y, %H:%M";
I18n.translations[I18n.currentLocale()].date.formats = {};
I18n.translations[I18n.currentLocale()].date.formats.long = "%a %b %d %Y, %H:%M";
I18n.translations[I18n.currentLocale()].date.formats.default = "%a %b %d %Y";
if (I18n.currentLocale() == 'en-GB') {
I18n.translations['en-GB'].update_requests.panel.reported = 'Reported on: %{date}';
}
// Set the "Chat is here!" message to be hidden
if (localStorage.hiddenMessages) {
var hm = JSON.parse(localStorage.hiddenMessages);
if (hm.chat_intro_tip === false) {
logit("Hiding Chat is Here! message","info");
hm.chat_intro_tip = true;
localStorage.setItem('hiddenMessages', JSON.stringify(hm));
}
}
function init1() {
console.group(prefix + ": initialising...");
console.time(prefix + ": 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;
}
// identify WME version by checking for an item that no longer appears in the new version
UIver = ((document.getElementById("input-overlay") === null) ? "new" : "old");
// 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;
}
//test for 2017 UI
logit("UI version is " + UIver, "info");
// setup event handlers for my controls:
getId('_cbMoveZoomBar').onclick = moveZoomBar;
getId('_cbHideUserInfo').onclick = hideUserInfo;
getId('_cbHideAveSpeedControls').onclick = hideAveSpeedControls;
getId('_cbFixExternalProviders').onclick = fixExternalProviders;
getId('_cbMoveChatIcon').onclick = moveChatIcon;
getId('_cbDarkenSaveLayer').onclick = darkenSaveLayer;
getId('_cbShrinkTopBars').onclick = shrinkTopBars;
getId('_cbCompressSegmentTab').onclick = compressSegmentTab;
getId('_cbCompressLayersMenu').onclick = compressLayersMenu;
getId('_cbRestyleReports').onclick = restyleReports;
getId('_cbEnhanceChat').onclick = enhanceChat;
getId('_cbNarrowSidePanel').onclick = narrowSidePanel;
if (UIver=='new') {
getId("_inpUICompression").onchange = applyEnhancements;
getId("_inpUIContrast").onchange = applyEnhancements;
}
// getId('_cbAddzoomindicator').onclick = WaddZoomIndicator;
//x getId('_cbClickablePlaceAddress').onclick = hideAveSpeedControls;
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() {
getId("_inpASX").value = 0;
getId("_inpASY").value = 0;
shiftAerials();
};
getId("_inpGSVContrast").onchange = adjustGSV;
getId("_inpGSVBrightness").onchange = adjustGSV;
getId("_cbGSVInvert").onchange = adjustGSV;
//REGISTER WAZE EVENT HOOKS
// event to recreate my tab when MTE mode is exited
Waze.app.modeController.model.bind('change:mode', addMyTab);
// event to recreate my tab after changing WME units
Waze.prefs.on('change:isImperial', function() {
tabAttempts = 0;
tabsLooper();
});
// 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);
// event to deal with ASC controls and make place address clickable
Waze.selectionManager.events.register("selectionchanged", null, hideAveSpeedControls);
// events to change menu bar color based on map comments checkbox
Waze.map.events.register("zoomend", null, warnCommentsOff);
Waze.map.events.register("moveend", null, warnCommentsOff);
//window resize event to resize chat
window.addEventListener('resize', enhanceChat, true);
//event to re-hack toolbar buttons when exitine HN mode
W.editingMediator.on('change:editingHouseNumbers', function() {
if (W.editingMediator.attributes.editingHouseNumbers === false) {
setTimeout(hackToolbarButtons,5000);
}
});
// overload the window unload function to save my settings
window.addEventListener("beforeunload", saveSettings, false);
loadSettings();
// Add 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');
var extraCBSection = document.createElement('p');
extraCBSection.innerHTML = '<input type="checkbox" id="_cbextraCBSection" />';
brand.appendChild(extraCBSection);
getId('_cbextraCBSection').onclick = FALSEcompressSegmentTab;
getId('_cbextraCBSection').checked = getId('_cbCompressSegmentTab').checked;
}
// warn of permalink segments not all selected
URLSegments = window.location.search.match(new RegExp("[?&]segments?=([^&]*)"));
if (URLSegments) {
URLSegmentCount = URLSegments[1].split(',').length;
if (Waze.selectionManager.selectedItems.length > 0) {
permalinkCheck();
} else {
Waze.selectionManager.events.register("selectionchanged", null, permalinkCheck);
}
}
// Alert to new version
if (oldVersion != wmefu_version) {
alert("WME Fix UI has been updated to version " + wmefu_version + "\n" +
ChromeWarning() +
"\n" +
"Version 2.6.1 - 2017-11-29\n" +
"* Minor tweaks for Chat enhancement\n" +
"* Turn off Chat enhancement when WME Chat UI Fix is detected\n" +
"* Minor bug fixes/fix attempts\n" +
"\n" +
"Previous V2 highlights:\n" +
"* 2.6 New Chat enhancements for the Chat panel\n" +
"* 2.5 UR/MP panel enhancement re-written for new WME UI\n" +
"* 2.5 Narrow Side Panel re-written for new WME UI\n" +
"* 2.4 Top bar compression/enhancement re-written for new WME UI\n" +
"* 2.4 Recovery from unit change & house number mode implemented\n" +
"* 2.3 The zoom bar is back, with permanent level indicator\n" +
"* 2.2 Place details enhancement re-written for new WME UI\n" +
"* 2.2 New option to darken screen overlay when saving\n" +
// "* 2.1 Settings not updated for new WME UI will be turned off on script update\n" +
// ((getId("_cbNarrowSidePanel").checked === true) ? " * Reduce width of side panel turned off - not yet working properly in WME V2\n" : "") +
"* 2.0 New operation with variable & independent compression/contrast control\n" +
"* 2.0 Handling of Feed, Drives and Areas re-written for new WME UI\n" +
"* 2.0 Segment edit panel handling re-written for new UI\n" +
"");
saveSettings();
// if (getId("_cbNarrowSidePanel").checked === true) getId("_cbNarrowSidePanel").checked = false;
}
// fix for sidebar display problem in Safari, requested by edsonajj
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
if (isSafari) {
addGlobalStyle('.flex-parent { height: 99% !important; }');
}
// apply the settings
shiftAerials();
setTimeout(applyAllSettings, 2000);
logit("Initialisation complete");
console.timeEnd(prefix + ": initialisation time");
console.groupEnd();
//GPS fucking about
// addGlobalStyle('#OpenLayers\\2e Layer\\2e XYZ_212 { z-index: 334 !important; }');
}
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.style.lineHeight = "16px";
section.id = "fuContent";
section.innerHTML = "";
section.innerHTML += '<b>UI Fixes/changes</b><br>';
section.innerHTML += '<input type="checkbox" id="_cbMoveZoomBar" /> ' +
'<span title="Because nobody likes a pointless UI change that breaks your workflow,\nimposed by idiots who rarely use the editor and don\'t listen to feedback">Move and restore zoom bar</span><br>';
// section.innerHTML += '<input style="display:none" 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\nwasted 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="_cbHideAveSpeedControls" /> ' +
'<span title="If you don\'t have these in your country, YOU\'RE LUCKY!\nBut don\'t forget you\'ve disabled this - they\'ll be coming soon!">Hide average speed camera controls</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbFixExternalProviders" /> ' +
'<span title="The External Providers interface has a dexcription box that will only show one live of text.\nThis fixes that.">Expand External Provider details for places</span><br>';
//x section.innerHTML += '<input type="checkbox" id="_cbClickablePlaceAddress" /> ' +
//x '<span title="For segments, the entire address is a clickable button to edit - for places, only the small pencil icon. \nThis fixes that inconsistency and also gives the correct mouse pointer.">Make the entire place address clickable</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbPermalinkChecker" /> ' +
'<span title="If a permalink is created with off-screen segments or segment IDs have been changed,\nWME may open with fewer segments selected than are included in the permalink.\nThis causes a pop-up warning when that happens.">Warn on invalid permalinks</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbMoveChatIcon" /> ' +
'<span title="Here\'s a truly outstanding example of making a stupid change to the UI in order to\ndeal with another stupid change to the UI!\nBecause HQ couldn\'t make the new layers menu auto-hide, they moved the chat icon.\nTick this box to put it back where it belongs.">Move Chat icon back to right</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbLayersMenuMoreOptions" /> ' +
'<span title="As requested by users, this option turns on the More Options in the Layers menu.\nNote that this option only has an effect when the page is loaded. You can still toggle as normal.">Turn on More Options in Layers menu</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbDarkenSaveLayer" /> ' +
'<span title="It\'s not bad enough they\'ve removed all the contrast to give you eyestrain,\nbut then they blind you every time you save. ">Darken screen overlay when saving</span><br>';
section.innerHTML += '<br>';
section.innerHTML += '<b>UI Enhancements</b><br>';
section.innerHTML += '<input type="checkbox" id="_cbShrinkTopBars" /> ' +
'<span title="Because we can\'t afford to waste screen space, particularly on\nstuff we didn\'t ask for and don\'t want, like the black bar.\nAnd why does the reload button have a re-do icon?!">Compress/enhance bars 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' + (UIver=='new' ? '/enhance' : '') + ' side panel contents</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbCompressLayersMenu" /> ' +
'<span title="Because it\'s already too big for small screens and Waze only plan to make it bigger">Compress' + (UIver=='new' ? '/enhance' : '') + ' layers menu</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbRestyleReports" /> ' +
'<span title="Another UI element configured for developers with massive screens instead of normal users">Compress' + (UIver=='new' ? '/enhance' : '') + ' report panels (UR/MP)</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbEnhanceChat" /> ' +
'<span title="A perfect example of the new WME UI. Looks very stylish,\nbut destroys usability and utterly ignores small-screen users.">Compress/enhance Chat panel</span><br>';
section.innerHTML += '<input type="checkbox" id="_cbNarrowSidePanel" /> ' +
'<span title="If you have a netbook, Waze isn\'t interested in your experience.\nYou 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>';
if (UIver == "new") {
section.innerHTML += '<br>';
section.innerHTML += '<b title="Control the amount of compression/enhancment">UI Enhancement controls<br>';
section.innerHTML += '<div style="display:inline-block"><input type="number" id="_inpUICompression" title="Compression enhancement" max=2 min=0 step=1 style="height:20px; width:35px;text-align:center;"/> <span class="fa fa-compress"></span></div> ';
section.innerHTML += '<div style="display:inline-block"><input type="number" id="_inpUIContrast" title="Contrast enhancement" max=2 min=0 step=1 style="height:20px; width:35px;text-align:center;"/> <span class="fa fa-adjust"></span></div>';
section.innerHTML += '<br>';
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 title="Adjust contrast & brightness for Google Street View images">GSV image adjust</b><br>';
section.innerHTML += '<span title="Contrast"><input type="number" id="_inpGSVContrast" max=200 min=0 step=25 style="height:20px; width:47px;text-align:right;"/><b>%</b><span class="fa fa-adjust"></span></span> ';
section.innerHTML += '<span title="Brightness"><input type="number" id="_inpGSVBrightness" max=200 min=0 step=25 style="height:20px; width:47px;text-align:right;"/><b>%</b><span class="fa fa-sun-o"></span></span> ';
section.innerHTML += '<span title="Invert colours"><input type="checkbox" id="_cbGSVInvert"/><span class="fa fa-tint"></span></span>';
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);
if (_cbShrinkTopBars.checked === true) {
hackToolbarButtons();
}
}
}
function loadSettings() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
// Convert old version of settings to new version
var options;
if (localStorage.WMEFixUI) {
var oldSettings = JSON.parse(localStorage.WMEFixUI);
var newSettings = {};
newSettings.oldVersion = (oldSettings[0] ? oldSettings[0] : "1.0" );
newSettings.moveZoomBar = (oldSettings[1] ? oldSettings[1] : true );
newSettings.shrinkTopBars = (oldSettings[2] ? oldSettings[2] : true );
newSettings.hideUserInfo = (oldSettings[3] ? oldSettings[3] : true );
newSettings.restyleSidePanel = (oldSettings[4] ? oldSettings[4] : true );
newSettings.restyleReports = (oldSettings[5] ? oldSettings[5] : true );
newSettings.narrowSidePanel = (oldSettings[7] ? oldSettings[7] : false );
newSettings.hideASCControls = (oldSettings[8] ? oldSettings[8] : false );
// newSettings.addZoomIndicator = (oldSettings[9] ? oldSettings[9] : true );
newSettings.aerialShiftX = (oldSettings[10] ? oldSettings[10] : 0 );
newSettings.aerialShiftY = (oldSettings[11] ? oldSettings[11] : 0 );
newSettings.aerialOpacity = (oldSettings[12] ? oldSettings[12] : 100 );
newSettings.fixExternalProviders = (oldSettings[13] ? oldSettings[13] : true );
newSettings.GSVContrast = (oldSettings[14] ? oldSettings[14] : 100 );
newSettings.GSVBrightness = (oldSettings[15] ? oldSettings[15] : 100 );
newSettings.GSVInvert = (oldSettings[16] ? oldSettings[16] : false );
//x newSettings.clickablePlaceAddress = (oldSettings[17] ? oldSettings[17] : true );
newSettings.permalinkChecker = (oldSettings[18] ? oldSettings[18] : true );
newSettings.restyleLayersMenu = (oldSettings[19] ? oldSettings[19] : true );
newSettings.moveChatIcon = (oldSettings[20] ? oldSettings[20] : true );
// setting[21] was Menu Autohide - no longer needed
newSettings.layersMenuMore = (oldSettings[22] ? oldSettings[22] : true );
localStorage.WMEFUSettings = JSON.stringify(newSettings);
localStorage.removeItem("WMEFixUI");
}
if (localStorage.WMEFUSettings) {
options = JSON.parse(localStorage.WMEFUSettings);
} else {
options = {};
}
oldVersion = (options.oldVersion !== undefined ? options.oldVersion : "0.0");
getId('_cbMoveZoomBar').checked = (options.moveZoomBar !== undefined ? options.moveZoomBar : true);
getId('_cbShrinkTopBars').checked = (options.shrinkTopBars !== undefined ? options.shrinkTopBars : true);
getId('_cbHideUserInfo').checked = ( options.hideUserInfo !== undefined ? options.hideUserInfo : true);
getId('_cbCompressSegmentTab').checked = ( options.restyleSidePanel !== undefined ? options.restyleSidePanel : true);
getId('_cbRestyleReports').checked = ( options.restyleReports !== undefined ? options.restyleReports : true);
getId('_cbEnhanceChat').checked = ( options.enhanceChat !== undefined ? options.enhanceChat : true);
getId('_cbNarrowSidePanel').checked = ( options.narrowSidePanel !== undefined ? options.narrowSidePanel : false);
getId('_cbHideAveSpeedControls').checked = ( options.hideASCControls !== undefined ? options.hideASCControls : false);
// getId('_cbAddZoomIndicator').checked = ( options.addZoomIndicator !== undefined ? options.addZoomIndicator : true);
getId('_inpASX').value = ( options.aerialShiftX !== undefined ? options.aerialShiftX : 0);
getId('_inpASY').value = ( options.aerialShiftY !== undefined ? options.aerialShiftY : 0);
getId('_inpASO').value = ( options.aerialOpacity !== undefined ? options.aerialOpacity : 100);
getId('_cbFixExternalProviders').checked = ( options.fixExternalProviders !== undefined ? options.fixExternalProviders : true);
getId('_inpGSVContrast').value = ( options.GSVContrast !== undefined ? options.GSVContrast : 100);
getId('_inpGSVBrightness').value = ( options.GSVBrightness !== undefined ? options.GSVBrightness : 100);
getId('_cbGSVInvert').checked = ( options.GSVInvert !== undefined ? options.GSVInvert : false);
//x getId('_cbClickablePlaceAddress').checked = ( options.clickablePlaceAddress !== undefined ? options.clickablePlaceAddress : true);
getId('_cbPermalinkChecker').checked = ( options.permalinkChecker !== undefined ? options.permalinkChecker : true);
getId('_cbCompressLayersMenu').checked = ( options.restyleLayersMenu !== undefined ? options.restyleLayersMenu : true);
getId('_cbMoveChatIcon').checked = ( options.moveChatIcon !== undefined ? options.moveChatIcon : true);
getId('_cbDarkenSaveLayer').checked = ( options.darkenSaveLayer !== undefined ? options.darkenSaveLayer : true);
getId('_cbLayersMenuMoreOptions').checked = ( options.layersMenuMore !== undefined ? options.layersMenuMore : true);
if (UIver == "new") {
getId('_inpUIContrast').value = ( options.UIContrast !== undefined ? options.UIContrast : 1);
getId('_inpUICompression').value = ( options.UICompression !== undefined ? options.UICompression : 1);
}
}
function saveSettings() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
if (localStorage) {
logit("saving options to local storage");
var options = {};
options.oldVersion = wmefu_version;
options.moveZoomBar = getId('_cbMoveZoomBar').checked;
options.shrinkTopBars = getId('_cbShrinkTopBars').checked;
options.hideUserInfo = getId('_cbHideUserInfo').checked;
options.restyleSidePanel = getId('_cbCompressSegmentTab').checked;
options.restyleReports = getId('_cbRestyleReports').checked;
options.enhanceChat = getId('_cbEnhanceChat').checked;
options.narrowSidePanel = getId('_cbNarrowSidePanel').checked;
options.hideASCControls = getId('_cbHideAveSpeedControls').checked;
// options.addZoomIndicator = getId('_cbAddZoomIndicator').checked;
options.aerialShiftX = getId('_inpASX').value;
options.aerialShiftY = getId('_inpASY').value;
options.aerialOpacity = getId('_inpASO').value;
options.fixExternalProviders = getId('_cbFixExternalProviders').checked;
options.GSVContrast = getId('_inpGSVContrast').value;
options.GSVBrightness = getId('_inpGSVBrightness').value;
options.GSVInvert = getId('_cbGSVInvert').checked;
//x options.clickablePlaceAddress = getId('_cbClickablePlaceAddress').checked;
options.permalinkChecker = getId('_cbPermalinkChecker').checked;
options.restyleLayersMenu = getId('_cbCompressLayersMenu').checked;
options.moveChatIcon = getId('_cbMoveChatIcon').checked;
options.darkenSaveLayer = getId('_cbDarkenSaveLayer').checked;
options.layersMenuMore = getId('_cbLayersMenuMoreOptions').checked;
if (UIver == "new") {
options.UIContrast = getId('_inpUIContrast').value;
options.UICompression = getId('_inpUICompression').value;
}
localStorage.WMEFUSettings = JSON.stringify(options);
}
}
function applyAllSettings() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
console.group(prefix + ": applying all settings");
moveZoomBar();
shrinkTopBars();
hideUserInfo();
compressSegmentTab();
restyleReports();
enhanceChat();
narrowSidePanel();
hideAveSpeedControls();
fixExternalProviders();
// addZoomIndicator();
warnCommentsOff();
adjustGSV();
compressLayersMenu();
moveChatIcon();
darkenSaveLayer();
console.groupEnd();
if (getId('_cbLayersMenuMoreOptions').checked === true) {
$("#toolbar > div > div.layer-switcher-container > div > div > div > div > div.menu > div.more-options-toggle > label > div").click();
}
wmeFUinitialising = false;
saveSettings();
}
function applyEnhancements() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
shrinkTopBars();
compressSegmentTab();
restyleReports();
enhanceChat();
compressLayersMenu();
}
function moveZoomBar() {
// Now functioning correctly for prod & beta
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
if (_cbMoveZoomBar.checked) {
var styles = "";
if (UIver == "old") {
styles += '.olControlPanZoomBar { left: 10px; width: 30px; }';
// shift UR/MP panel to the right
styles += '#panel-container > div { left: 40px; }';
} else {
styles += '.olControlPanZoomBar { left: 10px; top: 35px; height: 158px; border-width: 1px; }';
styles += '.zoom-minus-button { top: 0px !important; }';
styles += '.slider-stops { display: inherit; width: 24px; height: 109px !important; }';
styles += '.slider { font-size: 15px; font-weight: 900; line-height: 1; height: 18px; margin-top: 19px; padding-top: 1px; width: 24px; border: 1px solid lightgrey; text-align: center; }';
styles += '.street-view-control-container { bottom: -40px; margin-right: -3px; }';
styles += '.geolocation-control-container { bottom: -79px; margin-right: -3px; id: "WMEFU"; }';
// fix for WME Map Tiles Update script
styles += '#Info_div { margin-top: 89px !important; margin-left: 2px !important; }';
// fix for WME BeenHere - old but I still use it :)
styles += '#BeenHere { top: 310px !important; }';
// shift UR/MP panel to the right
styles += '#panel-container > div { left: 40px; }';
Waze.map.events.register("zoomend", null, ZLI);
ZLI();
}
addStyle(prefix + fname,styles);
} else {
var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
removeStyle(prefix + fname);
Waze.map.events.unregister("zoomend", null, ZLI);
slider.innerText = "";
slider.title = "";
}
}
function hideUserInfo() {
// Now functioning correctly for prod & beta
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
var styles = "";
// 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) {
styles += '#user-box { display: none; }';
// extra fix for WME Panel Swap control (not working with new WME UI)
if (PSButton1) { PSButton1.style.top = '-27px'; }
if (PSButton2) { PSButton2.style.top = '-27px'; }
addStyle(prefix + fname,styles);
//Fix to move control button of Invalidated Camera Mass Eraser
if (getId("_UCME_btn")) {
var but = getId("_UCME_btn");
var dest = getId("advanced-tools");
getId("advanced-tools").appendChild(getId("_UCME_btn"));
document.getElementById('UCME_btn').parentNode.removeChild(document.getElementById('UCME_btn'));
}
} else {
if (PSButton1) { PSButton1.style.top = '0px'; }
if (PSButton2) { PSButton2.style.top = '0px'; }
removeStyle(prefix + fname);
}
}
function shrinkTopBars() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
var styles = "";
if (_cbShrinkTopBars.checked) {
//always do this stuff
//event mode button
styles += '#mode-switcher .title-button .icon { font-size: 13px; font-weight: bold; color: black; }';
//black bar
styles += '#topbar-container { pointer-events: none; }';
styles += '#map #topbar-container .topbar > div { pointer-events: initial; }';
//change toolbar buttons - from JustinS83
$('#mode-switcher .title-button .icon').removeClass('fa fa-angle-down');
$('#mode-switcher .title-button .icon').addClass('fa fa-calendar');
hackToolbarButtons();
// HN editing tweaks
styles += '#map-lightbox .content { pointer-events: none; }';
styles += '#map-lightbox .content > div { pointer-events: initial; }';
styles += '#map-lightbox .content .header { pointer-events: none !important; }';
styles += '.toolbar .toolbar-button.add-house-number { background-color: #61cbff; float: right; font-weight: bold; }';
styles += '.waze-icon-exit { background-color: #61cbff; font-weight: bold; }';
// event mode button
styles += '.toolbar.toolbar-mte .add-button { background-color: orange; font-weight: bold; }';
var contrast = _inpUIContrast.value;
var compress = _inpUICompression.value;
if (compress > 0) {
styles += '#app-head { height: ' + ['','35px','24px'][compress] + '; }';
styles += '#app-head aside #brand { height: ' + ['','34px','22px'][compress] + '; padding-left: ' + ['','10px','5px'][compress] + '; }';
styles += '.toolbar { height: ' + ['','35px','24px'][compress] + '; }';
styles += '#mode-switcher .title-button .icon { line-height: ' + ['','34px','22px'][compress] + '; }';
//search box
styles += '#search { padding-top: ' + ['','3px','0px'][compress] + '; }';
styles += '.form-search { height: ' + ['','27px','20px'][compress] + '; }';
styles += '.form-search .search-query { height: ' + ['','26px','19px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
styles += '.form-search .input-wrapper::after { top: ' + ['','6px','2px'][compress] + '; }';
//toolbar dropdown menus
//Toolbox switcher
styles += '#toolbox-switcher .toolbar-button { margin-top: 0px; line-height: ' + ['','34px','22px'][compress] + '; }';
styles += '#toolbox-switcher .fa { margin-right: ' + ['','5px','0px'][compress] + ' !important; }';
//Toolbox menu
styles += '.toolbox-dropdown-menu { top: ' + ['','17px','12px'][compress] + ' !important; }';
//toolbar dropdowns
styles += '.toolbar .toolbar-group { margin-right: ' + ['','14px','8px'][compress] + '; }';
styles += '.toolbar .toolbar-icon { width: ' + ['','31px','22px'][compress] + '; height: ' + ['','34px','22px'][compress] + '; line-height: ' + ['','34px','22px'][compress] + '; }';
styles += '.toolbar .group-title { height: ' + ['','34px','22px'][compress] + '; line-height: ' + ['','34px','22px'][compress] + '; margin-left: ' + ['','31px','22px'][compress] + '; }';
styles += '.toolbar .dropdown-menu { top: ' + ['','34px','22px'][compress] + ' !important; left: ' + ['','7px','4px'][compress] + ' !important; }';
//toolbar buttons
styles += '#edit-buttons > div > .toolbar-button { margin-top: ' + ['','3px','1px'][compress] + '; margin-left: 3px; padding-left: ' + ['','10px','5px'][compress] + '; padding-right: ' + ['','10px','5px'][compress] + '; height: ' + ['','27px','22px'][compress] + '; line-height: ' + ['','27px','22px'][compress] + '; }';
//keep save button wide enough for counter
styles += '.toolbar .toolbar-button.waze-icon-save { padding-right: 15px !important; }';
styles += '.toolbar .toolbar-button.waze-icon-save .counter { top: ' + ['','-3px','-1px'][compress] + '; }';
styles += '#edit-buttons > div > .toolbar-button > .item-icon { top: ' + ['','5px','2px'][compress] + '; }';
styles += '.toolbar .toolbar-separator { height: ' + ['','34px','22px'][compress] + '; }';
//layers menu
styles += '.waze-icon-layers { height: ' + ['','27px','22px'][compress] + ' !important; margin-top: ' + ['','3px','0px'][compress] + ' !important; }';
styles += '.layer-switcher .menu { top: ' + ['','31px','24px'][compress] + '; }';
// fix for WME Edit Count Monitor
styles += '#edit-buttons > div > div:nth-child(10) { margin-top: ' + ['','5px','-1px'][compress] + ' !important; }';
//black bar
styles += '.topbar { height: ' + ['','24px','18px'][compress] + '; line-height: ' + ['','24px','18px'][compress] + '; }';
}
if (contrast > 0) {
//toolbar dropdown menus
styles += '.toolbar .group-title { color: black; }';
styles += '#edit-buttons > div > .toolbar-button { border-radius: 8px; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; color: black; }';
//layers icon - until Waze fix it
styles += '.layer-switcher .waze-icon-layers.toolbar-button{ background-color: white; }';
}
//Toolbox width override - can go with next TB update
styles += '#edit-buttons { width: unset !important; }';
// //fix for buttons of WME GIS script
// styles += '.btn-group-sm { text-shadow: initial; background: white; }';
addStyle(prefix + fname,styles);
} else {
removeStyle(prefix + fname);
//change toolbar buttons - from JustinS83
$('#mode-switcher .title-button .icon').removeClass('fa fa-calendar');
$('#mode-switcher .title-button .icon').addClass('fa fa-angle-down');
//un-hack Toolbar buttons
if (document.getElementsByClassName("waze-icon-reload").length > 0) {
$('.waze-icon-reload span').removeClass('fa fa-refresh fa-lg');
$('.waze-icon-reload').addClass('reload');
$('.waze-icon-reload span')[0].innerHTML = "Reload";
}
if (document.getElementsByClassName("waze-icon-undo").length > 0) {
$('.waze-icon-undo span').removeClass('fa fa-undo fa-lg');
$('.waze-icon-undo').addClass('undo');
$('.waze-icon-undo span')[0].innerHTML = "Undo";
}
if (document.getElementsByClassName("waze-icon-redo").length > 0) {
$('.waze-icon-redo span').removeClass('fa fa-repeat fa-lg');
$('.waze-icon-redo').addClass('redo');
$('.waze-icon-redo span')[0].innerHTML = "Redo";
}
buttonObserver.disconnect();
}
window.dispatchEvent(new Event('resize'));
}
function hackToolbarButtons() {
if (document.getElementsByClassName("waze-icon-reload").length > 0) {
$('.waze-icon-reload').removeClass('reload');
$('.waze-icon-reload span').addClass('fa fa-refresh fa-lg');
$('.waze-icon-reload span')[0].innerHTML = "";
}
if (document.getElementsByClassName("waze-icon-undo").length > 0) {
$('.waze-icon-undo').removeClass('undo');
$('.waze-icon-undo span').addClass('fa fa-undo fa-lg');
$('.waze-icon-undo span')[0].innerHTML = "";
}
if (document.getElementsByClassName("waze-icon-redo").length > 0) {
$('.waze-icon-redo').removeClass('redo');
$('.waze-icon-redo span').addClass('fa fa-repeat fa-lg');
$('.waze-icon-redo span')[0].innerHTML = "";
}
buttonObserver.observe(getId('edit-buttons'), { childList: true, subtree: true });
}
function FALSEcompressSegmentTab() {
_cbCompressSegmentTab.checked = _cbextraCBSection.checked;
compressSegmentTab();
}
function compressSegmentTab() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
var styles = "";
if (_cbCompressSegmentTab.checked) {
// shrink address
if (UIver == "old") {
styles += '#edit-panel .primary-street { font-size: 14px; line-height: 15px; font-weight: 600; color: black; }';
styles += '#edit-panel .address-edit-view .preview .address-edit-btn:not(.disabled) { background-color: #FFF9C4; }';
styles += '#edit-panel .segment .address-edit-view, .edit-panel .segment .address-edit-view { margin-bottom: 5px; }';
//shrink tabs
styles += '#sidebar .nav-tabs>li {margin-top: 2px; }';
styles += '#sidebar .nav-tabs li a { padding: 2px; }';
styles += '#sidebar .nav-tabs { margin: 0 0 5px 0; padding-left: 4px; }';
//reduce some vertical margins
styles += '#edit-panel .contents { padding: 0 5px 0 5px; overflow: hidden; }';
styles += '#edit-panel .form-group { margin-bottom: 2px; line-height: 1; font-size: 11px; }';
styles += '#edit-panel .selection { margin-bottom: 5px; }';
styles += '#sidebar .side-panel-section:not(:last-child) { margin-bottom: 2px; }';
styles += '#sidebar .side-panel-section:not(:last-child)::after { margin-top: 5px; margin-bottom: 2px; }';
styles += '#edit-panel .control-label { margin-bottom: 1px; }';
styles += '#sidebar .controls-container { padding-top: 2px; }';
styles += '#edit-panel .segment .speed-limit label { margin-bottom: 0px; }';
styles += '#edit-panel .more-actions { padding-top: 2px; }';
styles += '#edit-panel .segment .speed-limit .direction-label, #edit-panel .segment .speed-limit .unit-label { line-height: 2.1em; }';
styles += '#sidebar .side-panel-section~.side-panel-section:not(:last-child):before { margin: 5px -20px !important; }';
styles += '#sidebar .side-panel-section~.side-panel-section:not(:last-child) { margin-top: 5px !important; }';
//shrink dropdown controls & buttons
styles += '#edit-panel button, #edit-panel select, #edit-panel .form-control { font-size: 11px; height: 19px; padding: 0px 4px; }';
styles += '#edit-panel .more-actions button:not(:last-of-type) { margin-bottom: 2px; }';
styles += '.edit-closure .input-group-addon { padding: 2px 8px; }';
//fit road property checkboxes on one line for all three (if text length allows)
styles += '#edit-panel .controls-container { display: inline-block; }';
styles += '#edit-panel .controls-container label { font-size: 12px; line-height: 18px; padding-left: 22px; }';
styles += '#edit-panel .select-entire-street { width: 49%; overflow: hidden; }';
styles += '#edit-panel .edit-house-numbers { width: 49%; overflow: hidden; }';
styles += '#edit-panel .action-button { color: black; }';
styles += '#edit-panel .categories .select2-container { margin-bottom: -5px; }';
//tweak for speed camera checkbox having a left margin of -20px. Why?!
styles += '#edit-panel .checkbox, .radio { margin-left: 20px; }';
//tweaks for Closures tab
styles += '#edit-panel .segment .segment-details { margin-bottom: 4px; }';
styles += '.closures-list .closure-item .section { padding: 2px; }';
styles += '.col-xs-6 { line-height: 14px; }';
styles += '.closures-list .direction { margin-bottom: 0px; }';
styles += '.closures-list .closure-item:not(:last-child) { margin-bottom: 4px; }';
//tweak required for Speedhelper script
styles += 'div[id^="spd_"] { line-height: 1.43; }';
//tweaks for Feed tab
styles += '.feed-item { margin-bottom: 2px; }';
styles += '.feed-item .inner { padding: 2px; }';
styles += '.feed-item .delete { zoom: 149%; }';
styles += '.feed-item .motivation { margin-bottom: 0px; }';
styles += '.feed-item .content .title { margin-bottom: 0px; }';
styles += '.feed-item .content .subtext { font-size: 11px; }';
//tweaks for Drives tab
styles += '#sidebar .message { margin-bottom: 0px; line-height: 14px; }';
styles += '#sidebar .result-list .result { padding: 2px 5px; }';
//tweaks for Restrictions dialogue
styles += '#schedule-modal .modal-body { padding: 2px 8px; }';
styles += '#schedule-modal .items { line-height: 0.5; }';
styles += '#schedule-modal .table { margin-bottom: 10px; }';
styles += '#schedule-modal .no-restrictions { margin-bottom: 10px; }';
styles += '#schedule-modal .well { padding: 5px; }';
styles += '#schedule-modal .edit-restriction .section { margin-bottom: 2px; padding: 0 2px; }';
styles += '#schedule-modal .nav>li>a { padding: 2px 15px; }';
styles += '#schedule-modal .btn { height: 22px; padding: 2px 15px; }';
//tweaks for Map Comments
styles += '.map-comment-feature-editor .conversation-region, .map-comment-feature-editor .name-editor-region { margin-left: -17px; margin-right: -5px; }';
if (_cbNarrowSidePanel.checked) {
styles += '.map-comment-feature-editor .conversation-view .new-comment-text { resize: both; max-width: 230px; }';
} else {
styles += '.map-comment-feature-editor .conversation-view .new-comment-text { resize: both; max-width: 310px; }';
}
//tweaks for History
styles += '.toggleHistory { padding: 2px 12px 7px 12px; }';
styles += '.tx-header { padding: 2px 15px 2px 15px !important; }';
styles += '.tx-author-date { margin-bottom: 2px !important; }';
styles += '.element-history-item { font-size: 11px; }';
styles += '.tx-content { padding: 2px 15px 2px 15px !important; }';
styles += '.tx-changed-ro:not(:last-child) { margin-bottom: 2px; }';
styles += '.tx-changed-attribute .ca-name { margin-bottom: 2px; }';
styles += '.tx-changed-attribute:not(:last-child) {margin-bottom: 2px; }';
} else {
//For new WME version
var contrast = _inpUIContrast.value;
var compress = _inpUICompression.value;
if (compress > 0) {
//general compression enhancements
styles += '#sidebar #advanced-tools { padding: ' + ['','0 9px','0 4px'][compress] + '; }';
styles += '#sidebar waze-staff-tools { margin-bottom: ' + ['','9px','4px'][compress] + '; }';
styles += '#sidebar .tab-content { padding: ' + ['','9px','4px'][compress] + '; }';
//Tabs
styles += '#sidebar #user-info #user-tabs { padding: ' + ['','0 9px','0 4px'][compress] + '; }';
styles += '#sidebar .nav-tabs li a { margin-top: ' + ['','2px','1px'][compress] + '; margin-left: ' + ['','3px','1px'][compress] + '; padding-top: 0px !important; line-height: ' + ['','24px','21px'][compress] + '; height: ' + ['','24px','21px'][compress] + '; }';
styles += '#sidebar .nav-tabs li { flex-grow: 0; }';
//Feed
styles += '.feed-item { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
styles += '.feed-item .inner { padding: ' + ['','5px','0px'][compress] + '; }';
styles += '.feed-item .content .title { margin-bottom: ' + ['','1px','0px'][compress] + '; }';
styles += '.feed-item .motivation { margin-bottom: ' + ['','2px','0px'][compress] + '; }';
//Drives & Areas
styles += '#sidebar .message { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
styles += '#sidebar .result-list .result { padding: ' + ['','6px 17px','2px 9px'][compress] + '; margin-bottom: ' + ['','3px','1px'][compress] + '; }';
//SEGMENT EDIT PANEL
//general changes
//checkbox groups
styles += '#sidebar .controls-container { padding-top: ' + ['','4px','1px'][compress] + '; display: inline-block; font-size: ' + ['','12px','11px'][compress] + '; }';
//form groups
styles += '#sidebar .form-group { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
//dropdown inputs
styles += '#sidebar .form-control { height: ' + ['','28px','21px'][compress] + '; padding-top: ' + ['','4px','0px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; color: black; }';
//buttons
styles += '#edit-panel .waze-btn { padding-top: ' + ['','3px','1px'][contrast] + '; padding-bottom: ' + ['','3px','1px'][contrast] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
//radio button controls
styles += '.waze-radio-container label { height: ' + ['','19px','16px'][compress] + '; width: ' + ['','19px','16px'][compress] + '; line-height: ' + ['','19px','16px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; margin-bottom: ' + ['','3px','1px'][compress] + '; }';
//specific changes
//Selected segments info
styles += '#edit-panel .selection { padding-top: ' + ['','8px','2px'][compress] + '; padding-bottom: ' + ['','8px','4px'][compress] + '; }';
styles += '#edit-panel .segment .direction-message { margin-bottom: ' + ['','9px','3px'][compress] + '; }';
//Segment details (closure warning)
styles += '#edit-panel .segment .segment-details { padding: ' + ['','10px','5px'][compress] + '; padding-top: 0px; }';
//All control labels
styles += '#edit-panel .control-label { font-size: ' + ['','11px','10px'][compress] + '; margin-bottom: ' + ['','4px','2px'][compress] + '; }';
//Address input
styles += '#edit-panel .address-edit-view { cursor: pointer; margin-bottom: ' + ['','6px','2px'][compress] + '; }';
styles += '#edit-panel .address-edit-input { padding: ' + ['','4px','1px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
styles += '.tts-button { height: ' + ['','28px','21px'][compress] + '; }';
//speed limit controls
styles += '#edit-panel .segment .speed-limit .form-control { height: ' + ['','23px','19px'][compress] + '; padding-top: ' + ['','4px','2px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; width: 5em; }';
styles += '#edit-panel .segment .speed-limit .direction-label { font-size: ' + ['','12px','11px'][compress] + '; line-height: ' + ['','2.0em','1.8em'][compress] + '; }';
styles += '#edit-panel .segment .speed-limit .unit-label { font-size: ' + ['','12px','11px'][compress] + '; line-height: ' + ['','2.0em','1.8em'][compress] + '; padding-right: ' + ( (getId('_cbNarrowSidePanel').checked === true) ? '50px' : '130px' ) + '; }';
//more actions section
styles += '#edit-panel .more-actions { padding-top: ' + ['','6px','2px'][compress] + '; }';
styles += '#edit-panel .more-actions .waze-btn.waze-btn-white { height: ' + ['','28px','21px'][compress] + '; line-height: ' + ['','25px','18px'][compress] + '; padding-left: 0px; padding-right: 0px; }';
//get more-actions buttons on one line
styles += '#edit-panel .more-actions { display: inline-flex; }';
styles += '#edit-panel .action-button { width: 155px; overflow: hidden; }';
styles += '#edit-panel .action-button:before { margin-right: 0px !important; }';
styles += '#edit-panel .more-actions .edit-house-numbers-btn-wrapper { margin-top: 0px; }';
//additional attributes
styles += '#edit-panel .additional-attributes { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
//history items
styles += '.toggleHistory { padding: ' + ['','7px','3px'][compress] + '; }';
styles += '.element-history-item:not(:last-child) { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
styles += '.element-history-item .tx-header { padding: ' + ['','6px','2px'][compress] + '; }';
styles += '.element-history-item .tx-header .tx-author-date { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
styles += '.element-history-item .tx-content { padding: ' + ['','7px 7px 7px 22px','4px 4px 4px 22px'][compress] + '; }';
styles += '.loadMoreContainer { padding: ' + ['','5px 0px','3px 0px'][compress] + '; }';
//closures list
styles += '.closures-list .closure-item:not(:last-child) { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
styles += '.closures-list .closure-item .details { padding: ' + ['','5px','0px'][compress] + '; font-size: ' + ['','12px','11px'][compress] + '; }';
styles += '.closures-list .closure-item .buttons { top: ' + ['','7px','4px'][compress] + '; }';
//tweak for Junction Box button
styles += '#edit-panel .junction-actions > button { width: inherit; }';
//PLACE DETAILS
//alert
styles += '#edit-panel .header-alert { margin-bottom: ' + ['','6px','2px'][compress] + '; padding: ' + ['','6px','2px'][compress] + '; }';
//address input
styles += '#edit-panel .full-address { padding-top: ' + ['','4px','1px'][compress] + '; padding-bottom: ' + ['','4px','1px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
//alt names
styles += '#edit-panel .aliases-view .list li { margin: ' + ['','12px 0','4px 0'][compress] + '; }';
styles += '#edit-panel .aliases-view .delete { line-height: inherit; }';
//categories
styles += '#edit-panel .categories .select2-search-choice .category { margin: ' + ['','2px 0 2px 4px','1px 0 1px 3px'][compress] + '; height: ' + ['','18px','15px'][compress] + '; line-height: ' + ['','18px','15px'][compress] + '; }';
styles += '#edit-panel .categories .select2-search-field input { height: ' + ['','18px','17px'][compress] + '; }';
styles += '#edit-panel .categories .select2-choices { min-height: ' + ['','26px','19px'][compress] + '; }';
styles += '#edit-panel .categories .select2-container { margin-bottom: 0px; }';
//entry/exit points
styles += '#edit-panel .navigation-point-view .navigation-point-list-item .preview { padding: ' + ['','3px 7px','0px 4px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
styles += '#edit-panel .navigation-point-view .add-button { height: ' + ['','28px','18px'][contrast] + '; line-height: ' + ['','17px','16px'][contrast] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
//type buttons
styles += '#sidebar .area-btn, #sidebar .point-btn { height: ' + ['','19px','16px'][compress] + '; line-height: ' + ['','19px','16px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
// { height: ' + ['','19px','16px'][compress] + '; width: ' + ['','19px','16px'][compress] + '; line-height: ' + ['','19px','16px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; margin-bottom: ' + ['','3px','1px'][compress] + '; }';
//external providers
styles += '.select2-container { font-size: ' + ['','13px','12px'][compress] + '; }';
styles += '#edit-panel .external-providers-view .external-provider-item { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
styles += '.external-providers-view > div > ul { margin-bottom: ' + ['','4px','0px'][compress] + '; }';
styles += '#edit-panel .external-providers-view .add { padding: ' + ['','3px 12px','1px 9px'][compress] + '; }';
styles += '#edit-panel .waze-btn.waze-btn-smaller { line-height: ' + ['','26px','21px'][compress] + '; }';
//residential toggle
styles += '#edit-panel .toggle-residential { height: ' + ['','27px','22px'][compress] + '; }';
//more info
styles += '.service-checkbox { font-size: ' + ['','13px','12px'][compress] + '; }';
}
if (contrast > 0) {
//contrast enhancements
//general
//text colour
styles += '#sidebar { color: black; }';
//advanced tools section
styles += '#sidebar waze-staff-tools { background-color: #c7c7c7; }';
//Tabs
styles += '#sidebar .nav-tabs li a { border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
//Feed
styles += '.feed-item { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
//Drives & Areas
styles += '#sidebar .result-list .result { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
//Segment edit panel
styles += '#edit-panel .selection { font-size: 13px; }';
styles += '#edit-panel .segment .direction-message { color: orangered; }';
styles += '#edit-panel .address-edit-input { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
styles += '#sidebar .form-control { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
//radio buttons when disabled
styles += '.waze-radio-container input[type="radio"]:disabled:checked + label { color: black; opacity: 0.7; font-weight:600; }';
//override border for lock levels
styles += '#sidebar .waze-radio-container { border: 0 none !important; }';
styles += '#edit-panel .waze-btn { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
styles += '.waze-radio-container label { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
//history items
styles += '.toggleHistory { color: black; text-align: center; }';
styles += '.element-history-item .tx-header { color: black; }';
styles += '.element-history-item.closed .tx-header { border-radius: 8px; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
styles += '.loadMoreHistory { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
//closures list
styles += '.closures-list .closure-item .details { border-radius: 8px; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
styles += '.closures-list .closure-item .dates { color: black; }';
styles += '.closures-list .closure-item .dates .date-label { opacity: 1; }';
//Place details
//alert
styles += '#edit-panel .alert-danger { color: red; }';
//address input
styles += '#edit-panel .full-address { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
styles += '#edit-panel a.waze-link { font-weight: bold; }';
//categories
styles += '#edit-panel .categories .select2-search-choice .category { text-transform: inherit; font-weight: bold; background: gray; }';
//entry/exit points
styles += '#edit-panel .navigation-point-view .navigation-point-list-item .preview { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
styles += '#edit-panel .navigation-point-view .add-button { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; margin-top: 2px; padding: 0 5px; }';
//type buttons
styles += '#sidebar .point-btn { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
//external providers
styles += '.select2-container { color: teal; border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
styles += '.select2-container .select2-choice { color: black; }';
//residential toggle
styles += '#edit-panel .toggle-residential { font-weight: bold; }';
}
}
//fix for buttons of WME Image Overlay script
styles += '#sidepanel-imageoverlays > div.result-list button { height: 24px; }';
addStyle(prefix + fname,styles);
} else {
removeStyle(prefix + fname);
}
}
function compressLayersMenu() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
var styles = "";
if (_cbCompressLayersMenu.checked) {
// tweaks for layers menu
if (document.getElementById('layer-switcher-list') === null) {
//new style layers menu
styles += '.layer-switcher { line-height: 11px; }';
styles += '#layer-switcher .dropdown-menu .draggable .toggler .handle { height: 18px; }';
styles += '.layer-switcher .togglers .group:not(:last-child):after { margin: 5px -7px -2px; }';
styles += '.layer-switcher .more-options-toggle { height: 20px; line-height: 20px; }';
} else {
//old style layers menu
styles += '.layer-switcher { line-height: 14px; }';
}
// styles += '.layer-switcher .toggler { padding-top: 0px; padding-bottom: 0px; }';
addStyle(prefix + fname,styles);
} else {
removeStyle(prefix + fname);
}
}
function restyleReports() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
var styles = "";
if (_cbRestyleReports.checked) {
var contrast = _inpUIContrast.value;
var compress = _inpUICompression.value;
if (compress > 0) {
//report header
styles += '#panel-container .header { padding: ' + ['','9px 36px','1px 36px'][compress] + '; line-height: ' + ['','19px','17px'][compress] + '; }';
styles += '#panel-container .header .dot { top: ' + ['','15px','7px'][compress] + '; }';
//report body
styles += '#panel-container .body { line-height: ' + ['','15px','13px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
//problem description
styles += '#panel-container div.description.section > div.collapsible.content { padding: ' + ['','9px','3px'][compress] + '; }';
//comments
styles += '#panel-container .conversation-view .comment .comment-content { padding: ' + ['','6px 9px','2px 3px'][compress] + '; }';
styles += '#panel-container .comment .text { padding: ' + ['','7px 9px','4px 4px'][compress] + '; }';
//new comment entry
styles += '#panel-container .conversation-view .new-comment-form { padding: ' + ['','8px 9px 6px 9px','1px 3px 2px 3px'][compress] + '; }';
//send button
styles += '#panel-container .conversation-view .send-button { padding: ' + ['','4px 16px','2px 12px'][compress] + '; box-shadow: ' + ['','3px 3px 4px 0 #def7ff','3px 2px 4px 0 #def7ff'][compress] + '; }';
//lower buttons
styles += '#panel-container > div > div > div.actions > div > div { WME: FU; padding-top: ' + ['','6px','3px'][compress] + '; }';
styles += '#panel-container .close-details.section { font-size: ' + ['','13px','12px'][compress] + '; line-height: ' + ['','13px','9px'][compress] + '; }';
styles += '#panel-container .problem-edit .actions .controls-container label { WME: FU; height: ' + ['','28px','21px'][compress] + '; line-height: ' + ['','28px','21px'][compress] + '; margin-bottom: ' + ['','5px','2px'][compress] + '; }';
styles += '#panel-container .waze-plain-btn { height: ' + ['','30px','20px'][compress] + '; line-height: ' + ['','30px','20px'][compress] + '; }';
styles += '.panel .navigation { margin-top: ' + ['','6px','2px'][compress] + '; }';
//WMEFP All PM button
styles += '#WMEFP-UR-ALLPM { top: ' + ['','5px','0px'][compress] + ' !important; }';
}
if (contrast > 0) {
styles += '#panel-container .section { border-bottom: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
styles += '#panel-container .close-panel { border-color: ' + ['','lightgrey','grey'][contrast] + '; }';
styles += '#panel-container .main-title { font-weight: 900; }';
styles += '#panel-container .reported { color: ' + ['','dimgrey','black'][contrast] + '; }';
styles += '#panel-container .date { color: ' + ['','#6d6d6d','#3d3d3d'][contrast] + '; }';
styles += '#panel-container .comment .text { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
styles += '#panel-container .comment-content.reporter .username { color: ' + ['','#159dc6','#107998'][contrast] + '; }';
styles += '#panel-container .conversation-view .new-comment-form textarea { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
styles += '#panel-container .top-section { border-bottom: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
styles += '#panel-container .waze-plain-btn { font-weight: 800; color: ' + ['','#159dc6','#107998'][contrast] + '; }';
}
addStyle(prefix + fname,styles);
if (wmeFUinitialising) {
setTimeout(draggablePanel, 5000);
} else {
draggablePanel();
}
} else {
removeStyle(prefix + fname);
if (jQuery.ui) {
if ( $("#panel-container").hasClass('ui-draggable') ) {
$("#panel-container").draggable("destroy");
}
getId("panel-container").style = "";
}
}
window.dispatchEvent(new Event('resize'));
}
function draggablePanel() {
if (jQuery.ui) {
if ($("#panel-container").data("ui-draggable")) {
$("#panel-container").draggable({ handle: ".header" });
}
}
}
function enhanceChat() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
var styles = "";
if (_cbEnhanceChat.checked) {
removeStyle(prefix + fname);
var contrast = _inpUIContrast.value;
var compress = _inpUICompression.value;
var mapX = getId('map').clientWidth;
var mapY = getId('map').clientHeight;
var chatX = Math.floor( mapX * 0.45);
var chatY = Math.floor( mapY * 0.5);
var chatHeaderY = [50,35,20][compress];
var chatMessageInputY = [39,31,23][compress];
var chatMessagesY = chatY - chatHeaderY - chatMessageInputY;
var chatUsersY = chatY - chatHeaderY;
// logit('mapX='+mapX+',mapY='+mapY+',chatX='+chatX+',chatY='+chatY+',chatHeaderY='+chatHeaderY+',\nchatMessageInputY='+chatMessageInputY+',chatMessagesY='+chatMessagesY+',chatUsersY='+chatUsersY,'info');
//change chat width to 45% of map view
styles += '#chat-overlay { width: ' + chatX + 'px; min-width: 334px; }'; //14px added for Chat addon
styles += '#chat .messages { width: 70%; min-width: 200px;}';
styles += '#map.street-view-mode #chat .messages { width: 70%; }';
styles += '#chat .messages .message-list { margin-bottom: 0px; }';
styles += '#chat .messages .new-message { position: inherit; width: unset; }';
styles += '#map.street-view-mode #chat .messages .new-message { position: inherit; width: unset; }';
styles += '#chat .users { width: 30%; min-width: 120px; }';
styles += '#chat .messages .message-list .message.normal-message { max-width: unset; }';
//change chat height to 50% of map view
styles += '#chat .messages .message-list { min-height: ' + chatMessagesY + 'px; }';
styles += '#chat .users { max-height: ' + chatUsersY + 'px; }';
// #chat .messages .unread-messages-notification width=70%, bottom64px>
if (compress > 0) {
//do compression
//header
styles += '#chat .header { line-height: ' + chatHeaderY + 'px; }';
styles += '#chat .header .dropdown .dropdown-toggle { line-height: ' + ['','30px','19px'][compress] + '; }';
styles += '#chat .header button { line-height: ' + ['','20px','19px'][compress] + '; font-size: ' + ['','13px','11px'][compress] + '; height: ' + ['','20px','19px'][compress] + '; }';
//message list
styles += '#chat .messages .message-list { padding: ' + ['','9px','3px'][compress] + '; }';
styles += '#chat .messages .message-list .message.normal-message { padding: ' + ['','6px','2px'][compress] + '; }';
styles += '#chat .messages .message-list .message { margin-bottom: ' + ['','8px','2px'][compress] + '; line-height: ' + ['','16px','14px'][compress] + '; font-size: ' + ['','12px','11px'][compress] + '; }';
styles += '#chat .messages .new-message input { height: ' + chatMessageInputY + 'px; }';
//user list
styles += '#chat .users { padding: ' + ['','8px','1px'][compress] + '; }';
styles += '#chat ul.user-list a.user { padding: ' + ['','2px','1px'][compress] + '; }';
styles += '#chat ul.user-list a.user .rank { width: ' + ['','25px','20px'][compress] + '; height: ' + ['','20px','16px'][compress] + '; margin-right: ' + ['','3px','1px'][compress] + '; }';
styles += '#chat ul.user-list a.user .username { line-height: ' + ['','21px','17px'][compress] + '; }';
styles += '#chat ul.user-list a.user:hover .crosshair { margin-top: ' + ['','3px','1px'][compress] + '; right: ' + ['','3px','1px'][compress] + '; }';
//fix for WME Chat Addon
styles += '#chat .users > ul > li > a { margin: 0px !important; }';
}
if (contrast > 0) {
//header
styles += '#chat .header { color: black; background-color: ' + ['','#d9d9d9','#bfbfbf'][contrast] + '; }';
styles += '#chat .messages .message-list { background-color: ' + ['','#e8e8e8','lightgrey'][contrast] + '; }';
styles += '#chat .messages .message-list .message.normal-message { color: black; float: left; }';
styles += '#chat .messages .message-list .message.normal-message .from { color: dimgrey; font-weight: bold; font-style: italic; }';
styles += '#chat .messages .message-list .message.own-message .from { color: black; background-color: #a1dcf5; }';
//user message timestamps
styles += '#chat > div.chat-body > div.messages > div.message-list > div > div.from > span { color: ' + ['','dimgrey','black'][contrast] + ' !important; }';
//system message timestamps
styles += '#chat > div.chat-body > div.messages > div.message-list > div > div.body > div > span { color: ' + ['','dimgrey','black'][contrast] + ' !important; }';
//fix for WME Chat Addon
styles += '#chat .body > div { color: black !important; }';
}
//fix for Chat Addon timestamps running up against names
styles += '#chat > div.chat-body > div.messages > div.message-list > div > div.from > span { margin-left: 5px; }';
addStyle(prefix + fname,styles);
} else {
removeStyle(prefix + fname);
}
}
function WnarrowSidePanel() {
if (getId("_cbNarrowSidePanel").checked === true) {
alert("You have enabled the 'Reduce width of side panel' option\n"+
"Please be aware that this function is not yet compatible with WME V2");
}
narrowSidePanel();
}
function narrowSidePanel() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
var styles = "";
if (_cbNarrowSidePanel.checked) {
//sidebar width
styles += '.row-fluid #sidebar { width: 250px; }';
//map width
styles += '.show-sidebar .row-fluid .fluid-fixed { margin-left: 250px; }';
//user info tweaks
styles += '#sidebar #user-info #user-box { padding: 0 0 5px 0; }';
styles += '#sidebar #user-details { width: 250px; }';
styles += '#sidebar #user-details .user-profile .level-icon { margin: 0; }';
styles += '#sidebar #user-details .user-profile .user-about { max-width: 161px; }';
//gradient bars
styles += '#sidebar .tab-scroll-gradient { width: 220px; }';
styles += '#sidebar #links:before { width: 236px; }';
//feed
styles += '.feed-item .content { max-width: 189px; }';
//segment edit panel
styles += '#edit-panel .more-actions .waze-btn.waze-btn-white { width: 122px; }';
//tweak for WME Bookmarks
styles += '#divBookmarksContent .divName { max-width: 164px; }';
addStyle(prefix + fname, styles);
} else {
removeStyle(prefix + fname);
}
compressSegmentTab();
window.dispatchEvent(new Event('resize'));
}
function hideAveSpeedControls() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
removeStyle(prefix + fname);
if (_cbHideAveSpeedControls.checked) {
var ASCBox;
if (getId('fwdSpeedCameraCheckbox')) {
ASCBox = getId('fwdSpeedCameraCheckbox');
}
if (getId('revSpeedCameraCheckbox')) {
ASCBox = getId('revSpeedCameraCheckbox');
}
if (ASCBox) {
var formGroup = ASCBox.parentNode.parentNode.parentNode;
var formGroupParent = formGroup.parentNode;
var targetGroup = Array.prototype.indexOf.call(formGroupParent.children, formGroup) + 1;
addStyle(prefix + fname, '#segment-edit-general > .side-panel-section.attributes-form > .form-group:nth-of-type(' + targetGroup + ') { display: none; }');
}
}
// if (_cbClickablePlaceAddress.checked) {
// var address;
// // Place address
// if (UIver == "old") {
// address = document.querySelector("#landmark-edit-general > div.address-edit.side-panel-section > div > div");
// if (address) {
// address.classList.add('edit-button');
// address.style.cursor = 'pointer';
// }
// } else {
// address = document.querySelector("#landmark-edit-general > div.form-group > div > div > div");
// if (address) {
// address.classList.add('edit-button');
// address.style.cursor = 'pointer';
// }
// }
// // Segment address
// if (UIver == "old") {
// // don't need to do anything - already clickable
// } else {
// address = document.querySelector("#segment-edit-general > div.address-edit.address-edit-view.clearfix.preview > div");
// if (address) {
// address.classList.add('address-edit-btn');
// address.style.cursor = 'pointer';
// var styles = "";
// styles += "#segment-edit-general > div.address-edit.address-edit-view.clearfix.preview > div:before { content: none; }";
// styles += "#segment-edit-general > div.address-edit.address-edit-view.clearfix.preview > div:after { content: none; }";
// addStyle(prefix + fname, styles);
// }
// }
// } else {
// removeStyle(prefix + fname);
// }
}
function WaddZoomIndicator() {
if (getId("_cbAddZoomIndicator").checked === true) {
alert("You have enabled the Zoom Level Indicator\n"+
"Please be aware that this function is not yet compatible with WME V2");
}
addZoomIndicator();
}
function addZoomIndicator() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
if (_cbAddZoomIndicator.checked) {
addStyle(prefix + fname, '.slider { font-size: 15px; font-weight: 900; line-height: 1; height: 18px; margin-top: 23px; padding-top: 2px; text-align: center; }');
Waze.map.events.register("zoomend", null, ZLI);
ZLI();
} else {
removeStyle(prefix + fname);
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";
switch (Waze.map.zoom) {
case 0:
case 1:
slider.style.background = '#ef9a9a';
slider.title += "\nCannot permalink any segments at this zoom level";
break;
case 2:
case 3:
slider.style.background = '#ffe082';
slider.title += "\nCan only permalink primary or higher at this zoom level";
break;
default:
slider.style.background = '#ffffff';
slider.title += "\nCan permalink any segments at this zoom level";
break;
}
}
function shiftAerials() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " 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;
//turn off Enhance Chat if WME Chat Fix is loaded
if (document.getElementById('WMEfixChat-setting')) {
if (_cbEnhanceChat.checked === true) {
alert("WME FixUI: Enhance Chat disabled because WME Chat UI Fix detected");
}
_cbEnhanceChat.checked = false;
}
}
function fixExternalProviders () {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
var styles = "";
if (_cbFixExternalProviders.checked) {
//enlarge external provider boxes
styles += '#edit-panel .external-providers-view .select2-container { width: 90%; margin-bottom: 2px; }';
styles += '.select2-container .select2-choice { height: inherit; line-height: 16px; }';
styles += '.select2-container .select2-choice>.select2-chosen { white-space: normal; }';
styles += '.placeId { padding-bottom: 5px; }';
addStyle(prefix + fname,styles);
} else {
removeStyle(prefix + fname);
}
}
function warnCommentsOff() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
if (Waze.map.getLayerByUniqueName('mapComments').visibility === false) {
removeStyle(prefix + fname);
addStyle(prefix + fname, '.toolbar { background-color: #FFC107; }');
} else {
removeStyle(prefix + fname);
}
}
function adjustGSV() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
var styles = "";
styles += '.gm-style { filter: contrast(' + getId('_inpGSVContrast').value + '%) ';
styles += 'brightness(' + getId('_inpGSVBrightness').value + '%) ';
if (getId('_cbGSVInvert').checked) {
styles += 'invert(1); }';
} else {
styles += 'invert(0); }';
}
removeStyle(prefix + fname);
addStyle(prefix + fname, styles);
}
function permalinkCheck() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
var selSegments = Waze.selectionManager.selectedItems.length;
if ( URLSegmentCount != selSegments ) {
alert("WARNING FROM WME FixUI!\n\n" +
"You have opened a permalink with " + URLSegmentCount + " segments,\n" +
"but the total selected in WME is " + selSegments + ".\n\n" +
"The permalink may contain segments not selectable at this zoom\n" +
"or not visible on-screen, or some segment IDs may have been\n" +
"changed since the permalink was created.");
}
Waze.selectionManager.events.unregister("selectionchanged", null, permalinkCheck);
}
function moveChatIcon() {
// Now functioning correctly for prod & beta
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
var styles = "";
if (_cbMoveChatIcon.checked) {
styles += '#chat-overlay { left: inherit !important; right: 30px !important; }';
if (UIver == "new") {
styles += '#chat-overlay #chat-toggle { right: 0px !important; }';
}
addStyle(prefix + fname,styles);
} else {
removeStyle(prefix + fname);
}
}
function darkenSaveLayer() {
var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
logit("function " + fname + " called", "debug");
var styles = "";
if (_cbDarkenSaveLayer.checked) {
styles += '#popup-overlay { background-color: dimgrey !important; }';
addStyle(prefix + fname,styles);
} else {
removeStyle(prefix + fname);
}
}
//function layersMenuAutoHide() {
// var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
// logit("function " + fname + " called", "debug");
// var LS = getElementsByClassName('layer-switcher')[0];
// if (_cbLayersMenuAutoHide.checked) {
// LS.onmouseleave = function () { $(".waze-icon-layers").click(); };
// LS.onmouseenter = function () { $(".waze-icon-layers").click(); };
// } else {
// LS.onmouseleave = null;
// LS.onmouseenter = null;
// }
//}
//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 addStyle(ID, css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) {
return;
}
removeStyle(ID); // in case it is already there
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
style.id = ID;
head.appendChild(style);
}
function removeStyle(ID) {
var style = document.getElementById(ID);
if (style) { style.parentNode.removeChild(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 ChromeWarning () {
var m = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
var CV = ( m ? parseInt(m[2], 10) : false);
if (CV) {
if (CV <62) {
return '\nWARNING: OUTDATED CHROME VERSION ' + CV + ' DETECTED.\nSettings saving may not work properly and update notice\nwill probably appear every time WME FixUI runs.\n';
} else {
return '';
}
} else {
return '';
}
}
function logit(msg, typ) {
if (!typ) {
console.log(prefix + ": " + msg);
} else {
switch(typ) {
case "error":
console.error(prefix + ": " + msg);
break;
case "warning":
console.warn(prefix + ": " + msg);
break;
case "info":
console.info(prefix + ": " + msg);
break;
case "debug":
if (debug) {
console.warn(prefix + ": " + msg);
}
break;
default:
console.log(prefix + " unknown message type: " + msg);
break;
}
}
}
// Start it running
setTimeout(init1, 200);
})();