WME Fix UI

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

当前为 2016-07-11 提交的版本,查看 最新版本

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