WME Fix UI

Allows alterations to the WME UI to fix things screwed up or ignored by Waze

当前为 2017-11-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name WME Fix UI
  3. // @namespace https://greasyfork.org/en/users/46070
  4. // @description Allows alterations to the WME UI to fix things screwed up or ignored by Waze
  5. // @include https://www.waze.com/editor*
  6. // @include https://www.waze.com/*/editor*
  7. // @include https://beta.waze.com/editor*
  8. // @include https://beta.waze.com/*/editor*
  9. // @exclude https://www.waze.com/*user/editor/*
  10. // @supportURL https://www.waze.com/forum/viewtopic.php?f=819&t=191178
  11. // @version 2.2
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. // Thanks to (in no particular order)
  16. // Bellhouse, Twister-UK, Timbones, Dave2084, Rickzabel, Glodenox,
  17. // JJohnston84, SAR85, Cardyin
  18.  
  19. (function()
  20. {
  21. // global variables
  22. var wmefu_version = "2.2";
  23. var oldVersion;
  24. var prefix = "WMEFU";
  25. var tabAttempts = 0;
  26. var wmeFUAddon;
  27. var debug = false;
  28. var wmeFUinitialising = true;
  29. var URLSegments;
  30. var URLSegmentCount;
  31. var UIver;
  32. //Fix for date/time formats in WME released Oct/Nov 2016 - provided by Glodenox
  33. I18n.translations[I18n.currentLocale()].time = {};
  34. I18n.translations[I18n.currentLocale()].time.formats = {};
  35. I18n.translations[I18n.currentLocale()].time.formats.long = "%a %b %d %Y, %H:%M";
  36. I18n.translations[I18n.currentLocale()].date.formats = {};
  37. I18n.translations[I18n.currentLocale()].date.formats.long = "%a %b %d %Y, %H:%M";
  38. I18n.translations[I18n.currentLocale()].date.formats.default = "%a %b %d %Y";
  39. if (I18n.currentLocale() == 'en-GB') {
  40. I18n.translations['en-GB'].update_requests.panel.reported = 'Reported on: %{date}';
  41. }
  42. // Set the "Chat is here!" message to be hidden
  43. if (localStorage.hiddenMessages) {
  44. var hm = JSON.parse(localStorage.hiddenMessages);
  45. if (hm.chat_intro_tip === false) {
  46. logit("Hiding Chat is Here! message","info");
  47. hm.chat_intro_tip = true;
  48. localStorage.setItem('hiddenMessages', JSON.stringify(hm));
  49. }
  50. }
  51.  
  52. function init1() {
  53. console.group(prefix + ": initialising...");
  54. console.time(prefix + ": initialisation time");
  55. logit("Starting init1","debug");
  56. // go round again if map container isn't there yet
  57. if(!window.Waze.map) {
  58. logit("waiting for WME...","warning");
  59. setTimeout(init1, 200);
  60. return;
  61. }
  62. // identify WME version by checking for an item that no longer appears in the new version
  63. UIver = ((document.getElementById("input-overlay") === null) ? "new" : "old");
  64. // create tab content and store it
  65. wmeFUAddon = createAddon();
  66. // insert the content as a tab
  67. addMyTab(null,0);
  68. //pass control to init2
  69. init2();
  70. }
  71.  
  72. function init2() {
  73. logit("Starting init2","debug");
  74. //go round again if my tab isn't there yet
  75. if (!getId('sidepanel-FixUI')) {
  76. logit("Waiting for my tab to appear...","warning");
  77. setTimeout(init2, 200);
  78. return;
  79. }
  80. //test for 2017 UI
  81. logit("UI version is " + UIver, "info");
  82. // setup event handlers for my controls:
  83. getId('_cbMoveZoomBar').onclick = moveZoomBar;
  84. getId('_cbShrinkTopBars').onclick = WshrinkTopBars;
  85. getId('_cbHideUserInfo').onclick = hideUserInfo;
  86. getId('_cbCompressSegmentTab').onclick = compressSegmentTab;
  87. getId('_cbRestyleReports').onclick = WrestyleReports;
  88. getId('_cbNarrowSidePanel').onclick = WnarrowSidePanel;
  89. getId('_cbHideAveSpeedControls').onclick = hideAveSpeedControls;
  90. getId('_cbAddZoomIndicator').onclick = WaddZoomIndicator;
  91. getId('_cbFixExternalProviders').onclick = fixExternalProviders;
  92. //x getId('_cbClickablePlaceAddress').onclick = hideAveSpeedControls;
  93. getId('_cbCompressLayersMenu').onclick = compressLayersMenu;
  94. getId('_cbMoveChatIcon').onclick = moveChatIcon;
  95. getId('_cbDarkenSaveLayer').onclick = darkenSaveLayer;
  96. getId("_inpASX").onchange = shiftAerials;
  97. getId("_inpASX").onwheel = shiftAerials;
  98. getId("_inpASY").onchange = shiftAerials;
  99. getId("_inpASY").onwheel = shiftAerials;
  100. getId("_inpASO").onchange = shiftAerials;
  101. getId("_inpASO").onwheel = shiftAerials;
  102. getId("_resetAS").onclick = function() {
  103. getId("_inpASX").value = 0;
  104. getId("_inpASY").value = 0;
  105. shiftAerials();
  106. };
  107. getId("_inpGSVContrast").onchange = adjustGSV;
  108. getId("_inpGSVBrightness").onchange = adjustGSV;
  109. getId("_cbGSVInvert").onchange = adjustGSV;
  110. if (UIver=='new') {
  111. getId("_inpUICompression").onchange = applyEnhancements;
  112. getId("_inpUIContrast").onchange = applyEnhancements;
  113. }
  114.  
  115. //REGISTER WAZE EVENT HOOKS
  116. // event to recreate my tab when MTE mode is exited
  117. Waze.app.modeController.model.bind('change:mode', addMyTab);
  118. // events for Aerial Shifter
  119. Waze.map.events.register("zoomend", null, shiftAerials);
  120. Waze.map.events.register("moveend", null, shiftAerials);
  121. Waze.map.baseLayer.events.register("loadend", null, shiftAerials);
  122. // event to deal with ASC controls and make place address clickable
  123. Waze.selectionManager.events.register("selectionchanged", null, hideAveSpeedControls);
  124. // event to change menu bar color based on map comments checkbox
  125. Waze.map.events.register("zoomend", null, warnCommentsOff);
  126. Waze.map.events.register("moveend", null, warnCommentsOff);
  127.  
  128. // overload the window unload function to save my settings
  129. window.addEventListener("beforeunload", saveSettings, false);
  130.  
  131. loadSettings();
  132. // Add an extra checkbox so I can test segment panel changes easily
  133. if (Waze.loginManager.user.userName == 'iainhouse') {
  134. logit("creating segment detail debug checkbox","info");
  135. var brand = getId('brand');
  136. var extraCBSection = document.createElement('p');
  137. extraCBSection.innerHTML = '<input type="checkbox" id="_cbextraCBSection" />';
  138. brand.appendChild(extraCBSection);
  139. getId('_cbextraCBSection').onclick = FALSEcompressSegmentTab;
  140. getId('_cbextraCBSection').checked = getId('_cbCompressSegmentTab').checked;
  141. }
  142. // warn of permalink segments not all selected
  143. URLSegments = window.location.search.match(new RegExp("[?&]segments?=([^&]*)"));
  144. if (URLSegments) {
  145. URLSegmentCount = URLSegments[1].split(',').length;
  146. if (Waze.selectionManager.selectedItems.length > 0) {
  147. permalinkCheck();
  148. } else {
  149. Waze.selectionManager.events.register("selectionchanged", null, permalinkCheck);
  150. }
  151. }
  152.  
  153. // Alert to new version
  154. if (oldVersion != wmefu_version) {
  155. alert("WME Fix UI has been updated to version " + wmefu_version +
  156. "\n" +
  157. "\nVersion 2.2 - 2017-11-03" +
  158. "\n" +
  159. "\n* More tweaks to Segment details enhancement." +
  160. "\n* Place details enhancement completed." +
  161. "\n* New option to darken screen overlay when saving." +
  162. "\n" +
  163. "\nVersion 2.1 - 2017-10-28" +
  164. "\n" +
  165. "\nSettings not yet fully compatible with WME V2 will be turned off on script update." +
  166. ((getId("_cbAddZoomIndicator").checked === true) ? "\n* Zoom level indicator turned off - not yet working properly in WME V2" : "") +
  167. ((getId("_cbShrinkTopBars").checked === true) ? "\n* Shrink bars above map turned off - not yet working properly in WME V2" : "") +
  168. ((getId("_cbRestyleReports").checked === true) ? "\n* Restyle reports turned off - not yet working properly in WME V2" : "") +
  169. ((getId("_cbNarrowSidePanel").checked === true) ? "\n* Reduce width of side panel turned off - not yet working properly in WME V2" : "") +
  170. "\n" +
  171. "\nVersion 2.0.1 - 2017-10-27" +
  172. "\n" +
  173. "\nMinor update to re-instate 'Fix external providers'." +
  174. "\n" +
  175. "\nVersion 2.0 - 2017-10-25" +
  176. "\n" +
  177. "\nWME 2 is released, so WME FixUI is also out of beta." +
  178. "\n" +
  179. "\n* New operation with variable & independent compression/contrast enhancements" +
  180. "\n" +
  181. "\n* Updated handling for Feed, Drives and Areas" +
  182. "\n" +
  183. "\n* Segment edit panel updates completed" +
  184. "\n" +
  185. "\n* Disable map blocker removed - no longer needed" +
  186. "\n* Layers menu autohide removed - no longer needed" +
  187. "\n* Make place address clickable removed - no longer needed" +
  188. "\n* Fix external providers removed - no longer needed" +
  189. "\n");
  190. saveSettings();
  191. if (getId("_cbAddZoomIndicator").checked === true) getId("_cbAddZoomIndicator").checked = false;
  192. if (getId("_cbShrinkTopBars").checked === true) getId("_cbShrinkTopBars").checked = false;
  193. if (getId("_cbRestyleReports").checked === true) getId("_cbRestyleReports").checked = false;
  194. if (getId("_cbNarrowSidePanel").checked === true) getId("_cbNarrowSidePanel").checked = false;
  195. }
  196.  
  197. // fix for sidebar display problem in Safari, requested by edsonajj
  198. var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  199. if (isSafari) {
  200. addGlobalStyle('.flex-parent { height: 99% !important; }');
  201. }
  202. // apply the settings
  203. shiftAerials();
  204. setTimeout(applyAllSettings, 2000);
  205. logit("Initialisation complete");
  206. console.timeEnd(prefix + ": initialisation time");
  207. console.groupEnd();
  208. }
  209.  
  210. function createAddon() {
  211. //create the contents of my side-panel tab
  212. var addon = document.createElement('section');
  213. var section = document.createElement('p');
  214. addon.id = "sidepanel-FixUI";
  215. section.style.paddingTop = "0px";
  216. section.style.lineHeight = "16px";
  217. section.id = "fuContent";
  218. section.innerHTML = "";
  219. section.innerHTML += '<b>UI Fixes/changes</b><br>';
  220. section.innerHTML += '<input type="checkbox" id="_cbMoveZoomBar" /> ' +
  221. '<span title="Because nobody likes a pointless UI change that breaks your workflow,\nimposed by idiots who rarely use the editor and don\'t listen to feedback">Move zoom bar to left</span><br>';
  222. section.innerHTML += '<input type="checkbox" id="_cbAddZoomIndicator" /> ' +
  223. '<span title="Yes - I stole the idea from WME Toolbox. But mine is clearer and takes up no extra room ;)">Add zoom level indicator to zoom bar</span><br>';
  224. section.innerHTML += '<input type="checkbox" id="_cbHideUserInfo" /> ' +
  225. '<span title="Because we can earn points quicker without a massive chunk of space\nwasted on telling us how many we earnt up to yesterday">Hide user info in the side panel</span><br>';
  226. section.innerHTML += '<input type="checkbox" id="_cbHideAveSpeedControls" /> ' +
  227. '<span title="If you don\'t have these in your country, YOU\'RE LUCKY!\nBut don\'t forget you\'ve disabled this - they\'ll be coming soon!">Hide average speed camera controls</span><br>';
  228. section.innerHTML += '<input type="checkbox" id="_cbFixExternalProviders" /> ' +
  229. '<span title="The External Providers interface is really poor - you can rarely see all of the\ndetails in the box provided and the other elements are poorly arranged.\nThis fixes all that.">Expand & improve External Provider details for places</span><br>';
  230. //x section.innerHTML += '<input type="checkbox" id="_cbClickablePlaceAddress" /> ' +
  231. //x '<span title="For segments, the entire address is a clickable button to edit - for places, only the small pencil icon. \nThis fixes that inconsistency and also gives the correct mouse pointer.">Make the entire place address clickable</span><br>';
  232. section.innerHTML += '<input type="checkbox" id="_cbPermalinkChecker" /> ' +
  233. '<span title="If a permalink is created with off-screen segments or segment IDs have been changed,\nWME may open with fewer segments selected than are included in the permalink.\nThis causes a pop-up warning when that happens.">Warn on invalid permalinks</span><br>';
  234. section.innerHTML += '<input type="checkbox" id="_cbMoveChatIcon" /> ' +
  235. '<span title="Here\'s a truly outstanding example of making a stupid change to the UI in order to\ndeal with another stupid change to the UI!\nBecause HQ couldn\'t make the new layers menu auto-hide, they moved the chat icon.\nTick this box to put it back where it belongs.">Move Chat icon back to right</span><br>';
  236. section.innerHTML += '<input type="checkbox" id="_cbLayersMenuMoreOptions" /> ' +
  237. '<span title="As requested by users, this option turns on the More Options in the Layers menu.\nNote that this option only has an effect when the page is loaded. You can still toggle as normal.">Turn on More Options in Layers menu</span><br>';
  238. section.innerHTML += '<input type="checkbox" id="_cbDarkenSaveLayer" /> ' +
  239. '<span title="It\'s not bad enough they\'ve removed all the contrast to give you eyestrain,\nbut then they blind you every time you save. ">Darken screen overlay when saving</span><br>';
  240. section.innerHTML += '<br>';
  241. section.innerHTML += '<b>UI Enhancements</b><br>';
  242. section.innerHTML += '<input type="checkbox" id="_cbShrinkTopBars" /> ' +
  243. '<span title="Because we can\'t afford to waste screen space, particularly on\nstuff we didn\'t ask for and don\'t want, like the black bar">Shrink bars above the map</span><br>';
  244. section.innerHTML += '<input type="checkbox" id="_cbCompressSegmentTab" /> ' +
  245. '<span title="Because I\'m sick of having to scroll the side panel because of oversized fonts and wasted space">Compress' + (UIver=='new' ? '/enhance' : '') + ' side panel contents</span><br>';
  246. section.innerHTML += '<input type="checkbox" id="_cbCompressLayersMenu" /> ' +
  247. '<span title="Because it\'s already too big for small screens and Waze only plan to make it bigger">Compress' + (UIver=='new' ? '/enhance' : '') + ' layers menu</span><br>';
  248. section.innerHTML += '<input type="checkbox" id="_cbRestyleReports" /> ' +
  249. '<span title="Another UI element configured for developers with massive screens instead of normal users">Compress' + (UIver=='new' ? '/enhance' : '') + ' report panels (UR/MP)</span><br>';
  250. section.innerHTML += '<input type="checkbox" id="_cbNarrowSidePanel" /> ' +
  251. '<span title="If you have a netbook, Waze isn\'t interested in your experience.\nYou need every bit of map space you can get - so have a present from me!">Reduce width of the side panel</span><span title="This will definitely interfere with scripts that rely on a fixed width for their tab contents." style="font-size: 16px; color: red;">&#9888</span><br>';
  252. if (UIver == "new") {
  253. section.innerHTML += '<br>';
  254. section.innerHTML += '<b title="Control the amount of compression/enhancment">UI Enhancement controls<br>';
  255. section.innerHTML += '<div style="display:inline-block"><input type="number" id="_inpUICompression" title="Compression enhancement" max=2 min=0 step=1 style="height:20px; width:35px;text-align:center;"/>&nbsp;<span class="fa fa-compress"></span></div>&nbsp;&nbsp;&nbsp;&nbsp;';
  256. section.innerHTML += '<div style="display:inline-block"><input type="number" id="_inpUIContrast" title="Contrast enhancement" max=2 min=0 step=1 style="height:20px; width:35px;text-align:center;"/>&nbsp;<span class="fa fa-adjust"></span></div>';
  257. section.innerHTML += '<br>';
  258. section.innerHTML += '<br>';
  259. }
  260. section.innerHTML += '<b title="Shift aerial images layer to match GPS tracks and reduce image opacity">Aerial Shifter</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  261. section.innerHTML += '<span class="fa fa-power-off" id="_resetAS" title="Clear X/Y offsets"></span><br>';
  262. section.innerHTML += '<div style="display:inline-block"><input type="number" id="_inpASX" title="horizontal shift" max=100 min=-100 step=5 style="height:20px; width:47px;text-align:right;"/><b>m</b><span class="fa fa-arrow-right"></span></div>';
  263. section.innerHTML += '<div id="as2" style="display:inline-block;padding:0 5px;"><input type="number" id="_inpASY" title="vertical shift" max=100 min=-100 step=5 style="height:20px; width:47px;text-align:right;"/><b>m</b><span class="fa fa-arrow-up"></span></div>';
  264. section.innerHTML += '<div id="as3" style="display:inline-block"><input type="number" id="_inpASO" title="opacity" max=100 min=0 step=10 style="height:20px; width:44px;text-align:right;"/><b>%</b><span class="fa fa-adjust"></span></div>';
  265. section.innerHTML += '<br>';
  266. section.innerHTML += '<br>';
  267.  
  268. section.innerHTML += '<b title="Adjust contrast & brightness for Google Street View images">GSV image adjust</b><br>';
  269. section.innerHTML += '<span title="Contrast"><input type="number" id="_inpGSVContrast" max=200 min=0 step=25 style="height:20px; width:47px;text-align:right;"/><b>%</b><span class="fa fa-adjust"></span></span>&nbsp;&nbsp;';
  270. section.innerHTML += '<span title="Brightness"><input type="number" id="_inpGSVBrightness" max=200 min=0 step=25 style="height:20px; width:47px;text-align:right;"/><b>%</b><span class="fa fa-sun-o"></span></span>&nbsp;&nbsp;&nbsp;';
  271. section.innerHTML += '<span title="Invert colours"><input type="checkbox" id="_cbGSVInvert"/><span class="fa fa-tint"></span></span>';
  272.  
  273. section.innerHTML += '<br>';
  274. section.innerHTML += '<br>';
  275. section.innerHTML += '<b><a href="https://www.waze.com/forum/viewtopic.php?f=819&t=191178" title="Forum topic" target="_blank"><u>' +
  276. 'WME Fix UI</u></a></b> &nbsp; v' + wmefu_version;
  277. addon.appendChild(section);
  278. addon.className = "tab-pane";
  279. return addon;
  280. }
  281.  
  282. function addMyTab(model,modeID) {
  283. if (modeID === 0) {
  284. logit("entering default mode, so creating tab");
  285. tabAttempts = 0;
  286. tabsLooper();
  287. } else {
  288. logit("entering event mode, so not initialising");
  289. return;
  290. }
  291. }
  292.  
  293. function tabsLooper() {
  294. tabAttempts += 1;
  295. if (tabAttempts > 20) {
  296. // tried 20 times to create tab without luck
  297. logit("unable to create my tab after 20 attempts","error");
  298. return;
  299. }
  300. var userTabs = getId('user-info');
  301. var navTabs = getElementsByClassName('nav-tabs', userTabs)[0];
  302. if (typeof navTabs === "undefined") {
  303. //the basic tabs aren't there yet, so I can't add mine
  304. logit("waiting for NavTabs","warning");
  305. setTimeout(tabsLooper, 200);
  306. } else{
  307. var tabContent = getElementsByClassName('tab-content', userTabs)[0];
  308. newtab = document.createElement('li');
  309. newtab.innerHTML = '<a href="#sidepanel-FixUI" data-toggle="tab" title="Fix UI">FU</a>';
  310. navTabs.appendChild(newtab);
  311. tabContent.appendChild(wmeFUAddon);
  312. }
  313. }
  314.  
  315. function loadSettings() {
  316. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  317. logit("function " + fname + " called", "debug");
  318. // Convert old version of settings to new version
  319. var options;
  320. if (localStorage.WMEFixUI) {
  321. var oldSettings = JSON.parse(localStorage.WMEFixUI);
  322. var newSettings = {};
  323. newSettings.oldVersion = (oldSettings[0] ? oldSettings[0] : "1.0" );
  324. newSettings.moveZoomBar = (oldSettings[1] ? oldSettings[1] : true );
  325. newSettings.shrinkTopBars = (oldSettings[2] ? oldSettings[2] : true );
  326. newSettings.hideUserInfo = (oldSettings[3] ? oldSettings[3] : true );
  327. newSettings.restyleSidePanel = (oldSettings[4] ? oldSettings[4] : true );
  328. newSettings.restyleReports = (oldSettings[5] ? oldSettings[5] : true );
  329. newSettings.narrowSidePanel = (oldSettings[7] ? oldSettings[7] : false );
  330. newSettings.hideASCControls = (oldSettings[8] ? oldSettings[8] : false );
  331. newSettings.addZoomIndicator = (oldSettings[9] ? oldSettings[9] : true );
  332. newSettings.aerialShiftX = (oldSettings[10] ? oldSettings[10] : 0 );
  333. newSettings.aerialShiftY = (oldSettings[11] ? oldSettings[11] : 0 );
  334. newSettings.aerialOpacity = (oldSettings[12] ? oldSettings[12] : 100 );
  335. newSettings.fixExternalProviders = (oldSettings[13] ? oldSettings[13] : true );
  336. newSettings.GSVContrast = (oldSettings[14] ? oldSettings[14] : 100 );
  337. newSettings.GSVBrightness = (oldSettings[15] ? oldSettings[15] : 100 );
  338. newSettings.GSVInvert = (oldSettings[16] ? oldSettings[16] : false );
  339. //x newSettings.clickablePlaceAddress = (oldSettings[17] ? oldSettings[17] : true );
  340. newSettings.permalinkChecker = (oldSettings[18] ? oldSettings[18] : true );
  341. newSettings.restyleLayersMenu = (oldSettings[19] ? oldSettings[19] : true );
  342. newSettings.moveChatIcon = (oldSettings[20] ? oldSettings[20] : true );
  343. // setting[21] was Menu Autohide - no longer needed
  344. newSettings.layersMenuMore = (oldSettings[22] ? oldSettings[22] : true );
  345. localStorage.WMEFUSettings = JSON.stringify(newSettings);
  346. localStorage.removeItem("WMEFixUI");
  347. }
  348.  
  349. if (localStorage.WMEFUSettings) {
  350. options = JSON.parse(localStorage.WMEFUSettings);
  351. } else {
  352. options = {};
  353. }
  354. oldVersion = (options.oldVersion !== undefined ? options.oldVersion : "0.0");
  355. getId('_cbMoveZoomBar').checked = (options.moveZoomBar !== undefined ? options.moveZoomBar : true);
  356. getId('_cbShrinkTopBars').checked = (options.shrinkTopBars !== undefined ? options.shrinkTopBars : true);
  357. getId('_cbHideUserInfo').checked = ( options.hideUserInfo !== undefined ? options.hideUserInfo : true);
  358. getId('_cbCompressSegmentTab').checked = ( options.restyleSidePanel !== undefined ? options.restyleSidePanel : true);
  359. getId('_cbRestyleReports').checked = ( options.restyleReports !== undefined ? options.restyleReports : true);
  360. getId('_cbNarrowSidePanel').checked = ( options.narrowSidePanel !== undefined ? options.narrowSidePanel : false);
  361. getId('_cbHideAveSpeedControls').checked = ( options.hideASCControls !== undefined ? options.hideASCControls : false);
  362. getId('_cbAddZoomIndicator').checked = ( options.addZoomIndicator !== undefined ? options.addZoomIndicator : true);
  363. getId('_inpASX').value = ( options.aerialShiftX !== undefined ? options.aerialShiftX : 0);
  364. getId('_inpASY').value = ( options.aerialShiftY !== undefined ? options.aerialShiftY : 0);
  365. getId('_inpASO').value = ( options.aerialOpacity !== undefined ? options.aerialOpacity : 100);
  366. getId('_cbFixExternalProviders').checked = ( options.fixExternalProviders !== undefined ? options.fixExternalProviders : true);
  367. getId('_inpGSVContrast').value = ( options.GSVContrast !== undefined ? options.GSVContrast : 100);
  368. getId('_inpGSVBrightness').value = ( options.GSVBrightness !== undefined ? options.GSVBrightness : 100);
  369. getId('_cbGSVInvert').checked = ( options.GSVInvert !== undefined ? options.GSVInvert : false);
  370. //x getId('_cbClickablePlaceAddress').checked = ( options.clickablePlaceAddress !== undefined ? options.clickablePlaceAddress : true);
  371. getId('_cbPermalinkChecker').checked = ( options.permalinkChecker !== undefined ? options.permalinkChecker : true);
  372. getId('_cbCompressLayersMenu').checked = ( options.restyleLayersMenu !== undefined ? options.restyleLayersMenu : true);
  373. getId('_cbMoveChatIcon').checked = ( options.moveChatIcon !== undefined ? options.moveChatIcon : true);
  374. getId('_cbDarkenSaveLayer').checked = ( options.darkenSaveLayer !== undefined ? options.darkenSaveLayer : true);
  375. getId('_cbLayersMenuMoreOptions').checked = ( options.layersMenuMore !== undefined ? options.layersMenuMore : true);
  376. if (UIver == "new") {
  377. getId('_inpUIContrast').value = ( options.UIContrast !== undefined ? options.UIContrast : 1);
  378. getId('_inpUICompression').value = ( options.UICompression !== undefined ? options.UICompression : 1);
  379. }
  380. }
  381.  
  382. function saveSettings() {
  383. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  384. logit("function " + fname + " called", "debug");
  385. if (localStorage) {
  386. logit("saving options to local storage");
  387. var options = {};
  388. options.oldVersion = wmefu_version;
  389. options.moveZoomBar = getId('_cbMoveZoomBar').checked;
  390. options.shrinkTopBars = getId('_cbShrinkTopBars').checked;
  391. options.hideUserInfo = getId('_cbHideUserInfo').checked;
  392. options.restyleSidePanel = getId('_cbCompressSegmentTab').checked;
  393. options.restyleReports = getId('_cbRestyleReports').checked;
  394. options.narrowSidePanel = getId('_cbNarrowSidePanel').checked;
  395. options.hideASCControls = getId('_cbHideAveSpeedControls').checked;
  396. options.addZoomIndicator = getId('_cbAddZoomIndicator').checked;
  397. options.aerialShiftX = getId('_inpASX').value;
  398. options.aerialShiftY = getId('_inpASY').value;
  399. options.aerialOpacity = getId('_inpASO').value;
  400. options.fixExternalProviders = getId('_cbFixExternalProviders').checked;
  401. options.GSVContrast = getId('_inpGSVContrast').value;
  402. options.GSVBrightness = getId('_inpGSVBrightness').value;
  403. options.GSVInvert = getId('_cbGSVInvert').checked;
  404. //x options.clickablePlaceAddress = getId('_cbClickablePlaceAddress').checked;
  405. options.permalinkChecker = getId('_cbPermalinkChecker').checked;
  406. options.restyleLayersMenu = getId('_cbCompressLayersMenu').checked;
  407. options.moveChatIcon = getId('_cbMoveChatIcon').checked;
  408. options.darkenSaveLayer = getId('_cbDarkenSaveLayer').checked;
  409. options.layersMenuMore = getId('_cbLayersMenuMoreOptions').checked;
  410. if (UIver == "new") {
  411. options.UIContrast = getId('_inpUIContrast').value;
  412. options.UICompression = getId('_inpUICompression').value;
  413. }
  414. localStorage.WMEFUSettings = JSON.stringify(options);
  415. }
  416. }
  417.  
  418. function applyAllSettings() {
  419. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  420. logit("function " + fname + " called", "debug");
  421. console.group(prefix + ": applying all settings");
  422. moveZoomBar();
  423. shrinkTopBars();
  424. hideUserInfo();
  425. compressSegmentTab();
  426. restyleReports();
  427. narrowSidePanel();
  428. hideAveSpeedControls();
  429. fixExternalProviders();
  430. addZoomIndicator();
  431. warnCommentsOff();
  432. adjustGSV();
  433. compressLayersMenu();
  434. moveChatIcon();
  435. darkenSaveLayer();
  436. // layersMenuAutoHide();
  437. console.groupEnd();
  438. if (getId('_cbLayersMenuMoreOptions').checked === true) {
  439. $("#toolbar > div > div.layer-switcher-container > div > div > div > div > div.menu > div.more-options-toggle > label > div").click();
  440. }
  441. wmeFUinitialising = false;
  442. saveSettings();
  443. }
  444.  
  445. function applyEnhancements() {
  446. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  447. logit("function " + fname + " called", "debug");
  448. shrinkTopBars();
  449. compressSegmentTab();
  450. restyleReports();
  451. compressLayersMenu();
  452. }
  453.  
  454. function moveZoomBar() {
  455. // Now functioning correctly for prod & beta
  456. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  457. logit("function " + fname + " called", "debug");
  458. if (_cbMoveZoomBar.checked) {
  459. var styles = "";
  460. if (UIver == "old") {
  461. styles += '.olControlPanZoomBar { left: 10px; width: 30px; }';
  462. // shift UR/MP panel to the right
  463. styles += '#panel-container > div { left: 40px; }';
  464. } else {
  465. styles += '.olControlPanZoomBar { left: 10px; top: 40px; }';
  466. styles += '.street-view-control-container { bottom: -42px; }';
  467. styles += '.geolocation-control-container { bottom: -81px; }';
  468. // fix for WME Map Tiles Update script
  469. styles += '#Info_div { margin-top: 93px !important; }';
  470. // shift UR/MP panel to the right
  471. styles += '#panel-container > div { left: 40px; }';
  472. }
  473. addStyle(prefix + fname,styles);
  474. } else {
  475. removeStyle(prefix + fname);
  476. }
  477. }
  478.  
  479. function hideUserInfo() {
  480. // Now functioning correctly for prod & beta
  481. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  482. logit("function " + fname + " called", "debug");
  483. var styles = "";
  484. // WME Panel Swap buttons - move them up if user info is hidden
  485. var PSButton1 = getId('WMEPS_UIButton');
  486. var PSButton2 = getId('WMEPS_EditButton');
  487. if (_cbHideUserInfo.checked) {
  488. styles += '#user-box { display: none; }';
  489. // extra fix for WME Panel Swap control (not working with new WME UI)
  490. if (PSButton1) { PSButton1.style.top = '-27px'; }
  491. if (PSButton2) { PSButton2.style.top = '-27px'; }
  492. addStyle(prefix + fname,styles);
  493. //Fix to move control button of Invalidated Camera Mass Eraser
  494. if (getId("_UCME_btn")) {
  495. var but = getId("_UCME_btn");
  496. var dest = getId("advanced-tools");
  497. getId("advanced-tools").appendChild(getId("_UCME_btn"));
  498. document.getElementById('UCME_btn').parentNode.removeChild(document.getElementById('UCME_btn'));
  499. }
  500. } else {
  501. if (PSButton1) { PSButton1.style.top = '0px'; }
  502. if (PSButton2) { PSButton2.style.top = '0px'; }
  503. removeStyle(prefix + fname);
  504. }
  505. }
  506.  
  507. function WshrinkTopBars() {
  508. if (getId("_cbShrinkTopBars").checked === true) {
  509. alert("You have enabled the 'Shrink bars above map' option\n"+
  510. "Please be aware that this function is not yet compatible with WME V2");
  511. }
  512. shrinkTopBars();
  513. }
  514.  
  515. function shrinkTopBars() {
  516. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  517. logit("function " + fname + " called", "debug");
  518. var styles = "";
  519. if (_cbShrinkTopBars.checked) {
  520. //shrink the blue tool bar
  521. styles += '.toolbar { height: 31px; }';
  522. styles += '#app-head { height: 31px; }';
  523. styles += '#search { padding-top: 1px; }';
  524. styles += '.toolbar .toolbar-button { padding: 2px 7px; }';
  525. styles += '.toolbar .toolbar-separator { height: 31px; }';
  526. styles += '#layer-switcher { height: 51px; }';
  527. styles += '.toolbar menu.dropdown-menu { top: 31px; }';
  528. styles += '.toolbar .menu { top: 31px; }';
  529. styles += '#layer-switcher .dropdown-menu { top: 31px; }';
  530. styles += '.layer-switcher .content { top: 31px; }';
  531. //extra tweaks for Toolbox button & layers menu
  532. styles += '.WazeControlLayerSwitcherIcon { margin: 5px 2px 0 !important; }';
  533. styles += '#WazeControlLayerSwitcherIconContainer { height: 51px !important; }';
  534. styles += '#WazeControlLayerSwitcherIconContainerBeta { height: 51px !important; }';
  535. if (document.body.dir != "rtl") {
  536. styles += '.WazeControlLayerSwitcherToolbox { margin-left: -92px !important; }';
  537. } else {
  538. styles += '.WazeControlLayerSwitcherToolbox { margin-left: 112px !important; }';
  539. }
  540. styles += '#sidebar waze-links { height: 16px; }';
  541. //shrink the black bar
  542. styles += 'div#topbar-container { position: relative; }';
  543. styles += '.topbar { position: absolute; z-index: 1; background: transparent; height: 0; color: white; text-shadow: -1px -1px 0 #000, 1px -1px #000, -1px 1px #000, 1px 1px #000; line-height: 1.1; }';
  544. styles += '.topbar .location-info { font-size: 15px; font-weight: 900; }';
  545. styles += '.topbar .area-managers .title, .topbar .area-managers .main-list { font-size: 15px; font-weight: 900; }';
  546. styles += '.olControlPanZoomBar { top: 32px; }';
  547. styles += '#panel-container .panel { top: 20px; }';
  548. // disable text shadow for the list of additional AMs
  549. styles += '#topbar-container > div > div > div.area-managers-region > div > div.rest-list-region > div > span > ul { text-shadow: none; }';
  550. // following line needed to move MTE menu over the WME Bookmarks pin control
  551. styles += '#mode-switcher .dropdown-menu { top: 30px; }';
  552. //fix for buttons of WME GIS script
  553. styles += '.btn-group-sm { text-shadow: initial; background: white; }';
  554. addStyle(prefix + fname,styles);
  555. } else {
  556. removeStyle(prefix + fname);
  557. }
  558. window.dispatchEvent(new Event('resize'));
  559. }
  560.  
  561. function FALSEcompressSegmentTab() {
  562. _cbCompressSegmentTab.checked = _cbextraCBSection.checked;
  563. compressSegmentTab();
  564. }
  565.  
  566. function compressSegmentTab() {
  567. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  568. logit("function " + fname + " called", "debug");
  569. var styles = "";
  570. if (_cbCompressSegmentTab.checked) {
  571. // shrink address
  572. if (UIver == "old") {
  573. styles += '#edit-panel .primary-street { font-size: 14px; line-height: 15px; font-weight: 600; color: black; }';
  574. styles += '#edit-panel .address-edit-view .preview .address-edit-btn:not(.disabled) { background-color: #FFF9C4; }';
  575. styles += '#edit-panel .segment .address-edit-view, .edit-panel .segment .address-edit-view { margin-bottom: 5px; }';
  576. //shrink tabs
  577. styles += '#sidebar .nav-tabs>li {margin-top: 2px; }';
  578. styles += '#sidebar .nav-tabs li a { padding: 2px; }';
  579. styles += '#sidebar .nav-tabs { margin: 0 0 5px 0; padding-left: 4px; }';
  580. //reduce some vertical margins
  581. styles += '#edit-panel .contents { padding: 0 5px 0 5px; overflow: hidden; }';
  582. styles += '#edit-panel .form-group { margin-bottom: 2px; line-height: 1; font-size: 11px; }';
  583. styles += '#edit-panel .selection { margin-bottom: 5px; }';
  584. styles += '#sidebar .side-panel-section:not(:last-child) { margin-bottom: 2px; }';
  585. styles += '#sidebar .side-panel-section:not(:last-child)::after { margin-top: 5px; margin-bottom: 2px; }';
  586. styles += '#edit-panel .control-label { margin-bottom: 1px; }';
  587. styles += '#sidebar .controls-container { padding-top: 2px; }';
  588. styles += '#edit-panel .segment .speed-limit label { margin-bottom: 0px; }';
  589. styles += '#edit-panel .more-actions { padding-top: 2px; }';
  590. styles += '#edit-panel .segment .speed-limit .direction-label, #edit-panel .segment .speed-limit .unit-label { line-height: 2.1em; }';
  591. styles += '#sidebar .side-panel-section~.side-panel-section:not(:last-child):before { margin: 5px -20px !important; }';
  592. styles += '#sidebar .side-panel-section~.side-panel-section:not(:last-child) { margin-top: 5px !important; }';
  593. //shrink dropdown controls & buttons
  594. styles += '#edit-panel button, #edit-panel select, #edit-panel .form-control { font-size: 11px; height: 19px; padding: 0px 4px; }';
  595. styles += '#edit-panel .more-actions button:not(:last-of-type) { margin-bottom: 2px; }';
  596. styles += '.edit-closure .input-group-addon { padding: 2px 8px; }';
  597. //fit road property checkboxes on one line for all three (if text length allows)
  598. styles += '#edit-panel .controls-container { display: inline-block; }';
  599. styles += '#edit-panel .controls-container label { font-size: 12px; line-height: 18px; padding-left: 22px; }';
  600. styles += '#edit-panel .select-entire-street { width: 49%; overflow: hidden; }';
  601. styles += '#edit-panel .edit-house-numbers { width: 49%; overflow: hidden; }';
  602. styles += '#edit-panel .action-button { color: black; }';
  603. styles += '#edit-panel .categories .select2-container { margin-bottom: -5px; }';
  604. //tweak for speed camera checkbox having a left margin of -20px. Why?!
  605. styles += '#edit-panel .checkbox, .radio { margin-left: 20px; }';
  606. //tweaks for Closures tab
  607. styles += '#edit-panel .segment .segment-details { margin-bottom: 4px; }';
  608. styles += '.closures-list .closure-item .section { padding: 2px; }';
  609. styles += '.col-xs-6 { line-height: 14px; }';
  610. styles += '.closures-list .direction { margin-bottom: 0px; }';
  611. styles += '.closures-list .closure-item:not(:last-child) { margin-bottom: 4px; }';
  612. //tweak required for Speedhelper script
  613. styles += 'div[id^="spd_"] { line-height: 1.43; }';
  614. //tweaks for Feed tab
  615. styles += '.feed-item { margin-bottom: 2px; }';
  616. styles += '.feed-item .inner { padding: 2px; }';
  617. styles += '.feed-item .delete { zoom: 149%; }';
  618. styles += '.feed-item .motivation { margin-bottom: 0px; }';
  619. styles += '.feed-item .content .title { margin-bottom: 0px; }';
  620. styles += '.feed-item .content .subtext { font-size: 11px; }';
  621. //tweaks for Drives tab
  622. styles += '#sidebar .message { margin-bottom: 0px; line-height: 14px; }';
  623. styles += '#sidebar .result-list .result { padding: 2px 5px; }';
  624. //tweaks for Restrictions dialogue
  625. styles += '#schedule-modal .modal-body { padding: 2px 8px; }';
  626. styles += '#schedule-modal .items { line-height: 0.5; }';
  627. styles += '#schedule-modal .table { margin-bottom: 10px; }';
  628. styles += '#schedule-modal .no-restrictions { margin-bottom: 10px; }';
  629. styles += '#schedule-modal .well { padding: 5px; }';
  630. styles += '#schedule-modal .edit-restriction .section { margin-bottom: 2px; padding: 0 2px; }';
  631. styles += '#schedule-modal .nav>li>a { padding: 2px 15px; }';
  632. styles += '#schedule-modal .btn { height: 22px; padding: 2px 15px; }';
  633. //tweaks for Map Comments
  634. styles += '.map-comment-feature-editor .conversation-region, .map-comment-feature-editor .name-editor-region { margin-left: -17px; margin-right: -5px; }';
  635. if (_cbNarrowSidePanel.checked) {
  636. styles += '.map-comment-feature-editor .conversation-view .new-comment-text { resize: both; max-width: 230px; }';
  637. } else {
  638. styles += '.map-comment-feature-editor .conversation-view .new-comment-text { resize: both; max-width: 310px; }';
  639. }
  640. //tweaks for History
  641. styles += '.toggleHistory { padding: 2px 12px 7px 12px; }';
  642. styles += '.tx-header { padding: 2px 15px 2px 15px !important; }';
  643. styles += '.tx-author-date { margin-bottom: 2px !important; }';
  644. styles += '.element-history-item { font-size: 11px; }';
  645. styles += '.tx-content { padding: 2px 15px 2px 15px !important; }';
  646. styles += '.tx-changed-ro:not(:last-child) { margin-bottom: 2px; }';
  647. styles += '.tx-changed-attribute .ca-name { margin-bottom: 2px; }';
  648. styles += '.tx-changed-attribute:not(:last-child) {margin-bottom: 2px; }';
  649. } else {
  650. //For new WME version
  651. var contrast = _inpUIContrast.value;
  652. var compress = _inpUICompression.value;
  653. if (compress > 0) {
  654. //general compression enhancements
  655. styles += '#sidebar #advanced-tools { padding: ' + ['','0 9px','0 4px'][compress] + '; }';
  656. styles += '#sidebar waze-staff-tools { margin-bottom: ' + ['','9px','4px'][compress] + '; }';
  657. styles += '#sidebar .tab-content { padding: ' + ['','9px','4px'][compress] + '; }';
  658. //Tabs
  659. styles += '#sidebar #user-info #user-tabs { padding: ' + ['','0 9px','0 4px'][compress] + '; }';
  660. styles += '#sidebar .nav-tabs li a { margin-top: ' + ['','2px','1px'][compress] + '; margin-left: ' + ['','3px','1px'][compress] + '; padding-top: 0px !important; }';
  661. styles += '#sidebar .nav-tabs li { flex-grow: 0; }';
  662. //Feed
  663. styles += '.feed-item { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  664. styles += '.feed-item .inner { padding: ' + ['','5px','0px'][compress] + '; }';
  665. styles += '.feed-item .content .title { margin-bottom: ' + ['','1px','0px'][compress] + '; }';
  666. styles += '.feed-item .motivation { margin-bottom: ' + ['','2px','0px'][compress] + '; }';
  667. //Drives & Areas
  668. styles += '#sidebar .message { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  669. styles += '#sidebar .result-list .result { padding: ' + ['','6px 17px','2px 9px'][compress] + '; margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  670. //SEGMENT EDIT PANEL
  671. //general changes
  672. //checkbox groups
  673. styles += '#sidebar .controls-container { padding-top: ' + ['','4px','1px'][compress] + '; display: inline-block; font-size: ' + ['','12px','11px'][compress] + '; }';
  674. //form groups
  675. styles += '#sidebar .form-group { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  676. //dropdown inputs
  677. styles += '#sidebar .form-control { height: ' + ['','28px','21px'][compress] + '; padding-top: ' + ['','4px','0px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; color: black; }';
  678. //buttons
  679. styles += '#edit-panel .waze-btn { padding-top: ' + ['','3px','1px'][contrast] + '; padding-bottom: ' + ['','3px','1px'][contrast] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  680. //radio button controls
  681. styles += '.waze-radio-container label { height: ' + ['','19px','16px'][compress] + '; width: ' + ['','19px','16px'][compress] + '; line-height: ' + ['','19px','16px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  682. //specific changes
  683. //Selected segments info
  684. styles += '#edit-panel .selection { padding-top: ' + ['','8px','2px'][compress] + '; padding-bottom: ' + ['','8px','4px'][compress] + '; }';
  685. styles += '#edit-panel .segment .direction-message { margin-bottom: ' + ['','9px','3px'][compress] + '; }';
  686. //Segment details (closure warning)
  687. styles += '#edit-panel .segment .segment-details { padding: ' + ['','10px','5px'][compress] + '; padding-top: 0px; }';
  688. //All control labels
  689. styles += '#edit-panel .control-label { font-size: ' + ['','11px','10px'][compress] + '; margin-bottom: ' + ['','4px','2px'][compress] + '; }';
  690. //Address input
  691. styles += '#edit-panel .address-edit-view { cursor: pointer; margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  692. styles += '#edit-panel .address-edit-input { padding: ' + ['','4px','1px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  693. //speed limit controls
  694. styles += '#edit-panel .segment .speed-limit .form-control { height: ' + ['','23px','19px'][compress] + '; padding-top: ' + ['','4px','2px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; width: 5em; }';
  695. styles += '#edit-panel .segment .speed-limit .direction-label { font-size: ' + ['','12px','11px'][compress] + '; line-height: ' + ['','2.0em','1.8em'][compress] + '; }';
  696. styles += '#edit-panel .segment .speed-limit .unit-label { font-size: ' + ['','12px','11px'][compress] + '; line-height: ' + ['','2.0em','1.8em'][compress] + '; padding-right: ' + ( (getId('_cbNarrowSidePanel').checked === true) ? '50px' : '130px' ) + '; }';
  697. //more actions section
  698. styles += '#edit-panel .more-actions { padding-top: ' + ['','6px','2px'][compress] + '; }';
  699. styles += '#edit-panel .more-actions .waze-btn.waze-btn-white { height: ' + ['','28px','21px'][compress] + '; line-height: ' + ['','25px','18px'][compress] + '; padding-left: 0px; padding-right: 0px; }';
  700. //get more-actions buttons on one line
  701. styles += '#edit-panel .more-actions { display: inline-flex; }';
  702. styles += '#edit-panel .action-button { width: 155px; overflow: hidden; }';
  703. styles += '#edit-panel .action-button:before { margin-right: 0px !important; }';
  704. styles += '#edit-panel .more-actions .edit-house-numbers-btn-wrapper { margin-top: 0px; }';
  705. //additional attributes
  706. styles += '#edit-panel .additional-attributes { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  707. //history items
  708. styles += '.toggleHistory { padding: ' + ['','7px','3px'][compress] + '; }';
  709. styles += '.element-history-item:not(:last-child) { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  710. styles += '.element-history-item .tx-header { padding: ' + ['','6px','2px'][compress] + '; }';
  711. styles += '.element-history-item .tx-header .tx-author-date { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  712. styles += '.element-history-item .tx-content { padding: ' + ['','7px 7px 7px 22px','4px 4px 4px 22px'][compress] + '; }';
  713. styles += '.loadMoreContainer { padding: ' + ['','5px 0px','3px 0px'][compress] + '; }';
  714. //closures list
  715. styles += '.closures-list .closure-item:not(:last-child) { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  716. styles += '.closures-list .closure-item .details { padding: ' + ['','5px','0px'][compress] + '; font-size: ' + ['','12px','11px'][compress] + '; }';
  717. styles += '.closures-list .closure-item .buttons { top: ' + ['','7px','4px'][compress] + '; }';
  718. //PLACE DETAILS
  719. //alert
  720. styles += '#edit-panel .header-alert { margin-bottom: ' + ['','6px','2px'][compress] + '; padding: ' + ['','6px','2px'][compress] + '; }';
  721. //address input
  722. styles += '#edit-panel .full-address { padding-top: ' + ['','4px','1px'][compress] + '; padding-bottom: ' + ['','4px','1px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  723. //alt names
  724. styles += '#edit-panel .aliases-view .list li { margin: ' + ['','12px 0','4px 0'][compress] + '; }';
  725. styles += '#edit-panel .aliases-view .delete { line-height: inherit; }';
  726. //categories
  727. styles += '#edit-panel .categories .select2-search-choice .category { margin: ' + ['','2px 0 2px 4px','1px 0 1px 3px'][compress] + '; height: ' + ['','18px','15px'][compress] + '; line-height: ' + ['','18px','15px'][compress] + '; }';
  728. styles += '#edit-panel .categories .select2-search-field input { height: ' + ['','18px','17px'][compress] + '; }';
  729. styles += '#edit-panel .categories .select2-choices { min-height: ' + ['','26px','19px'][compress] + '; }';
  730. styles += '#edit-panel .categories .select2-container { margin-bottom: 0px; }';
  731. //entry/exit points
  732. styles += '#edit-panel .navigation-point-view .navigation-point-list-item .preview { padding: ' + ['','3px 7px','0px 4px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  733. styles += '#edit-panel .navigation-point-view .add-button { height: ' + ['','28px','18px'][contrast] + '; line-height: ' + ['','17px','16px'][contrast] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  734. //type buttons
  735. styles += '#sidebar .area-btn, #sidebar .point-btn { height: ' + ['','19px','16px'][compress] + '; line-height: ' + ['','19px','16px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  736. // { height: ' + ['','19px','16px'][compress] + '; width: ' + ['','19px','16px'][compress] + '; line-height: ' + ['','19px','16px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  737. //external providers
  738. styles += '.select2-container { font-size: ' + ['','13px','12px'][compress] + '; }';
  739. styles += '#edit-panel .external-providers-view .external-provider-item { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  740. styles += '.external-providers-view > div > ul { margin-bottom: ' + ['','4px','0px'][compress] + '; }';
  741. styles += '#edit-panel .external-providers-view .add { padding: ' + ['','3px 12px','1px 9px'][compress] + '; }';
  742. styles += '#edit-panel .waze-btn.waze-btn-smaller { line-height: ' + ['','26px','21px'][compress] + '; }';
  743. //residential toggle
  744. styles += '#edit-panel .toggle-residential { height: ' + ['','27px','22px'][compress] + '; }';
  745. //more info
  746. styles += '.service-checkbox { font-size: ' + ['','13px','12px'][compress] + '; }';
  747. }
  748. if (contrast > 0) {
  749. //contrast enhancements
  750. //general
  751. //text colour
  752. styles += '#sidebar { color: black; }';
  753. //advanced tools section
  754. styles += '#sidebar waze-staff-tools { background-color: #c7c7c7; }';
  755. //Tabs
  756. styles += '#sidebar .nav-tabs li a { border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
  757. //Feed
  758. styles += '.feed-item { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  759. //Drives & Areas
  760. styles += '#sidebar .result-list .result { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  761. //Segment edit panel
  762. styles += '#edit-panel .selection { font-size: 13px; }';
  763. styles += '#edit-panel .segment .direction-message { color: orangered; }';
  764. styles += '#edit-panel .address-edit-input { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  765. styles += '#sidebar .form-control { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  766. //radio buttons when disabled
  767. styles += '.waze-radio-container input[type="radio"]:disabled:checked + label { color: black; opacity: 0.7; font-weight:600; }';
  768. //override border for lock levels
  769. styles += '#sidebar .waze-radio-container { border: 0 none !important; }';
  770. styles += '#edit-panel .waze-btn { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  771. styles += '.waze-radio-container label { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  772. //history items
  773. styles += '.toggleHistory { color: black; text-align: center; }';
  774. styles += '.element-history-item .tx-header { color: black; }';
  775. styles += '.element-history-item.closed .tx-header { border-radius: 8px; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  776. styles += '.loadMoreHistory { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  777. //closures list
  778. styles += '.closures-list .closure-item .details { border-radius: 8px; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  779. styles += '.closures-list .closure-item .dates { color: black; }';
  780. styles += '.closures-list .closure-item .dates .date-label { opacity: 1; }';
  781. //Place details
  782. //alert
  783. styles += '#edit-panel .alert-danger { color: red; }';
  784. //address input
  785. styles += '#edit-panel .full-address { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  786. styles += '#edit-panel a.waze-link { font-weight: bold; }';
  787. //categories
  788. styles += '#edit-panel .categories .select2-search-choice .category { text-transform: inherit; font-weight: bold; background: gray; }';
  789. //entry/exit points
  790. styles += '#edit-panel .navigation-point-view .navigation-point-list-item .preview { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  791. styles += '#edit-panel .navigation-point-view .add-button { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; margin-top: 2px; padding: 0 5px; }';
  792. //type buttons
  793. styles += '#sidebar .point-btn { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
  794. //external providers
  795. styles += '.select2-container { color: teal; border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
  796. styles += '.select2-container .select2-choice { color: black; }';
  797. //residential toggle
  798. styles += '#edit-panel .toggle-residential { font-weight: bold; }';
  799. }
  800. }
  801. //fix for buttons of WME Image Overlay script
  802. styles += '#sidepanel-imageoverlays > div.result-list button { height: 24px; }';
  803. addStyle(prefix + fname,styles);
  804. } else {
  805. removeStyle(prefix + fname);
  806. }
  807. }
  808.  
  809. function compressLayersMenu() {
  810. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  811. logit("function " + fname + " called", "debug");
  812. var styles = "";
  813. if (_cbCompressLayersMenu.checked) {
  814. // tweaks for layers menu
  815. if (document.getElementById('layer-switcher-list') === null) {
  816. //new style layers menu
  817. styles += '.layer-switcher { line-height: 11px; }';
  818. styles += '#layer-switcher .dropdown-menu .draggable .toggler .handle { height: 18px; }';
  819. styles += '.layer-switcher .togglers .group:not(:last-child):after { margin: 5px -7px -2px; }';
  820. styles += '.layer-switcher .more-options-toggle { height: 20px; line-height: 20px; }';
  821. } else {
  822. //old style layers menu
  823. styles += '.layer-switcher { line-height: 14px; }';
  824. }
  825. // styles += '.layer-switcher .toggler { padding-top: 0px; padding-bottom: 0px; }';
  826. addStyle(prefix + fname,styles);
  827. } else {
  828. removeStyle(prefix + fname);
  829. }
  830. }
  831.  
  832. function WrestyleReports() {
  833. if (getId("_cbRestyleReports").checked === true) {
  834. alert("You have enabled the 'Compress/enhance report panels' option\n"+
  835. "Please be aware that this function is not yet compatible with WME V2");
  836. }
  837. restyleReports();
  838. }
  839.  
  840. function restyleReports() {
  841. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  842. logit("function " + fname + " called", "debug");
  843. var styles = "";
  844. if (_cbRestyleReports.checked) {
  845. styles += '#panel-container .panel { font-size: 12px; line-height: 15px; }';
  846. styles += '#panel-container .problem-edit .header { padding: 5px; line-height: 15px; }';
  847. styles += '#panel-container .problem-edit .problem-data .title { line-height: 22px; }';
  848. styles += '#panel-container .problem-edit .section .title { padding: 0 5px; }';
  849. styles += '#panel-container .problem-edit .section .content { padding: 5px; }';
  850. styles += '#WMEFP-UR-ALLPM { top: -2px !important; }';
  851. styles += '#panel-container .problem-edit .conversation.section .comment .comment-content { padding: 0 5px; }';
  852. styles += '#panel-container .problem-edit .conversation.section .no-comments { padding: 0; }';
  853. styles += '#panel-container .problem-edit .conversation.section .new-comment-form { padding: 0; }';
  854. styles += '#panel-container .problem-edit .conversation.section .new-comment-form textarea { resize: vertical; height: 110px; margin-bottom: 0px; padding: 3px 5px; font-size: 12px; }';
  855. styles += '#panel-container .btn { height: 20px; padding: 0px 10px;}';
  856. styles += '#panel-container .problem-edit .actions .content { padding: 2px 5px;}';
  857. styles += '#panel-container .problem-edit .actions .controls-container label { margin-bottom: 0px; line-height: 22px }';
  858. styles += '#panel-container .problem-edit .actions .navigation { margin-top: 5px;}';
  859. styles += '#panel-container .problem-edit .actions .controls-container { display: inline-flex; flex-wrap: wrap; margin-left: -3px; }';
  860. styles += '#panel-container .input-max-length { text-align: right; margin-top: 0; white-space: nowrap; color: #3d3d3d; font-weight: 700; font-size: 11px; }';
  861. addStyle(prefix + fname,styles);
  862. // if (wmeFUinitialising) {
  863. // setTimeout(draggablePanel, 5000);
  864. // } else {
  865. // draggablePanel();
  866. // }
  867. } else {
  868. removeStyle(prefix + fname);
  869. // if (jQuery.ui) {
  870. // $("#panel-container").draggable("destroy");
  871. // getId("panel-container").style = "";
  872. // }
  873. }
  874. window.dispatchEvent(new Event('resize'));
  875. }
  876.  
  877. function draggablePanel() {
  878. if (jQuery.ui) {
  879. if ($("#panel-container").data("ui-draggable")) {
  880. $("#panel-container").draggable({ handle: ".header" });
  881. }
  882. }
  883. }
  884.  
  885. function WnarrowSidePanel() {
  886. if (getId("_cbNarrowSidePanel").checked === true) {
  887. alert("You have enabled the 'Reduce width of side panel' option\n"+
  888. "Please be aware that this function is not yet compatible with WME V2");
  889. }
  890. narrowSidePanel();
  891. }
  892.  
  893. function narrowSidePanel() {
  894. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  895. logit("function " + fname + " called", "debug");
  896. var styles = "";
  897. if (_cbNarrowSidePanel.checked) {
  898. styles += '.row-fluid #sidebar { width: 250px; }';
  899. styles += '.col-fixed-330 { width: 250px; }';
  900. styles += '#sidebar waze-links { overflow: hidden; }';
  901. styles += '#sidebar waze-links li+li::before { padding: 0; }';
  902. styles += '#sidebar waze-links li { font-size: 10px; }';
  903. styles += '#edit-panel .add-alt-street-form th.city { min-width: inherit; }';
  904. styles += '#edit-panel .external-providers-view .select2-container { width: 100%; }';
  905. if (document.body.dir != "rtl") {
  906. styles += '.show-sidebar .row-fluid .fluid-fixed { margin-left: 250px; }';
  907. styles += '.col-offset-330 { padding-left: 250px; }';
  908. } else {
  909. styles += '.show-sidebar .row-fluid .fluid-fixed { margin-right: 250px; }';
  910. styles += '.col-offset-330 { padding-right: 250px; }';
  911. }
  912. styles += '.edit-closure .form { padding: 2px; }';
  913. styles += '.edit-closure .date-input-group { width: 56%; }';
  914. //for new WME
  915. //styles += '#sidebar .tab-scroll-gradient { width: 242px; }';
  916. //#sidebar #links:before
  917. addStyle(prefix + fname, styles);
  918. } else {
  919. removeStyle(prefix + fname);
  920. }
  921. compressSegmentTab();
  922. window.dispatchEvent(new Event('resize'));
  923. }
  924.  
  925. function hideAveSpeedControls() {
  926. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  927. logit("function " + fname + " called", "debug");
  928. removeStyle(prefix + fname);
  929. if (_cbHideAveSpeedControls.checked) {
  930. var ASCBox;
  931. if (getId('fwdSpeedCameraCheckbox')) {
  932. ASCBox = getId('fwdSpeedCameraCheckbox');
  933. }
  934. if (getId('revSpeedCameraCheckbox')) {
  935. ASCBox = getId('revSpeedCameraCheckbox');
  936. }
  937. if (ASCBox) {
  938. var formGroup = ASCBox.parentNode.parentNode.parentNode;
  939. var formGroupParent = formGroup.parentNode;
  940. var targetGroup = Array.prototype.indexOf.call(formGroupParent.children, formGroup) + 1;
  941. addStyle(prefix + fname, '#segment-edit-general > .side-panel-section.attributes-form > .form-group:nth-of-type(' + targetGroup + ') { display: none; }');
  942. }
  943. }
  944. // if (_cbClickablePlaceAddress.checked) {
  945. // var address;
  946. // // Place address
  947. // if (UIver == "old") {
  948. // address = document.querySelector("#landmark-edit-general > div.address-edit.side-panel-section > div > div");
  949. // if (address) {
  950. // address.classList.add('edit-button');
  951. // address.style.cursor = 'pointer';
  952. // }
  953. // } else {
  954. // address = document.querySelector("#landmark-edit-general > div.form-group > div > div > div");
  955. // if (address) {
  956. // address.classList.add('edit-button');
  957. // address.style.cursor = 'pointer';
  958. // }
  959. // }
  960. // // Segment address
  961. // if (UIver == "old") {
  962. // // don't need to do anything - already clickable
  963. // } else {
  964. // address = document.querySelector("#segment-edit-general > div.address-edit.address-edit-view.clearfix.preview > div");
  965. // if (address) {
  966. // address.classList.add('address-edit-btn');
  967. // address.style.cursor = 'pointer';
  968. // var styles = "";
  969. // styles += "#segment-edit-general > div.address-edit.address-edit-view.clearfix.preview > div:before { content: none; }";
  970. // styles += "#segment-edit-general > div.address-edit.address-edit-view.clearfix.preview > div:after { content: none; }";
  971. // addStyle(prefix + fname, styles);
  972. // }
  973. // }
  974. // } else {
  975. // removeStyle(prefix + fname);
  976. // }
  977. }
  978.  
  979. function WaddZoomIndicator() {
  980. if (getId("_cbAddZoomIndicator").checked === true) {
  981. alert("You have enabled the Zoom Level Indicator\n"+
  982. "Please be aware that this function is not yet compatible with WME V2");
  983. }
  984. addZoomIndicator();
  985. }
  986.  
  987. function addZoomIndicator() {
  988. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  989. logit("function " + fname + " called", "debug");
  990. var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
  991. if (_cbAddZoomIndicator.checked) {
  992. addStyle(prefix + fname, '.slider { font-size: 15px; font-weight: 900; line-height: 1; height: 18px; margin-top: 23px; padding-top: 2px; text-align: center; }');
  993. Waze.map.events.register("zoomend", null, ZLI);
  994. ZLI();
  995. } else {
  996. removeStyle(prefix + fname);
  997. Waze.map.events.unregister("zoomend", null, ZLI);
  998. slider.innerText = "";
  999. slider.title = "";
  1000. }
  1001. }
  1002.  
  1003. function ZLI() {
  1004. var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
  1005. slider.innerText = Waze.map.zoom;
  1006. slider.title = "Zoom level indicator by WMEFU";
  1007. switch (Waze.map.zoom) {
  1008. case 0:
  1009. case 1:
  1010. slider.style.background = '#ef9a9a';
  1011. slider.title += "\nCannot permalink any segments at this zoom level";
  1012. break;
  1013. case 2:
  1014. case 3:
  1015. slider.style.background = '#ffe082';
  1016. slider.title += "\nCan only permalink primary or higher at this zoom level";
  1017. break;
  1018. default:
  1019. slider.style.background = '#ffffff';
  1020. slider.title += "\nCan permalink any segments at this zoom level";
  1021. break;
  1022. }
  1023. }
  1024.  
  1025. function shiftAerials() {
  1026. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1027. logit("function " + fname + " called", "debug");
  1028. // calculate meters/pixel for current map view
  1029. var ipu = OpenLayers.INCHES_PER_UNIT;
  1030. var metersPerPixel = Waze.map.getResolution() * ipu.m / ipu[Waze.map.getUnits()];
  1031. // Apply the shift and opacity
  1032. Waze.map.baseLayer.div.style.left = Math.round(getId("_inpASX").value / metersPerPixel) + 'px';
  1033. Waze.map.baseLayer.div.style.top = Math.round(- getId("_inpASY").value / metersPerPixel) + 'px';
  1034. Waze.map.baseLayer.div.style.opacity = getId("_inpASO").value/100;
  1035. }
  1036.  
  1037. function fixExternalProviders () {
  1038. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1039. logit("function " + fname + " called", "debug");
  1040. var styles = "";
  1041. if (_cbFixExternalProviders.checked) {
  1042. //enlarge external provider boxes
  1043. styles += '#edit-panel .external-providers-view .select2-container { width: 90%; margin-bottom: 2px; }';
  1044. styles += '.select2-container .select2-choice { height: inherit; line-height: 16px; }';
  1045. styles += '.select2-container .select2-choice>.select2-chosen { white-space: normal; }';
  1046. styles += '.placeId { padding-bottom: 5px; }';
  1047. addStyle(prefix + fname,styles);
  1048. } else {
  1049. removeStyle(prefix + fname);
  1050. }
  1051. }
  1052.  
  1053. function warnCommentsOff() {
  1054. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1055. logit("function " + fname + " called", "debug");
  1056. if (Waze.map.getLayerByUniqueName('mapComments').visibility === false) {
  1057. removeStyle(prefix + fname);
  1058. addStyle(prefix + fname, '.toolbar { background-color: #FFC107; }');
  1059. } else {
  1060. removeStyle(prefix + fname);
  1061. }
  1062. }
  1063.  
  1064. function adjustGSV() {
  1065. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1066. logit("function " + fname + " called", "debug");
  1067. var styles = "";
  1068. styles += '.gm-style { filter: contrast(' + getId('_inpGSVContrast').value + '%) ';
  1069. styles += 'brightness(' + getId('_inpGSVBrightness').value + '%) ';
  1070. if (getId('_cbGSVInvert').checked) {
  1071. styles += 'invert(1); }';
  1072. } else {
  1073. styles += 'invert(0); }';
  1074. }
  1075. removeStyle(prefix + fname);
  1076. addStyle(prefix + fname, styles);
  1077. }
  1078.  
  1079. function permalinkCheck() {
  1080. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1081. logit("function " + fname + " called", "debug");
  1082. var selSegments = Waze.selectionManager.selectedItems.length;
  1083. if ( URLSegmentCount != selSegments ) {
  1084. alert("WARNING FROM WME FixUI!\n\n" +
  1085. "You have opened a permalink with " + URLSegmentCount + " segments,\n" +
  1086. "but the total selected in WME is " + selSegments + ".\n\n" +
  1087. "The permalink may contain segments not selectable at this zoom\n" +
  1088. "or not visible on-screen, or some segment IDs may have been\n" +
  1089. "changed since the permalink was created.");
  1090. }
  1091. Waze.selectionManager.events.unregister("selectionchanged", null, permalinkCheck);
  1092. }
  1093.  
  1094. function moveChatIcon() {
  1095. // Now functioning correctly for prod & beta
  1096. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1097. logit("function " + fname + " called", "debug");
  1098. var styles = "";
  1099. if (_cbMoveChatIcon.checked) {
  1100. styles += '#chat-overlay { left: inherit; right: 20px; }';
  1101. if (UIver == "new") {
  1102. styles += '#chat-overlay #chat-toggle { right: 0px; }';
  1103. }
  1104. addStyle(prefix + fname,styles);
  1105. } else {
  1106. removeStyle(prefix + fname);
  1107. }
  1108. }
  1109.  
  1110. function darkenSaveLayer() {
  1111. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1112. logit("function " + fname + " called", "debug");
  1113. var styles = "";
  1114. if (_cbDarkenSaveLayer.checked) {
  1115. styles += '#popup-overlay { background-color: black; }';
  1116. addStyle(prefix + fname,styles);
  1117. } else {
  1118. removeStyle(prefix + fname);
  1119. }
  1120. }
  1121.  
  1122. //function layersMenuAutoHide() {
  1123. // var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1124. // logit("function " + fname + " called", "debug");
  1125. // var LS = getElementsByClassName('layer-switcher')[0];
  1126. // if (_cbLayersMenuAutoHide.checked) {
  1127. // LS.onmouseleave = function () { $(".waze-icon-layers").click(); };
  1128. // LS.onmouseenter = function () { $(".waze-icon-layers").click(); };
  1129. // } else {
  1130. // LS.onmouseleave = null;
  1131. // LS.onmouseenter = null;
  1132. // }
  1133. //}
  1134.  
  1135. //Helper functions
  1136.  
  1137. function addGlobalStyle(css) {
  1138. var head, style;
  1139. head = document.getElementsByTagName('head')[0];
  1140. if (!head) {
  1141. return;
  1142. }
  1143. style = document.createElement('style');
  1144. style.type = 'text/css';
  1145. style.innerHTML = css;
  1146. head.appendChild(style);
  1147. }
  1148.  
  1149. function addStyle(ID, css) {
  1150. var head, style;
  1151. head = document.getElementsByTagName('head')[0];
  1152. if (!head) {
  1153. return;
  1154. }
  1155. removeStyle(ID); // in case it is already there
  1156. style = document.createElement('style');
  1157. style.type = 'text/css';
  1158. style.innerHTML = css;
  1159. style.id = ID;
  1160. head.appendChild(style);
  1161. }
  1162.  
  1163. function removeStyle(ID) {
  1164. var style = document.getElementById(ID);
  1165. if (style) { style.parentNode.removeChild(style); }
  1166. }
  1167.  
  1168. function getElementsByClassName(classname, node) {
  1169. if(!node) { node = document.getElementsByTagName("body")[0]; }
  1170. var a = [];
  1171. var re = new RegExp('\\b' + classname + '\\b');
  1172. var els = node.getElementsByTagName("*");
  1173. for (var i=0,j=els.length; i<j; i++) {
  1174. if (re.test(els[i].className)) { a.push(els[i]); }
  1175. }
  1176. return a;
  1177. }
  1178.  
  1179. function getId(node) {
  1180. return document.getElementById(node);
  1181. }
  1182.  
  1183. function logit(msg, typ) {
  1184. if (!typ) {
  1185. console.log(prefix + ": " + msg);
  1186. } else {
  1187. switch(typ) {
  1188. case "error":
  1189. console.error(prefix + ": " + msg);
  1190. break;
  1191. case "warning":
  1192. console.warn(prefix + ": " + msg);
  1193. break;
  1194. case "info":
  1195. console.info(prefix + ": " + msg);
  1196. break;
  1197. case "debug":
  1198. if (debug) {
  1199. console.debug(prefix + ": " + msg);
  1200. }
  1201. break;
  1202. default:
  1203. console.log(prefix + " unknown message type: " + msg);
  1204. break;
  1205. }
  1206. }
  1207. }
  1208.  
  1209. // Start it running
  1210. setTimeout(init1, 200);
  1211. })();