WME Color Errors

Colorisation pour afficher les erreurs

目前為 2024-12-15 提交的版本,檢視 最新版本

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址