From e153136587e33cff2b851ac8ccf2019b65586ae1 Mon Sep 17 00:00:00 2001 From: mapomatic Date: Thu, 17 Jan 2019 09:55:49 -0500 Subject: [PATCH 1/7] Removing feature to hide suggested-categories... ... when place is Shopping / Services. Will be implemented in PIE. --- WME-Place-Harmonizer.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/WME-Place-Harmonizer.js b/WME-Place-Harmonizer.js index 55f7b36..b7eef3d 100644 --- a/WME-Place-Harmonizer.js +++ b/WME-Place-Harmonizer.js @@ -1,7 +1,7 @@ // ==UserScript== // @name WME Place Harmonizer Beta // @namespace WazeUSA -// @version 1.3.136 +// @version 1.3.137 // @description Harmonizes, formats, and locks a selected place // @author WMEPH Development Group // @include /^https:\/\/(www|beta)\.waze\.com\/(?!user\/)(.{2,6}\/)?editor\/?.*$/ @@ -5470,9 +5470,6 @@ } else { setTimeout(bootstrapRunButton,100); } - if ( venue.attributes.categories.length === 1 && venue.attributes.categories[0] === 'SHOPPING_AND_SERVICES' ) { - $('.suggested-categories').remove(); - } showOpenPlaceWebsiteButton(); showSearchButton(); }, betaDelay); From 6cc0c6cfd54f9ee13b17837e1bd8aa992d8c004b Mon Sep 17 00:00:00 2001 From: MapOMatic Date: Mon, 4 Feb 2019 22:04:21 -0500 Subject: [PATCH 2/7] Minor formatting changes (spacing) over a lot of the code. --- WME-Place-Harmonizer.js | 1880 ++++++++++++++++++++------------------- 1 file changed, 948 insertions(+), 932 deletions(-) diff --git a/WME-Place-Harmonizer.js b/WME-Place-Harmonizer.js index b7eef3d..7823f41 100644 --- a/WME-Place-Harmonizer.js +++ b/WME-Place-Harmonizer.js @@ -27,6 +27,7 @@ /* global LZString */ /* global Promise */ +/* eslint-disable */ (function () { 'use strict'; @@ -61,7 +62,7 @@ '.wmeph-fat-btn { padding-left:8px; padding-right:8px; padding-top:4px; margin-right:3px; display:inline-block; font-weight:normal; height:24px; }', '.ui-autocomplete { max-height: 300px;overflow-y: auto;overflow-x: hidden;} ' ]; - const _SCRIPT_VERSION = GM_info.script.version.toString(); // pull version from header + const _SCRIPT_VERSION = GM_info.script.version.toString(); // pull version from header const _SCRIPT_NAME = GM_info.script.name; const _IS_DEV_VERSION = /Beta/i.test(_SCRIPT_NAME); // enables dev messages and unique DOM options if the script is called "... Beta" const _PNH_DATA = { USA: {}, CAN: {} }; @@ -74,8 +75,8 @@ let _textEntryValues = null; // Store the values entered in text boxes so they can be re-added when the banner is reassembled. var hospitalPartMatch, hospitalFullMatch, animalPartMatch, animalFullMatch, schoolPartMatch, schoolFullMatch; // vars for cat-name checking var WMEPHdevList, WMEPHbetaList; // Userlists - var devVersStr= _IS_DEV_VERSION ? 'Beta' : ''; // strings to differentiate DOM elements between regular and beta script - var WMEServicesArray = ['VALLET_SERVICE','DRIVETHROUGH','WI_FI','RESTROOMS','CREDIT_CARDS','RESERVATIONS','OUTSIDE_SEATING','AIR_CONDITIONING','PARKING_FOR_CUSTOMERS','DELIVERIES','TAKE_AWAY','WHEELCHAIR_ACCESSIBLE','DISABILITY_PARKING']; + var devVersStr = _IS_DEV_VERSION ? 'Beta' : ''; // strings to differentiate DOM elements between regular and beta script + var WMEServicesArray = ['VALLET_SERVICE', 'DRIVETHROUGH', 'WI_FI', 'RESTROOMS', 'CREDIT_CARDS', 'RESERVATIONS', 'OUTSIDE_SEATING', 'AIR_CONDITIONING', 'PARKING_FOR_CUSTOMERS', 'DELIVERIES', 'TAKE_AWAY', 'WHEELCHAIR_ACCESSIBLE', 'DISABILITY_PARKING']; var collegeAbbreviations = 'USF|USFSP|UF|UCF|UA|UGA|FSU|UM|SCP|FAU|FIU'; var shortcutParse, modifKey = 'Alt+'; var venueWhitelist, venueWhitelistStr, WLSToMerge, wlKeyName, wlButtText = 'WL'; // Whitelisting vars @@ -83,7 +84,7 @@ var WLlocalStoreNameCompressed = 'WMEPH-venueWhitelistCompressed'; var _dupeLayer, dupeIDList = [], dupeHNRangeList, dupeHNRangeIDList, dupeHNRangeDistList; // Web search Window forming: - var searchResultsWindowSpecs = '"resizable=yes, top='+ Math.round(window.screen.height*0.1) +', left='+ Math.round(window.screen.width*0.3) +', width='+ Math.round(window.screen.width*0.7) +', height='+ Math.round(window.screen.height*0.8) +'"'; + var searchResultsWindowSpecs = '"resizable=yes, top=' + Math.round(window.screen.height * 0.1) + ', left=' + Math.round(window.screen.width * 0.3) + ', width=' + Math.round(window.screen.width * 0.7) + ', height=' + Math.round(window.screen.height * 0.8) + '"'; var searchResultsWindowName = '"WMEPH Search Results"'; var WMEPHmousePosition; var cloneMaster = null; @@ -118,10 +119,10 @@ var lockLevel2 = 1, lockLevel4 = 3; var defaultLockLevel = lockLevel2, PNHLockLevel; var PMUserList = { // user names and IDs for PM functions - SER: {approvalActive: true, modID: '17083181', modName: 'itzwolf'}, - WMEPH: {approvalActive: true, modID: '2647925', modName: 'MapOMatic'} + SER: { approvalActive: true, modID: '17083181', modName: 'itzwolf' }, + WMEPH: { approvalActive: true, modID: '2647925', modName: 'MapOMatic' } }; - var severityButt=0; // error tracking to determine banner color (action buttons) + var severityButt = 0; // error tracking to determine banner color (action buttons) var duplicateName = ''; var catTransWaze2Lang; // pulls the category translations var itemID, newName, optionalAlias, newURL, tempPNHURL = '', newPhone; @@ -154,27 +155,27 @@ var _updatedFields = { name: { updated: false, selector: '.landmark .form-control[name="name"]', tab: 'general' }, - aliases: {updated: false, selector: '.landmark .form-control.alias-name', tab: 'general' }, - address: {updated: false, selector: '.landmark .address-edit span.full-address', tab: 'general'}, - categories: {updated: false, selector: '.landmark .categories.controls .select2-container', tab: 'general'}, - description: {updated: false, selector: '.landmark .form-control[name="description"]', tab: 'general' }, - lock: {updated: false, selector: '.landmark .form-control.waze-radio-container', tab: 'general' }, - externalProvider: {updated: false, selector: '.landmark .external-providers-view', tab: 'general' }, - brand: {updated: false, selector: '.landmark .brand .select2-container', tab: 'general' }, - url: {updated: false, selector: '.landmark .form-control[name="url"]', tab: 'more-info' }, - phone: {updated: false, selector: '.landmark .form-control[name="phone"]', tab: 'more-info' }, - openingHours: {updated: false, selector: '.landmark .opening-hours ul', tab: 'more-info' }, - cost: {updated: false, selector: '.landmark .form-control[name="costType"]', tab: 'more-info' }, - canExit: {updated: false, selector: '.landmark label[for="can-exit-checkbox"]', tab: 'more-info' }, - hasTBR: {updated: false, selector: '.landmark label[for="has-tbr"]', tab: 'more-info' }, - lotType: {updated: false, selector: '.landmark .parking-type-option', tab: 'more-info' }, - parkingSpots: {updated: false, selector: '.landmark .form-control[name="estimatedNumberOfSpots"]', tab: 'more-info' }, - lotElevation: {updated: false, selector: '.landmark .lot-checkbox', tab: 'more-info'}, - - getFieldProperties: function() { + aliases: { updated: false, selector: '.landmark .form-control.alias-name', tab: 'general' }, + address: { updated: false, selector: '.landmark .address-edit span.full-address', tab: 'general' }, + categories: { updated: false, selector: '.landmark .categories.controls .select2-container', tab: 'general' }, + description: { updated: false, selector: '.landmark .form-control[name="description"]', tab: 'general' }, + lock: { updated: false, selector: '.landmark .form-control.waze-radio-container', tab: 'general' }, + externalProvider: { updated: false, selector: '.landmark .external-providers-view', tab: 'general' }, + brand: { updated: false, selector: '.landmark .brand .select2-container', tab: 'general' }, + url: { updated: false, selector: '.landmark .form-control[name="url"]', tab: 'more-info' }, + phone: { updated: false, selector: '.landmark .form-control[name="phone"]', tab: 'more-info' }, + openingHours: { updated: false, selector: '.landmark .opening-hours ul', tab: 'more-info' }, + cost: { updated: false, selector: '.landmark .form-control[name="costType"]', tab: 'more-info' }, + canExit: { updated: false, selector: '.landmark label[for="can-exit-checkbox"]', tab: 'more-info' }, + hasTBR: { updated: false, selector: '.landmark label[for="has-tbr"]', tab: 'more-info' }, + lotType: { updated: false, selector: '.landmark .parking-type-option', tab: 'more-info' }, + parkingSpots: { updated: false, selector: '.landmark .form-control[name="estimatedNumberOfSpots"]', tab: 'more-info' }, + lotElevation: { updated: false, selector: '.landmark .lot-checkbox', tab: 'more-info' }, + + getFieldProperties: function () { return Object.keys(this).filter(key => this[key] && this[key].updated); }, - getUpdatedTabs: function() { + getUpdatedTabs: function () { var tabs = []; this.getFieldProperties().forEach(propName => { var prop = this[propName]; @@ -184,24 +185,24 @@ }); return tabs; }, - checkAddedNode: function(addedNode) { + checkAddedNode: function (addedNode) { this.getFieldProperties().forEach(propName => { var prop = this[propName]; if (prop.updated && addedNode.querySelector(prop.selector)) { - $(prop.selector).css({'background-color':'#dfd'}); - $('a[href="#landmark-edit-' + prop.tab + '"]').css({'background-color':'#dfd'}); + $(prop.selector).css({ 'background-color': '#dfd' }); + $('a[href="#landmark-edit-' + prop.tab + '"]').css({ 'background-color': '#dfd' }); } }); }, - reset: function() { - this.getFieldProperties().forEach(propName => {this[propName].updated = false;}); + reset: function () { + this.getFieldProperties().forEach(propName => { this[propName].updated = false; }); }, - init: function() { + init: function () { ['VALLET_SERVICE', 'DRIVETHROUGH', 'WI_FI', 'RESTROOMS', 'CREDIT_CARDS', 'RESERVATIONS', 'OUTSIDE_SEATING', 'AIR_CONDITIONING', 'PARKING_FOR_CUSTOMERS', 'DELIVERIES', 'TAKE_AWAY', - 'WHEELCHAIR_ACCESSIBLE', 'DISABILITY_PARKING', 'CARPOOL_PARKING', 'EV_CHARGING_STATION', 'CAR_WASH', 'SECURITY', 'AIRPORT_SHUTTLE'].forEach(service => { - var propName = 'services_' + service; - this[propName] = {updated: false, selector:'.landmark label[for="service-checkbox-' + service + '"]', tab: 'more-info' }; - }); + 'WHEELCHAIR_ACCESSIBLE', 'DISABILITY_PARKING', 'CARPOOL_PARKING', 'EV_CHARGING_STATION', 'CAR_WASH', 'SECURITY', 'AIRPORT_SHUTTLE'].forEach(service => { + var propName = 'services_' + service; + this[propName] = { updated: false, selector: '.landmark label[for="service-checkbox-' + service + '"]', tab: 'more-info' }; + }); var observer = new MutationObserver(mutations => { mutations.forEach(mutation => { @@ -224,58 +225,62 @@ // KB Shortcut object var shortcut = { 'all_shortcuts': {}, //All the shortcuts are stored in this array - 'add': function(shortcut_combination, callback, opt) { + 'add': function (shortcut_combination, callback, opt) { //Provide a set of default options var default_options = { 'type': 'keydown', 'propagate': false, 'disable_in_input': false, 'target': document, 'keycode': false }; - if (!opt) {opt = default_options;} + if (!opt) { opt = default_options; } else { for (var dfo in default_options) { - if (typeof opt[dfo] === 'undefined') {opt[dfo] = default_options[dfo];} + if (typeof opt[dfo] === 'undefined') { opt[dfo] = default_options[dfo]; } } } var ele = opt.target; - if (typeof opt.target === 'string') {ele = document.getElementById(opt.target);} + if (typeof opt.target === 'string') { ele = document.getElementById(opt.target); } // var ths = this; shortcut_combination = shortcut_combination.toLowerCase(); //The function to be called at keypress - var func = function(e) { + var func = function (e) { e = e || window.event; if (opt.disable_in_input) { //Don't enable shortcut keys in Input, Textarea fields var element; - if (e.target) {element = e.target;} - else if (e.srcElement) {element = e.srcElement;} - if (element.nodeType === 3) {element = element.parentNode;} - if (element.tagName === 'INPUT' || element.tagName === 'TEXTAREA') {return;} + if (e.target) { element = e.target; } + else if (e.srcElement) { element = e.srcElement; } + if (element.nodeType === 3) { element = element.parentNode; } + if (element.tagName === 'INPUT' || element.tagName === 'TEXTAREA') { return; } } //Find Which key is pressed var code; - if (e.keyCode) {code = e.keyCode;} - else if (e.which) {code = e.which;} + if (e.keyCode) { code = e.keyCode; } + else if (e.which) { code = e.which; } var character = String.fromCharCode(code).toLowerCase(); - if (code === 188) {character = ',';} //If the user presses , when the type is onkeydown - if (code === 190) {character = '.';} //If the user presses , when the type is onkeydown + if (code === 188) { character = ','; } //If the user presses , when the type is onkeydown + if (code === 190) { character = '.'; } //If the user presses , when the type is onkeydown var keys = shortcut_combination.split('+'); //Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked var kp = 0; //Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken - var shift_nums = { '`': '~','1': '!','2': '@','3': '#','4': '$','5': '%','6': '^','7': '&', - '8': '*','9': '(','0': ')','-': '_','=': '+',';': ':','\'': '"',',': '<','.': '>','/': '?','\\': '|' }; + var shift_nums = { + '`': '~', '1': '!', '2': '@', '3': '#', '4': '$', '5': '%', '6': '^', '7': '&', + '8': '*', '9': '(', '0': ')', '-': '_', '=': '+', ';': ':', '\'': '"', ',': '<', '.': '>', '/': '?', '\\': '|' + }; //Special Keys - and their codes - var special_keys = { 'esc': 27,'escape': 27,'tab': 9,'space': 32,'return': 13,'enter': 13,'backspace': 8,'scrolllock': 145, - 'scroll_lock': 145,'scroll': 145,'capslock': 20,'caps_lock': 20,'caps': 20,'numlock': 144,'num_lock': 144,'num': 144, - 'pause': 19,'break': 19,'insert': 45,'home': 36,'delete': 46,'end': 35,'pageup': 33,'page_up': 33,'pu': 33,'pagedown': 34, - 'page_down': 34,'pd': 34,'left': 37,'up': 38,'right': 39,'down': 40,'f1': 112,'f2': 113,'f3': 114,'f4': 115,'f5': 116, - 'f6': 117,'f7': 118,'f8': 119,'f9': 120,'f10': 121,'f11': 122,'f12': 123 }; + var special_keys = { + 'esc': 27, 'escape': 27, 'tab': 9, 'space': 32, 'return': 13, 'enter': 13, 'backspace': 8, 'scrolllock': 145, + 'scroll_lock': 145, 'scroll': 145, 'capslock': 20, 'caps_lock': 20, 'caps': 20, 'numlock': 144, 'num_lock': 144, 'num': 144, + 'pause': 19, 'break': 19, 'insert': 45, 'home': 36, 'delete': 46, 'end': 35, 'pageup': 33, 'page_up': 33, 'pu': 33, 'pagedown': 34, + 'page_down': 34, 'pd': 34, 'left': 37, 'up': 38, 'right': 39, 'down': 40, 'f1': 112, 'f2': 113, 'f3': 114, 'f4': 115, 'f5': 116, + 'f6': 117, 'f7': 118, 'f8': 119, 'f9': 120, 'f10': 121, 'f11': 122, 'f12': 123 + }; var modifiers = { shift: { wanted: false, pressed: false }, ctrl: { wanted: false, pressed: false }, alt: { wanted: false, pressed: false }, meta: { wanted: false, pressed: false } //Meta is Mac specific }; - if (e.ctrlKey) {modifiers.ctrl.pressed = true;} - if (e.shiftKey) {modifiers.shift.pressed = true;} - if (e.altKey) {modifiers.alt.pressed = true;} - if (e.metaKey) {modifiers.meta.pressed = true;} + if (e.ctrlKey) { modifiers.ctrl.pressed = true; } + if (e.shiftKey) { modifiers.shift.pressed = true; } + if (e.altKey) { modifiers.alt.pressed = true; } + if (e.metaKey) { modifiers.meta.pressed = true; } for (var i = 0; i < keys.length; i++) { var k = keys[i]; //Modifiers @@ -292,15 +297,15 @@ kp++; modifiers.meta.wanted = true; } else if (k.length > 1) { //If it is a special key - if (special_keys[k] === code) {kp++;} + if (special_keys[k] === code) { kp++; } } else if (opt.keycode) { - if (opt.keycode === code) {kp++;} + if (opt.keycode === code) { kp++; } } else { //The special keys did not match - if (character === k) {kp++;} + if (character === k) { kp++; } else { if (shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by using lowercase character = shift_nums[character]; - if (character === k) {kp++;} + if (character === k) { kp++; } } } } @@ -324,22 +329,22 @@ }; this.all_shortcuts[shortcut_combination] = { 'callback': func, 'target': ele, 'event': opt.type }; //Attach the function with the event - if (ele.addEventListener) {ele.addEventListener(opt.type, func, false);} - else if (ele.attachEvent) {ele.attachEvent('on' + opt.type, func);} - else {ele['on' + opt.type] = func;} + if (ele.addEventListener) { ele.addEventListener(opt.type, func, false); } + else if (ele.attachEvent) { ele.attachEvent('on' + opt.type, func); } + else { ele['on' + opt.type] = func; } }, //Remove the shortcut - just specify the shortcut and I will remove the binding - 'remove': function(shortcut_combination) { + 'remove': function (shortcut_combination) { shortcut_combination = shortcut_combination.toLowerCase(); var binding = this.all_shortcuts[shortcut_combination]; - delete(this.all_shortcuts[shortcut_combination]); - if (!binding) {return;} + delete (this.all_shortcuts[shortcut_combination]); + if (!binding) { return; } var type = binding.event; var ele = binding.target; var callback = binding.callback; - if (ele.detachEvent) {ele.detachEvent('on' + type, callback);} - else if (ele.removeEventListener) {ele.removeEventListener(type, callback, false);} - else {ele['on' + type] = false;} + if (ele.detachEvent) { ele.detachEvent('on' + type, callback); } + else if (ele.removeEventListener) { ele.removeEventListener(type, callback, false); } + else { ele['on' + type] = false; } } }; // END Shortcut function @@ -351,7 +356,7 @@ } } - function getHoursHtml(label, defaultText){ + function getHoursHtml(label, defaultText) { defaultText = defaultText || _DEFAULT_HOURS_TEXT; return label + ': ' + ' ' + @@ -359,7 +364,7 @@ ''; } - function getSelectedVenue(){ + function getSelectedVenue() { let venue; let features = W.selectionManager.getSelectedFeatures(); if (features.length && features[0].model.type === 'venue') { @@ -370,7 +375,7 @@ function isAlwaysOpen(venue) { var hours = venue.attributes.openingHours; - return hours.length === 1 && hours[0].days.length === 7 && hours[0].fromHour === '00:00' && hours[0].toHour ==='00:00'; + return hours.length === 1 && hours[0].days.length === 7 && hours[0].fromHour === '00:00' && hours[0].toHour === '00:00'; } function isEmergencyRoom(venue) { @@ -383,21 +388,21 @@ function getPvaSeverity(pvaValue, venue) { var isER = pvaValue === 'hosp' && isEmergencyRoom(venue); - return (pvaValue ==='' || pvaValue === '0' || (pvaValue === 'hosp' && !isER)) ? 3 : (pvaValue ==='2') ? 1 : (pvaValue ==='3') ? 2 : 0; + return (pvaValue === '' || pvaValue === '0' || (pvaValue === 'hosp' && !isER)) ? 3 : (pvaValue === '2') ? 1 : (pvaValue === '3') ? 2 : 0; } function addPURWebSearchButton() { var purLayerObserver = new MutationObserver(panelContainerChanged); - purLayerObserver.observe($('#map #panel-container')[0],{childList: true, subtree: true}); + purLayerObserver.observe($('#map #panel-container')[0], { childList: true, subtree: true }); function panelContainerChanged() { if (!$('#WMEPH-HidePURWebSearch').prop('checked')) { var $panelNav = $('.place-update-edit.panel .categories.small'); if ($('#PHPURWebSearchButton').length === 0 && $panelNav.length > 0) { - var $btn = $('