// ==UserScript== // @name WME Place Interface Enhancements // @namespace https://greasyfork.org/users/30701-justins83-waze // @version 0.2.0 // @description Enhancements to various Place interfaces // @include https://www.waze.com/editor/* // @include https://www.waze.com/*/editor/* // @include https://beta.waze.com/* // @exclude https://www.waze.com/user/editor* // @author JustinS83 // @grant none // @require https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js // @license GPLv3 // @downloadURL none // ==/UserScript== (function() { 'use strict'; var settings = {}; // Your code here... function bootstrap(tries) { tries = tries || 1; if (window.W && window.W.map && window.W.model && $) { init(); } else if (tries < 1000) { setTimeout(function () {bootstrap(tries++);}, 200); } } bootstrap(); function init(){ var $section = $("
", {style:"padding:8px 16px", id:"WMEPIESettings"}); $section.html([ 'WME Place Interface Enhancements', '
', '
', '
', '
', '
', '
', '
0 && isArea){ var ftArea = Math.round(metersArea * 10.76391 *100)/100; var list = $('#landmark-edit-general > ul')[0]; var newList = document.createElement("UL"); newList.id = "AreaSize"; var newItem = document.createElement("LI"); if(isChecked("_cbShowAreaPlaceSizeMetric")){ newItem.innerHTML = "Area: " + metersArea.toFixed(2) + " m2"; newList.append(newItem); } if(isChecked("_cbShowAreaPlaceSizeImperial")){ newItem = document.createElement("LI"); newItem.innerHTML = "Area: " + ftArea.toFixed(2) + " ft2"; newList.append(newItem); } if(metersArea < 500){ newItem = document.createElement("LI"); newItem.innerHTML = "Places smaller than 500 m2/5382 ft2 will not show in the client"; newList.append(newItem); } list.before(newList); $('#AreaSize').addClass("list-unstyled"); $('#AreaSize').addClass("additional-attributes"); } } } } function loadSettings() { var loadedSettings = $.parseJSON(localStorage.getItem("WMEPIE_Settings")); var defaultSettings = { ShowAreaPlaceSize: false, ShowAreaPlaceSizeImperial: false, ShowAreaPlaceSizeMetric: false, ShowLockButtonsRPP: true }; settings = loadedSettings ? loadedSettings : defaultSettings; for (var prop in defaultSettings) { if (!settings.hasOwnProperty(prop)) settings[prop] = defaultSettings[prop]; } if(settings.ShowAreaPlaceSizeImperial === false && settings.ShowAreaPlaceSizeMetric === false) if(Waze.prefs.attributes.isImperial) settings.ShowAreaPlaceSizeImperial = true; else settings.ShowAreaPlaceSizeMetric = true; } function saveSettings() { if (localStorage) { var localsettings = { ShowAreaPlaceSize: settings.ShowAreaPlaceSize, ShowAreaPlaceSizeImperial: settings.ShowAreaPlaceSizeImperial, ShowAreaPlaceSizeMetric: settings.ShowAreaPlaceSizeMetric, ShowLockButtonsRPP: settings.ShowLockButtonsRPP }; localStorage.setItem("WMEPIE_Settings", JSON.stringify(localsettings)); } } //Using the same display for lock buttons as ClickSaver (with permission from MapoMatic) - thanks MoM! function addLockButtons() { if(W.selectionManager.selectedItems.length > 0){ var item = W.selectionManager.selectedItems[0]; var isRPP = (item.model.type === "venue" && item.model.attributes.residential === true); if(isRPP){ console.log("adding!!!"); var attr = item.model.attributes; var autoRank = attr.rank; var manualRank = attr.lockRank; var firstManualRank = manualRank; var userRank = WazeWrap.User.Rank() - 1; var maxAutoRank = autoRank; var disabled = false; var $div = $('#RPPOptionPlaceLockButtonsContainer'); $div.remove(); $div = $('
',{id:'RPPOptionPlaceLockButtonsContainer',style:'margin-bottom:5px;'}); $div.append(''); var btnInfos = []; for(var iBtn=0;iBtn<=6;iBtn++){btnInfos.push({r:iBtn,val:iBtn});} btnInfos.forEach(function(btnInfo){ var selected = (btnInfo.val === manualRank); disabled = userRank < btnInfo.val; if (btnInfo.val !== 6) { $div.append( $('
', { class:'btn btn-lh' + (selected ? ' btn-lh-selected':'') + (btnInfo.r < 6 & (userRank < btnInfo.r || disabled) ? ' disabled' : '') }) .text(btnInfo.hasOwnProperty('title') ? btnInfo.title : btnInfo.r + 1) .data('val',btnInfo.hasOwnProperty('val') ? btnInfo.val : btnInfo.r + 1) .hover(function() {}) .click(function() { if((userRank >= $(this).data('val')) && (btnInfo.r < 6)) { W.model.actionManager.add(new UpdateObject(item.model,{lockRank:($(this).data('val'))})); addLockButtons(); } }) ); } }); $('#landmark-edit-general > div').after($div); } } } function listPlaces(){ var category = ""; for(i=0; i