WME Color Errors

Colorisation pour afficher les erreurs

目前为 2025-05-11 提交的版本。查看 最新版本

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