WME Color Errors

Colorisation pour afficher les erreurs

  1. // ==UserScript==
  2. // @name WME Color Errors
  3. // @version 2025.08.08.01
  4. // @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=
  5. // @description Colorisation pour afficher les erreurs
  6. // @include https://www.waze.com/editor*
  7. // @include https://www.waze.com/*/editor*
  8. // @include https://beta.waze.com/*
  9. // @exclude https://www.waze.com/user/*
  10. // @exclude https://www.waze.com/*/user/*
  11. // @namespace https://greasyfork.org/fr/scripts/21186-wme-color-errors
  12. // @author Sebiseba / MatthieuF44 par intérim :)
  13. // @copyright Sebiseba 2014-2023
  14. // @license GNU GPL v2
  15. // @grant none
  16. // ==/UserScript==
  17. WMECE_log("Démarrage en cours, version : " + GM_info.script.version);
  18. var wmeSDK;
  19. window.SDK_INITIALIZED.then(() => {
  20. wmeSDK = getWmeSdk({ scriptId: "WME-Color-Error", scriptName: GM_info.script.name });
  21. wmeSDK.Events.once({ eventName: "wme-ready" }).then(CErrors_init);
  22. });
  23.  
  24.  
  25. var WMECErrors = {}, ColorErrors_mapLayer = [], CErrLeg, CErrSeg, CErrPoi, debug = false;
  26. var ActiveCountry, ABBR, UpdateObject, cntryDB = {
  27. 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 },
  28. 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 },
  29. 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 },
  30. 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 },
  31. 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 },
  32. 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 },
  33. 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 }
  34. }; // France
  35. var CErrWaze, CErrorsMap, CErrorsModel, CErrorsI18n, CErrorsOpenLayers, CErrorshandle, CErrorshandleClass, CErrorshandleClass2,
  36.  
  37. //french rules
  38. 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 )",
  39. parkNameSeg = "^(Aire |Place |Square )",
  40. excepNameSeg = "(Périphérique |Rocade |Duplex |Tunnel |Pont )",
  41. 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 )",
  42. parkNamePoi = "(Parking[s]?|Parc-Relais|Placette|Aire|Arrêt|Emplacement)",
  43. 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)",
  44. busPoi = "(Bus[ ][-][ ]|Gare Routière)",
  45. tramPoi = "(Tramway[ ][-][ ]|Métro[ ][-][ ])",
  46. possibleTransPoi = "(Tram$|Métro$|Arrêt$|Gare$|Station$|Tram |Métro |Arrêt |Gare |Station )",
  47.  
  48. // common all countries
  49. 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)",
  50. landmarkPoi = "(RIVER_STREAM|CANAL|SEA_LAKE_POOL|SWAMP_MARSH|ISLAND|FOREST_GROVE|BRIDGE)",
  51. excepCatPoi = "(RIVER_STREAM|CANAL|SEA_LAKE_POOL|SWAMP_MARSH|ISLAND|FOREST_GROVE|BRIDGE|PARK|JUNCTION_INTERCHANGE|CEMETERY|TUNNEL)",
  52. 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)",
  53. entryPointPoi = "(BRIDGE|CANAL|FOREST_GROVE|ISLAND|JUNCTION_INTERCHANGE|POOL|RIVER_STREAM|SEA_LAKE_POOL|SWAMP_MARSH|TUNNEL)",
  54. wazeBot = "(admin|avseu|WazeFeed|waze-maint-bot|Waze3rdparty|evcs feed 1)";
  55.  
  56. // *********************
  57. // ** HELPER FUNCTION **
  58. // *********************
  59. function getId(node) {
  60. return document.getElementById(node);
  61. }
  62. function getElementsByClassName(classname, node) {
  63. node || (node = document.getElementsByTagName("body")[0]);
  64. for (var a = [], re = new RegExp("\\b" + classname + "\\b"), els =
  65. node.getElementsByTagName("*"), i =
  66. 0, j =
  67. els.length; i < j; i++) {
  68. re.test(els[i].className) && a.push(els[i]);
  69. }
  70. return a;
  71. }
  72. function IsJsonString(str) {
  73. try {
  74. JSON.parse(str);
  75. } catch (e) {
  76. return false;
  77. }
  78. return true;
  79. }
  80. function getSelectedDataModelObjects() {
  81. return CErrorsEdits.getSelection();
  82. }
  83. function openInNewTab(url) {
  84. var win = window.open('https://wazeopedia.waze.com/wiki/France/' + url, '_blank');
  85. win.focus();
  86. }
  87. function onScreen(obj) {
  88. if (obj.getOLGeometry()) {
  89. return (W.map.getExtent());
  90. //return(W.map.getExtent().intersectsBounds(obj.getOLGeometry().getBounds()));
  91. }
  92. return (false);
  93. }
  94.  
  95. // *************
  96. // ** INIT **
  97. // *************
  98.  
  99. // Fonction log avec affichage du nom du script
  100. function WMECE_log(message) {
  101. if (typeof message === 'string') {
  102. console.log(GM_info.script.name + ': ' + message);
  103. } else {
  104. console.log(GM_info.script.name + ': ', message);
  105. }
  106. }
  107.  
  108. function CErrors_init() {
  109. WMECE_log("Initialisation en cours ");
  110. fixTel();
  111. // SDK W object needed
  112. CErrWaze = wmeSDK; if (typeof (CErrWaze) === 'undefined') { if (debug) { WMECE_log("WME ColorErrors - CErrWaze : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  113. CErrorsEdits = CErrWaze.Editing; if (typeof (CErrorsEdits) == 'undefined') { if (debug) { WMECE_log("WME ColorErrors - CErrorsedits : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  114. CErrorsMapSDK = CErrWaze.Map; if (typeof (CErrorsMapSDK) == 'undefined') { if (debug) { WMECE_log("WME ColorErrors - CErrorsmap : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  115. CErrorsModel = CErrWaze.DataModel; if (typeof (CErrorsModel) == 'undefined') { if (debug) { WMECE_log("WME ColorErrors - CErrorsmodel : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  116. 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; }
  117. CErrorsI18n = I18n; if (typeof (CErrorsI18n) == 'undefined') { if (debug) { console.error('WME ColorErrors - CErrorsI18n : NOK'); } setTimeout(CErrors_init, 500); return; }
  118. CErrorsUser = CErrWaze.State.getUserInfo(); if (typeof (CErrorsUser) === 'undefined') { if (debug) { WMECE_log("WME ColorErrors - CErrorsUser : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  119.  
  120. // W object needed à supprimer quand SDK W object needed fonctionne
  121. //CErrWaze = W; if (typeof (CErrWaze) === 'undefined') { if (debug) { console.error("WME ColorErrors - CErrWaze : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  122. CErrorsMap = W.map; if (typeof (CErrorsMap) == 'undefined') { if (debug) { console.error("WME ColorErrors - CErrorsmap : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  123. //CErrorsModel = CErrWaze.model; if (typeof (CErrorsModel) == 'undefined') { if (debug) { console.error("WME ColorErrors - CErrorsmodel : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  124. //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; }
  125. //CErrorsI18n = I18n; if (typeof (CErrorsI18n) == 'undefined') { if (debug) { console.error('WME ColorErrors - CErrorsI18n : NOK'); } setTimeout(CErrors_init, 500); return; }
  126. //--------
  127.  
  128.  
  129. // OpenLayers
  130. CErrorsOpenLayers = OpenLayers; if (typeof (CErrorsOpenLayers) === 'undefined') { if (debug) { console.error("WME ColorErrors - OL : NOK"); } window.setTimeout(CErrors_init, 500); return; }
  131. // Waze GUI needed
  132. CErrorshandle = getId("user-info"); if (typeof (CErrorshandle) == 'undefined') { window.setTimeout(CErrors_init, 500); return; }
  133. CErrorshandleClass = getElementsByClassName("nav-tabs", CErrorshandle)[0]; if (typeof (CErrorshandleClass) === 'undefined') { window.setTimeout(CErrors_init, 500); return; }
  134. CErrorshandleClass2 = getElementsByClassName("tab-content", CErrorshandle)[0]; if (typeof (CErrorshandleClass2) === 'undefined') { window.setTimeout(CErrors_init, 500); return; }
  135.  
  136. // Verify localStorage. Init if empty or not correct
  137. if (typeof (localStorage.WMEColorErrors) === "undefined" || localStorage.WMEColorErrors.lenght === null || !IsJsonString(localStorage.WMEColorErrors)) {
  138. WMECErrors.opacity = 0.85; // Icons Opacity on map
  139. WMECErrors.myLvl = false; // Show when editable
  140. WMECErrors.seg_Bad = false; // Bad Segments (group)
  141. WMECErrors.seg_Priv = true; // Private with bad name
  142. WMECErrors.seg_Park = true; // Parking with name (but Place / Square)
  143. WMECErrors.seg_Rail = true; // Railroad with bad name
  144. WMECErrors.seg_HW_name = true; //Highways with bad name
  145. WMECErrors.seg_Dir_name = true; // Directions but not Ramp/Freeway
  146. WMECErrors.seg_Toll = true; // Toll (but Ramp/Freeway)
  147. WMECErrors.seg_Ramp_name = true; // Ramp with 3 directions or more
  148. WMECErrors.seg_Ramp_city = true; // Ramp with city name
  149. WMECErrors.seg_RShield = true; // Wrong prefix
  150. WMECErrors.seg_DleSpace = true; // Double space in name
  151. WMECErrors.seg_SegBadRS = true; // RoadShield but bad type
  152. WMECErrors.seg_SegRSWithoutCity = true; // RoadShield without city in alt
  153. WMECErrors.seg_HNFree = true; // House number on Freeway or ramp
  154. WMECErrors.seg_BadSpeed = true; // Bad speed (ex: >80km/h in city)
  155. WMECErrors.seg_BadAltState = true; // Alt State != Main State
  156. WMECErrors.seg_EmptyCityAlt = true; // Alt City is empty
  157. WMECErrors.seg_LockValue = true; // Bad lock
  158. // POI
  159. WMECErrors.poi_Bad = false; // Bad POI (group)
  160. WMECErrors.poi_Park_name = true; // Parking with [P]
  161. WMECErrors.poi_Address = true; // Bad adresss
  162. WMECErrors.poi_Entry = true; // Entry Point not defined
  163. WMECErrors.poi_LandM = true; // Landmark with address (street |& city)
  164. WMECErrors.poi_DleSpace = true; // Double space in name
  165. // Low errors
  166. WMECErrors.poi_Resid = true; // Maybe a residential
  167. WMECErrors.poi_Google = true; // No link with Google
  168. WMECErrors.poi_Phone = true; // bad phone number format
  169. WMECErrors.poi_AutoFixTel = false; // Auto-Format phone number when error
  170. WMECErrors.poi_WFeed = true; // Place created by WazeFeed
  171. WMECErrors.poi_WPark = true; // Place created by WazeParking1
  172. WMECErrors.poi_Relig = true; // Religious Center with bad name
  173. WMECErrors.poi_Transp = true; // Bad type or bad name for Buses, Subway or Tramway
  174. WMECErrors.poi_GasSta = true; // Gas Station with bad name
  175. WMECErrors.poi_Other = true; // Place "Other"
  176. //Autolock
  177. WMECErrors.autoLock = true; // Autolock
  178. localStorage.setItem('WMEColorErrors', JSON.stringify(WMECErrors));
  179. }
  180.  
  181. // WME Layers check
  182. var layersColor = CErrorsMap.getLayersBy("uniqueName", "__WME_Color_Errors"), layersIcons = CErrorsMap.getLayersBy("uniqueName", "__WME_Color_Errors_Icons");
  183. var ColorErrors_style = new CErrorsOpenLayers.Style({
  184. pointRadius: 2,
  185. fontWeight: "normal",
  186. label: "${labelText}",
  187. fontFamily: "Tahoma, Courier New",
  188. labelOutlineColor: "#FFFFFF",
  189. labelOutlineWidth: 2,
  190. fontColor: '#000000',
  191. fontSize: "10px"
  192. });
  193. if (layersColor.length === 0) {
  194. ColorErrors_mapLayer = new CErrorsOpenLayers.Layer.Vector("Color Errors", {
  195. displayInLayerSwitcher: false,
  196. uniqueName: "__WME_Color_Errors",
  197. styleMap: new CErrorsOpenLayers.StyleMap(ColorErrors_style)
  198. });
  199. CErrorsI18n.translations[CErrorsI18n.locale].layers.name["__WME_Color_Errors"] = "Color Errors";
  200. CErrorsMap.addLayer(ColorErrors_mapLayer);
  201. ColorErrors_mapLayer.setVisibility(true);
  202. }
  203. if (layersIcons.length === 0) {
  204. ColorErrors_mapLayerIcons = new CErrorsOpenLayers.Layer.Vector("Color Errors Icons", {
  205. displayInLayerSwitcher: false,
  206. uniqueName: "__WME_Color_Errors_Icons",
  207. styleMap: new CErrorsOpenLayers.StyleMap(ColorErrors_style)
  208. });
  209. CErrorsI18n.translations[CErrorsI18n.locale].layers.name["__WME_Color_Errors_Icons"] = "Color Errors Icons";
  210. CErrorsMap.addLayer(ColorErrors_mapLayerIcons);
  211. ColorErrors_mapLayerIcons.setVisibility(true);
  212. }
  213. UpdateObject = require("Waze/Action/UpdateObject");
  214. ActiveCountry = CErrorsModel.Countries.getTopCountry().abbr;
  215. ABBR = cntryDB[ActiveCountry];
  216. CErrors_Mainhtml();
  217. }
  218. function CErrAddInfo() {
  219. const editPanelObserver = new MutationObserver(function (mutations) {
  220. mutations.forEach((mutation) => {
  221. const nodeList = mutation.addedNodes;
  222. nodeList.forEach(addedNode => {
  223. // Only fire up if it's a node
  224. if (addedNode.nodeType === Node.ELEMENT_NODE) {
  225. /** @returns `<div>` element. */
  226. const alertDiv = /**@type {Element} */(addedNode).querySelector('wz-alerts-group');
  227. if (alertDiv) {
  228. if (getSelectedDataModelObjects().length !== 0 && !getId('ErrorsList')) {
  229. var ErrorsList_Div = document.createElement('span');
  230. ErrorsList_Div.id = "ErrorsList";
  231. ErrorsList_Div.style.cssText = "list-style-type:none;";
  232. if (document.querySelector('wz-alerts-group')) {
  233. document.querySelector('wz-alerts-group').appendChild(ErrorsList_Div);
  234. }
  235. CErrColor()
  236. }
  237. }
  238.  
  239. }
  240. }
  241. );
  242. });
  243. });
  244. editPanelObserver.observe(document.getElementById('edit-panel'), { childList: true, subtree: true });
  245. }
  246.  
  247.  
  248.  
  249. // *************
  250. // ** HTML **
  251. // *************
  252. function CErrors_Mainhtml() {
  253. if (CErrorsI18n.locale == 'fr') {
  254. CErrSeg = new Array('Contrôle des segments',
  255. 'Mauvais segments',
  256. 'Voie privée avec possible mauvais nom',
  257. 'Voie de Parking nommée',
  258. 'Voie ferrée nommée ou nom en alt',
  259. 'Types Routes avec mauvais nom',
  260. 'Bretelle avec plusieurs directions',
  261. 'Direction (sauf bretelle et Autoroute)',
  262. 'Mauvais préfixe (RoadShield)',
  263. 'Double espace dans le nom',
  264. 'Péage (sauf bretelle et Autoroute)',
  265. 'Bretelle/Autoroute avec nom de ville',
  266. 'Le RoadShield doit être en alt',
  267. 'Le nom de route doit être en alt',
  268. 'RoadShield sur mauvais type de voie',
  269. 'N° de rue sur mauvais type de voie',
  270. 'Mauvaise vitesse validée',
  271. 'Département alt différent du principal',
  272. 'Lock non conforme (Auto ou valeur)',
  273. 'Alt non conforme',
  274. 'RoadShield sans ville en alt'
  275. );
  276. CErrPoi = new Array('Contrôle des places',
  277. 'Mauvaises places',
  278. 'Parking mal nommé ou sans nom',
  279. 'Adresse incorrecte ou incomplète',
  280. 'Point d\'entrée non défini',
  281. 'Site naturel avec adresse',
  282. 'Double espace dans le nom',
  283. 'Peut-être une place résidentielle',
  284. 'Pas de lien avec Google',
  285. 'Lieu édité par WazeFeed',
  286. 'Lieu de type "Autres"',
  287. 'Lieu édité par WazeParking1',
  288. 'Parking : type non défini',
  289. 'Mauvais format du n° de tel',
  290. 'Lieu de culte (nom ou catégorie)',
  291. 'Transport (nom ou catégorie)',
  292. 'Station-Service mal nommée',
  293. 'Correction automatique du numéro'
  294. );
  295. CErrLeg = new Array('Légende',
  296. 'A corriger',
  297. 'A vérifier',
  298. 'Pour information',
  299. 'Réglages',
  300. 'Opacité des icônes',
  301. 'Afficher seulements les éditables',
  302. 'Verrouillé par la publicité',
  303. 'Auto-verrouillage'
  304. );
  305. }
  306. else {
  307. CErrSeg = new Array('Segments Checking',
  308. 'Bad Segments',
  309. 'Private with possible bad name',
  310. 'Parking with bad name or without',
  311. 'Railroad with name or altname',
  312. 'Highways with bad name',
  313. 'Ramp with several directions',
  314. 'Direction (but Ramp/Freeway)',
  315. 'Wrong prefix (RoadShield)',
  316. 'Double spacing in name',
  317. 'Toll (but Ramp/Freeway)',
  318. 'Ramp/Freeway with city name',
  319. 'RoadShield must be in alt',
  320. 'Road name must be in alt',
  321. 'RoadShield but bad type',
  322. 'HN but bad type',
  323. 'Bad speed verified',
  324. 'Alt State dirrent to Main State',
  325. 'Bad lock (Auto or value)',
  326. 'Bad Alt',
  327. 'RoadShield without city in alt'
  328. );
  329. CErrPoi = new Array('Places Checking',
  330. 'Bad Places',
  331. 'Parking with bad name or null',
  332. 'Bad or incomplete address',
  333. 'Entry Point not defined',
  334. 'Natural features with address',
  335. 'Double spacing in name',
  336. 'Maybe a residential place',
  337. 'No link with Google',
  338. 'Place created by WazeFeed',
  339. 'Place type is "Other"',
  340. 'Place created by WazeParking1',
  341. 'Parking : type undefined',
  342. 'Bad phone number format',
  343. 'Religious Center (name or cat)',
  344. 'Transportation (name or cat)',
  345. 'Gas Station with bad name',
  346. 'Auto number format'
  347. );
  348. CErrLeg = new Array('Legend',
  349. 'To correct',
  350. 'To check',
  351. 'For information',
  352. 'Settings',
  353. 'Icons opacity',
  354. 'Show when editable',
  355. 'Locked by ad',
  356. 'Autolock'
  357. );
  358. }
  359. //Create content in CErrors's tab
  360. var CEnewtab = document.createElement('li');
  361. CEnewtab.innerHTML = "<a href='#sidepanel-ColorErrors' data-toggle='tab'><span class='fa fa-eye' title='Color Errors'></span></a>";
  362. CErrorshandleClass.appendChild(CEnewtab);
  363.  
  364. var WMECErrors = JSON.parse(localStorage.getItem('WMEColorErrors'));
  365. if (typeof (WMECErrors.autoLock) == "undefined") { WMECErrors.autoLock = false; }
  366. var CEaddon = document.createElement('section');
  367. CEaddon.id = "sidepanel-ColorErrors";
  368. 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>'
  369. + '<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>'
  370. + '<div style="float:left;clear:both;"><input type="checkbox" id="_myLvl"' + (WMECErrors.myLvl ? ' checked' : '') + '/> ' + CErrLeg[6] + '</div>'
  371. + '<br><br><H6 style="float:left;margin-top:10px;">' + CErrSeg[0] + '</H6><div style="clear:both;">'
  372. + '<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>'
  373. + fillHtml("seg_Ramp_name", "seg_Bad", "#ff7700", "\uf25a", CErrSeg[6])
  374. + fillHtml("seg_BadSpeed", "seg_Bad", "#ff7700", "\uf1ce", CErrSeg[16])
  375. + fillHtml("seg_BadAltState", "seg_Bad", "#ff7700", "\uf037", CErrSeg[17])
  376. + fillHtml("seg_EmptyCityAlt", "seg_Bad", "#ff7700", "\uf064", CErrSeg[19])
  377. + fillHtml("seg_LockValue", "seg_Bad", "#ff7700", "\uf023", CErrSeg[18])
  378. + fillHtml("seg_Park", "seg_Bad", "#ff0000", "\uf288", CErrSeg[3])
  379. + fillHtml("seg_Rail", "seg_Bad", "#ff0000", "\uf238", CErrSeg[4])
  380. + fillHtml("seg_Dir_name", "seg_Bad", "#ff0000", "\uf0a9", CErrSeg[7])
  381. + fillHtml("seg_Toll", "seg_Bad", "#ff0000", "\uf155", CErrSeg[10])
  382. + fillHtml("seg_Ramp_city", "seg_Bad", "#ff0000", "\uf015", CErrSeg[11])
  383. + fillHtml("seg_DleSpace", "seg_Bad", "#ff0000", "\uf101", CErrSeg[9])
  384. + fillHtml("seg_HW_name", "seg_Bad", "#ff0000", "\uf018", CErrSeg[5])
  385. + fillHtml("seg_RShield", "seg_Bad", "#ff0000", "\uf152", CErrSeg[8])
  386. + fillHtml("seg_SegBadRS", "seg_Bad", "#ff0000", "\uf044", CErrSeg[14])
  387. + fillHtml("seg_SegRSWithoutCity", "seg_Bad", "#ff0000", "\uf044", CErrSeg[20])
  388. + fillHtml("seg_HNFree", "seg_Bad", "#ff0000", "\uf162", CErrSeg[15])
  389.  
  390. + '</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>'
  391. + fillHtml("poi_Address", "poi_Bad", "#ff0000", "\uf2bc", CErrPoi[3])
  392. + fillHtml("poi_LandM", "poi_Bad", "#ff0000", "\uf1bb", CErrPoi[5])
  393. + fillHtml("poi_DleSpace", "poi_Bad", "#ff0000", "\uf101", CErrPoi[6])
  394. + fillHtml("poi_Transp", "poi_Bad", "#ff0000", "\uf207", CErrPoi[15])
  395. + fillHtml("poi_GasSta", "poi_Bad", "#ff0000", "\uf1b9", CErrPoi[16])
  396. + fillHtml("poi_Park_name", "poi_Bad", "#ff0000", "\uf288", CErrPoi[2])
  397. + fillHtml("poi_Park_type", "poi_Bad", "#ff0000", "\uf11d", CErrPoi[12])
  398. + fillHtml("poi_Relig", "poi_Bad", "#ff0000", "\uf015", CErrPoi[14])
  399. + fillHtml("poi_Entry", "poi_Bad", "#ff7700", "\uf18e", CErrPoi[4])
  400. + fillHtml("poi_Resid", "poi_Bad", "#ff7700", "\uf015", CErrPoi[7])
  401. + fillHtml("poi_Google", "poi_Bad", "#ff7700", "\uf1a0", CErrPoi[8])
  402. + fillHtml("poi_Phone", "poi_Bad", "#ff7700", "\uf095", CErrPoi[13])
  403. + fillHtml("poi_AutoFixTel", "poi_Bad", "#ff7700", "\uf062\uf0d0", CErrPoi[17])
  404. + fillHtml("poi_Other", "poi_Bad", "#ff7700", "\uf29c", CErrPoi[10])
  405. + fillHtml("poi_WFeed", "poi_Bad", "#ffcc00", "\uf263", CErrPoi[9])
  406. + fillHtml("poi_WPark", "poi_Bad", "#ffcc00", "\uf263", CErrPoi[11])
  407. + '</table></div></div><br><H6 style="float:left;">' + CErrLeg[0] + '</H6><div style="clear:both;">'
  408. + '<table><tr><td><div style="margin:5px;width:30px;height:2px;background-color:#ff0000;"></div></td><td>' + CErrLeg[1] + '</td></tr>'
  409. + '<tr><td><div style="margin:5px;width:30px;height:2px;background-color:#ff7700;"></div></td><td>' + CErrLeg[2] + '</td></tr>'
  410. + '<tr><td><div style="margin:5px;width:30px;height:2px;background-color:#ffcc00;"></div></td><td>' + CErrLeg[3] + '</td></tr>'
  411.  
  412. + '</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>'
  413. + fillHtmlAL("Freeway", I18n.translations[I18n.locale].segment.road_types[3], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.fwy_lvl + 1)))
  414. + fillHtmlAL("Ramp", I18n.translations[I18n.locale].segment.road_types[4], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.rmp_lvl + 1)))
  415. + fillHtmlAL("Major", I18n.translations[I18n.locale].segment.road_types[6], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.maj_lvl + 1)))
  416. + fillHtmlAL("Minor", I18n.translations[I18n.locale].segment.road_types[7], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.min_lvl + 1)))
  417. + fillHtmlAL("Primary", I18n.translations[I18n.locale].segment.road_types[2], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.pri_lvl + 1)))
  418. + fillHtmlAL("Street", I18n.translations[I18n.locale].segment.road_types[1], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.str_lvl + 1)))
  419. + fillHtmlAL("Railway", I18n.translations[I18n.locale].segment.road_types[18], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.rwy_lvl + 1)))
  420. + fillHtmlAL("Narrow", I18n.translations[I18n.locale].segment.road_types[22], (typeof (ABBR) == 'undefined' ? 'N/A' : (ABBR.nar_lvl + 1)))
  421. + '</table></div></div>';
  422.  
  423. CEaddon.innerHTML = CEcontent;
  424. CEaddon.className = 'tab-pane';
  425. CErrorshandleClass2.appendChild(CEaddon);
  426.  
  427. getId('errOpacity').value = WMECErrors.opacity;
  428. getId('opacityValue').innerHTML = getId('errOpacity').value;
  429. getId('errOpacity').onmousemove = function () {
  430. getId('opacityValue').innerHTML = getId('errOpacity').value;
  431. var ls = JSON.parse(localStorage.WMEColorErrors);
  432. ls.opacity = getId('errOpacity').value;
  433. localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
  434. CErrColor();
  435. };
  436. getId('_myLvl').onclick = (function () {
  437. var ls = JSON.parse(localStorage.WMEColorErrors);
  438. (getId('_myLvl').checked === true ? ls.myLvl = true : ls.myLvl = false);
  439. localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
  440. CErrColor();
  441. });
  442. getId('_seg_Bad').onclick = (function () {
  443. var ls = JSON.parse(localStorage.WMEColorErrors);
  444. if (getId('_seg_Bad').checked === true) {
  445. for (var i = 0; getElementsByClassName('_seg', BadSeg)[i]; i++) getElementsByClassName('_seg', BadSeg)[i].disabled = false;
  446. ls.seg_Bad = true;
  447. }
  448. else {
  449. for (var i = 0; getElementsByClassName('_seg', BadSeg)[i]; i++) getElementsByClassName('_seg', BadSeg)[i].disabled = true;
  450. ls.seg_Bad = false;
  451. }
  452. localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
  453. CErrColor();
  454. });
  455. getId('_poi_Bad').onclick = (function () {
  456. var ls = JSON.parse(localStorage.WMEColorErrors);
  457. if (getId('_poi_Bad').checked === true) {
  458. for (var i = 0; getElementsByClassName('_poi', BadPoi)[i]; i++) getElementsByClassName('_poi', BadPoi)[i].disabled = false;
  459. ls.poi_Bad = true;
  460. }
  461. else {
  462. for (var i = 0; getElementsByClassName('_poi', BadPoi)[i]; i++) getElementsByClassName('_poi', BadPoi)[i].disabled = true;
  463. ls.poi_Bad = false;
  464. }
  465. localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
  466. CErrColor();
  467. });
  468. getId('_autoLock').onclick = (function () {
  469. var ls = JSON.parse(localStorage.WMEColorErrors);
  470. if (getId('_autoLock').checked === true) {
  471. for (var i = 0; getElementsByClassName('_auto', AutoLock)[i]; i++) getElementsByClassName('_auto', AutoLock)[i].disabled = false;
  472. ls.autoLock = true;
  473. getId('addLockButton').className = 'fabkm fa fa-lock';
  474. getId('addLockButton').style.color = '#7f0';
  475. }
  476. else {
  477. for (var i = 0; getElementsByClassName('_auto', AutoLock)[i]; i++) getElementsByClassName('_auto', AutoLock)[i].disabled = true;
  478. ls.autoLock = false;
  479. getId('addLockButton').className = 'fabkm fa fa-unlock';
  480. getId('addLockButton').style.color = '#f60';
  481. }
  482. localStorage.setItem('WMEColorErrors', JSON.stringify(ls));
  483. CErrColor();
  484. });
  485.  
  486. 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(); });
  487. 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(); });
  488. 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(); });
  489. 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(); });
  490. 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(); });
  491. 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(); });
  492. 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(); });
  493. 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(); });
  494. 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(); });
  495. 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(); });
  496. 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(); });
  497. 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(); });
  498. 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(); });
  499. 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(); });
  500. 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(); });
  501. 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(); });
  502.  
  503. 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(); });
  504. 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(); });
  505. 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(); });
  506. 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(); });
  507. 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(); });
  508. 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(); });
  509. 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(); });
  510. 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(); });
  511. 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(); });
  512. 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(); });
  513. 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(); });
  514. 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(); });
  515. 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(); });
  516. 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(); });
  517. 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(); });
  518. 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(); });
  519.  
  520. 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(); });
  521. 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(); });
  522. 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(); });
  523. 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(); });
  524. 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(); });
  525. 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(); });
  526. 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(); });
  527. 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(); });
  528. if (CErrorsUser.rank > 3) {
  529. setTimeout(function () {
  530. var addLockButton = document.createElement('div');
  531. addLockButton.id = 'addLockButton';
  532. $(addLockButton).css({ 'float': 'left', 'margin-right': '5px', 'cursor': 'pointer', 'opacity': '0.6' });
  533. addLockButton.className = 'fabkm fa fa-lock';
  534. addLockButton.onclick = (function () {
  535. getId('_autoLock').click();
  536. if (getId('_autoLock').checked) {
  537. addLockButton.className = 'fabkm fa fa-lock';
  538. addLockButton.style.color = '#7f0';
  539. } else {
  540. addLockButton.className = 'fabkm fa fa-unlock';
  541. addLockButton.style.color = '#f60';
  542. }
  543. });
  544. getElementsByClassName('topbar')[0].insertBefore(addLockButton, getElementsByClassName('location-info-region')[0]);
  545. getElementsByClassName('topbar')[0].style.padding = '0 10px';
  546. addLockButton.onmouseover = (function () { getId('addLockButton').style.opacity = '1'; });
  547. addLockButton.onmouseout = (function () { getId('addLockButton').style.opacity = '0.6'; });
  548. if (WMECErrors.autoLock) {
  549. addLockButton.className = 'fabkm fa fa-lock';
  550. addLockButton.style.color = '#7f0';
  551. } else {
  552. addLockButton.className = 'fabkm fa fa-unlock';
  553. addLockButton.style.color = '#f60';
  554. }
  555. }, 1000);
  556. }
  557.  
  558. // Gestion des Events
  559. CErrWaze.Events.on({
  560. eventName: "wme-selection-changed",
  561. eventHandler: () => {
  562. CErrAddInfo();
  563. CErrColor();
  564. }
  565. });
  566. CErrWaze.Events.on({
  567. eventName: "wme-after-redo-clear",
  568. eventHandler: () => {
  569. CErrColor();
  570. }
  571. });
  572. CErrWaze.Events.on({
  573. eventName: "wme-after-undo",
  574. eventHandler: () => {
  575. CErrColor();
  576. }
  577. });
  578. CErrWaze.Events.on({
  579. eventName: "wme-map-data-loaded",
  580. eventHandler: () => {
  581. CErrColor();
  582. }
  583. });
  584. }
  585. function fillHtml(id, type, color, icon, text) {
  586. var WMECErrors = JSON.parse(localStorage.getItem('WMEColorErrors'));
  587. 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>';
  588. }
  589. function fillHtmlAL(id, text, lockValue) {
  590. var WMECErrors = JSON.parse(localStorage.getItem('WMEColorErrors')), colorLock;
  591. switch (lockValue) {
  592. case 1: colorLock = "#00cf00"; break;
  593. case 2: colorLock = "#0179B5"; break;
  594. case 3: colorLock = "#ffcc00"; break;
  595. case 4: colorLock = "orange"; break;
  596. case 5: colorLock = "red"; break;
  597. }
  598. 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>';
  599. }
  600.  
  601. function addIcon(icon, color, geometry, type, pos) {
  602.  
  603. var style = {
  604. fill: false,
  605. stroke: false,
  606. label: icon,
  607. labelAlign: "cb",
  608. labelXOffset: -4,
  609. labelYOffset: (pos * 20),
  610. fontColor: color,
  611. fontSize: "20px",
  612. fontOpacity: getId('errOpacity').value,
  613. fontFamily: "FontAwesome",
  614. labelOutlineWidth: 2,
  615. zIndex: 99999
  616. };
  617. geometry = W.userscripts.toOLGeometry(geometry);
  618. if (type === "segment") {
  619. geometry = geometry.components;
  620. if (geometry.length == 2) {
  621. var midX = (((geometry[0].x + geometry[1].x) / 2) + geometry[0].x) / 2;
  622. var midY = (((geometry[0].y + geometry[1].y) / 2) + geometry[0].y) / 2;
  623. var labelPoint = new CErrorsOpenLayers.Geometry.Point(midX, midY);
  624. var imageFeature = new CErrorsOpenLayers.Feature.Vector(labelPoint, null, style);
  625. ColorErrors_mapLayer.addFeatures([imageFeature]);
  626. }
  627. else {
  628. for (i = 0; i < geometry.length - 1; i++) {
  629. if (i % 3 == 1) {
  630. var midX = (((geometry[i].x + geometry[i + 1].x) / 2) + geometry[i].x) / 2;
  631. var midY = (((geometry[i].y + geometry[i + 1].y) / 2) + geometry[i].y) / 2;
  632. var labelPoint = new CErrorsOpenLayers.Geometry.Point(midX, midY);
  633. var imageFeature = new CErrorsOpenLayers.Feature.Vector(labelPoint, null, style);
  634. ColorErrors_mapLayer.addFeatures([imageFeature]);
  635. }
  636. }
  637. }
  638. }
  639. else {
  640. if (geometry) {
  641. if (geometry.components) {
  642. geometry = geometry.components[0].components[0];
  643. var labelPoint = new CErrorsOpenLayers.Geometry.Point(geometry.x, geometry.y);
  644. var imageFeature = new CErrorsOpenLayers.Feature.Vector(labelPoint, null, style);
  645. ColorErrors_mapLayer.addFeatures([imageFeature]);
  646. } else {
  647. var labelPoint = new CErrorsOpenLayers.Geometry.Point(geometry.x, geometry.y);
  648. var imageFeature = new CErrorsOpenLayers.Feature.Vector(labelPoint, null, style);
  649. ColorErrors_mapLayer.addFeatures([imageFeature]);
  650. }
  651. }
  652. }
  653. }
  654. function addLegend(id, icon, color, text, url) {
  655. if (getSelectedDataModelObjects() && getSelectedDataModelObjects().ids[0] === id && getId('ErrorsList')) {
  656. getId('ErrorsList').innerHTML += "<li id='item" + id + "'><span style='color:" + color + ";font-family:FontAwesome;'>" + icon + "</span> <span style='color:" + color + ";'>" + text + "</span></li>";
  657. //getId('item'+id).onclick=openInNewTab(url);
  658. }
  659. }
  660. function relock(obj, key) {
  661. var objects = obj[key], _i = 0;
  662. while (typeof (objects[_i]) != "undefined") {
  663. W.model.actionManager.add(objects[_i]);
  664. _i++;
  665. }
  666. }
  667. function CErrColor() {
  668. if (CErrorsUser != null && CErrorsModel.Countries.getTopCountry() != null) {
  669. var lineFeature = [], ls = JSON.parse(localStorage.WMEColorErrors);
  670. var lieu = CErrorsI18n.translations[CErrorsI18n.locale].layers.name.landmarks;
  671.  
  672. //Check if Autolock is defined for active country
  673. if (ActiveCountry != CErrorsModel.Countries.getTopCountry().abbr) {
  674. ActiveCountry = CErrorsModel.Countries.getTopCountry().abbr;
  675. ABBR = cntryDB[ActiveCountry];
  676. if (typeof (ABBR) == 'undefined') {
  677. getId('_autoLock').disabled = true;
  678. for (var i = 0; getElementsByClassName('_auto', AutoLock)[i]; i++) getElementsByClassName('_auto', AutoLock)[i].disabled = true;
  679. } else {
  680. getId('_autoLock').disabled = false;
  681. for (var i = 0; getElementsByClassName('_auto', AutoLock)[i]; i++) getElementsByClassName('_auto', AutoLock)[i].disabled = false;
  682. }
  683. getId('_autoLockLabel').innerHTML = CErrLeg[8] + ' (' + CErrorsModel.Countries.getTopCountry().name + ')';
  684. }
  685.  
  686. if (CErrorsUser.rank > 3) { if (getId('CMOnly')) { getId('CMOnly').style.display = "block"; } } else { if (getId('CMOnly')) { getId('CMOnly').style.display = "none"; } }
  687.  
  688. // Initialize layer
  689. try { ColorErrors_mapLayer.destroyFeatures(); }
  690. catch (err) { log('err destroyFeatures: ', err); }
  691. if (getId('ErrorsList')) { getId('ErrorsList').innerHTML = ""; }
  692. //Segments Checking
  693. if (ls.seg_Bad || ls.autoLock) {
  694. var autoLockId = [], relockObject = { 'str': [], 'pri': [], 'min': [], 'maj': [], 'rmp': [], 'fwy': [], 'rwy': [], 'nar': [] };
  695.  
  696. for (var seg of CErrorsModel.Segments.getAll()) {
  697. // Get values
  698. var segment = CErrorsModel.Segments.getById({ segmentId: seg.id }), j = 0;
  699. var attributes = segment
  700. var geometry = segment.geometry;
  701. if (segment === null || segment.state === "Update") continue;
  702. //Name
  703. var sid = attributes.primaryStreetId;
  704. if (sid) {
  705. var street = CErrorsModel.Streets.getById({ streetId: sid });
  706. } else { var street = ""; }
  707. //Alt Name
  708. if (attributes.alternateStreetIds && Object.keys(attributes.alternateStreetIds) > 0) {
  709. var salt = attributes.alternateStreetIds[0];
  710. var streetalt = CErrorsModel.Streets.getById({ streetId: salt });
  711. if (streetalt) {
  712. var altname = streetalt.name;
  713. var streetAltCity = CErrorsModel.Cities.getById({ cityId: streetalt.cityId });
  714. } else { var altname = ""; }
  715. }
  716.  
  717. //Alt Name for roadshield
  718. saltArray = attributes.alternateStreetIds;
  719. const altnameArray = [];
  720. const streetCityArray = [];
  721. if (saltArray.length > 0) {
  722. var i = 0;
  723. for (const idsalt of saltArray) {
  724. streetaltTest = CErrorsModel.Streets.getById({ streetId: idsalt });
  725. if (streetaltTest) {
  726. altnameArray.push(streetaltTest.name);
  727. var streetAltCityTest = CErrorsModel.Cities.getById({ cityId: streetaltTest.cityId });
  728. if (streetAltCityTest) {
  729. streetCityArray.push(streetAltCityTest.name);
  730. }
  731. }
  732. i++;
  733. }
  734. }
  735. //City
  736. if (street.cityId === null) continue;
  737. var streetCity = CErrorsModel.Cities.getById({ cityId: street.cityId });
  738. if (streetCity === null) continue;
  739. streetCity = streetCity.name;
  740. var roadType = attributes.roadType;
  741. if (attributes.primaryStreetId === null || attributes.primaryStreetId === undefined) continue;
  742. if (CErrorsModel.Streets.getById({ streetId: attributes.primaryStreetId }) === null || CErrorsModel.Streets.getById({ streetId: attributes.primaryStreetId }) === undefined) continue;
  743. if (CErrorsModel.Cities.getById({ cityId: street.cityId }).countryId != CErrorsModel.Countries.getTopCountry().id) { continue; }
  744.  
  745. var newWidth = "", newColor = "", newOpacity = "0", gline = "";
  746. if (ls.seg_Bad == true && (ls.myLvl && attributes.lockRank <= CErrorsUser.rank) || ls.seg_Bad == true && ls.myLvl == false) {
  747. if (ls.seg_Ramp_city) { // Ramp/Freeway with city name
  748. if (streetCity && /^(3|4)$/.test(attributes.roadType)) {
  749. newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  750. j++;
  751. addIcon("\uf015", newColor, geometry, "segment", j);
  752. 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");
  753. }
  754. }
  755. if (street.name || altname) {
  756. if (/( - )/.test(street.name)) { var trs = street.name.split(" - "); }
  757. if (ls.seg_Park && street.name) { // Parking with name (But Place / Square)
  758. if (attributes.roadType === 20 && new RegExp(parkNameSeg).test(street.name) === false) {
  759. newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  760. j++;
  761. addIcon("\uf288", newColor, geometry, "segment", j);
  762. addLegend(attributes.id, "\uf288", newColor, CErrSeg[3], "");
  763. }
  764. }
  765. if (ls.seg_Rail && street.name) { // Railroad with bad name
  766. if (attributes.roadType === 18 && (altname || street.name)) { //Railroad with name
  767. newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  768. j++;
  769. addIcon("\uf238", newColor, geometry, "segment", j);
  770. addLegend(attributes.id, "\uf238", newColor, CErrSeg[4], "Routes_Nommage#1.5.4_Voies_ferr.C3.A9es");
  771. }
  772. }
  773. if (ls.seg_Ramp_name && street.name) {
  774. if (/^(3|4)$/.test(attributes.roadType) && /\/.*\//.test(street.name)) { // Ramp with 3 directions or more
  775. newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  776. j++;
  777. addIcon("\uf25b", newColor, geometry, "segment", j);
  778. 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");
  779. }
  780. else if (/^(3|4)$/.test(attributes.roadType) && /\//.test(street.name)) { // Ramp with 2 directions
  781. newColor = "#ff7700"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  782. j++;
  783. addIcon("\uf25a", newColor, geometry, "segment", j);
  784. 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");
  785. }
  786. }
  787. if (ls.seg_Dir_name && street.name) { // Directions but not Ramp/Freeway/Major
  788. if (/^[^3|4|6]$/.test(attributes.roadType) && /[:|>]/.test(street.name)) {
  789. newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  790. j++;
  791. addIcon("\uf0a9", newColor, geometry, "segment", j);
  792. 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");
  793. }
  794. }
  795. if (ls.seg_Toll) { // Toll but not Ramp/Freeway
  796. if (/^[^3|4]$/.test(attributes.roadType) && (attributes.fwdToll || attributes.revToll)) {
  797. newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  798. j++;
  799. addIcon("\uf155", newColor, geometry, "segment", j);
  800. addLegend(attributes.id, "\uf155", newColor, CErrSeg[10], "");
  801. }
  802. }
  803. if (ls.seg_HW_name && street.name) { // Highways with bad name
  804. 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) {
  805. newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  806. j++;
  807. addIcon("\uf018", newColor, geometry, "segment", j);
  808. addLegend(attributes.id, "\uf018", newColor, CErrSeg[5], "Routes_Nommage#1.4.2_Autoroutes");
  809. }
  810. }
  811. if (ls.seg_SegBadRS && street.name) { // RoadShield but bad type
  812. 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))) {
  813. newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  814. j++;
  815. addIcon("\uf044", newColor, geometry, "segment", j);
  816. addLegend(attributes.id, "\uf044", newColor, CErrSeg[14], "Routes_Classification#2.4_Famille_des_Routes");
  817. }
  818. }
  819. if (ls.seg_HNFree) { // House number on undrivables
  820. if (/^(14|18|19)$/.test(attributes.roadType) && attributes.hasHNs === true) {
  821. newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  822. j++;
  823. addIcon("\uf162", newColor, geometry, "segment", j);
  824. addLegend(attributes.id, "\uf162", newColor, CErrSeg[15], "");
  825. }
  826. }
  827. if (ls.seg_BadSpeed) { // Bad speed (ex: >70km/h in city)
  828. if (attributes.fwdMaxSpeed > 70 && attributes.fwdMaxSpeedUnverified === false && attributes.revMaxSpeed > 70 && attributes.revMaxSpeedUnverified === false && streetCity) {
  829. newColor = "#ff7700"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  830. j++;
  831. addIcon("\uf1ce", newColor, geometry, "segment", j);
  832. addLegend(attributes.id, "\uf1ce", newColor, CErrSeg[16], "Routes_Vitesses#4.2_Tour_d.27horizon_des_diff.C3.A9rentes_vitesses_limites");
  833. }
  834. }
  835. if (ls.seg_RShield && street.name) { // Wrong prefix (RoadShield)
  836. 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)
  837. || /^[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
  838. ) {
  839. newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  840. j++;
  841. addIcon("\uf152", newColor, geometry, "segment", j);
  842. addLegend(attributes.id, "\uf152", newColor, CErrSeg[8], "");
  843. }
  844. }
  845.  
  846. if (ls.seg_SegRSWithoutCity && street.name) {// RoadShield without city in alt
  847. if (/^(1|2|6|7)$/.test(attributes.roadType) && (/^[C|D|N|M|R|T][0-9]+/.test(street.name)) && !streetCity && altnameArray && streetCityArray) {
  848. BadAltRoadshield = false;
  849. NoRoadshield = true;
  850. if (altnameArray.length >= 1) {
  851. for (let i = 0; i < altnameArray.length; i++) {
  852. if ((/^[A|C|D|N|M|R|T][0-9]+/.test(altnameArray[i])) == true && NoRoadshield == true) {
  853. NoRoadshield = false;
  854. }
  855. if (((/^[A|C|D|N|M|R|T][0-9]+/.test(altnameArray[i])) == true && !streetCityArray[i])) {
  856. BadAltRoadshield = true;
  857. }
  858. }
  859. }
  860. if (BadAltRoadshield || NoRoadshield) {
  861. newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  862. j++;
  863. addIcon("\uf044", newColor, geometry, "segment", j);
  864. addLegend(attributes.id, "\uf044", newColor, CErrSeg[20], "Routes_Classification#2.4_Famille_des_Routes");
  865. }
  866. }
  867. }
  868. if (ls.seg_DleSpace && street.name) { // Double spacing in name
  869. if (/ /.test(street.name) === true) {
  870.  
  871. newColor = "#ff0000"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  872. j++;
  873. addIcon("\uf101", newColor, geometry, "segment", j);
  874. addLegend(attributes.id, "\uf101", newColor, CErrSeg[9], "");
  875. }
  876. }
  877. if (ls.seg_BadAltState) {
  878. if (streetalt != null && CErrorsModel.Cities.getById({ cityId: street.cityId }).stateId != streetAltCity.stateId) { // Alt State != Main State
  879. newColor = "#ff7700"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  880. j++;
  881. addIcon("\uf037", newColor, geometry, "segment", j);
  882. 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>", "");
  883. }
  884. }
  885. if (ls.seg_EmptyCityAlt && streetalt != null) { // Bad Alt
  886. var g = 0;
  887. for (var f = 0; f < Object.keys(attributes.alternateStreetIds).length; f++) {
  888. var streetalt = CErrorsModel.Streets.getById({ streetId: attributes.alternateStreetIds[f] });
  889. 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) {
  890. newColor = "#ff7700"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  891. j++;
  892. addIcon("\uf064", newColor, geometry, "segment", j);
  893. addLegend(attributes.id, "\uf064", newColor, CErrSeg[19], "");
  894. }
  895. }
  896. }
  897. }
  898. if (ls.seg_LockValue && attributes.lockRank != 5) { // Ignore Lock 6;
  899. if (
  900. ((attributes.flagAttributes.fwdSpeedCamera == 1 || attributes.flagAttributes.revSpeedCamera == 1) && attributes.lockRank != 4) || // Speedcam but not locked 5
  901. attributes.flagAttributes.fwdSpeedCamera != 1 && attributes.flagAttributes.revSpeedCamera != 1 && // no speedcam
  902. (/^(3|4|6|18)$/.test(attributes.roadType) && attributes.lockRank != 4 //Lock 5 for freeway, ramp, major and railroad
  903. || attributes.roadType == 7 && attributes.lockRank != 3 //Lock 4 for minor
  904. || attributes.roadType == 2 && attributes.lockRank != 2 //Lock 3 for primary
  905. || /^(1|8|17|19|22)$/.test(attributes.roadType) === true && attributes.lockRank != 0 && attributes.lockRank != null) //Lock 1 for others (5,10,15,16,20)
  906. ) {
  907. newColor = "#ff7700"; newWidth = 3; newOpacity = 0.95; gline = W.userscripts.toOLGeometry(seg.geometry).components;
  908. j++;
  909. addIcon("\uf023", newColor, geometry, "segment", j);
  910. addLegend(attributes.id, "\uf023", newColor, CErrSeg[18], "WME_Droits");
  911. }
  912. }
  913. // Highlight if error
  914. if (gline !== "") {
  915. var style = {
  916. strokeWidth: newWidth,
  917. strokeColor: newColor,
  918. strokeOpacity: newOpacity
  919. };
  920. var points = [];
  921. for (var i = 0; i < gline.length; i++) { points.push(new CErrorsOpenLayers.Geometry.Point(gline[i].x, gline[i].y)); }
  922. var newline = new CErrorsOpenLayers.Geometry.LineString(points);
  923. lineFeature.push(new CErrorsOpenLayers.Feature.Vector(newline, null, style));
  924. }
  925. }
  926.  
  927. //Autolock
  928. var lock = attributes.lockRank;
  929. if (ls.autoLock === true &&
  930. (ls.myLvl && lock <= CErrorsUser.rank || ls.myLvl == false) &&
  931. lock != 5 &&
  932. onScreen(segment) &&
  933. autoLockId.indexOf(attributes.id) == -1 &&
  934. getId('_autoLock').disabled == false &&
  935. CErrorsUser.rank > 3) {
  936. if (attributes.flagAttributes.revSpeedCamera != '1' && attributes.flagAttributes.fwdSpeedCamera != '1') {
  937. switch (attributes.roadType) {
  938. 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;
  939. 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;
  940. 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;
  941. 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;
  942. 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;
  943. 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;
  944. 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;
  945. 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;
  946. }
  947. }
  948. // Lock 5 if ASC
  949. if ((attributes.flagAttributes.fwdSpeedCamera == '1' || attributes.flagAttributes.revSpeedCamera == '1') && lock != '4') { autoLockId.push(attributes.id); relockObject.others.push(new UpdateObject(segment, { lockRank: '4' })); }
  950. }
  951. }
  952.  
  953. $.each(relockObject, function (key, value) {
  954. relock(relockObject, key);
  955. });
  956. }
  957.  
  958. //Places Checking
  959. if (ls.poi_Bad && getId('layer-switcher-group_places').checked) {
  960. for (var poi of CErrorsModel.Venues.getAll()) {
  961. // Get values
  962. var venue = CErrorsModel.Venues.getById({ venueId: poi.id }), j = 0;
  963. var pattributes = venue;
  964. var pid = pattributes.id;
  965. if (pattributes.geometry) geometry = pattributes.geometry;
  966. if (venue === null || pid === null || geometry === null || poi.state == "Update" || poi.selected) continue;
  967. var categories = pattributes.categories;
  968. var pname = pattributes.name;
  969. var venueAddress = CErrorsModel.Venues.getAddress({ venueId: pattributes.id });
  970. if (venueAddress === null) continue;
  971. if (venueAddress.street === null) continue;
  972. if (venueAddress.street.name || venueAddress.street.name !== null) {
  973. var venueStreetName = venueAddress.street.name;
  974. } else {
  975. var venueStreetName = "";
  976. }
  977. if (venueAddress.houseNumber || venueAddress.street.name !== null) {
  978. var venueHN = venueAddress.houseNumber;
  979. } else {
  980. var venueHN = "";
  981. }
  982. if (venueAddress.city === null) continue;
  983. if (venueAddress.city.name || venueAddress.city.name !== null) {
  984. var venueCity = venueAddress.city.name;
  985. } else {
  986. var venueCity = "";
  987. }
  988.  
  989. var newWidth = "", newColor = "", newOpacity = "0", gpoly = "";
  990. if ((ls.myLvl && pattributes.lockRank <= CErrorsUser.rank && pattributes.isAdLocked === false) || ls.myLvl == false) {
  991. if (ls.poi_Resid) { // maybe a residential POI
  992. if ((/^[0-9][ ]?[a-zA-Z]/.test(pname) === true || new RegExp(privNameSeg).test(pname) === true) && pattributes.isResidential === false && pattributes.categories.indexOf("PARKING_LOT") === -1) {
  993. newColor = "#ff7700"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  994. if (venue.geometry.type === "Point") { newWidth = 26; }
  995. j++;
  996. addIcon("\uf015", newColor, geometry, "venue", j);
  997. addLegend(pid, "\uf015", newColor, CErrPoi[7], "");
  998. }
  999. }
  1000. if (ls.poi_Google) { //POI without Google link
  1001. if (pattributes.externalProviderIds.length === 0 && pattributes.isResidential === false && new RegExp(excepCatPoi).test(categories) === false) {
  1002. newColor = "#ff7700"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1003. if (venue.geometry.type === "Point") { newWidth = 26; }
  1004. j++;
  1005. addIcon("\uf1a0", newColor, geometry, "venue", j);
  1006. addLegend(pid, "\uf1a0", newColor, CErrPoi[8], "");
  1007. }
  1008. }
  1009. if (ls.poi_Phone && pattributes.phone) { //POI with bad phone number
  1010. // Phone prefix
  1011. var prefPhone;
  1012. switch (CErrorsModel.Countries.getTopCountry().id) {
  1013. case 3: prefPhone = '+213[ ](\\d{2})'; break; // format +213 (dd) xx xx xx @ Algeria
  1014. case 73: prefPhone = '+33[ ]\\d[ ]\\d{2}'; break; // format +33 d xx xx xx xx @ France
  1015. case 74: prefPhone = '+594[ ](594|694)'; break; // format +594 594 xx xx xx @ French Guiana
  1016. case 88: prefPhone = '+590[ ](590|690)'; break; // format +590 590 xx xx xx @ Guadeloupe
  1017. case 141: prefPhone = '+596[ ]596'; break; // format +596 596 xx xx xx @ Martinique
  1018. case 148: prefPhone = '+377[ ]\\d{2}'; break; // format +377 xx xx xx xx @ Monaco
  1019. case 152: prefPhone = '+212[ ](\\d{3})'; break; // format +212 xxx xx xx xx @ Morocco
  1020. case 184: prefPhone = '+262[ ](262|692|693)'; break; // format +262 (262 ou 692) xx xx xx @ Reunion
  1021. default: break;
  1022. }
  1023. if (new RegExp('^(\\' + prefPhone + ')([ ](\\d{2})){3}$').test(pattributes.phone) === false // Prefix + 4 digits
  1024. && new RegExp('^(\\' + prefPhone + ')([ ](\\d{3})){2}$').test(pattributes.phone) === false // Prefix + 3 digits
  1025. && (/^[13]\d[ ](\d{2})$/).test(pattributes.phone) === false // 1x xx or 3x xx
  1026. && (/^(0[ ](8|9)\d{2})([ ](\d{3})){2}/).test(pattributes.phone) === false // 0 8xx xxx xxx
  1027. && (/^(0[ ](8|9)\d{2})([ ](\d{2})){3}/).test(pattributes.phone) === false // 0 8xx xx xx xx
  1028. && (/^(15|17|18|112|115)$/).test(pattributes.phone) === false // Emergency numbers
  1029. ) {
  1030. newColor = "#ff7700"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1031. if (venue.geometry.type === "Point") { newWidth = 26; }
  1032. j++;
  1033. addIcon("\uf095", newColor, geometry, "venue", j);
  1034. addLegend(pid, "\uf095", newColor, CErrPoi[13], "Lieux_Generalites#1.7._Format_du_num.C3.A9ro_de_t.C3.A9l.C3.A9phone");
  1035. if (ls.poi_AutoFixTel && pattributes.permissions != 0 && pattributes.approved == true) {
  1036. autoFixTel(venue);
  1037. }
  1038. }
  1039. }
  1040. if (ls.poi_Other) { // Place type is "Other"
  1041. if (categories.indexOf("OTHER") > -1 && (/^Déchèterie/).test(pname) === false) {
  1042. newColor = "#ff7700"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1043. if (venue.geometry.type === "Point") { newWidth = 26; }
  1044. j++;
  1045. addIcon("\uf29c", newColor, geometry, "venue", j);
  1046. addLegend(pid, "\uf29c", newColor, CErrPoi[10], "");
  1047. }
  1048. }
  1049. if (ls.poi_Entry) { // POI with default navigationPoints
  1050. if (new RegExp(entryPointPoi).test(categories) === false && pattributes.navigationPoints.length === 0 && venue.geometry.type === "Point" === false) {
  1051. newColor = "#ff7700"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1052. j++;
  1053. addIcon("\uf18e", newColor, geometry, "venue", j);
  1054. addLegend(pid, "\uf18e", newColor, CErrPoi[4], "Lieux_Generalites#1.3._Positionner_le_point_de_destination_d.27un_POI");
  1055. }
  1056. }
  1057. if (ls.poi_Park_name && categories.indexOf("PARKING_LOT") > -1) { // Parking with bad name
  1058. if (new RegExp(streetNameSeg).test(pname) === true) { continue; } //If parking name is a road
  1059. if (new RegExp('^' + parkNamePoi + '$').test(pname) === true || // Only Parkings or Aire // ?️|?️️|
  1060. new RegExp('^' + parkNamePoi).test(pname) === false // Don't start by ?️ or Parking
  1061. // /^(Parking[s]?)( de[s]?| du | le[s]? | la | pour )/.test(pname)===true // Contain bad words
  1062. ) {
  1063. newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1064. j++;
  1065. addIcon("\uf288", newColor, geometry, "venue", j);
  1066. addLegend(pid, "\uf288", newColor, CErrPoi[2], "Lieux_Particuliers#2.3._Parkings");
  1067. }
  1068. else if (pname === "") {
  1069. newColor = "#ff7700"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1070. j++;
  1071. addIcon("\uf288", newColor, geometry, "venue", j);
  1072. addLegend(pid, "\uf288", newColor, CErrPoi[2], "Lieux_Particuliers#2.3._Parkings");
  1073. }
  1074. if (venue.geometry.type === "Point") newWidth = 26;
  1075. }
  1076. if (ls.poi_Park_type && categories.indexOf("PARKING_LOT") > -1) { // Parking with type undefined
  1077. if (/PUBLIC|RESTRICTED|PRIVATE/.test(pattributes.categoryAttributes.PARKING_LOT.parkingType) === false) {
  1078. newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1079. j++;
  1080. addIcon("\uf11d", newColor, geometry, "venue", j);
  1081. addLegend(pid, "\uf11d", newColor, CErrPoi[12], "Lieux_Particuliers#2.3._Parkings");
  1082. }
  1083. }
  1084. if (ls.poi_Address) { // POI with bad address or incomplete
  1085. if (venueStreetName === null) continue;
  1086. if ((/^[A|D|N|M|R][0-9]+/.test(venueStreetName) && /[ - ]/.test(venueStreetName)) || ((!venueStreetName || !venueHN) && !new RegExp(PoiWithoutCompleteAdress).test(categories))) {
  1087. if (debug) {
  1088. //console.log("Nom : " + pname + " - Catégorie : " + categories);
  1089. }
  1090. newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1091. if (venue.geometry.type === "Point") { newWidth = 26; }
  1092. j++;
  1093.  
  1094. addIcon("\uf2bc", newColor, geometry, "venue", j);
  1095. addLegend(pid, "\uf2bc", newColor, CErrPoi[3], "Lieux_Generalites#1.2._Nommage_et_Adresse_d.27un_POI");
  1096. }
  1097. }
  1098. if (ls.poi_LandM) { // Landmark with road name or city name
  1099. if (new RegExp(landmarkPoi).test(categories) && pname === "" && ((venueStreetName && venueStreetName) || (venueCity && venueCity.name))) {
  1100. newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1101. if (venue.geometry.type === "Point") { newWidth = 26; }
  1102. j++;
  1103. addIcon("\uf1bb", newColor, geometry, "venue", j);
  1104. addLegend(pid, "\uf1bb", newColor, CErrPoi[5], "");
  1105. }
  1106. }
  1107. if (ls.poi_DleSpace) { // Double spacing in name
  1108. if (venueStreetName && (/ /.test(venueStreetName) === true || / /.test(pname) === true)) {
  1109. newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1110. j++;
  1111. addIcon("\uf101", newColor, geometry, "venue", j);
  1112. addLegend(pid, "\uf101", newColor, CErrPoi[6], "");
  1113. if (venue.geometry.type === "Point") { newWidth = 26; }
  1114. }
  1115. }
  1116. if (ls.poi_GasSta && categories.indexOf("GAS_STATION") > -1) { // Gas Station with bad name
  1117. if (new RegExp(streetNameSeg).test(pname) === true) { continue; } //If parking name is a road
  1118. if (/^(Station-service )/.test(pname) === false) { // Don't start by
  1119. newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1120. j++;
  1121. addIcon("\uf1b9", newColor, geometry, "venue", j);
  1122. addLegend(pid, "\uf288", newColor, CErrPoi[16], "Lieux_Particuliers#2.5._Stations-services");
  1123. if (venue.geometry.type === "Point") newWidth = 26;
  1124. }
  1125. }
  1126. if (ls.poi_Transp && new RegExp(stationsPoi).test(categories) === false && categories.indexOf("FAST_FOOD") == -1) { //Bus Subway and Tram Station wihtout others stations
  1127. if ((
  1128. categories.indexOf("BUS_STATION") > -1 && // Good category for bus station
  1129. new RegExp('^' + busPoi).test(pname) === false // Bad name
  1130. ) || (
  1131. categories.indexOf("SUBWAY_STATION") > -1 && // Good category for subway station
  1132. new RegExp('^' + tramPoi).test(pname) === false // Bad name
  1133. ) || (
  1134. categories.indexOf("TRAIN_STATION") > -1 && // Good category for train station
  1135. /Gare d[e|u|es|\']/.test(pname) === false // Bad name
  1136. ) || (
  1137. categories.indexOf("OTHER") == -1 && categories.indexOf("BUS_STATION") == -1 && categories.indexOf("SUBWAY_STATION") == -1 && categories.indexOf("TRAIN_STATION") == -1 &&
  1138. new RegExp('^' + possibleTransPoi).test(pname) === true // Maybe a transport station
  1139. )) {
  1140. newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1141. j++;
  1142. addIcon("\uf207", newColor, geometry, "venue", j);
  1143. addLegend(pid, "\uf207", newColor, CErrPoi[15], "Lieux_Particuliers#2.8._Arr.C3.AAts_de_bus.2C_m.C3.A9tro_et_tramway");
  1144. if (venue.geometry.type === "Point") { newWidth = 26; }
  1145. }
  1146. }
  1147. if (ls.poi_Relig && categories.indexOf("RELIGIOUS_CENTER") > -1) { // Religious Center with bad name
  1148. if (new RegExp('^' + religiousPoi).test(pname) === false) { // Bad 1st name
  1149. newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1150. j++;
  1151. addIcon("\uf015", newColor, geometry, "venue", j);
  1152. addLegend(pid, "\uf015", newColor, CErrPoi[14], "Lieux_Particuliers#2.10._Site_religieux");
  1153. if (venue.geometry.type === "Point") { newWidth = 26; }
  1154. }
  1155. }
  1156. if ((ls.poi_Relig && new RegExp('^' + religiousPoi).test(pname) === true && categories.indexOf("RELIGIOUS_CENTER") == -1) || // Religious Center Name but bad category
  1157. (new RegExp('^' + religiousPoi + '$').test(pname) === true && categories.indexOf("RELIGIOUS_CENTER") == -1)) { // Bad Religious Center Name with bad category
  1158. console.log("2- Checking Religious Center: " + pname);
  1159. newColor = "#ff0000"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1160. j++;
  1161. addIcon("\uf015", newColor, geometry, "venue", j);
  1162. addLegend(pid, "\uf015", newColor, CErrPoi[14], "Lieux_Particuliers#2.10._Site_religieux");
  1163. if (venue.geometry.type === "Point") { newWidth = 26; }
  1164. }
  1165. if (ls.poi_WFeed || ls.poi_WPark) { //Place updated by WazeFeed
  1166. if (pattributes.modificationData.updatedBy) {
  1167. var updName = pattributes.modificationData.updatedBy;
  1168. if (((ls.poi_WFeed && new RegExp(wazeBot).test(updName)) || (ls.poi_WPark && updName == "WazeParking1")) && pattributes.isResidential === false) {
  1169. newColor = "#ffcc00"; newWidth = 15; newOpacity = 0.5; poly = W.userscripts.toOLGeometry(geometry);
  1170. if (venue.geometry.type === "Point") { newWidth = 26; newOpacity = 0.75; }
  1171. j++;
  1172. addIcon("\uf263", newColor, geometry, "venue", j);
  1173. if (updName == "WazeFeed") { addLegend(pid, "\uf263", newColor, CErrPoi[9], ""); }
  1174. else { addLegend(pid, "\uf263", newColor, CErrPoi[11], ""); }
  1175. }
  1176. }
  1177. }
  1178. // Highlight if error
  1179.  
  1180. }
  1181. if (pattributes.adLocked) {
  1182. newColor = "#ff0000"; newWidth = 15; newOpacity = 0.75; poly = W.userscripts.toOLGeometry(geometry);
  1183. j++;
  1184. addIcon("\uf023", newColor, geometry, "venue", j);
  1185. addLegend(pid, "\uf023", newColor, CErrLeg[7], "");
  1186. if (venue.geometry.type === "Point") { newWidth = 26; }
  1187. }
  1188. if (gpoly !== "") {
  1189. var style = {
  1190. strokeWidth: newWidth,
  1191. strokeColor: newColor,
  1192. strokeOpacity: newOpacity,
  1193. fillOpacity: 0
  1194. };
  1195. var points = [];
  1196. for (var i = 0; i < gpoly.length; i++) { points.push(new CErrorsOpenLayers.Geometry.Point(gpoly[i].x, gpoly[i].y)); }
  1197. var newpoly = new CErrorsOpenLayers.Geometry.LinearRing(points);
  1198. lineFeature.push(new CErrorsOpenLayers.Feature.Vector(newpoly, null, style));
  1199. }
  1200. }
  1201. }
  1202.  
  1203. // Display highlighted features
  1204. try { ColorErrors_mapLayer.addFeatures(lineFeature); }
  1205. catch (err) { log('err addFeatures: ', err); }
  1206. }
  1207. }
  1208. // **********************
  1209. // ** Telephone fix **
  1210. // **********************
  1211. function formatTelCounty(venue) {
  1212. phoneTo = '';
  1213. // num 0800 et 0900
  1214. if (venue.phone.startsWith('08') == true) {
  1215. 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");
  1216. } else {
  1217. // rules by country
  1218. switch (CErrorsModel.Countries.getTopCountry().id) {
  1219. case 3: // Algeria
  1220. if (venue.phone.startsWith('+213') == true) {
  1221. 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");
  1222. } else {
  1223. 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");
  1224. }
  1225. break;
  1226. case 73: // France
  1227. if (venue.phone.startsWith('+338') == true || venue.phone.startsWith('00338') == true || venue.phone.startsWith('+33-8') == true || venue.phone.startsWith('+33 8') == true) {
  1228. if (venue.phone.startsWith('+33') == true) {
  1229. 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");
  1230. } else if (venue.phone.startsWith('0033') == true) {
  1231. 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");
  1232. }
  1233. } else if (venue.phone.startsWith('+33') == true) {
  1234. 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");
  1235. } else if (venue.phone.startsWith('0033') == true) {
  1236. 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");
  1237. } else if (venue.phone.startsWith('33') == true) {
  1238. 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");
  1239. } else {
  1240. 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");
  1241. }
  1242. break;
  1243. case 74: // French Guiana
  1244. if (venue.phone.startsWith('+594 5 94') == true || venue.phone.startsWith('+594594') == true) {
  1245. 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");
  1246. } else {
  1247. 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");
  1248. }
  1249. break;
  1250. case 88: // Guadeloupe
  1251. if (venue.phone.startsWith('+590 5 90') == true || venue.phone.startsWith('+590590') == true) {
  1252. 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");
  1253. } else {
  1254. 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");
  1255. }
  1256. break;
  1257. case 141: // Martinique
  1258. if (venue.phone.startsWith('+596 5 96') == true || venue.phone.startsWith('+596596') == true) {
  1259. 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");
  1260. } else {
  1261. 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");
  1262. }
  1263. break;
  1264. case 148: // Monaco
  1265. if (venue.phone.startsWith('+377') == true) {
  1266. 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");
  1267. } else {
  1268. 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");
  1269. }
  1270. break;
  1271. case 152: // Morocco
  1272. if (venue.phone.startsWith('+212') == true) {
  1273. 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");
  1274. } else {
  1275. 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");
  1276. }
  1277. break;
  1278. case 184: // Reunion
  1279. if (venue.phone.startsWith('+262 2 62') == true || venue.phone.startsWith('+262262') == true) {
  1280. 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");
  1281. } else {
  1282. 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");
  1283. }
  1284. break;
  1285. default: break;
  1286. }
  1287. }
  1288. return phoneTo;
  1289. }
  1290.  
  1291. function autoFixTel(venue) {
  1292. phoneTo = ''
  1293. phoneTo = formatTelCounty(venue);
  1294. if (phoneTo != '' && Object.keys(venue.venueUpdateRequests).length == 0) {
  1295. CErrorsModel.Venues.updateVenue({ venueId: venue.id, phone: phoneTo });
  1296. }
  1297. }
  1298. function fixTel() {
  1299. var editpanel = $('#edit-panel');
  1300. if (editpanel.length == 0) { window.setTimeout(fixTel, 1000); return; }
  1301.  
  1302. const observer = new MutationObserver(mutations => {
  1303. mutations.forEach(mutation => {
  1304. for (let i = 0; i < mutation.addedNodes.length; i++) {
  1305. const addedNode = mutation.addedNodes[i];
  1306. if (addedNode &&
  1307. W.selectionManager &&
  1308. W.selectionManager.getSelectedDataModelObjects &&
  1309. W.selectionManager.getSelectedDataModelObjects()[0].type == "venue") {
  1310. var editLM = $('#venue-edit-more-info');
  1311. if (editLM.length == 1) {
  1312. var fixPhoneBtn = $('#wme-telephonefix-fr');
  1313. if (fixPhoneBtn.length == 0) {
  1314. fixPhoneBtn = document.createElement('button');
  1315. fixPhoneBtn.innerHTML = 'fix';
  1316. fixPhoneBtn.id = 'wme-telephonefix-fr';
  1317. $(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' });
  1318. $('[name=phone]').parent().append(fixPhoneBtn);
  1319.  
  1320. try {
  1321. var venue = W.selectionManager.getSelectedDataModelObjects()[0];
  1322. var phone = venue.phone;
  1323. var newPhone = '';
  1324. var phoneTo = '';
  1325. phoneTo = formatTelCounty(venue);
  1326.  
  1327. if (phoneTo != venue.phone) { newPhone = phoneTo; }
  1328.  
  1329. if (newPhone != '') {
  1330. fixPhoneBtn.addEventListener("click", function (v, p) {
  1331. return function () {
  1332. var newAtts = { phone: p, id: v.id };
  1333. W.model.actionManager.add(new (require("Waze/Action/UpdateObject"))(v, newAtts));
  1334. $(fixPhoneBtn).css({ 'display': 'none' });
  1335. }
  1336. }(venue, newPhone), false);
  1337. }
  1338. else
  1339. $(fixPhoneBtn).css({ 'display': 'none' });
  1340. }
  1341. catch (err) {
  1342. $(fixPhoneBtn).css({ 'display': 'none' });
  1343. }
  1344. }
  1345. }
  1346. }
  1347. }
  1348. });
  1349. });
  1350. observer.observe(document.getElementById('edit-panel'), { childList: true, subtree: true });
  1351.  
  1352. }