WME Fix UI

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

当前为 2016-06-28 提交的版本,查看 最新版本

  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://editor-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.1
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. // Thanks to (in no particular order) Bellhouse, Twister-UK, Timbones, Dave2084, Rickzabel, Glodenox
  15.  
  16. (function()
  17. {
  18. // global variables
  19. var wmefu_version = "1.1";
  20. var tabAttempts = 0;
  21. var wmeFUAddon;
  22. var debug = false;
  23.  
  24. function init1() {
  25. console.group("WMEFU initialising...");
  26. console.time("WMEFU initialisation time");
  27. logit("Starting init1","debug");
  28. // go round again if map container isn't there yet
  29. if(!window.Waze.map) {
  30. logit("waiting for WME...","warning");
  31. setTimeout(init1, 200);
  32. return;
  33. }
  34. // create tab content and store it
  35. wmeFUAddon = createAddon();
  36. // insert the content as a tab
  37. addMyTab(null,0);
  38. //pass control to init2
  39. init2();
  40. }
  41.  
  42. function init2() {
  43. logit("Starting init2","debug");
  44. //go round again if my tab isn't there yet
  45. if (!getId('sidepanel-FixUI')) {
  46. logit("Waiting for my tab to appear...","warning");
  47. setTimeout(init2, 200);
  48. return;
  49. }
  50. // setup event handlers for user actions:
  51. getId('_cbMoveZoomBar').onclick = moveZoomBar;
  52. getId('_cbShrinkBlackBar').onclick = shrinkBlackBar;
  53. getId('_cbHideUserInfo').onclick = hideUserInfo;
  54. getId('_cbCompressSegmentTab').onclick = compressSegmentTab;
  55. getId('_cbRestyleReports').onclick = restyleReports;
  56. getId('_cbDisableMapBlocker').onclick = disableMapBlocker;
  57. getId('_cbNarrowSidePanel').onclick = narrowSidePanel;
  58. getId('_cbHideAveSpeedControls').onclick = hideAveSpeedControls;
  59. getId('_cbAddZoomIndicator').onclick = addZoomIndicator;
  60. // set event to recreate my tab when MTE mode is exited
  61. Waze.app.modeController.model.bind('change:mode', addMyTab);
  62. //events for Aerial Shifter
  63. Waze.map.events.register("zoomend", null, shiftAerials);
  64. Waze.map.events.register("moveend", null, shiftAerials);
  65. Waze.map.baseLayer.events.register("loadend", null, shiftAerials);
  66. getId("_inpASX").onchange = shiftAerials;
  67. getId("_inpASX").onwheel = shiftAerials;
  68. getId("_inpASY").onchange = shiftAerials;
  69. getId("_inpASY").onwheel = shiftAerials;
  70. getId("_inpASO").onchange = shiftAerials;
  71. getId("_inpASO").onwheel = shiftAerials;
  72. getId("_resetAS").onclick = function() {
  73. _inpASX.value = 0;
  74. _inpASY.value = 0;
  75. shiftAerials();
  76. };
  77. // restore saved settings
  78. if (localStorage.WMEFixUI) {
  79. logit("loading options from local storage");
  80. options = JSON.parse(localStorage.WMEFixUI);
  81. getId('_cbMoveZoomBar').checked = options[1];
  82. getId('_cbShrinkBlackBar').checked = options[2];
  83. getId('_cbHideUserInfo').checked = options[3];
  84. getId('_cbCompressSegmentTab').checked = options[4];
  85. getId('_cbRestyleReports').checked = options[5];
  86. getId('_cbDisableMapBlocker').checked = options[6];
  87. getId('_cbNarrowSidePanel').checked = options[7];
  88. getId('_cbHideAveSpeedControls').checked = options[8];
  89. getId('_cbAddZoomIndicator').checked = options[9];
  90. if (typeof(options[10]) === "undefined") {
  91. //define sensible values for AS if none are stored
  92. logit("setting new AS values","debug");
  93. options[10] = 0;
  94. options[11] = 0;
  95. options[12] = 100;
  96. }
  97. getId('_inpASX').value = options[10];
  98. getId('_inpASY').value = options[11];
  99. getId('_inpASO').value = options[12];
  100. } else {
  101. // default values for first installation
  102. logit("no options in local storage - setting defaults");
  103. getId('_cbMoveZoomBar').checked = true;
  104. getId('_cbShrinkBlackBar').checked = true;
  105. getId('_cbHideUserInfo').checked = true;
  106. getId('_cbCompressSegmentTab').checked = true;
  107. getId('_cbRestyleReports').checked = true;
  108. getId('_cbDisableMapBlocker').checked = false;
  109. getId('_cbNarrowSidePanel').checked = false;
  110. getId('_cbHideAveSpeedControls').checked = false;
  111. getId('_cbAddZoomIndicator').checked = true;
  112. getId('_inpASX').value = 0;
  113. getId('_inpASY').value = 0;
  114. getId('_inpASO').value = 100;
  115. }
  116. // Adds an extra checkbox so I can test segment panel changes easily
  117. if (Waze.loginManager.user.userName == 'iainhouse') {
  118. logit("creating segment detail debug checkbox","info");
  119. var brand = getId('brand');
  120. extraCBSection = document.createElement('p');
  121. extraCBSection.innerHTML = '<input type="checkbox" id="_cbextraCBSection" />';
  122. brand.appendChild(extraCBSection);
  123. getId('_cbextraCBSection').onclick = FALSEcompressSegmentTab;
  124. _cbextraCBSection.checked = _cbCompressSegmentTab.checked;
  125. }
  126. // overload the WME exit function to save my settings
  127. saveOptions = function() {
  128. if (localStorage) {
  129. logit("saving options to local storage");
  130. var options = [];
  131. // preserve previous options which may get lost after logout
  132. if (localStorage.WMEFixUI)
  133. options = JSON.parse(localStorage.WMEFixUI);
  134. options[1] = getId('_cbMoveZoomBar').checked;
  135. options[2] = getId('_cbShrinkBlackBar').checked;
  136. options[3] = getId('_cbHideUserInfo').checked;
  137. options[4] = getId('_cbCompressSegmentTab').checked;
  138. options[5] = getId('_cbRestyleReports').checked;
  139. options[6] = getId('_cbDisableMapBlocker').checked;
  140. options[7] = getId('_cbNarrowSidePanel').checked;
  141. options[8] = getId('_cbHideAveSpeedControls').checked;
  142. options[9] = getId('_cbAddZoomIndicator').checked;
  143. options[10] = getId('_inpASX').value;
  144. options[11] = getId('_inpASY').value;
  145. options[12] = getId('_inpASO').value;
  146. localStorage.WMEFixUI = JSON.stringify(options);
  147. }
  148. };
  149. window.addEventListener("beforeunload", saveOptions, false);
  150.  
  151. // apply the settings
  152. shiftAerials();
  153. setTimeout(applyAllSettings, 2000);
  154. logit("Initialisation complete");
  155. console.timeEnd("WMEFU initialisation time");
  156. console.groupEnd();
  157. }
  158.  
  159. function createAddon() {
  160. //create the contents of my side-panel tab
  161. var addon = document.createElement('section');
  162. var section = document.createElement('p');
  163. addon.id = "sidepanel-FixUI";
  164. section.style.paddingTop = "0px";
  165. section.id = "fuContent";
  166. section.innerHTML = '<b>UI Fixes</b><br>';
  167. section.innerHTML += '<input type="checkbox" id="_cbMoveZoomBar" /> ' +
  168. '<span title="Because nobody likes a pointless UI change that breaks your workflow, imposed by idiots who rarely use the editor and don\'t listen to feedback">Move zoom bar to left <sup>*</sup></span><br>';
  169. section.innerHTML += '<input type="checkbox" id="_cbAddZoomIndicator" /> ' +
  170. '<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>';
  171. section.innerHTML += '<input type="checkbox" id="_cbHideUserInfo" /> ' +
  172. '<span title="Because we can earn points quicker without a massive chunk of space wasted on telling us how many we earnt up to yesterday">Hide user info in the side panel</span><br>';
  173. section.innerHTML += '<input type="checkbox" id="_cbShrinkBlackBar" /> ' +
  174. '<span title="Because we can\'t afford to waste screen space on stuff we didn\'t ask for and don\'t want">Shrink the black bar above the map</span><br>';
  175. section.innerHTML += '<input type="checkbox" id="_cbCompressSegmentTab" /> ' +
  176. '<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>';
  177. section.innerHTML += '<input type="checkbox" id="_cbRestyleReports" /> ' +
  178. '<span title="Another UI element configured for developers with massive screens instead of normal users">Change formatting for report panels (UR/MP)</span><br>';
  179. section.innerHTML += '<input type="checkbox" id="_cbDisableMapBlocker" /> ' +
  180. '<span title="As if the crappy interface wasn\'t making life hard enough, now 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>';
  181. section.innerHTML += '<input type="checkbox" id="_cbNarrowSidePanel" /> ' +
  182. '<span title="If you have a netbook, Waze isn\'t interested in your experience. You 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>';
  183. section.innerHTML += '<input type="checkbox" id="_cbHideAveSpeedControls" /> ' +
  184. '<span title="If you don\'t have these in your country, YOU\'RE LUCKY! But don\'t forget you\'ve disabled this - they\'ll be coming soon!">Hide average speed camera controls</span><br>';
  185. section.innerHTML += '<br>';
  186. var tbHackStr = '<sup>* If you have WME Toolbox installed, make sure the setting "Move zoom control to left" is ';
  187. if (document.body.dir != "rtl") {
  188. tbHackStr += 'OFF';
  189. } else {
  190. tbHackStr += 'ON';
  191. }
  192. tbHackStr += '.</sup><br>';
  193. section.innerHTML += tbHackStr;
  194. section.innerHTML += '<br>';
  195. section.innerHTML += '<b title="Shift aerial images layer to match GPS tracks and reduce image opacity">Aerial Shifter</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  196. section.innerHTML += '<span class="fa fa-power-off" id="_resetAS" title="Clear X/Y offsets"></span><br>';
  197.  
  198. 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>';
  199. 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>';
  200. 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>';
  201. section.innerHTML += '<br>';
  202. section.innerHTML += '<br>';
  203. section.innerHTML += '<b><a href="https://www.waze.com/forum/viewtopic.php?f=819&t=191178" title="Forum topic" target="_blank"><u>' +
  204. 'WME Fix UI</u></a></b> &nbsp; v' + wmefu_version;
  205. addon.appendChild(section);
  206. addon.className = "tab-pane";
  207. return addon;
  208. }
  209.  
  210. function addMyTab(model,modeID) {
  211. if (modeID === 0) {
  212. logit("entering default mode, so creating tab");
  213. tabAttempts = 0;
  214. tabsLooper();
  215. } else {
  216. logit("entering event mode, so not initialising");
  217. return;
  218. }
  219. }
  220.  
  221. function tabsLooper() {
  222. tabAttempts += 1;
  223. if (tabAttempts > 20) {
  224. // tried 20 times to create tab without luck
  225. logit("unable to create my tab after 20 attempts","error");
  226. return;
  227. }
  228. var userTabs = getId('user-info');
  229. var navTabs = getElementsByClassName('nav-tabs', userTabs)[0];
  230. if (typeof navTabs === "undefined") {
  231. //the basic tabs aren't there yet, so I can't add mine
  232. logit("waiting for NavTabs","warning");
  233. setTimeout(tabsLooper, 200);
  234. } else{
  235. var tabContent = getElementsByClassName('tab-content', userTabs)[0];
  236. newtab = document.createElement('li');
  237. newtab.innerHTML = '<a href="#sidepanel-FixUI" data-toggle="tab" title="Fix UI">FU</a>';
  238. navTabs.appendChild(newtab);
  239. tabContent.appendChild(wmeFUAddon);
  240. }
  241. }
  242.  
  243. function applyAllSettings() {
  244. // logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
  245. console.group("WMEFU: applying all settings");
  246. moveZoomBar();
  247. shrinkBlackBar();
  248. hideUserInfo();
  249. compressSegmentTab();
  250. restyleReports();
  251. disableMapBlocker();
  252. narrowSidePanel();
  253. hideAveSpeedControls();
  254. addZoomIndicator();
  255. console.groupEnd();
  256. }
  257.  
  258. function moveZoomBar() {
  259. logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
  260. var reportPanel = getId('panel-container');
  261. reportPanel.style.position = "absolute";
  262. if (_cbMoveZoomBar.checked) {
  263. addGlobalStyle('.olControlPanZoomBar { left: 10px; width: 30px; right: inherit; }');
  264. addGlobalStyle('#WMETB_ZoomLevelIndicator { left: 43px !important; right: inherit !important; }');
  265. if (document.body.dir != "rtl") {
  266. addGlobalStyle('.panel { left: 40px; }');
  267. } else {
  268. addGlobalStyle('.panel { right: inherit; }');
  269. }
  270. } else {
  271. addGlobalStyle('.olControlPanZoomBar { left: inherit; width: 30px; right: 10px; }');
  272. addGlobalStyle('#WMETB_ZoomLevelIndicator { left: inherit !important; right: 43px !important; }');
  273. if (document.body.dir != "rtl") {
  274. addGlobalStyle('.panel { left: inherit; }');
  275. } else {
  276. addGlobalStyle('.panel { right: 40px; }');
  277. }
  278. }
  279. }
  280.  
  281. function hideUserInfo() {
  282. logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
  283. // WME Panel Swap buttons - move them up if user info is hidden
  284. var PSButton1 = getId('WMEPS_UIButton');
  285. var PSButton2 = getId('WMEPS_EditButton');
  286. if (_cbHideUserInfo.checked) {
  287. addGlobalStyle('#sidebar #user-info #user-box { padding: 0px; }');
  288. addGlobalStyle('#sidebar #user-details .user-profile { display: none !important; }');
  289. if (PSButton1) PSButton1.style.top = '-27px';
  290. if (PSButton2) PSButton2.style.top = '-27px';
  291. // Keep My Layers toggle - move up if user info is hidden
  292. addGlobalStyle('.kml-toggle-container { top: -25px; }');
  293. } else {
  294. addGlobalStyle('#sidebar #user-info #user-box { padding: 20px; }');
  295. addGlobalStyle('#sidebar #user-details .user-profile { display: inherit !important; }');
  296. if (PSButton1) PSButton1.style.top = '0px';
  297. if (PSButton2) PSButton2.style.top = '0px';
  298. // Keep My Layers toggle - move back down if user info is shown
  299. addGlobalStyle('.kml-toggle-container { top: 13px; }');
  300. }
  301. }
  302.  
  303. function shrinkBlackBar() {
  304. logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
  305. var wm = getId('WazeMap');
  306. if (_cbShrinkBlackBar.checked) {
  307. addGlobalStyle('.topbar { height: 20px; line-height: 20px; }');
  308. addGlobalStyle('.topbar .location-info { font-size: 12px; }');
  309. } else {
  310. addGlobalStyle('.topbar { height: 30px; line-height: 30px; }');
  311. addGlobalStyle('.topbar .location-info { font-size: 15px; }');
  312. }
  313. window.dispatchEvent(new Event('resize'));
  314. }
  315.  
  316. function FALSEcompressSegmentTab() {
  317. _cbCompressSegmentTab.checked = _cbextraCBSection.checked;
  318. compressSegmentTab();
  319. }
  320.  
  321. function compressSegmentTab() {
  322. logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
  323. var ep=getId('edit-panel');
  324. if (_cbCompressSegmentTab.checked) {
  325. // shrink address
  326. addGlobalStyle('#edit-panel .primary-street { font-size: 14px; line-height: 15px; font-weight: 600; color: black; }');
  327. addGlobalStyle('#edit-panel .address-edit-view .preview .address-edit-btn:not(.disabled) { background-color: #FFF9C4; }');
  328. addGlobalStyle('#edit-panel .segment .address-edit-view, .edit-panel .segment .address-edit-view { margin-bottom: 5px; }');
  329. //shrink tabs
  330. addGlobalStyle('#sidebar .nav-tabs li a { padding: 4px; }');
  331. addGlobalStyle('#sidebar .nav-tabs { margin-bottom: 5px; }');
  332. //reduce some vertical margins
  333. addGlobalStyle('#edit-panel .contents { padding-top: 0px; }');
  334. addGlobalStyle('#edit-panel .form-group { margin-bottom: 2px; line-height: 1; font-size: 11px; }');
  335. addGlobalStyle('#edit-panel .selection { margin-bottom: 5px; }');
  336. addGlobalStyle('#sidebar .side-panel-section:not(:last-child) { margin-bottom: 2px; }');
  337. addGlobalStyle('#sidebar .side-panel-section:not(:last-child)::after { margin-top: 5px; margin-bottom: 2px; }');
  338. addGlobalStyle('#edit-panel .control-label { margin-bottom: 1px; }');
  339. addGlobalStyle('#sidebar .controls-container { padding-top: 2px; }');
  340. addGlobalStyle('#edit-panel .segment .speed-limit label { margin-bottom: 0px; }');
  341. addGlobalStyle('#edit-panel .more-actions { padding-top: 2px; }');
  342. addGlobalStyle('#edit-panel .segment .speed-limit .direction-label, #edit-panel .segment .speed-limit .unit-label { line-height: 2.1em; }');
  343. //shrink dropdown controls & buttons
  344. addGlobalStyle('#edit-panel button, #edit-panel select, #edit-panel .form-control { font-size: 11px; height: 22px; padding: 0px 4px; }');
  345. addGlobalStyle('#edit-panel .more-actions button:not(:last-of-type) { margin-bottom: 2px; }');
  346. addGlobalStyle('.edit-closure .input-group-addon { padding: 2px 8px; }');
  347. //fit road property checkboxes on one line for all three (if text length allows)
  348. addGlobalStyle('#edit-panel .controls-container { display: inline-block; }');
  349. addGlobalStyle('#edit-panel .controls-container label { font-size: 12px; line-height: 18px; padding-left: 22px; }');
  350. addGlobalStyle('#edit-panel .select-entire-street { width: 49%; overflow: hidden; }');
  351. addGlobalStyle('#edit-panel .edit-house-numbers { width: 49%; overflow: hidden; }');
  352. addGlobalStyle('#edit-panel .action-button { color: black; }');
  353. } else {
  354. //enlarge address
  355. addGlobalStyle('#edit-panel .primary-street { font-size: 18px; line-height: 24px; font-weight: inherit; color: inherit; }');
  356. addGlobalStyle('#edit-panel .address-edit-view .preview .address-edit-btn:not(.disabled) { background-color: inherit; }');
  357. addGlobalStyle('#edit-panel .segment .address-edit-view, .edit-panel .segment .address-edit-view { margin-bottom: 20px; }');
  358. //enlarge tabs
  359. addGlobalStyle('#sidebar .nav-tabs li a { padding: 5px 15px; }');
  360. addGlobalStyle('#sidebar .nav-tabs { margin-bottom: 20px; }');
  361. //restore vertical margins
  362. addGlobalStyle('#edit-panel .contents { padding-top: 20px; }');
  363. addGlobalStyle('#edit-panel .form-group { margin-bottom: 10px; line-height: 1.43; font-size: 13px; }');
  364. addGlobalStyle('#edit-panel .selection { margin-bottom: 20px; }');
  365. addGlobalStyle('#sidebar .side-panel-section:not(:last-child) { margin-bottom: 21px; }');
  366. addGlobalStyle('#sidebar .side-panel-section:not(:last-child)::after { margin-top: 21px; margin-bottom: 21px; }');
  367. addGlobalStyle('#edit-panel .control-label { margin-bottom: 5px; }');
  368. addGlobalStyle('#sidebar .controls-container { padding-top: 7px; }');
  369. addGlobalStyle('#edit-panel .segment .speed-limit label { margin-bottom: 5px; }');
  370. addGlobalStyle('#edit-panel .more-actions { padding-top: 10px; }');
  371. addGlobalStyle('#edit-panel .segment .speed-limit .direction-label, #edit-panel .segment .speed-limit .unit-label { line-height: 2.5em; }');
  372. //enlarge dropdown controls & buttons
  373. addGlobalStyle('#edit-panel button, #edit-panel select, #edit-panel .form-control { font-size: 13px; height: 32px; padding: 6px 12px; }');
  374. addGlobalStyle('#edit-panel .more-actions button:not(:last-of-type) { margin-bottom: 10px; }');
  375. addGlobalStyle('.edit-closure .input-group-addon { padding: 6px 8px; }');
  376. //restore road property checkboxes to one line per item
  377. addGlobalStyle('#edit-panel .controls-container { display: inherit; }');
  378. addGlobalStyle('#edit-panel .controls-container label { font-size: inherit; line-height: inherit; padding-left: 25px; }');
  379. addGlobalStyle('#edit-panel .select-entire-street { width: 100%; overflow: inherit; }');
  380. addGlobalStyle('#edit-panel .edit-house-numbers { width: 100%; overflow: inherit; }');
  381. addGlobalStyle('#edit-panel .action-button { color: inherit; }');
  382. }
  383. //tweak required for Speedhelper script
  384. addGlobalStyle('div[id^="spd_"] { line-height: 1.43; }');
  385. }
  386.  
  387. function restyleReports() {
  388. logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
  389. if (_cbRestyleReports.checked) {
  390. addGlobalStyle('#panel-container .panel { font-size: 12px; line-height: 15px; }');
  391. addGlobalStyle('#panel-container .problem-edit .header { padding: 5px; line-height: 15px; }');
  392. addGlobalStyle('#panel-container .problem-edit .problem-data .title { line-height: 22px; }');
  393. addGlobalStyle('#panel-container .problem-edit .section .title { padding: 0 5px; }');
  394. addGlobalStyle('#panel-container .problem-edit .section .content { padding: 5px; }');
  395. addGlobalStyle('#WMEFP-UR-ALLPM { top: -2px !important; }');
  396. addGlobalStyle('#panel-container .problem-edit .conversation.section .comment .comment-content { padding: 0 5px; }');
  397. addGlobalStyle('#panel-container .problem-edit .conversation.section .no-comments { padding: 0; }');
  398. addGlobalStyle('#panel-container .problem-edit .conversation.section .new-comment-form { padding: 0; }');
  399. addGlobalStyle('#panel-container .problem-edit .conversation.section .new-comment-form textarea { resize: vertical; height: 110px; margin-bottom: 5px; padding: 3px 5px; font-size: 12px; }');
  400. addGlobalStyle('#panel-container .btn { height: 20px; padding: 0px 10px;}');
  401. addGlobalStyle('#panel-container .problem-edit .actions .content { padding: 2px 5px;}');
  402. addGlobalStyle('#panel-container .problem-edit .actions .controls-container label { margin-bottom: 0px; line-height: 22px }');
  403. addGlobalStyle('#panel-container .problem-edit .actions .navigation { margin-top: 5px;}');
  404. addGlobalStyle('#panel-container .problem-edit .actions .controls-container { display: inline-flex; flex-wrap: wrap; margin-left: -3px; }');
  405. } else {
  406. addGlobalStyle('#panel-container .panel { font-size: inherit; line-height: inherit; }');
  407. addGlobalStyle('#panel-container .problem-edit .header { padding: 10px 15px; line-height: 21px; }');
  408. addGlobalStyle('#panel-container .problem-edit .problem-data .title { line-height: 40px; }');
  409. addGlobalStyle('#panel-container .problem-edit .section .title { padding: 0 15px; }');
  410. addGlobalStyle('#panel-container .problem-edit .section .content { padding: 15px; }');
  411. addGlobalStyle('#WMEFP-UR-ALLPM { top: 10px !important; }');
  412. addGlobalStyle('#panel-container .problem-edit .conversation.section .comment .comment-content { padding: 10px 15px 10px 15px; }');
  413. addGlobalStyle('#panel-container .problem-edit .conversation.section .no-comments { padding: 15px; }');
  414. addGlobalStyle('#panel-container .problem-edit .conversation.section .new-comment-form { padding: 15px 15px 10px 15px; }');
  415. addGlobalStyle('#panel-container .problem-edit .conversation.section .new-comment-form textarea { resize: none; height: 70px; margin-bottom: 10px; padding: 6px 10px; font-size: 13px; }');
  416. addGlobalStyle('#panel-container .btn { height: inherit; padding: 6px 20px;}');
  417. addGlobalStyle('#panel-container .problem-edit .actions .content { padding: 15px;}');
  418. addGlobalStyle('#panel-container .problem-edit .actions .controls-container label { margin-bottom: 12px; line-height: inherit; }');
  419. addGlobalStyle('#panel-container .problem-edit .actions .navigation { margin-top: 10px;}');
  420. addGlobalStyle('#panel-container .problem-edit .actions .controls-container { display: inherit; flex-wrap: inherit; margin-left: inherit; }');
  421. }
  422. }
  423.  
  424. function disableMapBlocker() {
  425. logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
  426. if (_cbDisableMapBlocker.checked) {
  427. addGlobalStyle('#popup-overlay { width: 0%; height: 0%; }');
  428. } else {
  429. addGlobalStyle('#popup-overlay { width: 100%; height: 100%; }');
  430. }
  431. }
  432.  
  433. function narrowSidePanel() {
  434. logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
  435. if (_cbNarrowSidePanel.checked) {
  436. addGlobalStyle('.row-fluid #sidebar { width: 250px; }');
  437. addGlobalStyle('.col-fixed-330 { width: 250px; }');
  438. if (document.body.dir != "rtl") {
  439. addGlobalStyle('.show-sidebar .row-fluid .fluid-fixed { margin-left: 250px; }');
  440. addGlobalStyle('.col-offset-330 { padding-left: 250px; }');
  441. } else {
  442. addGlobalStyle('.show-sidebar .row-fluid .fluid-fixed { margin-right: 250px; }');
  443. addGlobalStyle('.col-offset-330 { padding-right: 250px; }');
  444. }
  445. addGlobalStyle('.edit-closure .form { padding: 2px; }');
  446. addGlobalStyle('.edit-closure .date-input-group { width: 56%; }');
  447. } else {
  448. addGlobalStyle('.row-fluid #sidebar { width: 330px; }');
  449. addGlobalStyle('.col-fixed-330 { width: 330px; }');
  450. if (document.body.dir != "rtl") {
  451. addGlobalStyle('.show-sidebar .row-fluid .fluid-fixed { margin-left: 330px; }');
  452. addGlobalStyle('.col-offset-330 { padding-left: 330px; }');
  453. } else {
  454. addGlobalStyle('.show-sidebar .row-fluid .fluid-fixed { margin-right: 330px; }');
  455. addGlobalStyle('.col-offset-330 { padding-right: 330px; }');
  456. }
  457. addGlobalStyle('.edit-closure .form { padding 15px; }');
  458. addGlobalStyle('.edit-closure .date-input-group { width: 62%; }');
  459. }
  460. window.dispatchEvent(new Event('resize'));
  461. }
  462.  
  463. function hideAveSpeedControls() {
  464. logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
  465. var controlPosition = 4;
  466. if (window.location.hostname.startsWith('editor-beta')) controlPosition = 5;
  467. if (_cbHideAveSpeedControls.checked) {
  468. addGlobalStyle('#segment-edit-general > .side-panel-section.attributes-form > .form-group:nth-of-type(' + controlPosition + ') { display: none; }');
  469. }else {
  470. addGlobalStyle('#segment-edit-general > .side-panel-section.attributes-form > .form-group:nth-of-type(' + controlPosition + ') { display: inherit; }');
  471. }
  472. }
  473.  
  474. function addZoomIndicator() {
  475. logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
  476. var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
  477. if (_cbAddZoomIndicator.checked) {
  478. addGlobalStyle('.slider { font-size: 15px; font-weight: 900; line-height: 1; height: 18px; margin-top: 23px; padding-top: 2px; text-align: center; }');
  479. ZLI();
  480. Waze.map.events.register("zoomend", null, ZLI);
  481. } else {
  482. addGlobalStyle('.slider { font-size: inherit; font-weight: inherit; line-height: inherit; height: 10px; margin-top: 27px; padding-top: inherit; text-align: inherit; }');
  483. Waze.map.events.unregister("zoomend", null, ZLI);
  484. slider.innerText = "";
  485. slider.title = "";
  486. }
  487. }
  488.  
  489. function ZLI() {
  490. var slider = getElementsByClassName('slider', getId('WazeMap'))[1];
  491. slider.innerText = Waze.map.zoom;
  492. slider.title = "Zoom level indicator by WMEFU";
  493. }
  494.  
  495. function shiftAerials() {
  496. logit("function " + arguments.callee.toString().match(/function ([^\(]+)/)[1] + " called","debug");
  497. // calculate meters/pixel for current map view
  498. var ipu = OpenLayers.INCHES_PER_UNIT;
  499. var metersPerPixel = Waze.map.getResolution() * ipu['m'] / ipu[Waze.map.getUnits()];
  500. // Apply the shift and opacity
  501. Waze.map.baseLayer.div.style.left = Math.round(getId("_inpASX").value / metersPerPixel) + 'px';
  502. Waze.map.baseLayer.div.style.top = Math.round(- getId("_inpASY").value / metersPerPixel) + 'px';
  503. Waze.map.baseLayer.div.style.opacity = getId("_inpASO").value/100;
  504. }
  505.  
  506. //Helper functions
  507.  
  508. function addGlobalStyle(css) {
  509. var head, style;
  510. head = document.getElementsByTagName('head')[0];
  511. if (!head) {
  512. return;
  513. }
  514. style = document.createElement('style');
  515. style.type = 'text/css';
  516. style.innerHTML = css;
  517. head.appendChild(style);
  518. }
  519.  
  520. function getElementsByClassName(classname, node) {
  521. if(!node) node = document.getElementsByTagName("body")[0];
  522. var a = [];
  523. var re = new RegExp('\\b' + classname + '\\b');
  524. var els = node.getElementsByTagName("*");
  525. for (var i=0,j=els.length; i<j; i++)
  526. if (re.test(els[i].className)) a.push(els[i]);
  527. return a;
  528. }
  529.  
  530. function getId(node) {
  531. return document.getElementById(node);
  532. }
  533.  
  534. function logit(msg, typ) {
  535. if (!typ) {
  536. console.log("WMEFU: " + msg);
  537. } else {
  538. switch(typ) {
  539. case "error":
  540. console.error("WMEFU: " + msg);
  541. break;
  542. case "warning":
  543. console.warn("WMEFU: " + msg);
  544. break;
  545. case "info":
  546. console.info("WMEFU: " + msg);
  547. break;
  548. case "info":
  549. console.info("WMEFU: " + msg);
  550. break;
  551. case "debug":
  552. if (debug) {
  553. console.debug("WMEFU: " + msg);
  554. }
  555. break;
  556. case "default":
  557. console.log("WMEFU unknown message type: " + msg);
  558. }
  559. }
  560. }
  561.  
  562. // Start it running
  563. setTimeout(init1, 200);
  564. })();