WME Fix UI

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

  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.57
  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, Sebiseba,
  18. // The_Cre8r, ABelter
  19.  
  20. /* eslint-env jquery */
  21. /* global I18n,W,OpenLayers */
  22. // jshint esversion: 6
  23.  
  24. // Notes
  25. //new idea: hide Parking lot payment types when cost is FREE
  26. //new idea: red notification icon
  27. //
  28.  
  29. (function ()
  30. {
  31. // global variables
  32. var wmefu_version = "2.57";
  33. var oldVersion;
  34. var prefix = "WMEFU";
  35. var tabAttempts = 0;
  36. var wmeFUAddon;
  37. var debug = false;
  38. var wmeFUinitialising = true;
  39. var kineticDragParams;
  40. var yslider;
  41. var layersButton,refreshButton,shareButton;
  42. //Mutation Observer for daterangepicker in Restrictions
  43. var RestrictionObserver = new MutationObserver(function(mutations) {
  44. if (getById('_cbMondayFirst').checked || getById('_cbISODates').checked) {
  45. mutations.forEach(function(mutation) {
  46. if ($(mutation.target).hasClass('modal-content')) {
  47. if (mutation.addedNodes.length > 0) {
  48. if ($(".datepicker").length > 0) {
  49. var DRP = $(".datepicker")[0];
  50. if (getById('_cbMondayFirst').checked && getById('_cbISODates').checked) {
  51. $(DRP).data("daterangepicker").locale.firstDay = 1;
  52. $(DRP).data("daterangepicker").locale.daysOfWeek = ['Mo','Tu','We','Th','Fr','Sa','Su'];
  53. $(DRP).data("daterangepicker").locale.format = "YYYY-MM-DD";
  54. DRP.value = $(DRP).data("daterangepicker").startDate._i + " - " + $(DRP).data("daterangepicker").endDate._i;
  55. } else if (getById('_cbMondayFirst').checked) {
  56. $(DRP).data("daterangepicker").locale.firstDay = 1;
  57. $(DRP).data("daterangepicker").locale.daysOfWeek = ['Mo','Tu','We','Th','Fr','Sa','Su'];
  58. } else if (getById('_cbISODates').checked) {
  59. $(DRP).data("daterangepicker").locale.format = "YYYY-MM-DD";
  60. DRP.value = $(DRP).data("daterangepicker").startDate._i + " - " + $(DRP).data("daterangepicker").endDate._i;
  61. }
  62. }
  63. }
  64. }
  65. });
  66. }
  67. });
  68. //Mutation Observer for daterangepicker in Closures
  69. var ClosureObserver = new MutationObserver(function(mutations) {
  70. if (getById('_cbMondayFirst').checked) {
  71. mutations.forEach(function(mutation) {
  72. if (mutation.target.className == "closures") {
  73. if (mutation.addedNodes.length > 0) {
  74. if (mutation.addedNodes[0].firstChild.classList.contains("edit-closure")) {
  75. $(".end-date").data("daterangepicker").locale.firstDay = 1;
  76. $(".end-date").data("daterangepicker").locale.daysOfWeek = ['Mo','Tu','We','Th','Fr','Sa','Su'];
  77. $(".start-date").data("daterangepicker").locale.firstDay = 1;
  78. $(".start-date").data("daterangepicker").locale.daysOfWeek = ['Mo','Tu','We','Th','Fr','Sa','Su'];
  79. }
  80. }
  81. }
  82. });
  83. }
  84. });
  85. //Fix for date/time formats in WME released Oct/Nov 2016 - provided by Glodenox
  86. I18n.translations[I18n.currentLocale()].time = {};
  87. I18n.translations[I18n.currentLocale()].time.formats = {};
  88. I18n.translations[I18n.currentLocale()].time.formats.long = "%a %b %d %Y, %H:%M";
  89. I18n.translations[I18n.currentLocale()].date.formats = {};
  90. I18n.translations[I18n.currentLocale()].date.formats.long = "%a %b %d %Y, %H:%M";
  91. I18n.translations[I18n.currentLocale()].date.formats.default = "%a %b %d %Y";
  92. if (I18n.currentLocale() == 'en-GB') {
  93. I18n.translations['en-GB'].update_requests.panel.reported = 'Reported on: %{date}';
  94. }
  95.  
  96. function init1() {
  97. console.group(prefix + ": initialising...");
  98. console.time(prefix + ": initialisation time");
  99. logit("Starting init1","debug");
  100. // go round again if map container isn't there yet
  101. if(!window.W.map) {
  102. logit("waiting for WME...","warning");
  103. setTimeout(init1, 200);
  104. return;
  105. }
  106. // create tab content and store it
  107. wmeFUAddon = createAddon();
  108. // insert the content as a tab
  109. addMyTab(null,0);
  110. //pass control to init2
  111. init2();
  112. }
  113.  
  114. function init2() {
  115. logit("Starting init2","debug");
  116. //go round again if my tab isn't there yet
  117. if (!getById('sidepanel-FixUI')) {
  118. logit("Waiting for my tab to appear...","warning");
  119. setTimeout(init2, 200);
  120. return;
  121. }
  122. // setup event handlers for my controls:
  123. getById('_cbMoveZoomBar').onclick = createZoomBar;
  124. getById('_cbFixExternalProviders').onclick = fixExternalProviders;
  125. getById('_cbMoveChatIcon').onclick = moveChatIcon;
  126. getById('_cbHighlightInvisible').onclick = highlightInvisible;
  127. getById('_cbDarkenSaveLayer').onclick = darkenSaveLayer;
  128. getById('_cbSwapRoadsGPS').onclick = swapRoadsGPS;
  129. getById('_cbShowMapBlockers').onclick = showMapBlockers;
  130. getById('_cbHideLinks').onclick = hideLinks;
  131. getById('_cbShrinkTopBars').onclick = shrinkTopBars;
  132. getById('_cbCompressSegmentTab').onclick = compressSegmentTab;
  133. getById('_cbCompressLayersMenu').onclick = compressLayersMenu;
  134. getById('_cbLayersColumns').onclick = compressLayersMenu;
  135. getById('_cbRestyleReports').onclick = restyleReports;
  136. getById('_cbEnhanceChat').onclick = enhanceChat;
  137. getById('_cbNarrowSidePanel').onclick = narrowSidePanel;
  138. getById('_inpUICompression').onchange = applyEnhancements;
  139. getById('_inpUIContrast').onchange = applyEnhancements;
  140. getById('_inpASX').onchange = shiftAerials;
  141. getById('_inpASX').onwheel = shiftAerials;
  142. getById('_inpASY').onchange = shiftAerials;
  143. getById('_inpASY').onwheel = shiftAerials;
  144. getById('_inpASO').onchange = shiftAerials;
  145. getById('_inpASO').onwheel = shiftAerials;
  146. getById('_resetAS').onclick = function() {
  147. getById('_inpASX').value = 0;
  148. getById('_inpASY').value = 0;
  149. shiftAerials();
  150. };
  151. getById('_inpGSVContrast').onchange = adjustGSV;
  152. getById('_inpGSVBrightness').onchange = adjustGSV;
  153. getById('_cbGSVInvert').onchange = adjustGSV;
  154. getById('_inpGSVWidth').onchange = GSVWidth;
  155. getById('_cbDisableBridgeButton').onchange = disableBridgeButton;
  156. getById('_btnKillNode').onclick = killNode;
  157. getById('_cbDisableKinetic').onclick = disableKinetic;
  158. getById('_cbDisableScrollZoom').onclick = disableScrollZoom;
  159. getById('_cbDisableSaveBlocker').onclick = disableSaveBlocker;
  160. getById('_cbColourBlindTurns').onclick = colourBlindTurns;
  161. getById('_cbHideMenuLabels').onclick = hideMenuLabels;
  162. getById('_cbUnfloatButtons').onclick = unfloatButtons;
  163. getById('_cbMoveUserInfo').onclick = moveUserInfo;
  164. getById('_cbHackGSVHandle').onclick = hackGSVHandle;
  165. getById('street-view-drag-handle').ondblclick = GSVWidthReset;
  166. getById('_cbEnlargeGeoNodes').onclick = enlargeGeoNodes;
  167. getById('_inpEnlargeGeoNodes').onchange = enlargeGeoNodes;
  168. getById('_cbEnlargeGeoHandlesFU').onclick = enlargeGeoHandles;
  169. getById('_inpEnlargeGeoHandles').onchange = enlargeGeoHandles;
  170.  
  171. //REGISTER WAZE EVENT HOOKS
  172. // event to recreate my tab after changing WME units
  173. W.prefs.on('change:isImperial', function() {
  174. tabAttempts = 0;
  175. tabsLooper();
  176. createDSASection();
  177. if (getById('_cbUnfloatButtons').checked) unfloat();
  178. });
  179. // events for Aerial Shifter
  180. W.map.events.register("zoomend", null, shiftAerials);
  181. W.map.events.register("moveend", null, shiftAerials);
  182. W.map.getOLMap().baseLayer.events.register("loadend", null, shiftAerials);
  183. // events to change menu bar color based on map comments checkbox
  184. W.map.events.register("zoomend", null, warnCommentsOff);
  185. W.map.events.register("moveend", null, warnCommentsOff);
  186. // event to re-hack my zoom bar if it's there
  187. W.map.getOLMap().baseLayer.events.register("loadend", null, ZLI);
  188. //window resize event to resize chat
  189. window.addEventListener('resize', enhanceChat, true);
  190. //window resize event to resize layers menu
  191. window.addEventListener('resize', compressLayersMenu, true);
  192. //event to re-hack toolbar buttons on exiting HN mode
  193. W.editingMediator.on('change:editingHouseNumbers', function() {
  194. if (getById('_cbUnfloatButtons').checked) {
  195. if (W.editingMediator.attributes.editingHouseNumbers) unfloat();
  196. if (W.editingMediator.attributes.editingEnabled) unfloat();
  197. }
  198. });
  199. //create Aerial Shifter warning div
  200. var ASwarning = document.createElement('div');
  201. ASwarning.id = "WMEFU_AS";
  202. ASwarning.innerHTML = "Aerials Shifted";
  203. ASwarning.setAttribute('style','top:20px; left:0px; width:100%; position:absolute; z-index:10000; font-size:100px; font-weight:900; color:rgba(255, 255, 0, 0.4); text-align:center; pointer-events:none; display:none;');
  204. getById("WazeMap").appendChild(ASwarning);
  205.  
  206. loadSettings();
  207. // Add an extra checkbox so I can test segment panel changes easily
  208. if (W.loginManager.user.userName == 'iainhouse') {
  209. logit("creating segment detail debug checkbox","info");
  210. var extraCBSection = document.createElement('p');
  211. extraCBSection.innerHTML = '<input type="checkbox" id="_cbextraCBSection" />';
  212. getById('left-app-head').appendChild(extraCBSection);
  213. getById('_cbextraCBSection').onclick = FALSEcompressSegmentTab;
  214. getById('_cbextraCBSection').checked = getById('_cbCompressSegmentTab').checked;
  215. }
  216. //create Panel Swap div
  217. var WMEPS_div = document.createElement('div');
  218. var WMEPS_div_sub = document.createElement('div');
  219. WMEPS_div.id = "WMEFUPS";
  220. WMEPS_div.setAttribute('style','color: lightgrey; margin-left: 5px; font-size: 20px;');
  221. WMEPS_div.title = "Panel Swap: when map elements are selected, this lets you\nswap between the edit panel and the other tabs.";
  222. WMEPS_div_sub.innerHTML = '<i class="fa fa-sticky-note"></i>';
  223. WMEPS_div.appendChild(WMEPS_div_sub);
  224. insertNodeBeforeNode(WMEPS_div,getById('mode-switcher-region'));
  225. getById("WMEFUPS").onclick = PSclicked;
  226. W.selectionManager.events.register("selectionchanged", null, PSicon);
  227. //create Permalink Count div
  228. var WMEPC_div = document.createElement('div');
  229. var WMEPC_div_sub = document.createElement('div');
  230. WMEPC_div.id = "WMEFUPC";
  231. WMEPC_div.classList.add("toolbar-button","toolbar-button-with-icon");
  232. WMEPC_div.title = "Number of selectable map objects in the URL\nClick to reselect them.";
  233. WMEPC_div_sub.classList.add("item-container","WMEFU-toolbar-button");
  234. var totalItems;
  235. if (location.search.match("segments")) totalItems = window.location.search.match(new RegExp("[?&]segments?=([^&]*)"))[1].split(',').length;
  236. else if (location.search.match("venues")) totalItems = window.location.search.match(new RegExp("[?&]venues?=([^&]*)"))[1].split(',').length;
  237. else if (location.search.match("nodes")) totalItems = Math.min(1,window.location.search.match(new RegExp("[?&]nodes?=([^&]*)"))[1].split(',').length);
  238. else if (location.search.match("mapComments")) totalItems = Math.min(1,window.location.search.match(new RegExp("[?&]mapComments?=([^&]*)"))[1].split(',').length);
  239. else if (location.search.match("cameras")) totalItems = Math.min(1,window.location.search.match(new RegExp("[?&]cameras?=([^&]*)"))[1].split(',').length);
  240. else totalItems = 0;
  241. WMEPC_div_sub.innerHTML = '<span class="item-icon" style="display:inline-flex"><i style="margin-top:8px" class="fa fa-link WMEFUPCicon"></i>&nbsp;' + totalItems +'</span>';
  242. WMEPC_div.appendChild(WMEPC_div_sub);
  243. insertNodeBeforeNode(WMEPC_div,getById('search'));
  244. WMEPC_div.onclick = PCclicked;
  245. //Create Turn Popup Blocker div
  246. var WMETPB_div = document.createElement('div');
  247. var WMETPB_div_sub = document.createElement('div');
  248. WMETPB_div.id = "WMEFUTPB";
  249. WMETPB_div.classList.add("toolbar-button","toolbar-button-with-icon");
  250. WMETPB_div.title = "Disable/enable the turn arrow popup dialogue";
  251. WMETPB_div_sub.classList.add('item-container',"WMEFU-toolbar-button");
  252. WMETPB_div_sub.innerHTML = '<span class="item-icon fa-stack fa-2x" style="display:inline-flex; font-size:10px !important"><i class="fa fa-comment fa-stack-2x"></i><i class="fa fa-arrow-up fa-inverse fa-stack-1x"></i></span>';
  253. WMETPB_div.appendChild(WMETPB_div_sub);
  254. insertNodeBeforeNode(WMETPB_div,getById('search'));
  255. WMETPB_div.onclick = killTurnPopup;
  256. addGlobalStyle('.WMEFU-toolbar-button { padding: 0px !important; }');
  257. //Create layer pin div
  258. var WMEPin_div = document.createElement('div');
  259. var WMEPin_div_sub = document.createElement('div');
  260. WMEPin_div.id = "WMEFUPIN";
  261. WMEPin_div.style.opacity = '0.2';
  262. WMEPin_div.style.display = 'none';
  263. WMEPin_div.onclick = pinLayers;
  264. WMEPin_div_sub.classList.add('pinned','text-checkbox');
  265. WMEPC_div_sub.setAttribute('style','margin: 0px; font-size: 24px;');
  266. WMEPin_div_sub.innerHTML = '<input id="layer-switcher-pinned-input" type="checkbox" name="pinned" style="display:none"><label for="layer-switcher-pinned-input" title="Pin layer switcher"><i class="waze-icon-pin pin-label"></i></label>';
  267. WMEPin_div.appendChild(WMEPin_div_sub);
  268. insertNodeBeforeNode(WMEPin_div,getByClass('js-close-layer-switcher')[0]);
  269. addGlobalStyle('.pin-label { margin: 0; font-size: 18px; line-height: 18px } #WMEFUPIN label { margin-bottom: 0 }');
  270. // overload the window unload function to save my settings
  271. window.addEventListener("beforeunload", saveSettings, false);
  272. if (!W.selectionManager.getSelectedFeatures) {
  273. W.selectionManager.getSelectedFeatures = W.selectionManager.getSelectedItems;
  274. }
  275. // Alert to new version
  276. if (oldVersion != wmefu_version) {
  277. alert("WME Fix UI has been updated to version " + wmefu_version + "\n" +
  278. ChromeWarning() +
  279. "\n" +
  280. "Version 2.57 - 2021-07-25\n" +
  281. "* Updates for background changes in WME map model\n" +
  282. "\n" +
  283. "Previous highlights (in the last 6 months):\n" +
  284. "* 2.56 New feature: Adjust size of geo/junction nodes\n" +
  285. "* 2.56 New feature: Adjust size of geo handles\n" +
  286. "* 2.52 New feature: Auto-expanded element history items\n" +
  287. "");
  288. saveSettings();
  289. }
  290. // fix for sidebar display problem in Safari, requested by edsonajj
  291. var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  292. if (isSafari) {
  293. addGlobalStyle('.flex-parent { height: 99% !important; }');
  294. }
  295. // stop wobbling status bar
  296. addGlobalStyle('.WazeControlMousePosition { font-family: monospace }');
  297. // move closed node icon below node markers
  298. // apply the settings
  299. shiftAerials();
  300. // attempt to make liveuser names show
  301. setTimeout(applyAllSettings, 1000);
  302. W.model.liveUsers.users.on("add", function() {
  303. try {
  304. liveUserAdded.apply(this, arguments);
  305. } catch (e) {
  306. logit(e,"error");
  307. }
  308. });
  309. addGlobalStyle('.live-user-marker { pointer-events: none; }');
  310. // auto-expand all history
  311. addGlobalStyle('.element-history-item.closed .tx-content { display: block; }');
  312. logit("Initialisation complete");
  313. console.timeEnd(prefix + ": initialisation time");
  314. console.groupEnd();
  315. }
  316.  
  317. function createAddon() {
  318. //create the contents of my side-panel tab
  319. var addon = document.createElement('section');
  320. var section = document.createElement('p');
  321. addon.id = "sidepanel-FixUI";
  322. section.style.paddingTop = "4px";
  323. section.style.lineHeight = "11px";
  324. section.style.fontSize = "11px";
  325. section.id = "fuContent";
  326. section.innerHTML = "";
  327. section.innerHTML += '<b title="Shift aerial images layer to match GPS tracks and reduce image opacity">Aerial Shifter</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  328. section.innerHTML += '<span class="fa fa-power-off" id="_resetAS" title="Clear X/Y offsets"></span><br>';
  329. 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:40px;text-align:right;"/><b>m</b><span class="fa fa-arrow-right"></span></div>';
  330. 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:40px;text-align:right;"/><b>m</b><span class="fa fa-arrow-up"></span></div>';
  331. section.innerHTML += '<div id="as3" style="display:inline-block"><input type="number" id="_inpASO" title="opacity" max=100 min=10 step=10 style="height:20px; width:40px;text-align:right;"/><b>%</b><span class="fa fa-adjust"></span></div>';
  332. section.innerHTML += '<br>';
  333. section.innerHTML += '<br>';
  334.  
  335. section.innerHTML += '<b title="Adjust contrast, brightness, colours & width for Google Street View images">GSV image adjust</b><br>';
  336. section.innerHTML += '<span title="Contrast"><input type="number" id="_inpGSVContrast" max=200 min=25 step=25 style="height:20px; width:42px;text-align:right;"/><b>%</b><span class="fa fa-adjust"></span></span>&nbsp;&nbsp;';
  337. section.innerHTML += '<span title="Brightness"><input type="number" id="_inpGSVBrightness" max=200 min=25 step=25 style="height:20px; width:42px;text-align:right;"/><b>%</b><span class="fa fa-sun-o"></span></span>&nbsp;&nbsp;';
  338. section.innerHTML += '<span title="Invert colours"><input type="checkbox" id="_cbGSVInvert"/><span class="fa fa-tint"></span></span>&nbsp;&nbsp;';
  339. section.innerHTML += '<span title="Default width"><input type="number" id="_inpGSVWidth" max=90 min=10 step=10 style="height:20px; width:36px;text-align:right;"/><b>%</b><span class="fa fa-arrows-h"></span></span>&nbsp;&nbsp;&nbsp;';
  340. section.innerHTML += '<br>';
  341. section.innerHTML += '<br>';
  342. section.innerHTML += '<b>UI Enhancements</b><br>';
  343. section.innerHTML += '<input type="checkbox" id="_cbShrinkTopBars" /> ' +
  344. '<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>';
  345. section.innerHTML += '<input type="checkbox" id="_cbCompressSegmentTab" /> ' +
  346. '<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>';
  347. section.innerHTML += '<input type="checkbox" id="_cbCompressLayersMenu" /> ' +
  348. '<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>';
  349. section.innerHTML += '<span id="layersColControls"><input type="checkbox" id="_cbLayersColumns" /> ' +
  350. '<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>';
  351. section.innerHTML += '<input type="checkbox" id="_cbRestyleReports" /> ' +
  352. '<span title="Another UI element configured for developers with massive screens instead of normal users">Compress/enhance report panels (UR/MP)</span><br>';
  353. section.innerHTML += '<input type="checkbox" id="_cbEnhanceChat" /> ' +
  354. '<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>';
  355. section.innerHTML += '<input type="checkbox" id="_cbNarrowSidePanel" /> ' +
  356. '<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>';
  357. section.innerHTML += '<br>';
  358. section.innerHTML += '<b title="Control the amount of compression/enhancment">UI Enhancement controls<br>';
  359. section.innerHTML += '<div style="display:inline-block"><select id="_inpUICompression" title="Compression enhancement" style="height:20px; padding:0px; border-radius=0px;"><option value="2">High</option><option value="1">Low</option><option value="0">None</option></select><span class="fa fa-compress"></span></div>&nbsp;&nbsp;&nbsp;&nbsp;';
  360. section.innerHTML += '<div style="display:inline-block"><select id="_inpUIContrast" title="Contrast enhancement" style="height:20px; padding:0px; border-radius=0px;"><option value="2">High</option><option value="1">Low</option><option value="0">None</option></select><span class="fa fa-adjust"></span></div>';
  361. section.innerHTML += '<br>';
  362. section.innerHTML += '<button id="_btnKillNode" style = "height: 18px; margin-top: 5px;" title="Hide the junction nodes layer to allow access to Map Comments hidden under nodes.\nThis stays in effect until the page is zoomed/panned/refreshed.">Hide junction nodes</button>&nbsp;&nbsp;';
  363. section.innerHTML += '<br><br>';
  364. section.innerHTML += '<b>UI Fixes/changes</b><br>';
  365. section.innerHTML += '<input type="checkbox" id="_cbMoveZoomBar" /> ' +
  366. '<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.\nNO MATTER HOW HARD THEY TRY, I WILL BRING IT BACK!">Re-create zoom bar & move map controls</span><br>';
  367. section.innerHTML += '<input type="checkbox" id="_cbFixExternalProviders" /> ' +
  368. '<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>';
  369. section.innerHTML += '<input type="checkbox" id="_cbMoveChatIcon" /> ' +
  370. '<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>';
  371. section.innerHTML += '<input type="checkbox" id="_cbHighlightInvisible" /> ' +
  372. '<span title="Typical WME design - the chat icon changes when you\'re invisible,\nbut the change is practically invisible!\nThis option provides a more obvious highlight.">Highlight invisible mode</span></span><br>';
  373. section.innerHTML += '<input type="checkbox" id="_cbLayersMenuMoreOptions" /> ' +
  374. '<span title="This function shows all options in the Layers menu at all times.\nNote that changing this only updates when the page loads.">Show all options in Layers menu</span><br>';
  375. section.innerHTML += '<input type="checkbox" id="_cbDarkenSaveLayer" /> ' +
  376. '<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>';
  377. section.innerHTML += '<input type="checkbox" id="_cbSwapRoadsGPS" /> ' +
  378. '<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>';
  379. section.innerHTML += '<input type="checkbox" id="_cbShowMapBlockers" /> ' +
  380. '<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></span><br>';
  381. section.innerHTML += '<input type="checkbox" id="_cbHideLinks" /> ' +
  382. '<span title="Hide the small Links bar at the bottom of the side panel,\nto give more usable space there.">Hide Links panel</span><br>';
  383. section.innerHTML += '<input type="checkbox" id="_cbDisableBridgeButton" /> ' +
  384. '<span title="The Bridge button is rarely useful, but often used incorrectly.\nIt\'s best to keep it disabled unless you need it.">Disable Bridge button</span><br>';
  385. section.innerHTML += '<input type="checkbox" id="_cbMondayFirst" /> ' +
  386. '<span title="Requests to have calendar items localised with Monday as the first day of the week\ngo back a while. Now you don\'t have to wait for Waze.">Start calendars on Monday</span><br>';
  387. section.innerHTML += '<input type="checkbox" id="_cbISODates" /> ' +
  388. '<span title="Dates in the Restrictions dialogues are all in American format - MM/DD/YY\nFine if you\' American, confusing as hell for the rest of us!\nThis changes the dates to ISO format, matching the Closures dialogue">ISO dates in Restrictions</span><br>';
  389. section.innerHTML += '<input type="checkbox" id="_cbDisableKinetic" /> ' +
  390. '<span title="Kinetic panning is a new WME feature: if you release the mouse whilst dragging the map,\nthe map will keep moving. It can be very useful for panning large distances.\nIt can also be very annoying. Now YOU have control.">Disable Kinetic Panning</span><br>';
  391. section.innerHTML += '<input type="checkbox" id="_cbDisableScrollZoom" /> ' +
  392. '<span title="Zooming with the scroll wheel can be problematic when using an Apple Magic Mouse, which\nscrolls on touch. This will disable scroll-to-zoom.">Disable scroll-to-zoom</span><br>';
  393. section.innerHTML += '<input type="checkbox" id="_cbDisableSaveBlocker" /> ' +
  394. '<span title="When you hit Save, WME places a blocking element over the map until the save is complete\nThis disables that element, allowing you to pan the map and use GSV whilst a slow save is in progress.">Disable map blocking during save</span><br>';
  395. section.innerHTML += '<input type="checkbox" id="_cbColourBlindTurns" /> ' +
  396. '<span title="Change green turn arrows blue in order to make them more visible\nfor users with the most common type of colour blindness.">Change green turn arrows to blue</span><br>';
  397. section.innerHTML += '<input type="checkbox" id="_cbHideMenuLabels" /> ' +
  398. '<span title="Hide the text labels on the toolbar menus to save space on small screens">Hide menu labels</span><br>';
  399. section.innerHTML += '<input type="checkbox" id="_cbUnfloatButtons" /> ' +
  400. '<span title="Move Layers/Refresh buttons back into the toolbar and Share button into the\nfooter.\nWaze put little enough effort into giving us enough map area to work with,\nand then they drop little button turds all over it!">Remove floating buttons from map area</span><br>';
  401. section.innerHTML += '<input type="checkbox" id="_cbMoveUserInfo" /> ' +
  402. '<span title="The new user info button is very useful, but it\'s not a map editing control,\nso it shouldn\'t be in the toolbar. The same goes for the notification button.\nThis function moves them both to a sensible location.">Move user info/notification buttons</span><br>';
  403. section.innerHTML += '<input type="checkbox" id="_cbHackGSVHandle" /> ' +
  404. '<span title="Whilst being able to adjust the GSV width is useful, the drag handle\ninvisibly covers 30 pixels of map and is very easy to drag accidentally.\nThis function transforms it to a button drag control that\'s much less\nlikely to be used by accident.">Minimise GSV drag handle</span><br>';
  405. section.innerHTML += '<input type="checkbox" id="_cbEnlargeGeoNodes" /> ' +
  406. '<span title="If you\'re getting old, like me, grabbing those little circles is a pain!\nThis control lets you enlarge the geo nodes (and junction nodes for segments),\nwhich define the shapes of segments and place boundaries.">Enlarge geo/junction nodes</span><div style="display:inline-block">&nbsp;&nbsp;<input type="number" id="_inpEnlargeGeoNodes" title="radius (default=6)" max=12 min=8 step=2 style="height:16px; padding:0 0 0 2px;; border:1px solid; width:37px;"/></div><span style = "color: red; font-weight: bold;">&nbsp;&nbsp;--- NEW</span><br>';
  407. section.innerHTML += '<input type="checkbox" id="_cbEnlargeGeoHandlesFU" /> ' +
  408. '<span title="If you\'re getting old, like me, grabbing those little circles is a pain!\nThis control lets you enlarge the geo handles, used to add geo nodes to segments and place boundaries.">Enlarge geo handles</span><div style="display:inline-block">&nbsp;&nbsp;<input type="number" id="_inpEnlargeGeoHandles" title="radius (default=4)" max=10 min=6 step=2 style="height:16px; padding:0 0 0 2px;; border:1px solid; width:37px;"/></div><span style = "color: red; font-weight: bold;">&nbsp;&nbsp;--- NEW</span><br>';
  409. section.innerHTML += '<br>';
  410. section.innerHTML += '<b><a href="https://www.waze.com/forum/viewtopic.php?f=819&t=191178" title="Forum topic" target="_blank"><u>' +
  411. 'WME Fix UI</u></a></b> &nbsp; v' + wmefu_version;
  412. // Text for end of line for new features
  413. // <span style = "color: red; font-weight: bold;">--- NEW</span>
  414. // Same text for forum topic
  415. // [b][color=#BF0000]--- NEW[/color][/b]
  416. addon.appendChild(section);
  417. addon.className = "tab-pane";
  418. return addon;
  419. }
  420.  
  421. function addMyTab(model,modeID) {
  422. // if (getById('_cbUnfloatButtons').checked) float();
  423. if (modeID === 0) {
  424. logit("entering default mode, so creating tab");
  425. tabAttempts = 0;
  426. tabsLooper();
  427. createDSASection();
  428. } else {
  429. logit("entering event mode, so not initialising");
  430. return;
  431. }
  432. }
  433.  
  434. function tabsLooper() {
  435. tabAttempts += 1;
  436. if (tabAttempts > 20) {
  437. // tried 20 times to create tab without luck
  438. logit("unable to create my tab after 20 attempts","error");
  439. return;
  440. }
  441. var userTabs = getById('user-info');
  442. var navTabs = getByClass('nav-tabs', userTabs)[0];
  443. if (typeof navTabs === "undefined") {
  444. //the basic tabs aren't there yet, so I can't add mine
  445. logit("waiting for NavTabs","warning");
  446. setTimeout(tabsLooper, 200);
  447. } else{
  448. var tabContent = getByClass('tab-content', userTabs)[0];
  449. var newtab = document.createElement('li');
  450. newtab.innerHTML = '<a href="#sidepanel-FixUI" data-toggle="tab" title="Fix UI">FU</a>';
  451. navTabs.appendChild(newtab);
  452. tabContent.appendChild(wmeFUAddon);
  453. }
  454. }
  455.  
  456. function loadSettings() {
  457. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  458. logit("function " + fname + " called", "debug");
  459. // Remove old V1 settings if they're still hanging around
  460. if (localStorage.WMEFixUI) {
  461. localStorage.removeItem("WMEFixUI");
  462. }
  463. var options;
  464. if (localStorage.WMEFUSettings) {
  465. options = JSON.parse(localStorage.WMEFUSettings);
  466. } else {
  467. options = {};
  468. }
  469. oldVersion = (options.oldVersion !== undefined ? options.oldVersion : "0.0");
  470. getById('_cbMoveZoomBar').checked = (options.moveZoomBar !== undefined ? options.moveZoomBar : true);
  471. getById('_cbShrinkTopBars').checked = (options.shrinkTopBars !== undefined ? options.shrinkTopBars : true);
  472. getById('_cbCompressSegmentTab').checked = ( options.restyleSidePanel !== undefined ? options.restyleSidePanel : true);
  473. getById('_cbRestyleReports').checked = ( options.restyleReports !== undefined ? options.restyleReports : true);
  474. getById('_cbEnhanceChat').checked = ( options.enhanceChat !== undefined ? options.enhanceChat : true);
  475. getById('_cbNarrowSidePanel').checked = ( options.narrowSidePanel !== undefined ? options.narrowSidePanel : false);
  476. getById('_inpASX').value = ( options.aerialShiftX !== undefined ? options.aerialShiftX : 0);
  477. getById('_inpASY').value = ( options.aerialShiftY !== undefined ? options.aerialShiftY : 0);
  478. getById('_inpASO').value = ( options.aerialOpacity !== undefined ? options.aerialOpacity : 100);
  479. getById('_cbFixExternalProviders').checked = ( options.fixExternalProviders !== undefined ? options.fixExternalProviders : true);
  480. getById('_inpGSVContrast').value = ( options.GSVContrast !== undefined ? options.GSVContrast : 100);
  481. getById('_inpGSVBrightness').value = ( options.GSVBrightness !== undefined ? options.GSVBrightness : 100);
  482. getById('_cbGSVInvert').checked = ( options.GSVInvert !== undefined ? options.GSVInvert : false);
  483. getById('_inpGSVWidth').value = ( options.GSVWidth !== undefined ? options.GSVWidth : 50);
  484. getById('_cbCompressLayersMenu').checked = ( options.restyleLayersMenu !== undefined ? options.restyleLayersMenu : true);
  485. getById('_cbLayersColumns').checked = ( options.layers2Cols !== undefined ? options.layers2Cols : false);
  486. getById('_cbMoveChatIcon').checked = ( options.moveChatIcon !== undefined ? options.moveChatIcon : true);
  487. getById('_cbHighlightInvisible').checked = ( options.highlightInvisible !== undefined ? options.highlightInvisible : true);
  488. getById('_cbDarkenSaveLayer').checked = ( options.darkenSaveLayer !== undefined ? options.darkenSaveLayer : true);
  489. getById('_cbLayersMenuMoreOptions').checked = ( options.layersMenuMore !== undefined ? options.layersMenuMore : true);
  490. getById('_inpUIContrast').value = ( options.UIContrast !== undefined ? options.UIContrast : 1);
  491. getById('_inpUICompression').value = ( options.UICompression !== undefined ? options.UICompression : 1);
  492. getById('_cbSwapRoadsGPS').checked = ( options.swapRoadsGPS !== undefined ? options.swapRoadsGPS : true);
  493. getById('_cbShowMapBlockers').checked = ( options.showMapBlockers !== undefined ? options.showMapBlockers : true);
  494. getById('_cbHideLinks').checked = ( options.hideLinks !== undefined ? options.hideLinks : false);
  495. getById('_cbDisableBridgeButton').checked = ( options.disableBridgeButton !== undefined ? options.disableBridgeButton : true);
  496. getById('_cbISODates').checked = ( options.ISODates !== undefined ? options.ISODates : true);
  497. getById('_cbMondayFirst').checked = ( options.mondayFirst !== undefined ? options.mondayFirst : false);
  498. getById('_cbDisableKinetic').checked = ( options.disableKinetic !== undefined ? options.disableKinetic : false);
  499. getById('_cbDisableScrollZoom').checked = ( options.disableScrollZoom !== undefined ? options.disableScrollZoom : false);
  500. getById('_cbDisableSaveBlocker').checked = ( options.disableSaveBlocker !== undefined ? options.disableSaveBlocker : false);
  501. getById('_cbColourBlindTurns').checked = ( options.colourBlindTurns !== undefined ? options.colourBlindTurns : false);
  502. getById('_cbHideMenuLabels').checked = ( options.hideMenuLabels !== undefined ? options.hideMenuLabels : false);
  503. getById('_cbUnfloatButtons').checked = ( options.unfloatButtons !== undefined ? options.unfloatButtons : false);
  504. getById('_cbMoveUserInfo').checked = ( options.moveUserInfo !== undefined ? options.moveUserInfo : false);
  505. getById('_cbHackGSVHandle').checked = ( options.hackGSVHandle !== undefined ? options.hackGSVHandle : false);
  506. getById('_cbEnlargeGeoNodes').checked = ( options.enlargeGeoNodes !== undefined ? options.enlargeGeoNodes : false);
  507. getById('_inpEnlargeGeoNodes').value = ( options.geoNodeSize !== undefined ? options.geoNodeSize : 8);
  508. getById('_cbEnlargeGeoHandlesFU').checked = ( options.enlargeGeoHandles !== undefined ? options.enlargeGeoHandles : false);
  509. getById('_inpEnlargeGeoHandles').value = ( options.geoHandleSize !== undefined ? options.geoHandleSize : 6);
  510. }
  511.  
  512. function saveSettings() {
  513. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  514. logit("function " + fname + " called", "debug");
  515. if (localStorage) {
  516. logit("saving options to local storage");
  517. var options = {};
  518. options.oldVersion = wmefu_version;
  519. options.moveZoomBar = getById('_cbMoveZoomBar').checked;
  520. options.shrinkTopBars = getById('_cbShrinkTopBars').checked;
  521. options.restyleSidePanel = getById('_cbCompressSegmentTab').checked;
  522. options.restyleReports = getById('_cbRestyleReports').checked;
  523. options.enhanceChat = getById('_cbEnhanceChat').checked;
  524. options.narrowSidePanel = getById('_cbNarrowSidePanel').checked;
  525. options.aerialShiftX = getById('_inpASX').value;
  526. options.aerialShiftY = getById('_inpASY').value;
  527. options.aerialOpacity = getById('_inpASO').value;
  528. options.fixExternalProviders = getById('_cbFixExternalProviders').checked;
  529. options.GSVContrast = getById('_inpGSVContrast').value;
  530. options.GSVBrightness = getById('_inpGSVBrightness').value;
  531. options.GSVInvert = getById('_cbGSVInvert').checked;
  532. options.GSVWidth = getById('_inpGSVWidth').value;
  533. options.restyleLayersMenu = getById('_cbCompressLayersMenu').checked;
  534. options.layers2Cols = getById('_cbLayersColumns').checked;
  535. options.moveChatIcon = getById('_cbMoveChatIcon').checked;
  536. options.highlightInvisible = getById('_cbHighlightInvisible').checked;
  537. options.darkenSaveLayer = getById('_cbDarkenSaveLayer').checked;
  538. options.layersMenuMore = getById('_cbLayersMenuMoreOptions').checked;
  539. options.UIContrast = getById('_inpUIContrast').value;
  540. options.UICompression = getById('_inpUICompression').value;
  541. options.swapRoadsGPS = getById('_cbSwapRoadsGPS').checked;
  542. options.showMapBlockers = getById('_cbShowMapBlockers').checked;
  543. options.hideLinks = getById('_cbHideLinks').checked;
  544. options.disableBridgeButton = getById('_cbDisableBridgeButton').checked;
  545. options.ISODates = getById('_cbISODates').checked;
  546. options.mondayFirst = getById('_cbMondayFirst').checked;
  547. options.disableKinetic = getById('_cbDisableKinetic').checked;
  548. options.disableScrollZoom = getById('_cbDisableScrollZoom').checked;options.disableSaveBlocker = getById('_cbDisableSaveBlocker').checked;
  549. options.colourBlindTurns = getById('_cbColourBlindTurns').checked;
  550. options.hideMenuLabels = getById('_cbHideMenuLabels').checked;
  551. options.unfloatButtons = getById('_cbUnfloatButtons').checked;
  552. options.moveUserInfo = getById('_cbMoveUserInfo').checked;
  553. options.hackGSVHandle = getById('_cbHackGSVHandle').checked;
  554. options.enlargeGeoNodes = getById('_cbEnlargeGeoNodes').checked;
  555. options.geoNodeSize = getById('_inpEnlargeGeoNodes').value;
  556. options.enlargeGeoHandles = getById('_cbEnlargeGeoHandlesFU').checked;
  557. // alert(options.enlargeGeoHandles);
  558. options.geoHandleSize = getById('_inpEnlargeGeoHandles').value;
  559. localStorage.WMEFUSettings = JSON.stringify(options);
  560. }
  561. }
  562.  
  563. function applyAllSettings() {
  564. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  565. logit("function " + fname + " called", "debug");
  566. console.group(prefix + ": applying all settings");
  567. kineticDragParams = W.map.controls.find(control => control.dragPan).dragPan.kinetic;
  568. shrinkTopBars();
  569. compressSegmentTab();
  570. restyleReports();
  571. enhanceChat();
  572. narrowSidePanel();
  573. fixExternalProviders();
  574. warnCommentsOff();
  575. adjustGSV();
  576. GSVWidth();
  577. compressLayersMenu();
  578. moveChatIcon();
  579. highlightInvisible();
  580. darkenSaveLayer();
  581. swapRoadsGPS();
  582. showMapBlockers();
  583. hideLinks();
  584. disableBridgeButton();
  585. disableKinetic();
  586. disableScrollZoom();
  587. disableSaveBlocker();
  588. colourBlindTurns();
  589. hideMenuLabels();
  590. createZoomBar();
  591. unfloatButtons();
  592. moveUserInfo();
  593. hackGSVHandle();
  594. enlargeGeoNodes();
  595. enlargeGeoHandles();
  596. console.groupEnd();
  597. RestrictionObserver.observe(getById('dialog-container'), { childList: true, subtree: true });
  598. ClosureObserver.observe(getById('edit-panel'), { childList: true, subtree: true });
  599. if (getById('_cbLayersMenuMoreOptions').checked === true) {
  600. $("#layer-switcher-region > div > div > div.more-options-toggle > label > div").click();
  601. Array.from(getByClass('upside-down',getById('layer-switcher-region'))).forEach(function(item){item.click();});
  602. }
  603. wmeFUinitialising = false;
  604. saveSettings();
  605. }
  606.  
  607. function applyEnhancements() {
  608. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  609. logit("function " + fname + " called", "debug");
  610. shrinkTopBars();
  611. compressSegmentTab();
  612. restyleReports();
  613. enhanceChat();
  614. compressLayersMenu();
  615. hideLinks();
  616. moveUserInfo();
  617. }
  618.  
  619. function createZoomBar() {
  620. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  621. logit("function " + fname + " called", "debug");
  622. if (getById('_cbMoveZoomBar').checked) {
  623. yslider = new OpenLayers.Control.PanZoomBar({zoomStopHeight:9 , panIcons:false});
  624. yslider.position.x = 10;
  625. yslider.position.y = 35;
  626. yslider.id = 'WMEFUzoom';
  627. W.map.addControl(yslider);
  628. getById('WMEFUzoom').appendChild(getByClass('bottom overlay-buttons-container')[0]);
  629. var styles = "";
  630. //Overall bar
  631. styles += '.olControlPanZoomBar { left: 10px; top: 35px; height: 158px; border: 1px solid #f0f2f2; background-color: #f0f2f2; border-radius: 30px; width: 24px; box-sizing: initial; }';
  632. styles += '#WMEFUzoom { z-index: 1200 !important; }';
  633. //zoom in/out buttons
  634. styles += '.olButton { background-color: white; border-radius: 30px; width: 24px; height: 24px; cursor: pointer; }';
  635. styles += '.olControlZoomButton { padding: 3px 5px; font-size: 18px; }';
  636. //slider stops
  637. styles += '.yslider-stops { width: 24px; height: 110px; background-color: #f3f3f3; background-image: linear-gradient(90deg, transparent 45%, #dedede 45%, #dedede 55%, transparent 55%), linear-gradient(#dedede 1px, transparent 1px); background-size: 50% 8px; background-repeat: repeat-y; background-position: 6px; }';
  638. //slider
  639. styles += '.slider { position: absolute; font-size: 15px; font-weight: 900; line-height: 1; text-align: center; width: 24px; height: 18px; margin-top: -29px; padding-top: 1px; border: 1px solid lightgrey; border-radius: 10px; background-color: white; cursor: ns-resize; }';
  640. // kill new zoom buttons
  641. styles += '.zoom-bar-region { display: none; }';
  642. // shift UR/MP panel to the right
  643. styles += '.panel.show { margin-left: 55px; }';
  644. // if gsv control is moved
  645. styles += '.bottom.overlay-buttons-container { position: absolute; top: 170px; }';
  646. styles += '.street-view-region { margin-bottom: 8px; }';
  647. addStyle(prefix + fname,styles);
  648. W.map.events.register("zoomend", null, ZLI);
  649. getById('WMEFUzoom').appendChild(getByClass('bottom overlay-buttons-container')[0]);
  650. ZLI();
  651. getById('WMEFUzoom').appendChild(getByClass('bottom overlay-buttons-container')[0]);
  652. } else {
  653. if (yslider) {
  654. getById('overlay-buttons').appendChild(getByClass('bottom overlay-buttons-container')[0]);
  655. yslider.destroy();
  656. }
  657. W.map.events.unregister("zoomend", null, ZLI);
  658. removeStyle(prefix + fname);
  659. removeStyle('WMEMTU');
  660. }
  661. }
  662.  
  663. function ZLI() {
  664. if (yslider) {
  665. //Need to reset the OpenLayers-created settings from the zoom bar when it's redrawn
  666. //Overall bar
  667. yslider.div.style.left = "";
  668. yslider.div.style.top = "";
  669. //zoom in/out buttons
  670. yslider.buttons[0].style = "";
  671. yslider.buttons[0].innerHTML = "<div class='olControlZoomButton fa fa-plus' ></div>";
  672. yslider.buttons[1].style = "";
  673. yslider.buttons[1].innerHTML = "<div class='olControlZoomButton fa fa-minus' ></div>";
  674. //slider stops
  675. yslider.zoombarDiv.classList.add("yslider-stops");
  676. yslider.zoombarDiv.classList.remove("olButton");
  677. yslider.zoombarDiv.style="";
  678. //slider
  679. yslider.slider.innerHTML = "";
  680. yslider.slider.style = "";
  681. yslider.slider.classList.add("slider");
  682. yslider.moveZoomBar();
  683. //Actually set the ZLI
  684. yslider.slider.innerText = W.map.getZoom();
  685. yslider.slider.title = "Zoom level indicator by WMEFU";
  686. switch (W.map.getZoom()) {
  687. case 0:
  688. case 1:
  689. yslider.slider.style.background = '#ef9a9a';
  690. yslider.slider.title += "\nCannot permalink any segments at this zoom level";
  691. break;
  692. case 2:
  693. case 3:
  694. yslider.slider.style.background = '#ffe082';
  695. yslider.slider.title += "\nCan only permalink primary or higher at this zoom level";
  696. break;
  697. default:
  698. yslider.slider.style.background = '#ffffff';
  699. yslider.slider.title += "\nCan permalink any segments at this zoom level";
  700. break;
  701. }
  702. }
  703. }
  704.  
  705. function moveUserInfo() {
  706. // Now functioning correctly for prod & beta
  707. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  708. logit("function " + fname + " called", "debug");
  709. var styles = "";
  710. if (getById('_cbMoveUserInfo').checked) {
  711. // styles += '#user-box-region { margin-left: 5px; }';
  712. styles += '.notifications-button { display: flex; }';
  713. styles += '#app-head aside #left-app-head .waze-logo { width: 50px; }';
  714. styles += '#user-toolbar .notifications-button { padding: 0 4px; }';
  715. styles += '#user-toolbar .notifications-button .counter { left: ' + ['84px','76px','68px'][getById('_inpUICompression').value] + '; }';
  716. addStyle(prefix + fname,styles);
  717. // insertNodeAfterNode(getById('notifications-button-region'),getByClass('waze-logo')[0]);
  718. // insertNodeAfterNode(getById('user-box-region'),getByClass('waze-logo')[0]);
  719. insertNodeAfterNode(getById('user-toolbar'),getByClass('waze-logo')[0]);
  720. //Fix to move control button of Invalidated Camera Mass Eraser
  721. if (getById("_UCME_btn")) {
  722. getById("advanced-tools").appendChild(getById("_UCME_btn"));
  723. document.getElementById('UCME_btn').parentNode.removeChild(document.getElementById('UCME_btn'));
  724. }
  725. } else {
  726. removeStyle(prefix + fname);
  727. // insertNodeAfterNode(getById('user-box-region'),getById('edit-buttons'));
  728. // insertNodeAfterNode(getById('notifications-button-region'),getById('user-box-region'));
  729. insertNodeAfterNode(getById('user-toolbar'),getById('edit-buttons'));
  730. }
  731. }
  732.  
  733. function shrinkTopBars() {
  734. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  735. logit("function " + fname + " called", "debug");
  736. var styles = "";
  737. var levelIcon;
  738. if (getById('_cbShrinkTopBars').checked) {
  739. //always do this stuff
  740. //event mode button
  741. styles += '#mode-switcher-region .title-button .icon { font-size: 13px; font-weight: bold; color: black; }';
  742. //black bar
  743. styles += '#topbar-container { pointer-events: none; }';
  744. styles += '#map #topbar-container .topbar > div { pointer-events: initial; }';
  745. //change toolbar buttons - from JustinS83
  746. $('#mode-switcher-region .title-button .icon').removeClass('w-icon-caret-down');
  747. $('#mode-switcher-region .title-button .icon').addClass('fa fa-calendar');
  748. // HN editing tweaks
  749. styles += '#map-lightbox .content { pointer-events: none; }';
  750. styles += '#map-lightbox .content > div { pointer-events: initial; }';
  751. styles += '#map-lightbox .content .header { pointer-events: none !important; }';
  752. styles += '.toolbar .toolbar-button.add-house-number { background-color: #61cbff; float: right; font-weight: bold; }';
  753. styles += '.waze-icon-exit { background-color: #61cbff; font-weight: bold; }';
  754. // event mode button
  755. styles += '.toolbar.toolbar-mte .add-button { background-color: orange; font-weight: bold; }';
  756. var contrast = getById('_inpUIContrast').value;
  757. var compress = getById('_inpUICompression').value;
  758. // fix for narrow windows and new toolbar
  759. var nbuttons = 3 + (getById('_cbUnfloatButtons').checked ? 2 : 0);
  760. var minW = nbuttons * ([58,49,33][compress]) + [80,65,55][compress];
  761. styles += '#edit-buttons { min-width: ' + minW + 'px; }';
  762. if (compress > 0) {
  763. //overall menu bar
  764. styles += '#app-head aside #left-app-head { height: ' + ['','35px','24px'][compress] + '; padding-left: ' + ['','9px','2px'][compress] + '; }';
  765. styles += '#app-head { height: ' + ['','35px','24px'][compress] + '; }';
  766. styles += '#app-head aside .short-title { font-size: ' + ['','13px','12px'][compress] + '; margin-right: 4px; }';
  767. styles += '#app-head aside #debug { padding-right: ' + ['','10px','6px'][compress] + '; line-height: ' + ['','15px','12px'][compress] + '; white-space: nowrap; }';
  768. styles += '.mode-switcher-view .title-button .icon { line-height: ' + ['','35px','24px'][compress] + '; }';
  769. styles += '.mode-switcher-view .dropdown-menu { top: ' + ['','35px','24px'][compress] + '; }';
  770. styles += '.toolbar { font-size: ' + ['','13px','12px'][compress] + '; }';
  771. styles += '.toolbar { height: ' + ['','35px','24px'][compress] + '; }';
  772. //search box
  773. styles += '#search { padding-top: ' + ['','3px','1px'][compress] + '; }';
  774. styles += '.form-search { height: ' + ['','27px','22px'][compress] + '; }';
  775. styles += '.form-search .search-query { height: ' + ['','27px','22px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  776. styles += '.form-search .input-wrapper .search-icon { top: ' + ['','4px','3px'][compress] + '; font-size: ' + ['','18px','16px'][compress] + '; left: ' + ['','9px','6px'][compress] + '; }';
  777. styles += '.form-search .search-query { padding-left: ' + ['','34px','24px'][compress] + ';; }';
  778. //edit-buttons section
  779. styles += '#edit-buttons { margin-right: ' + ['','9px','2px'][compress] + '; }';
  780. //toolbar dropdowns
  781. styles += '.toolbar .toolbar-group { margin-right: ' + ['','14px','8px'][compress] + '; padding-top: 0px; }';
  782. styles += '.toolbar .toolbar-icon { width: ' + ['','31px','22px'][compress] + '; height: ' + ['','34px','22px'][compress] + '; line-height: ' + ['','34px','22px'][compress] + '; margin-top: 0px; }';
  783. styles += '.toolbar .group-title { height: ' + ['','34px','24px'][compress] + '; line-height: ' + ['','34px','24px'][compress] + '; margin-left: ' + ['','31px','22px'][compress] + '; margin-top: ' + ['','1px','0px'][compress] + '; }';
  784. styles += '.toolbar .dropdown-menu { top: ' + ['','34px','24px'][compress] + ' !important; left: ' + ['','7px','4px'][compress] + ' !important; }';
  785. //toolbar buttons
  786. styles += '.toolbar .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] + '; }';
  787. styles += '.toolbar .toolbar-button { padding-left: ' + ['','2px','2px'][compress] + '; padding-right: ' + ['','2px','2px'][compress] + '; }';
  788. styles += '.toolbar .toolbar-button .item-container { padding-left: ' + ['','9px','2px'][compress] + '; padding-right: ' + ['','9px','2px'][compress] + '; }';
  789. styles += '.toolbar .item-icon { font-size: ' + ['','22px','20px'][compress] + ' !important; }';
  790. //keep save button wide enough for counter
  791. styles += '.toolbar .toolbar-button.waze-icon-save { padding-right: 15px !important; width: ' + ['','62px','52px'][compress] + '; margin-left: 3px; }';
  792. styles += '.toolbar .toolbar-button.waze-icon-save .counter { top: ' + ['','-3px','-1px'][compress] + '; }';
  793. styles += '.toolbar .toolbar-button > .item-icon { top: ' + ['','5px','2px'][compress] + '; }';
  794. styles += '.toolbar .toolbar-separator { height: ' + ['','34px','22px'][compress] + '; }';
  795. //extra hack for my Permalink Counter button
  796. styles += '.WMEFUPCicon { margin-top: ' + ['','4px !important','2px !important'][compress] + '; }';
  797. //floating buttons
  798. styles += '.overlay-button { height: ' + ['','33px','26px'][compress] + '; width: ' + ['','33px','26px'][compress] + '; font-size: ' + ['','22px','20px'][compress] + '; padding: ' + ['','3px','1px'][compress] + '; }';
  799. styles += '#Info_div { height: ' + ['','33px','26px'][compress] + ' !important; width: ' + ['','33px','26px'][compress] + ' !important; }';
  800. styles += '.zoom-bar-container {width: ' + ['','33px','26px'][compress] + ' !important; }';
  801. styles += '.zoom-bar-container .overlay-button {height: ' + ['','33px','26px'][compress] + ' !important; }';
  802. styles += '#overlay-buttons .overlay-buttons-container > div:last-child { margin-bottom: 0; }';
  803. //layers menu
  804. // styles += '.layer-switcher .toolbar-button { margin-top: ' + ['','1px','0px'][compress] + ' !important; font-size: ' + ['','22px','20px'][compress] + ' !important; height: ' + ['','32px','24px'][compress] + '; }';
  805. //user button
  806. styles += '#user-box-region { margin-right: ' + ['','8px','2px'][compress] + '; }';
  807. styles += '.user-box-avatar { height: ' + ['','32px','23px'][compress] + ' !important; font-size: ' + ['','22px','20px'][compress] + '; }';
  808. styles += '.app .level-icon { width: ' + ['','32px','23px'][compress] + ' !important; height: ' + ['','32px','23px'][compress] + ' !important;}';
  809. levelIcon = getByClass('user-box-avatar')[0].firstElementChild;
  810. levelIcon.classList.remove('level-icon','level-icon-' + (W.loginManager.user.rank+1));
  811. styles += '#user-box-region .user-box-avatar .user-box-avatar-container img { display: none; }';
  812. levelIcon.classList.add('item-icon','w-icon','w-icon-user');
  813. //new save menu
  814. styles += '.changes-log-region { top: ' + ['','26px','21px'][compress] + '; }';
  815. // fix for WME Edit Count Monitor
  816. // no longer needed - it's calculating it's own position!
  817. //styles += '#edit-buttons > div > div:nth-child(10) { margin-top: ' + ['','3px','1px'][compress] + ' !important; }';
  818. //black bar
  819. styles += '.topbar { height: ' + ['','24px','18px'][compress] + '; line-height: ' + ['','24px','18px'][compress] + '; }';
  820. //fix for WME Presets button
  821. styles += '#WMEPresetsDiv > i { height: 100%;}';
  822. } else {
  823. levelIcon = getByClass('user-box-avatar')[0].firstElementChild;
  824. levelIcon.classList.add('level-icon','level-icon-' + (W.loginManager.user.rank+1));
  825. levelIcon.classList.remove('item-icon','w-icon','w-icon-user');
  826. }
  827. if (contrast > 0) {
  828. //toolbar dropdown menus
  829. styles += '.toolbar .group-title { color: black; }';
  830. styles += '.toolbar .toolbar-button { border-radius: 8px; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; color: black; }';
  831. //layers icon - until Waze fix it
  832. styles += '.layer-switcher .waze-icon-layers.toolbar-button{ background-color: white; }';
  833. }
  834. // //fix for buttons of WME GIS script
  835. // styles += '.btn-group-sm { text-shadow: initial; background: white; }';
  836. addStyle(prefix + fname,styles);
  837. } else {
  838. removeStyle(prefix + fname);
  839. levelIcon = getByClass('user-box-avatar')[0].firstElementChild;
  840. //change toolbar buttons - from JustinS83
  841. $('#mode-switcher-region .title-button .icon').removeClass('fa fa-calendar');
  842. $('#mode-switcher-region .title-button .icon').addClass('fa fa-angle-down');
  843. levelIcon = getByClass('user-box-avatar')[0].firstElementChild;
  844. levelIcon.classList.add('level-icon','level-icon-' + (W.loginManager.user.rank+1));
  845. levelIcon.classList.remove('item-icon','w-icon','w-icon-user');
  846. }
  847. window.dispatchEvent(new Event('resize'));
  848. }
  849.  
  850. function FALSEcompressSegmentTab() {
  851. getById('_cbCompressSegmentTab').checked = getById('_cbextraCBSection').checked;
  852. compressSegmentTab();
  853. }
  854.  
  855. function compressSegmentTab() {
  856. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  857. logit("function " + fname + " called", "debug");
  858. var styles = "";
  859. if (getById('_cbCompressSegmentTab').checked) {
  860. var contrast = getById('_inpUIContrast').value;
  861. var compress = getById('_inpUICompression').value;
  862. //Neuter the top gradient
  863. styles += '#sidebar .tab-scroll-gradient { pointer-events: none; }';
  864. //Nuke the bottom gradient
  865. styles += '#sidebar #links:before { display: none; }';
  866. // Make map comment text always visible
  867. styles += '.map-comment-name-editor .edit-button { display: block !important; }';
  868. //remove Waze font from side panel
  869. styles += '#sidebar { font-family: sans-serif; }';
  870. if (compress > 0) {
  871. //general compression enhancements
  872. styles += '#sidebar { line-height: ' + ['','18px','16px'][compress] + ';}';
  873. styles += '#sidebar .tab-content .tab-pane { padding: ' + ['','8px','1px'][compress] + '; }';
  874. styles += '#sidebar #sidebarContent { font-size: ' + ['','13px','12px'][compress] + '; }';
  875. styles += '#sidebar #advanced-tools { padding: ' + ['','0 9px','0 4px'][compress] + '; }';
  876. styles += '#sidebar .waze-staff-tools { margin-bottom: ' + ['','9px','4px'][compress] + '; height: ' + ['','25px','20px'][compress] + '; }';
  877. styles += '#sidebar .tab-content { padding: ' + ['','9px','4px'][compress] + '; padding-top: ' + ['','4px','0px'][compress] + '; }';
  878. //Tabs
  879. styles += '#sidebar .nav-tabs { padding-bottom: ' + ['','3px','2px'][compress] + '; }';
  880. styles += '#sidebar #user-info #user-tabs { padding: ' + ['','0 9px','0 4px'][compress] + '; }';
  881. styles += '#sidebar .tabs-container { padding: ' + ['','0 9px','0 4px'][compress] + '; }';
  882. styles += '#sidebar .nav-tabs li a { margin-top: ' + ['','2px','1px'][compress] + '; margin-left: ' + ['','3px','1px'][compress] + '; padding: ' + ['','0 6px','0 2px'][compress] + '; line-height: ' + ['','24px','21px'][compress] + '; height: ' + ['','24px','21px'][compress] + '; }';
  883. styles += '#sidebar .nav-tabs li { flex-grow: 0; }';
  884. //Feed
  885. styles += '.feed-item { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  886. styles += '.feed-item .inner { padding: ' + ['','5px','0px'][compress] + '; }';
  887. styles += '.feed-item .content .title { margin-bottom: ' + ['','1px','0px'][compress] + '; }';
  888. styles += '.feed-item .motivation { margin-bottom: ' + ['','2px','0px'][compress] + '; }';
  889. //Drives & Areas
  890. styles += '#sidebar .message { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  891. styles += '#sidebar .result-list .result { padding: ' + ['','6px 17px','2px 9px'][compress] + '; margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  892. styles += '#sidebar .result-list .session { background-color: lightgrey; }';
  893. styles += '#sidebar .result-list .session-available { background-color: white; }';
  894. styles += '#sidebar .result-list .result.selected { background-color: lightgreen; }';
  895. styles += 'div#sidepanel-drives { height: auto !important; }';
  896. //SEGMENT EDIT PANEL
  897. //general changes
  898. //checkbox groups
  899. styles += '#sidebar .controls-container { padding-top: ' + ['','4px','1px'][compress] + '; display: inline-block; font-size: ' + ['','12px','11px'][compress] + '; }';
  900. styles += '.controls-container input[type="checkbox"] + label { padding-left: ' + ['','21px','17px'][compress] + ' !important; } }';
  901. //form groups
  902. styles += '#sidebar .form-group { margin-bottom: ' + ['','5px','0px'][compress] + '; }';
  903. //dropdown inputs
  904. 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; }';
  905. //buttons
  906. styles += '#edit-panel .waze-btn { padding-top: 0px !important; padding-bottom: ' + ['','3px','1px'][compress] + '; height: ' + ['','20px','18px'][compress] + ' !important; line-height: ' + ['','20px','18px'][compress] + ' !important; font-size: ' + ['','13px','12px'][compress] + '; }';
  907. // 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] + '; }';
  908. //radio button controls
  909. 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] + '; }';
  910. styles += '.waze-radio-container label { width: auto; padding-left: ' + ['','6px','3px'][compress] + ' !important; padding-right: ' + ['','6px','3px'][compress] + ' !important; }';
  911. //text input areas
  912. styles += '#sidebar textarea.form-control { height: auto; }';
  913. styles += '#sidebar textarea { max-width: unset; }';
  914. //specific changes
  915. //Selected segments info
  916. styles += '#edit-panel .selection { padding-top: ' + ['','8px','2px'][compress] + '; padding-bottom: ' + ['','8px','4px'][compress] + '; }';
  917. styles += '#edit-panel .segment .direction-message { margin-bottom: ' + ['','9px','3px'][compress] + '; }';
  918. //Segment details (closure warning)
  919. styles += '#edit-panel .segment .segment-details { padding: ' + ['','10px','5px'][compress] + '; padding-top: 0px; }';
  920. //All control labels
  921. styles += '#edit-panel .control-label { font-size: ' + ['','11px','10px'][compress] + '; margin-bottom: ' + ['','4px','1px'][compress] + '; }';
  922. //Address input
  923. styles += '#edit-panel .address-edit-view { cursor: pointer; margin-bottom: ' + ['','6px','2px'][compress] + '!important; }';
  924. styles += '#edit-panel .address-edit-input { padding: ' + ['','4px','1px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  925. styles += '.tts-button { height: ' + ['','28px','21px'][compress] + '; }';
  926. //alt names
  927. styles += '.alt-street-list { margin-bottom: ' + ['','4px','0px'][compress] + '; }';
  928. styles += '#edit-panel .add-alt-street-form .alt-street { padding-top: ' + ['','13px','3px'][compress] + '; padding-bottom: ' + ['','13px','3px'][compress] + '; }';
  929. styles += '#edit-panel .add-alt-street-form .alt-street .alt-street-delete { top: ' + ['','12px','4px'][compress] + '; }';
  930. styles += '#edit-panel .segment .address-edit-view .address-form .action-buttons { padding-top: ' + ['','11px','6px'][compress] + '; padding-bottom: ' + ['','11px','6px'][compress] + '; margin-top: ' + ['','5px','0px'][compress] + '; height: ' + ['','45px','28px'][compress] + '; }';
  931. styles += '#edit-panel .add-alt-street-form .new-alt-street { padding-top: ' + ['','8px','3px'][compress] + '; padding-bottom: ' + ['','8px','3px'][compress] + '; }';
  932. //restrictions control
  933. styles += '#edit-panel .restriction-list { margin-bottom: ' + ['','5px','0px'][compress] + '; }';
  934. //speed limit controls
  935. styles += '#edit-panel .clearfix.controls.speed-limit { margin-top: ' + ['','0px','-5px'][compress] + '; }';
  936. styles += '#edit-panel .segment .speed-limit label { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  937. styles += '#edit-panel .segment .speed-limit .form-control { height: ' + ['','23px','19px'][compress] + '; padding-top: ' + ['','4px','2px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; width: 5em; margin-left: 0px; }';
  938. styles += '#edit-panel .segment .speed-limit .direction-label { font-size: ' + ['','12px','11px'][compress] + '; line-height: ' + ['','2.0em','1.8em'][compress] + '; }';
  939. styles += '#edit-panel .segment .speed-limit .unit-label { font-size: ' + ['','12px','11px'][compress] + '; line-height: ' + ['','2.0em','1.8em'][compress] + '; margin-left: 0px;}';
  940. styles += '#edit-panel .segment .speed-limit .average-speed-camera { margin-left: 40px; }';
  941. styles += '#edit-panel .segment .speed-limit .average-speed-camera .camera-icon { vertical-align: top; }';
  942. styles += '#edit-panel .segment .speed-limit .verify-buttons { margin-bottom: ' + ['','5px','0px'][compress] + '; }';
  943. //more actions section
  944. styles += '#edit-panel .more-actions { padding-top: ' + ['','6px','2px'][compress] + '; }';
  945. styles += '#edit-panel .more-actions .waze-btn.waze-btn-white { padding-left: 0px; padding-right: 0px; }';
  946. //get more-actions buttons on one line
  947. styles += '#edit-panel .more-actions { display: inline-flex; }';
  948. styles += '#edit-panel .action-button { width: 155px; overflow: hidden; }';
  949. styles += '#edit-panel .action-button:before { margin-right: 0px !important; }';
  950. styles += '#edit-panel .more-actions .edit-house-numbers-btn-wrapper { margin-top: 0px; }';
  951. //additional attributes
  952. styles += '#edit-panel .additional-attributes { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  953. //history items
  954. styles += '.toggleHistory { padding: ' + ['','7px','3px'][compress] + '; }';
  955. styles += '.element-history-item:not(:last-child) { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  956. styles += '.element-history-item .tx-header { padding: ' + ['','6px','2px'][compress] + '; }';
  957. styles += '.element-history-item .tx-header .tx-author-date { margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  958. styles += '.element-history-item .tx-content { padding: ' + ['','7px 7px 7px 22px','4px 4px 4px 22px'][compress] + '; }';
  959. styles += '.loadMoreContainer { padding: ' + ['','5px 0px','3px 0px'][compress] + '; }';
  960. //closures tab
  961. styles += 'wz-button { transform: scale(' + ['','0.9','0.8'][compress] + '); }';
  962. styles += '.closures > div:not(.closures-list) { padding: ' + ['','0px','0px'][compress] + '; }';
  963. styles += 'body { --wz-text-input-height: ' + ['','30px','20px'][compress] + '; }';
  964. styles += 'body { --wz-select-height: ' + ['','30px','20px'][compress] + '; }';
  965. styles += 'input.wz-text-input { height: ' + ['','30px','20px'][compress] + '; }';
  966. styles += '.edit-closure .closure-nodes .closure-node-item .closure-node-control { padding: ' + ['','7px','2px'][compress] + '; }';
  967. //closures list
  968. styles += '.closures-list .add-closure-button { line-height: ' + ['','20px','18px'][compress] + '; }';
  969. styles += '.closures-list .closure-item:not(:last-child) { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  970. styles += '.closures-list .closure-item .details { padding: ' + ['','5px','0px'][compress] + '; font-size: ' + ['','12px','11px'][compress] + '; }';
  971. styles += '.closures-list .closure-item .buttons { top: ' + ['','7px','4px'][compress] + '; }';
  972. //tweak for Junction Box button
  973. styles += '#edit-panel .junction-actions > button { width: inherit; }';
  974. //PLACE DETAILS
  975. //alert
  976. styles += '#edit-panel .header-alert { margin-bottom: ' + ['','6px','2px'][compress] + '; padding: ' + ['','6px 32px','2px 32px'][compress] + '; }';
  977. //address input
  978. styles += '#edit-panel .full-address { padding-top: ' + ['','4px','1px'][compress] + '; padding-bottom: ' + ['','4px','1px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  979. //alt names
  980. styles += '#edit-panel .aliases-view .list li { margin: ' + ['','12px 0','4px 0'][compress] + '; }';
  981. styles += '#edit-panel .aliases-view .delete { line-height: inherit; }';
  982. //categories
  983. 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] + '; }';
  984. styles += '#edit-panel .categories .select2-search-field input { height: ' + ['','18px','17px'][compress] + '; }';
  985. styles += '#edit-panel .categories .select2-choices { min-height: ' + ['','26px','19px'][compress] + '; }';
  986. styles += '#edit-panel .categories .select2-container { margin-bottom: 0px; }';
  987. //entry/exit points
  988. styles += '#edit-panel .navigation-point-view .navigation-point-list-item .preview { padding: ' + ['','3px 7px','0px 4px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  989. styles += '#edit-panel .navigation-point-view .add-button { height: ' + ['','28px','18px'][contrast] + '; line-height: ' + ['','17px','16px'][contrast] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  990. //type buttons
  991. styles += '#sidebar .area-btn, #sidebar .point-btn { height: ' + ['','19px','16px'][compress] + '; line-height: ' + ['','19px','16px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  992. // { height: ' + ['','19px','16px'][compress] + '; width: ' + ['','19px','16px'][compress] + '; line-height: ' + ['','19px','16px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; margin-bottom: ' + ['','3px','1px'][compress] + '; }';
  993. //external providers
  994. styles += '.select2-container { font-size: ' + ['','13px','12px'][compress] + '; }';
  995. styles += '#edit-panel .external-providers-view .external-provider-item { margin-bottom: ' + ['','6px','2px'][compress] + '; }';
  996. styles += '.external-providers-view > div > ul { margin-bottom: ' + ['','4px','0px'][compress] + '; }';
  997. styles += '#edit-panel .external-providers-view .add { padding: ' + ['','3px 12px','1px 9px'][compress] + '; }';
  998. styles += '#edit-panel .waze-btn.waze-btn-smaller { line-height: ' + ['','26px','21px'][compress] + '; }';
  999. //residential toggle
  1000. styles += '#edit-panel .toggle-residential { height: ' + ['','27px','22px'][compress] + '; }';
  1001. //more info
  1002. styles += '.service-checkbox { font-size: ' + ['','13px','12px'][compress] + '; }';
  1003. //PARKING LOT SPECIFIC
  1004. styles += '.parking-type-option{ display: inline-block; }';
  1005. styles += '.payment-checkbox { display: inline-block; min-width: ' + ['','48%','31%'][compress] + '; }';
  1006. styles += '.service-checkbox { display: inline-block; min-width: 49%; font-size: ' + ['','12px','11px'][compress] + '; }';
  1007. styles += '.lot-checkbox { display: inline-block; min-width: 49%; }';
  1008. //MAP COMMENTS
  1009. styles += '.map-comment-name-editor { padding: ' + ['','10px','5px'][compress] + '; }';
  1010. styles += '.map-comment-name-editor .edit-button { margin-top: 0px; font-size: ' + ['','13px','12px'][compress] + '; padding-top: ' + ['','3px','1px'][compress] + '; }';
  1011. styles += '.conversation-view .no-comments { padding: ' + ['','10px 15px','5px 15px'][compress] + '; }';
  1012. styles += '.map-comment-feature-editor .conversation-view .comment-list { padding-top: ' + ['','8px','1px'][compress] + '; padding-bottom: ' + ['','8px','1px'][compress] + '; }';
  1013. styles += '.map-comment-feature-editor .conversation-view .comment-list .comment .comment-content { padding: ' + ['','6px 0px','2px 0px'][compress] + '; }';
  1014. styles += '.conversation-view .comment .text { padding: ' + ['','6px 9px','3px 4px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  1015. styles += '.conversation-view .new-comment-form { padding-top: ' + ['','10px','5px'][compress] + '; }';
  1016. styles += '.map-comment-feature-editor .clear-btn { height: ' + ['','26px','19px'][compress] + '; line-height: ' + ['','26px','19px'][compress] + '; }';
  1017. //Compression for WME Speedhelper
  1018. styles += '.clearfix.controls.speed-limit { margin-top: ' + ['','-4px','-8px'][compress] + '; }';
  1019. //Compression for WME Clicksaver
  1020. styles += '.rth-btn-container { margin-bottom: ' + ['','2px','-1px'][compress] + '; }';
  1021. styles += '#csRoutingTypeContainer { height: ' + ['','23px','16px'][compress] + ' !important; margin-top: ' + ['','-2px','-4px'][compress] + '; }';
  1022. styles += '#csElevationButtonsContainer { margin-bottom: ' + ['','2px','-1px'][compress] + ' !important; }';
  1023. //tweak for WME Clicksaver tab controls
  1024. styles += '#sidepanel-clicksaver .controls-container { width: 100%; }';
  1025. //tweak for JAI tab controls
  1026. styles += '#sidepanel-ja .controls-container { width: 100%; }';
  1027. //tweaks for UR-MP Tracker
  1028. styles += '#sidepanel-urt { margin-left: ' + ['','-5px','0px'][compress] + ' !important; }';
  1029. styles += '#urt-main-title { margin-top: ' + ['','-5px','0px'][compress] + ' !important; }';
  1030. //tweaks for my own panel
  1031. styles += '#fuContent { line-height: ' + ['','10px','9px'][compress] + ' !important; }';
  1032. }
  1033. if (contrast > 0) {
  1034. //contrast enhancements
  1035. //general
  1036. styles += '#sidebar .form-group { border-top: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1037. //text colour
  1038. styles += '#sidebar { color: black; }';
  1039. //advanced tools section
  1040. styles += '#sidebar waze-staff-tools { background-color: #c7c7c7; }';
  1041. //Tabs
  1042. styles += '#sidebar .nav-tabs { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1043. styles += '#sidebar .nav-tabs li a { border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
  1044. //Fix the un-noticeable feed refresh button
  1045. styles += 'span.fa.fa-repeat.feed-refresh.nav-tab-icon { width: 19px; color: orangered; }';
  1046. styles += 'span.fa.fa-repeat.feed-refresh.nav-tab-icon:hover { color: red; font-weight: bold; font-size: 15px; }';
  1047. //Feed
  1048. styles += '.feed-item { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1049. styles += '.feed-issue .content .title .type { color: ' + ['','black','black'][contrast] + '; font-weight: bold; }';
  1050. styles += '.feed-issue .content .timestamp { color: ' + ['','dimgrey','black'][contrast] + '; }';
  1051. styles += '.feed-issue .content .subtext { color: ' + ['','dimgrey','black'][contrast] + '; }';
  1052. styles += '.feed-item .motivation { font-weight: bold; }';
  1053. //Drives & Areas
  1054. styles += '#sidebar .result-list .result { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1055. //Segment edit panel
  1056. styles += '#edit-panel .selection { font-size: 13px; }';
  1057. styles += '#edit-panel .segment .direction-message { color: orangered; }';
  1058. styles += '#edit-panel .address-edit-input { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1059. styles += '#sidebar .form-control { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1060. //radio buttons when disabled
  1061. styles += '.waze-radio-container input[type="radio"]:disabled:checked + label { color: black; opacity: 0.7; font-weight:600; }';
  1062. //override border for lock levels
  1063. styles += '#sidebar .waze-radio-container { border: 0 none !important; }';
  1064. styles += '#edit-panel .waze-btn { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1065. styles += '.waze-radio-container label { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1066. //history items
  1067. styles += '.toggleHistory { color: black; text-align: center; }';
  1068. styles += '.element-history-item .tx-header { color: black; }';
  1069. styles += '.element-history-item.closed .tx-header { border-radius: 8px; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1070. styles += '.loadMoreHistory { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1071. //closures list
  1072. styles += '.closures-list .closure-item .details { border-radius: 8px; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1073. styles += '.closures-list .closure-item .dates { color: black; }';
  1074. styles += '.closures-list .closure-item .dates .date-label { opacity: 1; }';
  1075. //Place details
  1076. //alert
  1077. styles += '#edit-panel .alert-danger { color: red; }';
  1078. //address input
  1079. styles += '#edit-panel .full-address { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1080. styles += '#edit-panel a.waze-link { font-weight: bold; }';
  1081. //categories
  1082. styles += '#edit-panel .categories .select2-search-choice .category { text-transform: inherit; font-weight: bold; background: gray; }';
  1083. //entry/exit points
  1084. styles += '#edit-panel .navigation-point-view .navigation-point-list-item .preview { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1085. styles += '#edit-panel .navigation-point-view .add-button { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; margin-top: 2px; padding: 0 5px; }';
  1086. //type buttons
  1087. styles += '#sidebar .point-btn { color: black; border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
  1088. //external providers
  1089. styles += '.select2-container { color: teal; border: 1px solid ' + ['','lightgrey','grey'][contrast] + ' !important; }';
  1090. styles += '.select2-container .select2-choice { color: black; }';
  1091. //residential toggle
  1092. styles += '#edit-panel .toggle-residential { font-weight: bold; }';
  1093. //COMMENTS
  1094. styles += '.map-comment-name-editor { border-color: ' + ['','darkgrey','grey'][contrast] + '; }';
  1095. }
  1096. // hide headlight required control if not valid for this country
  1097. // need to delay, as topCountry is taking too long to appear
  1098. setTimeout(hideHeadlights,5000);
  1099. //fix for buttons of WME Image Overlay script
  1100. styles += '#sidepanel-imageoverlays > div.result-list button { height: 24px; }';
  1101. addStyle(prefix + fname,styles);
  1102. } else {
  1103. removeStyle(prefix + fname);
  1104. removeStyle(prefix + 'hideHeadlights');
  1105. }
  1106. }
  1107.  
  1108. function hideHeadlights() {
  1109. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1110. logit("function " + fname + " called", "debug");
  1111. var styles = "";
  1112. if (W.model.getTopCountry()) {
  1113. if (W.model.getTopCountry().allowHeadlightsReminderRank === null) {
  1114. styles += '.headlights-reminder { display: none !important; }';
  1115. addStyle(prefix + fname,styles);
  1116. }
  1117. }
  1118. }
  1119.  
  1120. function compressLayersMenu() {
  1121. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1122. logit("function " + fname + " called", "debug");
  1123. removeStyle(prefix + fname);
  1124. var styles = "";
  1125. if (getById('_cbCompressLayersMenu').checked) {
  1126. getById('layersColControls').style.opacity = '1';
  1127. var contrast = getById('_inpUIContrast').value;
  1128. var compress = getById('_inpUICompression').value;
  1129. if (compress > 0) {
  1130. //VERTICAL CHANGES
  1131. //change menu to autoheight - not working
  1132. // styles += '.layer-switcher .menu { height: auto; width: auto; max-height: calc(100% - 26px); overflow-y: scroll }';
  1133. //change menu to auto-width
  1134. styles += '.layer-switcher .menu { width: auto }';
  1135. styles += '.layer-switcher .menu.hide-layer-switcher { left: 100% }';
  1136. //menu title
  1137. styles += '.layer-switcher .menu > .title { font-size: ' + ['','14px','12px'][compress] + '; padding-bottom: ' + ['','7px','2px'][compress] + '; padding-top: ' + ['','7px','2px'][compress] + ' }';
  1138. styles += '.layer-switcher .menu > .title .w-icon-x { font-size: ' + ['','21px','18px'][compress] + ' }';
  1139. styles += '.layer-switcher .scrollable { height: calc(100% - ' + ['','39px','29px'][compress] + ') }';
  1140. //menu group headers
  1141. styles += '.layer-switcher .layer-switcher-toggler-tree-category { padding: ' + ['','5px','2px'][compress] + ' 0; height: ' + ['','30px','20px'][compress] + ' }';
  1142. //menu items
  1143. styles += '.layer-switcher li { line-height: ' + ['','20px','16px'][compress] + '}';
  1144. styles += '.layer-switcher .togglers ul li .wz-checkbox { margin-bottom: ' + ['','3px','0px'][compress] + ' }';
  1145. styles += '.wz-checkbox { min-height: ' + ['','20px','16px'][compress] + ' }';
  1146. styles += '.wz-checkbox input[type="checkbox"] + label { line-height: ' + ['','20px','16px'][compress] + '; font-size: ' + ['','12px','11px'][compress] + ' }';
  1147. styles += '.wz-checkbox input[type="checkbox"] + label:before { font-size: ' + ['','13px','10px'][compress] + '; height: ' + ['','16px','14px'][compress] + '; width: ' + ['','16px','14px'][compress] + '; line-height: ' + ['','12px','11px'][compress] + ' }';
  1148. //HORIZONTAL CHANGES
  1149. styles += '.layer-switcher .togglers ul { padding-left: ' + ['','19px','12px'][compress] + '; }';
  1150. styles += '.layer-switcher .togglers .group { padding: ' + ['','0 8px 0 4px','0 4px 0 2px'][compress] + ' }';
  1151. if (getById('_cbLayersColumns').checked) {
  1152. //2 column stuff
  1153. styles += '.layer-switcher .scrollable { columns: 2; }';
  1154. styles += 'li.group { break-inside: avoid; page-break-inside: avoid; }';
  1155. //prevent city names showing up when it should be hidden
  1156. styles += ' .layer-switcher ul[class^="collapsible"].collapse-layer-switcher-group { visibility: collapse }';
  1157. styles += '.layer-switcher .menu { overflow-x: hidden; overflow-y: scroll; height: auto; max-height: calc(100% - ' + ['','39px','29px'][compress] + ') }';
  1158. styles += '.layer-switcher .scrollable { overflow-x: hidden; overflow-y: hidden; height: unset }';
  1159. }
  1160. // fix from ABelter for layers menu
  1161. styles += ' .layer-switcher ul[class^="collapsible"] { max-height: none; }';
  1162. } else {
  1163. //2-columns not available without compression
  1164. getById('layersColControls').style.opacity = '0.5';
  1165. }
  1166. if (contrast > 0) {
  1167. styles += '.controls-container.main.toggler { color: white; background: dimgray }';
  1168. styles += '.layer-switcher .toggler.main .label-text { text-transform: inherit }';
  1169. //labels
  1170. styles += '.layer-switcher .layer-switcher-toggler-tree-category > .label-text { color: black }';
  1171. styles += '.wz-checkbox input[type="checkbox"] + label { WME: FU; color: black }';
  1172. //group separator
  1173. styles += '.layer-switcher .togglers .group { border-bottom: 1px solid ' + ['','lightgrey','grey'][contrast] + ' }';
  1174. //column rule
  1175. styles += '.layer-switcher .scrollable { column-rule: 1px solid ' + ['','lightgrey','grey'][contrast] + ' }';
  1176. }
  1177. if (getById('_cbLayersMenuMoreOptions').checked === true) {
  1178. styles += '.layer-switcher ul[class^="collapsible"].collapse-layer-switcher-group { visibility: inherit; max-height: inherit }';
  1179. styles += '.layer-switcher i.toggle-category { visibility: hidden; width: 0 }';
  1180. }
  1181. addStyle(prefix + fname,styles);
  1182. } else {
  1183. getById('layersColControls').style.opacity = '0.5';
  1184. removeStyle(prefix + fname);
  1185. }
  1186. }
  1187.  
  1188. function restyleReports() {
  1189. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1190. logit("function " + fname + " called", "debug");
  1191. var styles = "";
  1192. if (getById('_cbRestyleReports').checked) {
  1193. var contrast = getById('_inpUIContrast').value;
  1194. var compress = getById('_inpUICompression').value;
  1195. if (compress > 0) {
  1196. //report header
  1197. styles += '#panel-container .header { padding: ' + ['','9px 36px','1px 36px'][compress] + '; line-height: ' + ['','19px','17px'][compress] + '; }';
  1198. styles += '#panel-container .header .dot { top: ' + ['','15px','7px'][compress] + '; }';
  1199. //special treatment for More Information checkboxes (with legends)
  1200. styles += '#panel-container .problem-edit .more-info .legend { left: 20px; top: 3px; }';
  1201. styles += '#panel-container .more-info input[type="checkbox"] + label { padding-left: 33px !important; }';
  1202. //report body
  1203. styles += '#panel-container .body { line-height: ' + ['','15px','13px'][compress] + '; font-size: ' + ['','13px','12px'][compress] + '; }';
  1204. //problem description
  1205. styles += '#panel-container div.description.section > div.collapsible.content { padding: ' + ['','9px','3px'][compress] + '; }';
  1206. //comments
  1207. styles += '#panel-container .conversation-view .comment .comment-content { padding: ' + ['','6px 9px','2px 3px'][compress] + '; }';
  1208. styles += '#panel-container .comment .text { padding: ' + ['','7px 9px','4px 4px'][compress] + '; }';
  1209. //new comment entry
  1210. styles += '#panel-container .conversation-view .new-comment-form { padding: ' + ['','8px 9px 6px 9px','1px 3px 2px 3px'][compress] + '; }';
  1211. //send button
  1212. 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] + '; }';
  1213. //lower buttons
  1214. styles += '#panel-container > div > div > div.actions > div > div { padding-top: ' + ['','6px','3px'][compress] + '; }';
  1215. styles += '#panel-container .close-details.section { font-size: ' + ['','13px','12px'][compress] + '; line-height: ' + ['','13px','9px'][compress] + '; }';
  1216. styles += '#panel-container .problem-edit .actions .controls-container label { height: ' + ['','28px','21px'][compress] + '; line-height: ' + ['','28px','21px'][compress] + '; margin-bottom: ' + ['','5px','2px'][compress] + '; }';
  1217. styles += '#panel-container .waze-plain-btn { height: ' + ['','30px','20px'][compress] + '; line-height: ' + ['','30px','20px'][compress] + '; }';
  1218. styles += '.panel .navigation { margin-top: ' + ['','6px','2px'][compress] + '; }';
  1219. //WMEFP All PM button
  1220. styles += '#WMEFP-UR-ALLPM { top: ' + ['','5px','0px'][compress] + ' !important; }';
  1221. }
  1222. if (contrast > 0) {
  1223. styles += '#panel-container .section { border-bottom: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1224. styles += '#panel-container .close-panel { border-color: ' + ['','lightgrey','grey'][contrast] + '; }';
  1225. styles += '#panel-container .main-title { font-weight: 900; }';
  1226. styles += '#panel-container .reported { color: ' + ['','dimgrey','black'][contrast] + '; }';
  1227. styles += '#panel-container .date { color: ' + ['','#6d6d6d','#3d3d3d'][contrast] + '; }';
  1228. styles += '#panel-container .comment .text { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1229. styles += '#panel-container .comment-content.reporter .username { color: ' + ['','#159dc6','#107998'][contrast] + '; }';
  1230. styles += '#panel-container .conversation-view .new-comment-form textarea { border: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1231. styles += '#panel-container .top-section { border-bottom: 1px solid ' + ['','lightgrey','grey'][contrast] + '; }';
  1232. styles += '#panel-container .waze-plain-btn { font-weight: 800; color: ' + ['','#159dc6','#107998'][contrast] + '; }';
  1233. }
  1234. addStyle(prefix + fname,styles);
  1235. if (wmeFUinitialising) {
  1236. setTimeout(draggablePanel, 5000);
  1237. } else {
  1238. draggablePanel();
  1239. }
  1240. } else {
  1241. removeStyle(prefix + fname);
  1242. if (jQuery.ui) {
  1243. if ( $("#panel-container").hasClass('ui-draggable') ) {
  1244. $("#panel-container").draggable("destroy");
  1245. }
  1246. getById("panel-container").style = "";
  1247. }
  1248. }
  1249. window.dispatchEvent(new Event('resize'));
  1250. }
  1251.  
  1252. function draggablePanel() {
  1253. if (jQuery.ui) {
  1254. if ($("#panel-container").draggable) {
  1255. $("#panel-container").draggable({ handle: ".header" });
  1256. }
  1257. }
  1258. }
  1259.  
  1260. function enhanceChat() {
  1261. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1262. logit("function " + fname + " called", "debug");
  1263. var styles = "";
  1264. if (getById('_cbEnhanceChat').checked) {
  1265. removeStyle(prefix + fname);
  1266. var contrast = getById('_inpUIContrast').value;
  1267. var compress = getById('_inpUICompression').value;
  1268. var mapY = getById('map').clientHeight;
  1269. var chatY = Math.floor( mapY * 0.5);
  1270. var chatHeaderY = [50,35,20][compress];
  1271. var chatMessageInputY = [39,31,23][compress];
  1272. var chatMessagesY = chatY - chatHeaderY - chatMessageInputY;
  1273. var chatUsersY = chatY - chatHeaderY;
  1274. //change chat width to 35% of whole window
  1275. styles += '#chat .messages { width: calc(25vw); min-width: 200px;}';
  1276. styles += '#map.street-view-mode #chat .messages { width: calc(25vw); }';
  1277. styles += '#chat .messages .message-list { margin-bottom: 0px; }';
  1278. styles += '#chat .messages .new-message { position: inherit; width: unset; }';
  1279. styles += '#map.street-view-mode #chat .messages .new-message { position: inherit; width: unset; }';
  1280. styles += '#chat .users { width: calc(10vw); min-width: 120px; }';
  1281. styles += '#chat .messages .message-list .message.normal-message { max-width: unset; }';
  1282. //change chat height to 50% of map view
  1283. styles += '#chat .messages .message-list { min-height: ' + chatMessagesY + 'px; }';
  1284. styles += '#chat .users { max-height: ' + chatUsersY + 'px; }';
  1285. // #chat .messages .unread-messages-notification width=70%, bottom64px>
  1286. if (compress > 0) {
  1287. //do compression
  1288. //header
  1289. styles += '#chat .header { line-height: ' + chatHeaderY + 'px; }';
  1290. styles += '#chat .header .dropdown .dropdown-toggle { line-height: ' + ['','30px','22px'][compress] + '; }';
  1291. styles += '#chat .header button { line-height: ' + ['','20px','19px'][compress] + '; font-size: ' + ['','13px','11px'][compress] + '; height: ' + ['','20px','19px'][compress] + '; }';
  1292. //message list
  1293. styles += '#chat .messages .message-list { padding: ' + ['','9px','3px'][compress] + '; }';
  1294. styles += '#chat .messages .message-list .message.normal-message { padding: ' + ['','6px','2px'][compress] + '; }';
  1295. styles += '#chat .messages .message-list .message { margin-bottom: ' + ['','8px','2px'][compress] + '; line-height: ' + ['','16px','14px'][compress] + '; font-size: ' + ['','12px','11px'][compress] + '; }';
  1296. styles += '#chat .messages .new-message input { height: ' + chatMessageInputY + 'px; }';
  1297. //user list
  1298. styles += '#chat .users { padding: ' + ['','8px','1px'][compress] + '; }';
  1299. styles += '#chat ul.user-list a.user { padding: ' + ['','2px','1px'][compress] + '; }';
  1300. styles += '#chat ul.user-list a.user .rank { width: ' + ['','25px','20px'][compress] + '; height: ' + ['','20px','16px'][compress] + '; margin-right: ' + ['','3px','1px'][compress] + '; }';
  1301. styles += '#chat ul.user-list a.user .username { line-height: ' + ['','21px','17px'][compress] + '; }';
  1302. styles += '#chat ul.user-list a.user:hover .crosshair { margin-top: ' + ['','3px','1px'][compress] + '; right: ' + ['','3px','1px'][compress] + '; }';
  1303. //fix for WME Chat Addon
  1304. styles += '#chat .users > ul > li > a { margin: 0px !important; }';
  1305. }
  1306. if (contrast > 0) {
  1307. //header
  1308. styles += '#chat .header { color: black; background-color: ' + ['','#d9d9d9','#bfbfbf'][contrast] + '; }';
  1309. styles += '#chat .messages .message-list { background-color: ' + ['','#e8e8e8','lightgrey'][contrast] + '; }';
  1310. styles += '#chat .messages .message-list .message.normal-message { color: black; float: left; }';
  1311. styles += '#chat .messages .message-list .message.normal-message .from { color: dimgrey; font-weight: bold; font-style: italic; }';
  1312. styles += '#chat .messages .message-list .message.own-message .from { color: black; background-color: #a1dcf5; }';
  1313. //user message timestamps
  1314. styles += '#chat > div.chat-body > div.messages > div.message-list > div > div.from > span { color: ' + ['','dimgrey','black'][contrast] + ' !important; }';
  1315. //system message timestamps
  1316. styles += '#chat > div.chat-body > div.messages > div.message-list > div > div.body > div > span { color: ' + ['','dimgrey','black'][contrast] + ' !important; }';
  1317. //fix for WME Chat Addon
  1318. styles += '#chat .body > div { color: black !important; }';
  1319. }
  1320. //fix for Chat Addon timestamps running up against names
  1321. styles += '#chat > div.chat-body > div.messages > div.message-list > div > div.from > span { margin-left: 5px; }';
  1322. addStyle(prefix + fname,styles);
  1323. } else {
  1324. removeStyle(prefix + fname);
  1325. }
  1326. }
  1327.  
  1328. function narrowSidePanel() {
  1329. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1330. logit("function " + fname + " called", "debug");
  1331. var styles = "";
  1332. if (getById('_cbNarrowSidePanel').checked) {
  1333. //sidebar width
  1334. styles += '.row-fluid #sidebar { width: 250px; }';
  1335. //map width
  1336. styles += '.show-sidebar .row-fluid .fluid-fixed { margin-left: 250px; }';
  1337. //user info tweaks
  1338. styles += '#sidebar #user-info #user-box { padding: 0 0 5px 0; }';
  1339. styles += '#sidebar #user-details { width: 250px; }';
  1340. styles += '#sidebar #user-details .user-profile .level-icon { margin: 0; }';
  1341. styles += '#sidebar #user-details .user-profile .user-about { max-width: 161px; }';
  1342. //gradient bars
  1343. styles += '#sidebar .tab-scroll-gradient { width: 220px; }';
  1344. styles += '#sidebar #links:before { width: 236px; }';
  1345. //feed
  1346. styles += '.feed-item .content { max-width: 189px; }';
  1347. //segment edit panel
  1348. styles += '#edit-panel .more-actions .waze-btn.waze-btn-white { width: 122px; }';
  1349. //tweak for WME Bookmarks
  1350. styles += '#divBookmarksContent .divName { max-width: 164px; }';
  1351. //tweak for WME PH buttons
  1352. styles += '#WMEPH_runButton .btn { font-size: 11px; padding: 2px !important; }';
  1353. addStyle(prefix + fname, styles);
  1354. } else {
  1355. removeStyle(prefix + fname);
  1356. }
  1357. compressSegmentTab();
  1358. window.dispatchEvent(new Event('resize'));
  1359. }
  1360.  
  1361. function shiftAerials() {
  1362. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1363. logit("function " + fname + " called", "debug");
  1364. // calculate meters/pixel for current map view
  1365. var ipu = OpenLayers.INCHES_PER_UNIT;
  1366. var metersPerPixel = W.map.getResolution() * ipu.m / ipu[W.map.getOLMap().getUnits()];
  1367. // Apply the shift and opacity
  1368. W.map.getOLMap().baseLayer.div.style.left = Math.round(getById("_inpASX").value / metersPerPixel) + 'px';
  1369. W.map.getOLMap().baseLayer.div.style.top = Math.round(- getById("_inpASY").value / metersPerPixel) + 'px';
  1370. if (getById('_inpASO').value < 10) getById('_inpASO').value = 10;
  1371. W.map.getOLMap().baseLayer.div.style.opacity = getById("_inpASO").value/100;
  1372. if (getById("_inpASX").value != 0 || getById("_inpASY").value != 0) {
  1373. getById("WMEFU_AS").style.display = "block";
  1374. } else {
  1375. getById("WMEFU_AS").style.display = "none";
  1376. }
  1377. //turn off Enhance Chat if WME Chat Fix is loaded
  1378. if (document.getElementById('WMEfixChat-setting')) {
  1379. if (getById('_cbEnhanceChat').checked === true) {
  1380. alert("WME FixUI: Enhance Chat disabled because WME Chat UI Fix detected");
  1381. }
  1382. getById('_cbEnhanceChat').checked = false;
  1383. }
  1384. }
  1385.  
  1386. function fixExternalProviders () {
  1387. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1388. logit("function " + fname + " called", "debug");
  1389. var styles = "";
  1390. if (getById('_cbFixExternalProviders').checked) {
  1391. //enlarge external provider boxes
  1392. styles += '#edit-panel .external-providers-view .select2-container { width: 90%; margin-bottom: 2px; }';
  1393. styles += '.select2-container .select2-choice { height: inherit; line-height: 16px; }';
  1394. styles += '.select2-container .select2-choice>.select2-chosen { white-space: normal; }';
  1395. styles += '.placeId { padding-bottom: 5px; }';
  1396. addStyle(prefix + fname,styles);
  1397. } else {
  1398. removeStyle(prefix + fname);
  1399. }
  1400. }
  1401.  
  1402. function warnCommentsOff() {
  1403. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1404. logit("function " + fname + " called", "debug");
  1405. if (W.map.getLayerByUniqueName('mapComments').visibility === false) {
  1406. removeStyle(prefix + fname);
  1407. addStyle(prefix + fname, '.toolbar { background-color: #FFC107; }');
  1408. } else {
  1409. removeStyle(prefix + fname);
  1410. }
  1411. // extra bit because killNodeLayer will be inactive
  1412. // getId("_btnKillNode").innerHTML = "Hide junction nodes";
  1413. getById("_btnKillNode").style.backgroundColor = "";
  1414. }
  1415.  
  1416. function adjustGSV() {
  1417. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1418. logit("function " + fname + " called", "debug");
  1419. var styles = "";
  1420. var C = getById('_inpGSVContrast');
  1421. var B = getById('_inpGSVBrightness');
  1422. var I = getById('_cbGSVInvert');
  1423. if (C.value < 10) C.value = 10;
  1424. if (B.value < 10) B.value = 10;
  1425. styles += '.gm-style { filter: contrast(' + C.value + '%) ';
  1426. styles += 'brightness(' + B.value + '%) ';
  1427. if (I.checked) {
  1428. styles += 'invert(1); }';
  1429. } else {
  1430. styles += 'invert(0); }';
  1431. }
  1432. removeStyle(prefix + fname);
  1433. if ((C.value != 100) || (B.value !=100) || I.checked) addStyle(prefix + fname, styles);
  1434. }
  1435.  
  1436. function GSVWidth() {
  1437. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1438. logit("function " + fname + " called", "debug");
  1439. removeStyle(prefix + fname);
  1440. var w = getById('_inpGSVWidth').value;
  1441. if (w != 50) {
  1442. var styles = "";
  1443. styles += '#editor-container #map.street-view-mode #waze-map-container { width: ' + (100-w) + '%; }';
  1444. styles += '#editor-container #street-view-container { width: ' + w + '%; }';
  1445. styles += '#editor-container #map #street-view-drag-handle { left: ' + (100-w) + '%; }';
  1446. addStyle(prefix + fname, styles);
  1447. }
  1448. window.dispatchEvent(new Event('resize'));
  1449. }
  1450.  
  1451. function GSVWidthReset() {
  1452. getById('waze-map-container').style = null;
  1453. getById('street-view-container').style = null;
  1454. getById('street-view-drag-handle').style = null;
  1455. // Check for WME Street View Availability
  1456. // This can be removed soon - WME SVA no longer remembers GSV width
  1457. if (localStorage.WMEStreetViewWidth) {
  1458. localStorage.WMEStreetViewWidth = '';
  1459. }
  1460. window.dispatchEvent(new Event('resize'));
  1461. }
  1462.  
  1463. function moveChatIcon() {
  1464. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1465. logit("function " + fname + " called", "debug");
  1466. var styles = "";
  1467. if (getById('_cbMoveChatIcon').checked) {
  1468. styles += '#chat-overlay { left: inherit !important; right: 60px !important;}';
  1469. styles += '#chat-overlay #chat-toggle { right: 0px !important; }';
  1470. addStyle(prefix + fname,styles);
  1471. } else {
  1472. removeStyle(prefix + fname);
  1473. }
  1474. }
  1475.  
  1476. function highlightInvisible() {
  1477. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1478. logit("function " + fname + " called", "debug");
  1479. var styles = "";
  1480. if (getById('_cbHighlightInvisible').checked) {
  1481. styles += '#chat-overlay.visible-false #chat-toggle button { filter: none; background-color: #ff0000c0; }';
  1482. addStyle(prefix + fname,styles);
  1483. } else {
  1484. removeStyle(prefix + fname);
  1485. }
  1486. }
  1487.  
  1488. function darkenSaveLayer() {
  1489. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1490. logit("function " + fname + " called", "debug");
  1491. var styles = "";
  1492. if (getById('_cbDarkenSaveLayer').checked) {
  1493. //don't publish without alteration!
  1494. styles += '#popup-overlay { background-color: dimgrey !important; }';
  1495. addStyle(prefix + fname,styles);
  1496. } else {
  1497. removeStyle(prefix + fname);
  1498. }
  1499. }
  1500.  
  1501. function swapRoadsGPS() {
  1502. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1503. logit("function " + fname + " called", "debug");
  1504. var styles = "";
  1505. if (getById('_cbSwapRoadsGPS').checked) {
  1506. var roadLayerId = W.map.getLayerByUniqueName("roads").id;
  1507. var GPSLayerId = W.map.getLayerByUniqueName("gps_points").id;
  1508. var roadLayerZ = W.map.getLayerByUniqueName("roads").getZIndex();
  1509. var GPSLayerZ = W.map.getLayerByUniqueName("gps_points").getZIndex();
  1510. logit("Layers identified\n\tRoads: " + roadLayerId + "," + roadLayerZ + "\n\tGPS: " + GPSLayerId + "," + GPSLayerZ, "info");
  1511. styles += '#' + roadLayerId.replace(/\./g,"\\2e") + ' { z-index: ' + GPSLayerZ + ' !important; }';
  1512. styles += '#' + GPSLayerId.replace(/\./g,"\\2e") + ' { z-index: ' + roadLayerZ + ' !important; }';
  1513. addStyle(prefix + fname,styles);
  1514. } else {
  1515. removeStyle(prefix + fname);
  1516. }
  1517. }
  1518.  
  1519. function killNode() {
  1520. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1521. logit("function " + fname + " called", "debug");
  1522. getById(W.map.getLayerByUniqueName("nodes").id + "_root").style.display = "none";
  1523. getById("_btnKillNode").style.backgroundColor = "yellow";
  1524. // getId("_btnKillNode").innerHTML = "Junction nodes hidden!";
  1525. }
  1526.  
  1527. function killTurnPopup() {
  1528. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1529. logit("function " + fname + " called", "debug");
  1530. if (getById("WMEFUTPB").style.backgroundColor == "red") {
  1531. getById("WMEFUTPB").style.backgroundColor = "inherit";
  1532. removeStyle(prefix + fname);
  1533. } else {
  1534. getById("WMEFUTPB").style.backgroundColor = "red";
  1535. addStyle(prefix + fname,'#big-tooltip-region { display: none !important; }');
  1536. }
  1537. }
  1538.  
  1539. function showMapBlockers() {
  1540. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1541. logit("function " + fname + " called", "debug");
  1542. var styles = "";
  1543. if (getById('_cbShowMapBlockers').checked) {
  1544. styles += '.street-view-layer { background-color: rgba(255,0,0,0.3); }';
  1545. // styles += '.live-user-marker { background-color: rgba(255,0,0,0.3); }';
  1546. styles += '.overlay-buttons-container.top { background-color: rgba(255,0,0,0.3); }';
  1547. styles += '.overlay-buttons-container.bottom { background-color: rgba(255,0,0,0.3); }';
  1548. styles += '#street-view-drag-handle { background-color: rgba(255,0,0,0.3); }';
  1549. addStyle(prefix + fname,styles);
  1550. fixNodeClosureIcons();
  1551. } else {
  1552. removeStyle(prefix + fname);
  1553. }
  1554. }
  1555.  
  1556. function fixNodeClosureIcons() {
  1557. var closureNodesId = W.map.getLayerByUniqueName('closure_nodes').id;
  1558. var SVPinId = W.map.getLayersByName('streetViewPin')[0].id;
  1559. addGlobalStyle('div#' + closureNodesId + ' { z-index: 725 !important }');
  1560. insertNodeBeforeNode(getById(closureNodesId), getById(SVPinId));
  1561. }
  1562.  
  1563. function disableBridgeButton() {
  1564. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1565. logit("function " + fname + " called", "debug");
  1566. var styles = "";
  1567. if (getById('_cbDisableBridgeButton').checked) {
  1568. styles += '.add-bridge { pointer-events: none; opacity: 0.4; }';
  1569. addStyle(prefix + fname,styles);
  1570. } else {
  1571. removeStyle(prefix + fname);
  1572. }
  1573. }
  1574.  
  1575. function hideLinks() {
  1576. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1577. logit("function " + fname + " called", "debug");
  1578. var styles = "";
  1579. var compress = getById('_inpUICompression').value;
  1580. if (getById('_cbHideLinks').checked) {
  1581. //Nuke the links at the bottom of the side panel
  1582. styles += '.waze-links { display: none; }';
  1583. //extend side panel to the bottom
  1584. if (getById('_cbShrinkTopBars').checked) {
  1585. styles += '.edit-area { height: calc(100% ' + ['- 30px','- 9px','+ 2px'][compress] + '); }';
  1586. } else {
  1587. styles += '.edit-area { height: calc(100% - 30px); }';
  1588. }
  1589. addStyle(prefix + fname,styles);
  1590. } else {
  1591. removeStyle(prefix + fname);
  1592. }
  1593. }
  1594.  
  1595. function disableKinetic() {
  1596. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1597. logit("function " + fname + " called", "debug");
  1598. if (getById('_cbDisableKinetic').checked) {
  1599. W.map.controls.find(control => control.dragPan).dragPan.kinetic = null;
  1600. } else {
  1601. W.map.controls.find(control => control.dragPan).dragPan.kinetic = kineticDragParams;
  1602. }
  1603. }
  1604.  
  1605. function disableScrollZoom() {
  1606. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1607. logit("function " + fname + " called", "debug");
  1608. var controller = null;
  1609. if (W.map.navigationControl) {
  1610. controller = W.map.navigationControl;
  1611. } else if (W.map.controls.find(control => control.CLASS_NAME == 'OpenLayers.Control.Navigation')) {
  1612. controller = W.map.controls.find(control => control.CLASS_NAME == 'OpenLayers.Control.Navigation');
  1613. } else {
  1614. logit('Cannot find zoom wheel controls - please alert iainhouse','error');
  1615. }
  1616. if (controller !== null) {
  1617. if (getById('_cbDisableScrollZoom').checked) {
  1618. controller.disableZoomWheel();
  1619. } else {
  1620. controller.enableZoomWheel();
  1621. }
  1622. }
  1623. }
  1624.  
  1625. function PSclicked(event) {
  1626. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1627. logit("function " + fname + " called", "debug");
  1628. if (event.ctrlKey) alert('CTRL');
  1629. if (W.selectionManager.getSelectedFeatures().length > 0) {
  1630. if (getById("user-info").style.display == "none") {
  1631. getById("user-info").style.display = "block";
  1632. getById("edit-panel").style.display = "none";
  1633. } else {
  1634. getById("user-info").style.display = "none";
  1635. getById("edit-panel").style.display = "block";
  1636. }
  1637. }
  1638. }
  1639.  
  1640. function PSicon() {
  1641. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1642. logit("function " + fname + " called", "debug");
  1643. if (W.selectionManager.getSelectedFeatures().length > 0) {
  1644. getById("WMEFUPS").style.color = "red";
  1645. } else {
  1646. getById("WMEFUPS").style.color = "lightgrey";
  1647. }
  1648. }
  1649.  
  1650. function PCclicked() {
  1651. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1652. logit("function " + fname + " called", "debug");
  1653. if (location.search.match("segments")) reselectItems('segments',true);
  1654. else if (location.search.match("venues")) reselectItems('venues',true);
  1655. else if (location.search.match("nodes")) reselectItems('nodes',false);
  1656. else if (location.search.match("mapComments")) reselectItems('mapComments',false);
  1657. else if (location.search.match("cameras")) reselectItems('cameras',false);
  1658. }
  1659.  
  1660. function reselectItems ( typeDesc, isArray) {
  1661. var parameter, IDArray, objectArray, i, object;
  1662. parameter = location.search.match(new RegExp("[?&]" + typeDesc + "?=([^&]*)"));
  1663. if (parameter) {
  1664. IDArray=parameter[1].split(',');
  1665. objectArray=[];
  1666. for (i=0;i<IDArray.length;i++) {
  1667. object=W.model[typeDesc].objects[IDArray[i]];
  1668. if (typeof object!='undefined') objectArray.push(object);
  1669. }
  1670. if (isArray) {
  1671. W.selectionManager.setSelectedModels(objectArray);
  1672. } else {
  1673. W.selectionManager.setSelectedModels(objectArray[0]);
  1674. }
  1675. }
  1676. }
  1677.  
  1678. function createDSASection() {
  1679. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1680. logit("function " + fname + " called", "debug");
  1681. var settingsDiv = document.querySelector("#sidepanel-prefs > div > div > form");
  1682. if (!settingsDiv) {
  1683. logit("WME Settings div not there yet - looping...","warning");
  1684. setTimeout(createDSASection,500);
  1685. return;
  1686. }
  1687. if (localStorage.dontShowAgain) {
  1688. var dontShowAgain = JSON.parse(localStorage.dontShowAgain);
  1689. var DSGroup = document.createElement('div');
  1690. DSGroup.classList = "form-group";
  1691. var DSLabel = document.createElement('label');
  1692. DSLabel.classList = "control-label";
  1693. DSLabel.innerHTML = "Disabled WME warnings";
  1694. DSLabel.title = "This section will not update if you disable a warning\n";
  1695. DSLabel.title += "from a WME pop-up. Re-load the page if you need\n";
  1696. DSLabel.title += "to re-enable a warning you have just disabled.\n\n";
  1697. DSLabel.title += "SECTION ADDED BY WME Fix UI.";
  1698. DSGroup.appendChild(DSLabel);
  1699. DSGroup.appendChild(document.createElement('br'));
  1700. var DSCC = document.createElement('div');
  1701. DSCC.classList = "controls-container";
  1702. var DSInput;
  1703. for (var property in dontShowAgain) {
  1704. DSInput = document.createElement('input');
  1705. DSInput.type = "checkbox";
  1706. DSInput.id = "WMEFUDScb_" + property.toString();
  1707. DSInput.setAttribute("orig", property.toString());
  1708. DSInput.checked = dontShowAgain[property];
  1709. DSLabel = document.createElement('label');
  1710. DSLabel.setAttribute("for", DSInput.id);
  1711. DSLabel.innerText = property.toString();
  1712. DSCC.appendChild(DSInput);
  1713. DSCC.appendChild(DSLabel);
  1714. DSCC.appendChild(document.createElement('br'));
  1715. DSInput.onclick = DSIclicked;
  1716. }
  1717. DSGroup.appendChild(DSCC);
  1718. settingsDiv.appendChild(DSGroup);
  1719. }
  1720. }
  1721.  
  1722. function DSIclicked (e) {
  1723. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1724. logit("function " + fname + " called", "debug");
  1725. var DSA = JSON.parse(localStorage.dontShowAgain);
  1726. DSA[e.target.getAttribute("orig")] = e.target.checked;
  1727. localStorage.dontShowAgain = JSON.stringify(DSA);
  1728. }
  1729.  
  1730. function disableSaveBlocker() {
  1731. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1732. logit("function " + fname + " called", "debug");
  1733. var styles = "";
  1734. if (getById('_cbDisableSaveBlocker').checked) {
  1735. styles += '#popup-overlay { display: none !important; }';
  1736. addStyle(prefix + fname,styles);
  1737. } else {
  1738. removeStyle(prefix + fname);
  1739. }
  1740. }
  1741.  
  1742. function colourBlindTurns() {
  1743. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1744. logit("function " + fname + " called", "debug");
  1745. var styles = "";
  1746. if (getById('_cbColourBlindTurns').checked) {
  1747. styles += '.turn-arrow-state-open { filter: hue-rotate(90deg); }';
  1748. addStyle(prefix + fname,styles);
  1749. } else {
  1750. removeStyle(prefix + fname);
  1751. }
  1752. }
  1753.  
  1754. function hideMenuLabels() {
  1755. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1756. logit("function " + fname + " called", "debug");
  1757. var styles = "";
  1758. if (getById('_cbHideMenuLabels').checked) {
  1759. styles += '.toolbar .group-title { width: 0; overflow: hidden; }';
  1760. styles += '.toolbar .toolbar-button.toolbar-button-with-label.toolbar-button-with-icon .menu-title { width: 0; overflow: hidden; }';
  1761. addStyle(prefix + fname,styles);
  1762. } else {
  1763. removeStyle(prefix + fname);
  1764. }
  1765. }
  1766.  
  1767. function unfloatButtons() {
  1768. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1769. logit("function " + fname + " called", "debug");
  1770. layersButton = getByClass('layers-switcher-region')[0];
  1771. refreshButton = getByClass('reload-button-region')[0];
  1772. shareButton = getByClass('share-location-button-region')[0];
  1773. if (getById('_cbUnfloatButtons').checked) {
  1774. unfloat();
  1775. //restore mouseover opening for layers menu
  1776. layersButton.onmouseover = unfloat_showmenu;
  1777. // getByClass('waze-icon-save')[0].onmouseover = unfloat_hidemenu;
  1778. // getById('user-box-or-login-button-region').onmouseover = unfloat_hidemenu;
  1779. document.body.onmouseleave = unfloat_hidemenu;
  1780. //extra needed because layers no longer autohides
  1781. getById('layer-switcher-region').onmouseleave = unfloat_hidemenu;
  1782. //move layers menu div so it doesn't get moved by GSV
  1783. insertNodeBeforeNode(getById('layer-switcher-region'),getById('waze-map-container'));
  1784. var styles = '';
  1785. styles += '.layer-switcher .menu { z-index: 4; }';
  1786. styles += '.layer-switcher .menu > .title .w-icon-x { display: none }';
  1787. addStyle(prefix + fname,styles);
  1788. getById('WMEFUPIN').style.display = 'inherit';
  1789. //hacks for other scripts
  1790. if (getById('Info_div')) {
  1791. getByClass('bottom overlay-buttons-container')[0].appendChild(getById('Info_div'));
  1792. getById('Info_div').style.marginTop = '8px';
  1793. }
  1794. if (getById('BeenHere')) getById('BeenHere').style.top = '310px';
  1795. //temporary hack for new button arrangements Map Nav Historic
  1796. if (getById('prevIcon')) insertNodeBeforeNode(getById('prevIcon').parentNode,getById('nextIcon').parentNode);
  1797. if ( wmeFUinitialising) setTimeout(unfloat,5000);
  1798. } else {
  1799. if (!wmeFUinitialising) {
  1800. float();
  1801. layersButton.onmouseover = null;
  1802. // getByClass('waze-icon-save')[0].onmouseover = null;
  1803. // getById('user-box-region').onmouseover = null;
  1804. document.body.onmouseleave = null;
  1805. getById('layer-switcher-region').onmouseleave = null;
  1806. removeStyle(prefix + fname);
  1807. getById('WMEFUPIN').style.display = 'none';
  1808. getById('layer-switcher-pinned-input').checked = false;
  1809. unfloat_hidemenu();
  1810. pinLayers();
  1811. if (getById('Info_div')) {
  1812. getByClass('overlay-buttons-container top')[0].appendChild(getById('Info_div'));
  1813. getById('Info_div').style.marginTop = '';
  1814. }
  1815. if (getById('BeenHere')) getById('BeenHere').style.top = '280px';
  1816. }
  1817. }
  1818. }
  1819.  
  1820. function unfloat_showmenu () {
  1821. getByClass('menu',getById('layer-switcher-region'))[0].classList.remove('hide-layer-switcher');
  1822. }
  1823.  
  1824. function unfloat_hidemenu () {
  1825. //This fails in Beta - the pin no longer exists
  1826. if (getById('layer-switcher-pinned-input').checked == false) {
  1827. getByClass('menu',getById('layer-switcher-region'))[0].classList.add('hide-layer-switcher');
  1828. }
  1829. }
  1830.  
  1831. function unfloat () {
  1832. getByClass('waze-icon-save')[0].onmouseover = unfloat_hidemenu;
  1833. if (getById('user-toolbar') !== null) {
  1834. getById('user-toolbar').onmouseover = unfloat_hidemenu;
  1835. } else if (getById('user-box-region') !== null) {
  1836. getById('user-box-region').onmouseover = unfloat_hidemenu;
  1837. } else logit('Problem with User box ID','error');
  1838. insertNodeAfterNode(layersButton,getById('save-button'));
  1839. layersButton.classList.add('toolbar-button');
  1840. layersButton.firstChild.classList.add('item-container');
  1841. layersButton.firstChild.firstChild.classList.add('item-icon','w-icon','w-icon-layers');
  1842. layersButton.firstChild.firstChild.classList.remove('overlay-button');
  1843. layersButton.firstChild.firstChild.firstElementChild.classList.remove('w-icon','w-icon-layers');
  1844. insertNodeBeforeNode(refreshButton,getById('undo-button'));
  1845. refreshButton.classList.add('toolbar-button');
  1846. refreshButton.firstChild.classList.add('item-container');
  1847. refreshButton.firstChild.firstChild.classList.add('item-icon','w-icon','w-icon-refresh');
  1848. refreshButton.firstChild.firstChild.classList.remove('overlay-button');
  1849. refreshButton.firstChild.firstChild.firstElementChild.classList.remove('w-icon','w-icon-refresh');
  1850. var styles = '';
  1851. styles += '#edit-buttons .overlay-button-disabled { opacity: 0.5; cursor: not-allowed; }';
  1852. styles += '#tippy-1 { top: -170px !important; }';
  1853. styles += '.share-location-button-region { display: inline-block; }';
  1854. styles += 'div.WazeControlPermalink > div > div > div { width: 26px; height: 22px; padding: 1px; }';
  1855. styles += 'div.share-location-button-region > div > div > i { line-height: 18px; }';
  1856. styles += 'a.w-icon.w-icon-link { line-height:17px; font-size: 20px; }';
  1857. addStyle(prefix + 'unfloatButtons2',styles);
  1858. insertNodeAfterNode(shareButton,getByClass('livemap-link')[0]);
  1859. if (shareButton.firstChild.firstChild.innerHTML != '<i class="w-icon w-icon-link"></i>') {
  1860. if (wmeFUinitialising) logit("Share button link has changed. Please let iainhouse know!","error");
  1861. } else {
  1862. shareButton.firstChild.firstChild.innerHTML = '<a class="w-icon w-icon-link"></a>';
  1863. }
  1864. }
  1865.  
  1866. function float () {
  1867. getByClass('overlay-buttons-container top')[0].appendChild(layersButton);
  1868. layersButton.classList.remove('toolbar-button');
  1869. layersButton.firstChild.classList.remove('item-container');
  1870. layersButton.firstChild.firstChild.classList.remove('item-icon','w-icon','w-icon-layers');
  1871. layersButton.firstChild.firstChild.classList.add('overlay-button');
  1872. layersButton.firstChild.firstChild.firstElementChild.classList.add('w-icon','w-icon-layers');
  1873. getByClass('overlay-buttons-container top')[0].appendChild(refreshButton);
  1874. refreshButton.classList.remove('toolbar-button');
  1875. refreshButton.firstChild.classList.remove('item-container');
  1876. refreshButton.firstChild.firstChild.classList.remove('item-icon','w-icon','w-icon-refresh');
  1877. refreshButton.firstChild.firstChild.classList.add('overlay-button');
  1878. refreshButton.firstChild.firstChild.firstElementChild.classList.add('w-icon','w-icon-refresh');
  1879. getByClass('overlay-buttons-container top')[0].appendChild(shareButton);
  1880. shareButton.firstChild.firstChild.innerHTML = '<i class="w-icon w-icon-link"></i>';
  1881. removeStyle(prefix + 'unfloatButtons2');
  1882. }
  1883.  
  1884. function pinLayers () {
  1885. if (getById('layer-switcher-pinned-input').checked) {
  1886. getById('WMEFUPIN').style.opacity = '1';
  1887. } else {
  1888. getById('WMEFUPIN').style.opacity = '0.2';
  1889. }
  1890. }
  1891.  
  1892. function hackGSVHandle () {
  1893. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1894. logit("function " + fname + " called", "debug");
  1895. var styles = "";
  1896. if (getById('_cbHackGSVHandle').checked) {
  1897. styles += '#editor-container #map.street-view-mode #street-view-drag-handle { height: 29px; background: lightgrey; font-size: 24px; border-radius: 8px; text-align: center; padding-top: 2px; border: 1px black solid; }';
  1898. addStyle(prefix + fname,styles);
  1899. getById('street-view-drag-handle').classList.add('w-icon','w-icon-round-trip');
  1900. getById('street-view-drag-handle').title = 'Double-click to reset\ndefault width.';
  1901. } else {
  1902. removeStyle(prefix + fname);
  1903. getById('street-view-drag-handle').removeAttribute('class');
  1904. getById('street-view-drag-handle').removeAttribute('title');
  1905. }
  1906. }
  1907.  
  1908. function enlargeGeoNodes () {
  1909. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1910. logit("function " + fname + " called", "debug");
  1911. removeStyle(prefix + fname);
  1912. var styles = "";
  1913. if (getById('_inpEnlargeGeoNodes').value < 6) getById('_inpEnlargeGeoNodes').value = 6;
  1914. if (getById('_cbEnlargeGeoNodes').checked) {
  1915. styles += '#' + W.map.getLayersByName('sketch')[0].id + '_vroot [id^="OpenLayers_Geometry_Point_"][fill-opacity="1"] { r: ' + getById('_inpEnlargeGeoNodes').value + '; }';
  1916. styles += '#' + W.map.getLayerByUniqueName('venues').id + '_vroot [id^="OpenLayers_Geometry_Point_"][fill-opacity="1"] { r: ' + getById('_inpEnlargeGeoNodes').value + '; }';
  1917. addStyle(prefix + fname,styles);
  1918. }
  1919. }
  1920.  
  1921. function enlargeGeoHandles () {
  1922. var fname = arguments.callee.toString().match(/function ([^(]+)/)[1];
  1923. logit("function " + fname + " called", "debug");
  1924. removeStyle(prefix + fname);
  1925. var styles = "";
  1926. if (getById('_inpEnlargeGeoHandles').value < 4) getById('_inpEnlargeGeoHandles').value = 4;
  1927. if (getById('_cbEnlargeGeoHandlesFU').checked) {
  1928. styles += '#' + W.map.getLayersByName('sketch')[0].id + '_vroot [id^="OpenLayers_Geometry_Point_"][fill-opacity="0.6"] { r: ' + getById('_inpEnlargeGeoHandles').value + '; }';
  1929. styles += '#' + W.map.getLayerByUniqueName('venues').id + '_vroot [id^="OpenLayers_Geometry_Point_"][fill-opacity="0.6"] { r: ' + getById('_inpEnlargeGeoHandles').value + '; }';
  1930. addStyle(prefix + fname,styles);
  1931. }
  1932. }
  1933.  
  1934. function liveUserAdded(u) {
  1935. var usrRank = u.attributes.rank;
  1936. if (usrRank == null) {
  1937. window.setTimeout(function() {
  1938. liveUserAdded(u);
  1939. }, 500);
  1940. logit("User not loaded yet. Wait and try later...","info");
  1941. return;
  1942. } else {
  1943. usrRank++;
  1944. }
  1945. var nameMarker = document.createElement("div");
  1946. nameMarker.className = "tooltip fade top in";
  1947. nameMarker.style.top = "-19px";
  1948. nameMarker.style.backgroundColor = "black";
  1949. nameMarker.style.color = "white";
  1950. nameMarker.style.borderRadius = "5px";
  1951. nameMarker.style.padding = "0px";
  1952. nameMarker.style.zIndex = 3;
  1953. nameMarker.style.pointerEvents = "none";
  1954. nameMarker.innerHTML = u.attributes.name.replace(/-/gi, "&#x2011;") + "&nbsp;(" + usrRank + ')<div style="top: 17px;" class="tooltip-arrow"></div>';
  1955. var marker = W.map.getLayerByUniqueName("live_users").markers.find(function(e) {
  1956. return e.model.attributes.name == u.attributes.name;
  1957. });
  1958. if (typeof marker != "undefined") {
  1959. marker.icon.$div[0].appendChild(nameMarker);
  1960. marker.icon.$div[0].onmouseover = mouseOverLiveUser;
  1961. // var d = new Date;
  1962. // if (d.getDate() == 1 && d.getMonth() == 3) {
  1963. // marker.icon.$div.css("background-image", 'url("data:image/png;base64,' + specialEventIcon + '")');
  1964. // }
  1965. }
  1966. nameMarker.style.left = parseInt(u._events.moved[0].ctx.icon.$div[0].offsetWidth / 2 - nameMarker.offsetWidth / 2) + "px";
  1967. }
  1968.  
  1969. function mouseOverLiveUser() {
  1970. var n = this.nextElementSibling;
  1971. if (n.className == "tooltip fade top in") {
  1972. n.style.display = "none";
  1973. }
  1974. }
  1975.  
  1976. function addGlobalStyle(css) {
  1977. var head, style;
  1978. head = document.getElementsByTagName('head')[0];
  1979. if (!head) {
  1980. return;
  1981. }
  1982. style = document.createElement('style');
  1983. style.type = 'text/css';
  1984. style.innerHTML = css;
  1985. head.appendChild(style);
  1986. }
  1987.  
  1988. function addStyle(ID, css) {
  1989. var head, style;
  1990. head = document.getElementsByTagName('head')[0];
  1991. if (!head) {
  1992. return;
  1993. }
  1994. removeStyle(ID); // in case it is already there
  1995. style = document.createElement('style');
  1996. style.type = 'text/css';
  1997. style.innerHTML = css;
  1998. style.id = ID;
  1999. head.appendChild(style);
  2000. }
  2001.  
  2002. function removeStyle(ID) {
  2003. var style = document.getElementById(ID);
  2004. if (style) { style.parentNode.removeChild(style); }
  2005. }
  2006.  
  2007. function getByClass(classname, node) {
  2008. if(!node) { node = document.getElementsByTagName("body")[0]; }
  2009. return node.getElementsByClassName(classname);
  2010. // var a = [];
  2011. // var re = new RegExp('\\b' + classname + '\\b');
  2012. // var els = node.getElementsByTagName("*");
  2013. // for (var i=0,j=els.length; i<j; i++) {
  2014. // if (re.test(els[i].className)) { a.push(els[i]); }
  2015. // }
  2016. // return a;
  2017. }
  2018.  
  2019. function getById(node) {
  2020. return document.getElementById(node);
  2021. }
  2022.  
  2023. function insertNodeBeforeNode (insertNode, beforeNode) {
  2024. beforeNode.parentNode.insertBefore(insertNode,beforeNode);
  2025. }
  2026.  
  2027. function insertNodeAfterNode (insertNode, afterNode) {
  2028. insertNodeBeforeNode (insertNode, afterNode);
  2029. insertNodeBeforeNode (afterNode,insertNode);
  2030. }
  2031.  
  2032. function ChromeWarning () {
  2033. var m = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
  2034. var CV = ( m ? parseInt(m[2], 10) : false);
  2035. if (CV) {
  2036. if (CV <62) {
  2037. 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';
  2038. } else {
  2039. return '';
  2040. }
  2041. } else {
  2042. return '';
  2043. }
  2044. }
  2045.  
  2046. function logit(msg, typ) {
  2047. if (!typ) {
  2048. console.log(prefix + ": " + msg);
  2049. } else {
  2050. switch(typ) {
  2051. case "error":
  2052. console.error(prefix + ": " + msg);
  2053. break;
  2054. case "warning":
  2055. console.warn(prefix + ": " + msg);
  2056. break;
  2057. case "info":
  2058. console.info(prefix + ": " + msg);
  2059. break;
  2060. case "debug":
  2061. if (debug) {
  2062. console.warn(prefix + ": " + msg);
  2063. }
  2064. break;
  2065. default:
  2066. console.log(prefix + " unknown message type: " + msg);
  2067. break;
  2068. }
  2069. }
  2070. }
  2071.  
  2072. // eslint-disable-next-line no-unused-vars
  2073. function versionGreaterThan(major, minor) {
  2074. var v = W.version.substring(1).replace("-",".").split(".");
  2075. if (v[0] > major) return true;
  2076. if (v[1] > minor) return true;
  2077. return false;
  2078. }
  2079.  
  2080. // Start it running
  2081. setTimeout(init1, 200);
  2082. })();