From d13b79cec66703ad11f78e9ad37bdaea43b23e07 Mon Sep 17 00:00:00 2001 From: jangliss Date: Fri, 28 Dec 2018 14:46:07 -0600 Subject: [PATCH 1/3] #355 Use built in encoding function for URI search string. --- WME-Place-Harmonizer.js | 59 +++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/WME-Place-Harmonizer.js b/WME-Place-Harmonizer.js index 83694b1..fdcf62e 100644 --- a/WME-Place-Harmonizer.js +++ b/WME-Place-Harmonizer.js @@ -418,25 +418,24 @@ function buildSearchUrl(searchName, address) { searchName = searchName - .replace(/&/g, '%26') - .replace(/[ \/]/g, '%20') + .replace(/[\/]/g, ' ') .trim(); address = address .replace(/No street, /, '') .replace(/No address/, '') - .replace(/ /g, '%20') - .replace(/CR-/g, 'County%20Rd%20') - .replace(/SR-/g, 'State%20Hwy%20') - .replace(/US-/g, 'US%20Hwy%20') - .replace(/ CR /g, '%20County%20Rd%20') - .replace(/ SR /g, '%20State%20Hwy%20') - .replace(/ US /g, '%20US%20Hwy%20') - .replace(/$CR /g, 'County%20Rd%20') - .replace(/$SR /g, 'State%20Hwy%20') - .replace(/$US /g, 'US%20Hwy%20') + .replace(/CR-/g, 'County Rd ') + .replace(/SR-/g, 'State Hwy ') + .replace(/US-/g, 'US Hwy ') + .replace(/ CR /g, ' County Rd ') + .replace(/ SR /g, ' State Hwy ') + .replace(/ US /g, ' US Hwy ') + .replace(/$CR /g, 'County Rd ') + .replace(/$SR /g, 'State Hwy ') + .replace(/$US /g, 'US Hwy ') .trim(); - return 'http://www.google.com/search?q=' + searchName + (address.length > 0 ? ',%20' + address: ''); + seachName = encodeURIComponent(searchName + (address.length > 0 ? ', ' + address: '')); + return 'http://www.google.com/search?q=' + searchName; } function openWebSearch() { @@ -6326,30 +6325,28 @@ // Build a Google search url based on place name and address function buildGLink(searchName,addr,HN) { var searchHN = '', searchStreet = '', searchCity = ''; - searchName = searchName.replace(/&/g, '%26'); - searchName = searchName.replace(/[ \/]/g, '%20'); + searchName = searchName.replace(/\//g, ' '); if ('string' === typeof addr.street.name && addr.street.name !== null && addr.street.name !== '') { - searchStreet = addr.street.name + ',%20'; - } - searchStreet = searchStreet.replace(/ /g, '%20'); - searchStreet = searchStreet.replace(/CR-/g, 'County%20Rd%20'); - searchStreet = searchStreet.replace(/SR-/g, 'State%20Hwy%20'); - searchStreet = searchStreet.replace(/US-/g, 'US%20Hwy%20'); - searchStreet = searchStreet.replace(/ CR /g, '%20County%20Rd%20'); - searchStreet = searchStreet.replace(/ SR /g, '%20State%20Hwy%20'); - searchStreet = searchStreet.replace(/ US /g, '%20US%20Hwy%20'); - searchStreet = searchStreet.replace(/$CR /g, 'County%20Rd%20'); - searchStreet = searchStreet.replace(/$SR /g, 'State%20Hwy%20'); - searchStreet = searchStreet.replace(/$US /g, 'US%20Hwy%20'); + searchStreet = addr.street.name + ', '; + } + searchStreet = searchStreet.replace(/CR-/g, 'County Rd '); + searchStreet = searchStreet.replace(/SR-/g, 'State Hwy '); + searchStreet = searchStreet.replace(/US-/g, 'US Hwy '); + searchStreet = searchStreet.replace(/ CR /g, ' County Rd '); + searchStreet = searchStreet.replace(/ SR /g, ' State Hwy '); + searchStreet = searchStreet.replace(/ US /g, ' US Hwy '); + searchStreet = searchStreet.replace(/$CR /g, 'County Rd '); + searchStreet = searchStreet.replace(/$SR /g, 'State Hwy '); + searchStreet = searchStreet.replace(/$US /g, 'US Hwy '); if ('string' === typeof HN && searchStreet !== '') { - searchHN = HN + '%20'; + searchHN = HN + ' '; } if ('string' === typeof addr.city.attributes.name && addr.city.attributes.name !== '') { - searchCity = addr.city.attributes.name + ',%20'; + searchCity = addr.city.attributes.name + ', '; } - searchCity = searchCity.replace(/ /g, '%20'); - return 'http://www.google.com/search?q=' + searchName + (searchName ? ',%20' : '') + searchHN + searchStreet + searchCity + addr.state.name; + searchName = searchName + (searchName ? ', ' : '') + searchHN + searchStreet + searchCity + addr.state.name; + return 'http://www.google.com/search?q=' + encodeURIComponent(searchName); } // END buildGLink function // WME Category translation from Natural language to object language (Bank / Financial --> BANK_FINANCIAL) From bfed6ccc6e575a09438a5c7ea5a2e34589e76a4c Mon Sep 17 00:00:00 2001 From: jangliss Date: Fri, 28 Dec 2018 15:35:54 -0600 Subject: [PATCH 2/3] Helps if we can spell. --- WME-Place-Harmonizer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WME-Place-Harmonizer.js b/WME-Place-Harmonizer.js index fdcf62e..542391e 100644 --- a/WME-Place-Harmonizer.js +++ b/WME-Place-Harmonizer.js @@ -434,7 +434,7 @@ .replace(/$US /g, 'US Hwy ') .trim(); - seachName = encodeURIComponent(searchName + (address.length > 0 ? ', ' + address: '')); + searchName = encodeURIComponent(searchName + (address.length > 0 ? ', ' + address: '')); return 'http://www.google.com/search?q=' + searchName; } From c4d5f5a139e3dca661c42052725a5f5e8d1ecdcc Mon Sep 17 00:00:00 2001 From: mapomatic Date: Sun, 30 Dec 2018 00:24:43 -0500 Subject: [PATCH 3/3] Remove references to .is2D() function For some odd reason, it was returning false on at least one place that had 3 nodes. Adding a 4th node would make it return true. --- WME-Place-Harmonizer.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/WME-Place-Harmonizer.js b/WME-Place-Harmonizer.js index 83694b1..3e44bc1 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.134 +// @version 1.3.135 // @description Harmonizes, formats, and locks a selected place // @author WMEPH Development Group // @include /^https:\/\/(www|beta)\.waze\.com\/(?!user\/)(.{2,6}\/)?editor\/?.*$/ @@ -3390,7 +3390,8 @@ // no field HL } } - if (item.is2D()) { + // NOTE: do not use is2D() function. It doesn't seem to be 100% reliable. + if (!item.isPoint()) { bannButt.pointNotArea = new Flag.PointNotArea(); } } else if (item.isParkingLot() || (newName && newName.trim().length > 0)) { // for non-residential places @@ -4093,7 +4094,8 @@ var isPoint = item.isPoint(); - var isArea = item.is2D(); + // NOTE: do not use is2D() function. It doesn't seem to be 100% reliable. + var isArea = !isPoint; var maxPointSeverity = 0; var maxAreaSeverity = 3; var highestCategoryLock = -1;