- // ==UserScript==
- // @name WME Color Errors
- // @version 2025.08.08.01
- // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAALuSURBVHja7Jots6swEIb7x6qiUFVVUVEoVBSqKioqU8EfqKpCRaE6FShMo5gjUCiOYebOzTXnvaKlhR44LbS9vcyQmVWdbt5nd7P5GGbr/eFjvT98jtQ+Zuv9oVzvDxiplbMTyVgBPieACWACmADeD/Bn7ABfE8D77PfYAfBUgFCt4DEKZz7H/Js5oMzDSoXPBPh6GCBSHAvSJviGkQW4it4HECmvI9IncygYY2ALcgPGgTccpD9AkQRwf4g4cQPEWYnzsDHkXRlxESTFawFixUDOkxIwIeEvLiKojFFclKPIDOJwhWWX6AWHWF35VPFrAEJeKwXHw9aUsIm8TO6GyE7S80iA3bUuCGRiUZotPKeWRR4+F0DXxBMeIrNHoUaRhhAAKCJei+htI8ocnZUGG7c+j34OQF08FTvk5xLJELJKiEICAEixWfbsRuySOSDHTtA+ED8D5Jo3nF3EA4CBqkR4p98KDd63nc4VTMNv3gga1/lwALeahCoYi6tRA5hzhFmJPFr1Kp92AADWQNHqd3cYQORX7Y1D52gZObQ3YAO7Nu86s5X7Wjb9qD/AOboihkX7SDfLhwGWm7TDu0UsLlnqDbATVR1SKGO7CEAfAqDo0m+NOvsmYjdsDXByq4wsYkkGAxDZkd1cN+YevIgbPb11IV8vuB52lz8CHhWP7QNG1foyC5CULZMWMWQfCCoRFy1+ygQBq+07yjxnJ65vLnMqELWVk82gBbvRRh24MuroOhFELQi0u+6HnYViSRuLT+gUbclAmSEOFVYeOx6nGQPzJbY6Qdb+B6RaNJoBlfFrTqNZ6DfuAIQJ6LTE0FGmGoKRRob8MHv9haY56RxkwaG0QV7am6JtkSHRCvzqokOY+Lc3slR3HJkdCuatoIIAwdmOJUWdtosMg9Dp++7EpiWad+0Bp6z9V68S6/0BgfTBvr1MOKCMwZfBs59Vfs3G/CZUvczZ6XV6ApgAJoAJYAIYM8DoP/YY9ec2fwcAaebQXj6i79wAAAAASUVORK5CYII=
- // @description Colorisation pour afficher les erreurs
- // @include https://www.waze.com/editor*
- // @include https://www.waze.com/*/editor*
- // @include https://beta.waze.com/*
- // @exclude https://www.waze.com/user/*
- // @exclude https://www.waze.com/*/user/*
- // @namespace https://greasyfork.org/fr/scripts/21186-wme-color-errors
- // @author Sebiseba / MatthieuF44 par intérim :)
- // @copyright Sebiseba 2014-2023
- // @license GNU GPL v2
- // @grant none
- // ==/UserScript==
- WMECE_log("Démarrage en cours, version : " + GM_info.script.version);
- var wmeSDK;
- window.SDK_INITIALIZED.then(() => {
- wmeSDK = getWmeSdk({ scriptId: "WME-Color-Error", scriptName: GM_info.script.name });
- wmeSDK.Events.once({ eventName: "wme-ready" }).then(CErrors_init);
- });
-
-
- var WMECErrors = {}, ColorErrors_mapLayer = [], CErrLeg, CErrSeg, CErrPoi, debug = false;
- var ActiveCountry, ABBR, UpdateObject, cntryDB = {
- FR: { str_lvl: 0, pri_lvl: 2, min_lvl: 3, maj_lvl: 4, rmp_lvl: 4, fwy_lvl: 4, rwy_lvl: 4, nar_lvl: 0 },
- GP: { str_lvl: 0, pri_lvl: 2, min_lvl: 3, maj_lvl: 4, rmp_lvl: 4, fwy_lvl: 4, rwy_lvl: 4, nar_lvl: 0 },
- MB: { str_lvl: 0, pri_lvl: 2, min_lvl: 3, maj_lvl: 4, rmp_lvl: 4, fwy_lvl: 4, rwy_lvl: 4, nar_lvl: 0 },
- FG: { str_lvl: 0, pri_lvl: 2, min_lvl: 3, maj_lvl: 4, rmp_lvl: 4, fwy_lvl: 4, rwy_lvl: 4, nar_lvl: 0 },
- RE: { str_lvl: 0, pri_lvl: 2, min_lvl: 3, maj_lvl: 4, rmp_lvl: 4, fwy_lvl: 4, rwy_lvl: 4, nar_lvl: 0 },
- FP: { str_lvl: 0, pri_lvl: 2, min_lvl: 3, maj_lvl: 4, rmp_lvl: 4, fwy_lvl: 4, rwy_lvl: 4, nar_lvl: 0 },
- BE: { str_lvl: null, pri_lvl: 1, min_lvl: 2, maj_lvl: 3, rmp_lvl: 4, fwy_lvl: 4, rwy_lvl: 4, nar_lvl: 0 }
- }; // France
- var CErrWaze, CErrorsMap, CErrorsModel, CErrorsI18n, CErrorsOpenLayers, CErrorshandle, CErrorshandleClass, CErrorshandleClass2,
-
- //french rules
- streetNameSeg = "^(^Le |^La |^Les |Grande |Allée |[ ]?Avenue[]?|Boulevard |Chemin |Cité |Clos |Côte |Cour[s]? |Descente |Domaine |Hameau |Impasse |Levée |Lotissement |Mail |Montée |Parc |Parvis |Passage |Place |Placette |Pont |Promenade |Quai |Résidence[s]? |Route |[ ]?Rue[ ]?|Ruelle |Sente |Sentier |Square |Terrasse |Traverse |Venelle |Villa |Voie )",
- parkNameSeg = "^(Aire |Place |Square )",
- excepNameSeg = "(Périphérique |Rocade |Duplex |Tunnel |Pont )",
- privNameSeg = "^(Allée |Avenue |Boulevard |Chemin |Clos |Côte |Cours |Faubourg |Hameau |Impasse |Lotissement |Mail |Parvis |Passage |Port |Porte |Promenade |Quai |Route |Rue |Ruelle |Sente |Sentier |Terrasse |Voie )",
- parkNamePoi = "(Parking[s]?|Parc-Relais|Placette|Aire|Arrêt|Emplacement)",
- religiousPoi = "(Abbatiale|Abbaye|Basilique|Calvaire|Carmel|Cathédrale|Chapelle|Cloître|Collégiale|Conjuratoire|Couvent|Crypte|Dôme|Église|Grande Mosquée|Grotte|Mandir|Maison Diocésaine|Monastère|Mosquée|Notre-Dame|Oratoire|Ordre|Pagode|Paroisse|Presbytère|Prieuré|Sanctuaire|Stupa|Synagogue|Temple)",
- busPoi = "(Bus[ ][-][ ]|Gare Routière)",
- tramPoi = "(Tramway[ ][-][ ]|Métro[ ][-][ ])",
- possibleTransPoi = "(Tram$|Métro$|Arrêt$|Gare$|Station$|Tram |Métro |Arrêt |Gare |Station )",
-
- // common all countries
- stationsPoi = "(CAR_WASH|CHARGING_STATION|FACTORY_INDUSTRIAL|GAS_STATION|JUNCTION_INTERCHANGE|PARKING_LOT|SEAPORT_MARINA_HARBOR|SKI_AREA|SUPERMARKET_GROCERY|TAXI_STATION|TRANSPORTATION|TRASH_AND_RECYCLING_FACILITIES)",
- landmarkPoi = "(RIVER_STREAM|CANAL|SEA_LAKE_POOL|SWAMP_MARSH|ISLAND|FOREST_GROVE|BRIDGE)",
- excepCatPoi = "(RIVER_STREAM|CANAL|SEA_LAKE_POOL|SWAMP_MARSH|ISLAND|FOREST_GROVE|BRIDGE|PARK|JUNCTION_INTERCHANGE|CEMETERY|TUNNEL)",
- PoiWithoutCompleteAdress = "(RIVER_STREAM|CANAL|SEA_LAKE_POOL|SWAMP_MARSH|ISLAND|FOREST_GROVE|BRIDGE|PARK|JUNCTION_INTERCHANGE|CEMETERY|TUNNEL|STADIUM|SPORTS|CARPOOL|TRANSPORTATION|SKI_AREA|SEAPORT_MARINA_HARBOR|TAXI_STATION|PLAZA)",
- entryPointPoi = "(BRIDGE|CANAL|FOREST_GROVE|ISLAND|JUNCTION_INTERCHANGE|POOL|RIVER_STREAM|SEA_LAKE_POOL|SWAMP_MARSH|TUNNEL)",
- wazeBot = "(admin|avseu|WazeFeed|waze-maint-bot|Waze3rdparty|evcs feed 1)";
-
- // *********************
- // ** HELPER FUNCTION **
- // *********************
- function getId(node) {
- return document.getElementById(node);
- }
- function getElementsByClassName(classname, node) {
- node || (node = document.getElementsByTagName("body")[0]);
- for (var a = [], re = new RegExp("\\b" + classname + "\\b"), els =
- node.getElementsByTagName("*"), i =
- 0, j =
- els.length; i < j; i++) {
- re.test(els[i].className) && a.push(els[i]);
- }
- return a;
- }
- function IsJsonString(str) {
- try {
- JSON.parse(str);
- } catch (e) {
- return false;
- }
- return true;
- }
- function getSelectedDataModelObjects() {
- return CErrorsEdits.getSelection();
- }
- function openInNewTab(url) {
- var win = window.open('https://wazeopedia.waze.com/wiki/France/' + url, '_blank');
- win.focus();
- }
- function onScreen(obj) {
- if (obj.getOLGeometry()) {
- return (W.map.getExtent());
- //return(W.map.getExtent().intersectsBounds(obj.getOLGeometry().getBounds()));
- }
- return (false);
- }
-
- // *************
- // ** INIT **
- // *************
-
- // Fonction log avec affichage du nom du script
- function WMECE_log(message) {
- if (typeof message === 'string') {
- console.log(GM_info.script.name + ': ' + message);
- } else {
- console.log(GM_info.script.name + ': ', message);
- }
- }
-
- function CErrors_init() {
- WMECE_log("Initialisation en cours ");
- fixTel();
- // SDK W object needed
- CErrWaze = wmeSDK; if (typeof (CErrWaze) === 'undefined') { if (debug) { WMECE_log("WME ColorErrors - CErrWaze : NOK"); } window.setTimeout(CErrors_init, 500); return; }
- CErrorsEdits = CErrWaze.Editing; if (typeof (CErrorsEdits) == 'undefined') { if (debug) { WMECE_log("WME ColorErrors - CErrorsedits : NOK"); } window.setTimeout(CErrors_init, 500); return; }
- CErrorsMapSDK = CErrWaze.Map; if (typeof (CErrorsMapSDK) == 'undefined') { if (debug) { WMECE_log("WME ColorErrors - CErrorsmap : NOK"); } window.setTimeout(CErrors_init, 500); return; }
- CErrorsModel = CErrWaze.DataModel; if (typeof (CErrorsModel) == 'undefined') { if (debug) { WMECE_log("WME ColorErrors - CErrorsmodel : NOK"); } window.setTimeout(CErrors_init, 500); return; }
- if (typeof (CErrorsModel.Countries.getTopCountry()) === 'undefined' || CErrorsModel.Countries.getTopCountry() === null) { if (debug) { WMECE_log("WME ColorErrors - CErrorsmodel Countries top : NOK"); } window.setTimeout(CErrors_init, 500); return; }
- CErrorsI18n = I18n; if (typeof (CErrorsI18n) == 'undefined') { if (debug) { console.error('WME ColorErrors - CErrorsI18n : NOK'); } setTimeout(CErrors_init, 500); return; }
- CErrorsUser = CErrWaze.State.getUserInfo(); if (typeof (CErrorsUser) === 'undefined') { if (debug) { WMECE_log("WME ColorErrors - CErrorsUser : NOK"); } window.setTimeout(CErrors_init, 500); return; }
-
- // W object needed à supprimer quand SDK W object needed fonctionne
- //CErrWaze = W; if (typeof (CErrWaze) === 'undefined') { if (debug) { console.error("WME ColorErrors - CErrWaze : NOK"); } window.setTimeout(CErrors_init, 500); return; }
- CErrorsMap = W.map; if (typeof (CErrorsMap) == 'undefined') { if (debug) { console.error("WME ColorErrors - CErrorsmap : NOK"); } window.setTimeout(CErrors_init, 500); return; }
- //CErrorsModel = CErrWaze.model; if (typeof (CErrorsModel) == 'undefined') { if (debug) { console.error("WME ColorErrors - CErrorsmodel : NOK"); } window.setTimeout(CErrors_init, 500); return; }
- //if (typeof (CErrorsModel.Countries.getTopCountry()) === 'undefined' || CErrorsModel.Countries.getTopCountry() === null) { if (debug) { console.error("WME ColorErrors - CErrorsmodel Countries top : NOK"); } window.setTimeout(CErrors_init, 500); return; }
- //CErrorsI18n = I18n; if (typeof (CErrorsI18n) == 'undefined') { if (debug) { console.error('WME ColorErrors - CErrorsI18n : NOK'); } setTimeout(CErrors_init, 500); return; }
- //--------
-
-
- // OpenLayers
- CErrorsOpenLayers = OpenLayers; if (typeof (CErrorsOpenLayers) === 'undefined') { if (debug) { console.error("WME ColorErrors - OL : NOK"); } window.setTimeout(CErrors_init, 500); return; }
- // Waze GUI needed
- CErrorshandle = getId("user-info"); if (typeof (CErrorshandle) == 'undefined') { window.setTimeout(CErrors_init, 500); return; }
- CErrorshandleClass = getElementsByClassName("nav-tabs", CErrorshandle)[0]; if (typeof (CErrorshandleClass) === 'undefined') { window.setTimeout(CErrors_init, 500); return; }
- CErrorshandleClass2 = getElementsByClassName("tab-content", CErrorshandle)[0]; if (typeof (CErrorshandleClass2) === 'undefined') { window.setTimeout(CErrors_init, 500); return; }
-
- // Verify localStorage. Init if empty or not correct
- if (typeof (localStorage.WMEColorErrors) === "undefined" || localStorage.WMEColorErrors.lenght === null || !IsJsonString(localStorage.WMEColorErrors)) {
- WMECErrors.opacity = 0.85; // Icons Opacity on map
- WMECErrors.myLvl = false; // Show when editable
- WMECErrors.seg_Bad = false; // Bad Segments (group)
- WMECErrors.seg_Priv = true; // Private with bad name
- WMECErrors.seg_Park = true; // Parking with name (but Place / Square)
- WMECErrors.seg_Rail = true; // Railroad with bad name
- WMECErrors.seg_HW_name = true; //Highways with bad name
- WMECErrors.seg_Dir_name = true; // Directions but not Ramp/Freeway
- WMECErrors.seg_Toll = true; // Toll (but Ramp/Freeway)
- WMECErrors.seg_Ramp_name = true; // Ramp with 3 directions or more
- WMECErrors.seg_Ramp_city = true; // Ramp with city name
- WMECErrors.seg_RShield = true; // Wrong prefix
- WMECErrors.seg_DleSpace = true; // Double space in name
- WMECErrors.seg_SegBadRS = true; // RoadShield but bad type
- WMECErrors.seg_SegRSWithoutCity = true; // RoadShield without city in alt
- WMECErrors.seg_HNFree = true; // House number on Freeway or ramp
- WMECErrors.seg_BadSpeed = true; // Bad speed (ex: >80km/h in city)
- WMECErrors.seg_BadAltState = true; // Alt State != Main State
- WMECErrors.seg_EmptyCityAlt = true; // Alt City is empty
- WMECErrors.seg_LockValue = true; // Bad lock
- // POI
- WMECErrors.poi_Bad = false; // Bad POI (group)
- WMECErrors.poi_Park_name = true; // Parking with [P]
- WMECErrors.poi_Address = true; // Bad adresss
- WMECErrors.poi_Entry = true; // Entry Point not defined
- WMECErrors.poi_LandM = true; // Landmark with address (street |& city)
- WMECErrors.poi_DleSpace = true; // Double space in name
- // Low errors
- WMECErrors.poi_Resid = true; // Maybe a residential
- WMECErrors.poi_Google = true; // No link with Google
- WMECErrors.poi_Phone = true; // bad phone number format
- WMECErrors.poi_AutoFixTel = false; // Auto-Format phone number when error
- WMECErrors.poi_WFeed = true; // Place created by WazeFeed
- WMECErrors.poi_WPark = true; // Place created by WazeParking1
- WMECErrors.poi_Relig = true; // Religious Center with bad name
- WMECErrors.poi_Transp = true; // Bad type or bad name for Buses, Subway or Tramway
- WMECErrors.poi_GasSta = true; // Gas Station with bad name
- WMECErrors.poi_Other = true; // Place "Other"
- //Autolock
- WMECErrors.autoLock = true; // Autolock
- localStorage.setItem('WMEColorErrors', JSON.stringify(WMECErrors));
- }
-
- // WME Layers check
- var layersColor = CErrorsMap.getLayersBy("uniqueName", "__WME_Color_Errors"), layersIcons = CErrorsMap.getLayersBy("uniqueName", "__WME_Color_Errors_Icons");
- var ColorErrors_style = new CErrorsOpenLayers.Style({
- pointRadius: 2,
- fontWeight: "normal",
- label: "${labelText}",
- fontFamily: "Tahoma, Courier New",
- labelOutlineColor: "#FFFFFF",
- labelOutlineWidth: 2,
- fontColor: '#000000',
- fontSize: "10px"
- });
- if (layersColor.length === 0) {
- ColorErrors_mapLayer = new CErrorsOpenLayers.Layer.Vector("Color Errors", {
- displayInLayerSwitcher: false,
- uniqueName: "__WME_Color_Errors",
- styleMap: new CErrorsOpenLayers.StyleMap(ColorErrors_style)
- });
- CErrorsI18n.translations[CErrorsI18n.locale].layers.name["__WME_Color_Errors"] = "Color Errors";
- CErrorsMap.addLayer(ColorErrors_mapLayer);
- ColorErrors_mapLayer.setVisibility(true);
- }
- if (layersIcons.length === 0) {
- ColorErrors_mapLayerIcons = new CErrorsOpenLayers.Layer.Vector("Color Errors Icons", {
- displayInLayerSwitcher: false,
- uniqueName: "__WME_Color_Errors_Icons",
- styleMap: new CErrorsOpenLayers.StyleMap(ColorErrors_style)
- });
- CErrorsI18n.translations[CErrorsI18n.locale].layers.name["__WME_Color_Errors_Icons"] = "Color Errors Icons";
- CErrorsMap.addLayer(ColorErrors_mapLayerIcons);
- ColorErrors_mapLayerIcons.setVisibility(true);
- }
- UpdateObject = require("Waze/Action/UpdateObject");
- ActiveCountry = CErrorsModel.Countries.getTopCountry().abbr;
- ABBR = cntryDB[ActiveCountry];
- CErrors_Mainhtml();
- }
- function CErrAddInfo() {
- const editPanelObserver = new MutationObserver(function (mutations) {
- mutations.forEach((mutation) => {
- const nodeList = mutation.addedNodes;
- nodeList.forEach(addedNode => {
- // Only fire up if it's a node
- if (addedNode.nodeType === Node.ELEMENT_NODE) {
- /** @returns `<div>` element. */
- const alertDiv = /**@type {Element} */(addedNode).querySelector('wz-alerts-group');
- if (alertDiv) {
- if (getSelectedDataModelObjects().length !== 0 && !getId('ErrorsList')) {
- var ErrorsList_Div = document.createElement('span');
- ErrorsList_Div.id = "ErrorsList";
- ErrorsList_Div.style.cssText = "list-style-type:none;";
- if (document.querySelector('wz-alerts-group')) {
- document.querySelector('wz-alerts-group').appendChild(ErrorsList_Div);
- }
- CErrColor()
- }
- }
-
- }
- }
- );
- });
- });
- editPanelObserver.observe(document.getElementById('edit-panel'), { childList: true, subtree: true });
- }
-
-
-
- // *************
- // ** HTML **
- // *************
- function CErrors_Mainhtml() {
- if (CErrorsI18n.locale == 'fr') {
- CErrSeg = new Array('Contrôle des segments',
- 'Mauvais segments',
- 'Voie privée avec possible mauvais nom',
- 'Voie de Parking nommée',
- 'Voie ferrée nommée ou nom en alt',
- 'Types Routes avec mauvais nom',
- 'Bretelle avec plusieurs directions',
- 'Direction (sauf bretelle et Autoroute)',
- 'Mauvais préfixe (RoadShield)',
- 'Double espace dans le nom',
- 'Péage (sauf bretelle et Autoroute)',
- 'Bretelle/Autoroute avec nom de ville',
- 'Le RoadShield doit être en alt',
- 'Le nom de route doit être en alt',
- 'RoadShield sur mauvais type de voie',
- 'N° de rue sur mauvais type de voie',
- 'Mauvaise vitesse validée',
- 'Département alt différent du principal',
- 'Lock non conforme (Auto ou valeur)',
- 'Alt non conforme',
- 'RoadShield sans ville en alt'
- );
- CErrPoi = new Array('Contrôle des places',
- 'Mauvaises places',
- 'Parking mal nommé ou sans nom',
- 'Adresse incorrecte ou incomplète',
- 'Point d\'entrée non défini',
- 'Site naturel avec adresse',
- 'Double espace dans le nom',
- 'Peut-être une place résidentielle',
- 'Pas de lien avec Google',
- 'Lieu édité par WazeFeed',
- 'Lieu de type "Autres"',
- 'Lieu édité par WazeParking1',
- 'Parking : type non défini',
- 'Mauvais format du n° de tel',
- 'Lieu de culte (nom ou catégorie)',
- 'Transport (nom ou catégorie)',
- 'Station-Service mal nommée',
- 'Correction automatique du numéro'
- );
- CErrLeg = new Array('Légende',
- 'A corriger',
- 'A vérifier',
- 'Pour information',
- 'Réglages',
- 'Opacité des icônes',
- 'Afficher seulements les éditables',
- 'Verrouillé par la publicité',
- 'Auto-verrouillage'
- );
- }
- else {
- CErrSeg = new Array('Segments Checking',
- 'Bad Segments',
- 'Private with possible bad name',
- 'Parking with bad name or without',
- 'Railroad with name or altname',
- 'Highways with bad name',
- 'Ramp with several directions',
- 'Direction (but Ramp/Freeway)',
- 'Wrong prefix (RoadShield)',
- 'Double spacing in name',
- 'Toll (but Ramp/Freeway)',
- 'Ramp/Freeway with city name',
- 'RoadShield must be in alt',
- 'Road name must be in alt',
- 'RoadShield but bad type',
- 'HN but bad type',
- 'Bad speed verified',
- 'Alt State dirrent to Main State',
- 'Bad lock (Auto or value)',
- 'Bad Alt',
- 'RoadShield without city in alt'
- );
- CErrPoi = new Array('Places Checking',
- 'Bad Places',
- 'Parking with bad name or null',
- 'Bad or incomplete address',
- 'Entry Point not defined',
- 'Natural features with address',
- 'Double spacing in name',
- 'Maybe a residential place',
- 'No link with Google',
- 'Place created by WazeFeed',
- 'Place type is "Other"',
- 'Place created by WazeParking1',
- 'Parking : type undefined',
- 'Bad phone number format',
- 'Religious Center (name or cat)',
- 'Transportation (name or cat)',
- 'Gas Station with bad name',
- 'Auto number format'
- );
- CErrLeg = new Array('Legend',
- 'To correct',
- 'To check',
- 'For information',
- 'Settings',
- 'Icons opacity',
- 'Show when editable',
- 'Locked by ad',
- 'Autolock'
- );
- }
- //Create content in CErrors's tab
- var CEnewtab = document.createElement('li');
- CEnewtab.innerHTML = "<a href='#sidepanel-ColorErrors' data-toggle='tab'><span class='fa fa-eye' title='Color Errors'></span></a>";
- CErrorshandleClass.appendChild(CEnewtab);
-
- var WMECErrors = JSON.parse(localStorage.getItem('WMEColorErrors'));
- if (typeof (WMECErrors.autoLock) == "undefined") { WMECErrors.autoLock = false; }
- var CEaddon = document.createElement('section');
- CEaddon.id = "sidepanel-ColorErrors";
- var CEcontent = '<div style="float:left; margin-left:5px;padding-bottom:10px;"><b><a href="https://greasyfork.org/fr/scripts/21186-wme-color-errors" target="_blank"><u>WME Color Errors</u></a></b> v' + GM_info.script.version + '</div>'
- + '<H6 style="float:left;clear:both;">' + CErrLeg[4] + '</H6><span style="float:left;clear:both;font-weight:bold;margin-top:10px;">' + CErrLeg[5] + '</span><input id="errOpacity" type="range" max="1" min="0" step="0.05" style="float:left;width:240px;"><div id="opacityValue" style="float:left;font-weight:bold;padding-left:10px;"></div>'
- + '<div style="float:left;clear:both;"><input type="checkbox" id="_myLvl"' + (WMECErrors.myLvl ? ' checked' : '') + '/> ' + CErrLeg[6] + '</div>'
- + '<br><br><H6 style="float:left;margin-top:10px;">' + CErrSeg[0] + '</H6><div style="clear:both;">'
- + '<input type="checkbox" id="_seg_Bad"' + (WMECErrors.seg_Bad ? ' checked' : '') + '/> <label for="_seg_Bad" style="font-weight:normal;">' + CErrSeg[1] + '</label><br><div id="BadSeg" style="margin-left:5px;"><table>'
- + fillHtml("seg_Ramp_name", "seg_Bad", "#ff7700", "\uf25a", CErrSeg[6])
- + fillHtml("seg_BadSpeed", "seg_Bad", "#ff7700", "\uf1ce", CErrSeg[16])
- + fillHtml("seg_BadAltState", "seg_Bad", "#ff7700", "\uf037", CErrSeg[17])
- + fillHtml("seg_EmptyCityAlt", "seg_Bad", "#ff7700", "\uf064", CErrSeg[19])
- + fillHtml("seg_LockValue", "seg_Bad", "#ff7700", "\uf023", CErrSeg[18])
- + fillHtml("seg_Park", "seg_Bad", "#ff0000", "\uf288", CErrSeg[3])
- + fillHtml("seg_Rail", "seg_Bad", "#ff0000", "\uf238", CErrSeg[4])
- + fillHtml("seg_Dir_name", "seg_Bad", "#ff0000", "\uf0a9", CErrSeg[7])
- + fillHtml("seg_Toll", "seg_Bad", "#ff0000", "\uf155", CErrSeg[10])
- + fillHtml("seg_Ramp_city", "seg_Bad", "#ff0000", "\uf015", CErrSeg[11])
- + fillHtml("seg_DleSpace", "seg_Bad", "#ff0000", "\uf101", CErrSeg[9])
- + fillHtml("seg_HW_name", "seg_Bad", "#ff0000", "\uf018", CErrSeg[5])
- + fillHtml("seg_RShield", "seg_Bad", "#ff0000", "\uf152", CErrSeg[8])
- + fillHtml("seg_SegBadRS", "seg_Bad", "#ff0000", "\uf044", CErrSeg[14])
- + fillHtml("seg_SegRSWithoutCity", "seg_Bad", "#ff0000", "\uf044", CErrSeg[20])
- + fillHtml("seg_HNFree", "seg_Bad", "#ff0000", "\uf162", CErrSeg[15])
-
- + '</table></div></div><br><H6 style="float:left;">' + CErrPoi[0] + '</H6><div style="clear:both;"><tr><td><input type="checkbox" id="_poi_Bad"' + (WMECErrors.poi_Bad ? ' checked' : '') + '/> <label for="_poi_Bad" style="font-weight:normal;">' + CErrPoi[1] + '</label><br><div id="BadPoi" style="margin-left:5px;"><table>'
- + fillHtml("poi_Address", "poi_Bad", "#ff0000", "\uf2bc", CErrPoi[3])
- + fillHtml("poi_LandM", "poi_Bad", "#ff0000", "\uf1bb", CErrPoi[5])
- + fillHtml("poi_DleSpace", "poi_Bad", "#ff0000", "\uf101", CErrPoi[6])
- + fillHtml("poi_Transp", "poi_Bad", "#ff0000", "\uf207", CErrPoi[15])
- + fillHtml("poi_GasSta", "poi_Bad", "#ff0000", "\uf1b9", CErrPoi[16])
- + fillHtml("poi_Park_name", "poi_Bad", "#ff0000", "\uf288", CErrPoi[2])
- + fillHtml("poi_Park_type", "poi_Bad", "#ff0000", "\uf11d", CErrPoi[12])
- + fillHtml("poi_Relig", "poi_Bad", "#ff0000", "\uf015", CErrPoi[14])
- + fillHtml("poi_Entry", "poi_Bad", "#ff7700", "\uf18e", CErrPoi[4])
- + fillHtml("poi_Resid", "poi_Bad", "#ff7700", "\uf015", CErrPoi[7])
- + fillHtml("poi_Google", "poi_Bad", "#ff7700", "\uf1a0", CErrPoi[8])
- + fillHtml("poi_Phone", "poi_Bad", "#ff7700", "\uf095", CErrPoi[13])
- + fillHtml("poi_AutoFixTel", "poi_Bad", "#ff7700", "\uf062\uf0d0", CErrPoi[17])
- + fillHtml("poi_Other", "poi_Bad", "#ff7700", "\uf29c", CErrPoi[10])
- + fillHtml("poi_WFeed", "poi_Bad", "#ffcc00", "\uf263", CErrPoi[9])
- + fillHtml("poi_WPark", "poi_Bad", "#ffcc00", "\uf263", CErrPoi[11])
- + '</table></div></div><br><H6 style="float:left;">' + CErrLeg[0] + '</H6><div style="clear:both;">'
- + '<table><tr><td><div style="margin:5px;width:30px;height:2px;background-color:#ff0000;"></div></td><td>' + CErrLeg[1] + '</td></tr>'
- + '<tr><td><div style="margin:5px;width:30px;height:2px;background-color:#ff7700;"></div></td><td>' + CErrLeg[2] + '</td></tr>'
- + '<tr><td><div style="margin:5px;width:30px;height:2px;background-color:#ffcc00;"></div></td><td>' + CErrLeg[3] + '</td></tr>'
-
- + '</table></div></div><div id="CMOnly"><br><H6 style="float:left;">' + CErrLeg[8] + '</H6><div style="clear:both;"><tr><td><input type="checkbox" id="_autoLock"' + (WMECErrors.autoLock ? ' checked' : '') + (typeof (ABBR) == 'undefined' ? 'disabled' : ' ') + '/> <label id="_autoLockLabel" for="_autoLock" style="font-weight:normal;">' + CErrLeg[8] + ' (' + CErrorsModel.Countries.getTopCountry().name + ')</label><br><div id="AutoLock" style="margin-left:5px;"><table>'
- + fillHtmlAL("Freeway", I18n.translations[I18n.locale].segment.road_types[3], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.fwy_lvl + 1)))
- + fillHtmlAL("Ramp", I18n.translations[I18n.locale].segment.road_types[4], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.rmp_lvl + 1)))
- + fillHtmlAL("Major", I18n.translations[I18n.locale].segment.road_types[6], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.maj_lvl + 1)))
- + fillHtmlAL("Minor", I18n.translations[I18n.locale].segment.road_types[7], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.min_lvl + 1)))
- + fillHtmlAL("Primary", I18n.translations[I18n.locale].segment.road_types[2], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.pri_lvl + 1)))
- + fillHtmlAL("Street", I18n.translations[I18n.locale].segment.road_types[1], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.str_lvl + 1)))
- + fillHtmlAL("Railway", I18n.translations[I18n.locale].segment.road_types[18], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.rwy_lvl + 1)))
- + fillHtmlAL("Narrow", I18n.translations[I18n.locale].segment.road_types[22], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.nar_lvl + 1)))
- + '</table></div></div>';
-
- CEaddon.innerHTML = CEcontent;
- CEaddon.className = 'tab-pane';
- CErrorshandleClass2.appendChild(CEaddon);
-
- getId('errOpacity').value = WMECErrors.opacity;
- getId('opacityValue').innerHTML = getId('errOpacity').value;
- getId('errOpacity').onmousemove = function () {
- getId('opacityValue').innerHTML = getId('errOpacity').value;
- var ls = JSON.parse(localStorage.WMEColorErrors);
- ls.opacity = getId('errOpacity').value;
- localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
- CErrColor();
- };
- getId('_myLvl').onclick = (function () {
- var ls = JSON.parse(localStorage.WMEColorErrors);
- (getId('_myLvl').checked === true ? ls.myLvl = true : ls.myLvl = false);
- localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
- CErrColor();
- });
- getId('_seg_Bad').onclick = (function () {
- var ls = JSON.parse(localStorage.WMEColorErrors);
- if (getId('_seg_Bad').checked === true) {
- for (var i = 0; getElementsByClassName('_seg', BadSeg)[i]; i++) getElementsByClassName('_seg', BadSeg)[i].disabled = false;
- ls.seg_Bad = true;
- }
- else {
- for (var i = 0; getElementsByClassName('_seg', BadSeg)[i]; i++) getElementsByClassName('_seg', BadSeg)[i].disabled = true;
- ls.seg_Bad = false;
- }
- localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
- CErrColor();
- });
- getId('_poi_Bad').onclick = (function () {
- var ls = JSON.parse(localStorage.WMEColorErrors);
- if (getId('_poi_Bad').checked === true) {
- for (var i = 0; getElementsByClassName('_poi', BadPoi)[i]; i++) getElementsByClassName('_poi', BadPoi)[i].disabled = false;
- ls.poi_Bad = true;
- }
- else {
- for (var i = 0; getElementsByClassName('_poi', BadPoi)[i]; i++) getElementsByClassName('_poi', BadPoi)[i].disabled = true;
- ls.poi_Bad = false;
- }
- localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
- CErrColor();
- });
- getId('_autoLock').onclick = (function () {
- var ls = JSON.parse(localStorage.WMEColorErrors);
- if (getId('_autoLock').checked === true) {
- for (var i = 0; getElementsByClassName('_auto', AutoLock)[i]; i++) getElementsByClassName('_auto', AutoLock)[i].disabled = false;
- ls.autoLock = true;
- getId('addLockButton').className = 'fabkm fa fa-lock';
- getId('addLockButton').style.color = '#7f0';
- }
- else {
- for (var i = 0; getElementsByClassName('_auto', AutoLock)[i]; i++) getElementsByClassName('_auto', AutoLock)[i].disabled = true;
- ls.autoLock = false;
- getId('addLockButton').className = 'fabkm fa fa-unlock';
- getId('addLockButton').style.color = '#f60';
- }
- localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
- CErrColor();
- });
-
- getId('_seg_Park').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_Park').checked === true) ? ls.seg_Park = true : ls.seg_Park = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_Rail').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_Rail').checked === true) ? ls.seg_Rail = true : ls.seg_Rail = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_HW_name').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_HW_name').checked === true) ? ls.seg_HW_name = true : ls.seg_HW_name = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_Dir_name').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_Dir_name').checked === true) ? ls.seg_Dir_name = true : ls.seg_Dir_name = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_Toll').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_Toll').checked === true) ? ls.seg_Toll = true : ls.seg_Toll = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_Ramp_name').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_Ramp_name').checked === true) ? ls.seg_Ramp_name = true : ls.seg_Ramp_name = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_Ramp_city').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_Ramp_city').checked === true) ? ls.seg_Ramp_city = true : ls.seg_Ramp_city = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_RShield').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_RShield').checked === true) ? ls.seg_RShield = true : ls.seg_RShield = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_DleSpace').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_DleSpace').checked === true) ? ls.seg_DleSpace = true : ls.seg_DleSpace = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_SegBadRS').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_SegBadRS').checked === true) ? ls.seg_SegBadRS = true : ls.seg_SegBadRS = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_SegRSWithoutCity').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_SegRSWithoutCity').checked === true) ? ls.seg_SegRSWithoutCity = true : ls.seg_SegRSWithoutCity = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_HNFree').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_HNFree').checked === true) ? ls.seg_HNFree = true : ls.seg_HNFree = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_BadSpeed').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_BadSpeed').checked === true) ? ls.seg_BadSpeed = true : ls.seg_BadSpeed = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_BadAltState').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_BadAltState').checked === true) ? ls.seg_BadAltState = true : ls.seg_BadAltState = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_EmptyCityAlt').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_EmptyCityAlt').checked === true) ? ls.seg_EmptyCityAlt = true : ls.seg_EmptyCityAlt = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_seg_LockValue').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_seg_LockValue').checked === true) ? ls.seg_LockValue = true : ls.seg_LockValue = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
-
- getId('_poi_Park_name').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Park_name').checked === true) ? ls.poi_Park_name = true : ls.poi_Park_name = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_Park_type').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Park_type').checked === true) ? ls.poi_Park_type = true : ls.poi_Park_type = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_Address').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Address').checked === true) ? ls.poi_Address = true : ls.poi_Address = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_Entry').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Entry').checked === true) ? ls.poi_Entry = true : ls.poi_Entry = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_LandM').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_LandM').checked === true) ? ls.poi_LandM = true : ls.poi_LandM = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_DleSpace').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_DleSpace').checked === true) ? ls.poi_DleSpace = true : ls.poi_DleSpace = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_Resid').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Resid').checked === true) ? ls.poi_Resid = true : ls.poi_Resid = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_Google').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Google').checked === true) ? ls.poi_Google = true : ls.poi_Google = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_Phone').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Phone').checked === true) ? ls.poi_Phone = true : ls.poi_Phone = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_AutoFixTel').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_AutoFixTel').checked === true) ? ls.poi_AutoFixTel = true : ls.poi_AutoFixTel = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_WFeed').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_WFeed').checked === true) ? ls.poi_WFeed = true : ls.poi_WFeed = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_WPark').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_WPark').checked === true) ? ls.poi_WPark = true : ls.poi_WPark = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_Relig').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Relig').checked === true) ? ls.poi_Relig = true : ls.poi_Relig = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_Other').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Other').checked === true) ? ls.poi_Other = true : ls.poi_Other = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_Transp').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_Transp').checked === true) ? ls.poi_Transp = true : ls.poi_Transp = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_poi_GasSta').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_poi_GasSta').checked === true) ? ls.poi_GasSta = true : ls.poi_GasSta = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
-
- getId('_Freeway').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_Freeway').checked === true) ? ls.Freeway = true : ls.Freeway = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_Ramp').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_Ramp').checked === true) ? ls.Ramp = true : ls.Ramp = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_Major').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_Major').checked === true) ? ls.Major = true : ls.Major = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_Minor').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_Minor').checked === true) ? ls.Minor = true : ls.Minor = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_Primary').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_Primary').checked === true) ? ls.Primary = true : ls.Primary = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_Street').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_Street').checked === true) ? ls.Street = true : ls.Street = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_Railway').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_Railway').checked === true) ? ls.Railway = true : ls.Railway = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- getId('_Narrow').onclick = (function () { var ls = JSON.parse(localStorage.WMEColorErrors); (getId('_Narrow').checked === true) ? ls.Narrow = true : ls.Narrow = false; localStorage.setItem('WMEColorErrors', JSON.stringify(ls)); CErrColor(); });
- if (CErrorsUser.rank > 3) {
- setTimeout(function () {
- var addLockButton = document.createElement('div');
- addLockButton.id = 'addLockButton';
- $(addLockButton).css({ 'float': 'left', 'margin-right': '5px', 'cursor': 'pointer', 'opacity': '0.6' });
- addLockButton.className = 'fabkm fa fa-lock';
- addLockButton.onclick = (function () {
- getId('_autoLock').click();
- if (getId('_autoLock').checked) {
- addLockButton.className = 'fabkm fa fa-lock';
- addLockButton.style.color = '#7f0';
- } else {
- addLockButton.className = 'fabkm fa fa-unlock';
- addLockButton.style.color = '#f60';
- }
- });
- getElementsByClassName('topbar')[0].insertBefore(addLockButton, getElementsByClassName('location-info-region')[0]);
- getElementsByClassName('topbar')[0].style.padding = '0 10px';
- addLockButton.onmouseover = (function () { getId('addLockButton').style.opacity = '1'; });
- addLockButton.onmouseout = (function () { getId('addLockButton').style.opacity = '0.6'; });
- if (WMECErrors.autoLock) {
- addLockButton.className = 'fabkm fa fa-lock';
- addLockButton.style.color = '#7f0';
- } else {
- addLockButton.className = 'fabkm fa fa-unlock';
- addLockButton.style.color = '#f60';
- }
- }, 1000);
- }
-
- // Gestion des Events
- CErrWaze.Events.on({
- eventName: "wme-selection-changed",
- eventHandler: () => {
- CErrAddInfo();
- CErrColor();
- }
- });
- CErrWaze.Events.on({
- eventName: "wme-after-redo-clear",
- eventHandler: () => {
- CErrColor();
- }
- });
- CErrWaze.Events.on({
- eventName: "wme-after-undo",
- eventHandler: () => {
- CErrColor();
- }
- });
- CErrWaze.Events.on({
- eventName: "wme-map-data-loaded",
- eventHandler: () => {
- CErrColor();
- }
- });
- }
- function fillHtml(id, type, color, icon, text) {
- var WMECErrors = JSON.parse(localStorage.getItem('WMEColorErrors'));
- return '<tr style="line-height:14px;"><td style="width:20px;"><input type="checkbox" class="' + (type === "seg_Bad" ? '_seg' : '_poi') + '" id="_' + id + '"' + (WMECErrors[id] ? ' checked' : '') + (WMECErrors[type] ? '' : ' disabled') + '/></td><td style="width:20px;"><font style="color:' + color + ';font-family:FontAwesome;">' + icon + '</font></td><td><label for="_' + id + '" style="font-weight:normal;">' + text + '</label></td></tr>';
- }
- function fillHtmlAL(id, text, lockValue) {
- var WMECErrors = JSON.parse(localStorage.getItem('WMEColorErrors')), colorLock;
- switch (lockValue) {
- case 1: colorLock = "#00cf00"; break;
- case 2: colorLock = "#0179B5"; break;
- case 3: colorLock = "#ffcc00"; break;
- case 4: colorLock = "orange"; break;
- case 5: colorLock = "red"; break;
- }
- return '<tr style="line-height:14px;"><td style="width:20px;"><input type="checkbox" class="_auto" id="_' + id + '" ' + (WMECErrors[id] ? ' checked' : '') + (WMECErrors.autoLock ? '' : ' disabled') + '/></td><td style="width:30px;"><i class="fa fa-lock" style="color:' + colorLock + ';"></i> ' + lockValue + '</td><td><label for="_' + id + '" style="font-weight:normal;">' + text + '</label></td></tr>';
- }
-
- function addIcon(icon, color, geometry, type, pos) {
-
- var style = {
- fill: false,
- stroke: false,
- label: icon,
- labelAlign: "cb",
- labelXOffset: -4,
- labelYOffset: (pos * 20),
- fontColor: color,
- fontSize: "20px",
- fontOpacity: getId('errOpacity').value,
- fontFamily: "FontAwesome",
- labelOutlineWidth: 2,
- zIndex: 99999
- };
- geometry = W.userscripts.toOLGeometry(geometry);
- if (type === "segment") {
- geometry = geometry.components;
- if (geometry.length == 2) {
- var midX = (((geometry[0].x + geometry[1].x) / 2) + geometry[0].x) / 2;
- var midY = (((geometry[0].y + geometry[1].y) / 2) + geometry[0].y) / 2;
- var labelPoint = new CErrorsOpenLayers.Geometry.Point(midX, midY);
- var imageFeature = new CErrorsOpenLayers.Feature.Vector(labelPoint, null, style);
- ColorErrors_mapLayer.addFeatures([imageFeature]);
- }
- else {
- for (i = 0; i < geometry.length - 1; i++) {
- if (i % 3 == 1) {
- var midX = (((geometry[i].x + geometry[i + 1].x) / 2) + geometry[i].x) / 2;
- var midY = (((geometry[i].y + geometry[i + 1].y) / 2) + geometry[i].y) / 2;
- var labelPoint = new CErrorsOpenLayers.Geometry.Point(midX, midY);
- var imageFeature = new CErrorsOpenLayers.Feature.Vector(labelPoint, null, style);
- ColorErrors_mapLayer.addFeatures([imageFeature]);
- }
- }
- }
- }
- else {
- if (geometry) {
- if (geometry.components) {
- geometry = geometry.components[0].components[0];
- var labelPoint = new CErrorsOpenLayers.Geometry.Point(geometry.x, geometry.y);
- var imageFeature = new CErrorsOpenLayers.Feature.Vector(labelPoint, null, style);
- ColorErrors_mapLayer.addFeatures([imageFeature]);
- } else {
- var labelPoint = new CErrorsOpenLayers.Geometry.Point(geometry.x, geometry.y);
- var imageFeature = new CErrorsOpenLayers.Feature.Vector(labelPoint, null, style);
- ColorErrors_mapLayer.addFeatures([imageFeature]);
- }
- }
- }
- }
- function addLegend(id, icon, color, text, url) {
- if (getSelectedDataModelObjects() && getSelectedDataModelObjects().ids[0] === id && getId('ErrorsList')) {
- getId('ErrorsList').innerHTML += "<li id='item" + id + "'><span style='color:" + color + ";font-family:FontAwesome;'>" + icon + "</span> <span style='color:" + color + ";'>" + text + "</span></li>";
- //getId('item'+id).onclick=openInNewTab(url);
- }
- }
- function relock(obj, key) {
- var objects = obj[key], _i = 0;
- while (typeof (objects[_i]) != "undefined") {
- W.model.actionManager.add(objects[_i]);
- _i++;
- }
- }
- function CErrColor() {
- if (CErrorsUser != null && CErrorsModel.Countries.getTopCountry() != null) {
- var lineFeature = [], ls = JSON.parse(localStorage.WMEColorErrors);
- var lieu = CErrorsI18n.translations[CErrorsI18n.locale].layers.name.landmarks;
-
- //Check if Autolock is defined for active country
- if (ActiveCountry != CErrorsModel.Countries.getTopCountry().abbr) {
- ActiveCountry = CErrorsModel.Countries.getTopCountry().abbr;
- ABBR = cntryDB[ActiveCountry];
- if (typeof (ABBR) == 'undefined') {
- getId('_autoLock').disabled = true;
- for (var i = 0; getElementsByClassName('_auto', AutoLock)[i]; i++) getElementsByClassName('_auto', AutoLock)[i].disabled = true;
- } else {
- getId('_autoLock').disabled = false;
- for (var i = 0; getElementsByClassName('_auto', AutoLock)[i]; i++) getElementsByClassName('_auto', AutoLock)[i].disabled = false;
- }
- getId('_autoLockLabel').innerHTML = CErrLeg[8] + ' (' + CErrorsModel.Countries.getTopCountry().name + ')';
- }
-
- if (CErrorsUser.rank > 3) { if (getId('CMOnly')) { getId('CMOnly').style.display = "block"; } } else { if (getId('CMOnly')) { getId('CMOnly').style.display = "none"; } }
-
- // Initialize layer
- try { ColorErrors_mapLayer.destroyFeatures(); }
- catch (err) { log('err destroyFeatures: ', err); }
- if (getId('ErrorsList')) { getId('ErrorsList').innerHTML = ""; }
- //Segments Checking
- if (ls.seg_Bad || ls.autoLock) {
- var autoLockId = [], relockObject = { 'str': [], 'pri': [], 'min': [], 'maj': [], 'rmp': [], 'fwy': [], 'rwy': [], 'nar': [] };
-
- for (var seg of CErrorsModel.Segments.getAll()) {
- // Get values
- var segment = CErrorsModel.Segments.getById({ segmentId: seg.id }), j = 0;
- var attributes = segment
- var geometry = segment.geometry;
- if (segment === null || segment.state === "Update") continue;
- //Name
- var sid = attributes.primaryStreetId;
- if (sid) {
- var street = CErrorsModel.Streets.getById({ streetId: sid });
- } else { var street = ""; }
- //Alt Name
- if (attributes.alternateStreetIds && Object.keys(attributes.alternateStreetIds) > 0) {
- var salt = attributes.alternateStreetIds[0];
- var streetalt = CErrorsModel.Streets.getById({ streetId: salt });
- if (streetalt) {
- var altname = streetalt.name;
- var streetAltCity = CErrorsModel.Cities.getById({ cityId: streetalt.cityId });
- } else { var altname = ""; }
- }
-
- //Alt Name for roadshield
- saltArray = attributes.alternateStreetIds;
- const altnameArray = [];
- const streetCityArray = [];
- if (saltArray.length > 0) {
- var i = 0;
- for (const idsalt of saltArray) {
- streetaltTest = CErrorsModel.Streets.getById({ streetId: idsalt });
- if (streetaltTest) {
- altnameArray.push(streetaltTest.name);
- var streetAltCityTest = CErrorsModel.Cities.getById({ cityId: streetaltTest.cityId });
- if (streetAltCityTest) {
- streetCityArray.push(streetAltCityTest.name);
- }
- }
- i++;
- }
- }
- //City
- if (street.cityId === null) continue;
- var streetCity = CErrorsModel.Cities.getById({ cityId: street.cityId });
- if (streetCity === null) continue;
- streetCity = streetCity.name;
- var roadType = attributes.roadType;
- if (attributes.primaryStreetId === null || attributes.primaryStreetId === undefined) continue;
- if (CErrorsModel.Streets.getById({ streetId: attributes.primaryStreetId }) === null || CErrorsModel.Streets.getById({ streetId: attributes.primaryStreetId }) === undefined) continue;
- if (CErrorsModel.Cities.getById({ cityId: street.cityId }).countryId != CErrorsModel.Countries.getTopCountry().id) { continue; }
-
- var newWidth = "", newColor = "", newOpacity = "0", gline = "";
- if (ls.seg_Bad == true && (ls.myLvl && attributes.lockRank <= CErrorsUser.rank) || ls.seg_Bad == true && ls.myLvl == false) {
- if (ls.seg_Ramp_city) { // Ramp/Freeway with city name
- if (streetCity && /^(3|4)$/.test(attributes.roadType)) {
- newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf015", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf015", newColor, CErrSeg[11], "Routes_Nommage#1.4.4_Bretelles_d.27entr.C3.A9e_ou_de_sortie_des_autoroutes_et_voies_rapides");
- }
- }
- if (street.name || altname) {
- if (/( - )/.test(street.name)) { var trs = street.name.split(" - "); }
- if (ls.seg_Park && street.name) { // Parking with name (But Place / Square)
- if (attributes.roadType === 20 && new RegExp(parkNameSeg).test(street.name) === false) {
- newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf288", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf288", newColor, CErrSeg[3], "");
- }
- }
- if (ls.seg_Rail && street.name) { // Railroad with bad name
- if (attributes.roadType === 18 && (altname || street.name)) { //Railroad with name
- newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf238", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf238", newColor, CErrSeg[4], "Routes_Nommage#1.5.4_Voies_ferr.C3.A9es");
- }
- }
- if (ls.seg_Ramp_name && street.name) {
- if (/^(3|4)$/.test(attributes.roadType) && /\/.*\//.test(street.name)) { // Ramp with 3 directions or more
- newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf25b", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf25b", newColor, CErrSeg[6], "Routes_Nommage#1.4.4_Bretelles_d.27entr.C3.A9e_ou_de_sortie_des_autoroutes_et_voies_rapides");
- }
- else if (/^(3|4)$/.test(attributes.roadType) && /\//.test(street.name)) { // Ramp with 2 directions
- newColor = "#ff7700"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf25a", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf25a", newColor, CErrSeg[6], "Routes_Nommage#1.4.4_Bretelles_d.27entr.C3.A9e_ou_de_sortie_des_autoroutes_et_voies_rapides");
- }
- }
- if (ls.seg_Dir_name && street.name) { // Directions but not Ramp/Freeway/Major
- if (/^[^3|4|6]$/.test(attributes.roadType) && /[:|>]/.test(street.name)) {
- newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf0a9", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf0a9", newColor, CErrSeg[7], "Routes_Nommage#1.4.4_Bretelles_d.27entr.C3.A9e_ou_de_sortie_des_autoroutes_et_voies_rapides");
- }
- }
- if (ls.seg_Toll) { // Toll but not Ramp/Freeway
- if (/^[^3|4]$/.test(attributes.roadType) && (attributes.fwdToll || attributes.revToll)) {
- newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf155", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf155", newColor, CErrSeg[10], "");
- }
- }
- if (ls.seg_HW_name && street.name) { // Highways with bad name
- if (/^(3|4|6)$/.test(attributes.roadType) && (/:/.test(street.name) === true && /^[A|C|D|E|N|M|R|T][0-9]+[a-z]?[0-9]?/.test(street.name) === false) && /^>/.test(street.name) === false && /^[Sortie ]+[0-9]+/.test(street.name) === false && /^(Rocade|Périphérique)/.test(street.name) === false) {
- newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf018", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf018", newColor, CErrSeg[5], "Routes_Nommage#1.4.2_Autoroutes");
- }
- }
- if (ls.seg_SegBadRS && street.name) { // RoadShield but bad type
- if (/^(1|8|17|20)$/.test(attributes.roadType) && (/^[A|D|N|M|R|T][0-9]+/.test(street.name) || /^[A|D|N|M|R|T]$/.test(street.name))) {
- newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf044", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf044", newColor, CErrSeg[14], "Routes_Classification#2.4_Famille_des_Routes");
- }
- }
- if (ls.seg_HNFree) { // House number on undrivables
- if (/^(14|18|19)$/.test(attributes.roadType) && attributes.hasHNs === true) {
- newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf162", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf162", newColor, CErrSeg[15], "");
- }
- }
- if (ls.seg_BadSpeed) { // Bad speed (ex: >70km/h in city)
- if (attributes.fwdMaxSpeed > 70 && attributes.fwdMaxSpeedUnverified === false && attributes.revMaxSpeed > 70 && attributes.revMaxSpeedUnverified === false && streetCity) {
- newColor = "#ff7700"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf1ce", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf1ce", newColor, CErrSeg[16], "Routes_Vitesses#4.2_Tour_d.27horizon_des_diff.C3.A9rentes_vitesses_limites");
- }
- }
- if (ls.seg_RShield && street.name) { // Wrong prefix (RoadShield)
- if ((trs && attributes.roadType != 19 && /^[A|D|N|M|R|T][0-9]+[a-z]?[0-9]?/.test(trs[0].replace(".", "")) === false && / - /.test(street.name) === true)
- || /^[A|D|N|M|R|T][0-9]+[a-z]?[0-9]? ?-[A-Za-z]/.test(street.name) === true || /^[A|D|N|M|R|T][0-9]+[a-z]?[0-9]?- ?[A-Za-z]/.test(street.name) === true// No space between RS and street name
- ) {
- newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf152", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf152", newColor, CErrSeg[8], "");
- }
- }
-
- if (ls.seg_SegRSWithoutCity && street.name) {// RoadShield without city in alt
- if (/^(1|2|6|7)$/.test(attributes.roadType) && (/^[C|D|N|M|R|T][0-9]+/.test(street.name)) && !streetCity && altnameArray && streetCityArray) {
- BadAltRoadshield = false;
- NoRoadshield = true;
- if (altnameArray.length >= 1) {
- for (let i = 0; i < altnameArray.length; i++) {
- if ((/^[A|C|D|N|M|R|T][0-9]+/.test(altnameArray[i])) == true && NoRoadshield == true) {
- NoRoadshield = false;
- }
- if (((/^[A|C|D|N|M|R|T][0-9]+/.test(altnameArray[i])) == true && !streetCityArray[i])) {
- BadAltRoadshield = true;
- }
- }
- }
- if (BadAltRoadshield || NoRoadshield) {
- newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf044", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf044", newColor, CErrSeg[20], "Routes_Classification#2.4_Famille_des_Routes");
- }
- }
- }
- if (ls.seg_DleSpace && street.name) { // Double spacing in name
- if (/ /.test(street.name) === true) {
-
- newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf101", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf101", newColor, CErrSeg[9], "");
- }
- }
- if (ls.seg_BadAltState) {
- if (streetalt != null && CErrorsModel.Cities.getById({ cityId: street.cityId }).stateId != streetAltCity.stateId) { // Alt State != Main State
- newColor = "#ff7700"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf037", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf037", newColor, CErrSeg[17] + "<br>Est <b><i>" + CErrorsModel.states.getObjectById(streetAltCity.stateId).name + "</i></b><br>Devrait être <b><i>" + CErrorsModel.states.getObjectById(CErrorsModel.Cities.getById({ cityId: street.cityId }).stateId).name + "</i></b>", "");
- }
- }
- if (ls.seg_EmptyCityAlt && streetalt != null) { // Bad Alt
- var g = 0;
- for (var f = 0; f < Object.keys(attributes.alternateStreetIds).length; f++) {
- var streetalt = CErrorsModel.Streets.getById({ streetId: attributes.alternateStreetIds[f] });
- if (/^(1|2|6|7)$/.test(attributes.roadType) && CErrorsModel.Cities.getById({ cityId: streetalt.cityId }).name === "" && /^[A|C|D|E|N|M|R|T|V][0-9]+[a-z]?[0-9]?/.test(streetalt.name) === false && new RegExp(excepNameSeg).test(street.name) === false) {
- newColor = "#ff7700"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf064", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf064", newColor, CErrSeg[19], "");
- }
- }
- }
- }
- if (ls.seg_LockValue && attributes.lockRank != 5) { // Ignore Lock 6;
- if (
- ((attributes.flagAttributes.fwdSpeedCamera == 1 || attributes.flagAttributes.revSpeedCamera == 1) && attributes.lockRank != 4) || // Speedcam but not locked 5
- attributes.flagAttributes.fwdSpeedCamera != 1 && attributes.flagAttributes.revSpeedCamera != 1 && // no speedcam
- (/^(3|4|6|18)$/.test(attributes.roadType) && attributes.lockRank != 4 //Lock 5 for freeway, ramp, major and railroad
- || attributes.roadType == 7 && attributes.lockRank != 3 //Lock 4 for minor
- || attributes.roadType == 2 && attributes.lockRank != 2 //Lock 3 for primary
- || /^(1|8|17|19|22)$/.test(attributes.roadType) === true && attributes.lockRank != 0 && attributes.lockRank != null) //Lock 1 for others (5,10,15,16,20)
- ) {
- newColor = "#ff7700"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
- j++;
- addIcon("\uf023", newColor, geometry, "segment", j);
- addLegend(attributes.id, "\uf023", newColor, CErrSeg[18], "WME_Droits");
- }
- }
- // Highlight if error
- if (gline !== "") {
- var style = {
- strokeWidth: newWidth,
- strokeColor: newColor,
- strokeOpacity: newOpacity
- };
- var points = [];
- for (var i = 0; i < gline.length; i++) { points.push(new CErrorsOpenLayers.Geometry.Point(gline[i].x, gline[i].y)); }
- var newline = new CErrorsOpenLayers.Geometry.LineString(points);
- lineFeature.push(new CErrorsOpenLayers.Feature.Vector(newline, null, style));
- }
- }
-
- //Autolock
- var lock = attributes.lockRank;
- if (ls.autoLock === true &&
- (ls.myLvl && lock <= CErrorsUser.rank || ls.myLvl == false) &&
- lock != 5 &&
- onScreen(segment) &&
- autoLockId.indexOf(attributes.id) == -1 &&
- getId('_autoLock').disabled == false &&
- CErrorsUser.rank > 3) {
- if (attributes.flagAttributes.revSpeedCamera != '1' && attributes.flagAttributes.fwdSpeedCamera != '1') {
- switch (attributes.roadType) {
- case 1: if ((lock == null || lock < ABBR.str_lvl) && ls.Street == true) { autoLockId.push(attributes.id); relockObject.str.push(new UpdateObject(segment, { lockRank: ABBR.str_lvl })); } break;
- case 2: if ((lock == null || lock < ABBR.pri_lvl) && ls.Primary == true) { autoLockId.push(attributes.id); relockObject.pri.push(new UpdateObject(segment, { lockRank: ABBR.pri_lvl })); } break;
- case 3: if ((lock == null || lock < ABBR.fwy_lvl) && ls.Freeway == true) { autoLockId.push(attributes.id); relockObject.fwy.push(new UpdateObject(segment, { lockRank: ABBR.fwy_lvl })); } break;
- case 4: if ((lock == null || lock < ABBR.rmp_lvl) && ls.Ramp == true) { autoLockId.push(attributes.id); relockObject.rmp.push(new UpdateObject(segment, { lockRank: ABBR.rmp_lvl })); } break;
- case 6: if ((lock == null || lock < ABBR.maj_lvl) && ls.Major == true) { autoLockId.push(attributes.id); relockObject.maj.push(new UpdateObject(segment, { lockRank: ABBR.maj_lvl })); } break;
- case 7: if ((lock == null || lock < ABBR.min_lvl) && ls.Minor == true) { autoLockId.push(attributes.id); relockObject.min.push(new UpdateObject(segment, { lockRank: ABBR.min_lvl })); } break;
- case 18: if ((lock == null || lock < ABBR.rwy_lvl) && ls.Railway == true) { autoLockId.push(attributes.id); relockObject.rwy.push(new UpdateObject(segment, { lockRank: ABBR.rwy_lvl })); } break;
- case 22: if ((lock == null || lock < ABBR.nar_lvl) && ls.Narrow == true) { autoLockId.push(attributes.id); relockObject.nar.push(new UpdateObject(segment, { lockRank: ABBR.nar_lvl })); } break;
- }
- }
- // Lock 5 if ASC
- if ((attributes.flagAttributes.fwdSpeedCamera == '1' || attributes.flagAttributes.revSpeedCamera == '1') && lock != '4') { autoLockId.push(attributes.id); relockObject.others.push(new UpdateObject(segment, { lockRank: '4' })); }
- }
- }
-
- $.each(relockObject, function (key, value) {
- relock(relockObject, key);
- });
- }
-
- //Places Checking
- if (ls.poi_Bad && getId('layer-switcher-group_places').checked) {
- for (var poi of CErrorsModel.Venues.getAll()) {
- // Get values
- var venue = CErrorsModel.Venues.getById({ venueId: poi.id }), j = 0;
- var pattributes = venue;
- var pid = pattributes.id;
- if (pattributes.geometry) geometry = pattributes.geometry;
- if (venue === null || pid === null || geometry === null || poi.state == "Update" || poi.selected) continue;
- var categories = pattributes.categories;
- var pname = pattributes.name;
- var venueAddress = CErrorsModel.Venues.getAddress({ venueId: pattributes.id });
- if (venueAddress === null) continue;
- if (venueAddress.street === null) continue;
- if (venueAddress.street.name || venueAddress.street.name !== null) {
- var venueStreetName = venueAddress.street.name;
- } else {
- var venueStreetName = "";
- }
- if (venueAddress.houseNumber || venueAddress.street.name !== null) {
- var venueHN = venueAddress.houseNumber;
- } else {
- var venueHN = "";
- }
- if (venueAddress.city === null) continue;
- if (venueAddress.city.name || venueAddress.city.name !== null) {
- var venueCity = venueAddress.city.name;
- } else {
- var venueCity = "";
- }
-
- var newWidth = "", newColor = "", newOpacity = "0", gpoly = "";
- if ((ls.myLvl && pattributes.lockRank <= CErrorsUser.rank && pattributes.isAdLocked === false) || ls.myLvl == false) {
- if (ls.poi_Resid) { // maybe a residential POI
- if ((/^[0-9][ ]?[a-zA-Z]/.test(pname) === true || new RegExp(privNameSeg).test(pname) === true) && pattributes.isResidential === false && pattributes.categories.indexOf("PARKING_LOT") === -1) {
- newColor = "#ff7700"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- if (venue.geometry.type === "Point") { newWidth = 26; }
- j++;
- addIcon("\uf015", newColor, geometry, "venue", j);
- addLegend(pid, "\uf015", newColor, CErrPoi[7], "");
- }
- }
- if (ls.poi_Google) { //POI without Google link
- if (pattributes.externalProviderIds.length === 0 && pattributes.isResidential === false && new RegExp(excepCatPoi).test(categories) === false) {
- newColor = "#ff7700"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- if (venue.geometry.type === "Point") { newWidth = 26; }
- j++;
- addIcon("\uf1a0", newColor, geometry, "venue", j);
- addLegend(pid, "\uf1a0", newColor, CErrPoi[8], "");
- }
- }
- if (ls.poi_Phone && pattributes.phone) { //POI with bad phone number
- // Phone prefix
- var prefPhone;
- switch (CErrorsModel.Countries.getTopCountry().id) {
- case 3: prefPhone = '+213[ ](\\d{2})'; break; // format +213 (dd) xx xx xx @ Algeria
- case 73: prefPhone = '+33[ ]\\d[ ]\\d{2}'; break; // format +33 d xx xx xx xx @ France
- case 74: prefPhone = '+594[ ](594|694)'; break; // format +594 594 xx xx xx @ French Guiana
- case 88: prefPhone = '+590[ ](590|690)'; break; // format +590 590 xx xx xx @ Guadeloupe
- case 141: prefPhone = '+596[ ]596'; break; // format +596 596 xx xx xx @ Martinique
- case 148: prefPhone = '+377[ ]\\d{2}'; break; // format +377 xx xx xx xx @ Monaco
- case 152: prefPhone = '+212[ ](\\d{3})'; break; // format +212 xxx xx xx xx @ Morocco
- case 184: prefPhone = '+262[ ](262|692|693)'; break; // format +262 (262 ou 692) xx xx xx @ Reunion
- default: break;
- }
- if (new RegExp('^(\\' + prefPhone + ')([ ](\\d{2})){3}$').test(pattributes.phone) === false // Prefix + 4 digits
- && new RegExp('^(\\' + prefPhone + ')([ ](\\d{3})){2}$').test(pattributes.phone) === false // Prefix + 3 digits
- && (/^[13]\d[ ](\d{2})$/).test(pattributes.phone) === false // 1x xx or 3x xx
- && (/^(0[ ](8|9)\d{2})([ ](\d{3})){2}/).test(pattributes.phone) === false // 0 8xx xxx xxx
- && (/^(0[ ](8|9)\d{2})([ ](\d{2})){3}/).test(pattributes.phone) === false // 0 8xx xx xx xx
- && (/^(15|17|18|112|115)$/).test(pattributes.phone) === false // Emergency numbers
- ) {
- newColor = "#ff7700"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- if (venue.geometry.type === "Point") { newWidth = 26; }
- j++;
- addIcon("\uf095", newColor, geometry, "venue", j);
- addLegend(pid, "\uf095", newColor, CErrPoi[13], "Lieux_Generalites#1.7._Format_du_num.C3.A9ro_de_t.C3.A9l.C3.A9phone");
- if (ls.poi_AutoFixTel && pattributes.permissions != 0 && pattributes.approved == true) {
- autoFixTel(venue);
- }
- }
- }
- if (ls.poi_Other) { // Place type is "Other"
- if (categories.indexOf("OTHER") > -1 && (/^Déchèterie/).test(pname) === false) {
- newColor = "#ff7700"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- if (venue.geometry.type === "Point") { newWidth = 26; }
- j++;
- addIcon("\uf29c", newColor, geometry, "venue", j);
- addLegend(pid, "\uf29c", newColor, CErrPoi[10], "");
- }
- }
- if (ls.poi_Entry) { // POI with default navigationPoints
- if (new RegExp(entryPointPoi).test(categories) === false && pattributes.navigationPoints.length === 0 && venue.geometry.type === "Point" === false) {
- newColor = "#ff7700"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- j++;
- addIcon("\uf18e", newColor, geometry, "venue", j);
- addLegend(pid, "\uf18e", newColor, CErrPoi[4], "Lieux_Generalites#1.3._Positionner_le_point_de_destination_d.27un_POI");
- }
- }
- if (ls.poi_Park_name && categories.indexOf("PARKING_LOT") > -1) { // Parking with bad name
- if (new RegExp(streetNameSeg).test(pname) === true) { continue; } //If parking name is a road
- if (new RegExp('^' + parkNamePoi + '$').test(pname) === true || // Only Parkings or Aire // ?️|?️️|
- new RegExp('^' + parkNamePoi).test(pname) === false // Don't start by ?️ or Parking
- // /^(Parking[s]?)( de[s]?| du | le[s]? | la | pour )/.test(pname)===true // Contain bad words
- ) {
- newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- j++;
- addIcon("\uf288", newColor, geometry, "venue", j);
- addLegend(pid, "\uf288", newColor, CErrPoi[2], "Lieux_Particuliers#2.3._Parkings");
- }
- else if (pname === "") {
- newColor = "#ff7700"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- j++;
- addIcon("\uf288", newColor, geometry, "venue", j);
- addLegend(pid, "\uf288", newColor, CErrPoi[2], "Lieux_Particuliers#2.3._Parkings");
- }
- if (venue.geometry.type === "Point") newWidth = 26;
- }
- if (ls.poi_Park_type && categories.indexOf("PARKING_LOT") > -1) { // Parking with type undefined
- if (/PUBLIC|RESTRICTED|PRIVATE/.test(pattributes.categoryAttributes.PARKING_LOT.parkingType) === false) {
- newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- j++;
- addIcon("\uf11d", newColor, geometry, "venue", j);
- addLegend(pid, "\uf11d", newColor, CErrPoi[12], "Lieux_Particuliers#2.3._Parkings");
- }
- }
- if (ls.poi_Address) { // POI with bad address or incomplete
- if (venueStreetName === null) continue;
- if ((/^[A|D|N|M|R][0-9]+/.test(venueStreetName) && /[ - ]/.test(venueStreetName)) || ((!venueStreetName || !venueHN) && !new RegExp(PoiWithoutCompleteAdress).test(categories))) {
- if (debug) {
- //console.log("Nom : " + pname + " - Catégorie : " + categories);
- }
- newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- if (venue.geometry.type === "Point") { newWidth = 26; }
- j++;
-
- addIcon("\uf2bc", newColor, geometry, "venue", j);
- addLegend(pid, "\uf2bc", newColor, CErrPoi[3], "Lieux_Generalites#1.2._Nommage_et_Adresse_d.27un_POI");
- }
- }
- if (ls.poi_LandM) { // Landmark with road name or city name
- if (new RegExp(landmarkPoi).test(categories) && pname === "" && ((venueStreetName && venueStreetName) || (venueCity && venueCity.name))) {
- newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- if (venue.geometry.type === "Point") { newWidth = 26; }
- j++;
- addIcon("\uf1bb", newColor, geometry, "venue", j);
- addLegend(pid, "\uf1bb", newColor, CErrPoi[5], "");
- }
- }
- if (ls.poi_DleSpace) { // Double spacing in name
- if (venueStreetName && (/ /.test(venueStreetName) === true || / /.test(pname) === true)) {
- newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- j++;
- addIcon("\uf101", newColor, geometry, "venue", j);
- addLegend(pid, "\uf101", newColor, CErrPoi[6], "");
- if (venue.geometry.type === "Point") { newWidth = 26; }
- }
- }
- if (ls.poi_GasSta && categories.indexOf("GAS_STATION") > -1) { // Gas Station with bad name
- if (new RegExp(streetNameSeg).test(pname) === true) { continue; } //If parking name is a road
- if (/^(Station-service )/.test(pname) === false) { // Don't start by
- newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- j++;
- addIcon("\uf1b9", newColor, geometry, "venue", j);
- addLegend(pid, "\uf288", newColor, CErrPoi[16], "Lieux_Particuliers#2.5._Stations-services");
- if (venue.geometry.type === "Point") newWidth = 26;
- }
- }
- if (ls.poi_Transp && new RegExp(stationsPoi).test(categories) === false && categories.indexOf("FAST_FOOD") == -1) { //Bus Subway and Tram Station wihtout others stations
- if ((
- categories.indexOf("BUS_STATION") > -1 && // Good category for bus station
- new RegExp('^' + busPoi).test(pname) === false // Bad name
- ) || (
- categories.indexOf("SUBWAY_STATION") > -1 && // Good category for subway station
- new RegExp('^' + tramPoi).test(pname) === false // Bad name
- ) || (
- categories.indexOf("TRAIN_STATION") > -1 && // Good category for train station
- /Gare d[e|u|es|\']/.test(pname) === false // Bad name
- ) || (
- categories.indexOf("OTHER") == -1 && categories.indexOf("BUS_STATION") == -1 && categories.indexOf("SUBWAY_STATION") == -1 && categories.indexOf("TRAIN_STATION") == -1 &&
- new RegExp('^' + possibleTransPoi).test(pname) === true // Maybe a transport station
- )) {
- newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- j++;
- addIcon("\uf207", newColor, geometry, "venue", j);
- addLegend(pid, "\uf207", newColor, CErrPoi[15], "Lieux_Particuliers#2.8._Arr.C3.AAts_de_bus.2C_m.C3.A9tro_et_tramway");
- if (venue.geometry.type === "Point") { newWidth = 26; }
- }
- }
- if (ls.poi_Relig && categories.indexOf("RELIGIOUS_CENTER") > -1) { // Religious Center with bad name
- if (new RegExp('^' + religiousPoi).test(pname) === false) { // Bad 1st name
- newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- j++;
- addIcon("\uf015", newColor, geometry, "venue", j);
- addLegend(pid, "\uf015", newColor, CErrPoi[14], "Lieux_Particuliers#2.10._Site_religieux");
- if (venue.geometry.type === "Point") { newWidth = 26; }
- }
- }
- if ((ls.poi_Relig && new RegExp('^' + religiousPoi).test(pname) === true && categories.indexOf("RELIGIOUS_CENTER") == -1) || // Religious Center Name but bad category
- (new RegExp('^' + religiousPoi + '$').test(pname) === true && categories.indexOf("RELIGIOUS_CENTER") == -1)) { // Bad Religious Center Name with bad category
- console.log("2- Checking Religious Center: " + pname);
- newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- j++;
- addIcon("\uf015", newColor, geometry, "venue", j);
- addLegend(pid, "\uf015", newColor, CErrPoi[14], "Lieux_Particuliers#2.10._Site_religieux");
- if (venue.geometry.type === "Point") { newWidth = 26; }
- }
- if (ls.poi_WFeed || ls.poi_WPark) { //Place updated by WazeFeed
- if (pattributes.modificationData.updatedBy) {
- var updName = pattributes.modificationData.updatedBy;
- if (((ls.poi_WFeed && new RegExp(wazeBot).test(updName)) || (ls.poi_WPark && updName == "WazeParking1")) && pattributes.isResidential === false) {
- newColor = "#ffcc00"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
- if (venue.geometry.type === "Point") { newWidth = 26; newOpacity = 0.75; }
- j++;
- addIcon("\uf263", newColor, geometry, "venue", j);
- if (updName == "WazeFeed") { addLegend(pid, "\uf263", newColor, CErrPoi[9], ""); }
- else { addLegend(pid, "\uf263", newColor, CErrPoi[11], ""); }
- }
- }
- }
- // Highlight if error
-
- }
- if (pattributes.adLocked) {
- newColor = "#ff0000"; newWidth = 15; newOpacity = 0.75; poly = W.userscripts.toOLGeometry(geometry);
- j++;
- addIcon("\uf023", newColor, geometry, "venue", j);
- addLegend(pid, "\uf023", newColor, CErrLeg[7], "");
- if (venue.geometry.type === "Point") { newWidth = 26; }
- }
- if (gpoly !== "") {
- var style = {
- strokeWidth: newWidth,
- strokeColor: newColor,
- strokeOpacity: newOpacity,
- fillOpacity: 0
- };
- var points = [];
- for (var i = 0; i < gpoly.length; i++) { points.push(new CErrorsOpenLayers.Geometry.Point(gpoly[i].x, gpoly[i].y)); }
- var newpoly = new CErrorsOpenLayers.Geometry.LinearRing(points);
- lineFeature.push(new CErrorsOpenLayers.Feature.Vector(newpoly, null, style));
- }
- }
- }
-
- // Display highlighted features
- try { ColorErrors_mapLayer.addFeatures(lineFeature); }
- catch (err) { log('err addFeatures: ', err); }
- }
- }
- // **********************
- // ** Telephone fix **
- // **********************
- function formatTelCounty(venue) {
- phoneTo = '';
- // num 0800 et 0900
- if (venue.phone.startsWith('08') == true) {
- phoneTo = venue.phone.replace(/^0[.| |-]?8[.| |-]?([0-9])([0-9])[.| |-]?([0-9])([0-9])[.| |-]?([0-9])([0-9])[.| |-]?([0-9])([0-9])$/g, "0 8$1$2 $3$4$5 $6$7$8");
- } else {
- // rules by country
- switch (CErrorsModel.Countries.getTopCountry().id) {
- case 3: // Algeria
- if (venue.phone.startsWith('+213') == true) {
- phoneTo = venue.phone.replace(/^\+213[ ]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+213 $1 $2 $3 $4 $5");
- } else {
- phoneTo = venue.phone.replace(/^0([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+213 $1 $2 $3 $4 $5");
- }
- break;
- case 73: // France
- if (venue.phone.startsWith('+338') == true || venue.phone.startsWith('00338') == true || venue.phone.startsWith('+33-8') == true || venue.phone.startsWith('+33 8') == true) {
- if (venue.phone.startsWith('+33') == true) {
- phoneTo = venue.phone.replace(/^\+33[.| |-]?8[.| |-]?([0-9])([0-9])[.| |-]?([0-9])([0-9])[.| |-]?([0-9])([0-9])[.| |-]?([0-9])([0-9])$/g, "0 8$1$2 $3$4$5 $6$7$8");
- } else if (venue.phone.startsWith('0033') == true) {
- phoneTo = venue.phone.replace(/^0033[.| |-]?8[.| |-]?([0-9])([0-9])[.| |-]?([0-9])([0-9])[.| |-]?([0-9])([0-9])[.| |-]?([0-9])([0-9])$/g, "0 8$1$2 $3$4$5 $6$7$8");
- }
- } else if (venue.phone.startsWith('+33') == true) {
- phoneTo = venue.phone.replace(/^\+33[.| |-]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+33 $1 $2 $3 $4 $5");
- } else if (venue.phone.startsWith('0033') == true) {
- phoneTo = venue.phone.replace(/^0033[.| |-]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+33 $1 $2 $3 $4 $5");
- } else if (venue.phone.startsWith('33') == true) {
- phoneTo = venue.phone.replace(/^33[.| |-]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+33 $1 $2 $3 $4 $5");
- } else {
- phoneTo = venue.phone.replace(/^0([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+33 $1 $2 $3 $4 $5");
- }
- break;
- case 74: // French Guiana
- if (venue.phone.startsWith('+594 5 94') == true || venue.phone.startsWith('+594594') == true) {
- phoneTo = venue.phone.replace(/^\+594[ ]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+594 $1$2 $3 $4 $5");
- } else {
- phoneTo = venue.phone.replace(/^0([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+594 $1$2 $3 $4 $5");
- }
- break;
- case 88: // Guadeloupe
- if (venue.phone.startsWith('+590 5 90') == true || venue.phone.startsWith('+590590') == true) {
- phoneTo = venue.phone.replace(/^\+590[ ]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+590 $1$2 $3 $4 $5");
- } else {
- phoneTo = venue.phone.replace(/^0([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+590 $1$2 $3 $4 $5");
- }
- break;
- case 141: // Martinique
- if (venue.phone.startsWith('+596 5 96') == true || venue.phone.startsWith('+596596') == true) {
- phoneTo = venue.phone.replace(/^\+596[ ]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+596 $1$2 $3 $4 $5");
- } else {
- phoneTo = venue.phone.replace(/^0([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+596 $1$2 $3 $4 $5");
- }
- break;
- case 148: // Monaco
- if (venue.phone.startsWith('+377') == true) {
- phoneTo = venue.phone.replace(/^\+377[ ]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+377 $1 $2 $3 $4 $5");
- } else {
- phoneTo = venue.phone.replace(/^0([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+377 $1 $2 $3 $4 $5");
- }
- break;
- case 152: // Morocco
- if (venue.phone.startsWith('+212') == true) {
- phoneTo = venue.phone.replace(/^\+212[ ]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+212 $1 $2 $3 $4 $5");
- } else {
- phoneTo = venue.phone.replace(/^0([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+212 $1 $2 $3 $4 $5");
- }
- break;
- case 184: // Reunion
- if (venue.phone.startsWith('+262 2 62') == true || venue.phone.startsWith('+262262') == true) {
- phoneTo = venue.phone.replace(/^\+262[ ]?([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+262 $1$2 $3 $4 $5");
- } else {
- phoneTo = venue.phone.replace(/^0([0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])[.| |-]?([0-9][0-9])$/g, "+262 $1$2 $3 $4 $5");
- }
- break;
- default: break;
- }
- }
- return phoneTo;
- }
-
- function autoFixTel(venue) {
- phoneTo = ''
- phoneTo = formatTelCounty(venue);
- if (phoneTo != '' && Object.keys(venue.venueUpdateRequests).length == 0) {
- CErrorsModel.Venues.updateVenue({ venueId: venue.id, phone: phoneTo });
- }
- }
- function fixTel() {
- var editpanel = $('#edit-panel');
- if (editpanel.length == 0) { window.setTimeout(fixTel, 1000); return; }
-
- const observer = new MutationObserver(mutations => {
- mutations.forEach(mutation => {
- for (let i = 0; i < mutation.addedNodes.length; i++) {
- const addedNode = mutation.addedNodes[i];
- if (addedNode &&
- W.selectionManager &&
- W.selectionManager.getSelectedDataModelObjects &&
- W.selectionManager.getSelectedDataModelObjects()[0].type == "venue") {
- var editLM = $('#venue-edit-more-info');
- if (editLM.length == 1) {
- var fixPhoneBtn = $('#wme-telephonefix-fr');
- if (fixPhoneBtn.length == 0) {
- fixPhoneBtn = document.createElement('button');
- fixPhoneBtn.innerHTML = 'fix';
- fixPhoneBtn.id = 'wme-telephonefix-fr';
- $(fixPhoneBtn).css({ 'float': 'right', 'position': 'relative', 'right': '0px', 'bottom': '56px', 'background-color': '#ade71f', 'font-weight': 'bold', 'border-top-right-radius': '6px', 'border-bottom-right-radius': '6px', 'border': '0', 'border-left': '1px dashed #cccccc' });
- $('[name=phone]').parent().append(fixPhoneBtn);
-
- try {
- var venue = W.selectionManager.getSelectedDataModelObjects()[0];
- var phone = venue.phone;
- var newPhone = '';
- var phoneTo = '';
- phoneTo = formatTelCounty(venue);
-
- if (phoneTo != venue.phone) { newPhone = phoneTo; }
-
- if (newPhone != '') {
- fixPhoneBtn.addEventListener("click", function (v, p) {
- return function () {
- var newAtts = { phone: p, id: v.id };
- W.model.actionManager.add(new (require("Waze/Action/UpdateObject"))(v, newAtts));
- $(fixPhoneBtn).css({ 'display': 'none' });
- }
- }(venue, newPhone), false);
- }
- else
- $(fixPhoneBtn).css({ 'display': 'none' });
- }
- catch (err) {
- $(fixPhoneBtn).css({ 'display': 'none' });
- }
- }
- }
- }
- }
- });
- });
- observer.observe(document.getElementById('edit-panel'), { childList: true, subtree: true });
-
- }