Skip to content

Commit

Permalink
Merge v1.1.52-rc
Browse files Browse the repository at this point in the history
Conflicts:
	WME-Place-Harmonizer.user.js
  • Loading branch information
mapomatic committed Dec 29, 2016
2 parents 194371f + ba9853a commit 0083416
Showing 1 changed file with 74 additions and 12 deletions.
86 changes: 74 additions & 12 deletions WME-Place-Harmonizer.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
/* global define */

// ==UserScript==
// @name WME Place Harmonizer
// @name WME Place Harmonizer
// @namespace https://github.com/WazeUSA/WME-Place-Harmonizer/raw/master/WME-Place-Harmonizer.user.js
// @version 1.1.48
// @version 1.1.52
// @description Harmonizes, formats, and locks a selected place
// @author WMEPH development group
// @include https://*.waze.com/editor/*
Expand Down Expand Up @@ -252,6 +252,10 @@
function runPH() {
// Script update info
var WMEPHWhatsNewList = [ // New in this version
'1.1.52: Fixed bug reporting PMs.',
'1.1.51: Fixed lowercase alphanumeric phone number parsing.',
'1.1.50: Fixed bug with adding hours more than once.',
'1.1.49: Added a Glink modification to turn them into links and limit search radius.',
'1.1.47: Fix for one-field-update-per-click issue',
'1.1.46: allow for https:// in urls. (credit RavenDT)',
'1.1.45: Add disable highlights for above rank function (credit RavenDT), stop url link from adding http://',
Expand All @@ -276,6 +280,8 @@
var thisUser = W.loginManager.user;
var UpdateObject = require("Waze/Action/UpdateObject");

modifyGoogleLinks();

// Whitelist initialization
compressedWLLS = false;
if ( validateWLS( LZString.decompressFromUTF16(localStorage.getItem(WLlocalStoreNameCompressed)) ) === false ) { // If no compressed WL string exists
Expand Down Expand Up @@ -712,6 +718,7 @@
var s1 = s.replace(/\D/g, ''); // remove non-number characters
var m = s1.match(/^1?([2-9]\d{2})([2-9]\d{2})(\d{4})$/); // Ignore leading 1, and also don't allow area code or exchange to start with 0 or 1 (***USA/CAN specific)
if (!m) { // then try alphanumeric matching
if (s) { s = s.toUpperCase() };
s1 = s.replace(/[^0-9A-Z]/g, '').replace(/^\D*(\d)/,'$1').replace(/^1?([2-9][0-9]{2}[0-9A-Z]{7})/g,'$1');
s1 = replaceLetters(s1);
m = s1.match(/^([2-9]\d{2})([2-9]\d{2})(\d{4})$/); // Ignore leading 1, and also don't allow area code or exchange to start with 0 or 1 (***USA/CAN specific)
Expand Down Expand Up @@ -1301,7 +1308,7 @@
} else {
if (confirm('WMEPH: URL Matching Error!\nClick OK to report this error') ) { // if the category doesn't translate, then pop an alert that will make a forum post to the thread
forumMsgInputs = {
subject: 'Re: WMEPH URL comparison Error report',
subject: 'WMEPH URL comparison Error report',
message: 'Error report: URL comparison failed for "' + item.attributes.name + '"\nPermalink: ' + placePL
};
WMEPH_errorReport(forumMsgInputs);
Expand Down Expand Up @@ -1768,7 +1775,7 @@
active: true, severity: 0, message: "", value: "Report script error", title: "Report a script error",
action: function() {
var forumMsgInputs = {
subject: 'Re: WMEPH Bug report',
subject: 'WMEPH Bug report: Scrpt Error',
message: 'Script version: ' + WMEPHversion + devVersStr + '\nPermalink: ' + placePL + '\nPlace name: ' + item.attributes.name + '\nCountry: ' + addr.country.name + '\n--------\nDescribe the error: \n '
};
WMEPH_errorReport(forumMsgInputs);
Expand Down Expand Up @@ -2397,7 +2404,7 @@
if (hpMode.harmFlag) {
if (confirm('WMEPH: Localization Error!\nClick OK to report this error') ) { // if the category doesn't translate, then pop an alert that will make a forum post to the thread
forumMsgInputs = {
subject: 'Re: WMEPH Localization Error report',
subject: 'WMEPH Localization Error report',
message: 'Error report: Localization match failed for "' + addr.state.name + '".'
};
WMEPH_errorReport(forumMsgInputs);
Expand Down Expand Up @@ -2512,8 +2519,8 @@
if (nsMultiMatch) {
if (confirm('WMEPH: Multiple matches found!\nDouble check the script changes.\nClick OK to report this situation.') ) {
forumMsgInputs = {
subject: 'Re: WMEPH Multiple match report',
message: 'Error report: PNH Order Nos. "' + orderList.join(', ') + '" are ambiguous multiple matches.'
subject: 'Order Nos. "' + orderList.join(', ') + '" WMEPH Multiple match report',
message: 'Error report: PNH Order Nos. "' + orderList.join(', ') + '" are ambiguous multiple matches.\n \nExample Permalink: ' + placePL + ''
};
WMEPH_errorReport(forumMsgInputs);
}
Expand Down Expand Up @@ -3808,7 +3815,7 @@
if (duplicateName.length+1 !== dupeIDList.length && devUser) { // If there's an issue with the data return, allow an error report
if (confirm('WMEPH: Dupefinder Error!\nClick OK to report this') ) { // if the category doesn't translate, then pop an alert that will make a forum post to the thread
forumMsgInputs = {
subject: 'Re: WMEPH Bug report',
subject: 'WMEPH Bug report DupeID',
message: 'Script version: ' + WMEPHversion + devVersStr + '\nPermalink: ' + placePL + '\nPlace name: ' + item.attributes.name + '\nCountry: ' + addr.country.name + '\n--------\nDescribe the error:\nDupeID mismatch with dupeName list'
};
WMEPH_errorReport(forumMsgInputs);
Expand Down Expand Up @@ -3900,7 +3907,7 @@
});
W.model.actionManager.add(m_action);
}

// Turn on website linking button if there is a url
if (newURL !== null && newURL !== "") {
bannButt.PlaceWebsite.active = true;
Expand Down Expand Up @@ -4578,9 +4585,16 @@
}
}

// Formats "hour object" into a string.
function formatOpeningHour(hourEntry) {
var dayNames = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
var hours = hourEntry.attributes.fromHour + '-' + hourEntry.attributes.toHour;
return hourEntry.attributes.days.map(function(day) {
return dayNames[day] + ' ' + hours;
}).join(', ');
}
// Pull natural text from opening hours
function getOpeningHours(venue) {
var formatOpeningHour = W.brara.ViewHelpers.formatOpeningHour;
return venue && venue.getOpeningHours && venue.getOpeningHours().map(formatOpeningHour);
}
// Parse hours paste for hours object array
Expand Down Expand Up @@ -5530,7 +5544,7 @@
// Generally this means the category used in the PNH sheet is not close enough to the natural language categories used inside the WME translations
if (confirm('WMEPH: Category Error!\nClick OK to report this error') ) {
forumMsgInputs = {
subject: 'Re: WMEPH Bug report',
subject: 'WMEPH Bug report: no tns',
message: 'Error report: Category "' + natCategories + '" is not translatable.'
};
WMEPH_errorReport(forumMsgInputs);
Expand Down Expand Up @@ -6809,6 +6823,54 @@
}
}

function modifyGoogleLinks() {
$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
try {
if (originalOptions.type === "GET") {
if (originalOptions.url === "/maps/api/place/autocomplete/json" && !originalOptions.data.hasOwnProperty("location")) {
options.data = $.param($.extend(originalOptions.data, {
location: W.map.getCenter().transform(W.map.getProjection(), W.map.displayProjection).lat + "," + W.map.getCenter().transform(W.map.getProjection(), W.map.displayProjection).lon,
radius: 3200
}));
}
}
} catch(e) {}
});
$(document).ajaxSuccess(function(event, jqXHR, ajaxOptions, data) {
try {
if (ajaxOptions && ajaxOptions.hasOwnProperty("url")) {
if (ajaxOptions.url.startsWith("/maps/api/place/details/json")) {
if (data && data.hasOwnProperty("status") && data.status === "OK") {
if (data.hasOwnProperty("result") && data.result.hasOwnProperty("url") && data.result.hasOwnProperty("place_id")) {
var gpids = document.getElementsByClassName("placeId");
for (var i = 0; i < gpids.length; i++) {
if (data.result.place_id === gpids[i].innerHTML) {
gpids[i].innerHTML = "<a href='" + data.result.url + "' target='_wmegpid'>" + data.result.place_id + "</a>";
}
};
}
}
}
if (ajaxOptions.url.startsWith("/maps/api/place/autocomplete/json")) {
var uuids = document.getElementsByClassName("uuid");
for (var i = 0; i < uuids.length; i++) {
if (uuids[i].className === "uuid") {
events = $._data(uuids[i], "events");
if (events && events.hasOwnProperty("change") && events.change.length === 1) {
$(uuids[i]).change(function(event) {
if (event && event.hasOwnProperty("val")) {
$.get(W.Config.places_api.url.details, {placeid: event.val, key: W.Config.places_api.key});
}
});
}
}
}
}
}
} catch(e) {}
});
}

// Run the script...
placeHarmonizer_bootstrap();

Expand Down Expand Up @@ -7286,4 +7348,4 @@
})();

//$('#service-checkbox-CREDIT_CARDS').siblings('label')[0].style="background-color:#dfd"
//$('.form-control')[8].style="background-color:#dfd"
//$('.form-control')[8].style="background-color:#dfd"

0 comments on commit 0083416

Please sign in to comment.