WME Fix UI

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

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

  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.8
  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, berestovskyy
  18.  
  19. (function()
  20. {
  21. // global variables
  22. var wmefu_version = "2.8";
  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. //Mutation Observer to re-hack buttons
  33. var buttonObserver = new MutationObserver(function(mutations) {
  34. mutations.forEach(function(mutation) {
  35. //do something
  36. if ($(mutation.target).hasClass('waze-icon-reload')){
  37. $('.waze-icon-reload').removeClass('reload');
  38. $('.waze-icon-reload span').addClass('fa fa-refresh fa-lg');
  39. $('.waze-icon-reload span')[0].innerHTML = "";
  40. }
  41. else if($(mutation.target).hasClass('waze-icon-undo')){
  42. $('.waze-icon-undo').removeClass('undo');
  43. $('.waze-icon-undo span').addClass('fa fa-undo fa-lg');
  44. $('.waze-icon-undo span')[0].innerHTML = "";
  45. }
  46. else if($(mutation.target).hasClass('waze-icon-redo')){
  47. $('.waze-icon-redo').removeClass('redo');
  48. $('.waze-icon-redo span').addClass('fa fa-repeat fa-lg');
  49. $('.waze-icon-redo span')[0].innerHTML = "";
  50. }
  51. else if($(mutation.target).is('#wecm-count')){
  52. $('#wecm-count')[0].parentElement.style.marginTop = ['11px','5px','-1px'][_inpUICompression.value];
  53. }
  54. });
  55. });
  56. //Fix for date/time formats in WME released Oct/Nov 2016 - provided by Glodenox
  57. I18n.translations[I18n.currentLocale()].time = {};
  58. I18n.translations[I18n.currentLocale()].time.formats = {};
  59. I18n.translations[I18n.currentLocale()].time.formats.long = "%a %b %d %Y, %H:%M";
  60. I18n.translations[I18n.currentLocale()].date.formats = {};
  61. I18n.translations[I18n.currentLocale()].date.formats.long = "%a %b %d %Y, %H:%M";
  62. I18n.translations[I18n.currentLocale()].date.formats.default = "%a %b %d %Y";
  63. if (I18n.currentLocale() == 'en-GB') {
  64. I18n.translations['en-GB'].update_requests.panel.reported = 'Reported on: %{date}';
  65. }
  66. // Set the "Chat is here!" message to be hidden
  67. if (localStorage.hiddenMessages) {
  68. var hm = JSON.parse(localStorage.hiddenMessages);
  69. if (hm.chat_intro_tip === false) {
  70. logit("Hiding Chat is Here! message","info");
  71. hm.chat_intro_tip = true;
  72. localStorage.setItem('hiddenMessages', JSON.stringify(hm));
  73. }
  74. }
  75.  
  76. function init1() {
  77. console.group(prefix + ": initialising...");
  78. console.time(prefix + ": initialisation time");
  79. logit("Starting init1","debug");
  80. // go round again if map container isn't there yet
  81. if(!window.Waze.map) {
  82. logit("waiting for WME...","warning");
  83. setTimeout(init1, 200);
  84. return;
  85. }
  86. // identify WME version by checking for an item that no longer appears in the new version
  87. UIver = ((document.getElementById("input-overlay") === null) ? "new" : "old");
  88. // create tab content and store it
  89. wmeFUAddon = createAddon();
  90. // insert the content as a tab
  91. addMyTab(null,0);
  92. //pass control to init2
  93. init2();
  94. }
  95.  
  96. function init2() {
  97. logit("Starting init2","debug");
  98. //go round again if my tab isn't there yet
  99. if (!getId('sidepanel-FixUI')) {
  100. logit("Waiting for my tab to appear...","warning");
  101. setTimeout(init2, 200);
  102. return;
  103. }
  104. //test for 2017 UI
  105. logit("UI version is " + UIver, "info");
  106. // setup event handlers for my controls:
  107. getId('_cbMoveZoomBar').onclick = moveZoomBar;
  108. getId('_cbHideUserInfo').onclick = hideUserInfo;
  109. getId('_cbHideAveSpeedControls').onclick = hideAveSpeedControls;
  110. getId('_cbFixExternalProviders').onclick = fixExternalProviders;
  111. getId('_cbMoveChatIcon').onclick = moveChatIcon;
  112. getId('_cbDarkenSaveLayer').onclick = darkenSaveLayer;
  113. getId('_cbSwapRoadsGPS').onclick = swapRoadsGPS;
  114. getId('_cbUndarkenAerials').onclick = undarkenAerials;
  115. getId('_cbShrinkTopBars').onclick = shrinkTopBars;
  116. getId('_cbCompressSegmentTab').onclick = compressSegmentTab;
  117. getId('_cbCompressLayersMenu').onclick = compressLayersMenu;
  118. getId('_cbLayersColumns').onclick = compressLayersMenu;
  119. getId('_cbRestyleReports').onclick = restyleReports;
  120. getId('_cbEnhanceChat').onclick = enhanceChat;
  121. getId('_cbNarrowSidePanel').onclick = narrowSidePanel;
  122. getId("_inpUICompression").onchange = applyEnhancements;
  123. getId("_inpUIContrast").onchange = applyEnhancements;
  124. // getId('_cbAddzoomindicator').onclick = WaddZoomIndicator;
  125. getId("_inpASX").onchange = shiftAerials;
  126. getId("_inpASX").onwheel = shiftAerials;
  127. getId("_inpASY").onchange = shiftAerials;
  128. getId("_inpASY").onwheel = shiftAerials;
  129. getId("_inpASO").onchange = shiftAerials;
  130. getId("_inpASO").onwheel = shiftAerials;
  131. getId("_resetAS").onclick = function() {
  132. getId("_inpASX").value = 0;
  133. getId("_inpASY").value = 0;
  134. shiftAerials();
  135. };
  136. getId("_inpGSVContrast").onchange = adjustGSV;
  137. getId("_inpGSVBrightness").onchange = adjustGSV;
  138. getId("_cbGSVInvert").onchange = adjustGSV;
  139.  
  140. //REGISTER WAZE EVENT HOOKS
  141. // event to recreate my tab when MTE mode is exited
  142. Waze.app.modeController.model.bind('change:mode', addMyTab);
  143. // event to recreate my tab after changing WME units
  144. Waze.prefs.on('change:isImperial', function() {
  145. tabAttempts = 0;
  146. tabsLooper();
  147. });
  148. // events for Aerial Shifter
  149. Waze.map.events.register("zoomend", null, shiftAerials);
  150. Waze.map.events.register("moveend", null, shiftAerials);
  151. Waze.map.baseLayer.events.register("loadend", null, shiftAerials);
  152. // event to deal with ASC controls and make place address clickable
  153. Waze.selectionManager.events.register("selectionchanged", null, hideAveSpeedControls);
  154. // events to change menu bar color based on map comments checkbox
  155. Waze.map.events.register("zoomend", null, warnCommentsOff);
  156. Waze.map.events.register("moveend", null, warnCommentsOff);
  157.  
  158. //window resize event to resize chat
  159. window.addEventListener('resize', enhanceChat, true);
  160. //window resize event to resize layers menu
  161. window.addEventListener('resize', compressLayersMenu, true);
  162. //event to re-hack toolbar buttons when exitine HN mode
  163. W.editingMediator.on('change:editingHouseNumbers', function() {
  164. if (W.editingMediator.attributes.editingHouseNumbers === false) {
  165. setTimeout(hackToolbarButtons,5000);
  166. }
  167. });
  168.  
  169. // overload the window unload function to save my settings
  170. window.addEventListener("beforeunload", saveSettings, false);
  171.  
  172. loadSettings();
  173. // Add an extra checkbox so I can test segment panel changes easily
  174. if (Waze.loginManager.user.userName == 'iainhouse') {
  175. logit("creating segment detail debug checkbox","info");
  176. var brand = getId('brand');
  177. var extraCBSection = document.createElement('p');
  178. extraCBSection.innerHTML = '<input type="checkbox" id="_cbextraCBSection" />';
  179. brand.appendChild(extraCBSection);
  180. getId('_cbextraCBSection').onclick = FALSEcompressSegmentTab;
  181. getId('_cbextraCBSection').checked = getId('_cbCompressSegmentTab').checked;
  182. //completely disable save overlay: experimental feature
  183. addGlobalStyle('#popup-overlay { display: none !important; }');
  184. }
  185. // warn of permalink segments not all selected
  186. URLSegments = window.location.search.match(new RegExp("[?&]segments?=([^&]*)"));
  187. if (URLSegments) {
  188. URLSegmentCount = URLSegments[1].split(',').length;
  189. if (Waze.selectionManager.selectedItems.length > 0) {
  190. permalinkCheck();
  191. } else {
  192. Waze.selectionManager.events.register("selectionchanged", null, permalinkCheck);
  193. }
  194. }
  195. // Alert to new version
  196. if (oldVersion != wmefu_version) {
  197. alert("WME Fix UI has been updated to version " + wmefu_version + "\n" +
  198. ChromeWarning() +
  199. "\n" +
  200. "Version 2.8 - 2017-12-26\n" +
  201. "* SCRIPT RE-WRITE FOR WME v2 IS NOW COMPLETE\n" +
  202. "* New feature: Un-darken map layer\n" +
  203. "* Minor style improvements\n" +
  204. "\n" +
  205. "Previous V2 highlights:\n" +
  206. "* 2.7 Layers menu enhancement re-written for new WME UI\n" +
  207. "* 2.7 New feature: move GPS layer below segments\n" +
  208. "* 2.6 New feature: Enhance Chat panel\n" +
  209. "* 2.5 UR/MP panel enhancement re-written for new WME UI\n" +
  210. "* 2.5 Narrow Side Panel re-written for new WME UI\n" +
  211. "* 2.4 Top bar compression/enhancement re-written for new WME UI\n" +
  212. "* 2.4 Recovery from unit change & house number mode implemented\n" +
  213. "* 2.3 The zoom bar is back, with permanent level indicator\n" +
  214. "* 2.2 Place details enhancement re-written for new WME UI\n" +
  215. "* 2.2 New option to darken screen overlay when saving\n" +
  216. "* 2.0 New operation with variable & independent compression/contrast control\n" +
  217. "* 2.0 Handling of Feed, Drives and Areas re-written for new WME UI\n" +
  218. "* 2.0 Segment edit panel handling re-written for new UI\n" +
  219. "");
  220. saveSettings();
  221. }
  222.  
  223. // fix for sidebar display problem in Safari, requested by edsonajj
  224. var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  225. if (isSafari) {
  226. addGlobalStyle('.flex-parent { height: 99% !important; }');
  227. }
  228. // apply the settings
  229. shiftAerials();
  230. setTimeout(applyAllSettings, 2000);
  231. logit("Initialisation complete");
  232. console.timeEnd(prefix + ": initialisation time");
  233. console.groupEnd();
  234. //GPS fucking about
  235. // addGlobalStyle('#OpenLayers\\2e Layer\\2e XYZ_212 { z-index: 334 !important; }');
  236. }
  237.  
  238. function createAddon() {
  239. //create the contents of my side-panel tab
  240. var addon = document.createElement('section');
  241. var section = document.createElement('p');
  242. addon.id = "sidepanel-FixUI";
  243. section.style.paddingTop = "0px";
  244. section.style.lineHeight = "16px";
  245. section.id = "fuContent";
  246. section.innerHTML = "";
  247. section.innerHTML += '<b>UI Fixes/changes</b><br>';
  248. section.innerHTML += '<input type="checkbox" id="_cbMoveZoomBar" /> ' +
  249. '<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>';
  250. // section.innerHTML += '<input style="display:none" type="checkbox" id="_cbAddZoomIndicator" /> ' +
  251. // '<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>';
  252. section.innerHTML += '<input type="checkbox" id="_cbHideUserInfo" /> ' +
  253. '<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>';
  254. section.innerHTML += '<input type="checkbox" id="_cbHideAveSpeedControls" /> ' +
  255. '<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>';
  256. section.innerHTML += '<input type="checkbox" id="_cbFixExternalProviders" /> ' +
  257. '<span title="The External Providers interface has a dexcription box that will only show one live of text.\nThis fixes that.">Expand External Provider details for places</span><br>';
  258. section.innerHTML += '<input type="checkbox" id="_cbPermalinkChecker" /> ' +
  259. '<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>';
  260. section.innerHTML += '<input type="checkbox" id="_cbMoveChatIcon" /> ' +
  261. '<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>';
  262. section.innerHTML += '<input type="checkbox" id="_cbLayersMenuMoreOptions" /> ' +
  263. '<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>';
  264. section.innerHTML += '<input type="checkbox" id="_cbDarkenSaveLayer" /> ' +
  265. '<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>';
  266. section.innerHTML += '<input type="checkbox" id="_cbSwapRoadsGPS" /> ' +
  267. '<span title="Guess what? Waze thinks the GPS layer should now be over the segments layer.\nWhy should you have any choice about that?">Move GPS layer below segments layer</span><br>';
  268. section.innerHTML += '<input type="checkbox" id="_cbUndarkenAerials" /> ' +
  269. '<span title="A new contribution from WME V2 to your eyestrain. Sometimes the aerial images\nare too dark - so WME makes them darker! This kills that behaviour.">Un-darken aerial images <span style = "color: red; font-weight: bold;">--- NEW</span></span><br>';
  270. section.innerHTML += '<br>';
  271. section.innerHTML += '<b>UI Enhancements</b><br>';
  272. section.innerHTML += '<input type="checkbox" id="_cbShrinkTopBars" /> ' +
  273. '<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>';
  274. section.innerHTML += '<input type="checkbox" id="_cbCompressSegmentTab" /> ' +
  275. '<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>';
  276. section.innerHTML += '<input type="checkbox" id="_cbCompressLayersMenu" /> ' +
  277. '<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>';
  278. section.innerHTML += '<span id="layersColControls"><input type="checkbox" id="_cbLayersColumns" /> ' +
  279. '<span title="Widen the layers menu to 2 columns - particulary for netbook users\nWon\'t work without some compression turned on">Two-column layers menu</span><br></span>';
  280. section.innerHTML += '<input type="checkbox" id="_cbRestyleReports" /> ' +
  281. '<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>';
  282. section.innerHTML += '<input type="checkbox" id="_cbEnhanceChat" /> ' +
  283. '<span title="A perfect example of the new WME UI. Looks very stylish,\nbut destroys usability and utterly ignores small-screen users.">Compress/enhance Chat panel</span><br>';
  284. section.innerHTML += '<input type="checkbox" id="_cbNarrowSidePanel" /> ' +
  285. '<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>';
  286. section.innerHTML += '<br>';
  287. section.innerHTML += '<b title="Control the amount of compression/enhancment">UI Enhancement controls<br>';
  288. 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;';
  289. 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>';
  290. section.innerHTML += '<br>';
  291. section.innerHTML += '<br>';
  292. section.innerHTML += '<b title="Shift aerial images layer to match GPS tracks and reduce image opacity">Aerial Shifter</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  293. section.innerHTML += '<span class="fa fa-power-off" id="_resetAS" title="Clear X/Y offsets"></span><br>';
  294. 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>';
  295. 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>';
  296. 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>';
  297. section.innerHTML += '<br>';
  298. section.innerHTML += '<br>';
  299.  
  300. section.innerHTML += '<b title="Adjust contrast & brightness for Google Street View images">GSV image adjust</b><br>';
  301. 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;';
  302. 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;';
  303. section.innerHTML += '<span title="Invert colours"><input type="checkbox" id="_cbGSVInvert"/><span class="fa fa-tint"></span></span>';
  304.  
  305. section.innerHTML += '<br>';
  306. section.innerHTML += '<br>';
  307. section.innerHTML += '<b><a href="https://www.waze.com/forum/viewtopic.php?f=819&t=191178" title="Forum topic" target="_blank"><u>' +
  308. 'WME Fix UI</u></a></b> &nbsp; v' + wmefu_version;
  309. addon.appendChild(section);
  310. addon.className = "tab-pane";
  311. return addon;
  312. }
  313.  
  314. function addMyTab(model,modeID) {
  315. if (modeID === 0) {
  316. logit("entering default mode, so creating tab");
  317. tabAttempts = 0;
  318. tabsLooper();
  319. } else {
  320. logit("entering event mode, so not initialising");
  321. return;
  322. }
  323. }
  324.  
  325. function tabsLooper() {
  326. tabAttempts += 1;
  327. if (tabAttempts > 20) {
  328. // tried 20 times to create tab without luck
  329. logit("unable to create my tab after 20 attempts","error");
  330. return;
  331. }
  332. var userTabs = getId('user-info');
  333. var navTabs = getElementsByClassName('nav-tabs', userTabs)[0];
  334. if (typeof navTabs === "undefined") {
  335. //the basic tabs aren't there yet, so I can't add mine
  336. logit("waiting for NavTabs","warning");
  337. setTimeout(tabsLooper, 200);
  338. } else{
  339. var tabContent = getElementsByClassName('tab-content', userTabs)[0];
  340. newtab = document.createElement('li');
  341. newtab.innerHTML = '<a href="#sidepanel-FixUI" data-toggle="tab" title="Fix UI">FU</a>';
  342. navTabs.appendChild(newtab);
  343. tabContent.appendChild(wmeFUAddon);
  344. if (_cbShrinkTopBars.checked === true) {
  345. hackToolbarButtons();
  346. }
  347. }
  348. }
  349.  
  350. function loadSettings() {
  351. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  352. logit("function " + fname + " called", "debug");
  353. // Convert old version of settings to new version
  354. var options;
  355. if (localStorage.WMEFixUI) {
  356. var oldSettings = JSON.parse(localStorage.WMEFixUI);
  357. var newSettings = {};
  358. newSettings.oldVersion = (oldSettings[0] ? oldSettings[0] : "1.0" );
  359. newSettings.moveZoomBar = (oldSettings[1] ? oldSettings[1] : true );
  360. newSettings.shrinkTopBars = (oldSettings[2] ? oldSettings[2] : true );
  361. newSettings.hideUserInfo = (oldSettings[3] ? oldSettings[3] : true );
  362. newSettings.restyleSidePanel = (oldSettings[4] ? oldSettings[4] : true );
  363. newSettings.restyleReports = (oldSettings[5] ? oldSettings[5] : true );
  364. newSettings.narrowSidePanel = (oldSettings[7] ? oldSettings[7] : false );
  365. newSettings.hideASCControls = (oldSettings[8] ? oldSettings[8] : false );
  366. // newSettings.addZoomIndicator = (oldSettings[9] ? oldSettings[9] : true );
  367. newSettings.aerialShiftX = (oldSettings[10] ? oldSettings[10] : 0 );
  368. newSettings.aerialShiftY = (oldSettings[11] ? oldSettings[11] : 0 );
  369. newSettings.aerialOpacity = (oldSettings[12] ? oldSettings[12] : 100 );
  370. newSettings.fixExternalProviders = (oldSettings[13] ? oldSettings[13] : true );
  371. newSettings.GSVContrast = (oldSettings[14] ? oldSettings[14] : 100 );
  372. newSettings.GSVBrightness = (oldSettings[15] ? oldSettings[15] : 100 );
  373. newSettings.GSVInvert = (oldSettings[16] ? oldSettings[16] : false );
  374. newSettings.permalinkChecker = (oldSettings[18] ? oldSettings[18] : true );
  375. newSettings.restyleLayersMenu = (oldSettings[19] ? oldSettings[19] : true );
  376. newSettings.moveChatIcon = (oldSettings[20] ? oldSettings[20] : true );
  377. // setting[21] was Menu Autohide - no longer needed
  378. newSettings.layersMenuMore = (oldSettings[22] ? oldSettings[22] : true );
  379. localStorage.WMEFUSettings = JSON.stringify(newSettings);
  380. localStorage.removeItem("WMEFixUI");
  381. }
  382.  
  383. if (localStorage.WMEFUSettings) {
  384. options = JSON.parse(localStorage.WMEFUSettings);
  385. } else {
  386. options = {};
  387. }
  388. oldVersion = (options.oldVersion !== undefined ? options.oldVersion : "0.0");
  389. getId('_cbMoveZoomBar').checked = (options.moveZoomBar !== undefined ? options.moveZoomBar : true);
  390. getId('_cbShrinkTopBars').checked = (options.shrinkTopBars !== undefined ? options.shrinkTopBars : true);
  391. getId('_cbHideUserInfo').checked = ( options.hideUserInfo !== undefined ? options.hideUserInfo : true);
  392. getId('_cbCompressSegmentTab').checked = ( options.restyleSidePanel !== undefined ? options.restyleSidePanel : true);
  393. getId('_cbRestyleReports').checked = ( options.restyleReports !== undefined ? options.restyleReports : true);
  394. getId('_cbEnhanceChat').checked = ( options.enhanceChat !== undefined ? options.enhanceChat : true);
  395. getId('_cbNarrowSidePanel').checked = ( options.narrowSidePanel !== undefined ? options.narrowSidePanel : false);
  396. getId('_cbHideAveSpeedControls').checked = ( options.hideASCControls !== undefined ? options.hideASCControls : false);
  397. // getId('_cbAddZoomIndicator').checked = ( options.addZoomIndicator !== undefined ? options.addZoomIndicator : true);
  398. getId('_inpASX').value = ( options.aerialShiftX !== undefined ? options.aerialShiftX : 0);
  399. getId('_inpASY').value = ( options.aerialShiftY !== undefined ? options.aerialShiftY : 0);
  400. getId('_inpASO').value = ( options.aerialOpacity !== undefined ? options.aerialOpacity : 100);
  401. getId('_cbFixExternalProviders').checked = ( options.fixExternalProviders !== undefined ? options.fixExternalProviders : true);
  402. getId('_inpGSVContrast').value = ( options.GSVContrast !== undefined ? options.GSVContrast : 100);
  403. getId('_inpGSVBrightness').value = ( options.GSVBrightness !== undefined ? options.GSVBrightness : 100);
  404. getId('_cbGSVInvert').checked = ( options.GSVInvert !== undefined ? options.GSVInvert : false);
  405. getId('_cbPermalinkChecker').checked = ( options.permalinkChecker !== undefined ? options.permalinkChecker : true);
  406. getId('_cbCompressLayersMenu').checked = ( options.restyleLayersMenu !== undefined ? options.restyleLayersMenu : true);
  407. getId('_cbLayersColumns').checked = ( options.layers2Cols !== undefined ? options.layers2Cols : false);
  408. getId('_cbMoveChatIcon').checked = ( options.moveChatIcon !== undefined ? options.moveChatIcon : true);
  409. getId('_cbDarkenSaveLayer').checked = ( options.darkenSaveLayer !== undefined ? options.darkenSaveLayer : true);
  410. getId('_cbLayersMenuMoreOptions').checked = ( options.layersMenuMore !== undefined ? options.layersMenuMore : true);
  411. if (UIver == "new") {
  412. getId('_inpUIContrast').value = ( options.UIContrast !== undefined ? options.UIContrast : 1);
  413. getId('_inpUICompression').value = ( options.UICompression !== undefined ? options.UICompression : 1);
  414. }
  415. getId('_cbSwapRoadsGPS').checked = ( options.swapRoadsGPS !== undefined ? options.swapRoadsGPS : true);
  416. getId('_cbUndarkenAerials').checked = ( options.undarkenAerials !== undefined ? options.undarkenAerials : true);
  417. }
  418.  
  419. function saveSettings() {
  420. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  421. logit("function " + fname + " called", "debug");
  422. if (localStorage) {
  423. logit("saving options to local storage");
  424. var options = {};
  425. options.oldVersion = wmefu_version;
  426. options.moveZoomBar = getId('_cbMoveZoomBar').checked;
  427. options.shrinkTopBars = getId('_cbShrinkTopBars').checked;
  428. options.hideUserInfo = getId('_cbHideUserInfo').checked;
  429. options.restyleSidePanel = getId('_cbCompressSegmentTab').checked;
  430. options.restyleReports = getId('_cbRestyleReports').checked;
  431. options.enhanceChat = getId('_cbEnhanceChat').checked;
  432. options.narrowSidePanel = getId('_cbNarrowSidePanel').checked;
  433. options.hideASCControls = getId('_cbHideAveSpeedControls').checked;
  434. // options.addZoomIndicator = getId('_cbAddZoomIndicator').checked;
  435. options.aerialShiftX = getId('_inpASX').value;
  436. options.aerialShiftY = getId('_inpASY').value;
  437. options.aerialOpacity = getId('_inpASO').value;
  438. options.fixExternalProviders = getId('_cbFixExternalProviders').checked;
  439. options.GSVContrast = getId('_inpGSVContrast').value;
  440. options.GSVBrightness = getId('_inpGSVBrightness').value;
  441. options.GSVInvert = getId('_cbGSVInvert').checked;
  442. options.permalinkChecker = getId('_cbPermalinkChecker').checked;
  443. options.restyleLayersMenu = getId('_cbCompressLayersMenu').checked;
  444. options.layers2Cols = getId('_cbLayersColumns').checked;
  445. options.moveChatIcon = getId('_cbMoveChatIcon').checked;
  446. options.darkenSaveLayer = getId('_cbDarkenSaveLayer').checked;
  447. options.layersMenuMore = getId('_cbLayersMenuMoreOptions').checked;
  448. if (UIver == "new") {
  449. options.UIContrast = getId('_inpUIContrast').value;
  450. options.UICompression = getId('_inpUICompression').value;
  451. }
  452. options.swapRoadsGPS = getId('_cbSwapRoadsGPS').checked;
  453. options.undarkenAerials = getId('_cbUndarkenAerials').checked;
  454. localStorage.WMEFUSettings = JSON.stringify(options);
  455. }
  456. }
  457.  
  458. function applyAllSettings() {
  459. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  460. logit("function " + fname + " called", "debug");
  461. console.group(prefix + ": applying all settings");
  462. moveZoomBar();
  463. shrinkTopBars();
  464. hideUserInfo();
  465. compressSegmentTab();
  466. restyleReports();
  467. enhanceChat();
  468. narrowSidePanel();
  469. hideAveSpeedControls();
  470. fixExternalProviders();
  471. // addZoomIndicator();
  472. warnCommentsOff();
  473. adjustGSV();
  474. compressLayersMenu();
  475. moveChatIcon();
  476. darkenSaveLayer();
  477. swapRoadsGPS();
  478. undarkenAerials();
  479. console.groupEnd();
  480. if (getId('_cbLayersMenuMoreOptions').checked === true) {
  481. $("#toolbar > div > div.layer-switcher-container > div > div > div > div > div.menu > div.more-options-toggle > label > div").click();
  482. }
  483. wmeFUinitialising = false;
  484. saveSettings();
  485. }
  486.  
  487. function applyEnhancements() {
  488. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  489. logit("function " + fname + " called", "debug");
  490. shrinkTopBars();
  491. compressSegmentTab();
  492. restyleReports();
  493. enhanceChat();
  494. compressLayersMenu();
  495. }
  496.  
  497. function moveZoomBar() {
  498. // Now functioning correctly for prod & beta
  499. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  500. logit("function " + fname + " called", "debug");
  501. if (_cbMoveZoomBar.checked) {
  502. var styles = "";
  503. styles += '.olControlPanZoomBar { left: 10px; top: 35px; height: 158px; border-width: 1px; }';
  504. styles += '.zoom-minus-button { top: 0px !important; }';
  505. styles += '.slider-stops { display: inherit; width: 24px; height: 109px !important; }';
  506. 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; }';
  507. styles += '.street-view-control-container { bottom: -40px; margin-right: -3px; }';
  508. styles += '.geolocation-control-container { bottom: -79px; margin-right: -3px; id: "WMEFU"; }';
  509. // fix for WME Map Tiles Update script
  510. styles += '#Info_div { margin-top: 89px !important; margin-left: 2px !important; }';
  511. // fix for WME BeenHere - old but I still use it :)
  512. styles += '#BeenHere { top: 310px !important; }';
  513. // shift UR/MP panel to the right
  514. styles += '#panel-container > div { left: 40px; }';
  515. Waze.map.events.register("zoomend", null, ZLI);
  516. ZLI();
  517. addStyle(prefix + fname,styles);
  518. } else {
  519. var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
  520. removeStyle(prefix + fname);
  521. Waze.map.events.unregister("zoomend", null, ZLI);
  522. slider.innerText = "";
  523. slider.title = "";
  524. }
  525. }
  526.  
  527. function hideUserInfo() {
  528. // Now functioning correctly for prod & beta
  529. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  530. logit("function " + fname + " called", "debug");
  531. var styles = "";
  532. // WME Panel Swap buttons - move them up if user info is hidden
  533. var PSButton1 = getId('WMEPS_UIButton');
  534. var PSButton2 = getId('WMEPS_EditButton');
  535. if (_cbHideUserInfo.checked) {
  536. styles += '#user-box { display: none; }';
  537. // extra fix for WME Panel Swap control (not working with new WME UI)
  538. if (PSButton1) { PSButton1.style.top = '-27px'; }
  539. if (PSButton2) { PSButton2.style.top = '-27px'; }
  540. addStyle(prefix + fname,styles);
  541. //Fix to move control button of Invalidated Camera Mass Eraser
  542. if (getId("_UCME_btn")) {
  543. var but = getId("_UCME_btn");
  544. var dest = getId("advanced-tools");
  545. getId("advanced-tools").appendChild(getId("_UCME_btn"));
  546. document.getElementById('UCME_btn').parentNode.removeChild(document.getElementById('UCME_btn'));
  547. }
  548. } else {
  549. if (PSButton1) { PSButton1.style.top = '0px'; }
  550. if (PSButton2) { PSButton2.style.top = '0px'; }
  551. removeStyle(prefix + fname);
  552. }
  553. }
  554.  
  555. function shrinkTopBars() {
  556. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  557. logit("function " + fname + " called", "debug");
  558. var styles = "";
  559. if (_cbShrinkTopBars.checked) {
  560. //always do this stuff
  561. //event mode button
  562. styles += '#mode-switcher .title-button .icon { font-size: 13px; font-weight: bold; color: black; }';
  563. //black bar
  564. styles += '#topbar-container { pointer-events: none; }';
  565. styles += '#map #topbar-container .topbar > div { pointer-events: initial; }';
  566. //change toolbar buttons - from JustinS83
  567. $('#mode-switcher .title-button .icon').removeClass('fa fa-angle-down');
  568. $('#mode-switcher .title-button .icon').addClass('fa fa-calendar');
  569. hackToolbarButtons();
  570. // HN editing tweaks
  571. styles += '#map-lightbox .content { pointer-events: none; }';
  572. styles += '#map-lightbox .content > div { pointer-events: initial; }';
  573. styles += '#map-lightbox .content .header { pointer-events: none !important; }';
  574. styles += '.toolbar .toolbar-button.add-house-number { background-color: #61cbff; float: right; font-weight: bold; }';
  575. styles += '.waze-icon-exit { background-color: #61cbff; font-weight: bold; }';
  576. // event mode button
  577. styles += '.toolbar.toolbar-mte .add-button { background-color: orange; font-weight: bold; }';
  578. var contrast = _inpUIContrast.value;
  579. var compress = _inpUICompression.value;
  580. if (compress > 0) {
  581. styles += '#app-head { height: ' + ['','35px','24px'][compress] + '; }';
  582. styles += '#app-head aside #brand { height: ' + ['','34px','22px'][compress] + '; padding-left: ' + ['','10px','5px'][compress] + '; }';
  583. styles += '.toolbar { height: ' + ['','35px','24px'][compress] + '; }';
  584. styles += '#mode-switcher .title-button .icon { line-height: ' + ['','34px','22px'][compress] + '; }';
  585. //search box
  586. styles += '#search { padding-top: ' + ['','3px','0px'][compress] + '; }';
  587. styles += '.form-search { height: ' + ['','27px','20px'][compress] + '; }';
  588. styles += '.form-search .search-query { height: ' + ['','26px','19px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  589. styles += '.form-search .input-wrapper::after { top: ' + ['','6px','2px'][compress] + '; }';
  590. //toolbar dropdown menus
  591. //Toolbox switcher
  592. styles += '#toolbox-switcher .toolbar-button { margin-top: 0px; line-height: ' + ['','34px','22px'][compress] + '; }';
  593. styles += '#toolbox-switcher .fa { margin-right: ' + ['','5px','0px'][compress] + ' !important; }';
  594. //Toolbox menu
  595. styles += '.toolbox-dropdown-menu { top: ' + ['','17px','12px'][compress] + ' !important; }';
  596. //toolbar dropdowns
  597. styles += '.toolbar .toolbar-group { margin-right: ' + ['','14px','8px'][compress] + '; }';
  598. styles += '.toolbar .toolbar-icon { width: ' + ['','31px','22px'][compress] + '; height: ' + ['','34px','22px'][compress] + '; line-height: ' + ['','34px','22px'][compress] + '; }';
  599. styles += '.toolbar .group-title { height: ' + ['','34px','22px'][compress] + '; line-height: ' + ['','34px','22px'][compress] + '; margin-left: ' + ['','31px','22px'][compress] + '; }';
  600. styles += '.toolbar .dropdown-menu { top: ' + ['','34px','22px'][compress] + ' !important; left: ' + ['','7px','4px'][compress] + ' !important; }';
  601. //toolbar buttons
  602. 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] + '; }';
  603. //keep save button wide enough for counter
  604. styles += '.toolbar .toolbar-button.waze-icon-save { padding-right: 15px !important; }';
  605. styles += '.toolbar .toolbar-button.waze-icon-save .counter { top: ' + ['','-3px','-1px'][compress] + '; }';
  606. styles += '#edit-buttons > div > .toolbar-button > .item-icon { top: ' + ['','5px','2px'][compress] + '; }';
  607. styles += '.toolbar .toolbar-separator { height: ' + ['','34px','22px'][compress] + '; }';
  608. //layers menu
  609. styles += '.waze-icon-layers { height: ' + ['','27px','22px'][compress] + ' !important; margin-top: ' + ['','3px','0px'][compress] + ' !important; }';
  610. styles += '.layer-switcher .menu { top: ' + ['','31px','24px'][compress] + '; }';
  611. // fix for WME Edit Count Monitor
  612. styles += '#edit-buttons > div > div:nth-child(10) { margin-top: ' + ['','5px','-1px'][compress] + ' !important; }';
  613. //black bar
  614. styles += '.topbar { height: ' + ['','24px','18px'][compress] + '; line-height: ' + ['','24px','18px'][compress] + '; }';
  615. }
  616. if (contrast > 0) {
  617. //toolbar dropdown menus
  618. styles += '.toolbar .group-title { color: black; }';
  619. styles += '#edit-buttons > div > .toolbar-button { border-radius: 8px; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; color: black; }';
  620. //layers icon - until Waze fix it
  621. styles += '.layer-switcher .waze-icon-layers.toolbar-button{ background-color: white; }';
  622. }
  623. //Toolbox width override - can go with next TB update - now redundant
  624. // styles += '#edit-buttons { width: unset !important; }';
  625. // //fix for buttons of WME GIS script
  626. // styles += '.btn-group-sm { text-shadow: initial; background: white; }';
  627. addStyle(prefix + fname,styles);
  628. } else {
  629. removeStyle(prefix + fname);
  630. //change toolbar buttons - from JustinS83
  631. $('#mode-switcher .title-button .icon').removeClass('fa fa-calendar');
  632. $('#mode-switcher .title-button .icon').addClass('fa fa-angle-down');
  633. //un-hack Toolbar buttons
  634. if (document.getElementsByClassName("waze-icon-reload").length > 0) {
  635. $('.waze-icon-reload span').removeClass('fa fa-refresh fa-lg');
  636. $('.waze-icon-reload').addClass('reload');
  637. $('.waze-icon-reload span')[0].innerHTML = "Reload";
  638. }
  639. if (document.getElementsByClassName("waze-icon-undo").length > 0) {
  640. $('.waze-icon-undo span').removeClass('fa fa-undo fa-lg');
  641. $('.waze-icon-undo').addClass('undo');
  642. $('.waze-icon-undo span')[0].innerHTML = "Undo";
  643. }
  644. if (document.getElementsByClassName("waze-icon-redo").length > 0) {
  645. $('.waze-icon-redo span').removeClass('fa fa-repeat fa-lg');
  646. $('.waze-icon-redo').addClass('redo');
  647. $('.waze-icon-redo span')[0].innerHTML = "Redo";
  648. }
  649. buttonObserver.disconnect();
  650. }
  651. window.dispatchEvent(new Event('resize'));
  652. }
  653.  
  654. function hackToolbarButtons() {
  655. if (document.getElementsByClassName("waze-icon-reload").length > 0) {
  656. $('.waze-icon-reload').removeClass('reload');
  657. $('.waze-icon-reload span').addClass('fa fa-refresh fa-lg');
  658. $('.waze-icon-reload span')[0].innerHTML = "";
  659. }
  660. if (document.getElementsByClassName("waze-icon-undo").length > 0) {
  661. $('.waze-icon-undo').removeClass('undo');
  662. $('.waze-icon-undo span').addClass('fa fa-undo fa-lg');
  663. $('.waze-icon-undo span')[0].innerHTML = "";
  664. }
  665. if (document.getElementsByClassName("waze-icon-redo").length > 0) {
  666. $('.waze-icon-redo').removeClass('redo');
  667. $('.waze-icon-redo span').addClass('fa fa-repeat fa-lg');
  668. $('.waze-icon-redo span')[0].innerHTML = "";
  669. }
  670. buttonObserver.observe(getId('edit-buttons'), { childList: true, subtree: true });
  671. }
  672.  
  673. function FALSEcompressSegmentTab() {
  674. _cbCompressSegmentTab.checked = _cbextraCBSection.checked;
  675. compressSegmentTab();
  676. }
  677.  
  678. function compressSegmentTab() {
  679. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  680. logit("function " + fname + " called", "debug");
  681. var styles = "";
  682. if (_cbCompressSegmentTab.checked) {
  683. var contrast = _inpUIContrast.value;
  684. var compress = _inpUICompression.value;
  685. //Neuter the top gradient
  686. styles += '#sidebar .tab-scroll-gradient { pointer-events: none; }';
  687. //Nuke the bottom gradient
  688. styles += '#sidebar #links:before { display: none; }';
  689. if (compress > 0) {
  690. //Nuke the links at the bottom of the side panel
  691. styles += '#sidebar waze-links { display: none; }';
  692. //extend side panel to the bottom
  693. styles += '#edit-panel { height: calc(100% + 25px); }';
  694. //general compression enhancements
  695. styles += '#sidebar #advanced-tools { padding: ' + ['','0 9px','0 4px'][compress] + '; }';
  696. styles += '#sidebar waze-staff-tools { margin-bottom: ' + ['','9px','4px'][compress] + '; height: ' + ['','25px','20px'][compress] + '; }';
  697. styles += '#sidebar .tab-content { padding: ' + ['','9px','4px'][compress] + '; padding-top: ' + ['','4px','0px'][compress] + '; }';
  698. //Tabs
  699. styles += '#sidebar .nav-tabs { padding-bottom: ' + ['','3px','2px'][compress] + '; }';
  700. styles += '#sidebar #user-info #user-tabs { padding: ' + ['','0 9px','0 4px'][compress] + '; }';
  701. 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] + '; }';
  702. styles += '#sidebar .nav-tabs li { flex-grow: 0; }';
  703. //Feed
  704. styles += '.feed-item { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  705. styles += '.feed-item .inner { padding: ' + ['','5px','0px'][compress] + '; }';
  706. styles += '.feed-item .content .title { margin-bottom: ' + ['','1px','0px'][compress] + '; }';
  707. styles += '.feed-item .motivation { margin-bottom: ' + ['','2px','0px'][compress] + '; }';
  708. //Drives & Areas
  709. styles += '#sidebar .message { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  710. styles += '#sidebar .result-list .result { padding: ' + ['','6px 17px','2px 9px'][compress] + '; margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  711. styles += 'div#sidepanel-drives { height: auto !important; }';
  712. //SEGMENT EDIT PANEL
  713. //general changes
  714. //checkbox groups
  715. styles += '#sidebar .controls-container { padding-top: ' + ['','4px','1px'][compress] + '; display: inline-block; font-size: ' + ['','12px','11px'][compress] + '; }';
  716. //form groups
  717. styles += '#sidebar .form-group { margin-bottom: ' + ['','5px','0px'][compress] + '; }';
  718. //dropdown inputs
  719. styles += '#sidebar .form-control { height: ' + ['','27px','19px'][compress] + '; padding-top: ' + ['','4px','0px'][compress] + '; padding-bottom: ' + ['','4px','0px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; color: black; }';
  720. //buttons
  721. styles += '#edit-panel .waze-btn { padding-top: ' + ['','3px','0px'][contrast] + ' !important; padding-bottom: ' + ['','3px','1px'][contrast] + '; height: ' + ['','20px','18px'][compress] + ' !important; line-height: ' + ['','20px','18px'][compress] + ' !important; font-size: ' + ['','13px','12px'][compress] + '; }';
  722. // styles += '#edit-panel .waze-btn.waze-btn-smaller { line-height: ' + ['','20px','18px'][compress] + ' !important; }';
  723. //radio button controls
  724. 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] + '; }';
  725. //specific changes
  726. //Selected segments info
  727. styles += '#edit-panel .selection { padding-top: ' + ['','8px','2px'][compress] + '; padding-bottom: ' + ['','8px','4px'][compress] + '; }';
  728. styles += '#edit-panel .segment .direction-message { margin-bottom: ' + ['','9px','3px'][compress] + '; }';
  729. //Segment details (closure warning)
  730. styles += '#edit-panel .segment .segment-details { padding: ' + ['','10px','5px'][compress] + '; padding-top: 0px; }';
  731. //All control labels
  732. styles += '#edit-panel .control-label { font-size: ' + ['','11px','10px'][compress] + '; margin-bottom: ' + ['','4px','1px'][compress] + '; }';
  733. //Address input
  734. styles += '#edit-panel .address-edit-view { cursor: pointer; margin-bottom: ' + ['','6px','2px'][compress] + '!important; }';
  735. styles += '#edit-panel .address-edit-input { padding: ' + ['','4px','1px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  736. styles += '.tts-button { height: ' + ['','28px','21px'][compress] + '; }';
  737. //speed limit controls
  738. styles += '#edit-panel .segment .speed-limit label { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  739. styles += '#edit-panel .segment .speed-limit .form-control { height: ' + ['','23px','19px'][compress] + '; padding-top: ' + ['','4px','2px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; width: 5em; }';
  740. styles += '#edit-panel .segment .speed-limit .direction-label { font-size: ' + ['','12px','11px'][compress] + '; line-height: ' + ['','2.0em','1.8em'][compress] + '; }';
  741. 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' ) + '; }';
  742. //more actions section
  743. styles += '#edit-panel .more-actions { padding-top: ' + ['','6px','2px'][compress] + '; }';
  744. styles += '#edit-panel .more-actions .waze-btn.waze-btn-white { padding-left: 0px; padding-right: 0px; }';
  745. // 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; }';
  746. //get more-actions buttons on one line
  747. styles += '#edit-panel .more-actions { display: inline-flex; }';
  748. styles += '#edit-panel .action-button { width: 155px; overflow: hidden; }';
  749. styles += '#edit-panel .action-button:before { margin-right: 0px !important; }';
  750. styles += '#edit-panel .more-actions .edit-house-numbers-btn-wrapper { margin-top: 0px; }';
  751. //additional attributes
  752. styles += '#edit-panel .additional-attributes { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  753. //history items
  754. styles += '.toggleHistory { padding: ' + ['','7px','3px'][compress] + '; }';
  755. styles += '.element-history-item:not(:last-child) { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  756. styles += '.element-history-item .tx-header { padding: ' + ['','6px','2px'][compress] + '; }';
  757. styles += '.element-history-item .tx-header .tx-author-date { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  758. styles += '.element-history-item .tx-content { padding: ' + ['','7px 7px 7px 22px','4px 4px 4px 22px'][compress] + '; }';
  759. styles += '.loadMoreContainer { padding: ' + ['','5px 0px','3px 0px'][compress] + '; }';
  760. //closures list
  761. styles += '.closures-list .add-closure-button { line-height: ' + ['','20px','18px'][compress] + '; }';
  762. styles += '.closures-list .closure-item:not(:last-child) { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  763. styles += '.closures-list .closure-item .details { padding: ' + ['','5px','0px'][compress] + '; font-size: ' + ['','12px','11px'][compress] + '; }';
  764. styles += '.closures-list .closure-item .buttons { top: ' + ['','7px','4px'][compress] + '; }';
  765. //tweak for Junction Box button
  766. styles += '#edit-panel .junction-actions > button { width: inherit; }';
  767. //PLACE DETAILS
  768. //alert
  769. styles += '#edit-panel .header-alert { margin-bottom: ' + ['','6px','2px'][compress] + '; padding: ' + ['','6px','2px'][compress] + '; }';
  770. //address input
  771. styles += '#edit-panel .full-address { padding-top: ' + ['','4px','1px'][compress] + '; padding-bottom: ' + ['','4px','1px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  772. //alt names
  773. styles += '#edit-panel .aliases-view .list li { margin: ' + ['','12px 0','4px 0'][compress] + '; }';
  774. styles += '#edit-panel .aliases-view .delete { line-height: inherit; }';
  775. //categories
  776. 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] + '; }';
  777. styles += '#edit-panel .categories .select2-search-field input { height: ' + ['','18px','17px'][compress] + '; }';
  778. styles += '#edit-panel .categories .select2-choices { min-height: ' + ['','26px','19px'][compress] + '; }';
  779. styles += '#edit-panel .categories .select2-container { margin-bottom: 0px; }';
  780. //entry/exit points
  781. styles += '#edit-panel .navigation-point-view .navigation-point-list-item .preview { padding: ' + ['','3px 7px','0px 4px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  782. styles += '#edit-panel .navigation-point-view .add-button { height: ' + ['','28px','18px'][contrast] + '; line-height: ' + ['','17px','16px'][contrast] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  783. //type buttons
  784. styles += '#sidebar .area-btn, #sidebar .point-btn { height: ' + ['','19px','16px'][compress] + '; line-height: ' + ['','19px','16px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  785. // { height: ' + ['','19px','16px'][compress] + '; width: ' + ['','19px','16px'][compress] + '; line-height: ' + ['','19px','16px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  786. //external providers
  787. styles += '.select2-container { font-size: ' + ['','13px','12px'][compress] + '; }';
  788. styles += '#edit-panel .external-providers-view .external-provider-item { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  789. styles += '.external-providers-view > div > ul { margin-bottom: ' + ['','4px','0px'][compress] + '; }';
  790. styles += '#edit-panel .external-providers-view .add { padding: ' + ['','3px 12px','1px 9px'][compress] + '; }';
  791. styles += '#edit-panel .waze-btn.waze-btn-smaller { line-height: ' + ['','26px','21px'][compress] + '; }';
  792. //residential toggle
  793. styles += '#edit-panel .toggle-residential { height: ' + ['','27px','22px'][compress] + '; }';
  794. //more info
  795. styles += '.service-checkbox { font-size: ' + ['','13px','12px'][compress] + '; }';
  796. //Compression for WME Speedhelper
  797. styles += '.clearfix.controls.speed-limit { margin-top: ' + ['','-4px','-8px'][compress] + '; }';
  798. //Compression for WME Clicksaver
  799. styles += '.rth-btn-container { margin-bottom: ' + ['','2px','-1px'][compress] + '; }';
  800. styles += '#csRoutingTypeContainer { height: ' + ['','23px','16px'][compress] + ' !important; margin-top: ' + ['','-2px','-4px'][compress] + '; }';
  801. styles += '#csElevationButtonsContainer { margin-bottom: ' + ['','2px','-1px'][compress] + ' !important; }';
  802. //tweaks for UR-MP Tracker
  803. styles += '#sidepanel-urt { margin-left: ' + ['','-5px','0px'][compress] + ' !important; }';
  804. styles += '#urt-main-title { margin-top: ' + ['','-5px','0px'][compress] + ' !important; }';
  805. }
  806. if (contrast > 0) {
  807. //contrast enhancements
  808. //general
  809. styles += '#sidebar .form-group { border-top: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  810. //text colour
  811. styles += '#sidebar { color: black; }';
  812. //advanced tools section
  813. styles += '#sidebar waze-staff-tools { background-color: #c7c7c7; }';
  814. //Tabs
  815. styles += '#sidebar .nav-tabs { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  816. styles += '#sidebar .nav-tabs li a { border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
  817. //Feed
  818. styles += '.feed-item { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  819. //Drives & Areas
  820. styles += '#sidebar .result-list .result { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  821. //Segment edit panel
  822. styles += '#edit-panel .selection { font-size: 13px; }';
  823. styles += '#edit-panel .segment .direction-message { color: orangered; }';
  824. styles += '#edit-panel .address-edit-input { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  825. styles += '#sidebar .form-control { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  826. //radio buttons when disabled
  827. styles += '.waze-radio-container input[type="radio"]:disabled:checked + label { color: black; opacity: 0.7; font-weight:600; }';
  828. //override border for lock levels
  829. styles += '#sidebar .waze-radio-container { border: 0 none !important; }';
  830. styles += '#edit-panel .waze-btn { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  831. styles += '.waze-radio-container label { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  832. //history items
  833. styles += '.toggleHistory { color: black; text-align: center; }';
  834. styles += '.element-history-item .tx-header { color: black; }';
  835. styles += '.element-history-item.closed .tx-header { border-radius: 8px; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  836. styles += '.loadMoreHistory { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  837. //closures list
  838. styles += '.closures-list .closure-item .details { border-radius: 8px; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  839. styles += '.closures-list .closure-item .dates { color: black; }';
  840. styles += '.closures-list .closure-item .dates .date-label { opacity: 1; }';
  841. //Place details
  842. //alert
  843. styles += '#edit-panel .alert-danger { color: red; }';
  844. //address input
  845. styles += '#edit-panel .full-address { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  846. styles += '#edit-panel a.waze-link { font-weight: bold; }';
  847. //categories
  848. styles += '#edit-panel .categories .select2-search-choice .category { text-transform: inherit; font-weight: bold; background: gray; }';
  849. //entry/exit points
  850. styles += '#edit-panel .navigation-point-view .navigation-point-list-item .preview { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  851. styles += '#edit-panel .navigation-point-view .add-button { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; margin-top: 2px; padding: 0 5px; }';
  852. //type buttons
  853. styles += '#sidebar .point-btn { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
  854. //external providers
  855. styles += '.select2-container { color: teal; border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
  856. styles += '.select2-container .select2-choice { color: black; }';
  857. //residential toggle
  858. styles += '#edit-panel .toggle-residential { font-weight: bold; }';
  859. }
  860. //fix for buttons of WME Image Overlay script
  861. styles += '#sidepanel-imageoverlays > div.result-list button { height: 24px; }';
  862. addStyle(prefix + fname,styles);
  863. } else {
  864. removeStyle(prefix + fname);
  865. }
  866. }
  867.  
  868. function compressLayersMenu() {
  869. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  870. logit("function " + fname + " called", "debug");
  871. removeStyle(prefix + fname);
  872. var styles = "";
  873. if (_cbCompressLayersMenu.checked) {
  874. getId('layersColControls').style.opacity = '1';
  875. var contrast = _inpUIContrast.value;
  876. var compress = _inpUICompression.value;
  877. if (compress > 0) {
  878. //VERTICAL CHANGES
  879. //Change menu to autoheight
  880. var menuHeight = document.querySelector("#toolbar > div > div.layer-switcher-container > div > div > div > div > div.menu").style.height;
  881. styles += '.layer-switcher .menu { height: auto !important; max-height: ' + menuHeight + '; overflow-y: scroll; width: auto; }';
  882. //Shrink options toggler section
  883. styles += '.layer-switcher .more-options-toggle { line-height: ' + ['','27px','19px'][compress] + '; height: ' + ['','27px','19px'][compress] + '; font-size: ' + ['','12px','11px'][compress] + '; }';
  884. styles += '.layer-switcher .more-options-toggle .pinned { font-size: ' + ['','19px','17px'][compress] + '; width: auto; }';
  885. styles += '.layer-switcher .scrollable { height: calc(100% - ' + ['','29px','22px'][compress] + '); overflow-x: hidden; font-size: ' + ['','13px','12px'][compress] + '; }';
  886. //menu
  887. styles += '.layer-switcher .togglers { padding: ' + ['','6px','2px'][compress] + '; width: auto; }';
  888. //line spacing
  889. styles += '.layer-switcher .toggler { padding-top: ' + ['','2px','0px'][compress] + '; padding-bottom: ' + ['','2px','0px'][compress] + '; line-height: ' + ['','16px','15px'][compress] + '; }';
  890. styles += '.layer-switcher .togglers .text-checkboxes .text-checkbox { margin-top: ' + ['','-2px','-4px'][compress] + '; margin-left: ' + ['','7px','2px'][compress] + '; }';
  891. //group separators
  892. styles += '.layer-switcher .togglers .group:not(:last-child)::after { margin: ' + ['','5px -7px 5px -7px','0 -7px 0 -7px'][compress] + '; }';
  893. //HORIZONTAL CHANGES
  894. styles += '.layer-switcher .togglers .children { padding-left: ' + ['','17px','12px'][compress] + '; }';
  895. if (_cbLayersColumns.checked) {
  896. //2 column stuff
  897. styles += '.layer-switcher .scrollable { columns: 2; }';
  898. styles += '.controls-container input[type="checkbox"]:checked + label:after { WME: FU; transform: unset; }';
  899. styles += 'li.group { break-inside: avoid; page-break-inside: avoid; }';
  900. styles += '.layer-switcher .togglers { padding-top: 0px; }';
  901. }
  902. } else {
  903. //2-columns not available without compression
  904. getId('layersColControls').style.opacity = '0.5';
  905. }
  906. if (contrast > 0) {
  907. //less options toggle
  908. styles += '.layer-switcher .more-options-toggle { color: ' + ['','#5ca6bc','#2e6170'][contrast] + '; }';
  909. //Group headers
  910. styles += '.controls-container.main.toggler { color: white; background: dimgray; }';
  911. styles += '.layer-switcher .toggler.main .label-text { text-transform: inherit; }';
  912. //labels
  913. styles += '.layer-switcher .togglers .children { color: ' + ['','#1e1e1e','#000000'][contrast] + '; }';
  914. //column rule
  915. styles += '.layer-switcher .scrollable { column-rule: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  916. }
  917. addStyle(prefix + fname,styles);
  918. } else {
  919. getId('layersColControls').style.opacity = '0.5';
  920. removeStyle(prefix + fname);
  921. }
  922. }
  923.  
  924. function restyleReports() {
  925. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  926. logit("function " + fname + " called", "debug");
  927. var styles = "";
  928. if (_cbRestyleReports.checked) {
  929. var contrast = _inpUIContrast.value;
  930. var compress = _inpUICompression.value;
  931. if (compress > 0) {
  932. //report header
  933. styles += '#panel-container .header { padding: ' + ['','9px 36px','1px 36px'][compress] + '; line-height: ' + ['','19px','17px'][compress] + '; }';
  934. styles += '#panel-container .header .dot { top: ' + ['','15px','7px'][compress] + '; }';
  935. //report body
  936. styles += '#panel-container .body { line-height: ' + ['','15px','13px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  937. //problem description
  938. styles += '#panel-container div.description.section > div.collapsible.content { padding: ' + ['','9px','3px'][compress] + '; }';
  939. //comments
  940. styles += '#panel-container .conversation-view .comment .comment-content { padding: ' + ['','6px 9px','2px 3px'][compress] + '; }';
  941. styles += '#panel-container .comment .text { padding: ' + ['','7px 9px','4px 4px'][compress] + '; }';
  942. //new comment entry
  943. styles += '#panel-container .conversation-view .new-comment-form { padding: ' + ['','8px 9px 6px 9px','1px 3px 2px 3px'][compress] + '; }';
  944. //send button
  945. styles += '#panel-container .conversation-view .send-button { padding: ' + ['','4px 16px','2px 12px'][compress] + '; box-shadow: ' + ['','3px 3px 4px 0 #def7ff','3px 2px 4px 0 #def7ff'][compress] + '; }';
  946. //lower buttons
  947. styles += '#panel-container > div > div > div.actions > div > div { WME: FU; padding-top: ' + ['','6px','3px'][compress] + '; }';
  948. styles += '#panel-container .close-details.section { font-size: ' + ['','13px','12px'][compress] + '; line-height: ' + ['','13px','9px'][compress] + '; }';
  949. styles += '#panel-container .problem-edit .actions .controls-container label { WME: FU; height: ' + ['','28px','21px'][compress] + '; line-height: ' + ['','28px','21px'][compress] + '; margin-bottom: ' + ['','5px','2px'][compress] + '; }';
  950. styles += '#panel-container .waze-plain-btn { height: ' + ['','30px','20px'][compress] + '; line-height: ' + ['','30px','20px'][compress] + '; }';
  951. styles += '.panel .navigation { margin-top: ' + ['','6px','2px'][compress] + '; }';
  952. //WMEFP All PM button
  953. styles += '#WMEFP-UR-ALLPM { top: ' + ['','5px','0px'][compress] + ' !important; }';
  954. }
  955. if (contrast > 0) {
  956. styles += '#panel-container .section { border-bottom: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  957. styles += '#panel-container .close-panel { border-color: ' + ['','lightgrey','grey'][contrast] + '; }';
  958. styles += '#panel-container .main-title { font-weight: 900; }';
  959. styles += '#panel-container .reported { color: ' + ['','dimgrey','black'][contrast] + '; }';
  960. styles += '#panel-container .date { color: ' + ['','#6d6d6d','#3d3d3d'][contrast] + '; }';
  961. styles += '#panel-container .comment .text { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  962. styles += '#panel-container .comment-content.reporter .username { color: ' + ['','#159dc6','#107998'][contrast] + '; }';
  963. styles += '#panel-container .conversation-view .new-comment-form textarea { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  964. styles += '#panel-container .top-section { border-bottom: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  965. styles += '#panel-container .waze-plain-btn { font-weight: 800; color: ' + ['','#159dc6','#107998'][contrast] + '; }';
  966. }
  967. addStyle(prefix + fname,styles);
  968. if (wmeFUinitialising) {
  969. setTimeout(draggablePanel, 5000);
  970. } else {
  971. draggablePanel();
  972. }
  973. } else {
  974. removeStyle(prefix + fname);
  975. if (jQuery.ui) {
  976. if ( $("#panel-container").hasClass('ui-draggable') ) {
  977. $("#panel-container").draggable("destroy");
  978. }
  979. getId("panel-container").style = "";
  980. }
  981. }
  982. window.dispatchEvent(new Event('resize'));
  983. }
  984.  
  985. function draggablePanel() {
  986. if (jQuery.ui) {
  987. if ($("#panel-container").data("ui-draggable")) {
  988. $("#panel-container").draggable({ handle: ".header" });
  989. }
  990. }
  991. }
  992.  
  993. function enhanceChat() {
  994. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  995. logit("function " + fname + " called", "debug");
  996. var styles = "";
  997. if (_cbEnhanceChat.checked) {
  998. removeStyle(prefix + fname);
  999. var contrast = _inpUIContrast.value;
  1000. var compress = _inpUICompression.value;
  1001. var mapX = getId('map').clientWidth;
  1002. var mapY = getId('map').clientHeight;
  1003. var chatX = Math.floor( mapX * 0.45);
  1004. var chatY = Math.floor( mapY * 0.5);
  1005. var chatHeaderY = [50,35,20][compress];
  1006. var chatMessageInputY = [39,31,23][compress];
  1007. var chatMessagesY = chatY - chatHeaderY - chatMessageInputY;
  1008. var chatUsersY = chatY - chatHeaderY;
  1009. //change chat width to 45% of map view
  1010. styles += '#chat-overlay { width: ' + chatX + 'px; min-width: 334px; }'; //14px added for Chat addon
  1011. styles += '#chat .messages { width: 70%; min-width: 200px;}';
  1012. styles += '#map.street-view-mode #chat .messages { width: 70%; }';
  1013. styles += '#chat .messages .message-list { margin-bottom: 0px; }';
  1014. styles += '#chat .messages .new-message { position: inherit; width: unset; }';
  1015. styles += '#map.street-view-mode #chat .messages .new-message { position: inherit; width: unset; }';
  1016. styles += '#chat .users { width: 30%; min-width: 120px; }';
  1017. styles += '#chat .messages .message-list .message.normal-message { max-width: unset; }';
  1018. //change chat height to 50% of map view
  1019. styles += '#chat .messages .message-list { min-height: ' + chatMessagesY + 'px; }';
  1020. styles += '#chat .users { max-height: ' + chatUsersY + 'px; }';
  1021. // #chat .messages .unread-messages-notification width=70%, bottom64px>
  1022. if (compress > 0) {
  1023. //do compression
  1024. //header
  1025. styles += '#chat .header { line-height: ' + chatHeaderY + 'px; }';
  1026. styles += '#chat .header .dropdown .dropdown-toggle { line-height: ' + ['','30px','19px'][compress] + '; }';
  1027. styles += '#chat .header button { line-height: ' + ['','20px','19px'][compress] + '; font-size: ' + ['','13px','11px'][compress] + '; height: ' + ['','20px','19px'][compress] + '; }';
  1028. //message list
  1029. styles += '#chat .messages .message-list { padding: ' + ['','9px','3px'][compress] + '; }';
  1030. styles += '#chat .messages .message-list .message.normal-message { padding: ' + ['','6px','2px'][compress] + '; }';
  1031. styles += '#chat .messages .message-list .message { margin-bottom: ' + ['','8px','2px'][compress] + '; line-height: ' + ['','16px','14px'][compress] + '; font-size: ' + ['','12px','11px'][compress] + '; }';
  1032. styles += '#chat .messages .new-message input { height: ' + chatMessageInputY + 'px; }';
  1033. //user list
  1034. styles += '#chat .users { padding: ' + ['','8px','1px'][compress] + '; }';
  1035. styles += '#chat ul.user-list a.user { padding: ' + ['','2px','1px'][compress] + '; }';
  1036. styles += '#chat ul.user-list a.user .rank { width: ' + ['','25px','20px'][compress] + '; height: ' + ['','20px','16px'][compress] + '; margin-right: ' + ['','3px','1px'][compress] + '; }';
  1037. styles += '#chat ul.user-list a.user .username { line-height: ' + ['','21px','17px'][compress] + '; }';
  1038. styles += '#chat ul.user-list a.user:hover .crosshair { margin-top: ' + ['','3px','1px'][compress] + '; right: ' + ['','3px','1px'][compress] + '; }';
  1039. //fix for WME Chat Addon
  1040. styles += '#chat .users > ul > li > a { margin: 0px !important; }';
  1041. }
  1042. if (contrast > 0) {
  1043. //header
  1044. styles += '#chat .header { color: black; background-color: ' + ['','#d9d9d9','#bfbfbf'][contrast] + '; }';
  1045. styles += '#chat .messages .message-list { background-color: ' + ['','#e8e8e8','lightgrey'][contrast] + '; }';
  1046. styles += '#chat .messages .message-list .message.normal-message { color: black; float: left; }';
  1047. styles += '#chat .messages .message-list .message.normal-message .from { color: dimgrey; font-weight: bold; font-style: italic; }';
  1048. styles += '#chat .messages .message-list .message.own-message .from { color: black; background-color: #a1dcf5; }';
  1049. //user message timestamps
  1050. styles += '#chat > div.chat-body > div.messages > div.message-list > div > div.from > span { color: ' + ['','dimgrey','black'][contrast] + ' !important; }';
  1051. //system message timestamps
  1052. styles += '#chat > div.chat-body > div.messages > div.message-list > div > div.body > div > span { color: ' + ['','dimgrey','black'][contrast] + ' !important; }';
  1053. //fix for WME Chat Addon
  1054. styles += '#chat .body > div { color: black !important; }';
  1055. }
  1056. //fix for Chat Addon timestamps running up against names
  1057. styles += '#chat > div.chat-body > div.messages > div.message-list > div > div.from > span { margin-left: 5px; }';
  1058. addStyle(prefix + fname,styles);
  1059. } else {
  1060. removeStyle(prefix + fname);
  1061. }
  1062. }
  1063.  
  1064. function narrowSidePanel() {
  1065. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1066. logit("function " + fname + " called", "debug");
  1067. var styles = "";
  1068. if (_cbNarrowSidePanel.checked) {
  1069. //sidebar width
  1070. styles += '.row-fluid #sidebar { width: 250px; }';
  1071. //map width
  1072. styles += '.show-sidebar .row-fluid .fluid-fixed { margin-left: 250px; }';
  1073. //user info tweaks
  1074. styles += '#sidebar #user-info #user-box { padding: 0 0 5px 0; }';
  1075. styles += '#sidebar #user-details { width: 250px; }';
  1076. styles += '#sidebar #user-details .user-profile .level-icon { margin: 0; }';
  1077. styles += '#sidebar #user-details .user-profile .user-about { max-width: 161px; }';
  1078. //gradient bars
  1079. styles += '#sidebar .tab-scroll-gradient { width: 220px; }';
  1080. styles += '#sidebar #links:before { width: 236px; }';
  1081. //feed
  1082. styles += '.feed-item .content { max-width: 189px; }';
  1083. //segment edit panel
  1084. styles += '#edit-panel .more-actions .waze-btn.waze-btn-white { width: 122px; }';
  1085. //tweak for WME Bookmarks
  1086. styles += '#divBookmarksContent .divName { max-width: 164px; }';
  1087. addStyle(prefix + fname, styles);
  1088. } else {
  1089. removeStyle(prefix + fname);
  1090. }
  1091. compressSegmentTab();
  1092. window.dispatchEvent(new Event('resize'));
  1093. }
  1094.  
  1095. function hideAveSpeedControls() {
  1096. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1097. logit("function " + fname + " called", "debug");
  1098. removeStyle(prefix + fname);
  1099. if (_cbHideAveSpeedControls.checked) {
  1100. var ASCBox;
  1101. if (getId('fwdSpeedCameraCheckbox')) {
  1102. ASCBox = getId('fwdSpeedCameraCheckbox');
  1103. }
  1104. if (getId('revSpeedCameraCheckbox')) {
  1105. ASCBox = getId('revSpeedCameraCheckbox');
  1106. }
  1107. if (ASCBox) {
  1108. var formGroup = ASCBox.parentNode.parentNode.parentNode;
  1109. var formGroupParent = formGroup.parentNode;
  1110. var targetGroup = Array.prototype.indexOf.call(formGroupParent.children, formGroup) + 1;
  1111. addStyle(prefix + fname, '#segment-edit-general > .side-panel-section.attributes-form > .form-group:nth-of-type(' + targetGroup + ') { display: none; }');
  1112. }
  1113. }
  1114. }
  1115.  
  1116. function WaddZoomIndicator() {
  1117. if (getId("_cbAddZoomIndicator").checked === true) {
  1118. alert("You have enabled the Zoom Level Indicator\n"+
  1119. "Please be aware that this function is not yet compatible with WME V2");
  1120. }
  1121. addZoomIndicator();
  1122. }
  1123.  
  1124. function addZoomIndicator() {
  1125. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1126. logit("function " + fname + " called", "debug");
  1127. var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
  1128. if (_cbAddZoomIndicator.checked) {
  1129. addStyle(prefix + fname, '.slider { font-size: 15px; font-weight: 900; line-height: 1; height: 18px; margin-top: 23px; padding-top: 2px; text-align: center; }');
  1130. Waze.map.events.register("zoomend", null, ZLI);
  1131. ZLI();
  1132. } else {
  1133. removeStyle(prefix + fname);
  1134. Waze.map.events.unregister("zoomend", null, ZLI);
  1135. slider.innerText = "";
  1136. slider.title = "";
  1137. }
  1138. }
  1139.  
  1140. function ZLI() {
  1141. var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
  1142. slider.innerText = Waze.map.zoom;
  1143. slider.title = "Zoom level indicator by WMEFU";
  1144. switch (Waze.map.zoom) {
  1145. case 0:
  1146. case 1:
  1147. slider.style.background = '#ef9a9a';
  1148. slider.title += "\nCannot permalink any segments at this zoom level";
  1149. break;
  1150. case 2:
  1151. case 3:
  1152. slider.style.background = '#ffe082';
  1153. slider.title += "\nCan only permalink primary or higher at this zoom level";
  1154. break;
  1155. default:
  1156. slider.style.background = '#ffffff';
  1157. slider.title += "\nCan permalink any segments at this zoom level";
  1158. break;
  1159. }
  1160. }
  1161.  
  1162. function shiftAerials() {
  1163. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1164. logit("function " + fname + " called", "debug");
  1165. // calculate meters/pixel for current map view
  1166. var ipu = OpenLayers.INCHES_PER_UNIT;
  1167. var metersPerPixel = Waze.map.getResolution() * ipu.m / ipu[Waze.map.getUnits()];
  1168. // Apply the shift and opacity
  1169. Waze.map.baseLayer.div.style.left = Math.round(getId("_inpASX").value / metersPerPixel) + 'px';
  1170. Waze.map.baseLayer.div.style.top = Math.round(- getId("_inpASY").value / metersPerPixel) + 'px';
  1171. Waze.map.baseLayer.div.style.opacity = getId("_inpASO").value/100;
  1172. //turn off Enhance Chat if WME Chat Fix is loaded
  1173. if (document.getElementById('WMEfixChat-setting')) {
  1174. if (_cbEnhanceChat.checked === true) {
  1175. alert("WME FixUI: Enhance Chat disabled because WME Chat UI Fix detected");
  1176. }
  1177. _cbEnhanceChat.checked = false;
  1178. }
  1179. }
  1180.  
  1181. function fixExternalProviders () {
  1182. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1183. logit("function " + fname + " called", "debug");
  1184. var styles = "";
  1185. if (_cbFixExternalProviders.checked) {
  1186. //enlarge external provider boxes
  1187. styles += '#edit-panel .external-providers-view .select2-container { width: 90%; margin-bottom: 2px; }';
  1188. styles += '.select2-container .select2-choice { height: inherit; line-height: 16px; }';
  1189. styles += '.select2-container .select2-choice>.select2-chosen { white-space: normal; }';
  1190. styles += '.placeId { padding-bottom: 5px; }';
  1191. addStyle(prefix + fname,styles);
  1192. } else {
  1193. removeStyle(prefix + fname);
  1194. }
  1195. }
  1196.  
  1197. function warnCommentsOff() {
  1198. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1199. logit("function " + fname + " called", "debug");
  1200. if (Waze.map.getLayerByUniqueName('mapComments').visibility === false) {
  1201. removeStyle(prefix + fname);
  1202. addStyle(prefix + fname, '.toolbar { background-color: #FFC107; }');
  1203. } else {
  1204. removeStyle(prefix + fname);
  1205. }
  1206. }
  1207.  
  1208. function adjustGSV() {
  1209. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1210. logit("function " + fname + " called", "debug");
  1211. var styles = "";
  1212. styles += '.gm-style { filter: contrast(' + getId('_inpGSVContrast').value + '%) ';
  1213. styles += 'brightness(' + getId('_inpGSVBrightness').value + '%) ';
  1214. if (getId('_cbGSVInvert').checked) {
  1215. styles += 'invert(1); }';
  1216. } else {
  1217. styles += 'invert(0); }';
  1218. }
  1219. removeStyle(prefix + fname);
  1220. addStyle(prefix + fname, styles);
  1221. }
  1222.  
  1223. function permalinkCheck() {
  1224. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1225. logit("function " + fname + " called", "debug");
  1226. var selSegments = Waze.selectionManager.selectedItems.length;
  1227. if ( URLSegmentCount != selSegments ) {
  1228. alert("WARNING FROM WME FixUI!\n\n" +
  1229. "You have opened a permalink with " + URLSegmentCount + " segments,\n" +
  1230. "but the total selected in WME is " + selSegments + ".\n\n" +
  1231. "The permalink may contain segments not selectable at this zoom\n" +
  1232. "or not visible on-screen, or some segment IDs may have been\n" +
  1233. "changed since the permalink was created.");
  1234. }
  1235. Waze.selectionManager.events.unregister("selectionchanged", null, permalinkCheck);
  1236. }
  1237.  
  1238. function moveChatIcon() {
  1239. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1240. logit("function " + fname + " called", "debug");
  1241. var styles = "";
  1242. if (_cbMoveChatIcon.checked) {
  1243. styles += '#chat-overlay { left: inherit !important; right: 30px !important; }';
  1244. if (UIver == "new") {
  1245. styles += '#chat-overlay #chat-toggle { right: 0px !important; }';
  1246. }
  1247. addStyle(prefix + fname,styles);
  1248. } else {
  1249. removeStyle(prefix + fname);
  1250. }
  1251. }
  1252.  
  1253. function darkenSaveLayer() {
  1254. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1255. logit("function " + fname + " called", "debug");
  1256. var styles = "";
  1257. if (_cbDarkenSaveLayer.checked) {
  1258. //don't publish without alteration!
  1259. styles += '#popup-overlay { background-color: dimgrey !important; }';
  1260. addStyle(prefix + fname,styles);
  1261. } else {
  1262. removeStyle(prefix + fname);
  1263. }
  1264. }
  1265.  
  1266. function swapRoadsGPS() {
  1267. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1268. logit("function " + fname + " called", "debug");
  1269. var styles = "";
  1270. if (_cbSwapRoadsGPS.checked) {
  1271. var roadLayerId = W.map.getLayerByUniqueName("roads").id;
  1272. var GPSLayerId = W.map.getLayerByUniqueName("gps_points").id;
  1273. var roadLayerZ = W.map.getLayerByUniqueName("roads").getZIndex();
  1274. var GPSLayerZ = W.map.getLayerByUniqueName("gps_points").getZIndex();
  1275. logit("Layers identified\n\tRoads: " + roadLayerId + "," + roadLayerZ + "\n\tGPS: " + GPSLayerId + "," + GPSLayerZ, "info");
  1276. styles += '#' + roadLayerId.replace(/\./g,"\\2e") + ' { z-index: ' + GPSLayerZ + ' !important; }';
  1277. styles += '#' + GPSLayerId.replace(/\./g,"\\2e") + ' { z-index: ' + roadLayerZ + ' !important; }';
  1278. // var layers = document.getElementById('OpenLayers.Map_184_OpenLayers_Container').children;
  1279. // for (i = 0; i < layers.length; i++) {
  1280. // if (layers[i].style.zIndex == 335) {
  1281. // styles += '#' + layers[i].id.replace(/\./g,"\\2e") + ' { z-index: 342 !important; }';
  1282. // }
  1283. // }
  1284. addStyle(prefix + fname,styles);
  1285. } else {
  1286. removeStyle(prefix + fname);
  1287. }
  1288. }
  1289.  
  1290. function undarkenAerials() {
  1291. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  1292. logit("function " + fname + " called", "debug");
  1293. var styles = "";
  1294. if (_cbUndarkenAerials.checked) {
  1295. styles += '.olTileImage { filter: none !important; }'; // for current production WME
  1296. styles += '.satellite-overlay { display: none !important; }'; //for current beta WME
  1297. addStyle(prefix + fname,styles);
  1298. } else {
  1299. removeStyle(prefix + fname);
  1300. }
  1301. }
  1302.  
  1303. //Helper functions
  1304.  
  1305. function addGlobalStyle(css) {
  1306. var head, style;
  1307. head = document.getElementsByTagName('head')[0];
  1308. if (!head) {
  1309. return;
  1310. }
  1311. style = document.createElement('style');
  1312. style.type = 'text/css';
  1313. style.innerHTML = css;
  1314. head.appendChild(style);
  1315. }
  1316.  
  1317. function addStyle(ID, css) {
  1318. var head, style;
  1319. head = document.getElementsByTagName('head')[0];
  1320. if (!head) {
  1321. return;
  1322. }
  1323. removeStyle(ID); // in case it is already there
  1324. style = document.createElement('style');
  1325. style.type = 'text/css';
  1326. style.innerHTML = css;
  1327. style.id = ID;
  1328. head.appendChild(style);
  1329. }
  1330.  
  1331. function removeStyle(ID) {
  1332. var style = document.getElementById(ID);
  1333. if (style) { style.parentNode.removeChild(style); }
  1334. }
  1335.  
  1336. function getElementsByClassName(classname, node) {
  1337. if(!node) { node = document.getElementsByTagName("body")[0]; }
  1338. var a = [];
  1339. var re = new RegExp('\\b' + classname + '\\b');
  1340. var els = node.getElementsByTagName("*");
  1341. for (var i=0,j=els.length; i<j; i++) {
  1342. if (re.test(els[i].className)) { a.push(els[i]); }
  1343. }
  1344. return a;
  1345. }
  1346.  
  1347. function getId(node) {
  1348. return document.getElementById(node);
  1349. }
  1350.  
  1351. function ChromeWarning () {
  1352. var m = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
  1353. var CV = ( m ? parseInt(m[2], 10) : false);
  1354. if (CV) {
  1355. if (CV <62) {
  1356. return '\nWARNING: OUTDATED CHROME VERSION ' + CV + ' DETECTED.\nSettings saving may not work properly and update notice\nwill probably appear every time WME FixUI runs.\n';
  1357. } else {
  1358. return '';
  1359. }
  1360. } else {
  1361. return '';
  1362. }
  1363. }
  1364.  
  1365. function logit(msg, typ) {
  1366. if (!typ) {
  1367. console.log(prefix + ": " + msg);
  1368. } else {
  1369. switch(typ) {
  1370. case "error":
  1371. console.error(prefix + ": " + msg);
  1372. break;
  1373. case "warning":
  1374. console.warn(prefix + ": " + msg);
  1375. break;
  1376. case "info":
  1377. console.info(prefix + ": " + msg);
  1378. break;
  1379. case "debug":
  1380. if (debug) {
  1381. console.warn(prefix + ": " + msg);
  1382. }
  1383. break;
  1384. default:
  1385. console.log(prefix + " unknown message type: " + msg);
  1386. break;
  1387. }
  1388. }
  1389. }
  1390.  
  1391. // Start it running
  1392. setTimeout(init1, 200);
  1393. })();