WME Fix UI

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

目前為 2017-10-22 提交的版本,檢視 最新版本

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