WME Fix UI

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

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

  1. // ==UserScript==
  2. // @name WME Fix UI
  3. // @namespace https://greasyfork.org/en/users/46070
  4. // @description Allows alterations to the WME UI to fix things screwed up or ignored by Waze
  5. // @include https://www.waze.com/*editor/*
  6. // @include https://editor-beta.waze.com/*
  7. // @include https://beta.waze.com/*
  8. // @exclude https://www.waze.com/*user/editor/*
  9. // @supportURL https://www.waze.com/forum/viewtopic.php?f=819&t=191178
  10. // @version 1.9
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. // Thanks to (in no particular order)
  15. // Bellhouse, Twister-UK, Timbones, Dave2084, Rickzabel, Glodenox,
  16. // JJohnston84, SAR85, Cardyin
  17.  
  18. (function()
  19. {
  20. // global variables
  21. var wmefu_version = "1.9";
  22. var oldVersion;
  23. var prefix = "WMEFU";
  24. var tabAttempts = 0;
  25. var wmeFUAddon;
  26. var debug = false;
  27. var wmeFUinitialising = true;
  28. var URLSegments;
  29. var URLSegmentCount;
  30. //Fix for date/time formats in WME released Oct/Nov 2016 - provided by Glodenox
  31. I18n.translations[I18n.currentLocale()].time = {};
  32. I18n.translations[I18n.currentLocale()].time.formats = {};
  33. I18n.translations[I18n.currentLocale()].time.formats.long = "%a %b %d %Y, %H:%M";
  34. I18n.translations[I18n.currentLocale()].date.formats = {};
  35. I18n.translations[I18n.currentLocale()].date.formats.long = "%a %b %d %Y, %H:%M";
  36. I18n.translations[I18n.currentLocale()].date.formats.default = "%a %b %d %Y";
  37. if (I18n.currentLocale() == 'en-GB') {
  38. I18n.translations['en-GB'].update_requests.panel.reported = 'Reported on: %{date}';
  39. }
  40. // Set the "Chat is here!" message to be hidden
  41. if (localStorage.hiddenMessages) {
  42. var hm = JSON.parse(localStorage.hiddenMessages);
  43. if (hm.chat_intro_tip === false) {
  44. logit("Hiding Chat is Here! message","info");
  45. hm.chat_intro_tip = true;
  46. localStorage.setItem('hiddenMessages', JSON.stringify(hm));
  47. }
  48. }
  49.  
  50. function init1() {
  51. console.group(prefix + ": initialising...");
  52. console.time(prefix + ": initialisation time");
  53. logit("Starting init1","debug");
  54. // go round again if map container isn't there yet
  55. if(!window.Waze.map) {
  56. logit("waiting for WME...","warning");
  57. setTimeout(init1, 200);
  58. return;
  59. }
  60. // create tab content and store it
  61. wmeFUAddon = createAddon();
  62. // insert the content as a tab
  63. addMyTab(null,0);
  64. //pass control to init2
  65. init2();
  66. }
  67.  
  68. function init2() {
  69. logit("Starting init2","debug");
  70. //go round again if my tab isn't there yet
  71. if (!getId('sidepanel-FixUI')) {
  72. logit("Waiting for my tab to appear...","warning");
  73. setTimeout(init2, 200);
  74. return;
  75. }
  76. // setup event handlers for user actions:
  77. getId('_cbMoveZoomBar').onclick = moveZoomBar;
  78. getId('_cbShrinkTopBars').onclick = shrinkTopBars;
  79. getId('_cbHideUserInfo').onclick = hideUserInfo;
  80. getId('_cbCompressSegmentTab').onclick = compressSegmentTab;
  81. getId('_cbRestyleReports').onclick = restyleReports;
  82. getId('_cbDisableMapBlocker').onclick = disableMapBlocker;
  83. getId('_cbNarrowSidePanel').onclick = narrowSidePanel;
  84. getId('_cbHideAveSpeedControls').onclick = hideAveSpeedControls;
  85. getId('_cbAddZoomIndicator').onclick = addZoomIndicator;
  86. getId('_cbFixExternalProviders').onclick = fixExternalProviders;
  87. getId('_cbClickablePlaceAddress').onclick = hideAveSpeedControls;
  88. getId('_cbCompressLayersMenu').onclick = compressLayersMenu;
  89. getId("_inpASX").onchange = shiftAerials;
  90. getId("_inpASX").onwheel = shiftAerials;
  91. getId("_inpASY").onchange = shiftAerials;
  92. getId("_inpASY").onwheel = shiftAerials;
  93. getId("_inpASO").onchange = shiftAerials;
  94. getId("_inpASO").onwheel = shiftAerials;
  95. getId("_resetAS").onclick = function() {
  96. _inpASX.value = 0;
  97. _inpASY.value = 0;
  98. shiftAerials();
  99. };
  100. // events for GSV adjustment
  101. getId("_inpGSVContrast").onchange = adjustGSV;
  102. getId("_inpGSVBrightness").onchange = adjustGSV;
  103. getId("_cbGSVInvert").onchange = adjustGSV;
  104.  
  105. //REGISTER WAZE EVENT HOOKS
  106. // event to recreate my tab when MTE mode is exited
  107. Waze.app.modeController.model.bind('change:mode', addMyTab);
  108. // events for Aerial Shifter
  109. Waze.map.events.register("zoomend", null, shiftAerials);
  110. Waze.map.events.register("moveend", null, shiftAerials);
  111. Waze.map.baseLayer.events.register("loadend", null, shiftAerials);
  112. // event to deal with ASC controls and make place address clickable
  113. Waze.selectionManager.events.register("selectionchanged", null, hideAveSpeedControls);
  114. // event to change menu bar color based on map comments checkbox
  115. Waze.map.events.register("zoomend", null, warnCommentsOff);
  116. Waze.map.events.register("moveend", null, warnCommentsOff);
  117.  
  118. // restore saved settings
  119. if (localStorage.WMEFixUI) {
  120. logit("loading options from local storage");
  121. options = JSON.parse(localStorage.WMEFixUI);
  122. oldVersion = options[0];
  123. getId('_cbMoveZoomBar').checked = options[1];
  124. getId('_cbShrinkTopBars').checked = options[2];
  125. getId('_cbHideUserInfo').checked = options[3];
  126. getId('_cbCompressSegmentTab').checked = options[4];
  127. getId('_cbRestyleReports').checked = options[5];
  128. getId('_cbDisableMapBlocker').checked = options[6];
  129. getId('_cbNarrowSidePanel').checked = options[7];
  130. getId('_cbHideAveSpeedControls').checked = options[8];
  131. getId('_cbAddZoomIndicator').checked = options[9];
  132. if (typeof(options[10]) === "undefined") {
  133. //define sensible values for AS if none are stored
  134. logit("setting new AS values","debug");
  135. options[10] = 0;
  136. options[11] = 0;
  137. options[12] = 100;
  138. }
  139. getId('_inpASX').value = options[10];
  140. getId('_inpASY').value = options[11];
  141. getId('_inpASO').value = options[12];
  142. getId('_cbFixExternalProviders').checked = options[13];
  143. if (typeof(options[14]) === "undefined") {
  144. //define sensible values for GSV if none are stored
  145. logit("setting new GSV values","debug");
  146. options[14] = 100;
  147. options[15] = 100;
  148. options[16] = false;
  149. }
  150. getId('_inpGSVContrast').value = options[14];
  151. getId('_inpGSVBrightness').value = options[15];
  152. getId('_cbGSVInvert').checked = options[16];
  153. getId('_cbClickablePlaceAddress').checked = options[17];
  154. getId('_cbPermalinkChecker').checked = options[18];
  155. getId('_cbCompressLayersMenu').checked = options[19];
  156. } else {
  157. // default values for first installation
  158. logit("no options in local storage - setting defaults");
  159. oldVersion = wmefu_version;
  160. getId('_cbMoveZoomBar').checked = true;
  161. getId('_cbShrinkTopBars').checked = true;
  162. getId('_cbHideUserInfo').checked = true;
  163. getId('_cbCompressSegmentTab').checked = true;
  164. getId('_cbRestyleReports').checked = true;
  165. getId('_cbDisableMapBlocker').checked = false;
  166. getId('_cbNarrowSidePanel').checked = false;
  167. getId('_cbHideAveSpeedControls').checked = false;
  168. getId('_cbAddZoomIndicator').checked = true;
  169. getId('_inpASX').value = 0;
  170. getId('_inpASY').value = 0;
  171. getId('_inpASO').value = 100;
  172. getId('_cbFixExternalProviders').checked = true;
  173. getId('_inpGSVContrast').value = 100;
  174. getId('_inpGSVBrightness').value = 100;
  175. getId('_cbGSVInvert').checked = false;
  176. getId('_cbClickablePlaceAddress').checked = true;
  177. getId('_cbPermalinkChecker').checked = true;
  178. getId('_cbCompressLayersMenu').checked = true;
  179. }
  180. // Adds an extra checkbox so I can test segment panel changes easily
  181. if (Waze.loginManager.user.userName == 'iainhouse') {
  182. logit("creating segment detail debug checkbox","info");
  183. var brand = getId('brand');
  184. extraCBSection = document.createElement('p');
  185. extraCBSection.innerHTML = '<input type="checkbox" id="_cbextraCBSection" />';
  186. brand.appendChild(extraCBSection);
  187. getId('_cbextraCBSection').onclick = FALSEcompressSegmentTab;
  188. _cbextraCBSection.checked = _cbCompressSegmentTab.checked;
  189. }
  190. // overload the WME exit function to save my settings
  191. saveOptions = function() {
  192. if (localStorage) {
  193. logit("saving options to local storage");
  194. var options = [];
  195. // preserve previous options which may get lost after logout
  196. if (localStorage.WMEFixUI) { options = JSON.parse(localStorage.WMEFixUI); }
  197. options[0] = wmefu_version;
  198. options[1] = getId('_cbMoveZoomBar').checked;
  199. options[2] = getId('_cbShrinkTopBars').checked;
  200. options[3] = getId('_cbHideUserInfo').checked;
  201. options[4] = getId('_cbCompressSegmentTab').checked;
  202. options[5] = getId('_cbRestyleReports').checked;
  203. options[6] = getId('_cbDisableMapBlocker').checked;
  204. options[7] = getId('_cbNarrowSidePanel').checked;
  205. options[8] = getId('_cbHideAveSpeedControls').checked;
  206. options[9] = getId('_cbAddZoomIndicator').checked;
  207. options[10] = getId('_inpASX').value;
  208. options[11] = getId('_inpASY').value;
  209. options[12] = getId('_inpASO').value;
  210. options[13] = getId('_cbFixExternalProviders').checked;
  211. options[14] = getId('_inpGSVContrast').value;
  212. options[15] = getId('_inpGSVBrightness').value;
  213. options[16] = getId('_cbGSVInvert').checked;
  214. options[17] = getId('_cbClickablePlaceAddress').checked;
  215. options[18] = getId('_cbPermalinkChecker').checked;
  216. options[19] = getId('_cbCompressLayersMenu').checked;
  217. localStorage.WMEFixUI = JSON.stringify(options);
  218. }
  219. };
  220. window.addEventListener("beforeunload", saveOptions, false);
  221. // warn of permalink segments not all selected
  222. URLSegments = window.location.search.match(new RegExp("[?&]segments?=([^&]*)"));
  223. if (URLSegments) {
  224. URLSegmentCount = URLSegments[1].split(',').length;
  225. if (Waze.selectionManager.selectedItems.length > 0) {
  226. permalinkCheck();
  227. } else {
  228. Waze.selectionManager.events.register("selectionchanged", null, permalinkCheck);
  229. }
  230. }
  231.  
  232. // Alert to new version
  233. if (oldVersion != wmefu_version) {
  234. alert("WME Fix UI has been updated to version " + wmefu_version +
  235. "\n" +
  236. "\nVersion 1.9 - 2017-03-12" +
  237. "\n" +
  238. "\n* Check permalink on opening for correct segments selected" +
  239. "\n" +
  240. "\n* Compress Layers menu" +
  241. "\n" +
  242. "\n* Fix for WME GIS script when black bar is hidden" +
  243. "\n" +
  244. "\n* Additional compression for segment tab (including beta)" +
  245. "\n" +
  246. "\n* Additional tweaks for Map Comments tab (including beta)" +
  247. "\n");
  248. saveOptions();
  249. }
  250.  
  251. // apply the settings
  252. shiftAerials();
  253. setTimeout(applyAllSettings, 2000);
  254. logit("Initialisation complete");
  255. console.timeEnd(prefix + ": initialisation time");
  256. console.groupEnd();
  257. }
  258.  
  259. function createAddon() {
  260. //create the contents of my side-panel tab
  261. var addon = document.createElement('section');
  262. var section = document.createElement('p');
  263. addon.id = "sidepanel-FixUI";
  264. section.style.paddingTop = "0px";
  265. section.style.lineHeight = "16px";
  266. section.id = "fuContent";
  267. section.innerHTML = '<b>UI Fixes</b><br>';
  268. section.innerHTML += '<input type="checkbox" id="_cbMoveZoomBar" /> ' +
  269. '<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>';
  270. section.innerHTML += '<input type="checkbox" id="_cbAddZoomIndicator" /> ' +
  271. '<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>';
  272. section.innerHTML += '<input type="checkbox" id="_cbHideUserInfo" /> ' +
  273. '<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>';
  274. section.innerHTML += '<input type="checkbox" id="_cbShrinkTopBars" /> ' +
  275. '<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>';
  276. section.innerHTML += '<input type="checkbox" id="_cbCompressSegmentTab" /> ' +
  277. '<span title="Because I\'m sick of having to scroll the side panel because of oversized fonts and wasted space">Compress the contents of the side panel</span><br>';
  278. section.innerHTML += '<input type="checkbox" id="_cbCompressLayersMenu" /> ' +
  279. '<span title="Because it\'s already too big for small screens and Waze only plan to make it bigger">Compress the layers menu</span><br>';
  280. section.innerHTML += '<input type="checkbox" id="_cbRestyleReports" /> ' +
  281. '<span title="Another UI element configured for developers with massive screens instead of normal users">Change formatting for report panels (UR/MP)</span><br>';
  282. section.innerHTML += '<input type="checkbox" id="_cbDisableMapBlocker" /> ' +
  283. '<span title="As if the crappy interface wasn\'t making life hard enough,\nnow they force us to wait for an arbitrary time after every save!">Disable map blocking during/after saving.</span><span title="Use at your own risk. We don\'t know why it\'s there. Maybe there\'s a good reason but Waze can\'t be arsed to tell us what it is." style="font-size: 16px; color: red;">&#9888</span><br>';
  284. section.innerHTML += '<input type="checkbox" id="_cbNarrowSidePanel" /> ' +
  285. '<span title="If you have a netbook, Waze isn\'t interested in your experience.\nYou need every bit of map space you can get - so have a present from me!">Reduce width of the side panel</span><span title="This will definitely interfere with scripts that rely on a fixed width for their tab contents." style="font-size: 16px; color: red;">&#9888</span><br>';
  286. section.innerHTML += '<input type="checkbox" id="_cbHideAveSpeedControls" /> ' +
  287. '<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>';
  288. section.innerHTML += '<input type="checkbox" id="_cbFixExternalProviders" /> ' +
  289. '<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>';
  290. section.innerHTML += '<input type="checkbox" id="_cbClickablePlaceAddress" /> ' +
  291. '<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>';
  292. section.innerHTML += '<input type="checkbox" id="_cbPermalinkChecker" /> ' +
  293. '<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>';
  294. section.innerHTML += '<br>';
  295. section.innerHTML += '<b title="Shift aerial images layer to match GPS tracks and reduce image opacity">Aerial Shifter</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  296. section.innerHTML += '<span class="fa fa-power-off" id="_resetAS" title="Clear X/Y offsets"></span><br>';
  297. 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>';
  298. 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>';
  299. 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>';
  300. section.innerHTML += '<br>';
  301. section.innerHTML += '<br>';
  302.  
  303. section.innerHTML += '<b title="Adjust contrast & brightness for Google Street View images">GSV image adjust</b><br>';
  304. 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;';
  305. 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;';
  306. section.innerHTML += '<span title="Invert colours"><input type="checkbox" id="_cbGSVInvert"/><span class="fa fa-tint"></span></span>';
  307.  
  308. section.innerHTML += '<br>';
  309. section.innerHTML += '<br>';
  310. section.innerHTML += '<b><a href="https://www.waze.com/forum/viewtopic.php?f=819&t=191178" title="Forum topic" target="_blank"><u>' +
  311. 'WME Fix UI</u></a></b> &nbsp; v' + wmefu_version;
  312. addon.appendChild(section);
  313. addon.className = "tab-pane";
  314. return addon;
  315. }
  316.  
  317. function addMyTab(model,modeID) {
  318. if (modeID === 0) {
  319. logit("entering default mode, so creating tab");
  320. tabAttempts = 0;
  321. tabsLooper();
  322. } else {
  323. logit("entering event mode, so not initialising");
  324. return;
  325. }
  326. }
  327.  
  328. function tabsLooper() {
  329. tabAttempts += 1;
  330. if (tabAttempts > 20) {
  331. // tried 20 times to create tab without luck
  332. logit("unable to create my tab after 20 attempts","error");
  333. return;
  334. }
  335. var userTabs = getId('user-info');
  336. var navTabs = getElementsByClassName('nav-tabs', userTabs)[0];
  337. if (typeof navTabs === "undefined") {
  338. //the basic tabs aren't there yet, so I can't add mine
  339. logit("waiting for NavTabs","warning");
  340. setTimeout(tabsLooper, 200);
  341. } else{
  342. var tabContent = getElementsByClassName('tab-content', userTabs)[0];
  343. newtab = document.createElement('li');
  344. newtab.innerHTML = '<a href="#sidepanel-FixUI" data-toggle="tab" title="Fix UI">FU</a>';
  345. navTabs.appendChild(newtab);
  346. tabContent.appendChild(wmeFUAddon);
  347. }
  348. }
  349.  
  350. function applyAllSettings() {
  351. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  352. logit("function " + fname + " called", "debug");
  353. console.group(prefix + ": applying all settings");
  354. moveZoomBar();
  355. shrinkTopBars();
  356. hideUserInfo();
  357. compressSegmentTab();
  358. restyleReports();
  359. disableMapBlocker();
  360. narrowSidePanel();
  361. hideAveSpeedControls();
  362. fixExternalProviders();
  363. addZoomIndicator();
  364. warnCommentsOff();
  365. adjustGSV();
  366. compressLayersMenu();
  367. console.groupEnd();
  368. wmeFUinitialising = false;
  369. }
  370.  
  371. function moveZoomBar() {
  372. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  373. logit("function " + fname + " called", "debug");
  374. var reportPanel = getId('panel-container');
  375.  
  376. reportPanel.style.position = "absolute";
  377. if (_cbMoveZoomBar.checked) {
  378. addGlobalStyle('.olControlPanZoomBar { left: 10px; width: 30px; right: inherit; }');
  379. if (document.body.dir != "rtl") {
  380. addGlobalStyle('.panel { left: 40px; }');
  381. } else {
  382. addGlobalStyle('.panel { right: inherit; }');
  383. }
  384. } else {
  385. addGlobalStyle('.olControlPanZoomBar { left: inherit; width: 30px; right: 10px; }');
  386. if (document.body.dir != "rtl") {
  387. addGlobalStyle('.panel { left: inherit; }');
  388. } else {
  389. addGlobalStyle('.panel { right: 40px; }');
  390. }
  391. }
  392. }
  393.  
  394. function hideUserInfo() {
  395. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  396. logit("function " + fname + " called", "debug");
  397. var styles = "";
  398. // WME Panel Swap buttons - move them up if user info is hidden
  399. var PSButton1 = getId('WMEPS_UIButton');
  400. var PSButton2 = getId('WMEPS_EditButton');
  401. if (_cbHideUserInfo.checked) {
  402. styles += '#sidebar #user-info #user-box { padding: 0px; }';
  403. styles += '#sidebar #user-details .user-profile { display: none !important; }';
  404. if (PSButton1) { PSButton1.style.top = '-27px'; }
  405. if (PSButton2) { PSButton2.style.top = '-27px'; }
  406. // Keep My Layers toggle - move up if user info is hidden
  407. styles += '.kml-toggle-container { top: -25px !important; }';
  408. addStyle(prefix + fname,styles);
  409. } else {
  410. if (PSButton1) { PSButton1.style.top = '0px'; }
  411. if (PSButton2) { PSButton2.style.top = '0px'; }
  412. removeStyle(prefix + fname);
  413. }
  414. }
  415.  
  416. function shrinkTopBars() {
  417. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  418. logit("function " + fname + " called", "debug");
  419. var styles = "";
  420. if (_cbShrinkTopBars.checked) {
  421. //shrink the blue tool bar
  422. styles += '.toolbar { height: 31px; }';
  423. styles += '#app-head { height: 31px; }';
  424. styles += '#search { padding-top: 1px; }';
  425. styles += '.toolbar .toolbar-button { padding: 2px 7px; }';
  426. styles += '.toolbar .toolbar-separator { height: 31px; }';
  427. styles += '#layer-switcher { height: 51px; }';
  428. styles += '.toolbar menu.dropdown-menu { top: 31px; }';
  429. styles += '#layer-switcher .dropdown-menu { top: 31px; }';
  430. styles += '.layer-switcher .content { top: 31px; }';
  431. //extra tweaks for Toolbox button & layers menu
  432. styles += '.WazeControlLayerSwitcherIcon { margin: 5px 2px 0 !important; }';
  433. styles += '#WazeControlLayerSwitcherIconContainer { height: 51px !important; }';
  434. styles += '#WazeControlLayerSwitcherIconContainerBeta { height: 51px !important; }';
  435. if (document.body.dir != "rtl") {
  436. styles += '.WazeControlLayerSwitcherToolbox { margin-left: -92px !important; }';
  437. } else {
  438. styles += '.WazeControlLayerSwitcherToolbox { margin-left: 112px !important; }';
  439. }
  440. styles += '#sidebar waze-links { height: 16px; }';
  441. //shrink the black bar
  442. styles += 'div#topbar-container { position: relative; }';
  443. 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; }';
  444. styles += '.topbar .location-info { font-size: 15px; font-weight: 900; }';
  445. styles += '.topbar .area-managers .title, .topbar .area-managers .main-list { font-size: 15px; font-weight: 900; }';
  446. styles += '.olControlPanZoomBar { top: 32px; }';
  447. styles += '#panel-container .panel { top: 20px; }';
  448. // following line needed to move MTE menu over the WME Bookmarks pin control
  449. styles += '#mode-switcher .dropdown-menu { top: 30px; }';
  450. //fix for buttons of WME GIS script
  451. styles += '.btn-group-sm { text-shadow: initial; background: white; }';
  452. addStyle(prefix + fname,styles);
  453. } else {
  454. removeStyle(prefix + fname);
  455. }
  456. window.dispatchEvent(new Event('resize'));
  457. }
  458.  
  459. function FALSEcompressSegmentTab() {
  460. _cbCompressSegmentTab.checked = _cbextraCBSection.checked;
  461. compressSegmentTab();
  462. }
  463.  
  464. function compressSegmentTab() {
  465. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  466. logit("function " + fname + " called", "debug");
  467. var styles = "";
  468. if (_cbCompressSegmentTab.checked) {
  469. // shrink address
  470. styles += '#edit-panel .primary-street { font-size: 14px; line-height: 15px; font-weight: 600; color: black; }';
  471. styles += '#edit-panel .address-edit-view .preview .address-edit-btn:not(.disabled) { background-color: #FFF9C4; }';
  472. styles += '#edit-panel .segment .address-edit-view, .edit-panel .segment .address-edit-view { margin-bottom: 5px; }';
  473. //shrink tabs
  474. styles += '#sidebar .nav-tabs>li {margin-top: 2px; }';
  475. styles += '#sidebar .nav-tabs li a { padding: 2px; }';
  476. styles += '#sidebar .nav-tabs { margin: 0 0 5px 0; padding-left: 4px; }';
  477. //reduce some vertical margins
  478. styles += '#edit-panel .contents { padding: 0 5px 0 5px; overflow: hidden; }';
  479. styles += '#edit-panel .form-group { margin-bottom: 2px; line-height: 1; font-size: 11px; }';
  480. styles += '#edit-panel .selection { margin-bottom: 5px; }';
  481. styles += '#sidebar .side-panel-section:not(:last-child) { margin-bottom: 2px; }';
  482. styles += '#sidebar .side-panel-section:not(:last-child)::after { margin-top: 5px; margin-bottom: 2px; }';
  483. styles += '#edit-panel .control-label { margin-bottom: 1px; }';
  484. styles += '#sidebar .controls-container { padding-top: 2px; }';
  485. styles += '#edit-panel .segment .speed-limit label { margin-bottom: 0px; }';
  486. styles += '#edit-panel .more-actions { padding-top: 2px; }';
  487. styles += '#edit-panel .segment .speed-limit .direction-label, #edit-panel .segment .speed-limit .unit-label { line-height: 2.1em; }';
  488. styles += '#sidebar .side-panel-section~.side-panel-section:not(:last-child):before { margin: 5px -20px !important; }';
  489. styles += '#sidebar .side-panel-section~.side-panel-section:not(:last-child) { margin-top: 5px !important; }';
  490. //shrink dropdown controls & buttons
  491. styles += '#edit-panel button, #edit-panel select, #edit-panel .form-control { font-size: 11px; height: auto; padding: 0px 4px; }';
  492. styles += '#edit-panel .more-actions button:not(:last-of-type) { margin-bottom: 2px; }';
  493. styles += '.edit-closure .input-group-addon { padding: 2px 8px; }';
  494. //fit road property checkboxes on one line for all three (if text length allows)
  495. styles += '#edit-panel .controls-container { display: inline-block; }';
  496. styles += '#edit-panel .controls-container label { font-size: 12px; line-height: 18px; padding-left: 22px; }';
  497. styles += '#edit-panel .select-entire-street { width: 49%; overflow: hidden; }';
  498. styles += '#edit-panel .edit-house-numbers { width: 49%; overflow: hidden; }';
  499. styles += '#edit-panel .action-button { color: black; }';
  500. styles += '#edit-panel .categories .select2-container { margin-bottom: -5px; }';
  501. //tweak for speed camera checkbox having a left margin of -20px. Why?!
  502. styles += '#edit-panel .checkbox, .radio { margin-left: 20px; }';
  503. //tweaks for Closures tab
  504. styles += '#edit-panel .segment .segment-details { margin-bottom: 4px; }';
  505. styles += '.closures-list .closure-item .section { padding: 2px; }';
  506. styles += '.col-xs-6 { line-height: 14px; }';
  507. styles += '.closures-list .direction { margin-bottom: 0px; }';
  508. styles += '.closures-list .closure-item:not(:last-child) { margin-bottom: 4px; }';
  509. //tweak required for Speedhelper script
  510. styles += 'div[id^="spd_"] { line-height: 1.43; }';
  511. //tweaks for Feed tab
  512. styles += '.feed-item { margin-bottom: 2px; }';
  513. styles += '.feed-item .inner { padding: 2px; }';
  514. styles += '.feed-item .delete { zoom: 149%; }';
  515. styles += '.feed-item .motivation { margin-bottom: 0px; }';
  516. styles += '.feed-item .content .title { margin-bottom: 0px; }';
  517. styles += '.feed-item .content .subtext { font-size: 11px; }';
  518. //tweaks for Drives tab
  519. styles += '#sidebar .message { margin-bottom: 0px; line-height: 14px; }';
  520. styles += '#sidebar .result-list .result { padding: 2px 5px; }';
  521. //tweaks for Restrictions dialogue
  522. styles += '#schedule-modal .modal-body { padding: 2px 8px; }';
  523. styles += '#schedule-modal .items { line-height: 0.5; }';
  524. styles += '#schedule-modal .table { margin-bottom: 10px; }';
  525. styles += '#schedule-modal .no-restrictions { margin-bottom: 10px; }';
  526. styles += '#schedule-modal .well { padding: 5px; }';
  527. styles += '#schedule-modal .edit-restriction .section { margin-bottom: 2px; padding: 0 2px; }';
  528. styles += '#schedule-modal .nav>li>a { padding: 2px 15px; }';
  529. styles += '#schedule-modal .btn { height: 22px; padding: 2px 15px; }';
  530. //tweaks for Map Comments
  531. styles += '.map-comment-feature-editor .conversation-region, .map-comment-feature-editor .name-editor-region { margin-left: -17px; margin-right: -5px; }';
  532. if (_cbNarrowSidePanel.checked) {
  533. styles += '.map-comment-feature-editor .conversation-view .new-comment-text { resize: both; max-width: 230px; }';
  534. } else {
  535. styles += '.map-comment-feature-editor .conversation-view .new-comment-text { resize: both; max-width: 310px; }';
  536. }
  537. //tweaks for History
  538. styles += '.toggleHistory { padding: 2px 12px 7px 12px; }';
  539. styles += '.tx-header { padding: 2px 15px 2px 15px !important; }';
  540. styles += '.tx-author-date { margin-bottom: 2px !important; }';
  541. styles += '.element-history-item { font-size: 11px; }';
  542. styles += '.tx-content { padding: 2px 15px 2px 15px !important; }';
  543. styles += '.tx-changed-ro:not(:last-child) { margin-bottom: 2px; }';
  544. styles += '.tx-changed-attribute .ca-name { margin-bottom: 2px; }';
  545. styles += '.tx-changed-attribute:not(:last-child) {margin-bottom: 2px; }';
  546. addStyle(prefix + fname,styles);
  547. } else {
  548. removeStyle(prefix + fname);
  549. }
  550. }
  551.  
  552. function compressLayersMenu() {
  553. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  554. logit("function " + fname + " called", "debug");
  555. var styles = "";
  556. if (_cbCompressLayersMenu.checked) {
  557. // tweaks for layers menu
  558. if (document.getElementById('layer-switcher-list') === null) {
  559. //new style layers menu
  560. styles += '.layer-switcher { line-height: 11px; }';
  561. styles += '#layer-switcher .dropdown-menu .draggable .toggler .handle { height: 18px; }';
  562. styles += '.layer-switcher .togglers .group:not(:last-child):after { margin: 5px -7px -2px; }';
  563. styles += '.layer-switcher .more-options-toggle { height: 20px; line-height: 20px; }';
  564. } else {
  565. //old style layers menu
  566. styles += '.layer-switcher { line-height: 14px; }';
  567. }
  568. // styles += '.layer-switcher .toggler { padding-top: 0px; padding-bottom: 0px; }';
  569. addStyle(prefix + fname,styles);
  570. } else {
  571. removeStyle(prefix + fname);
  572. }
  573. }
  574.  
  575. function restyleReports() {
  576. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  577. logit("function " + fname + " called", "debug");
  578. var styles = "";
  579. if (_cbRestyleReports.checked) {
  580. styles += '#panel-container .panel { font-size: 12px; line-height: 15px; }';
  581. styles += '#panel-container .problem-edit .header { padding: 5px; line-height: 15px; }';
  582. styles += '#panel-container .problem-edit .problem-data .title { line-height: 22px; }';
  583. styles += '#panel-container .problem-edit .section .title { padding: 0 5px; }';
  584. styles += '#panel-container .problem-edit .section .content { padding: 5px; }';
  585. styles += '#WMEFP-UR-ALLPM { top: -2px !important; }';
  586. styles += '#panel-container .problem-edit .conversation.section .comment .comment-content { padding: 0 5px; }';
  587. styles += '#panel-container .problem-edit .conversation.section .no-comments { padding: 0; }';
  588. styles += '#panel-container .problem-edit .conversation.section .new-comment-form { padding: 0; }';
  589. styles += '#panel-container .problem-edit .conversation.section .new-comment-form textarea { resize: vertical; height: 110px; margin-bottom: 0px; padding: 3px 5px; font-size: 12px; }';
  590. styles += '#panel-container .btn { height: 20px; padding: 0px 10px;}';
  591. styles += '#panel-container .problem-edit .actions .content { padding: 2px 5px;}';
  592. styles += '#panel-container .problem-edit .actions .controls-container label { margin-bottom: 0px; line-height: 22px }';
  593. styles += '#panel-container .problem-edit .actions .navigation { margin-top: 5px;}';
  594. styles += '#panel-container .problem-edit .actions .controls-container { display: inline-flex; flex-wrap: wrap; margin-left: -3px; }';
  595. styles += '#panel-container .input-max-length { text-align: right; margin-top: 0; white-space: nowrap; color: #3d3d3d; font-weight: 700; font-size: 11px; }';
  596. addStyle(prefix + fname,styles);
  597. if (wmeFUinitialising) {
  598. setTimeout(draggablePanel, 5000);
  599. } else {
  600. draggablePanel();
  601. }
  602. } else {
  603. removeStyle(prefix + fname);
  604. if (jQuery.ui) {
  605. $("#panel-container").draggable("destroy");
  606. getId("panel-container").style = "";
  607. }
  608. }
  609. window.dispatchEvent(new Event('resize'));
  610. }
  611.  
  612. function draggablePanel() {
  613. if (jQuery.ui) {
  614. $("#panel-container").draggable({ handle: ".header" });
  615. }
  616. }
  617.  
  618. function disableMapBlocker() {
  619. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  620. logit("function " + fname + " called", "debug");
  621. if (_cbDisableMapBlocker.checked) {
  622. addStyle(prefix + fname,'#popup-overlay { width: 0%; height: 0%; }');
  623. } else {
  624. removeStyle(prefix + fname);
  625. }
  626. }
  627.  
  628. function narrowSidePanel() {
  629. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  630. logit("function " + fname + " called", "debug");
  631. var styles = "";
  632. if (_cbNarrowSidePanel.checked) {
  633. styles += '.row-fluid #sidebar { width: 250px; }';
  634. styles += '.col-fixed-330 { width: 250px; }';
  635. styles += '#sidebar waze-links { overflow: hidden; }';
  636. styles += '#sidebar waze-links li+li::before { padding: 0; }';
  637. styles += '#sidebar waze-links li { font-size: 10px; }';
  638. styles += '#edit-panel .add-alt-street-form th.city { min-width: inherit; }';
  639. styles += '#edit-panel .external-providers-view .select2-container { width: 100%; }';
  640. if (document.body.dir != "rtl") {
  641. styles += '.show-sidebar .row-fluid .fluid-fixed { margin-left: 250px; }';
  642. styles += '.col-offset-330 { padding-left: 250px; }';
  643. } else {
  644. styles += '.show-sidebar .row-fluid .fluid-fixed { margin-right: 250px; }';
  645. styles += '.col-offset-330 { padding-right: 250px; }';
  646. }
  647. styles += '.edit-closure .form { padding: 2px; }';
  648. styles += '.edit-closure .date-input-group { width: 56%; }';
  649. styles += '#editor-container #map.street-view-mode #street-view-container { width: 35%; }';
  650. styles += '#editor-container #map.street-view-mode #WazeMap { width: 65%; margin-right: 65%; }';
  651. addStyle(prefix + fname, styles);
  652. } else {
  653. removeStyle(prefix + fname);
  654. }
  655. window.dispatchEvent(new Event('resize'));
  656. }
  657.  
  658. function hideAveSpeedControls() {
  659. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  660. logit("function " + fname + " called", "debug");
  661. removeStyle(prefix + fname);
  662. if (_cbHideAveSpeedControls.checked) {
  663. var ASCBox;
  664. if (getId('fwdSpeedCameraCheckbox')) {
  665. ASCBox = getId('fwdSpeedCameraCheckbox');
  666. }
  667. if (getId('revSpeedCameraCheckbox')) {
  668. ASCBox = getId('revSpeedCameraCheckbox');
  669. }
  670. if (ASCBox) {
  671. var formGroup = ASCBox.parentNode.parentNode.parentNode;
  672. var formGroupParent = formGroup.parentNode;
  673. var targetGroup = Array.prototype.indexOf.call(formGroupParent.children, formGroup) + 1;
  674. addStyle(prefix + fname, '#segment-edit-general > .side-panel-section.attributes-form > .form-group:nth-of-type(' + targetGroup + ') { display: none; }');
  675. }
  676. }
  677. if (_cbClickablePlaceAddress.checked) {
  678. if (getElementsByClassName('clearfix preview')) {
  679. var address = getElementsByClassName('clearfix preview');
  680. if (address[0]) {
  681. address[0].classList.add('edit-button');
  682. address[0].style.cursor = 'pointer';
  683. }
  684. }
  685. }
  686. }
  687.  
  688. function addZoomIndicator() {
  689. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  690. logit("function " + fname + " called", "debug");
  691. var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
  692. if (_cbAddZoomIndicator.checked) {
  693. addStyle(prefix + fname, '.slider { font-size: 15px; font-weight: 900; line-height: 1; height: 18px; margin-top: 23px; padding-top: 2px; text-align: center; }');
  694. Waze.map.events.register("zoomend", null, ZLI);
  695. ZLI();
  696. } else {
  697. removeStyle(prefix + fname);
  698. Waze.map.events.unregister("zoomend", null, ZLI);
  699. slider.innerText = "";
  700. slider.title = "";
  701. }
  702. }
  703.  
  704. function ZLI() {
  705. var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
  706. slider.innerText = Waze.map.zoom;
  707. slider.title = "Zoom level indicator by WMEFU";
  708. switch (Waze.map.zoom) {
  709. case 0:
  710. case 1:
  711. slider.style.background = '#ef9a9a';
  712. slider.title += "\nCannot permalink any segments at this zoom level";
  713. break;
  714. case 2:
  715. case 3:
  716. slider.style.background = '#ffe082';
  717. slider.title += "\nCan only permalink primary or higher at this zoom level";
  718. break;
  719. default:
  720. slider.style.background = '#ffffff';
  721. slider.title += "\nCan permalink any segments at this zoom level";
  722. break;
  723. }
  724. }
  725.  
  726. function shiftAerials() {
  727. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  728. logit("function " + fname + " called", "debug");
  729. // calculate meters/pixel for current map view
  730. var ipu = OpenLayers.INCHES_PER_UNIT;
  731. var metersPerPixel = Waze.map.getResolution() * ipu.m / ipu[Waze.map.getUnits()];
  732. // Apply the shift and opacity
  733. Waze.map.baseLayer.div.style.left = Math.round(getId("_inpASX").value / metersPerPixel) + 'px';
  734. Waze.map.baseLayer.div.style.top = Math.round(- getId("_inpASY").value / metersPerPixel) + 'px';
  735. Waze.map.baseLayer.div.style.opacity = getId("_inpASO").value/100;
  736. }
  737.  
  738. function fixExternalProviders () {
  739. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  740. logit("function " + fname + " called", "debug");
  741. var styles = "";
  742. if (_cbFixExternalProviders.checked) {
  743. //enlarge external provider boxes
  744. styles += '#edit-panel .external-providers-view .select2-container { width: 90%; margin-bottom: 2px; }';
  745. styles += '.select2-container .select2-choice { height: inherit; line-height: 16px; }';
  746. styles += '.select2-container .select2-choice>.select2-chosen { white-space: normal; }';
  747. styles += '.placeId { padding-bottom: 5px; }';
  748. addStyle(prefix + fname,styles);
  749. } else {
  750. removeStyle(prefix + fname);
  751. }
  752. }
  753.  
  754. function warnCommentsOff() {
  755. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  756. logit("function " + fname + " called", "debug");
  757. if (Waze.map.getLayerByUniqueName('mapComments').visibility === false) {
  758. removeStyle(prefix + fname);
  759. addStyle(prefix + fname, '.toolbar { background-color: #FFC107; }');
  760. } else {
  761. removeStyle(prefix + fname);
  762. }
  763. }
  764.  
  765. function adjustGSV() {
  766. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  767. logit("function " + fname + " called", "debug");
  768. var styles = "";
  769. styles += '.gm-style { filter: contrast(' + getId('_inpGSVContrast').value + '%) ';
  770. styles += 'brightness(' + getId('_inpGSVBrightness').value + '%) ';
  771. if (getId('_cbGSVInvert').checked) {
  772. styles += 'invert(1); }';
  773. } else {
  774. styles += 'invert(0); }';
  775. }
  776. removeStyle(prefix + fname);
  777. addStyle(prefix + fname, styles);
  778. }
  779.  
  780. function permalinkCheck() {
  781. var fname = arguments.callee.toString().match(/function ([^\(]+)/)[1];
  782. logit("function " + fname + " called", "debug");
  783. var selSegments = Waze.selectionManager.selectedItems.length;
  784. if ( URLSegmentCount != selSegments ) {
  785. alert("WARNING FROM WME FixUI!\n\n" +
  786. "You have opened a permalink with " + URLSegmentCount + " segments,\n" +
  787. "but the total selected in WME is " + selSegments + ".\n\n" +
  788. "The permalink may contain segments not selectable at this zoom\n" +
  789. "or not visible on-screen, or some segment IDs may have been\n" +
  790. "changed since the permalink was created.");
  791. }
  792. Waze.selectionManager.events.unregister("selectionchanged", null, permalinkCheck);
  793. }
  794.  
  795. //Helper functions
  796.  
  797. function addGlobalStyle(css) {
  798. var head, style;
  799. head = document.getElementsByTagName('head')[0];
  800. if (!head) {
  801. return;
  802. }
  803. style = document.createElement('style');
  804. style.type = 'text/css';
  805. style.innerHTML = css;
  806. head.appendChild(style);
  807. }
  808.  
  809. function addStyle(ID, css) {
  810. var head, style;
  811. head = document.getElementsByTagName('head')[0];
  812. if (!head) {
  813. return;
  814. }
  815. style = document.createElement('style');
  816. style.type = 'text/css';
  817. style.innerHTML = css;
  818. style.id = ID;
  819. head.appendChild(style);
  820. }
  821.  
  822. function removeStyle(ID) {
  823. var style = document.getElementById(ID);
  824. if (style) { style.parentNode.removeChild(style); }
  825. }
  826.  
  827. function getElementsByClassName(classname, node) {
  828. if(!node) { node = document.getElementsByTagName("body")[0]; }
  829. var a = [];
  830. var re = new RegExp('\\b' + classname + '\\b');
  831. var els = node.getElementsByTagName("*");
  832. for (var i=0,j=els.length; i<j; i++) {
  833. if (re.test(els[i].className)) { a.push(els[i]); }
  834. }
  835. return a;
  836. }
  837.  
  838. function getId(node) {
  839. return document.getElementById(node);
  840. }
  841.  
  842. function logit(msg, typ) {
  843. if (!typ) {
  844. console.log(prefix + ": " + msg);
  845. } else {
  846. switch(typ) {
  847. case "error":
  848. console.error(prefix + ": " + msg);
  849. break;
  850. case "warning":
  851. console.warn(prefix + ": " + msg);
  852. break;
  853. case "info":
  854. console.info(prefix + ": " + msg);
  855. break;
  856. case "debug":
  857. if (debug) {
  858. console.debug(prefix + ": " + msg);
  859. }
  860. break;
  861. default:
  862. console.log(prefix + " unknown message type: " + msg);
  863. break;
  864. }
  865. }
  866. }
  867.  
  868. // Start it running
  869. setTimeout(init1, 200);
  870. })();