Greasy Fork is available in English.

WME LevelReset

Script version of the WME LevelReset tool, to make relocking segments to their appropriate lock level easy & quick.

Цей скрипт не слід встановлювати безпосередньо. Це - бібліотека для інших скриптів для включення в мета директиву // @require https://update.greasyfork.org/scripts/14414/134648/WME%20LevelReset.js

  1. // ==UserScript==
  2. // @name WME LevelReset
  3. // @namespace broosgert@gmail.com
  4. // @version 0.2.1
  5. // @description Script version of the WME LevelReset tool, to make relocking segments to their appropriate lock level easy & quick.
  6. // @author Broos Gert '2015
  7. // @match https://editor-beta.waze.com/*editor/*
  8. // @match https://www.waze.com/*editor/*
  9. // @grant none
  10. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAA+VBMVEX///93PgHX19fTgQfFZgLLcwTrxYDDgA3nqBj5+fmwr6+Yl5f8/PzExMTl5eX114vv7+/e3t68vLzOzs6saRKARQSLTgeioqK2tbX72XfU1NT515fxz4b54b3RmySYWAv31aTpwIHgrn9/f3/75qPZsEvuuC/utx3psVP13KizbhXuuVj745bfoEzzwzDxwDXTjknpxqDPfhzWih7PhUaObErowqDJchrmqCfprRjbmUvblCLZjAv71WnhnyTfmA7hrmbjsm7qxpPv06vYljj305776MvLkD3XkjFwcHCMi4v6zk/6z1P2wVDYqzr3y3j2xWnrrl761X3u0VhGAAABv0lEQVQ4jZWTXXuaMBiGY7bZQUhIoBaKsIK0KkVqtd+2tJ2gnVJs9f//mAW78uHYwe6TXE+em/flJAD8D0RVdF3HTKqvGcaMAiAQVYd1vaEASikhhFKA1ZoeA8Iwct2lCAnAxl/zdcAMbeGipbtwMQM62xFEFUJtoWEIsbh0CVTF3QGqqrjax2cq4kkkFQFjTJD2eYeXBoa4uoEoBOU/RhBUWHWHJukUCZ9JQFCnWkVAQJRQniREyvGPANA/YzazRhBKwjSOg+DZmdoRZ+r8XAfxr5eo1AfzuW1HljXfYkX2zJ5b8TQXXtbWzPff38x2hvn27qf+zFrHubC39tppGoabjczZHIZpmra9/jgXTn2vnSTJaxgecsLwNRkmsueflgV5eLZarU4y+Lk6G9YIg8HxB4PBYEfY3woZQ0529rjQ3y+Evid3ez9K9LpmWTjqe2b3Ti5xlwlHhRDYzdvvFW5NOyiEAy48Pu2VeHps2sFBIUwi5/6hWeLh3okmhdCajJyLLxUunNGktS0lgdLW+agz/lZh3Bmdt6ggZS/NUBqX152brxVuOteXDZVRafsUrxq1XGHIBb6CwHoY4Tt+A1eiQ8S/AAv7AAAAAElFTkSuQmCC
  11. // ==/UserScript==
  12.  
  13. // initialize LevelReset and do some checks
  14. function LevelReset_bootstrap() {
  15. LevelReset_init();
  16. }
  17.  
  18. function LevelReset_init() {
  19. // Check initialisation
  20. if (typeof Waze == 'undefined' || typeof I18n == 'undefined') {
  21. setTimeout(LevelReset_init, 660);
  22. console.log('LevelReset: Waze object unavailable, map still loading');
  23. return;
  24. }
  25.  
  26. function onScreen(obj) {
  27. if (obj.geometry) {
  28. return(Waze.map.getExtent().intersectsBounds(obj.geometry.getBounds()));
  29. }
  30. return(false);
  31. }
  32.  
  33. // Country database --------------------------------------------------------------------------------------------------------------
  34. var cntryDB = {
  35. BE: { str_lvl:0, pri_lvl:1,min_lvl:2, maj_lvl:3, rmp_lvl:4, fwy_lvl:4}, //--------------------------------- Belgium
  36. NL: { str_lvl:0, pri_lvl:1,min_lvl:2, maj_lvl:3, rmp_lvl:4, fwy_lvl:4}, //--------------------------------- Netherlands
  37. LU: { str_lvl:0, pri_lvl:1,min_lvl:2, maj_lvl:3, rmp_lvl:4, fwy_lvl:4}, //--------------------------------- Luxemburg
  38. PL: { str_lvl:0, pri_lvl:1,min_lvl:2, maj_lvl:3, rmp_lvl:3, fwy_lvl:3}, //--------------------------------- Poland
  39. TU: { str_lvl:0, pri_lvl:1,min_lvl:2, maj_lvl:3, rmp_lvl:4, fwy_lvl:4} //--------------------------------- Turkey
  40. };
  41. // Country database --------------------------------------------------------------------------------------------------------------
  42.  
  43.  
  44. // Setting up all variables
  45. var UpdateObject = require("Waze/Action/UpdateObject"),
  46. VERSION = '0.2.0',
  47. loader = 'data:image/gif;base64,R0lGODlhEAAQAPQAAP///wAAAPj4+Dg4OISEhAYGBiYmJtbW1qioqBYWFnZ2dmZmZuTk5JiYmMbGxkhISFZWVgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH+GkNyZWF0ZWQgd2l0aCBhamF4bG9hZC5pbmZvACH5BAAKAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAEAAQAAAFUCAgjmRpnqUwFGwhKoRgqq2YFMaRGjWA8AbZiIBbjQQ8AmmFUJEQhQGJhaKOrCksgEla+KIkYvC6SJKQOISoNSYdeIk1ayA8ExTyeR3F749CACH5BAAKAAEALAAAAAAQABAAAAVoICCKR9KMaCoaxeCoqEAkRX3AwMHWxQIIjJSAZWgUEgzBwCBAEQpMwIDwY1FHgwJCtOW2UDWYIDyqNVVkUbYr6CK+o2eUMKgWrqKhj0FrEM8jQQALPFA3MAc8CQSAMA5ZBjgqDQmHIyEAIfkEAAoAAgAsAAAAABAAEAAABWAgII4j85Ao2hRIKgrEUBQJLaSHMe8zgQo6Q8sxS7RIhILhBkgumCTZsXkACBC+0cwF2GoLLoFXREDcDlkAojBICRaFLDCOQtQKjmsQSubtDFU/NXcDBHwkaw1cKQ8MiyEAIfkEAAoAAwAsAAAAABAAEAAABVIgII5kaZ6AIJQCMRTFQKiDQx4GrBfGa4uCnAEhQuRgPwCBtwK+kCNFgjh6QlFYgGO7baJ2CxIioSDpwqNggWCGDVVGphly3BkOpXDrKfNm/4AhACH5BAAKAAQALAAAAAAQABAAAAVgICCOZGmeqEAMRTEQwskYbV0Yx7kYSIzQhtgoBxCKBDQCIOcoLBimRiFhSABYU5gIgW01pLUBYkRItAYAqrlhYiwKjiWAcDMWY8QjsCf4DewiBzQ2N1AmKlgvgCiMjSQhACH5BAAKAAUALAAAAAAQABAAAAVfICCOZGmeqEgUxUAIpkA0AMKyxkEiSZEIsJqhYAg+boUFSTAkiBiNHks3sg1ILAfBiS10gyqCg0UaFBCkwy3RYKiIYMAC+RAxiQgYsJdAjw5DN2gILzEEZgVcKYuMJiEAOwAAAAAAAAAAAA==',
  48. strt = '',
  49. fwy_lvl = 4,
  50. rmp_lvl = 4,
  51. maj_lvl = 3,
  52. min_lvl = 2,
  53. pri_lvl = 1,
  54. str_lvl = 0,
  55. absolute = false,
  56. fwy_cnt = 0,
  57. rmp_cnt = 0,
  58. maj_cnt = 0,
  59. min_cnt = 0,
  60. pri_cnt = 0,
  61. str_cnt = 0,
  62. relockObject = null,
  63. userlevel = Waze.loginManager.user.normalizedLevel,
  64. //userlevel = 6, // for testing purposes (NOTE: this does not enable you to lock higher!)
  65. relockTab = document.createElement('li'),
  66. userInfo = document.getElementById('user-info'),
  67. navTabs = userInfo.querySelector('.nav-tabs'),
  68. tabContent = userInfo.querySelector('.tab-content'),
  69. relockContent = document.createElement('div'),
  70. relockTitle = document.createElement('h3'),
  71. relockSubTitle = document.createElement('h4'),
  72. relockAllbutton = document.createElement('input'),
  73. relockSub = document.createElement('p'),
  74. versionTitle = document.createElement('p'),
  75. resultsCntr = document.createElement('div'),
  76. alertCntr = document.createElement('div'),
  77. hidebutton = document.createElement('div'),
  78. dotscntr = document.createElement('div'),
  79. includeAllSegments = document.createElement('input'),
  80. includeAllSegmentsLabel = document.createElement('label'),
  81. percentageLoader = document.createElement('div'),
  82. readable = {'str':'Streets (#)', 'pri':'Primary Streets (#)','min':'Minor Highways (#)', 'maj':'Major Highways (#)', 'rmp':'Ramps (#)', 'fwy':'Freeways (#)'};
  83.  
  84. // Begin building
  85. relockContent.id = 'sidepanel-relockTab';
  86. relockContent.className = 'tab-pane';
  87. relockTitle.appendChild(document.createTextNode('Relock segments'));
  88. relockTitle.style.cssText = 'margin-bottom:0';
  89. relockTab.innerHTML = '<a href="#sidepanel-relockTab" data-toggle="tab" title="Relock segments">Re - <span class="fa fa-lock" id="lockcolor" style="color:green"></span></a>';
  90.  
  91. // fill tab
  92. relockSub.innerHTML = 'Your on-screen area is automatically scanned when you load or pan around. Pressing the lock behind each type will relock only those results, or you can choose to relock all.<br/><br/>You can only relock segments lower or equal to your current editor level. Segments locked higher than normal are left alone.';
  93. relockSub.style.cssText = 'font-size:85%;padding:15px;border:1px solid red;border-radius:5px;position:relative';
  94. relockSub.id = 'sub';
  95. hidebutton.style.cssText ='cursor:pointer;width:16px;height:16px;position:absolute;right:3px;top:3px;background-image:url(\'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAAAAWdEVYdENyZWF0aW9uIFRpbWUAMTEvMjAvMTVnsXrkAAADTUlEQVQ4jW2TW0xbZQCAv3ODnpYWegEGo1wKwzBcxAs6dONSjGMm3kjmnBqjYqLREE2WLDFTIBmbmmxRpzHy4NPi4zRLfNBlZjjtnCEaOwYDJUDcVqC3UzpWTkt7fp80hvk9f/nePkkIwWb+gA5jMXLQjK50Zc2cuKVp4wlX2UevtAYubnal/waWoTI1N38keu7ck2uTl335ZFJCkpE8XlGob4ibgeZvMl7P8MtdO6/dFohDe/Sn0LdzJ457MuHfUYqLkYtsSIqMJASyIiNv30Gm6+G1zNbqvpf6gqF/AwaUXx+/MDdz6KArH4ujVVRAbgPVroMsQz6P6nJiGUnUGj/pR/tTyx2dtW+11t2UAa5Pz34w//GHLitpsG1wkODp0xQ11GOZJpgmzq5uqo8ew76zAxFPUDJxscwzFR4BkGfh/tj58/3Zq9OoFZU0PHsAd00NnWNj6IEApd3duA48g2nXKenpQSl1oceWsUeuPfdp+M9GZf/zA5+lz3x9lxRbAUli+dIlKnt7Ud1uCk1NJH0+VnMmq6EQfw0NUzCSULBQfT4HVf4iNRO50VlIGSi6jup0sj5zlTO7d9N48iRLa2vkCwWsyTArbx/GAaSBm/MLyLm85OjZs0c2zawQsoRmt5NeXCRyeRLh9rBkGBSEwF6i09h+L96GemyAx2bDK4ENkGRJkbM2fVy4PRhT08RmZvH09VE29C6ixEFuahL3hklLby9PhEKUt7VRZln4kHD669Bqtl6Q7W07jqWL9FQiEkHTdUoGBsgXF5EPh0m8M8Tc62/CSoLSqmqaR4ZxaRpenxfbgw8lCy2Nx5Uv3xuNXEll7shO/HI38Rjr09NImkriyCgOy0JZTZM4+x3C7SY+epTaLZWsdwXJPNV/6jF/9ReSEIKzmcKWpbHPF9OHDxUr6xksoAiQJAmnpuEWAqeq4G9uRr7nPpZeeDG10NqybV+5Ly4DPGJXlsv79u51v38iK22/EwmwACEEIpdD2tjApmncan8A49XX4qtNgeC+cl/8tpm+jxoBY+K3N7I/jj+dvxKuIhZV7KpKWV295dy1K6YEg1/NO2wj+/210f+98R9+hub0wo1BOZnslRVV16orf0hVeD55HH7d7P4N0V1gY9/zcaEAAAAASUVORK5CYII=\');';
  96. hidebutton.onclick = function() {
  97. localStorage.msgHide = 1;
  98. $('#sub').hide('slow');
  99. };
  100. dotscntr.style.cssText = 'width:16px;height:16px;margin-left:5px;background:url("'+ loader + '");vertical-align:text-top;display:none';
  101. dotscntr.id = 'dotscntr';
  102. relockSubTitle.innerHTML = 'Results';
  103. versionTitle.innerHTML = 'Version ' + VERSION;
  104. versionTitle.style.cssText = 'margin:2px;font-size:85%;font-weight:bold';
  105. relockAllbutton.type = 'button';
  106. relockAllbutton.value = 'Relock All';
  107. relockAllbutton.style.cssText = 'margin: 10px 3px 0 0';
  108. relockAllbutton.onclick = function() {
  109. relockAll();
  110. };
  111.  
  112. // Also reset higher locked segments?
  113. includeAllSegments.type = 'checkbox';
  114. includeAllSegments.name = "name";
  115. includeAllSegments.value = "value";
  116. includeAllSegments.id = "_allSegments";
  117. includeAllSegments.onclick = function() {
  118. scanArea();
  119. relockShowAlert();
  120. };
  121. includeAllSegmentsLabel.htmlFor = "_allSegments";
  122. includeAllSegmentsLabel.innerHTML = 'Also reset higher locked segments';
  123. includeAllSegmentsLabel.style.cssText = 'font-size:95%;margin-left:5px;vertical-align:middle';
  124.  
  125. // Alert box
  126. alertCntr.id = "alertCntr";
  127. alertCntr.style.cssText = 'border:1px solid #EBCCD1;background-color:#F2DEDE;color:#AC4947;font-weight:bold;font-size:90%;border-radius:5px;padding:10px;margin:5px 0;display:none';
  128. alertCntr.innerHTML = 'Watch out for map exceptions, some higher locks are there for a reason!';
  129.  
  130. // add to stage
  131. navTabs.appendChild(relockTab);
  132. tabContent.appendChild(relockContent);
  133. relockContent.appendChild(relockTitle);
  134. relockContent.appendChild(versionTitle);
  135.  
  136. // Loader bar
  137. percentageLoader.id = 'percentageLoader';
  138. percentageLoader.style.cssText = 'width:1px;height:10px;background-color:green;margin-top:10px;border:1px solid:#333333;display:none';
  139.  
  140. // only show if user didn't hide it before
  141. if (localStorage.msgHide != 1) {
  142. relockSub.appendChild(hidebutton);
  143. relockContent.appendChild(relockSub);
  144. }
  145. relockContent.appendChild(includeAllSegments);
  146. relockContent.appendChild(includeAllSegmentsLabel);
  147. relockContent.appendChild(alertCntr);
  148. relockContent.appendChild(relockSubTitle);
  149. relockContent.appendChild(resultsCntr);
  150. relockContent.appendChild(relockAllbutton);
  151. relockContent.appendChild(dotscntr);
  152. relockContent.appendChild(percentageLoader);
  153.  
  154. // Some functions
  155. function relock(obj, key) {
  156. var objects = obj[key];
  157. var _i = 0;
  158.  
  159. // update GUI
  160. function RunLocal() {
  161. Waze.model.actionManager.add(objects[_i]);
  162. _i++;
  163.  
  164. if (_i < objects.length) {
  165. setTimeout(RunLocal, 1);
  166. var newWidth = (_i / objects.length) * $('#sidepanel-relockTab').css('width').replace('px', '');
  167. $('#percentageLoader').show();
  168. $('#percentageLoader').css('width', newWidth + 'px');
  169. $('#dotscntr').css('display', 'inline-block');
  170. } else {
  171. $('#dotscntr').css('display', 'none');
  172. $('#percentageLoader').hide();
  173. }
  174. }
  175. RunLocal();
  176. }
  177.  
  178. function relockAll() {
  179. // only lock "all" until the current editors level is reached, then stop...
  180. $('#dotscntr').css('display', 'inline-block');
  181.  
  182. $.each(relockObject, function( key, value ) {
  183. if (value.length !== 0) {
  184. // loop trough each segmentType
  185. var _i = 0;
  186. var RunLocal5 = function() {
  187. Waze.model.actionManager.add(value[_i]);
  188. _i++;
  189.  
  190. // Did not iterate with $.each, so the GUI can update with larger arrays
  191. if (_i < value.length) {
  192. setTimeout(RunLocal5, 1);
  193. var newWidth = (_i / value.length) * $('#sidepanel-relockTab').css('width').replace('px', '');
  194. $('#percentageLoader').show();
  195. $('#percentageLoader').css('width', newWidth + 'px');
  196. $('#dotscntr').css('display', 'inline-block');
  197. } else {
  198. $('#dotscntr').css('display', 'none');
  199. $('#percentageLoader').hide();
  200. }
  201. };
  202. RunLocal5();
  203. }
  204. });
  205. scanArea();
  206. $('#dotscntr').hide('slow');
  207. }
  208.  
  209. function relockShowAlert() {
  210. if (includeAllSegments.checked)
  211. $('#alertCntr').show("fast");
  212. else
  213. $('#alertCntr').hide("fast");
  214. }
  215.  
  216. function scanArea() {
  217. // Object with array of roadtypes, to collect each wrongly locked segment, for later use
  218. relockObject = {'str':[], 'pri':[], 'min':[], 'maj':[], 'rmp':[], 'fwy':[]};
  219. var foundBadlocks = false;
  220. var count = 0;
  221.  
  222. // Choose country lock settings. If country selection fails
  223. // or country isn't in this list, WME default values are used.
  224. try {
  225. var ABBR = cntryDB[Waze.model.countries.top.abbr];
  226. fwy_lvl = ABBR.fwy_lvl;
  227. rmp_lvl = ABBR.rmp_lvl;
  228. maj_lvl = ABBR.maj_lvl;
  229. min_lvl = ABBR.min_lvl;
  230. pri_lvl = ABBR.pri_lvl;
  231. str_lvl = ABBR.str_lvl;
  232. console.log("LevelReset: ", ABBR);
  233. } catch(err) {
  234. console.log("LevelReset ERROR: ", err);
  235. }
  236.  
  237. // Do a count on how many segments are in need of a correct lock (limit to 150 to save CPU)
  238. // Count also depends on the users editor level
  239. $.each(Waze.model.segments.objects, function( k, v ) {
  240. if (count < 150 && v.type == "segment" && onScreen(v) && v.isGeometryEditable()) {
  241. strt = Waze.model.streets.get(v.attributes.primaryStreetID);
  242.  
  243. // Street (L1)
  244. if (v.attributes.roadType == 1) {
  245. if (v.attributes.lockRank > str_lvl && includeAllSegments.checked) {
  246. relockObject.str.push(new UpdateObject(v, {lockRank: str_lvl}));
  247. foundBadlocks = true;
  248. count++;
  249. }
  250. }
  251. // Primary (L2)
  252. if (v.attributes.roadType == 2 && (userlevel >= (pri_lvl+1)) ) {
  253. if (v.attributes.lockRank < pri_lvl) {
  254. relockObject.pri.push(new UpdateObject(v, {lockRank: pri_lvl}));
  255. foundBadlocks = true;
  256. count++;
  257. }
  258. if (v.attributes.lockRank > pri_lvl && includeAllSegments.checked) {
  259. relockObject.pri.push(new UpdateObject(v, {lockRank: pri_lvl}));
  260. foundBadlocks = true;
  261. count++;
  262. }
  263. }
  264. // Minor Highway (L3)
  265. if (v.attributes.roadType == 7 && (userlevel >= (min_lvl+1)) ) {
  266. if (v.attributes.lockRank < min_lvl) {
  267. relockObject.min.push(new UpdateObject(v, {lockRank: min_lvl}));
  268. foundBadlocks = true;
  269. count++;
  270. }
  271. if (v.attributes.lockRank > min_lvl && includeAllSegments.checked) {
  272. relockObject.min.push(new UpdateObject(v, {lockRank: min_lvl}));
  273. foundBadlocks = true;
  274. count++;
  275. }
  276. }
  277. // Major Highway (L4)
  278. if (v.attributes.roadType == 6 && (userlevel >= (maj_lvl+1)) ) {
  279. if (v.attributes.lockRank < maj_lvl) {
  280. relockObject.maj.push(new UpdateObject(v, {lockRank: maj_lvl}));
  281. foundBadlocks = true;
  282. count++;
  283. }
  284. if (v.attributes.lockRank > maj_lvl && includeAllSegments.checked) {
  285. relockObject.maj.push(new UpdateObject(v, {lockRank: maj_lvl}));
  286. foundBadlocks = true;
  287. count++;
  288. }
  289. }
  290. // Ramps (L5)
  291. if (v.attributes.roadType == 4 && (userlevel >= (rmp_lvl+1)) ) {
  292. if (v.attributes.lockRank < rmp_lvl) {
  293. relockObject.rmp.push(new UpdateObject(v, {lockRank: rmp_lvl}));
  294. foundBadlocks = true;
  295. count++;
  296. }
  297. if (v.attributes.lockRank > rmp_lvl && includeAllSegments.checked) {
  298. relockObject.rmp.push(new UpdateObject(v, {lockRank: rmp_lvl}));
  299. foundBadlocks = true;
  300. count++;
  301. }
  302. }
  303. // Freeways (L5)
  304. if (v.attributes.roadType == 3 && (userlevel >= (fwy_lvl+1)) ) {
  305. if (v.attributes.lockRank < fwy_lvl) {
  306. relockObject.fwy.push(new UpdateObject(v, {lockRank: fwy_lvl}));
  307. foundBadlocks = true;
  308. count++;
  309. }
  310. if (v.attributes.lockRank > fwy_lvl && includeAllSegments.checked) {
  311. relockObject.fwy.push(new UpdateObject(v, {lockRank: fwy_lvl}));
  312. foundBadlocks = true;
  313. count++;
  314. }
  315. }
  316. }
  317. });
  318.  
  319. // Build result to users tabpanel
  320. resultsCntr.innerHTML = '';
  321. var lvlCnt;
  322. if (includeAllSegments.checked)
  323. lvlCnt = 1;
  324. else
  325. lvlCnt = 2;
  326.  
  327. $.each(relockObject, function( key, value ) {
  328. // Only show streets (L1) if needed -> checkbox checked. L1 streets cannot be locked too low, only too high :)
  329. if (key == 'str' && !includeAllSegments.checked) {
  330. return;
  331. }
  332.  
  333. var __cntr = document.createElement('div'),
  334. __keyLeft = document.createElement('div'),
  335. __lckRight = document.createElement('div'),
  336. __cntRight = document.createElement('div'),
  337. __cleardiv = document.createElement("div");
  338.  
  339. // Begin building
  340. __keyLeft.style.cssText = 'float:left';
  341. __keyLeft.innerHTML = readable[key].replace('#', 'Lock ' + (eval(key+'_lvl')+1)); // No eval is not evil :)
  342. __lckRight.className = ((value.length !==0) ? 'fa fa-lock' : '');
  343. __cntRight.style.cssText = 'float:right';
  344. __cntRight.innerHTML = ((value.length !==0) ? '<b>'+value.length+'</b>' : '-');
  345. __cleardiv.style.cssText ='clear:both;';
  346.  
  347. // only add relock function if the editor's level allows it...
  348. if (userlevel < 5) {
  349. if (userlevel >= lvlCnt) {
  350. __lckRight.style.cssText = 'width:15px;float:right;padding:3px 0 0 8px;cursor:pointer;' + ((value.length!== 0) ? 'color:red' : '' );
  351. __lckRight.onclick = function() {
  352. relock(relockObject, key);
  353. };
  354. } else {
  355. // Grey out options to make it more visible
  356. __lckRight.className = '';
  357. __keyLeft.style.cssText = 'float:left;color:#777';
  358. __cntRight.style.cssText = 'float:right;color:#777';
  359. __lckRight.style.cssText = 'float:right;padding:3px 0 0 8px;color:#777;width:15px';
  360. }
  361. }
  362. else
  363. {
  364. // User is an L5/L6 so he can edit all road types (exceptions possible)
  365. __lckRight.style.cssText = 'width:15px;float:right;padding:3px 0 0 8px;cursor:pointer;' + ((value.length!== 0) ? 'color:red' : '' );
  366. __lckRight.onclick = function() {
  367. relock(relockObject, key);
  368. };
  369. }
  370.  
  371. // Add to stage
  372. __cntr.appendChild(__keyLeft);
  373. __cntr.appendChild(__lckRight);
  374. __cntr.appendChild(__cntRight);
  375. __cntr.appendChild(__cleardiv);
  376. resultsCntr.appendChild(__cntr);
  377. lvlCnt++;
  378. });
  379.  
  380. // Color the small lock icon red, if errors are found, so people can decide what to do...
  381. if (foundBadlocks) {
  382. relockAllbutton.removeAttribute('disabled');
  383. $('#lockcolor').css('color', 'red');
  384. } else {
  385. relockAllbutton.setAttribute('disabled', true);
  386. $('#lockcolor').css('color', 'green');
  387. }
  388. }
  389.  
  390. // Do a default scan once at startup
  391. scanArea();
  392.  
  393. // Register some eventlisteners
  394. Waze.map.events.register("moveend", null, scanArea);
  395. Waze.model.actionManager.events.register("afteraction", null, scanArea);
  396. Waze.model.actionManager.events.register("afterundoaction", null, scanArea);
  397. Waze.model.actionManager.events.register("noActions", null, scanArea);
  398. }
  399. setTimeout(LevelReset_bootstrap, 2000);