WME Fix UI

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

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