WME Fix UI

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

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

  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.4
  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, JustinS83
  18.  
  19. (function()
  20. {
  21. // global variables
  22. var wmefu_version = "2.4";
  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 = shrinkTopBars;
  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. // event to recreate my tab after changing WME units
  119. Waze.prefs.on('change:isImperial', function() {
  120. // code to restore tab goes here
  121. tabAttempts = 0;
  122. tabsLooper();
  123. if (_cbShrinkTopBars.checked === true) {
  124. hackToolbarButtons();
  125. }
  126. });
  127. //event to re-hack toolbar buttons on exiting HN mode
  128. Waze.editingMediator.on('change:editingHouseNumbers', function() {
  129. if (_cbShrinkTopBars.checked === true) {
  130. hackToolbarButtons();
  131. }
  132. });
  133. // events for Aerial Shifter
  134. Waze.map.events.register("zoomend", null, shiftAerials);
  135. Waze.map.events.register("moveend", null, shiftAerials);
  136. Waze.map.baseLayer.events.register("loadend", null, shiftAerials);
  137. // event to deal with ASC controls and make place address clickable
  138. Waze.selectionManager.events.register("selectionchanged", null, hideAveSpeedControls);
  139. // events to change menu bar color based on map comments checkbox
  140. Waze.map.events.register("zoomend", null, warnCommentsOff);
  141. Waze.map.events.register("moveend", null, warnCommentsOff);
  142.  
  143. // overload the window unload function to save my settings
  144. window.addEventListener("beforeunload", saveSettings, false);
  145.  
  146. loadSettings();
  147. // Add an extra checkbox so I can test segment panel changes easily
  148. if (Waze.loginManager.user.userName == 'iainhouse') {
  149. logit("creating segment detail debug checkbox","info");
  150. var brand = getId('brand');
  151. var extraCBSection = document.createElement('p');
  152. extraCBSection.innerHTML = '<input type="checkbox" id="_cbextraCBSection" />';
  153. brand.appendChild(extraCBSection);
  154. getId('_cbextraCBSection').onclick = FALSEcompressSegmentTab;
  155. getId('_cbextraCBSection').checked = getId('_cbCompressSegmentTab').checked;
  156. }
  157. // warn of permalink segments not all selected
  158. URLSegments = window.location.search.match(new RegExp("[?&]segments?=([^&]*)"));
  159. if (URLSegments) {
  160. URLSegmentCount = URLSegments[1].split(',').length;
  161. if (Waze.selectionManager.selectedItems.length > 0) {
  162. permalinkCheck();
  163. } else {
  164. Waze.selectionManager.events.register("selectionchanged", null, permalinkCheck);
  165. }
  166. }
  167.  
  168. // Alert to new version
  169. if (oldVersion != wmefu_version) {
  170. alert("WME Fix UI has been updated to version " + wmefu_version +
  171. "\n" +
  172. "\nVersion 2.4 - 2017-11-12" +
  173. "\n" +
  174. "\n* Top bar compression/enhancement re-written for new UI." +
  175. "\n* Recovery from unit change & house number mode implemented." +
  176. "\n* Minor tweaks to left panel compression." +
  177. "\n" +
  178. "\nVersion 2.3 - 2017-11-08" +
  179. "\n" +
  180. "\n* The zoom bar is back, with permanent level indicator." +
  181. "\n" +
  182. "\nVersion 2.2 - 2017-11-03" +
  183. "\n" +
  184. "\n* More tweaks to Segment details enhancement." +
  185. "\n* Place details enhancement completed." +
  186. "\n* New option to darken screen overlay when saving." +
  187. "\n" +
  188. "\nVersion 2.1 - 2017-10-28" +
  189. "\n" +
  190. "\nSettings not yet fully compatible with WME V2 will be turned off on script update." +
  191. // ((getId("_cbAddzoomindicator").checked === true) ? "\n* Zoom level indicator turned off - not yet working properly in WME V2" : "") +
  192. // ((getId("_cbShrinkTopBars").checked === true) ? "\n* Shrink bars above map turned off - not yet working properly in WME V2" : "") +
  193. ((getId("_cbRestyleReports").checked === true) ? "\n* Restyle reports turned off - not yet working properly in WME V2" : "") +
  194. ((getId("_cbNarrowSidePanel").checked === true) ? "\n* Reduce width of side panel turned off - not yet working properly in WME V2" : "") +
  195. "\n" +
  196. "\nVersion 2.0.1 - 2017-10-27" +
  197. "\n" +
  198. "\nMinor update to re-instate 'Fix external providers'." +
  199. "\n" +
  200. "\nVersion 2.0 - 2017-10-25" +
  201. "\n" +
  202. "\nWME 2 is released, so WME FixUI is also out of beta." +
  203. "\n" +
  204. "\n* New operation with variable & independent compression/contrast enhancements" +
  205. "\n" +
  206. "\n* Updated handling for Feed, Drives and Areas" +
  207. "\n" +
  208. "\n* Segment edit panel updates completed" +
  209. "\n" +
  210. "\n* Disable map blocker removed - no longer needed" +
  211. "\n* Layers menu autohide removed - no longer needed" +
  212. "\n* Make place address clickable removed - no longer needed" +
  213. "\n* Fix external providers removed - no longer needed" +
  214. "\n");
  215. saveSettings();
  216. // if (getId("_cbAddZoomIndicator").checked === true) getId("_cbAddZoomIndicator").checked = false;
  217. // if (getId("_cbShrinkTopBars").checked === true) getId("_cbShrinkTopBars").checked = false;
  218. if (getId("_cbRestyleReports").checked === true) getId("_cbRestyleReports").checked = false;
  219. if (getId("_cbNarrowSidePanel").checked === true) getId("_cbNarrowSidePanel").checked = false;
  220. }
  221.  
  222. // fix for sidebar display problem in Safari, requested by edsonajj
  223. var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  224. if (isSafari) {
  225. addGlobalStyle('.flex-parent { height: 99% !important; }');
  226. }
  227. // apply the settings
  228. shiftAerials();
  229. setTimeout(applyAllSettings, 2000);
  230. logit("Initialisation complete");
  231. console.timeEnd(prefix + ": initialisation time");
  232. console.groupEnd();
  233. }
  234.  
  235. function createAddon() {
  236. //create the contents of my side-panel tab
  237. var addon = document.createElement('section');
  238. var section = document.createElement('p');
  239. addon.id = "sidepanel-FixUI";
  240. section.style.paddingTop = "0px";
  241. section.style.lineHeight = "16px";
  242. section.id = "fuContent";
  243. section.innerHTML = "";
  244. section.innerHTML += '<b>UI Fixes/changes</b><br>';
  245. section.innerHTML += '<input type="checkbox" id="_cbMoveZoomBar" /> ' +
  246. '<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 and restore zoom bar</span><br>';
  247. // section.innerHTML += '<input style="display:none" type="checkbox" id="_cbAddZoomIndicator" /> ' +
  248. // '<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>';
  249. section.innerHTML += '<input type="checkbox" id="_cbHideUserInfo" /> ' +
  250. '<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>';
  251. section.innerHTML += '<input type="checkbox" id="_cbHideAveSpeedControls" /> ' +
  252. '<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>';
  253. section.innerHTML += '<input type="checkbox" id="_cbFixExternalProviders" /> ' +
  254. '<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>';
  255. //x section.innerHTML += '<input type="checkbox" id="_cbClickablePlaceAddress" /> ' +
  256. //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>';
  257. section.innerHTML += '<input type="checkbox" id="_cbPermalinkChecker" /> ' +
  258. '<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>';
  259. section.innerHTML += '<input type="checkbox" id="_cbMoveChatIcon" /> ' +
  260. '<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>';
  261. section.innerHTML += '<input type="checkbox" id="_cbLayersMenuMoreOptions" /> ' +
  262. '<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>';
  263. section.innerHTML += '<input type="checkbox" id="_cbDarkenSaveLayer" /> ' +
  264. '<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>';
  265. section.innerHTML += '<br>';
  266. section.innerHTML += '<b>UI Enhancements</b><br>';
  267. section.innerHTML += '<input type="checkbox" id="_cbShrinkTopBars" /> ' +
  268. '<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.\nAnd why does the reload button have a re-do icon?!">Compress/enhance bars above the map</span><br>';
  269. section.innerHTML += '<input type="checkbox" id="_cbCompressSegmentTab" /> ' +
  270. '<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>';
  271. section.innerHTML += '<input type="checkbox" id="_cbCompressLayersMenu" /> ' +
  272. '<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>';
  273. section.innerHTML += '<input type="checkbox" id="_cbRestyleReports" /> ' +
  274. '<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>';
  275. section.innerHTML += '<input type="checkbox" id="_cbNarrowSidePanel" /> ' +
  276. '<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>';
  277. if (UIver == "new") {
  278. section.innerHTML += '<br>';
  279. section.innerHTML += '<b title="Control the amount of compression/enhancment">UI Enhancement controls<br>';
  280. 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;';
  281. 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>';
  282. section.innerHTML += '<br>';
  283. section.innerHTML += '<br>';
  284. }
  285. section.innerHTML += '<b title="Shift aerial images layer to match GPS tracks and reduce image opacity">Aerial Shifter</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  286. section.innerHTML += '<span class="fa fa-power-off" id="_resetAS" title="Clear X/Y offsets"></span><br>';
  287. 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>';
  288. 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>';
  289. 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>';
  290. section.innerHTML += '<br>';
  291. section.innerHTML += '<br>';
  292.  
  293. section.innerHTML += '<b title="Adjust contrast & brightness for Google Street View images">GSV image adjust</b><br>';
  294. 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;';
  295. 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;';
  296. section.innerHTML += '<span title="Invert colours"><input type="checkbox" id="_cbGSVInvert"/><span class="fa fa-tint"></span></span>';
  297.  
  298. section.innerHTML += '<br>';
  299. section.innerHTML += '<br>';
  300. section.innerHTML += '<b><a href="https://www.waze.com/forum/viewtopic.php?f=819&t=191178" title="Forum topic" target="_blank"><u>' +
  301. 'WME Fix UI</u></a></b> &nbsp; v' + wmefu_version;
  302. addon.appendChild(section);
  303. addon.className = "tab-pane";
  304. return addon;
  305. }
  306.  
  307. function addMyTab(model,modeID) {
  308. if (modeID === 0) {
  309. logit("entering default mode, so creating tab");
  310. tabAttempts = 0;
  311. tabsLooper();
  312. } else {
  313. logit("entering event mode, so not initialising");
  314. return;
  315. }
  316. }
  317.  
  318. function tabsLooper() {
  319. tabAttempts += 1;
  320. if (tabAttempts > 20) {
  321. // tried 20 times to create tab without luck
  322. logit("unable to create my tab after 20 attempts","error");
  323. return;
  324. }
  325. var userTabs = getId('user-info');
  326. var navTabs = getElementsByClassName('nav-tabs', userTabs)[0];
  327. if (typeof navTabs === "undefined") {
  328. //the basic tabs aren't there yet, so I can't add mine
  329. logit("waiting for NavTabs","warning");
  330. setTimeout(tabsLooper, 200);
  331. } else{
  332. var tabContent = getElementsByClassName('tab-content', userTabs)[0];
  333. newtab = document.createElement('li');
  334. newtab.innerHTML = '<a href="#sidepanel-FixUI" data-toggle="tab" title="Fix UI">FU</a>';
  335. navTabs.appendChild(newtab);
  336. tabContent.appendChild(wmeFUAddon);
  337. if (_cbShrinkTopBars.checked === true) {
  338. hackToolbarButtons();
  339. }
  340. }
  341. }
  342.  
  343. function loadSettings() {
  344. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  345. logit("function " + fname + " called", "debug");
  346. // Convert old version of settings to new version
  347. var options;
  348. if (localStorage.WMEFixUI) {
  349. var oldSettings = JSON.parse(localStorage.WMEFixUI);
  350. var newSettings = {};
  351. newSettings.oldVersion = (oldSettings[0] ? oldSettings[0] : "1.0" );
  352. newSettings.moveZoomBar = (oldSettings[1] ? oldSettings[1] : true );
  353. newSettings.shrinkTopBars = (oldSettings[2] ? oldSettings[2] : true );
  354. newSettings.hideUserInfo = (oldSettings[3] ? oldSettings[3] : true );
  355. newSettings.restyleSidePanel = (oldSettings[4] ? oldSettings[4] : true );
  356. newSettings.restyleReports = (oldSettings[5] ? oldSettings[5] : true );
  357. newSettings.narrowSidePanel = (oldSettings[7] ? oldSettings[7] : false );
  358. newSettings.hideASCControls = (oldSettings[8] ? oldSettings[8] : false );
  359. // newSettings.addZoomIndicator = (oldSettings[9] ? oldSettings[9] : true );
  360. newSettings.aerialShiftX = (oldSettings[10] ? oldSettings[10] : 0 );
  361. newSettings.aerialShiftY = (oldSettings[11] ? oldSettings[11] : 0 );
  362. newSettings.aerialOpacity = (oldSettings[12] ? oldSettings[12] : 100 );
  363. newSettings.fixExternalProviders = (oldSettings[13] ? oldSettings[13] : true );
  364. newSettings.GSVContrast = (oldSettings[14] ? oldSettings[14] : 100 );
  365. newSettings.GSVBrightness = (oldSettings[15] ? oldSettings[15] : 100 );
  366. newSettings.GSVInvert = (oldSettings[16] ? oldSettings[16] : false );
  367. //x newSettings.clickablePlaceAddress = (oldSettings[17] ? oldSettings[17] : true );
  368. newSettings.permalinkChecker = (oldSettings[18] ? oldSettings[18] : true );
  369. newSettings.restyleLayersMenu = (oldSettings[19] ? oldSettings[19] : true );
  370. newSettings.moveChatIcon = (oldSettings[20] ? oldSettings[20] : true );
  371. // setting[21] was Menu Autohide - no longer needed
  372. newSettings.layersMenuMore = (oldSettings[22] ? oldSettings[22] : true );
  373. localStorage.WMEFUSettings = JSON.stringify(newSettings);
  374. localStorage.removeItem("WMEFixUI");
  375. }
  376.  
  377. if (localStorage.WMEFUSettings) {
  378. options = JSON.parse(localStorage.WMEFUSettings);
  379. } else {
  380. options = {};
  381. }
  382. oldVersion = (options.oldVersion !== undefined ? options.oldVersion : "0.0");
  383. getId('_cbMoveZoomBar').checked = (options.moveZoomBar !== undefined ? options.moveZoomBar : true);
  384. getId('_cbShrinkTopBars').checked = (options.shrinkTopBars !== undefined ? options.shrinkTopBars : true);
  385. getId('_cbHideUserInfo').checked = ( options.hideUserInfo !== undefined ? options.hideUserInfo : true);
  386. getId('_cbCompressSegmentTab').checked = ( options.restyleSidePanel !== undefined ? options.restyleSidePanel : true);
  387. getId('_cbRestyleReports').checked = ( options.restyleReports !== undefined ? options.restyleReports : true);
  388. getId('_cbNarrowSidePanel').checked = ( options.narrowSidePanel !== undefined ? options.narrowSidePanel : false);
  389. getId('_cbHideAveSpeedControls').checked = ( options.hideASCControls !== undefined ? options.hideASCControls : false);
  390. // getId('_cbAddZoomIndicator').checked = ( options.addZoomIndicator !== undefined ? options.addZoomIndicator : true);
  391. getId('_inpASX').value = ( options.aerialShiftX !== undefined ? options.aerialShiftX : 0);
  392. getId('_inpASY').value = ( options.aerialShiftY !== undefined ? options.aerialShiftY : 0);
  393. getId('_inpASO').value = ( options.aerialOpacity !== undefined ? options.aerialOpacity : 100);
  394. getId('_cbFixExternalProviders').checked = ( options.fixExternalProviders !== undefined ? options.fixExternalProviders : true);
  395. getId('_inpGSVContrast').value = ( options.GSVContrast !== undefined ? options.GSVContrast : 100);
  396. getId('_inpGSVBrightness').value = ( options.GSVBrightness !== undefined ? options.GSVBrightness : 100);
  397. getId('_cbGSVInvert').checked = ( options.GSVInvert !== undefined ? options.GSVInvert : false);
  398. //x getId('_cbClickablePlaceAddress').checked = ( options.clickablePlaceAddress !== undefined ? options.clickablePlaceAddress : true);
  399. getId('_cbPermalinkChecker').checked = ( options.permalinkChecker !== undefined ? options.permalinkChecker : true);
  400. getId('_cbCompressLayersMenu').checked = ( options.restyleLayersMenu !== undefined ? options.restyleLayersMenu : true);
  401. getId('_cbMoveChatIcon').checked = ( options.moveChatIcon !== undefined ? options.moveChatIcon : true);
  402. getId('_cbDarkenSaveLayer').checked = ( options.darkenSaveLayer !== undefined ? options.darkenSaveLayer : true);
  403. getId('_cbLayersMenuMoreOptions').checked = ( options.layersMenuMore !== undefined ? options.layersMenuMore : true);
  404. if (UIver == "new") {
  405. getId('_inpUIContrast').value = ( options.UIContrast !== undefined ? options.UIContrast : 1);
  406. getId('_inpUICompression').value = ( options.UICompression !== undefined ? options.UICompression : 1);
  407. }
  408. }
  409.  
  410. function saveSettings() {
  411. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  412. logit("function " + fname + " called", "debug");
  413. if (localStorage) {
  414. logit("saving options to local storage");
  415. var options = {};
  416. options.oldVersion = wmefu_version;
  417. options.moveZoomBar = getId('_cbMoveZoomBar').checked;
  418. options.shrinkTopBars = getId('_cbShrinkTopBars').checked;
  419. options.hideUserInfo = getId('_cbHideUserInfo').checked;
  420. options.restyleSidePanel = getId('_cbCompressSegmentTab').checked;
  421. options.restyleReports = getId('_cbRestyleReports').checked;
  422. options.narrowSidePanel = getId('_cbNarrowSidePanel').checked;
  423. options.hideASCControls = getId('_cbHideAveSpeedControls').checked;
  424. // options.addZoomIndicator = getId('_cbAddZoomIndicator').checked;
  425. options.aerialShiftX = getId('_inpASX').value;
  426. options.aerialShiftY = getId('_inpASY').value;
  427. options.aerialOpacity = getId('_inpASO').value;
  428. options.fixExternalProviders = getId('_cbFixExternalProviders').checked;
  429. options.GSVContrast = getId('_inpGSVContrast').value;
  430. options.GSVBrightness = getId('_inpGSVBrightness').value;
  431. options.GSVInvert = getId('_cbGSVInvert').checked;
  432. //x options.clickablePlaceAddress = getId('_cbClickablePlaceAddress').checked;
  433. options.permalinkChecker = getId('_cbPermalinkChecker').checked;
  434. options.restyleLayersMenu = getId('_cbCompressLayersMenu').checked;
  435. options.moveChatIcon = getId('_cbMoveChatIcon').checked;
  436. options.darkenSaveLayer = getId('_cbDarkenSaveLayer').checked;
  437. options.layersMenuMore = getId('_cbLayersMenuMoreOptions').checked;
  438. if (UIver == "new") {
  439. options.UIContrast = getId('_inpUIContrast').value;
  440. options.UICompression = getId('_inpUICompression').value;
  441. }
  442. localStorage.WMEFUSettings = JSON.stringify(options);
  443. }
  444. }
  445.  
  446. function applyAllSettings() {
  447. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  448. logit("function " + fname + " called", "debug");
  449. console.group(prefix + ": applying all settings");
  450. moveZoomBar();
  451. shrinkTopBars();
  452. hideUserInfo();
  453. compressSegmentTab();
  454. restyleReports();
  455. narrowSidePanel();
  456. hideAveSpeedControls();
  457. fixExternalProviders();
  458. // addZoomIndicator();
  459. warnCommentsOff();
  460. adjustGSV();
  461. compressLayersMenu();
  462. moveChatIcon();
  463. darkenSaveLayer();
  464. // layersMenuAutoHide();
  465. console.groupEnd();
  466. if (getId('_cbLayersMenuMoreOptions').checked === true) {
  467. $("#toolbar > div > div.layer-switcher-container > div > div > div > div > div.menu > div.more-options-toggle > label > div").click();
  468. }
  469. wmeFUinitialising = false;
  470. saveSettings();
  471. }
  472.  
  473. function applyEnhancements() {
  474. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  475. logit("function " + fname + " called", "debug");
  476. shrinkTopBars();
  477. compressSegmentTab();
  478. restyleReports();
  479. compressLayersMenu();
  480. }
  481.  
  482. function moveZoomBar() {
  483. // Now functioning correctly for prod & beta
  484. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  485. logit("function " + fname + " called", "debug");
  486. if (_cbMoveZoomBar.checked) {
  487. var styles = "";
  488. if (UIver == "old") {
  489. styles += '.olControlPanZoomBar { left: 10px; width: 30px; }';
  490. // shift UR/MP panel to the right
  491. styles += '#panel-container > div { left: 40px; }';
  492. } else {
  493. styles += '.olControlPanZoomBar { left: 10px; top: 35px; height: 158px; border-width: 1px; }';
  494. styles += '.zoom-minus-button { top: 0px !important; }';
  495. styles += '.slider-stops { display: inherit; width: 24px; height: 109px !important; }';
  496. styles += '.slider { font-size: 15px; font-weight: 900; line-height: 1; height: 18px; margin-top: 19px; padding-top: 1px; width: 24px; border: 1px solid lightgrey; text-align: center; }';
  497. styles += '.street-view-control-container { bottom: -40px; margin-right: -3px; }';
  498. styles += '.geolocation-control-container { bottom: -79px; margin-right: -3px; id: "WMEFU"; }';
  499. // fix for WME Map Tiles Update script
  500. styles += '#Info_div { margin-top: 89px !important; margin-left: 2px !important; }';
  501. // fix for WME BeenHere - old but I still use it :)
  502. styles += '#BeenHere { top: 310px !important; }';
  503. // shift UR/MP panel to the right
  504. styles += '#panel-container > div { left: 40px; }';
  505. Waze.map.events.register("zoomend", null, ZLI);
  506. ZLI();
  507. }
  508. addStyle(prefix + fname,styles);
  509. } else {
  510. var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
  511. removeStyle(prefix + fname);
  512. Waze.map.events.unregister("zoomend", null, ZLI);
  513. slider.innerText = "";
  514. slider.title = "";
  515. }
  516. }
  517.  
  518. function hideUserInfo() {
  519. // Now functioning correctly for prod & beta
  520. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  521. logit("function " + fname + " called", "debug");
  522. var styles = "";
  523. // WME Panel Swap buttons - move them up if user info is hidden
  524. var PSButton1 = getId('WMEPS_UIButton');
  525. var PSButton2 = getId('WMEPS_EditButton');
  526. if (_cbHideUserInfo.checked) {
  527. styles += '#user-box { display: none; }';
  528. // extra fix for WME Panel Swap control (not working with new WME UI)
  529. if (PSButton1) { PSButton1.style.top = '-27px'; }
  530. if (PSButton2) { PSButton2.style.top = '-27px'; }
  531. addStyle(prefix + fname,styles);
  532. //Fix to move control button of Invalidated Camera Mass Eraser
  533. if (getId("_UCME_btn")) {
  534. var but = getId("_UCME_btn");
  535. var dest = getId("advanced-tools");
  536. getId("advanced-tools").appendChild(getId("_UCME_btn"));
  537. document.getElementById('UCME_btn').parentNode.removeChild(document.getElementById('UCME_btn'));
  538. }
  539. } else {
  540. if (PSButton1) { PSButton1.style.top = '0px'; }
  541. if (PSButton2) { PSButton2.style.top = '0px'; }
  542. removeStyle(prefix + fname);
  543. }
  544. }
  545.  
  546. function shrinkTopBars() {
  547. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  548. logit("function " + fname + " called", "debug");
  549. var styles = "";
  550. if (_cbShrinkTopBars.checked) {
  551. //always do this stuff
  552. //event mode button
  553. styles += '#mode-switcher .title-button .icon { font-size: 13px; font-weight: bold; color: black; }';
  554. //black bar
  555. styles += '#map #topbar-container { width: auto; }';
  556. //change toolbar buttons - from JustinS83
  557. $('#mode-switcher .title-button .icon').removeClass('fa fa-angle-down')
  558. $('#mode-switcher .title-button .icon').addClass('fa fa-calendar')
  559. hackToolbarButtons();
  560. // HN editing tweaks
  561. styles += '#map-lightbox .content { width: fit-content; }';
  562. styles += '.toolbar .toolbar-button.add-house-number { background-color: #61cbff; float: right; font-weight: bold; }';
  563. styles += '.waze-icon-exit { background-color: #61cbff; font-weight: bold; }';
  564. // event mode button
  565. styles += '.toolbar.toolbar-mte .add-button { background-color: orange; font-weight: bold; }';
  566. var contrast = _inpUIContrast.value;
  567. var compress = _inpUICompression.value;
  568. if (compress > 0) {
  569. styles += '#app-head { height: ' + ['','35px','24px'][compress] + '; }';
  570. styles += '#app-head aside #brand { height: ' + ['','34px','22px'][compress] + '; padding-left: ' + ['','10px','5px'][compress] + '; }';
  571. styles += '.toolbar { height: ' + ['','35px','24px'][compress] + '; }';
  572. styles += '#mode-switcher .title-button .icon { line-height: ' + ['','34px','22px'][compress] + '; }';
  573. //search box
  574. styles += '#search { padding-top: ' + ['','3px','0px'][compress] + '; }';
  575. styles += '.form-search { height: ' + ['','27px','20px'][compress] + '; }';
  576. styles += '.form-search .search-query { height: ' + ['','26px','19px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  577. styles += '.form-search .input-wrapper::after { top: ' + ['','6px','2px'][compress] + '; }';
  578. //toolbar dropdown menus
  579. //Toolbox switcher
  580. styles += '#toolbox-switcher .toolbar-button { margin-top: 0px; line-height: ' + ['','34px','22px'][compress] + '; }';
  581. styles += '#toolbox-switcher .fa { margin-right: ' + ['','5px','0px'][compress] + ' !important; }';
  582. //Toolbox menu
  583. styles += '.toolbox-dropdown-menu { top: ' + ['','17px','12px'][compress] + ' !important; }';
  584. //toolbar dropdowns
  585. styles += '.toolbar .toolbar-group { margin-right: ' + ['','14px','8px'][compress] + '; }';
  586. styles += '.toolbar .toolbar-icon { width: ' + ['','31px','22px'][compress] + '; height: ' + ['','34px','22px'][compress] + '; line-height: ' + ['','34px','22px'][compress] + '; }';
  587. styles += '.toolbar .group-title { height: ' + ['','34px','22px'][compress] + '; line-height: ' + ['','34px','22px'][compress] + '; margin-left: ' + ['','31px','22px'][compress] + '; }';
  588. styles += '.toolbar .dropdown-menu { top: ' + ['','34px','22px'][compress] + ' !important; left: ' + ['','7px','4px'][compress] + ' !important; }';
  589. //toolbar buttons
  590. styles += '#edit-buttons > div > .toolbar-button { margin-top: ' + ['','3px','1px'][compress] + '; margin-left: 3px; padding-left: ' + ['','10px','5px'][compress] + '; padding-right: ' + ['','10px','5px'][compress] + '; height: ' + ['','27px','22px'][compress] + '; line-height: ' + ['','27px','22px'][compress] + '; }';
  591. //keep save button wide enough for counter
  592. styles += '.toolbar .toolbar-button.waze-icon-save { padding-right: 15px !important; }';
  593. styles += '.toolbar .toolbar-button.waze-icon-save .counter { top: ' + ['','-3px','-1px'][compress] + '; }';
  594. styles += '#edit-buttons > div > .toolbar-button > .item-icon { top: ' + ['','5px','2px'][compress] + '; }';
  595. styles += '.toolbar .toolbar-separator { height: ' + ['','34px','22px'][compress] + '; }';
  596. //layers menu
  597. styles += '.waze-icon-layers { height: ' + ['','27px','22px'][compress] + ' !important; margin-top: ' + ['','3px','0px'][compress] + ' !important; }';
  598. styles += '.layer-switcher .menu { top: ' + ['','31px','24px'][compress] + '; }';
  599. // fix for WME Edit Count Monitor
  600. styles += '#edit-buttons > div > div:nth-child(10) { margin-top: ' + ['','5px','-1px'][compress] + ' !important; }';
  601. //black bar
  602. styles += '.topbar { height: ' + ['','24px','18px'][compress] + '; line-height: ' + ['','24px','18px'][compress] + '; }';
  603. }
  604. if (contrast > 0) {
  605. //toolbar dropdown menus
  606. styles += '.toolbar .group-title { color: black; }';
  607. styles += '#edit-buttons > div > .toolbar-button { border-radius: 8px; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; color: black; }';
  608. }
  609. //Toolbox width override - can go with next TB update
  610. styles += '#edit-buttons { width: unset !important; }';
  611. // //fix for buttons of WME GIS script
  612. // styles += '.btn-group-sm { text-shadow: initial; background: white; }';
  613. addStyle(prefix + fname,styles);
  614. } else {
  615. removeStyle(prefix + fname);
  616. //change toolbar buttons - from JustinS83
  617. $('#mode-switcher .title-button .icon').removeClass('fa fa-calendar')
  618. $('#mode-switcher .title-button .icon').addClass('fa fa-angle-down')
  619. unHackToolbarButtons();
  620. }
  621. window.dispatchEvent(new Event('resize'));
  622. }
  623.  
  624. function hackToolbarButtons() {
  625. if (document.getElementsByClassName("waze-icon-reload").length > 0) {
  626. $('.waze-icon-reload').removeClass('reload');
  627. $('.waze-icon-reload span').addClass('fa fa-refresh fa-lg');
  628. $('.waze-icon-reload span')[0].innerHTML = "";
  629. }
  630. if (document.getElementsByClassName("waze-icon-undo").length > 0) {
  631. $('.waze-icon-undo').removeClass('undo');
  632. $('.waze-icon-undo span').addClass('fa fa-undo fa-lg');
  633. $('.waze-icon-undo span')[0].innerHTML = "";
  634. }
  635. if (document.getElementsByClassName("waze-icon-redo").length > 0) {
  636. $('.waze-icon-redo').removeClass('redo');
  637. $('.waze-icon-redo span').addClass('fa fa-repeat fa-lg');
  638. $('.waze-icon-redo span')[0].innerHTML = "";
  639. }
  640. }
  641.  
  642. function unHackToolbarButtons() {
  643. if (document.getElementsByClassName("waze-icon-reload").length > 0) {
  644. $('.waze-icon-reload span').removeClass('fa fa-refresh fa-lg');
  645. $('.waze-icon-reload').addClass('reload');
  646. $('.waze-icon-reload span')[0].innerHTML = "Reload";
  647. }
  648. if (document.getElementsByClassName("waze-icon-undo").length > 0) {
  649. $('.waze-icon-undo span').removeClass('fa fa-undo fa-lg');
  650. $('.waze-icon-undo').addClass('undo');
  651. $('.waze-icon-undo span')[0].innerHTML = "Undo";
  652. }
  653. if (document.getElementsByClassName("waze-icon-redo").length > 0) {
  654. $('.waze-icon-redo span').removeClass('fa fa-repeat fa-lg');
  655. $('.waze-icon-redo').addClass('redo');
  656. $('.waze-icon-redo span')[0].innerHTML = "Redo";
  657. }
  658. }
  659.  
  660.  
  661.  
  662. function FALSEcompressSegmentTab() {
  663. _cbCompressSegmentTab.checked = _cbextraCBSection.checked;
  664. compressSegmentTab();
  665. }
  666.  
  667. function compressSegmentTab() {
  668. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  669. logit("function " + fname + " called", "debug");
  670. var styles = "";
  671. if (_cbCompressSegmentTab.checked) {
  672. // shrink address
  673. if (UIver == "old") {
  674. styles += '#edit-panel .primary-street { font-size: 14px; line-height: 15px; font-weight: 600; color: black; }';
  675. styles += '#edit-panel .address-edit-view .preview .address-edit-btn:not(.disabled) { background-color: #FFF9C4; }';
  676. styles += '#edit-panel .segment .address-edit-view, .edit-panel .segment .address-edit-view { margin-bottom: 5px; }';
  677. //shrink tabs
  678. styles += '#sidebar .nav-tabs>li {margin-top: 2px; }';
  679. styles += '#sidebar .nav-tabs li a { padding: 2px; }';
  680. styles += '#sidebar .nav-tabs { margin: 0 0 5px 0; padding-left: 4px; }';
  681. //reduce some vertical margins
  682. styles += '#edit-panel .contents { padding: 0 5px 0 5px; overflow: hidden; }';
  683. styles += '#edit-panel .form-group { margin-bottom: 2px; line-height: 1; font-size: 11px; }';
  684. styles += '#edit-panel .selection { margin-bottom: 5px; }';
  685. styles += '#sidebar .side-panel-section:not(:last-child) { margin-bottom: 2px; }';
  686. styles += '#sidebar .side-panel-section:not(:last-child)::after { margin-top: 5px; margin-bottom: 2px; }';
  687. styles += '#edit-panel .control-label { margin-bottom: 1px; }';
  688. styles += '#sidebar .controls-container { padding-top: 2px; }';
  689. styles += '#edit-panel .segment .speed-limit label { margin-bottom: 0px; }';
  690. styles += '#edit-panel .more-actions { padding-top: 2px; }';
  691. styles += '#edit-panel .segment .speed-limit .direction-label, #edit-panel .segment .speed-limit .unit-label { line-height: 2.1em; }';
  692. styles += '#sidebar .side-panel-section~.side-panel-section:not(:last-child):before { margin: 5px -20px !important; }';
  693. styles += '#sidebar .side-panel-section~.side-panel-section:not(:last-child) { margin-top: 5px !important; }';
  694. //shrink dropdown controls & buttons
  695. styles += '#edit-panel button, #edit-panel select, #edit-panel .form-control { font-size: 11px; height: 19px; padding: 0px 4px; }';
  696. styles += '#edit-panel .more-actions button:not(:last-of-type) { margin-bottom: 2px; }';
  697. styles += '.edit-closure .input-group-addon { padding: 2px 8px; }';
  698. //fit road property checkboxes on one line for all three (if text length allows)
  699. styles += '#edit-panel .controls-container { display: inline-block; }';
  700. styles += '#edit-panel .controls-container label { font-size: 12px; line-height: 18px; padding-left: 22px; }';
  701. styles += '#edit-panel .select-entire-street { width: 49%; overflow: hidden; }';
  702. styles += '#edit-panel .edit-house-numbers { width: 49%; overflow: hidden; }';
  703. styles += '#edit-panel .action-button { color: black; }';
  704. styles += '#edit-panel .categories .select2-container { margin-bottom: -5px; }';
  705. //tweak for speed camera checkbox having a left margin of -20px. Why?!
  706. styles += '#edit-panel .checkbox, .radio { margin-left: 20px; }';
  707. //tweaks for Closures tab
  708. styles += '#edit-panel .segment .segment-details { margin-bottom: 4px; }';
  709. styles += '.closures-list .closure-item .section { padding: 2px; }';
  710. styles += '.col-xs-6 { line-height: 14px; }';
  711. styles += '.closures-list .direction { margin-bottom: 0px; }';
  712. styles += '.closures-list .closure-item:not(:last-child) { margin-bottom: 4px; }';
  713. //tweak required for Speedhelper script
  714. styles += 'div[id^="spd_"] { line-height: 1.43; }';
  715. //tweaks for Feed tab
  716. styles += '.feed-item { margin-bottom: 2px; }';
  717. styles += '.feed-item .inner { padding: 2px; }';
  718. styles += '.feed-item .delete { zoom: 149%; }';
  719. styles += '.feed-item .motivation { margin-bottom: 0px; }';
  720. styles += '.feed-item .content .title { margin-bottom: 0px; }';
  721. styles += '.feed-item .content .subtext { font-size: 11px; }';
  722. //tweaks for Drives tab
  723. styles += '#sidebar .message { margin-bottom: 0px; line-height: 14px; }';
  724. styles += '#sidebar .result-list .result { padding: 2px 5px; }';
  725. //tweaks for Restrictions dialogue
  726. styles += '#schedule-modal .modal-body { padding: 2px 8px; }';
  727. styles += '#schedule-modal .items { line-height: 0.5; }';
  728. styles += '#schedule-modal .table { margin-bottom: 10px; }';
  729. styles += '#schedule-modal .no-restrictions { margin-bottom: 10px; }';
  730. styles += '#schedule-modal .well { padding: 5px; }';
  731. styles += '#schedule-modal .edit-restriction .section { margin-bottom: 2px; padding: 0 2px; }';
  732. styles += '#schedule-modal .nav>li>a { padding: 2px 15px; }';
  733. styles += '#schedule-modal .btn { height: 22px; padding: 2px 15px; }';
  734. //tweaks for Map Comments
  735. styles += '.map-comment-feature-editor .conversation-region, .map-comment-feature-editor .name-editor-region { margin-left: -17px; margin-right: -5px; }';
  736. if (_cbNarrowSidePanel.checked) {
  737. styles += '.map-comment-feature-editor .conversation-view .new-comment-text { resize: both; max-width: 230px; }';
  738. } else {
  739. styles += '.map-comment-feature-editor .conversation-view .new-comment-text { resize: both; max-width: 310px; }';
  740. }
  741. //tweaks for History
  742. styles += '.toggleHistory { padding: 2px 12px 7px 12px; }';
  743. styles += '.tx-header { padding: 2px 15px 2px 15px !important; }';
  744. styles += '.tx-author-date { margin-bottom: 2px !important; }';
  745. styles += '.element-history-item { font-size: 11px; }';
  746. styles += '.tx-content { padding: 2px 15px 2px 15px !important; }';
  747. styles += '.tx-changed-ro:not(:last-child) { margin-bottom: 2px; }';
  748. styles += '.tx-changed-attribute .ca-name { margin-bottom: 2px; }';
  749. styles += '.tx-changed-attribute:not(:last-child) {margin-bottom: 2px; }';
  750. } else {
  751. //For new WME version
  752. var contrast = _inpUIContrast.value;
  753. var compress = _inpUICompression.value;
  754. if (compress > 0) {
  755. //general compression enhancements
  756. styles += '#sidebar #advanced-tools { padding: ' + ['','0 9px','0 4px'][compress] + '; }';
  757. styles += '#sidebar waze-staff-tools { margin-bottom: ' + ['','9px','4px'][compress] + '; }';
  758. styles += '#sidebar .tab-content { padding: ' + ['','9px','4px'][compress] + '; }';
  759. //Tabs
  760. styles += '#sidebar #user-info #user-tabs { padding: ' + ['','0 9px','0 4px'][compress] + '; }';
  761. styles += '#sidebar .nav-tabs li a { margin-top: ' + ['','2px','1px'][compress] + '; margin-left: ' + ['','3px','1px'][compress] + '; padding-top: 0px !important; line-height: ' + ['','24px','21px'][compress] + '; height: ' + ['','24px','21px'][compress] + '; }';
  762. styles += '#sidebar .nav-tabs li { flex-grow: 0; }';
  763. //Feed
  764. styles += '.feed-item { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  765. styles += '.feed-item .inner { padding: ' + ['','5px','0px'][compress] + '; }';
  766. styles += '.feed-item .content .title { margin-bottom: ' + ['','1px','0px'][compress] + '; }';
  767. styles += '.feed-item .motivation { margin-bottom: ' + ['','2px','0px'][compress] + '; }';
  768. //Drives & Areas
  769. styles += '#sidebar .message { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  770. styles += '#sidebar .result-list .result { padding: ' + ['','6px 17px','2px 9px'][compress] + '; margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  771. //SEGMENT EDIT PANEL
  772. //general changes
  773. //checkbox groups
  774. styles += '#sidebar .controls-container { padding-top: ' + ['','4px','1px'][compress] + '; display: inline-block; font-size: ' + ['','12px','11px'][compress] + '; }';
  775. //form groups
  776. styles += '#sidebar .form-group { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  777. //dropdown inputs
  778. styles += '#sidebar .form-control { height: ' + ['','28px','21px'][compress] + '; padding-top: ' + ['','4px','0px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; color: black; }';
  779. //buttons
  780. styles += '#edit-panel .waze-btn { padding-top: ' + ['','3px','1px'][contrast] + '; padding-bottom: ' + ['','3px','1px'][contrast] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  781. //radio button controls
  782. 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] + '; }';
  783. //specific changes
  784. //Selected segments info
  785. styles += '#edit-panel .selection { padding-top: ' + ['','8px','2px'][compress] + '; padding-bottom: ' + ['','8px','4px'][compress] + '; }';
  786. styles += '#edit-panel .segment .direction-message { margin-bottom: ' + ['','9px','3px'][compress] + '; }';
  787. //Segment details (closure warning)
  788. styles += '#edit-panel .segment .segment-details { padding: ' + ['','10px','5px'][compress] + '; padding-top: 0px; }';
  789. //All control labels
  790. styles += '#edit-panel .control-label { font-size: ' + ['','11px','10px'][compress] + '; margin-bottom: ' + ['','4px','2px'][compress] + '; }';
  791. //Address input
  792. styles += '#edit-panel .address-edit-view { cursor: pointer; margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  793. styles += '#edit-panel .address-edit-input { padding: ' + ['','4px','1px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  794. styles += '.tts-button { height: ' + ['','28px','21px'][compress] + '; }';
  795. //speed limit controls
  796. styles += '#edit-panel .segment .speed-limit .form-control { height: ' + ['','23px','19px'][compress] + '; padding-top: ' + ['','4px','2px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; width: 5em; }';
  797. styles += '#edit-panel .segment .speed-limit .direction-label { font-size: ' + ['','12px','11px'][compress] + '; line-height: ' + ['','2.0em','1.8em'][compress] + '; }';
  798. 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' ) + '; }';
  799. //more actions section
  800. styles += '#edit-panel .more-actions { padding-top: ' + ['','6px','2px'][compress] + '; }';
  801. 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; }';
  802. //get more-actions buttons on one line
  803. styles += '#edit-panel .more-actions { display: inline-flex; }';
  804. styles += '#edit-panel .action-button { width: 155px; overflow: hidden; }';
  805. styles += '#edit-panel .action-button:before { margin-right: 0px !important; }';
  806. styles += '#edit-panel .more-actions .edit-house-numbers-btn-wrapper { margin-top: 0px; }';
  807. //additional attributes
  808. styles += '#edit-panel .additional-attributes { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  809. //history items
  810. styles += '.toggleHistory { padding: ' + ['','7px','3px'][compress] + '; }';
  811. styles += '.element-history-item:not(:last-child) { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  812. styles += '.element-history-item .tx-header { padding: ' + ['','6px','2px'][compress] + '; }';
  813. styles += '.element-history-item .tx-header .tx-author-date { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  814. styles += '.element-history-item .tx-content { padding: ' + ['','7px 7px 7px 22px','4px 4px 4px 22px'][compress] + '; }';
  815. styles += '.loadMoreContainer { padding: ' + ['','5px 0px','3px 0px'][compress] + '; }';
  816. //closures list
  817. styles += '.closures-list .closure-item:not(:last-child) { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  818. styles += '.closures-list .closure-item .details { padding: ' + ['','5px','0px'][compress] + '; font-size: ' + ['','12px','11px'][compress] + '; }';
  819. styles += '.closures-list .closure-item .buttons { top: ' + ['','7px','4px'][compress] + '; }';
  820. //PLACE DETAILS
  821. //alert
  822. styles += '#edit-panel .header-alert { margin-bottom: ' + ['','6px','2px'][compress] + '; padding: ' + ['','6px','2px'][compress] + '; }';
  823. //address input
  824. styles += '#edit-panel .full-address { padding-top: ' + ['','4px','1px'][compress] + '; padding-bottom: ' + ['','4px','1px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  825. //alt names
  826. styles += '#edit-panel .aliases-view .list li { margin: ' + ['','12px 0','4px 0'][compress] + '; }';
  827. styles += '#edit-panel .aliases-view .delete { line-height: inherit; }';
  828. //categories
  829. 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] + '; }';
  830. styles += '#edit-panel .categories .select2-search-field input { height: ' + ['','18px','17px'][compress] + '; }';
  831. styles += '#edit-panel .categories .select2-choices { min-height: ' + ['','26px','19px'][compress] + '; }';
  832. styles += '#edit-panel .categories .select2-container { margin-bottom: 0px; }';
  833. //entry/exit points
  834. styles += '#edit-panel .navigation-point-view .navigation-point-list-item .preview { padding: ' + ['','3px 7px','0px 4px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  835. styles += '#edit-panel .navigation-point-view .add-button { height: ' + ['','28px','18px'][contrast] + '; line-height: ' + ['','17px','16px'][contrast] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  836. //type buttons
  837. styles += '#sidebar .area-btn, #sidebar .point-btn { height: ' + ['','19px','16px'][compress] + '; line-height: ' + ['','19px','16px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  838. // { height: ' + ['','19px','16px'][compress] + '; width: ' + ['','19px','16px'][compress] + '; line-height: ' + ['','19px','16px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  839. //external providers
  840. styles += '.select2-container { font-size: ' + ['','13px','12px'][compress] + '; }';
  841. styles += '#edit-panel .external-providers-view .external-provider-item { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  842. styles += '.external-providers-view > div > ul { margin-bottom: ' + ['','4px','0px'][compress] + '; }';
  843. styles += '#edit-panel .external-providers-view .add { padding: ' + ['','3px 12px','1px 9px'][compress] + '; }';
  844. styles += '#edit-panel .waze-btn.waze-btn-smaller { line-height: ' + ['','26px','21px'][compress] + '; }';
  845. //residential toggle
  846. styles += '#edit-panel .toggle-residential { height: ' + ['','27px','22px'][compress] + '; }';
  847. //more info
  848. styles += '.service-checkbox { font-size: ' + ['','13px','12px'][compress] + '; }';
  849. }
  850. if (contrast > 0) {
  851. //contrast enhancements
  852. //general
  853. //text colour
  854. styles += '#sidebar { color: black; }';
  855. //advanced tools section
  856. styles += '#sidebar waze-staff-tools { background-color: #c7c7c7; }';
  857. //Tabs
  858. styles += '#sidebar .nav-tabs li a { border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
  859. //Feed
  860. styles += '.feed-item { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  861. //Drives & Areas
  862. styles += '#sidebar .result-list .result { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  863. //Segment edit panel
  864. styles += '#edit-panel .selection { font-size: 13px; }';
  865. styles += '#edit-panel .segment .direction-message { color: orangered; }';
  866. styles += '#edit-panel .address-edit-input { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  867. styles += '#sidebar .form-control { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  868. //radio buttons when disabled
  869. styles += '.waze-radio-container input[type="radio"]:disabled:checked + label { color: black; opacity: 0.7; font-weight:600; }';
  870. //override border for lock levels
  871. styles += '#sidebar .waze-radio-container { border: 0 none !important; }';
  872. styles += '#edit-panel .waze-btn { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  873. styles += '.waze-radio-container label { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  874. //history items
  875. styles += '.toggleHistory { color: black; text-align: center; }';
  876. styles += '.element-history-item .tx-header { color: black; }';
  877. styles += '.element-history-item.closed .tx-header { border-radius: 8px; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  878. styles += '.loadMoreHistory { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  879. //closures list
  880. styles += '.closures-list .closure-item .details { border-radius: 8px; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  881. styles += '.closures-list .closure-item .dates { color: black; }';
  882. styles += '.closures-list .closure-item .dates .date-label { opacity: 1; }';
  883. //Place details
  884. //alert
  885. styles += '#edit-panel .alert-danger { color: red; }';
  886. //address input
  887. styles += '#edit-panel .full-address { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  888. styles += '#edit-panel a.waze-link { font-weight: bold; }';
  889. //categories
  890. styles += '#edit-panel .categories .select2-search-choice .category { text-transform: inherit; font-weight: bold; background: gray; }';
  891. //entry/exit points
  892. styles += '#edit-panel .navigation-point-view .navigation-point-list-item .preview { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  893. styles += '#edit-panel .navigation-point-view .add-button { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; margin-top: 2px; padding: 0 5px; }';
  894. //type buttons
  895. styles += '#sidebar .point-btn { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
  896. //external providers
  897. styles += '.select2-container { color: teal; border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
  898. styles += '.select2-container .select2-choice { color: black; }';
  899. //residential toggle
  900. styles += '#edit-panel .toggle-residential { font-weight: bold; }';
  901. }
  902. }
  903. //fix for buttons of WME Image Overlay script
  904. styles += '#sidepanel-imageoverlays > div.result-list button { height: 24px; }';
  905. addStyle(prefix + fname,styles);
  906. } else {
  907. removeStyle(prefix + fname);
  908. }
  909. }
  910.  
  911. function compressLayersMenu() {
  912. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  913. logit("function " + fname + " called", "debug");
  914. var styles = "";
  915. if (_cbCompressLayersMenu.checked) {
  916. // tweaks for layers menu
  917. if (document.getElementById('layer-switcher-list') === null) {
  918. //new style layers menu
  919. styles += '.layer-switcher { line-height: 11px; }';
  920. styles += '#layer-switcher .dropdown-menu .draggable .toggler .handle { height: 18px; }';
  921. styles += '.layer-switcher .togglers .group:not(:last-child):after { margin: 5px -7px -2px; }';
  922. styles += '.layer-switcher .more-options-toggle { height: 20px; line-height: 20px; }';
  923. } else {
  924. //old style layers menu
  925. styles += '.layer-switcher { line-height: 14px; }';
  926. }
  927. // styles += '.layer-switcher .toggler { padding-top: 0px; padding-bottom: 0px; }';
  928. addStyle(prefix + fname,styles);
  929. } else {
  930. removeStyle(prefix + fname);
  931. }
  932. }
  933.  
  934. function WrestyleReports() {
  935. if (getId("_cbRestyleReports").checked === true) {
  936. alert("You have enabled the 'Compress/enhance report panels' option\n"+
  937. "Please be aware that this function is not yet compatible with WME V2");
  938. }
  939. restyleReports();
  940. }
  941.  
  942. function restyleReports() {
  943. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  944. logit("function " + fname + " called", "debug");
  945. var styles = "";
  946. if (_cbRestyleReports.checked) {
  947. styles += '#panel-container .panel { font-size: 12px; line-height: 15px; }';
  948. styles += '#panel-container .problem-edit .header { padding: 5px; line-height: 15px; }';
  949. styles += '#panel-container .problem-edit .problem-data .title { line-height: 22px; }';
  950. styles += '#panel-container .problem-edit .section .title { padding: 0 5px; }';
  951. styles += '#panel-container .problem-edit .section .content { padding: 5px; }';
  952. styles += '#WMEFP-UR-ALLPM { top: -2px !important; }';
  953. styles += '#panel-container .problem-edit .conversation.section .comment .comment-content { padding: 0 5px; }';
  954. styles += '#panel-container .problem-edit .conversation.section .no-comments { padding: 0; }';
  955. styles += '#panel-container .problem-edit .conversation.section .new-comment-form { padding: 0; }';
  956. styles += '#panel-container .problem-edit .conversation.section .new-comment-form textarea { resize: vertical; height: 110px; margin-bottom: 0px; padding: 3px 5px; font-size: 12px; }';
  957. styles += '#panel-container .btn { height: 20px; padding: 0px 10px;}';
  958. styles += '#panel-container .problem-edit .actions .content { padding: 2px 5px;}';
  959. styles += '#panel-container .problem-edit .actions .controls-container label { margin-bottom: 0px; line-height: 22px }';
  960. styles += '#panel-container .problem-edit .actions .navigation { margin-top: 5px;}';
  961. styles += '#panel-container .problem-edit .actions .controls-container { display: inline-flex; flex-wrap: wrap; margin-left: -3px; }';
  962. styles += '#panel-container .input-max-length { text-align: right; margin-top: 0; white-space: nowrap; color: #3d3d3d; font-weight: 700; font-size: 11px; }';
  963. addStyle(prefix + fname,styles);
  964. // if (wmeFUinitialising) {
  965. // setTimeout(draggablePanel, 5000);
  966. // } else {
  967. // draggablePanel();
  968. // }
  969. } else {
  970. removeStyle(prefix + fname);
  971. // if (jQuery.ui) {
  972. // $("#panel-container").draggable("destroy");
  973. // getId("panel-container").style = "";
  974. // }
  975. }
  976. window.dispatchEvent(new Event('resize'));
  977. }
  978.  
  979. function draggablePanel() {
  980. if (jQuery.ui) {
  981. if ($("#panel-container").data("ui-draggable")) {
  982. $("#panel-container").draggable({ handle: ".header" });
  983. }
  984. }
  985. }
  986.  
  987. function WnarrowSidePanel() {
  988. if (getId("_cbNarrowSidePanel").checked === true) {
  989. alert("You have enabled the 'Reduce width of side panel' option\n"+
  990. "Please be aware that this function is not yet compatible with WME V2");
  991. }
  992. narrowSidePanel();
  993. }
  994.  
  995. function narrowSidePanel() {
  996. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  997. logit("function " + fname + " called", "debug");
  998. var styles = "";
  999. if (_cbNarrowSidePanel.checked) {
  1000. styles += '.row-fluid #sidebar { width: 250px; }';
  1001. styles += '.col-fixed-330 { width: 250px; }';
  1002. styles += '#sidebar waze-links { overflow: hidden; }';
  1003. styles += '#sidebar waze-links li+li::before { padding: 0; }';
  1004. styles += '#sidebar waze-links li { font-size: 10px; }';
  1005. styles += '#edit-panel .add-alt-street-form th.city { min-width: inherit; }';
  1006. styles += '#edit-panel .external-providers-view .select2-container { width: 100%; }';
  1007. if (document.body.dir != "rtl") {
  1008. styles += '.show-sidebar .row-fluid .fluid-fixed { margin-left: 250px; }';
  1009. styles += '.col-offset-330 { padding-left: 250px; }';
  1010. } else {
  1011. styles += '.show-sidebar .row-fluid .fluid-fixed { margin-right: 250px; }';
  1012. styles += '.col-offset-330 { padding-right: 250px; }';
  1013. }
  1014. styles += '.edit-closure .form { padding: 2px; }';
  1015. styles += '.edit-closure .date-input-group { width: 56%; }';
  1016. //for new WME
  1017. //styles += '#sidebar .tab-scroll-gradient { width: 242px; }';
  1018. //#sidebar #links:before
  1019. addStyle(prefix + fname, styles);
  1020. } else {
  1021. removeStyle(prefix + fname);
  1022. }
  1023. compressSegmentTab();
  1024. window.dispatchEvent(new Event('resize'));
  1025. }
  1026.  
  1027. function hideAveSpeedControls() {
  1028. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1029. logit("function " + fname + " called", "debug");
  1030. removeStyle(prefix + fname);
  1031. if (_cbHideAveSpeedControls.checked) {
  1032. var ASCBox;
  1033. if (getId('fwdSpeedCameraCheckbox')) {
  1034. ASCBox = getId('fwdSpeedCameraCheckbox');
  1035. }
  1036. if (getId('revSpeedCameraCheckbox')) {
  1037. ASCBox = getId('revSpeedCameraCheckbox');
  1038. }
  1039. if (ASCBox) {
  1040. var formGroup = ASCBox.parentNode.parentNode.parentNode;
  1041. var formGroupParent = formGroup.parentNode;
  1042. var targetGroup = Array.prototype.indexOf.call(formGroupParent.children, formGroup) + 1;
  1043. addStyle(prefix + fname, '#segment-edit-general > .side-panel-section.attributes-form > .form-group:nth-of-type(' + targetGroup + ') { display: none; }');
  1044. }
  1045. }
  1046. // if (_cbClickablePlaceAddress.checked) {
  1047. // var address;
  1048. // // Place address
  1049. // if (UIver == "old") {
  1050. // address = document.querySelector("#landmark-edit-general > div.address-edit.side-panel-section > div > div");
  1051. // if (address) {
  1052. // address.classList.add('edit-button');
  1053. // address.style.cursor = 'pointer';
  1054. // }
  1055. // } else {
  1056. // address = document.querySelector("#landmark-edit-general > div.form-group > div > div > div");
  1057. // if (address) {
  1058. // address.classList.add('edit-button');
  1059. // address.style.cursor = 'pointer';
  1060. // }
  1061. // }
  1062. // // Segment address
  1063. // if (UIver == "old") {
  1064. // // don't need to do anything - already clickable
  1065. // } else {
  1066. // address = document.querySelector("#segment-edit-general > div.address-edit.address-edit-view.clearfix.preview > div");
  1067. // if (address) {
  1068. // address.classList.add('address-edit-btn');
  1069. // address.style.cursor = 'pointer';
  1070. // var styles = "";
  1071. // styles += "#segment-edit-general > div.address-edit.address-edit-view.clearfix.preview > div:before { content: none; }";
  1072. // styles += "#segment-edit-general > div.address-edit.address-edit-view.clearfix.preview > div:after { content: none; }";
  1073. // addStyle(prefix + fname, styles);
  1074. // }
  1075. // }
  1076. // } else {
  1077. // removeStyle(prefix + fname);
  1078. // }
  1079. }
  1080.  
  1081. function WaddZoomIndicator() {
  1082. if (getId("_cbAddZoomIndicator").checked === true) {
  1083. alert("You have enabled the Zoom Level Indicator\n"+
  1084. "Please be aware that this function is not yet compatible with WME V2");
  1085. }
  1086. addZoomIndicator();
  1087. }
  1088.  
  1089. function addZoomIndicator() {
  1090. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1091. logit("function " + fname + " called", "debug");
  1092. var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
  1093. if (_cbAddZoomIndicator.checked) {
  1094. addStyle(prefix + fname, '.slider { font-size: 15px; font-weight: 900; line-height: 1; height: 18px; margin-top: 23px; padding-top: 2px; text-align: center; }');
  1095. Waze.map.events.register("zoomend", null, ZLI);
  1096. ZLI();
  1097. } else {
  1098. removeStyle(prefix + fname);
  1099. Waze.map.events.unregister("zoomend", null, ZLI);
  1100. slider.innerText = "";
  1101. slider.title = "";
  1102. }
  1103. }
  1104.  
  1105. function ZLI() {
  1106. var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
  1107. slider.innerText = Waze.map.zoom;
  1108. slider.title = "Zoom level indicator by WMEFU";
  1109. switch (Waze.map.zoom) {
  1110. case 0:
  1111. case 1:
  1112. slider.style.background = '#ef9a9a';
  1113. slider.title += "\nCannot permalink any segments at this zoom level";
  1114. break;
  1115. case 2:
  1116. case 3:
  1117. slider.style.background = '#ffe082';
  1118. slider.title += "\nCan only permalink primary or higher at this zoom level";
  1119. break;
  1120. default:
  1121. slider.style.background = '#ffffff';
  1122. slider.title += "\nCan permalink any segments at this zoom level";
  1123. break;
  1124. }
  1125. }
  1126.  
  1127. function shiftAerials() {
  1128. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1129. logit("function " + fname + " called", "debug");
  1130. // calculate meters/pixel for current map view
  1131. var ipu = OpenLayers.INCHES_PER_UNIT;
  1132. var metersPerPixel = Waze.map.getResolution() * ipu.m / ipu[Waze.map.getUnits()];
  1133. // Apply the shift and opacity
  1134. Waze.map.baseLayer.div.style.left = Math.round(getId("_inpASX").value / metersPerPixel) + 'px';
  1135. Waze.map.baseLayer.div.style.top = Math.round(- getId("_inpASY").value / metersPerPixel) + 'px';
  1136. Waze.map.baseLayer.div.style.opacity = getId("_inpASO").value/100;
  1137. }
  1138.  
  1139. function fixExternalProviders () {
  1140. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1141. logit("function " + fname + " called", "debug");
  1142. var styles = "";
  1143. if (_cbFixExternalProviders.checked) {
  1144. //enlarge external provider boxes
  1145. styles += '#edit-panel .external-providers-view .select2-container { width: 90%; margin-bottom: 2px; }';
  1146. styles += '.select2-container .select2-choice { height: inherit; line-height: 16px; }';
  1147. styles += '.select2-container .select2-choice>.select2-chosen { white-space: normal; }';
  1148. styles += '.placeId { padding-bottom: 5px; }';
  1149. addStyle(prefix + fname,styles);
  1150. } else {
  1151. removeStyle(prefix + fname);
  1152. }
  1153. }
  1154.  
  1155. function warnCommentsOff() {
  1156. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1157. logit("function " + fname + " called", "debug");
  1158. if (Waze.map.getLayerByUniqueName('mapComments').visibility === false) {
  1159. removeStyle(prefix + fname);
  1160. addStyle(prefix + fname, '.toolbar { background-color: #FFC107; }');
  1161. } else {
  1162. removeStyle(prefix + fname);
  1163. }
  1164. }
  1165.  
  1166. function adjustGSV() {
  1167. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1168. logit("function " + fname + " called", "debug");
  1169. var styles = "";
  1170. styles += '.gm-style { filter: contrast(' + getId('_inpGSVContrast').value + '%) ';
  1171. styles += 'brightness(' + getId('_inpGSVBrightness').value + '%) ';
  1172. if (getId('_cbGSVInvert').checked) {
  1173. styles += 'invert(1); }';
  1174. } else {
  1175. styles += 'invert(0); }';
  1176. }
  1177. removeStyle(prefix + fname);
  1178. addStyle(prefix + fname, styles);
  1179. }
  1180.  
  1181. function permalinkCheck() {
  1182. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1183. logit("function " + fname + " called", "debug");
  1184. var selSegments = Waze.selectionManager.selectedItems.length;
  1185. if ( URLSegmentCount != selSegments ) {
  1186. alert("WARNING FROM WME FixUI!\n\n" +
  1187. "You have opened a permalink with " + URLSegmentCount + " segments,\n" +
  1188. "but the total selected in WME is " + selSegments + ".\n\n" +
  1189. "The permalink may contain segments not selectable at this zoom\n" +
  1190. "or not visible on-screen, or some segment IDs may have been\n" +
  1191. "changed since the permalink was created.");
  1192. }
  1193. Waze.selectionManager.events.unregister("selectionchanged", null, permalinkCheck);
  1194. }
  1195.  
  1196. function moveChatIcon() {
  1197. // Now functioning correctly for prod & beta
  1198. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1199. logit("function " + fname + " called", "debug");
  1200. var styles = "";
  1201. if (_cbMoveChatIcon.checked) {
  1202. styles += '#chat-overlay { left: inherit; right: 20px; }';
  1203. if (UIver == "new") {
  1204. styles += '#chat-overlay #chat-toggle { right: 0px; }';
  1205. }
  1206. addStyle(prefix + fname,styles);
  1207. } else {
  1208. removeStyle(prefix + fname);
  1209. }
  1210. }
  1211.  
  1212. function darkenSaveLayer() {
  1213. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1214. logit("function " + fname + " called", "debug");
  1215. var styles = "";
  1216. if (_cbDarkenSaveLayer.checked) {
  1217. styles += '#popup-overlay { background-color: dimgrey; }';
  1218. addStyle(prefix + fname,styles);
  1219. } else {
  1220. removeStyle(prefix + fname);
  1221. }
  1222. }
  1223.  
  1224. //function layersMenuAutoHide() {
  1225. // var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1226. // logit("function " + fname + " called", "debug");
  1227. // var LS = getElementsByClassName('layer-switcher')[0];
  1228. // if (_cbLayersMenuAutoHide.checked) {
  1229. // LS.onmouseleave = function () { $(".waze-icon-layers").click(); };
  1230. // LS.onmouseenter = function () { $(".waze-icon-layers").click(); };
  1231. // } else {
  1232. // LS.onmouseleave = null;
  1233. // LS.onmouseenter = null;
  1234. // }
  1235. //}
  1236.  
  1237. //Helper functions
  1238.  
  1239. function addGlobalStyle(css) {
  1240. var head, style;
  1241. head = document.getElementsByTagName('head')[0];
  1242. if (!head) {
  1243. return;
  1244. }
  1245. style = document.createElement('style');
  1246. style.type = 'text/css';
  1247. style.innerHTML = css;
  1248. head.appendChild(style);
  1249. }
  1250.  
  1251. function addStyle(ID, css) {
  1252. var head, style;
  1253. head = document.getElementsByTagName('head')[0];
  1254. if (!head) {
  1255. return;
  1256. }
  1257. removeStyle(ID); // in case it is already there
  1258. style = document.createElement('style');
  1259. style.type = 'text/css';
  1260. style.innerHTML = css;
  1261. style.id = ID;
  1262. head.appendChild(style);
  1263. }
  1264.  
  1265. function removeStyle(ID) {
  1266. var style = document.getElementById(ID);
  1267. if (style) { style.parentNode.removeChild(style); }
  1268. }
  1269.  
  1270. function getElementsByClassName(classname, node) {
  1271. if(!node) { node = document.getElementsByTagName("body")[0]; }
  1272. var a = [];
  1273. var re = new RegExp('\\b' + classname + '\\b');
  1274. var els = node.getElementsByTagName("*");
  1275. for (var i=0,j=els.length; i<j; i++) {
  1276. if (re.test(els[i].className)) { a.push(els[i]); }
  1277. }
  1278. return a;
  1279. }
  1280.  
  1281. function getId(node) {
  1282. return document.getElementById(node);
  1283. }
  1284.  
  1285. function logit(msg, typ) {
  1286. if (!typ) {
  1287. console.log(prefix + ": " + msg);
  1288. } else {
  1289. switch(typ) {
  1290. case "error":
  1291. console.error(prefix + ": " + msg);
  1292. break;
  1293. case "warning":
  1294. console.warn(prefix + ": " + msg);
  1295. break;
  1296. case "info":
  1297. console.info(prefix + ": " + msg);
  1298. break;
  1299. case "debug":
  1300. if (debug) {
  1301. console.debug(prefix + ": " + msg);
  1302. }
  1303. break;
  1304. default:
  1305. console.log(prefix + " unknown message type: " + msg);
  1306. break;
  1307. }
  1308. }
  1309. }
  1310.  
  1311. // Start it running
  1312. setTimeout(init1, 200);
  1313. })();