WME Place Interface Enhancements

Enhancements to various Place interfaces

Versione datata 14/07/2017. Vedi la nuova versione l'ultima versione.

  1. // ==UserScript==
  2. // @name WME Place Interface Enhancements
  3. // @namespace https://greasyfork.org/users/30701-justins83-waze
  4. // @version 1.02.05
  5. // @description Enhancements to various Place interfaces
  6. // @include https://www.waze.com/editor/*
  7. // @include https://www.waze.com/*/editor/*
  8. // @include https://beta.waze.com/*
  9. // @exclude https://www.waze.com/user/editor*
  10. // @icon data:image/jpeg;base64,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
  11. // @author JustinS83
  12. // @grant none
  13. // @require https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js
  14. // @require https://greasyfork.org/scripts/27023-jscolor/code/JSColor.js
  15. // @license GPLv3
  16. // ==/UserScript==
  17. var UpdateObject, MultiAction;
  18.  
  19. (function() {
  20. 'use strict';
  21.  
  22. var curr_ver = "1.02.05"
  23. var settings = {};
  24. var placeMenuSelector = "#edit-buttons > div > div.toolbar-button.waze-icon-place.toolbar-submenu.toolbar-group.toolbar-group-venues.ItemInactive > menu";
  25.  
  26. var placementMode = false;
  27. var resCategory = "RESIDENCE_HOME";
  28. var wazePL;
  29.  
  30. //Layer definitions
  31. {
  32. var layerName = "WME PIE";
  33. var newPlaceLayer, PLSpotEstimatorLayer, PLSpotEstimatorCalibrationLayer;
  34. var PIEPlaceNameLayer;
  35. var showStopPointsLayer;
  36. var closestSegmentLayer;
  37. }
  38.  
  39. //Drawing definitions
  40. {
  41. var drawPoly, PLSpotEstimatordrawControl, PLSpotEstimatorCalibrationdrawControl;
  42. var isDrawing;
  43. var pointStyle = {
  44. pointRadius: 6,
  45. fillOpacity: 0,
  46. strokeColor: '#00ece3',
  47. strokeWidth: '2',
  48. strokeLinecap: 'round'
  49. };
  50.  
  51. //Closest segment
  52. var lineStyleToNavPoint = {
  53. strokeWidth: 3,
  54. strokeColor: '#00ece3',
  55. strokeLinecap: 'round',
  56. strokeDashstyle: 'dash'
  57. },
  58. lineStyleToClosestSeg = {
  59. strokeWidth: 4,
  60. strokeColor: '#00ece3',
  61. strokeLinecap: 'round'
  62. },
  63. pointStyleNavPoint = {
  64. externalGraphic: 'http://i65.tinypic.com/28santx.gif',
  65. graphicWidth: 22,
  66. graphicHeight: 22
  67. },
  68. pointStyle = {
  69. pointRadius: 6,
  70. fillColor: 'white',
  71. fillOpacity: 1,
  72. strokeColor: '#00ece3',
  73. strokeWidth: '3',
  74. strokeLinecap: 'round'
  75. };
  76. }
  77.  
  78. function bootstrap(tries) {
  79. tries = tries || 1;
  80.  
  81. if (window.W &&
  82. window.W.map &&
  83. window.W.model &&
  84. window.W.loginManager.user &&
  85. $ && window.jscolor) {
  86. init();
  87. } else if (tries < 1000) {
  88. setTimeout(function () {bootstrap(tries++);}, 200);
  89. }
  90. }
  91.  
  92. bootstrap();
  93.  
  94. function init(){
  95. loadTranslations();
  96.  
  97. var $section = $("<div>", {style:"padding:8px 16px", id:"WMEPIESettings"});
  98. $section.html([
  99. '<h4 style="margin-bottom:0px;"><b>' + I18n.t('pie.prefs.title') + '</b></h4>',
  100. '<h6 style="margin-top:0px;">' + curr_ver + '</h6>',
  101. '<fieldset id="fieldPlacePanel" style="border: 1px solid silver; padding: 8px; border-radius: 4px;">',
  102. '<legend style="margin-bottom:0px; border-bottom-style:none;width:auto;"><h4>' + I18n.t('pie.prefs.PropertiesPanel') + '</h4></legend>',
  103. '<div class="controls-container pie-controls-container" id="divAreaPlaceSizeControls">',
  104. '<div id="divShowAreaPlaceSize" class="controls-container pie-controls-container"><input type="checkbox" id="_cbShowAreaPlaceSize" class="pieSettingsCheckbox" /><label for="_cbShowAreaPlaceSize">' + I18n.t('pie.prefs.ShowAreaPlaceSize') + '</label></div>',
  105. '<div id="divShowAreaPlaceSizeImperial"class="controls-container pie-controls-container" style="padding-left:20px;"><input type="checkbox" id="_cbShowAreaPlaceSizeImperial" class="pieSettingsCheckbox" disabled /><label for ="_cbShowAreaPlaceSizeImperial">' + I18n.t('pie.prefs.ShowImperial') + '</label></div>',
  106. '<div id="divShowAreaPlaceSizeMetric" class="controls-container pie-controls-container" style="padding-left:20px;"><input type="checkbox" id="_cbShowAreaPlaceSizeMetric" class="pieSettingsCheckbox" disabled /><label for ="_cbShowAreaPlaceSizeMetric">' + I18n.t('pie.prefs.ShowMetric') + '</label></div>',
  107. '</div>',
  108. '<div class="controls-container pie-controls-container" id="divShowLockButtonsRPP" title="' + I18n.t('pie.prefs.ShowRPPLockButtonsTitle') + '"><input type="checkbox" id="_cbShowLockButtonsRPP" class="pieSettingsCheckbox" /><label for="_cbShowLockButtonsRPP" style="white-space:pre-line;">' + I18n.t('pie.prefs.ShowRPPLockButtons') + '</label></div>',
  109. '<div class="controls-container pie-controls-container" id="divShowPlaceLocatorCrosshair" title="' + I18n.t('pie.prefs.ShowPlaceLocatorCrosshairTitle') + '" ><input type="checkbox" id="_cbShowPlaceLocatorCrosshair" class="pieSettingsCheckbox" /><label for="_cbShowPlaceLocatorCrosshair" style="white-space:pre-line;">' + I18n.t('pie.prefs.ShowPlaceLocatorCrosshair') + '</label></br>',
  110. '<span class="controls-container pie-controls-container" style="padding-left:30px;" title=""><input type="checkbox" id="_cbPlaceLocatorCrosshairProdPL" class="pieSettingsCheckbox" /><label for="_cbPlaceLocatorCrosshairProdPL" style="white-space:pre-line;">' + I18n.t('pie.prefs.ProdPL') + '</label></span></br>',
  111. '<span class="controls-container pie-controls-container" style="padding-left:30px;" title="' + I18n.t('pie.prefs.ZoomTitle') + '">' + I18n.t('pie.prefs.Zoom') + ' <select id="piePlaceZoom"><option value="10">10</option><option value="9">9</option><option value="8">8</option><option value="7">7</option><option value="6">6</option><option value="5">5</option><option value="4">4</option><option value="3">3</option><option value="2">2</option><option value="1">1</option><option value="0">0</option></select></span></div>',
  112. '<div class="controls-container pie-controls-container" id="divShowSearchButton" title="' + I18n.t('pie.prefs.ShowAddressSearchTitle') + '"><input type="checkbox" id="_cbShowSearchButton" class="pieSettingsCheckbox"/><label for="_cbShowSearchButton" style="white-space:pre-line;">' + I18n.t('pie.prefs.ShowAddressSearch') + '</label></div>',
  113. '<div class="controls-container pie-controls-container" id="divAddPlaceCategoriesButtons"><input type="checkbox" id="_cbAddPlaceCategoriesButtons" class="pieSettingsCheckbox"/><label for="_cbAddPlaceCategoriesButtons" style="white-space:pre-line;" style="white-space:pre-line;">' + I18n.t('pie.prefs.ShowPlaceCategoryButtons') + '</label></div>',
  114. '<div class="controls-container pie-controls-container" id="divShowParkingLotButton" title="' + I18n.t('pie.prefs.ShowPLAButtonTitle') + '" ><input type="checkbox" id="_cbShowParkingLotButton" class="pieSettingsCheckbox" /><label for="_cbShowParkingLotButton" style="white-space:pre-line;">' + I18n.t('pie.prefs.ShowPLAButton') + '</label></div>',
  115. '<div class="controls-container pie-controls-container" id="divShowCopyPlaceButton" title="' + I18n.t('pie.prefs.ShowCopyPlaceButtonTitle') + '" ><input type="checkbox" id="_cbShowCopyPlaceButton" class="pieSettingsCheckbox" /><label for="_cbShowCopyPlaceButton" style="white-space:pre-line;">' + I18n.t('pie.prefs.ShowCopyPlaceButton') + '</label></div>',
  116. '<div class="controls-container pie-controls-container" id="divShowExternalProviderTooltip" title="' + I18n.t('pie.prefs.ShowGPIDTooltipTitle') + '" ><input type="checkbox" id="_cbShowExternalProviderTooltip" class="pieSettingsCheckbox" /><label for="_cbShowExternalProviderTooltip" style="white-space:pre-line;">' + I18n.t('pie.prefs.ShowGPIDTooltip') + '</label></div>',
  117. '<div class="controls-container pie-controls-container" id="divClearDescription" title="' + I18n.t('pie.prefs.ClearDescriptionTitle') + '" ><input type="checkbox" id="_cbClearDescription" class="pieSettingsCheckbox" /><label for="_cbClearDescription" style="white-space:pre-line;">' + I18n.t('pie.prefs.ClearDescription') + '</label></div>',
  118. '<div class="controls-container pie-controls-container" id="divMoveAddress" title="' + I18n.t('pie.prefs.MoveAddressTitle') + '"><input type="checkbox" id="_cbMoveAddress" class="pieSettingsCheckbox"/><label for="_cbMoveAddress" style="white-space:pre-line;">' + I18n.t('pie.prefs.MoveAddress') + '</label></div>',
  119. '<div class="controls-container pie-controls-container" id="divMoveHNEntry" title="' + I18n.t('pie.prefs.MoveHNEntryTitle') + '"><input type="checkbox" id="_cbMoveHNEntry" class="pieSettingsCheckbox"/><label for="_cbMoveHNEntry" style="white-space:pre-line;">' + I18n.t('pie.prefs.MoveHNEntry') + '</label></div>',
  120. '</fieldset>',
  121.  
  122. '<fieldset id="fieldNewPlaces" style="border: 1px solid silver; padding: 8px; border-radius: 4px;">',
  123. '<legend style="margin-bottom:0px; border-bottom-style:none;width:auto;"><h4>' + I18n.t('pie.prefs.NewPlaces') + '</h4></legend>',
  124. '<div id="divEditRPPAfterCreated" class="controls-container pie-controls-container" title="' + I18n.t('pie.prefs.EditRPPAfterCreateTitle') + '"><input type="checkbox" id="_cbEditRPPAfterCreated" class="pieSettingsCheckbox"><label for="_cbEditRPPAfterCreated" style="white-space:pre-line;">' + I18n.t('pie.prefs.EditRPPAfterCreate') + '</label></div>',
  125. '<div id="divUseStreetFromClosestSeg" class="controls-container pie-controls-container" title="' + I18n.t('pie.prefs.UseStreetFromClosestSegmentTitle') + '"><input type="checkbox" id="_cbUseStreetFromClosestSeg" class="pieSettingsCheckbox"><label for="_cbUseStreetFromClosestSeg" style="white-space:pre-line;">' + I18n.t('pie.prefs.UseStreetFromClosestSegment') + '</label></div>',
  126. '<div id="divUseCityFromClosestSeg" class="controls-container pie-controls-container" title="' + I18n.t('pie.prefs.UseCityFromClosestSegmentTitle') + '"><input type="checkbox" id="_cbUseCityFromClosestSeg" class="pieSettingsCheckbox"><label for="_cbUseCityFromClosestSeg" style="white-space:pre-line;">' + I18n.t('pie.prefs.UseCityFromClosestSegment') + '</label></div>',
  127. '<div id="divUseAltCity" class="controls-container pie-controls-container" title="' + I18n.t('pie.prefs.ClosestSegmentAltCityTitle') + '" style="padding-left:20px; word-wrap: break-word;"><input type="checkbox" id="_cbUseAltCity" class="pieSettingsCheckbox"><label for="_cbUseAltCity" style="white-space:pre-line;">' + I18n.t('pie.prefs.ClosestSegmentAltCity') + '</label></div>',
  128. '<div id="divSkipPLR" class="controls-container pie-controls-container" title="' + I18n.t('pie.prefs.ClosestSegmentIgnorePLRUnnamedPRTitle') + '"><input type="checkbox" id="_cbSkipPLR" class="pieSettingsCheckbox"/><label for="_cbSkipPLR" style="white-space:pre-line;">' + I18n.t('pie.prefs.ClosestSegmentIgnorePLRUnnamedPR') + '</label></div>',
  129. '<div id="divDefaultLockLevel" class="controls-container pie-controls-container" style="left:8px;" title="' + I18n.t('pie.prefs.LockLevelTitle') + '">' + I18n.t('pie.prefs.LockLevel') + '<select id="pieDefaultLockLevel">' + buildLockLevelsList() + '</select></div>',
  130. '</fieldset>',
  131.  
  132. '<fieldset id="fieldMapMods" style="border: 1px solid silver; padding: 8px; border-radius: 4px;">',
  133. '<legend style="margin-bottom:0px; border-bottom-style:none;width:auto;"><h4>' + I18n.t('pie.prefs.MapChanges') + '</h4></legend>',
  134. '<div id="divShowNames" class="controls-container pie-controls-container" title="' + I18n.t('pie.prefs.ShowPlaceNames') + '"><input type="checkbox" id="_cbShowPlaceNames" class="pieSettingsCheckbox" /><label for="_cbShowPlaceNames">' + I18n.t('pie.prefs.ShowPlaceNames') + '</label></div>',
  135. '<div id="divShowNamesPoint"class="controls-container pie-controls-container" style="padding-left:20px;" title="' + I18n.t('pie.prefs.ShowPointNamesTitle') + '"><input type="checkbox" id="_cbShowPlaceNamesPoint" class="pieSettingsCheckbox" disabled /><label for ="_cbShowPlaceNamesPoint">' + I18n.t('pie.prefs.ShowPointNames') + '</label></div>',
  136. '<div id="divShowNamesArea"class="controls-container pie-controls-container" style="padding-left:20px;" title="' + I18n.t('pie.prefs.ShowAreaNamesTitle') + '"><input type="checkbox" id="_cbShowPlaceNamesArea" class="pieSettingsCheckbox" disabled /><label for ="_cbShowPlaceNamesArea">' + I18n.t('pie.prefs.ShowAreaNames') + '</label></div>',
  137. '<div id="divShowNamesPLA"class="controls-container pie-controls-container" style="padding-left:20px;" title="' + I18n.t('pie.prefs.ShowPLANameTitle') + '"><input type="checkbox" id="_cbShowPlaceNamesPLA" class="pieSettingsCheckbox" disabled /><label for ="_cbShowPlaceNamesPLA">' + I18n.t('pie.prefs.ShowPLAName') + '</label></div>',
  138. '<div id="divShowNamesLock"class="controls-container pie-controls-container" style="padding-left:20px;" title="' + I18n.t('pie.prefs.ShowLockLevelTitle') + '"><input type="checkbox" id="_cbShowPlaceNamesLock" class="pieSettingsCheckbox" disabled /><label for ="_cbShowPlaceNamesLock">' + I18n.t('pie.prefs.ShowLockLevel') + '</label></div>',
  139. '<div id="divPlaceNamesFontCustomization" class="controls-container pie-controls-container" style="padding-left:20px;">',
  140. I18n.t('pie.prefs.FontSize') + ' <input type="text" size="1" id="piePlaceNameFontSize"/>px</br>',
  141. I18n.t('pie.prefs.FontColor') + ' <button class="jscolor {valueElement:null,hash:true,closable:true}" style="width:15px; height:15px;border:2px solid black" id="colorPickerFont"></button></br>',
  142. '<input type="checkbox" id="_cbPlaceNameFontBold" class="pieSettingsCheckbox"/><label for ="_cbPlaceNameFontBold">' + I18n.t('pie.prefs.Bold') + '</label></br>',
  143. I18n.t('pie.prefs.FontOutlineColor') + ' <button class="jscolor {valueElement:null,hash:true,closable:true}" style="width:15px; height:15px;border:2px solid black" id="colorPickerFontOutline"></button></br>',
  144. I18n.t('pie.prefs.FontOutlineWidth') + ' <input type="text" size="1" id="piePlaceNameFontOutlineWidth"/>',
  145. '</div>',
  146. '<div id="divShowPLSpotEstimatorButton" class="controls-container pie-controls-container" title="' + I18n.t('pie.prefs.PSEShowPSEButtonTitle') + '"><input type="checkbox" id="_cbShowPLSpotEstimatorButton" class="pieSettingsCheckbox" /><label for="_cbShowPLSpotEstimatorButton" style="white-space:pre-line;">' + I18n.t('pie.prefs.PSEShowPSEButton') + '</label></div>',
  147. '<div id="divShowNavPointClosestSegmentOnHover" class="controls-container pie-controls-container" title=""><input type="checkbox" id="_cbShowNavPointClosestSegmentOnHover" class="pieSettingsCheckbox" /><label for="_cbShowNavPointClosestSegmentOnHover" style="white-space:pre-line;">' + I18n.t('pie.prefs.ShowNavPointClosestSegmentOnHover') + '</label></div>',
  148. '<div id="divShowClosestSegmentSelected" class="controls-container pie-controls-container" title=""><input type="checkbox" id="_cbShowClosestSegmentSelected" class="pieSettingsCheckbox" /><label for="_cbShowClosestSegmentSelected" style="white-space:pre-line;">' + I18n.t('pie.prefs.ShowClosestSegmentSelected') + '</label></div>',
  149. '</fieldset>',
  150. '<div class="controls-container" id="divPlaceMenuCustomization">',
  151. '<b>' + I18n.t('pie.prefs.PlaceMenuCustomization') + '</b></br>',
  152. buildItemOption(1),
  153. buildItemOption(2),
  154. buildItemOption(3),
  155. buildItemOption(4),
  156. buildItemOption(5),
  157. buildItemOption(6),
  158. buildItemOption(7),
  159. buildItemOption(8),
  160. buildItemOption(9),
  161. buildItemOption(10),
  162. buildItemOption(11),
  163. '</div>'
  164.  
  165. ].join(' '));
  166.  
  167. UpdateObject = require("Waze/Action/UpdateObject");
  168. MultiAction = require("Waze/Action/MultiAction");
  169.  
  170. //Load settings
  171. loadSettings();
  172.  
  173. var style = new OpenLayers.Style({
  174. pointRadius: "${pointRadius}",
  175. label : "${labelText}",
  176. fontFamily: "Tahoma, Arial, Verdana",
  177. labelOutlineColor: settings.PlaceNameFontOutline,
  178. labelOutlineWidth: Number(settings.PlaceNameFontOutlineWidth),
  179. labelAlign: 'cm',
  180. fontColor: settings.PlaceNameFontColor,
  181. fontOpacity: 1.0,
  182. fontSize: settings.PlaceNameFontSize + "px",
  183. labelYOffset: "${yOffset}",
  184. fontStyle: "${style}",
  185. fontWeight: (settings.PlaceNameFontBold ? 'bold' : ''),
  186. pointRadius: 0
  187. });
  188.  
  189. PIEPlaceNameLayer = new OL.Layer.Vector("PIEPlaceNameLayer",{displayInLayerSwitcher: false,
  190. uniqueName: "__PIEPlaceNameLayer", styleMap: new OL.StyleMap(style)});
  191. W.map.addLayer(PIEPlaceNameLayer);
  192. PIEPlaceNameLayer.setVisibility(true);
  193.  
  194. newPlaceLayer = new OL.Layer.Vector(layerName,{displayInLayerSwitcher: false});
  195. W.map.addLayer(newPlaceLayer);
  196.  
  197. PLSpotEstimatorLayer = new OL.Layer.Vector("PIEPLSpotEstimatorLayer",{displayInLayerSwitcher: false, uniqueName: "__PIEPLSpotEstimatorLayer"});
  198. W.map.addLayer(PLSpotEstimatorLayer);
  199. PLSpotEstimatorLayer.setVisibility(true);
  200.  
  201. PLSpotEstimatorCalibrationLayer= new OL.Layer.Vector("PIEPLSpotEstimatorCalibrationLayer",{displayInLayerSwitcher: false, uniqueName: "__PIEPLSpotEstimatorCalibrationLayer"});
  202. W.map.addLayer(PLSpotEstimatorCalibrationLayer);
  203. PLSpotEstimatorCalibrationLayer.setVisibility(true);
  204.  
  205. showStopPointsLayer = new OL.Layer.Vector("PIEShowStopPointsLayer", {displayInLayerSwitcher: false, uniqueName: "__PIEShowStopPointsLayer"});
  206. W.map.addLayer(showStopPointsLayer);
  207. showStopPointsLayer.setVisibility(true);
  208.  
  209. closestSegmentLayer = new OL.Layer.Vector("PIEClosestSegment", {displayInLayerSwitcher: false, uniqueName:"__PIEClosesetSegmentLayer"});
  210. W.map.addLayer(closestSegmentLayer);
  211. closestSegmentLayer.setVisibility(true);
  212.  
  213. var ctl = W.map.controls.find(function(ctrl) { return ctrl.displayClass ==="WazeControlSelectHighlightFeature"; });
  214. var ctlLayers = ctl.layers.clone();
  215. var myLayer = W.map.getLayersByName('PIEPlaceNameLayer')[0];
  216. ctlLayers.push(myLayer);
  217. ctl.setLayer(ctlLayers);
  218.  
  219. injectCss();
  220. new WazeWrap.Interface.Tab('PIE', $section.html(), init2);
  221. }
  222.  
  223. function init2(){
  224. $('#cboPlaceNameFontWeight').select2({placeholder: "No font weight set", allowClear: true});
  225. $('#divPlaceNamesFontCustomization .select2-choices').css("font-size", "10px");
  226.  
  227. initColorPicker();
  228. if ($('#colorPickerFont')[0].jscolor){
  229. $('#colorPickerFont')[0].jscolor.fromString(settings.PlaceNameFontColor);
  230. $('#colorPickerFontOutline')[0].jscolor.fromString(settings.PlaceNameFontOutline);
  231. }
  232.  
  233. //$('#divPlaceNamesFontCustomization .select2-input').remove()
  234. //Set up event handlers
  235. $('#_cbShowAreaPlaceSize').change(function() {
  236. if(this.checked) {
  237. attachPlaceSizeHandlers();
  238. updatePlaceSizeDisplay();
  239. $('#_cbShowAreaPlaceSizeImperial')[0].disabled = false;
  240. $('#_cbShowAreaPlaceSizeMetric')[0].disabled = false;
  241. }
  242. else
  243. {
  244. removePlaceSizeHandlers();
  245. $('#AreaSize').remove();
  246. $('#_cbShowAreaPlaceSizeImperial')[0].disabled = true;
  247. $('#_cbShowAreaPlaceSizeMetric')[0].disabled = true;
  248. }
  249. });
  250.  
  251. $('#_cbShowPlaceNames').change(function() {
  252. PIEPlaceNameLayer.setVisibility(this.checked);
  253. if(this.checked) {
  254. $('#_cbShowPlaceNamesPoint')[0].disabled = false;
  255. $('#_cbShowPlaceNamesArea')[0].disabled = false;
  256. $('#_cbShowPlaceNamesPLA')[0].disabled = false;
  257. $('#_cbShowPlaceNamesLock')[0].disabled = false;
  258. }
  259. else
  260. {
  261. $('#_cbShowPlaceNamesPoint')[0].disabled = true;
  262. $('#_cbShowPlaceNamesArea')[0].disabled = true;
  263. $('#_cbShowPlaceNamesPLA')[0].disabled = true;
  264. $('#_cbShowPlaceNamesLock')[0].disabled = true;
  265. }
  266. console.log(this.checked);
  267. DisplayPlaceNames();
  268. });
  269.  
  270. $('[id^="_cbShowPlaceNames"]').change(function(){
  271. DisplayPlaceNames();
  272. });
  273.  
  274. $('#_cbShowExternalProviderTooltip').change(function(){
  275. ToggleExternalProvidersCSS(this.checked);
  276. });
  277.  
  278. $('#_cbShowLockButtonsRPP').change(function() {
  279. if(this.checked)
  280. attachRPPLockButtonHandlers();
  281. else
  282. {
  283. $('#pieRPPLockButtonsContainer').remove();
  284. unregisterEvents(addLockButtons);
  285. }
  286. });
  287.  
  288. $('#_cbShowPlaceLocatorCrosshair').change(function(){
  289. if(this.checked)
  290. registerEvents(ShowPlaceLocatorCrosshair);
  291. else
  292. unregisterEvents(ShowPlaceLocatorCrosshair);
  293. });
  294.  
  295. $('#_cbShowParkingLotButton').change(function(){
  296. if(this.checked)
  297. registerEvents(ShowParkingLotButton);
  298. else
  299. unregisterEvents(ShowParkingLotButton);
  300. });
  301.  
  302. $('#_cbShowCopyPlaceButton').change(function(){
  303. if(this.checked)
  304. registerEvents(ShowCopyPlaceButton);
  305. else
  306. unregisterEvents(ShowCopyPlaceButton);
  307. });
  308.  
  309. $('#_cbShowSearchButton').change(function(){
  310. if(this.checked)
  311. registerEvents(ShowSearchButton);
  312. else
  313. unregisterEvents(ShowSearchButton);
  314. });
  315.  
  316. $('#_cbAddPlaceCategoriesButtons').change(function(){
  317. if(this.checked)
  318. registerEvents(AddPlaceCategoriesButtons);
  319. else
  320. unregisterEvents(AddPlaceCategoriesButtons);
  321. });
  322.  
  323. $('#_cbMoveAddress').change(function(){
  324. if(this.checked)
  325. registerEvents(MoveAddress);
  326. else
  327. unregisterEvents(MoveAddress);
  328. });
  329.  
  330. $('#_cbMoveHNEntry').change(function(){
  331. if(this.checked)
  332. registerEvents(MoveHNEntry);
  333. else
  334. unregisterEvents(MoveHNEntry);
  335. });
  336.  
  337. $('#_cbClearDescription').change(function(){
  338. if(this.checked)
  339. registerEvents(ShowClearDescription);
  340. else
  341. unregisterEvents(ShowClearDescription);
  342. });
  343.  
  344. $('#_cbShowPLSpotEstimatorButton').change(function(){
  345. if(this.checked)
  346. registerEvents(ShowPLSpotEstimatorButton);
  347. else
  348. unregisterEvents(ShowPLSpotEstimatorButton);
  349. });
  350.  
  351. $('#_cbShowNavPointClosestSegmentOnHover').change(function(){
  352. if(this.checked)
  353. W.map.events.register("mousemove", null, drawNavPointClosestSegmentLines);
  354. else
  355. W.map.events.unregister("mousemove", null, drawNavPointClosestSegmentLines);
  356. });
  357.  
  358. $('#_cbShowClosestSegmentSelected').change(function(){
  359. if(this.checked){
  360. W.model.actionManager.events.register('afterundoaction', this, checkSelection);
  361. W.model.actionManager.events.register('afteraction', this, checkSelection);
  362. W.selectionManager.events.register('selectionchanged', this, checkSelection);
  363. W.model.venues.on('objectschanged', ObjectsChanged);
  364. }
  365. else{
  366. W.model.actionManager.events.unregister('afterundoaction', this, checkSelection);
  367. W.model.actionManager.events.unregister('afteraction', this, checkSelection);
  368. W.selectionManager.events.unregister('selectionchanged', this, checkSelection);
  369. W.model.venues.off('objectschanged', ObjectsChanged);
  370. }
  371. });
  372.  
  373. //Load settings to interface
  374. setChecked('_cbShowAreaPlaceSize', settings.ShowAreaPlaceSize);
  375. setChecked('_cbShowAreaPlaceSizeImperial', settings.ShowAreaPlaceSizeImperial);
  376. setChecked('_cbShowAreaPlaceSizeMetric', settings.ShowAreaPlaceSizeMetric);
  377. setChecked('_cbShowLockButtonsRPP', settings.ShowLockButtonsRPP);
  378. setChecked('_cbEditRPPAfterCreated', settings.EditRPPAfterCreated);
  379. setChecked('_cbUseStreetFromClosestSeg', settings.UseStreetFromClosestSeg);
  380. setChecked('_cbUseCityFromClosestSeg', settings.UseCityFromClosestSeg);
  381. setChecked('_cbShowPlaceLocatorCrosshair', settings.ShowPlaceLocatorCrosshair);
  382. setChecked('_cbShowParkingLotButton', settings.ShowParkingLotButton);
  383. setChecked('_cbShowCopyPlaceButton', settings.ShowCopyPlaceButton);
  384. setChecked('_cbShowExternalProviderTooltip', settings.ShowExternalProviderTooltip);
  385. setChecked('_cbUseAltCity', settings.UseAltCity);
  386. setChecked('_cbShowSearchButton', settings.ShowSearchButton);
  387. setChecked('_cbAddPlaceCategoriesButtons', settings.AddPlaceCategoriesButtons);
  388. setChecked('_cbSkipPLR', settings.SkipPLR);
  389. setChecked('_cbShowPlaceNames', settings.ShowPlaceNames);
  390. setChecked('_cbShowPlaceNamesPoint', settings.ShowPlaceNamesPoint);
  391. setChecked('_cbShowPlaceNamesArea', settings.ShowPlaceNamesArea);
  392. setChecked('_cbShowPlaceNamesPLA', settings.ShowPlaceNamesPLA);
  393. setChecked('_cbShowPlaceNamesLock', settings.ShowPlaceNamesLock);
  394. setChecked('_cbClearDescription', settings.ClearDescription);
  395. setChecked('_cbPlaceNameFontBold', settings.PlaceNameFontBold);
  396. setChecked('_cbPlaceLocatorCrosshairProdPL', settings.PlaceLocatorCrosshairProdPL);
  397. setChecked('_cbMoveAddress', settings.MoveAddress);
  398. setChecked('_cbMoveHNEntry', settings.MoveHNEntry);
  399. setChecked('_cbShowPLSpotEstimatorButton', settings.ShowPLSpotEstimatorButton);
  400. setChecked('_cbShowNavPointClosestSegmentOnHover', settings.ShowNavPointClosestSegmentOnHover);
  401. setChecked('_cbShowClosestSegmentSelected', settings.ShowClosestSegmentSelected);
  402. if(settings.ShowPlaceNames){
  403. $('#_cbShowPlaceNamesPoint')[0].disabled = false;
  404. $('#_cbShowPlaceNamesArea')[0].disabled = false;
  405. $('#_cbShowPlaceNamesPLA')[0].disabled = false;
  406. $('#_cbShowPlaceNamesLock')[0].disabled = false;
  407. }
  408. $('#piePlaceZoom')[0].value = settings.PlaceZoom;
  409. $('#pieDefaultLockLevel')[0].value = settings.DefaultLockLevel;
  410. $('#piePlaceNameFontSize')[0].value = settings.PlaceNameFontSize
  411. $('#piePlaceNameFontOutlineWidth')[0].value = settings.PlaceNameFontOutlineWidth
  412.  
  413. if(settings.ShowNavPointClosestSegmentOnHover){
  414. W.map.events.register("mousemove", null, drawNavPointClosestSegmentLines);
  415. }
  416.  
  417. if(settings.ShowAreaPlaceSize){
  418. $('#_cbShowAreaPlaceSizeImperial')[0].disabled = false;
  419. $('#_cbShowAreaPlaceSizeMetric')[0].disabled = false;
  420. attachPlaceSizeHandlers();
  421. }
  422.  
  423. if(settings.ShowPlaceLocatorCrosshair){
  424. registerEvents(ShowPlaceLocatorCrosshair);
  425. ShowPlaceLocatorCrosshair(); //in case the user opened a PL with a Place selected
  426. }
  427.  
  428. if(settings.ShowParkingLotButton){
  429. registerEvents(ShowParkingLotButton);
  430. ShowParkingLotButton(); //in case the user opened a PL with a Place selected
  431. }
  432.  
  433. if(settings.ShowCopyPlaceButton){
  434. registerEvents(ShowCopyPlaceButton);
  435. ShowCopyPlaceButton();
  436. }
  437.  
  438. if(settings.ShowExternalProviderTooltip){
  439. //registerEvents(ShowExternalProviderTooltip);
  440. //ShowExternalProviderTooltip();
  441.  
  442. var observer = new MutationObserver(function(mutations) {
  443. mutations.forEach(function(mutation) {
  444. if ($(mutation.target).hasClass('select2-chosen')) ShowExternalProviderTooltip();
  445. });
  446. });
  447.  
  448. observer.observe(document.getElementById('edit-panel'), { childList: true, subtree: true });
  449. }
  450.  
  451. if(settings.ShowSearchButton){
  452. registerEvents(ShowSearchButton);
  453. ShowSearchButton(); //in case the user opened a PL with a Place selected
  454. }
  455.  
  456. if(settings.AddPlaceCategoriesButtons){
  457. registerEvents(AddPlaceCategoriesButtons);
  458. AddPlaceCategoriesButtons();
  459. }
  460.  
  461. if(settings.ClearDescription){
  462. registerEvents(ShowClearDescription);
  463. ShowClearDescription();
  464. }
  465.  
  466. if(settings.MoveAddress){
  467. registerEvents(MoveAddress);
  468. MoveAddress();
  469. }
  470.  
  471. if(settings.MoveHNEntry){
  472. registerEvents(MoveHNEntry);
  473. MoveHNEntry();
  474. }
  475.  
  476. if(settings.ShowPLSpotEstimatorButton){
  477. registerEvents(ShowPLSpotEstimatorButton);
  478. ShowPLSpotEstimatorButton();
  479. }
  480.  
  481. if(settings.ShowLockButtonsRPP)
  482. attachRPPLockButtonHandlers();
  483.  
  484. if(settings.ShowExternalProviderTooltip)
  485. ToggleExternalProvidersCSS(true);
  486.  
  487. if(settings.ShowClosestSegmentSelected){
  488. W.model.actionManager.events.register('afterundoaction', this, checkSelection);
  489. W.model.actionManager.events.register('afteraction', this, checkSelection);
  490. W.selectionManager.events.register('selectionchanged', this, checkSelection);
  491. W.model.venues.on('objectschanged', ObjectsChanged);
  492. }
  493.  
  494. $('.pieSettingsCheckbox').change(function() {
  495. var settingName = $(this)[0].id.substr(3);
  496. settings[settingName] = this.checked;
  497. saveSettings();
  498. });
  499.  
  500. $('#piePlaceZoom').change(function(){
  501. var settingName = $(this)[0].id.substr(3);
  502. settings[settingName] = $(this)[0].value;
  503. saveSettings();
  504. });
  505.  
  506. $('#pieDefaultLockLevel').change(function(){
  507. settings[$(this)[0].id.substr(3)] = $(this)[0].value;
  508. saveSettings();
  509. });
  510.  
  511. $('#_cbPlaceNameFontBold').change(function(){
  512. PIEPlaceNameLayer.styleMap.styles.default.defaultStyle.fontWeight = (this.checked ? 'bold' :'');
  513. DisplayPlaceNames();
  514. });
  515.  
  516. $('#piePlaceNameFontSize').focusout(function(){
  517. var fontSize = $(this)[0].value;
  518. if(fontSize == "" || fontSize == "0")
  519. $(this)[0].value = 12;
  520. settings[$(this)[0].id.substr(3)] = fontSize;
  521. saveSettings();
  522. PIEPlaceNameLayer.styleMap.styles.default.defaultStyle.fontSize = fontSize + "px";
  523. DisplayPlaceNames();
  524. });
  525.  
  526. $('#piePlaceNameFontOutlineWidth').focusout(function(){
  527. var outlineWidth = $(this)[0].value;
  528. if(outlineWidth == "" || outlineWidth == "0")
  529. $(this)[0].value = 3;
  530. settings[$(this)[0].id.substr(3)] = outlineWidth;
  531. saveSettings();
  532. PIEPlaceNameLayer.styleMap.styles.default.defaultStyle.labelOutlineWidth = outlineWidth;
  533. DisplayPlaceNames();
  534. });
  535.  
  536. $('#piePlaceNameFontSize').keypress(function(event) {
  537. if ((event.which < 48 || event.which > 57))
  538. event.preventDefault();
  539. });
  540.  
  541. $('#piePlaceNameFontOutlineWidth').keypress(function(event) {
  542. if ((event.which < 48 || event.which > 57))
  543. event.preventDefault();
  544. });
  545.  
  546. var i;
  547. //Whenever a Place item is changed, read the settings and save to localStorage
  548. $('[id^="pieItem"]').change(function(){
  549. for(i=0;i<11;i++){
  550. settings.NewPlacesList[i] = $('#pieItem'+(i+1))[0].value;
  551. }
  552. saveSettings();
  553. buildNewPlaceList();
  554. });
  555.  
  556. //Load settings into Place Customization list options
  557. for(i=0; i<11;i++)
  558. $('#pieItem'+(i+1))[0].value = settings.NewPlacesList[i];
  559.  
  560. //Build our new menu
  561. buildNewPlaceList();
  562.  
  563. new WazeWrap.Interface.Shortcut('CreateResidentialPlaceShortcut', 'Creates a resdiential Place point', 'wmepie', 'Place Interface Enhancements', settings.CreateResidentialPlaceShortcut, function(){startPlacementMode(resCategory, true);}, null).add();
  564.  
  565. new WazeWrap.Interface.Shortcut('CreateParkingLotShortcut', 'Creates a parking lot Place', 'wmepie', 'Place Interface Enhancements', settings.CreateParkingLotShortcut, function(){startPlacementMode("PARKING_LOT", false);}, null).add();
  566.  
  567. window.addEventListener("beforeunload", function() {
  568. saveSettings();
  569. }, false);
  570.  
  571. //Trim whitespace from start and end of house number field on Places
  572. W.selectionManager.events.register("selectionchanged", null, function(){
  573. if(W.selectionManager.selectedItems.length > 0 && W.selectionManager.selectedItems[0].model.type === "venue")
  574. $('.form-control.house-number').focusout(function(){
  575. $('.form-control.house-number')[0].value = $('.form-control.house-number')[0].value.trim();
  576. });
  577. });
  578.  
  579. var observer = new MutationObserver(function(mutations) {
  580. mutations.forEach(function(mutation) {
  581. if ($('#dialog-region').find('.venue-image-dialog').length > 0 && $('#detailsWrap').length == 0) ImageDialogEnhancement();
  582. });
  583. });
  584.  
  585. observer.observe(document.getElementById('dialog-region'), { childList: true, subtree: true });
  586.  
  587. //Highlight the categories box when the old hospital category is present
  588. /*W.selectionManager.events.register("selectionchanged", null, highlightObsoleteHospitalCategory);
  589. W.model.actionManager.events.register("afterundoaction",null, highlightObsoleteHospitalCategory);
  590. W.model.actionManager.events.register("afterclearactions",null, highlightObsoleteHospitalCategory);
  591. W.model.actionManager.events.register("afteraction",null, highlightObsoleteHospitalCategory);*/
  592.  
  593. W.map.events.register("zoomend", null, DisplayPlaceNames);
  594. W.map.events.register("changelayer", null, DisplayPlaceNames);
  595.  
  596. //Shamelessly copied from URO+
  597. var MO_MPLayer = new MutationObserver(MPLayerChanged);
  598. MO_MPLayer.observe(W.map.problemLayer.div,{childList : true});
  599.  
  600. wazePL = document.querySelector('.WazeControlPermalink>a.fa-link');
  601. wazePL.id = 'wazePermalink';
  602. }
  603.  
  604. var highlightedVenue, highlighting;
  605. function drawNavPointClosestSegmentLines(){
  606. highlighting = false;
  607. if(highlightedVenue !== null)
  608. if(highlightedVenue === W.map.landmarkLayer.getFeatureBy("renderIntent","highlight"))
  609. highlighting = true;
  610. else
  611. showStopPointsLayer.removeAllFeatures();
  612. highlightedVenue = W.map.landmarkLayer.getFeatureBy("renderIntent","highlight");
  613.  
  614. if(highlightedVenue !== null && highlightedVenue.model && highlighting === false && W.map.zoom >= 4){
  615. let isArea = !highlightedVenue.model.isPoint();
  616. let navPoint = highlightedVenue.model.getNavigationPoint();
  617.  
  618. //nav point to closest segment
  619. let closestSeg = WazeWrap.Geometry.findClosestSegment(navPoint.point,false, false);
  620. let lineFeature = new OL.Feature.Vector(new OL.Geometry.LineString([navPoint.point, closestSeg.closestPoint]), {}, lineStyleToClosestSeg);
  621. let pointFeature = new OL.Feature.Vector(closestSeg.closestPoint, {}, pointStyle);
  622. showStopPointsLayer.addFeatures([lineFeature, pointFeature]);
  623.  
  624. //place center to nav point
  625. let startPt = highlightedVenue.geometry;
  626. if(isArea)
  627. startPt = highlightedVenue.model.geometry.getCentroid();
  628. lineFeature = new OL.Feature.Vector(new OL.Geometry.LineString([startPt, navPoint.point]), {}, lineStyleToNavPoint);
  629. pointFeature = new OL.Feature.Vector(navPoint.point, {}, pointStyleNavPoint);
  630. if(highlightedVenue.model.attributes.entryExitPoints.length > 0 || isArea)
  631. showStopPointsLayer.addFeatures([lineFeature, pointFeature]);
  632.  
  633. }
  634. if(highlightedVenue === null || W.map.zoom < 4)
  635. showStopPointsLayer.removeAllFeatures();
  636. }
  637.  
  638. function ObjectsChanged(){
  639. if(W.map.getLayerByUniqueName('landmarks').selectedFeatures.length >0)
  640. if(placeIsPoint && W.geometryEditing.activeEditor.vertices.length > 0){
  641. removeDragCallbacks();
  642. checkSelection();
  643. }
  644. }
  645.  
  646. function handleNavPointOffScreen() {
  647. if (selectedItem !== W.selectionManager.selectedItems.first() ||
  648. WazeWrap.Geometry.isGeometryInMapExtent(ClosestSegmentNavPoint.lonlat.toPoint())) {
  649. W.map.events.unregister('moveend', window, handleNavPointOffScreen);
  650. checkSelection();
  651. }
  652. }
  653.  
  654. function clearClosesetSegmentLayerFeatures() {
  655. return closestSegmentLayer.features.length > 0 && closestSegmentLayer.removeAllFeatures();
  656. }
  657.  
  658. function checkConditions() {
  659. 'use strict';
  660. var a = W.map.getZoom() > 3,
  661. b = W.map.landmarkLayer.getVisibility(),
  662. c = closestSegmentLayer.getVisibility(),
  663. d = !$('#map-lightbox').is(':visible'),/* Check for HN editing */
  664. e = (W.selectionManager.hasSelectedItems() && W.selectionManager.selectedItems[0].model.type !== "bigJunction");
  665.  
  666. if (a && b && c && d && e) {
  667. return true;
  668. } else {
  669. return false;
  670. }
  671. }
  672.  
  673. function drawLine(start, end, lStyle, pStyle) {
  674. 'use strict';
  675. var lineFeature, pointFeature;
  676.  
  677. lineFeature = new OL.Feature.Vector(new OL.Geometry.LineString([start, end]), {}, lStyle);
  678. pointFeature = new OL.Feature.Vector(end, {}, pStyle);
  679. closestSegmentLayer.addFeatures([lineFeature, pointFeature]);
  680. }
  681.  
  682. function findNearestSegment(navPoint) {
  683. 'use strict';
  684. var closestSegment = {};
  685. if(navPoint.element)
  686. navPoint = W.geometryEditing.activeEditor._navigationPointMarker.lonlat.toPoint();
  687.  
  688. closestSegment = WazeWrap.Geometry.findClosestSegment(navPoint,false, false);
  689.  
  690. clearClosesetSegmentLayerFeatures();
  691. drawLine(navPoint, closestSegment.closestPoint, lineStyleToClosestSeg, pointStyle);
  692. }
  693.  
  694. var placeIsPoint = false;
  695. function checkSelection() {
  696. 'use strict';
  697.  
  698. var ClosestSegmentNavPoint;
  699.  
  700. if (!checkConditions()) {
  701. removeDragCallbacks();
  702. } else {
  703. ClosestSegmentNavPoint = W.geometryEditing.activeEditor._navigationPointMarker;
  704. if (W.selectionManager.hasSelectedItems()) {
  705. let selectedItem = W.selectionManager.selectedItems[0];
  706.  
  707. if ('venue' !== selectedItem.model.type) {
  708. removeDragCallbacks();
  709. clearClosesetSegmentLayerFeatures();
  710. } else {
  711.  
  712. placeIsPoint = selectedItem.model.isPoint();
  713. if (placeIsPoint && W.geometryEditing.activeEditor.navigationPoint == null) {
  714. //Event when the Place is moved
  715. W.geometryEditing.activeEditor.dragControl.onDrag = function (e, t) {
  716. W.geometryEditing.activeEditor.dragVertex.apply(W.geometryEditing.activeEditor, [e, t]);
  717. findNearestSegment(selectedItem.model.getNavigationPoint().point);
  718. };
  719. ClosestSegmentNavPoint.events.register('drag', W.geometryEditing.activeEditor, findNearestSegment);
  720. findNearestSegment(selectedItem.model.getNavigationPoint().point);
  721. } else {
  722. if (null !== typeof ClosestSegmentNavPoint) {
  723. //Event when the nav point is moved
  724. ClosestSegmentNavPoint.events.register('drag', W.geometryEditing.activeEditor, findNearestSegment);
  725. if (WazeWrap.Geometry.isGeometryInMapExtent(ClosestSegmentNavPoint.lonlat.toPoint())) {
  726. findNearestSegment(ClosestSegmentNavPoint.lonlat.toPoint());
  727. } else {
  728. W.map.events.register('moveend', window, handleNavPointOffScreen);
  729. }
  730. }
  731. }
  732. }
  733. } else {
  734. removeDragCallbacks();
  735. clearClosesetSegmentLayerFeatures();
  736. }
  737. }
  738. }
  739.  
  740. function removeDragCallbacks() {
  741. if(!W.geometryEditing.activeEditor == null){
  742. W.geometryEditing.activeEditor.dragControl.onDrag = function (e, t) {
  743. W.geometryEditing.activeEditor.dragVertex.apply(W.geometryEditing.activeEditor, [e, t]);
  744. };
  745. if (null !== typeof ClosestSegmentNavPoint) {
  746. try {
  747. ClosestSegmentNavPoint.events.unregister('drag', W.geometryEditing.activeEditor, findNearestSegment);
  748. } catch (err) { }
  749. }
  750. }
  751. clearClosesetSegmentLayerFeatures();
  752. }
  753.  
  754. function buildNewPlaceList(){
  755. //Clear out the Places menu
  756. $(placeMenuSelector).empty();
  757. var cat = "";
  758. var icon = "";
  759. var i;
  760. for(i=0;i<11;i++){
  761. icon = "";
  762. cat = $('#pieItem' + (i+1))[0].value;
  763. icon = $('#pieItem' + (i+1))[0].options[$('#pieItem' + (i+1))[0].selectedIndex].getAttribute("data-icon");
  764. if(cat !== "PARKING_LOT" && cat !== resCategory)
  765. $(placeMenuSelector).append('<div class="toolbar-group-item WazeControlDrawFeature ItemInactive" style="' + (icon !== "" ? "padding-left:0px;" : "") + ' height:40px;" id="piePlaceMainItem' + (i+1) + '" data-category="'+ cat + '"><span class="menu-title ' + icon + '" style="font-size:26px;"><span style="font-size:12px;">' + $('#pieItem' + (i+1))[0].options[$('#pieItem' + (i+1))[0].selectedIndex].innerHTML + '</span></span><div class="drawing-controls"><span class="drawing-control polygon secondary-control" id="piePlaceAreaItem' + (i+1) + '" data-category="' + cat + '" title="Place (area)"></span><span class="drawing-control main-control point" id="piePlacePointItem' + (i+1) + '" data-category="' + cat + '" title="Place (point)"></span></div></div>');
  766. else{
  767. if(cat === resCategory) //force point
  768. $(placeMenuSelector).append('<div class="toolbar-group-item WazeControlDrawFeature ItemInactive" style="padding-left:0px; height:40px;" id="piePlaceMainItem' + (i+1) + '" data-category="'+ cat + '"><span class="menu-title ' + icon + '" style="font-size:26px;"><span style="font-size:12px;">' + $('#pieItem' + (i+1))[0].options[$('#pieItem' + (i+1))[0].selectedIndex].innerHTML + '</span></span></div>');
  769. else //Parking lot - force area
  770. $(placeMenuSelector).append('<div class="toolbar-group-item WazeControlDrawFeature ItemInactive" style="padding-left:1px; height40px;" id="piePlaceAreaItem' + (i+1) + '" data-category="'+ cat + '"><i class="fa fa-product-hunt fa-2x" style="font-size:20px;padding-top:9px;margin-right:5px;"></i><span class="menu-title" style="flex-grow:1;">' + $('#pieItem' + (i+1))[0].options[$('#pieItem' + (i+1))[0].selectedIndex].innerHTML + '</span></div>');
  771. }
  772. }
  773.  
  774. $('[id^="piePlaceMainItem"]').click(function(e){
  775. startPlacementMode($('#' + this.id).data("category"), true);
  776. });
  777.  
  778. $('[id^="piePlaceAreaItem"]').click(function(e){
  779. e.stopPropagation();
  780. startPlacementMode($('#' + this.id).data("category"), false);
  781. });
  782. }
  783.  
  784. function initColorPicker(tries){
  785. tries = tries || 1;
  786.  
  787. if ($('#colorPickerFont')[0].jscolor ) {
  788. $('#colorPickerFont')[0].jscolor.fromString(settings.PlaceNameFontColor);
  789. $('[id^="colorPicker"]')[0].jscolor.closeText = 'Close';
  790. $('#colorPickerFont')[0].jscolor.onChange = jscolorChanged;
  791.  
  792. $('#colorPickerFontOutline')[0].jscolor.fromString(settings.PlaceNameFontOutline);
  793. $('#colorPickerFontOutline')[0].jscolor.onChange = jscolorChanged;
  794.  
  795.  
  796. } else if (tries < 1000) {
  797. setTimeout(function () {initColorPicker(tries++);}, 200);
  798. }
  799. }
  800.  
  801. function jscolorChanged(){
  802. settings.PlaceNameFontColor = "#" + $('#colorPickerFont')[0].jscolor.toString();
  803. settings.PlaceNameFontOutline = "#" + $('#colorPickerFontOutline')[0].jscolor.toString();
  804. saveSettings();
  805. PIEPlaceNameLayer.styleMap.styles.default.defaultStyle.fontColor = settings.PlaceNameFontColor;
  806. PIEPlaceNameLayer.styleMap.styles.default.defaultStyle.labelOutlineColor = settings.PlaceNameFontOutline;
  807. DisplayPlaceNames();
  808. }
  809.  
  810. function registerEvents(handler){
  811. W.selectionManager.events.register("selectionchanged", null, handler);
  812. W.model.actionManager.events.register("afterundoaction",null, handler);
  813. W.model.actionManager.events.register("afterclearactions",null, handler);
  814. W.model.actionManager.events.register("afteraction",null, handler);
  815. }
  816.  
  817. function unregisterEvents(handler){
  818. W.selectionManager.events.unregister("selectionchanged", null, handler);
  819. W.model.actionManager.events.unregister("afterundoaction",null, handler);
  820. W.model.actionManager.events.unregister("afterclearactions",null, handler);
  821. W.model.actionManager.events.unregister("afteraction",null, handler);
  822. }
  823.  
  824. function ToggleExternalProvidersCSS(truthiness){
  825. if(truthiness)
  826. injectCSSWithID('pieExternalProvidersTweaks', '#edit-panel .external-providers-view .select2-container {width:90%; margin-bottom:2px;}');
  827. else{
  828. var styles = document.getElementById('pieExternalProvidersTweaks');
  829. if(styles) styles.parentNode.removeChild(styles);
  830. }
  831. }
  832.  
  833. function DisplayPlaceNames(){
  834. PIEPlaceNameLayer.removeAllFeatures();
  835. var showPoint, showArea, showLock, showNames, showPLA;
  836. showNames = isChecked('_cbShowPlaceNames');
  837. showPoint = isChecked('_cbShowPlaceNamesPoint');
  838. showArea = isChecked('_cbShowPlaceNamesArea');
  839. showLock = isChecked('_cbShowPlaceNamesLock');
  840. showPLA = isChecked('_cbShowPlaceNamesPLA');
  841.  
  842. if(showNames){
  843. var isPoint;
  844. for (var placeID in W.model.venues.objects) {
  845. var venue = W.model.venues.get(placeID);
  846. isPoint = venue.isPoint();
  847. if((isPoint && W.map.zoom >= 5) || (!isPoint && W.map.zoom >= 3)){
  848. if(WazeWrap.Geometry.isGeometryInMapExtent(venue.geometry)){
  849. if( (isPoint && showPoint) || (!isPoint && showArea && !venue.isParkingLot()) || (!isPoint && showPLA && venue.isParkingLot())){
  850. var textLoc;
  851. if(isPoint)
  852. textLoc = new OpenLayers.Geometry.Point(venue.geometry.x, venue.geometry.y);
  853. else
  854. textLoc = venue.geometry.getCentroid();
  855. var placeName =WordWrap(venue.attributes.name.trim() + (showLock ? ' (L' + (venue.attributes.lockRank + 1) + ')' : ''));
  856. if(venue.attributes.categories[0] === "RESIDENCE_HOME")
  857. placeName = venue.attributes.houseNumber + (venue.attributes.name.trim() !== '' ? ' - ' + venue.attributes.name : '') + (showLock ? ' (L' + (venue.attributes.lockRank + 1) + ')' : '');
  858. var placeNameLabel = new OL.Feature.Vector(textLoc,{display: 'block',labelText: placeName.trim(), yOffset:(isPoint ? -13 - placeName.split("\n").length * 5 : 0)});
  859. PIEPlaceNameLayer.addFeatures([placeNameLabel]);
  860. }
  861. }
  862. }
  863. }
  864. }
  865. }
  866.  
  867. function WordWrap(text){
  868. var newName = "";
  869.  
  870. if(text !== ""){
  871. var splitName = text.match(/(.{1,35})(?:\s|$)/g);
  872. for(var i=0;i<splitName.length;i++){
  873. newName += splitName[i] + (i != splitName.length-1 ? '\n' : '');
  874. }
  875. }
  876. console.log()
  877. return newName;
  878. }
  879.  
  880. //Shamelessly copied from URO+
  881. function MPLayerChanged(){
  882. for(var mObj in W.map.problemLayer.markers){
  883. var mIcon = W.map.problemLayer.markers[mObj].icon.div;
  884. mIcon.addEventListener("click", MarkerClick, false);
  885. }
  886. }
  887.  
  888. function MarkerClick(){
  889. var markerType = GetMarkerType(this.className);
  890. if(markerType !== null){
  891. var markerID = this.attributes["data-id"].value;
  892. if(W.map.getLayerByUniqueName("problems").markers[markerID].model.attributes.subType === 71){
  893. var $PIECreatePLA = $("<div>", {style:"min-height:20px"});
  894. $PIECreatePLA.html([
  895. '<div id="PIECreatePLA">',
  896. '<div class="btn btn-block" id="PIECreatePLAButton" style="color: #fff; background-color: #92c2d1; border-color: #78b0bf; margin-top:5px;">Create Suggested PLA</div>',
  897. '</div>'
  898. ].join(' '));
  899.  
  900. setTimeout(function(){$('#panel-container > div > div > div.body > div.actions > div > div').append($PIECreatePLA); $('#PIECreatePLAButton').click(function(){createPLAFromMP(markerID);})}, 150);
  901. }
  902. }
  903. }
  904.  
  905. //Shamelessly copied from URO+
  906. function GetMarkerType(className){
  907. var markerType = null;
  908. if(className.indexOf('user-generated') !== -1) markerType = 'ur';
  909. else if(className.indexOf('map-problem') !== -1) markerType = 'mp';
  910. else if(className.indexOf('place-update') !== -1) markerType = 'pur';
  911. return markerType;
  912. }
  913.  
  914. function createPLAFromMP(MPID){
  915. var pos = W.model.problemDetails.objects[MPID].venueGeom;
  916.  
  917. var PlaceObject = require("Waze/Feature/Vector/Landmark");
  918. var AddPlace = require("Waze/Action/AddLandmark");
  919. var NewPlace = new PlaceObject();
  920.  
  921. var points = [];
  922. var i;
  923. for(i=0;i<pos.components[0].components.length;i++){
  924. points.push(new OL.Geometry.Point(pos.components[0].components[i].x, pos.components[0].components[i].y));
  925. }
  926. var ring = new OpenLayers.Geometry.LinearRing(points);
  927. NewPlace.geometry = new OL.Geometry.Polygon([ring]);
  928.  
  929. NewPlace.attributes.categories.push("PARKING_LOT");
  930.  
  931. W.model.actionManager.add(new AddPlace(NewPlace));
  932. Waze.selectionManager.select([NewPlace]);
  933. }
  934.  
  935. function highlightObsoleteHospitalCategory(){
  936. if(W.selectionManager.selectedItems.length > 0 && W.selectionManager.selectedItems[0].model.type === "venue"){
  937. if(W.selectionManager.selectedItems[0].model.attributes.categories.contains("HOSPITAL_MEDICAL_CARE")){
  938. $('.select2-choices').css('animation-iteration-count', 'infinite');
  939. $('.select2-choices').attr('title', 'The "Hospital / Medical Care" category is no longer valid.\n\nPlease change it to "Hospital / Urgent Care" or "Doctor / Clinic", whichever is most appropriate');
  940. $('.select2-choices').tooltip();
  941. }
  942. }
  943. }
  944.  
  945. var newPlaceCategory = "";
  946. function startPlacementMode(category, isPoint){
  947. if(category === "PARKING_LOT"){
  948. if(!isChecked("layer-switcher-item_parking_places")){
  949. if(!isChecked("layer-switcher-group_places"))
  950. $("#layer-switcher-group_places").click();
  951. $("#layer-switcher-item_parking_places").click();
  952. }
  953. }
  954. $('#edit-buttons > div > div.toolbar-button.waze-icon-place.toolbar-submenu.toolbar-group.toolbar-group-venues.ItemInactive').removeClass("open");
  955. newPlaceCategory = category;
  956. var polyDrawFeatureOptions = {callbacks : {"done": doneHandler}};
  957. if(isPoint){
  958. $("#map").on('mousemove', MouseMoveHandler);
  959. $("#map").click(function(){endPlacementMode(category, isPoint);});
  960. /*drawPoly = new OpenLayers.Control.DrawFeature(newPlaceLayer, OpenLayers.Handler.Polygon, polyDrawFeatureOptions);
  961. W.map.addControl(drawPoly);
  962. drawPoly.activate();*/
  963. }
  964. else{
  965. drawPoly = new OpenLayers.Control.DrawFeature(newPlaceLayer, OpenLayers.Handler.Polygon, polyDrawFeatureOptions);
  966. W.map.addControl(drawPoly);
  967. drawPoly.activate();
  968.  
  969. }
  970. document.addEventListener('keyup', keyUpHandler, false);
  971. }
  972.  
  973. var businessPLAPlaceName, businessPLAPlaceAddress;//, businessPLAPlacePhone, businessPLAPlaceURL;
  974. function startBusinessPLAPlacementMode(){
  975. var polyDrawFeatureOptions = {callbacks : {"done": doneHandlerBusinessPLAPlace}};
  976. drawPoly = new OpenLayers.Control.DrawFeature(newPlaceLayer, OpenLayers.Handler.Polygon, polyDrawFeatureOptions);
  977. W.map.addControl(drawPoly);
  978. drawPoly.activate();
  979. document.addEventListener('keyup', keyUpHandler, false);
  980. }
  981.  
  982. function doneHandlerBusinessPLAPlace(geom){
  983. drawPoly.destroy();
  984. BusinessPLAMode = false;
  985. CreateBusinesPLAPlace(geom, businessPLAPlaceName, businessPLAPlaceAddress);//, businessPLAPlacePhone, businessPLAPlaceURL);
  986. }
  987.  
  988. function CreateBusinesPLAPlace(geom, name, address){//, phone, url){
  989. drawPoly.destroy();
  990.  
  991. var PlaceObject = require("Waze/Feature/Vector/Landmark");
  992. var AddPlace = require("Waze/Action/AddLandmark");
  993. var multiaction = new MultiAction();
  994. multiaction.setModel(W.model);
  995.  
  996. var NewPlace = new PlaceObject();
  997. var points = [];
  998. var i;
  999. for(i=0;i<geom.components[0].components.length;i++){
  1000. points.push(new OL.Geometry.Point(geom.components[0].components[i].x, geom.components[0].components[i].y));
  1001. }
  1002. var ring = new OpenLayers.Geometry.LinearRing(points);
  1003. NewPlace.geometry = new OL.Geometry.Polygon([ring]);
  1004. NewPlace.attributes.categories.push("PARKING_LOT");
  1005.  
  1006. NewPlace.attributes.lockRank = Number(settings.DefaultLockLevel);
  1007. NewPlace.attributes.name = "Parking - " + name;
  1008. //NewPlace.attributes.phone = phone;
  1009. //NewPlace.attributes.url = url;
  1010. NewPlace.attributes.categoryAttributes.PARKING_LOT = {};
  1011. NewPlace.attributes.categoryAttributes.PARKING_LOT.parkingType = "RESTRICTED";
  1012. NewPlace.attributes.categoryAttributes.PARKING_LOT.lotType = ["STREET_LEVEL"];
  1013. NewPlace.attributes.categoryAttributes.PARKING_LOT.costType = "FREE";
  1014.  
  1015. W.model.actionManager.add(new AddPlace(NewPlace));
  1016.  
  1017. if(address){
  1018. var newAttributes, UpdateFeatureAddress = require('Waze/Action/UpdateFeatureAddress');
  1019. newAttributes = {
  1020. countryID: address.country.id,
  1021. stateID: address.state.id,
  1022. emptyCity: address.city.attributes.name ? null : true,
  1023. emptyStreet: address.street.name ? null : true,
  1024. houseNumber: address.houseNumber
  1025. };
  1026.  
  1027. newAttributes.streetName = address.street.name;
  1028.  
  1029. var cityName = address.city.attributes.name;
  1030.  
  1031. if(cityName !== "")
  1032. newAttributes.emptyCity = null;
  1033. newAttributes.cityName = cityName;
  1034.  
  1035. }
  1036. var UFA = new UpdateFeatureAddress(NewPlace, newAttributes);
  1037. UFA.options.updateHouseNumber = true;
  1038. multiaction.doSubAction(UFA);
  1039. W.model.actionManager.add(multiaction);
  1040.  
  1041. Waze.selectionManager.select([NewPlace]);
  1042. }
  1043.  
  1044. function doneHandler(geom){
  1045. drawPoly.destroy();
  1046. createPlace(geom, newPlaceCategory, false);
  1047. }
  1048.  
  1049. function keyUpHandler(e){
  1050. if (e.keyCode == 27){
  1051. BusinessPLAMode = false;
  1052. disablePlacementMode();
  1053. if(drawPoly !== "undefined")
  1054. drawPoly.destroy();
  1055. }
  1056. else if(e.keyCode == 90 && e.ctrlKey)
  1057. drawPoly.undo();
  1058. else if(e.keyCode == 89 && e.ctrlKey)
  1059. drawPoly.redo();
  1060. else if(e.keyCode == 13)
  1061. drawPoly.finishSketch();
  1062. }
  1063.  
  1064. function disablePlacementMode(){
  1065. $("#map").off('click');//, endPlacementMode);
  1066. $("#map").off('mousemove', MouseMoveHandler);
  1067. clearLayer();
  1068. document.removeEventListener('keyup', keyUpHandler);
  1069. }
  1070.  
  1071. function endPlacementMode(category, isPoint){
  1072. disablePlacementMode();
  1073. createPlace(getMousePos900913(), category, isPoint);
  1074. }
  1075.  
  1076. function getMousePos900913(){
  1077. var mousePosition = $('.WazeControlMousePosition').text().split(" ");
  1078. return WazeWrap.Geometry.ConvertTo900913(mousePosition[0], mousePosition[1]);
  1079. }
  1080.  
  1081. function MouseMoveHandler(e){
  1082. clearLayer();
  1083. drawCircle(getMousePos900913());
  1084. }
  1085.  
  1086. function clearLayer() {
  1087. var layer = W.map.getLayersByName(layerName)[0];
  1088. layer.removeAllFeatures();
  1089. }
  1090.  
  1091. function drawCircle(e){
  1092. var pointFeature = new OL.Feature.Vector(new OL.Geometry.Point(e.lon, e.lat), {}, pointStyle);
  1093. W.map.getLayersByName(layerName)[0].addFeatures([pointFeature]);
  1094. }
  1095.  
  1096. function createPlace(pos, category, isPoint){
  1097. var PlaceObject = require("Waze/Feature/Vector/Landmark");
  1098. var AddPlace = require("Waze/Action/AddLandmark");
  1099. var multiaction = new MultiAction();
  1100. multiaction.setModel(W.model);
  1101.  
  1102. var NewPlace = new PlaceObject();
  1103. if(isPoint)
  1104. NewPlace.geometry = new OL.Geometry.Point(pos.lon, pos.lat);
  1105. else{
  1106. var points = [];
  1107. var i;
  1108. for(i=0;i<pos.components[0].components.length;i++){
  1109. points.push(new OL.Geometry.Point(pos.components[0].components[i].x, pos.components[0].components[i].y));
  1110. }
  1111. var ring = new OpenLayers.Geometry.LinearRing(points);
  1112. NewPlace.geometry = new OL.Geometry.Polygon([ring]);
  1113.  
  1114. }
  1115.  
  1116. NewPlace.attributes.categories.push(category);
  1117. if(category === resCategory){
  1118. NewPlace._originalResidential = true;
  1119. NewPlace.attributes.residential = true;
  1120. }
  1121. NewPlace.attributes.lockRank = Number(settings.DefaultLockLevel);
  1122.  
  1123. var closestSeg = WazeWrap.Geometry.findClosestSegment(new OL.Geometry.Point(pos.lon, pos.lat), settings.SkipPLR, settings.SkipPLR);
  1124.  
  1125. W.model.actionManager.add(new AddPlace(NewPlace));
  1126. Waze.selectionManager.select([NewPlace]);
  1127.  
  1128. if(closestSeg){ //if we were able to find a segment, try to pull the city and/or street name if the options are enabled
  1129. var newAttributes, UpdateFeatureAddress = require('Waze/Action/UpdateFeatureAddress'), address = closestSeg.getAddress();
  1130.  
  1131. newAttributes = {
  1132. countryID: address.country.id,
  1133. stateID: address.state.id,
  1134. emptyCity: address.city.attributes.name ? null : true,
  1135. emptyStreet: address.street.name ? null : true
  1136. };
  1137.  
  1138. if(settings.UseStreetFromClosestSeg)
  1139. newAttributes.streetName = address.street.name;
  1140. else
  1141. newAttributes.emptyStreet = true;
  1142.  
  1143. if(settings.UseCityFromClosestSeg){
  1144. var cityName = address.city.attributes.name;
  1145.  
  1146. if(settings.UseAltCity && cityName === ""){
  1147. if(address.altStreets.length > 0){ //segment has alt names
  1148. for(var j=0;j<closestSeg.attributes.streetIDs.length;j++){
  1149. var altCity = W.model.cities.get(W.model.streets.get(closestSeg.attributes.streetIDs[j]).cityID).attributes;
  1150.  
  1151. if(altCity.englishName !== null && altCity.englishName !== "")
  1152. cityName = altCity.englishName;
  1153. }
  1154. }
  1155. }
  1156. if(cityName !== "")
  1157. newAttributes.emptyCity = null;
  1158. newAttributes.cityName = cityName;
  1159. }
  1160. else
  1161. newAttributes.emptyCity = true;
  1162.  
  1163. multiaction.doSubAction(new UpdateFeatureAddress(NewPlace, newAttributes));
  1164. W.model.actionManager.add(multiaction);
  1165. }
  1166. else
  1167. console.log("WMEPIE - No segment found; cannot set street or city name.");
  1168.  
  1169. if(category === resCategory && settings.EditRPPAfterCreated)
  1170. editRPPAddress();
  1171. }
  1172.  
  1173. function editRPPAddress(rppTries){
  1174. rppTries = rppTries || 1;
  1175.  
  1176. if ($('.edit-button').length > 0) {
  1177. $('.edit-button').trigger("click");
  1178. $('.house-number:first').focus();
  1179.  
  1180. } else if (rppTries < 1000) {
  1181. console.log("not found");
  1182. setTimeout(function () {editRPPAddress(rppTries++);}, 200);
  1183. }
  1184. }
  1185.  
  1186. function buildItemOption(itemNumber){
  1187. var $section = $("<div>", {style:"padding:8px 16px", id:"piePlaceCat" + itemNumber});
  1188. $section.html([
  1189. I18n.t('pie.prefs.Item') + " ",
  1190. itemNumber,
  1191. buildItemList(itemNumber),
  1192. '</br>'
  1193. ].join(' '));
  1194.  
  1195. return $section.html();
  1196. }
  1197.  
  1198. function buildLockLevelsList(){
  1199. var $lockLevels = $("<div>");
  1200. for(var i=0;i<WazeWrap.User.Rank();i++){
  1201. $lockLevels.append("<option value=" + i + ">" + (i+1) + "</option>");
  1202. }
  1203. return $lockLevels.html();
  1204. }
  1205.  
  1206. function attachRPPLockButtonHandlers(){
  1207. $('#pieRPPLockButtonsContainer').remove();
  1208. W.selectionManager.events.register("selectionchanged", null, addLockButtons);
  1209. W.model.actionManager.events.register("afterundoaction",null, addLockButtons);
  1210. W.model.actionManager.events.register("afterclearactions",null, addLockButtons);
  1211. W.model.actionManager.events.register("afteraction",null, addLockButtons);
  1212. }
  1213.  
  1214. function attachPlaceSizeHandlers(){
  1215. W.selectionManager.events.register("selectionchanged", null, updatePlaceSizeDisplay);
  1216. W.model.actionManager.events.register("afteraction",null, updatePlaceSizeDisplay);
  1217. W.model.actionManager.events.register("afterundoaction",null, updatePlaceSizeDisplay);
  1218. W.model.actionManager.events.register("afterclearactions",null, updatePlaceSizeDisplay);
  1219. W.model.actionManager.events.register("noActions",null, noActions);
  1220. updatePlaceSizeDisplay();
  1221. }
  1222.  
  1223. function removePlaceSizeHandlers(){
  1224. W.selectionManager.events.unregister("selectionchanged", null, updatePlaceSizeDisplay);
  1225. W.model.actionManager.events.unregister("afteraction",null, updatePlaceSizeDisplay);
  1226. W.model.actionManager.events.unregister("afterundoaction",null, updatePlaceSizeDisplay);
  1227. W.model.actionManager.events.unregister("afterclearactions",null, updatePlaceSizeDisplay);
  1228. W.model.actionManager.events.unregister("noActions",null, noActions);
  1229. }
  1230.  
  1231. function ShowPlaceLocatorCrosshair(){
  1232. $('#pieCrosshairs').remove();
  1233. if(W.selectionManager.selectedItems.length > 0){
  1234. if(W.selectionManager.selectedItems[0].model.type === "venue"){
  1235. var panelWidth = $('#landmark-edit-general').width();
  1236. var $crosshairs;
  1237. if(W.selectionManager.selectedItems[0].model.attributes.categories.contains("RESIDENCE_HOME")){
  1238. $('.landmark > .tab-content').css('position', 'relative');
  1239. $crosshairs = $('<div style="position:absolute; z-index:100; cursor:pointer; top:0; right:0;" id="pieCrosshairs" title="Zoom and center on Place"><i class="fa fa-crosshairs fa-lg" id="placeCrosshair" aria-hidden="true"></i></div>');
  1240. $('.landmark > .tab-content').append($crosshairs);
  1241. }
  1242. else{
  1243. $crosshairs = $('<div style="float:right; z-index:100; cursor:pointer; top:0; right:0;" id="pieCrosshairs" title="Zoom and center on Place"><i class="fa fa-crosshairs fa-lg" id="placeCrosshair" aria-hidden="true"></i></div>');
  1244. $('#landmark-edit-general > form > div:nth-child(1) > i').after($crosshairs);
  1245. }
  1246. $('#pieCrosshairs').click(function(){
  1247. CenterOnPlace(W.selectionManager.selectedItems[0].model, settings.PlaceZoom);
  1248. });
  1249.  
  1250. $('#pieCrosshairs').mouseenter(function(e) {
  1251. //var changedThisPl = getKMLPermalink(wazePL.getAttribute('href'));
  1252. window.addEventListener('keydown', copyPLHotkeyEvent, false);
  1253. });
  1254.  
  1255. $('#pieCrosshairs').mouseleave('mouseleave', function() {
  1256. window.removeEventListener('keydown', copyPLHotkeyEvent);
  1257. });
  1258. }
  1259. }
  1260. }
  1261.  
  1262. var copyPLHotkeyEvent = function(e) {
  1263. if ((e.metaKey || e.ctrlKey) && (e.which === 67))
  1264. copyToClipboard(getPermalink(wazePL.getAttribute('href')));
  1265. };
  1266.  
  1267. var BusinessPLAMode = false;
  1268. function ShowParkingLotButton(){
  1269. $('#piePLAButton').remove();
  1270.  
  1271. if(W.selectionManager.selectedItems.length > 0){
  1272. if(W.selectionManager.selectedItems[0].model.type === "venue"){
  1273. var $PLAButton;
  1274. if(!(W.selectionManager.selectedItems[0].model.attributes.categories.contains("RESIDENCE_HOME") || W.selectionManager.selectedItems[0].model.attributes.categories.contains("PARKING_LOT"))){
  1275. $PLAButton = $('<div style="float:right; z-index:100; cursor:pointer; top:0; right:0;" id="piePLAButton" title="Create a Parking Lot Area for this Place"><i class="fa fa-product-hunt fa-lg" aria-hidden="true"></i></div>');
  1276. $('#landmark-edit-general > form > div:nth-child(1) > i').after($PLAButton);
  1277.  
  1278. $('#piePLAButton').click(function(){
  1279. if(!BusinessPLAMode){
  1280. BusinessPLAMode = true;
  1281. businessPLAPlaceName = W.selectionManager.selectedItems[0].model.attributes.name;
  1282. businessPLAPlaceAddress = W.selectionManager.selectedItems[0].model.getAddress().attributes;
  1283. //businessPLAPlacePhone = W.selectionManager.selectedItems[0].model.attributes.phone;
  1284. //businessPLAPlaceURL = W.selectionManager.selectedItems[0].model.attributes.url;
  1285. startBusinessPLAPlacementMode();
  1286. if(!isChecked("layer-switcher-item_parking_places")){
  1287. if(!isChecked("layer-switcher-group_places"))
  1288. $("#layer-switcher-group_places").click();
  1289. $("#layer-switcher-item_parking_places").click();
  1290. }
  1291. }
  1292. });
  1293. }
  1294. }
  1295. }
  1296. }
  1297.  
  1298. var extProviderTries = 0;
  1299. function ShowExternalProviderTooltip(){
  1300. if(isChecked('_cbShowExternalProviderTooltip'))
  1301. if(W.selectionManager.selectedItems.length > 0 && W.selectionManager.selectedItems[0].model.type === "venue"){
  1302. if($('.select2-container.uuid').length > 0)
  1303. for(var i=0; i < $('.select2-container.uuid').find('span.select2-chosen').length; i++){
  1304. extProviderTries = 0;
  1305. ReadExtProviderText(i, extProviderTries);
  1306. }
  1307. }
  1308. }
  1309.  
  1310. var calibratingAngledWidth = false;
  1311. function ShowPLSpotEstimatorButton(){
  1312. $('.PIEParkingSpotEstimatorButton').remove();
  1313.  
  1314. if(W.selectionManager.selectedItems.length > 0){
  1315. if(W.selectionManager.selectedItems[0].model.type === "venue" && W.selectionManager.selectedItems[0].model.attributes.categories.includes("PARKING_LOT")){
  1316. var $ParkingSpotEstimatorButton;
  1317. $ParkingSpotEstimatorButton = $('<div style="font-size:18px; float:right; z-index:100; cursor:pointer; top:0; right:0; margin-left:1px; margin-right:1px;" class="PIEParkingSpotEstimatorButton" title="' + I18n.t('pie.prefs.PSEDisplayButtonTitle') + '">#</div>');
  1318. $('#landmark-edit-general > form > div:nth-child(1) > i').after($ParkingSpotEstimatorButton);
  1319.  
  1320. $('select[name="estimatedNumberOfSpots"]').before($ParkingSpotEstimatorButton.clone())
  1321.  
  1322. $('.PIEParkingSpotEstimatorButton').click(ShowPLSpotEstimator);
  1323. }
  1324. }
  1325. else
  1326. $('#PIEParkingSpotEstimator').remove();//if they de-select the Place, remove the tool from the screen
  1327. }
  1328.  
  1329. function startPLSpotEstimatorDrawMode(){
  1330. let polyDrawFeatureOptions = {callbacks : {"done": PLSpotEstimatordoneHandler, "point": pointHandler}};
  1331.  
  1332. PLSpotEstimatordrawControl = new OpenLayers.Control.DrawFeature(PLSpotEstimatorLayer, OpenLayers.Handler.Path, polyDrawFeatureOptions);
  1333. W.map.addControl(PLSpotEstimatordrawControl);
  1334. PLSpotEstimatordrawControl.activate();
  1335.  
  1336. $('div#WazeMap.view-area.olMap').keydown(PLSpotEstimatorkeyUpHandler);
  1337. }
  1338.  
  1339. function startPLSpotEstimatorCalibrationMode(){
  1340. let polyDrawFeatureOptions = {callbacks : {"done": PLSpotEstimatorCalibrationdoneHandler, "point": pointHandler}};
  1341.  
  1342. PLSpotEstimatorCalibrationdrawControl = new OpenLayers.Control.DrawFeature(PLSpotEstimatorCalibrationLayer, OpenLayers.Handler.Path, polyDrawFeatureOptions);
  1343. W.map.addControl(PLSpotEstimatorCalibrationdrawControl);
  1344. PLSpotEstimatorCalibrationdrawControl.activate();
  1345.  
  1346. $('div#WazeMap.view-area.olMap').keydown(PLSpotEstimatorCalibrationkeyUpHandler);
  1347. }
  1348.  
  1349. function pointHandler() {
  1350. isDrawing = true;
  1351. }
  1352.  
  1353. function PLSpotEstimatorkeyUpHandler(e){
  1354. if (e.keyCode == 27){
  1355. if (isDrawing) {
  1356. PLSpotEstimatordrawControl.cancel();
  1357. isDrawing = false;
  1358. } else {
  1359. disablePLSpotEstimatorDrawMode();
  1360. if(PLSpotEstimatordrawControl !== "undefined")
  1361. PLSpotEstimatordrawControl.destroy();
  1362. $('#PIE90DegreeSpotWidthDraw').removeClass("PSESelected");
  1363. $('#PIEAngledSpotWidthDraw').removeClass("PSESelected");
  1364. }
  1365. e.stopPropagation();
  1366. }
  1367. else if(e.keyCode == 90 && e.ctrlKey)
  1368. PLSpotEstimatordrawControl.undo();
  1369. else if(e.keyCode == 89 && e.ctrlKey)
  1370. PLSpotEstimatordrawControl.redo();
  1371. else if(e.keyCode == 13)
  1372. PLSpotEstimatordrawControl.finishSketch();
  1373. }
  1374.  
  1375. function PLSpotEstimatorCalibrationkeyUpHandler(e){
  1376. if (e.keyCode == 27){
  1377. if (isDrawing) {
  1378. PLSpotEstimatorCalibrationdrawControl.cancel();
  1379. isDrawing = false;
  1380. } else {
  1381. disablePLSpotEstimatorCalibrationDrawMode();
  1382. if(PLSpotEstimatorCalibrationdrawControl !== "undefined")
  1383. PLSpotEstimatorCalibrationdrawControl.destroy();
  1384. $('#PIE90DegreeSpotWidthCalibration').removeClass("PSESelected");
  1385. $('#PIEAngledSpotWidthCalibration').removeClass("PSESelected");
  1386. }
  1387. e.stopPropagation();
  1388.  
  1389. }
  1390. else if(e.keyCode == 90 && e.ctrlKey)
  1391. PLSpotEstimatorCalibrationdrawControl.undo();
  1392. else if(e.keyCode == 89 && e.ctrlKey)
  1393. PLSpotEstimatorCalibrationdrawControl.redo();
  1394. else if(e.keyCode == 13)
  1395. PLSpotEstimatorCalibrationdrawControl.finishSketch();
  1396. }
  1397.  
  1398. function disablePLSpotEstimatorDrawMode(){
  1399. $("#map").off('click');
  1400. if(PLSpotEstimatordrawControl){
  1401. PLSpotEstimatordrawControl.deactivate();
  1402. PLSpotEstimatordrawControl.destroy();
  1403. }
  1404. PLSpotEstimatorLayer.removeAllFeatures();
  1405. $('div#WazeMap.view-area.olMap').off('keydown');
  1406. }
  1407.  
  1408. function disablePLSpotEstimatorCalibrationDrawMode(){
  1409. $("#map").off('click');
  1410. if(PLSpotEstimatorCalibrationdrawControl){
  1411. PLSpotEstimatorCalibrationdrawControl.deactivate();
  1412. PLSpotEstimatorCalibrationdrawControl.destroy();
  1413. }
  1414. PLSpotEstimatorCalibrationLayer.removeAllFeatures();
  1415. $('div#WazeMap.view-area.olMap').off('keydown');
  1416. }
  1417.  
  1418. function PLSpotEstimatordoneHandler(geom){
  1419. var style = {strokeWidth: 3, strokeColor: '#ee9900'};
  1420. PLSpotEstimatorLayer.addFeatures(new OL.Feature.Vector(geom,{}, style));
  1421.  
  1422. var totalSpots = 0;
  1423. PLSpotEstimatorLayer.features.forEach(function(f) {
  1424. var spots = Math.round(WazeWrap.Geometry.calculateDistance(f.geometry.components)/($('#PIE90DegreeSpotWidthDraw').hasClass("PSESelected") ? $('#PIE90DegreeSpotWidth')[0].value : $('#PIEAngledSpotWidth')[0].value));
  1425. totalSpots += spots;
  1426. });
  1427.  
  1428. $('#PIEPLSpotEstimatorTotal')[0].innerText = totalSpots;
  1429.  
  1430. if(totalSpots > 0)
  1431. $('#PIESetParkingSpacesToPlace').prop('disabled', false);
  1432. isDrawing = false;
  1433. }
  1434.  
  1435. function PLSpotEstimatorCalibrationdoneHandler(geom){
  1436. var style = {strokeWidth: 3, strokeColor: '#00ee00'};
  1437. PLSpotEstimatorCalibrationLayer.addFeatures(new OL.Feature.Vector(geom,{}, style));
  1438. let totalLength = 0;
  1439.  
  1440. PLSpotEstimatorCalibrationLayer.features.forEach(function(f) {
  1441. let length = Math.round(WazeWrap.Geometry.calculateDistance(f.geometry.components)*100)/100;
  1442. totalLength += length;
  1443. });
  1444.  
  1445. if(calibratingAngledWidth){
  1446. $('#PIEAngledSpotWidth')[0].value = totalLength;
  1447. settings.PLAngledSpotWidth = totalLength;
  1448. }
  1449. else{
  1450. $('#PIE90DegreeSpotWidth')[0].value = totalLength;
  1451. settings.PLNormalSpotWidth = totalLength;
  1452. }
  1453. saveSettings();
  1454.  
  1455. $('#PIE90DegreeSpotWidthCalibration').removeClass("PSESelected");
  1456. $('#PIEAngledSpotWidthCalibration').removeClass("PSESelected");
  1457.  
  1458. isDrawing = false;
  1459. disablePLSpotEstimatorCalibrationDrawMode();
  1460. }
  1461.  
  1462. function ShowPLSpotEstimator(){
  1463. if($('#PIEParkingSpotEstimator').length > 0)
  1464. $('#PIEParkingSpotEstimator').remove();
  1465. else{
  1466. if(W.selectionManager.selectedItems.length > 0){
  1467. if(W.selectionManager.selectedItems[0].model.type === "venue" && W.selectionManager.selectedItems[0].model.attributes.categories.includes("PARKING_LOT")){
  1468.  
  1469. var $PLSpotEstimator = $('<div>');
  1470. $PLSpotEstimator.html([
  1471. '<div style="position: absolute; text-align:center; z-index:1000; background-color:white; top:20px; left:300px; border-radius:20px; border: 2px solid; width: 300px; padding-left:10px; padding-right:10px; padding-bottom:5px;" id="PIEParkingSpotEstimator">',
  1472. '<span style="font-weight:bold;">' + I18n.t('pie.prefs.PSEParkingSpaceEstimator') + '</span><i class="fa fa-window-close-o" aria-hidden="true" style="float:right; cursor:pointer;" id="PIECloseParkingSpotEstimator"></i>',
  1473. '<hr>',
  1474. '<div style=" display:flex; justify-content:space-between;">',
  1475. '<div style="display: inline;">' + I18n.t('pie.prefs.PSELayoutType') + '<br/><br/>' + I18n.t('pie.prefs.PSESpotWidth') + '</div>',
  1476. '<div style="display: inline;">' + I18n.t('pie.prefs.PSE90degree') + '<br/><br/><input type="text" size=2 id="PIE90DegreeSpotWidth"><button id="PIE90DegreeSpotWidthCalibration" title="Measure the width of a single 90 degree parking spot">' + I18n.t('pie.prefs.PSECal') + '</button><br/><button id="PIE90DegreeSpotWidthDraw" class="fa fa-pencil" title="' + I18n.t('pie.prefs.PSEDraw90DegreeTitle') + '"></button></div>',
  1477. '<div style="display: inline;">' + I18n.t('pie.prefs.PSEAngled') + '<br/><br/><input type="text" size=2 id="PIEAngledSpotWidth"><button id="PIEAngledSpotWidthCalibration" title="Measure the width of a single angled degree parking spot">' + I18n.t('pie.prefs.PSECal') + '</button><br/><button id="PIEAngledSpotWidthDraw" class="fa fa-pencil" title="' + I18n.t('pie.prefs.PSEDrawAngledTitle') + '"></button></div>',
  1478. '</div>',
  1479. '<hr>',
  1480. '<div>' + I18n.t('pie.prefs.PSEEstimatedNumOfSpots') + '<span id="PIEPLSpotEstimatorTotal" style="color:blue; padding:0px 3px; font-weight:900; font-size:1.2em;" >0</span>&emsp;<div style="display:inline-block;"><button id="PIESetParkingSpacesToPlace" disabled>' + I18n.t('pie.prefs.PSESet') + '</button></div></div>',
  1481. '</div>'
  1482. ].join(' '));
  1483.  
  1484. $("#WazeMap").append($PLSpotEstimator.html());
  1485.  
  1486. $("#PIECloseParkingSpotEstimator").click(function(){
  1487. $('#PIEParkingSpotEstimator').remove();
  1488. disablePLSpotEstimatorDrawMode();
  1489. disablePLSpotEstimatorCalibrationDrawMode();
  1490. if(PLSpotEstimatordrawControl != null)
  1491. PLSpotEstimatordrawControl.destroy();
  1492. if(PLSpotEstimatorCalibrationdrawControl != null)
  1493. PLSpotEstimatorCalibrationdrawControl.destroy();
  1494. });
  1495.  
  1496. $('#PIEParkingSpotEstimator').keydown(function(e){
  1497. disablePLSpotEstimatorDrawMode();
  1498. disablePLSpotEstimatorCalibrationDrawMode();
  1499. if(PLSpotEstimatordrawControl != null)
  1500. PLSpotEstimatordrawControl.destroy();
  1501. if(PLSpotEstimatorCalibrationdrawControl != null)
  1502. PLSpotEstimatorCalibrationdrawControl.destroy();
  1503. $('#PIE90DegreeSpotWidthDraw').removeClass("PSESelected");
  1504. $('#PIEAngledSpotWidthDraw').removeClass("PSESelected");
  1505. $('#PIE90DegreeSpotWidthCalibration').removeClass("PSESelected");
  1506. $('#PIEAngledSpotWidthCalibration').removeClass("PSESelected");
  1507. });
  1508.  
  1509. $('#PIE90DegreeSpotWidth')[0].value = settings.PLNormalSpotWidth;
  1510. $('#PIEAngledSpotWidth')[0].value = settings.PLAngledSpotWidth;
  1511.  
  1512. $('#PIESetParkingSpacesToPlace').click(function(){
  1513. let spotCount = $('#PIEPLSpotEstimatorTotal')[0].innerText;
  1514. if(spotCount != "0"){
  1515. let myPlace = W.selectionManager.selectedItems[0].model;
  1516. let existingAttr = myPlace.attributes.categoryAttributes.PARKING_LOT;
  1517. let newAttr = {};
  1518. if (existingAttr) {
  1519. for (var prop in existingAttr) {
  1520. let value = existingAttr[prop];
  1521. if (Array.isArray(value)) value = value.clone();
  1522. newAttr[prop] = value;
  1523. };
  1524. }
  1525. let spotPropValue;
  1526. spotCount = parseInt(spotCount);
  1527. if(spotCount < 11)
  1528. spotPropValue = "R_1_TO_10"
  1529. else if(spotCount < 31)
  1530. spotPropValue = "R_11_TO_30"
  1531. else if(spotCount < 61)
  1532. spotPropValue = "R_31_TO_60"
  1533. else if(spotCount < 101)
  1534. spotPropValue = "R_61_TO_100"
  1535. else if(spotCount < 301)
  1536. spotPropValue = "R_101_TO_300"
  1537. else if(spotCount < 601)
  1538. spotPropValue = "R_301_TO_600"
  1539. else if(spotCount >= 601)
  1540. spotPropValue = "R_600_PLUS"
  1541.  
  1542. newAttr.estimatedNumberOfSpots = spotPropValue;
  1543. W.model.actionManager.add(new UpdateObject(myPlace, {'categoryAttributes': {PARKING_LOT: newAttr}}));
  1544. }
  1545. });
  1546.  
  1547. $('#PIE90DegreeSpotWidth').focusout(function(){
  1548. let width = $(this)[0].value;
  1549. if(width == "" || width == "0")
  1550. $(this)[0].value = 3.44;
  1551. settings.PLNormalSpotWidth = width;
  1552. saveSettings();
  1553. });
  1554.  
  1555. $('#PIEAngledSpotWidth').focusout(function(){
  1556. let width = $(this)[0].value;
  1557. if(width == "" || width == "0")
  1558. $(this)[0].value = 3;
  1559. settings.PLAngledSpotWidth = width;
  1560. saveSettings();
  1561. });
  1562.  
  1563. $('#PIE90DegreeSpotWidthDraw').click(function() {
  1564. if (PLSpotEstimatordrawControl && PLSpotEstimatordrawControl.active) {
  1565. PLSpotEstimatordrawControl.deactivate();
  1566. PLSpotEstimatordrawControl.destroy();
  1567. $('div#WazeMap.view-area.olMap').off('keyup');
  1568. $('#PIE90DegreeSpotWidthDraw').removeClass("PSESelected");
  1569. $('#PIEAngledSpotWidthDraw').removeClass("PSESelected");
  1570. } else {
  1571. $('#PIEAngledSpotWidthDraw').removeClass("PSESelected");
  1572. $('#PIE90DegreeSpotWidthCalibration').removeClass("PSESelected");
  1573. $('#PIEAngledSpotWidthCalibration').removeClass("PSESelected");
  1574. $('#PIE90DegreeSpotWidthDraw').addClass("PSESelected");
  1575. startPLSpotEstimatorDrawMode();
  1576. }
  1577. });
  1578.  
  1579. $('#PIEAngledSpotWidthDraw').click(function() {
  1580. if (PLSpotEstimatordrawControl && PLSpotEstimatordrawControl.active) {
  1581. PLSpotEstimatordrawControl.deactivate();
  1582. PLSpotEstimatordrawControl.destroy();
  1583. $('div#WazeMap.view-area.olMap').off('keyup');
  1584. $('#PIEAngledSpotWidthDraw').removeClass("PSESelected");
  1585. $('#PIE90DegreeSpotWidthDraw').removeClass("PSESelected");
  1586. } else {
  1587. $('#PIE90DegreeSpotWidthDraw').removeClass("PSESelected");
  1588. $('#PIE90DegreeSpotWidthCalibration').removeClass("PSESelected");
  1589. $('#PIEAngledSpotWidthCalibration').removeClass("PSESelected");
  1590. $('#PIEAngledSpotWidthDraw').addClass("PSESelected");
  1591. startPLSpotEstimatorDrawMode();
  1592. }
  1593. });
  1594.  
  1595. $('#PIE90DegreeSpotWidthCalibration').click(function(){
  1596. if(PLSpotEstimatordrawControl){
  1597. PLSpotEstimatordrawControl.deactivate();
  1598. PLSpotEstimatordrawControl.destroy();
  1599. $('#PIE90DegreeSpotWidthDraw').removeClass("PSESelected");
  1600. $('#PIEAngledSpotWidthDraw').removeClass("PSESelected");
  1601. }
  1602. if(PLSpotEstimatorCalibrationdrawControl){
  1603. PLSpotEstimatorCalibrationdrawControl.deactivate();
  1604. PLSpotEstimatorCalibrationdrawControl.destroy();
  1605. $('#PIE90DegreeSpotWidthCalibration').removeClass("PSESelected");
  1606. $('#PIEAngledSpotWidthCalibration').removeClass("PSESelected");
  1607. }
  1608. $('#PIE90DegreeSpotWidthCalibration').addClass("PSESelected");
  1609. calibratingAngledWidth = false;
  1610. startPLSpotEstimatorCalibrationMode();
  1611. });
  1612.  
  1613. $('#PIEAngledSpotWidthCalibration').click(function(){
  1614. if(PLSpotEstimatordrawControl){
  1615. PLSpotEstimatordrawControl.deactivate();
  1616. PLSpotEstimatordrawControl.destroy();
  1617. $('#PIE90DegreeSpotWidthDraw').removeClass("PSESelected");
  1618. $('#PIEAngledSpotWidthDraw').removeClass("PSESelected");
  1619. }
  1620. if(PLSpotEstimatorCalibrationdrawControl){
  1621. PLSpotEstimatorCalibrationdrawControl.deactivate();
  1622. PLSpotEstimatorCalibrationdrawControl.destroy();
  1623. $('#PIE90DegreeSpotWidthCalibration').removeClass("PSESelected");
  1624. $('#PIEAngledSpotWidthCalibration').removeClass("PSESelected");
  1625. }
  1626. $('#PIEAngledSpotWidthCalibration').addClass("PSESelected");
  1627. calibratingAngledWidth = true;
  1628. startPLSpotEstimatorCalibrationMode();
  1629. });
  1630. }
  1631. }
  1632. else{
  1633. disablePLSpotEstimatorDrawMode();
  1634. disablePLSpotEstimatorCalibrationDrawMode();
  1635. }
  1636. }
  1637. }
  1638.  
  1639. function ImageDialogEnhancement(){
  1640. $('.venue-image-dialog .details').wrap("<div id='detailsWrap'></div>");
  1641. $('#detailsWrap').append("<div style='position:absolute;right:12px; bottom:25px;'><i class='fa fa-trash-o fa-lg' id='DeleteFromImageDialog' style='cursor:pointer;' aria-hidden='true'></i></div>");
  1642. var dataID = $('#detailsWrap').parent().find('img')[0].src;
  1643. dataID = /_(.+)/g.exec(dataID)[1];
  1644. $('#DeleteFromImageDialog').click(function(){
  1645. $('div[data-id="' + dataID + '"] button.image-delete-button').click();
  1646. $('.venue-image-dialog').find('.close').click();
  1647. });
  1648.  
  1649. //Image dialog navigation arrows
  1650. if(W.selectionManager.selectedItems[0].model.attributes.images.length > 1){
  1651. let thisImageIndex;
  1652. let PlaceImages = W.selectionManager.selectedItems[0].model.attributes.images;
  1653. for(let i=0; i<PlaceImages.length; i++){
  1654. if(W.selectionManager.selectedItems[0].model.attributes.images[i].id === dataID){
  1655. thisImageIndex = i;
  1656. break;
  1657. }
  1658. }
  1659. $('.modal-body').addClass('imgcon');
  1660. $('.modal-body').prepend((thisImageIndex + 1) + "/" + W.selectionManager.selectedItems[0].model.attributes.images.length);
  1661. $('.imgcon').append('<div class="imnav"><div class="prim control"></div><div class="zmim control"></div><div class="neim control"></div></div>');
  1662. $('.prim').click(function(){
  1663. let prevIndex;
  1664.  
  1665. if(thisImageIndex == 0)
  1666. prevIndex = PlaceImages.length - 1;
  1667. else
  1668. prevIndex = thisImageIndex - 1;
  1669. dataID = PlaceImages[prevIndex].id;
  1670. $('div[data-id="' + dataID +'"] img').click();
  1671. });
  1672.  
  1673. $('.neim').click(function(){
  1674. let nextIndex;
  1675.  
  1676. if(thisImageIndex == PlaceImages.length - 1)
  1677. nextIndex = 0;
  1678. else
  1679. nextIndex = thisImageIndex + 1;
  1680. dataID = PlaceImages[nextIndex].id;
  1681. $('div[data-id="' + dataID +'"] img').click();
  1682. });
  1683. }
  1684. }
  1685.  
  1686. function ReadExtProviderText(index, extProviderTries){
  1687. var providersList = $('.select2-container.uuid').find('span.select2-chosen');
  1688. if($('.select2-container.uuid').find('span.select2-chosen')[index].innerHTML == "&nbsp;" && extProviderTries <= 20)
  1689. setTimeout(function(){ReadExtProviderText(index, extProviderTries++);}, 50);
  1690. else{
  1691. if($('#' + providersList[index].id).parent().parent().data('original-title') == null){
  1692. $('#' + providersList[index].id).parent().parent().attr('title', $('.select2-container.uuid').find('span.select2-chosen')[index].innerText);
  1693. $('#' + providersList[index].id).parent().parent().tooltip()
  1694. }
  1695. else
  1696. $('#' + providersList[index].id).parent().parent().attr('data-original-title', $('.select2-container.uuid').find('span.select2-chosen')[index].innerText);
  1697. }
  1698. }
  1699.  
  1700. function ShowCopyPlaceButton(){
  1701. $('#pieCopyPlaceButton').remove();
  1702.  
  1703. if(W.selectionManager.selectedItems.length > 0){
  1704. //W.selectionManager.selectedItems[0].model.attributes.id.match(/(\d+\.){2}\d+/)
  1705. if(W.selectionManager.selectedItems[0].model.type === "venue"){// && (typeof W.selectionManager.selectedItems[0].model.attributes.id === "string")){ //id is only a string if the Place has been saved - don't allow copying unsaved Places
  1706. var $PlaceCopyButton;
  1707. if(!W.selectionManager.selectedItems[0].model.attributes.categories.contains("RESIDENCE_HOME")){
  1708. $PlaceCopyButton = $('<div style="float:right; z-index:100; cursor:pointer; top:0; right:0; margin-left:1px; margin-right:1px;" id="pieCopyPlaceButton" title="Creates a copy of this Place"><i class="fa fa-files-o fa-lg" aria-hidden="true"></i></div>');
  1709. $('#landmark-edit-general > form > div:nth-child(1) > i').after($PlaceCopyButton);
  1710.  
  1711. $('#pieCopyPlaceButton').click(function(){
  1712. var PlaceObject = require("Waze/Feature/Vector/Landmark");
  1713. var AddPlace = require("Waze/Action/AddLandmark");
  1714.  
  1715. var NewPlace = new PlaceObject();
  1716. var oldPlace = W.selectionManager.selectedItems[0].model;
  1717.  
  1718. NewPlace.attributes.name = oldPlace.attributes.name + " (copy)";
  1719. NewPlace.attributes.phone = oldPlace.attributes.phone;
  1720. NewPlace.attributes.url = oldPlace.attributes.url;
  1721. NewPlace.attributes.categories = oldPlace.attributes.categories.clone();
  1722. NewPlace.attributes.aliases = oldPlace.attributes.aliases.clone();
  1723. NewPlace.attributes.description = oldPlace.attributes.description;
  1724. NewPlace.attributes.houseNumber = oldPlace.attributes.houseNumber;
  1725. NewPlace.attributes.lockRank = oldPlace.attributes.lockRank;
  1726. NewPlace.attributes.geometry = oldPlace.attributes.geometry.clone();
  1727.  
  1728. if(oldPlace.attributes.geometry.toString().match(/^POLYGON/)){
  1729. var convertedCoords;
  1730. for(var i=0; i<NewPlace.attributes.geometry.components[0].components.length - 1; i++){
  1731. convertedCoords = WazeWrap.Geometry.ConvertTo4326(NewPlace.attributes.geometry.components[0].components[i].x, NewPlace.attributes.geometry.components[0].components[i].y);
  1732. convertedCoords.lon += WazeWrap.Geometry.CalculateLongOffsetGPS(5, convertedCoords.long, convertedCoords.lat);
  1733. NewPlace.attributes.geometry.components[0].components[i].x = WazeWrap.Geometry.ConvertTo900913(convertedCoords.lon, convertedCoords.lat).lon;
  1734. }
  1735. }
  1736. else{
  1737. var convertedCoords = WazeWrap.Geometry.ConvertTo4326(oldPlace.attributes.geometry.x, oldPlace.attributes.geometry.y);
  1738. convertedCoords.lon += WazeWrap.Geometry.CalculateLongOffsetGPS(5, convertedCoords.long, convertedCoords.lat);
  1739. NewPlace.attributes.geometry.x = WazeWrap.Geometry.ConvertTo900913(convertedCoords.lon, convertedCoords.lat).lon;
  1740. }
  1741.  
  1742. NewPlace.attributes.services = oldPlace.attributes.services.clone();
  1743. NewPlace.attributes.openingHours = oldPlace.attributes.openingHours.clone();
  1744. NewPlace.attributes.streetID = oldPlace.attributes.streetID;
  1745.  
  1746. if(NewPlace.attributes.categories.contains("GAS_STATION"))
  1747. NewPlace.attributes.brand = oldPlace.attributes.brand;
  1748.  
  1749. if(NewPlace.attributes.categories.contains("PARKING_LOT")){
  1750. NewPlace.attributes.categoryAttributes.PARKING_LOT = {};
  1751. var PLAttribute = oldPlace.attributes.categoryAttributes.PARKING_LOT;
  1752. if(!(PLAttribute.lotType == null))
  1753. NewPlace.attributes.categoryAttributes.PARKING_LOT.lotType = oldPlace.attributes.categoryAttributes.PARKING_LOT.lotType.clone();
  1754. if(!(PLAttribute.canExitWhileClosed == null))
  1755. NewPlace.attributes.categoryAttributes.PARKING_LOT.canExitWhileClosed = oldPlace.attributes.categoryAttributes.PARKING_LOT.canExitWhileClosed;
  1756. if(!(PLAttribute.costType == null))
  1757. NewPlace.attributes.categoryAttributes.PARKING_LOT.costType = oldPlace.attributes.categoryAttributes.PARKING_LOT.costType;
  1758. if(!(PLAttribute.estimatedNumberOfSpots == null))
  1759. NewPlace.attributes.categoryAttributes.PARKING_LOT.estimatedNumberOfSpots = oldPlace.attributes.categoryAttributes.PARKING_LOT.estimatedNumberOfSpots;
  1760. if(!(PLAttribute.hasTBR == null))
  1761. NewPlace.attributes.categoryAttributes.PARKING_LOT.hasTBR = oldPlace.attributes.categoryAttributes.PARKING_LOT.hasTBR;
  1762. if(!(PLAttribute.lotType == null))
  1763. NewPlace.attributes.categoryAttributes.PARKING_LOT.lotType = oldPlace.attributes.categoryAttributes.PARKING_LOT.lotType.clone();
  1764. if(!(PLAttribute.parkingType == null))
  1765. NewPlace.attributes.categoryAttributes.PARKING_LOT.parkingType = oldPlace.attributes.categoryAttributes.PARKING_LOT.parkingType;
  1766. if(!(PLAttribute.paymentType == null))
  1767. NewPlace.attributes.categoryAttributes.PARKING_LOT.paymentType = oldPlace.attributes.categoryAttributes.PARKING_LOT.paymentType.clone();
  1768. }
  1769.  
  1770. W.model.actionManager.add(new AddPlace(NewPlace));
  1771.  
  1772. var newAttributes, UpdateFeatureAddress = require('Waze/Action/UpdateFeatureAddress'), address = oldPlace.getAddress();
  1773. var MultiAction = require("Waze/Action/MultiAction");
  1774. var multiaction = new MultiAction();
  1775. multiaction.setModel(W.model);
  1776.  
  1777. console.log(address);
  1778. newAttributes = {
  1779. countryID: address.attributes.country.id,
  1780. stateID: address.attributes.state.id,
  1781. emptyCity: address.attributes.city.attributes.name ? null : true,
  1782. emptyStreet: address.attributes.street.name ? null : true
  1783. };
  1784.  
  1785. newAttributes.streetName = address.attributes.street.name;
  1786. var cityName = address.attributes.city.attributes.name;
  1787.  
  1788. if(cityName !== "")
  1789. newAttributes.emptyCity = null;
  1790. newAttributes.cityName = cityName;
  1791.  
  1792. var UFA = new UpdateFeatureAddress(NewPlace, newAttributes);
  1793. UFA.options.updateHouseNumber = true;
  1794. multiaction.doSubAction(UFA);
  1795. W.model.actionManager.add(multiaction);
  1796. Waze.selectionManager.select([NewPlace]);
  1797. });
  1798. }
  1799. }
  1800. }
  1801. }
  1802.  
  1803. function ShowSearchButton(){
  1804. $('#pieSearchButton').remove();
  1805. if(W.selectionManager.selectedItems.length > 0){
  1806. if(W.selectionManager.selectedItems[0].model.type === "venue"){
  1807. var $search = $('<div style="float:left; margin-right:5px; position:relative; left:-10px; cursor:pointer;" id="pieSearchButton" title="Fills the search bar with the address"><i class="fa fa-search" aria-hidden="true"></i></div>');
  1808. $('.address-edit-view').before($search);
  1809. $('#pieSearchButton').click(function(){
  1810. var address = $('.full-address')[0].innerHTML;
  1811. var noCity = I18n.translations[I18n.currentLocale()].edit.address.no_city;
  1812. var noStreet = I18n.translations[I18n.currentLocale()].edit.address.no_street;
  1813.  
  1814. address = address.replace(noCity + ",","");
  1815. if(address !== I18n.translations[I18n.currentLocale()].edit.landmark.no_address)
  1816. $('.search-query')[0].value = address;
  1817. });
  1818. }
  1819. }
  1820. }
  1821.  
  1822. function ShowClearDescription(){
  1823. $('#landmark-edit-general textarea').parent().append('<i class="fa fa-times-circle clearButton" style="position:absolute; top:0; right:0;"></i>');
  1824. $('#landmark-edit-general textarea').parent().css('position', 'relative');
  1825. $('.clearButton').click(function(){
  1826. W.model.actionManager.add(new UpdateObject( W.selectionManager.selectedItems[0].model, { description: "" }));
  1827. });
  1828. }
  1829.  
  1830. function MoveAddress(){
  1831. if(W.selectionManager.selectedItems.length > 0)
  1832. if(W.selectionManager.selectedItems[0].model.type === "venue")
  1833. $('#landmark-edit-general').prepend($('.address-edit.side-panel-section'));
  1834. }
  1835.  
  1836. function MoveHNEntry(){
  1837. if(W.selectionManager.selectedItems.length > 0)
  1838. if(W.selectionManager.selectedItems[0].model.type === "venue")
  1839. $('.edit-button').click(function(){
  1840. $('.street-name').parent().parent().before($('.house-number').parent().parent());
  1841. });
  1842. }
  1843.  
  1844. function AddPlaceCategoriesButtons(){
  1845. $('#piePlaceCategoriesButtonsContainer').remove();
  1846. if(W.selectionManager.selectedItems.length > 0){
  1847. if(W.selectionManager.selectedItems[0].model.type === "venue"){
  1848. var $container = $('<div>',{id:'piePlaceCategoriesButtonsContainer', style:'white-space: nowrap;'});
  1849. var categoryOptions = $('[id^=pieItem]');
  1850.  
  1851. var $button = $('<div>',{id:'btnPlaceCatClear', title:'Clear current categories', style:'display:inline-block; cursor:pointer'}).click(function() { onPlaceCategoriesButtonsClick(this.id); });
  1852. $button.append('<span class="fa fa-times" style="font-size:20px; color:red;"></span>');
  1853. $container.append($button);
  1854.  
  1855. for(var i=0;i<categoryOptions.length;i++){
  1856. var name = categoryOptions[i].options[categoryOptions[i].selectedIndex].innerHTML;
  1857. var icon = categoryOptions[i].options[categoryOptions[i].selectedIndex].getAttribute("data-icon");
  1858. var divid = 'btnPlaceCat' + categoryOptions[i].value;
  1859. if(categoryOptions[i].value !== resCategory && categoryOptions[i].value !== "PARKING_LOT"){
  1860. $button = $('<div>',{id:divid, title:name.replace('&amp;', '&'), style:'display:inline-block; cursor:pointer', 'data-category':categoryOptions[i].value}).click(function() { onPlaceCategoriesButtonsClick(this.id); });
  1861. $button.append('<span class="'+icon+'" style="font-size:20px;"></span>');
  1862.  
  1863. $container.append($button);
  1864. }
  1865. }
  1866. }
  1867.  
  1868. $('.categories.controls').before($container);
  1869. }
  1870. }
  1871.  
  1872. function onPlaceCategoriesButtonsClick(buttonid){
  1873. if(buttonid === "btnPlaceCatClear"){
  1874. var blankCategories = []; //W.selectionManager.selectedItems[0].model.attributes.categories.clone();
  1875. //console.log(blankCategories.length);
  1876. //blankCategories.splice(0, blankCategories.length);
  1877. //console.log(blankCategories);
  1878. W.model.actionManager.add(new UpdateObject(W.selectionManager.selectedItems[0].model, { categories: blankCategories }));
  1879. }
  1880. else{
  1881. var newCategories = W.selectionManager.selectedItems[0].model.attributes.categories.clone();
  1882. //console.log($('#'+buttonid)[0].getAttribute("data-category"));
  1883. newCategories.push($('#'+buttonid)[0].getAttribute("data-category"));
  1884. W.model.actionManager.add(new UpdateObject(W.selectionManager.selectedItems[0].model, {categories: newCategories}));
  1885. }
  1886. }
  1887.  
  1888. function CenterOnPlace(venue, zoom){
  1889. var centroid = venue.geometry.getCentroid();
  1890. W.map.setCenter([centroid.x, centroid.y], zoom);
  1891. }
  1892.  
  1893. function isChecked(checkboxId) {
  1894. return $('#' + checkboxId).is(':checked');
  1895. }
  1896.  
  1897. function setChecked(checkboxId, checked) {
  1898. $('#' + checkboxId).prop('checked', checked);
  1899. }
  1900.  
  1901. function noActions(){
  1902. setTimeout(updatePlaceSizeDisplay, 100 ); //have to put in a delay for when the user uses undo to clear all actions - WME updates on top of my changes otherwise.
  1903. }
  1904.  
  1905. function updatePlaceSizeDisplay(){
  1906. var count = W.selectionManager.selectedItems.length;
  1907. var metersArea = 0;
  1908. var bold = false;
  1909. if(count === 1){
  1910. var venue = W.selectionManager.selectedItems[0];
  1911. var isArea = venue.geometry.toString().match(/^POLYGON/);
  1912. //var isPoint = venue.geometry.toString().match(/^POINT/);
  1913.  
  1914. if(venue.model.type === "venue" && isArea){
  1915. if($('#AreaSize'))
  1916. $('#AreaSize').remove();
  1917. metersArea = W.selectionManager.selectedItems[0].model.geometry.getGeodesicArea(W.map.getProjectionObject());
  1918.  
  1919. if(metersArea > 0 && isArea){
  1920. var ftArea = Math.round(metersArea * 10.76391 *100)/100;
  1921.  
  1922. var list = $('#landmark-edit-general > ul')[0];
  1923. var newList = document.createElement("UL");
  1924. newList.id = "AreaSize";
  1925.  
  1926. var newItem = document.createElement("LI");
  1927. if(isChecked("_cbShowAreaPlaceSizeMetric")){
  1928. newItem.innerHTML = "Area: " + metersArea.toFixed(2) + " m<sup>2</sup>";
  1929. newList.appendChild(newItem);
  1930. }
  1931.  
  1932. if(isChecked("_cbShowAreaPlaceSizeImperial")){
  1933. newItem = document.createElement("LI");
  1934. newItem.innerHTML = "Area: " + ftArea.toFixed(2) + " ft<sup>2</sup>";
  1935. newList.appendChild(newItem);
  1936. }
  1937. if(metersArea < 500){
  1938. newItem = document.createElement("LI");
  1939. newItem.innerHTML = "<span style='color:red; font-weight:bold;'>Places smaller than 500 m<sup>2</sup>/5382 ft<sup>2</sup> will not show in the client</span>";
  1940. newList.appendChild(newItem);
  1941. }
  1942. if(metersArea > 20000){
  1943. newItem = document.createElement("LI");
  1944. newItem.innerHTML = "<span style='color:red; font-weight:bold;'>Places larger than 20000 m<sup>2</sup>/215278.2 ft<sup>2</sup> will <i>always</i> show in the client</span>";
  1945. newList.appendChild(newItem);
  1946. }
  1947. if(list.before != null)
  1948. list.before(newList);
  1949. else{
  1950. var parent = $('#landmark-edit-general > ul')[0].parentNode;
  1951. parent.insertBefore(newList,$('#landmark-edit-general > ul')[0]);
  1952. }
  1953.  
  1954. $('#AreaSize').addClass("list-unstyled");
  1955. $('#AreaSize').addClass("additional-attributes");
  1956. }
  1957. }
  1958. }
  1959. }
  1960.  
  1961. //Using the same display for lock buttons as ClickSaver (with permission from MapoMatic) - thanks MoM!
  1962. function addLockButtons() {
  1963. if(W.selectionManager.selectedItems.length > 0){
  1964. var item = W.selectionManager.selectedItems[0];
  1965. var isRPP = (item.model.type === "venue" && item.model.attributes.residential === true);
  1966.  
  1967. if(isRPP){
  1968. var attr = item.model.attributes;
  1969. var autoRank = attr.rank;
  1970. var manualRank = attr.lockRank;
  1971. var firstManualRank = manualRank;
  1972. var userRank = WazeWrap.User.Rank() - 1;
  1973. var maxAutoRank = autoRank;
  1974. var disabled = false;
  1975.  
  1976. var $div = $('#pieRPPLockButtonsContainer');
  1977. $div.remove();
  1978. $div = $('<div>',{id:'pieRPPLockButtonsContainer',style:'margin-bottom:5px;'});
  1979. $div.append('<label class="control-label">Lock</label>');
  1980. var btnInfos = [];
  1981.  
  1982. for(var iBtn=0;iBtn<=6;iBtn++){btnInfos.push({r:iBtn,val:iBtn});}
  1983. btnInfos.forEach(function(btnInfo){
  1984. var selected = (btnInfo.val == manualRank);
  1985. disabled = userRank < btnInfo.val;
  1986. if (btnInfo.val !== 6) {
  1987. $div.append(
  1988. $('<div>', {
  1989. class:'btn btn-lh' + (selected ? ' btn-lh-selected':'') + (btnInfo.r < 6 & (userRank < btnInfo.r || disabled) ? ' disabled' : '')
  1990. })
  1991. .text(btnInfo.hasOwnProperty('title') ? btnInfo.title : btnInfo.r + 1)
  1992. .data('val',btnInfo.hasOwnProperty('val') ? btnInfo.val : btnInfo.r + 1)
  1993. .hover(function() {})
  1994. .click(function() {
  1995. if((userRank >= $(this).data('val')) && (btnInfo.r < 6)) {
  1996. W.model.actionManager.add(new UpdateObject(item.model,{lockRank:($(this).data('val'))}));
  1997. addLockButtons();
  1998. }
  1999. })
  2000. );
  2001. }
  2002. });
  2003. $('#landmark-edit-general > div.address-edit.side-panel-section').after($div);
  2004. }
  2005. }
  2006. }
  2007.  
  2008. var getPermalink = function(currPl) {
  2009. var adjustedPL = currPl.substr(currPl.lastIndexOf('editor')).replace(/&[^&]*Filter=[^&]*|&s=(\d+)/ig,'');
  2010. var lon = adjustedPL.match(/lon=(-?\d+\.\d+)/)[1];
  2011. var lat = adjustedPL.match(/lat=(-?\d+\.\d+)/)[1];
  2012. var zoom = adjustedPL.match(/zoom=\d+/)[0];
  2013. var centroid = W.selectionManager.selectedItems[0].model.geometry.getCentroid();
  2014. adjustedPL = adjustedPL.replace(lon, WazeWrap.Geometry.ConvertTo4326(centroid.x,centroid.y).lon);
  2015. adjustedPL = adjustedPL.replace(lat, WazeWrap.Geometry.ConvertTo4326(centroid.x,centroid.y).lat);
  2016. adjustedPL = adjustedPL.replace(zoom, "zoom="+settings.PlaceZoom);
  2017. if(settings.PlaceLocatorCrosshairProdPL)
  2018. return 'https://www.waze.com/' + adjustedPL;
  2019. else
  2020. return location.origin + '/' + adjustedPL;
  2021. };
  2022.  
  2023. var copyToClipboard = function(str) {
  2024. var $temp = $('<input>');
  2025. $('body').append($temp);
  2026. $temp.val(str).select();
  2027. document.execCommand('copy');
  2028. $temp.remove();
  2029. };
  2030.  
  2031. function buildItemList(itemNumber){
  2032.  
  2033. var $places = $("<div>");
  2034. $places.html([
  2035. '<select id="pieItem' + itemNumber + '">',
  2036. '<option value="CAR_SERVICES" data-icon="waze-icon-place-car" style="font-weight:bold;">' + I18n.translations[I18n.currentLocale()].venues.categories.CAR_SERVICES + '</option>',
  2037. '<option value="GAS_STATION" data-icon="waze-icon-place-car">' + I18n.translations[I18n.currentLocale()].venues.categories.GAS_STATION + '</option>',
  2038. '<option value="GARAGE_AUTOMOTIVE_SHOP" data-icon="waze-icon-place-car">' + I18n.translations[I18n.currentLocale()].venues.categories.GARAGE_AUTOMOTIVE_SHOP + '</option>',
  2039. '<option value="CAR_WASH" data-icon="waze-icon-place-car">' + I18n.translations[I18n.currentLocale()].venues.categories.CAR_WASH + '</option>',
  2040. '<option value="CHARGING_STATION" data-icon="waze-icon-place-car">' + I18n.translations[I18n.currentLocale()].venues.categories.CHARGING_STATION + '</option>',
  2041. '<option value="TRANSPORTATION" data-icon="waze-icon-place-transportation" style="font-weight:bold;">' + I18n.translations[I18n.currentLocale()].venues.categories.TRANSPORTATION + '</option>',
  2042. '<option value="AIRPORT" data-icon="waze-icon-place-transportation">' + I18n.translations[I18n.currentLocale()].venues.categories.AIRPORT + '</option>',
  2043. '<option value="BUS_STATION" data-icon="waze-icon-place-transportation">' + I18n.translations[I18n.currentLocale()].venues.categories.BUS_STATION + '</option>',
  2044. '<option value="FERRY_PIER" data-icon="waze-icon-place-transportation">' + I18n.translations[I18n.currentLocale()].venues.categories.FERRY_PIER + '</option>',
  2045. '<option value="SEAPORT_MARINA_HARBOR" data-icon="waze-icon-place-transportation">' + I18n.translations[I18n.currentLocale()].venues.categories.SEAPORT_MARINA_HARBOR + '</option>',
  2046. '<option value="SUBWAY_STATION" data-icon="waze-icon-place-transportation">' + I18n.translations[I18n.currentLocale()].venues.categories.SUBWAY_STATION + '</option>',
  2047. '<option value="TRAIN_STATION" data-icon="waze-icon-place-transportation">' + I18n.translations[I18n.currentLocale()].venues.categories.TRAIN_STATION + '</option>',
  2048. '<option value="BRIDGE" data-icon="waze-icon-place-transportation">' + I18n.translations[I18n.currentLocale()].venues.categories.BRIDGE + '</option>',
  2049. '<option value="TUNNEL" data-icon="waze-icon-place-transportation">' + I18n.translations[I18n.currentLocale()].venues.categories.TUNNEL + '</option>',
  2050. '<option value="TAXI_STATION" data-icon="waze-icon-place-transportation">' + I18n.translations[I18n.currentLocale()].venues.categories.TAXI_STATION + '</option>',
  2051. '<option value="JUNCTION_INTERCHANGE" data-icon="waze-icon-place-transportation">' + I18n.translations[I18n.currentLocale()].venues.categories.JUNCTION_INTERCHANGE + '</option>',
  2052. '<option value="PROFESSIONAL_AND_PUBLIC" data-icon="waze-icon-place-professional" style="font-weight:bold;">' + I18n.translations[I18n.currentLocale()].venues.categories.PROFESSIONAL_AND_PUBLIC + '</option>',
  2053. '<option value="COLLEGE_UNIVERSITY" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.COLLEGE_UNIVERSITY + '</option>',
  2054. '<option value="SCHOOL" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.SCHOOL + '</option>',
  2055. '<option value="CONVENTIONS_EVENT_CENTER" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.CONVENTIONS_EVENT_CENTER + '</option>',
  2056. '<option value="GOVERNMENT" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.GOVERNMENT + '</option>',
  2057. '<option value="LIBRARY" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.LIBRARY + '</option>',
  2058. '<option value="CITY_HALL" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.CITY_HALL + '</option>',
  2059. '<option value="ORGANIZATION_OR_ASSOCIATION" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.ORGANIZATION_OR_ASSOCIATION + '</option>',
  2060. '<option value="PRISON_CORRECTIONAL_FACILITY" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.PRISON_CORRECTIONAL_FACILITY + '</option>',
  2061. '<option value="COURTHOUSE" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.COURTHOUSE + '</option>',
  2062. '<option value="CEMETERY" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.CEMETERY + '</option>',
  2063. '<option value="FIRE_DEPARTMENT" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.FIRE_DEPARTMENT + '</option>',
  2064. '<option value="POLICE_STATION" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.POLICE_STATION + '</option>',
  2065. '<option value="MILITARY" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.MILITARY + '</option>',
  2066. '<option value="HOSPITAL_URGENT_CARE" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.HOSPITAL_URGENT_CARE + '</option>',
  2067. '<option value="DOCTOR_CLINIC" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.DOCTOR_CLINIC + '</option>',
  2068. '<option value="OFFICES" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.OFFICES + '</option>',
  2069. '<option value="POST_OFFICE" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.POST_OFFICE + '</option>',
  2070. '<option value="RELIGIOUS_CENTER" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.RELIGIOUS_CENTER + '</option>',
  2071. '<option value="KINDERGARTEN" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.KINDERGARDEN + '</option>',
  2072. '<option value="FACTORY_INDUSTRIAL" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.FACTORY_INDUSTRIAL + '</option>',
  2073. '<option value="EMBASSY_CONSULATE" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.EMBASSY_CONSULATE + '</option>',
  2074. '<option value="INFORMATION_POINT" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.INFORMATION_POINT + '</option>',
  2075. '<option value="EMERGENCY_SHELTER" data-icon="waze-icon-place-professional">' + I18n.translations[I18n.currentLocale()].venues.categories.EMERGENCY_SHELTER + '</option>',
  2076. '<option value="SHOPPING_AND_SERVICES" data-icon="waze-icon-place-shopping" style="font-weight:bold;">' + I18n.translations[I18n.currentLocale()].venues.categories.SHOPPING_AND_SERVICES + '</option>',
  2077. '<option value="ARTS_AND_CRAFTS" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.ARTS_AND_CRAFTS + '</option>',
  2078. '<option value="BANK_FINANCIAL" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.BANK_FINANCIAL + '</option>',
  2079. '<option value="SPORTING_GOODS" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.SPORTING_GOODS + '</option>',
  2080. '<option value="BOOKSTORE" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.BOOKSTORE + '</option>',
  2081. '<option value="PHOTOGRAPHY" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.PHOTOGRAPHY + '</option>',
  2082. '<option value="CAR_DEALERSHIP" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.CAR_DEALERSHIP + '</option>',
  2083. '<option value="FASHION_AND_CLOTHING" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.FASHION_AND_CLOTHING + '</option>',
  2084. '<option value="CONVENIENCE_STORE" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.CONVENIENCE_STORE + '</option>',
  2085. '<option value="PERSONAL_CARE" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.PERSONAL_CARE + '</option>',
  2086. '<option value="DEPARTMENT_STORE" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.DEPARTMENT_STORE + '</option>',
  2087. '<option value="PHARMACY" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.PHARMACY + '</option>',
  2088. '<option value="ELECTRONICS" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.ELECTRONICS + '</option>',
  2089. '<option value="FLOWERS" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.FLOWERS + '</option>',
  2090. '<option value="FURNITURE_HOME_STORE" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.FURNITURE_HOME_STORE + '</option>',
  2091. '<option value="GIFTS" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.GIFTS + '</option>',
  2092. '<option value="GYM_FITNESS" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.GYM_FITNESS + '</option>',
  2093. '<option value="SWIMMING_POOL" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.SWIMMING_POOL + '</option>',
  2094. '<option value="HARDWARE_STORE" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.HARDWARE_STORE + '</option>',
  2095. '<option value="MARKET" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.MARKET + '</option>',
  2096. '<option value="SUPERMARKET_GROCERY" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.SUPERMARKET_GROCERY + '</option>',
  2097. '<option value="JEWELRY" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.JEWELRY + '</option>',
  2098. '<option value="LAUNDRY_DRY_CLEAN" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.LAUNDRY_DRY_CLEAN + '</option>',
  2099. '<option value="SHOPPING_CENTER" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.SHOPPING_CENTER + '</option>',
  2100. '<option value="MUSIC_STORE" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.MUSIC_STORE + '</option>',
  2101. '<option value="PET_STORE_VETERINARIAN_SERVICES" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.PET_STORE_VETERINARIAN_SERVICES + '</option>',
  2102. '<option value="TOY_STORE" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.TOY_STORE + '</option>',
  2103. '<option value="TRAVEL_AGENCY" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.TRAVEL_AGENCY + '</option>',
  2104. '<option value="ATM" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.ATM + '</option>',
  2105. '<option value="CURRENCY_EXCHANGE" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.CURRENCY_EXCHANGE + '</option>',
  2106. '<option value="CAR_RENTAL" data-icon="waze-icon-place-shopping">' + I18n.translations[I18n.currentLocale()].venues.categories.CAR_RENTAL + '</option>',
  2107. '<option value="FOOD_AND_DRINK" data-icon="waze-icon-place-food-drink" style="font-weight:bold;">' + I18n.translations[I18n.currentLocale()].venues.categories.FOOD_AND_DRINK + '</option>',
  2108. '<option value="RESTAURANT" data-icon="waze-icon-place-food-drink">' + I18n.translations[I18n.currentLocale()].venues.categories.RESTAURANT + '</option>',
  2109. '<option value="BAKERY" data-icon="waze-icon-place-food-drink">' + I18n.translations[I18n.currentLocale()].venues.categories.BAKERY + '</option>',
  2110. '<option value="DESSERT" data-icon="waze-icon-place-food-drink">' + I18n.translations[I18n.currentLocale()].venues.categories.DESSERT + '</option>',
  2111. '<option value="CAFE" data-icon="waze-icon-place-food-drink">' + I18n.translations[I18n.currentLocale()].venues.categories.CAFE + '</option>',
  2112. '<option value="FAST_FOOD" data-icon="waze-icon-place-food-drink">' + I18n.translations[I18n.currentLocale()].venues.categories.FAST_FOOD + '</option>',
  2113. '<option value="FOOD_COURT" data-icon="waze-icon-place-food-drink">' + I18n.translations[I18n.currentLocale()].venues.categories.FOOD_COURT + '</option>',
  2114. '<option value="BAR" data-icon="waze-icon-place-food-drink">' + I18n.translations[I18n.currentLocale()].venues.categories.BAR + '</option>',
  2115. '<option value="ICE_CREAM" data-icon="waze-icon-place-food-drink">' + I18n.translations[I18n.currentLocale()].venues.categories.ICE_CREAM + '</option>',
  2116. '<option value="CULTURE_AND_ENTERTAINEMENT" data-icon="waze-icon-place-culture" style="font-weight:bold;">' + I18n.translations[I18n.currentLocale()].venues.categories.CULTURE_AND_ENTERTAINEMENT + '</option>',
  2117. '<option value="ART_GALLERY" data-icon="waze-icon-place-culture">' + I18n.translations[I18n.currentLocale()].venues.categories.ART_GALLERY + '</option>',
  2118. '<option value="CASINO" data-icon="waze-icon-place-culture">' + I18n.translations[I18n.currentLocale()].venues.categories.CASINO + '</option>',
  2119. '<option value="CLUB" data-icon="waze-icon-place-culture">' + I18n.translations[I18n.currentLocale()].venues.categories.CLUB + '</option>',
  2120. '<option value="TOURIST_ATTRACTION_HISTORIC_SITE" data-icon="waze-icon-place-culture">' + I18n.translations[I18n.currentLocale()].venues.categories.TOURIST_ATTRACTION_HISTORIC_SITE + '</option>',
  2121. '<option value="MOVIE_THEATER" data-icon="waze-icon-place-culture">' + I18n.translations[I18n.currentLocale()].venues.categories.MOVIE_THEATER + '</option>',
  2122. '<option value="MUSEUM" data-icon="waze-icon-place-culture">' + I18n.translations[I18n.currentLocale()].venues.categories.MUSEUM + '</option>',
  2123. '<option value="MUSIC_VENUE" data-icon="waze-icon-place-culture">' + I18n.translations[I18n.currentLocale()].venues.categories.MUSIC_VENUE + '</option>',
  2124. '<option value="PERFORMING_ARTS_VENUE" data-icon="waze-icon-place-culture">' + I18n.translations[I18n.currentLocale()].venues.categories.PERFORMING_ARTS_VENUE + '</option>',
  2125. '<option value="GAME_CLUB" data-icon="waze-icon-place-culture">' + I18n.translations[I18n.currentLocale()].venues.categories.GAME_CLUB + '</option>',
  2126. '<option value="STADIUM_ARENA" data-icon="waze-icon-place-culture">' + I18n.translations[I18n.currentLocale()].venues.categories.STADIUM_ARENA + '</option>',
  2127. '<option value="THEME_PARK" data-icon="waze-icon-place-culture">' + I18n.translations[I18n.currentLocale()].venues.categories.THEME_PARK + '</option>',
  2128. '<option value="ZOO_AQUARIUM" data-icon="waze-icon-place-culture">' + I18n.translations[I18n.currentLocale()].venues.categories.ZOO_AQUARIUM + '</option>',
  2129. '<option value="RACING_TRACK" data-icon="waze-icon-place-culture">' + I18n.translations[I18n.currentLocale()].venues.categories.RACING_TRACK + '</option>',
  2130. '<option value="THEATER" data-icon="waze-icon-place-culture">' + I18n.translations[I18n.currentLocale()].venues.categories.THEATER + '</option>',
  2131. '<option value="OTHER" data-icon="waze-icon-place" style="font-weight:bold;">' + I18n.translations[I18n.currentLocale()].venues.categories.OTHER + '</option>',
  2132. '<option value="CONSTRUCTION_SITE" data-icon="">' + I18n.translations[I18n.currentLocale()].venues.categories.CONSTRUCTION_SITE + '</option>',
  2133. '<option value="LODGING" data-icon="waze-icon-place-lodging" style="font-weight:bold;">' + I18n.translations[I18n.currentLocale()].venues.categories.LODGING + '</option>',
  2134. '<option value="HOTEL" data-icon="waze-icon-place-lodging">' + I18n.translations[I18n.currentLocale()].venues.categories.HOTEL + '</option>',
  2135. '<option value="HOSTEL" data-icon="waze-icon-place-lodging">' + I18n.translations[I18n.currentLocale()].venues.categories.HOSTEL + '</option>',
  2136. '<option value="CAMPING_TRAILER_PARK" data-icon="waze-icon-place-lodging">' + I18n.translations[I18n.currentLocale()].venues.categories.CAMPING_TRAILER_PARK + '</option>',
  2137. '<option value="COTTAGE_CABIN" data-icon="waze-icon-place-lodging">' + I18n.translations[I18n.currentLocale()].venues.categories.COTTAGE_CABIN + '</option>',
  2138. '<option value="BED_AND_BREAKFAST" data-icon="waze-icon-place-lodging">' + I18n.translations[I18n.currentLocale()].venues.categories.BED_AND_BREAKFAST + '</option>',
  2139. '<option value="OUTDOORS" data-icon="waze-icon-place-outdoors" style="font-weight:bold;">' + I18n.translations[I18n.currentLocale()].venues.categories.OUTDOORS + '</option>',
  2140. '<option value="PARK" data-icon="waze-icon-place-outdoors">' + I18n.translations[I18n.currentLocale()].venues.categories.PARK + '</option>',
  2141. '<option value="PLAYGROUND" data-icon="waze-icon-place-outdoors">' + I18n.translations[I18n.currentLocale()].venues.categories.PLAYGROUND + '</option>',
  2142. '<option value="BEACH" data-icon="waze-icon-place-outdoors">' + I18n.translations[I18n.currentLocale()].venues.categories.BEACH + '</option>',
  2143. '<option value="SPORTS_COURT" data-icon="waze-icon-place-outdoors">' + I18n.translations[I18n.currentLocale()].venues.categories.SPORTS_COURT + '</option>',
  2144. '<option value="GOLF_COURSE" data-icon="waze-icon-place-outdoors">' + I18n.translations[I18n.currentLocale()].venues.categories.GOLF_COURSE + '</option>',
  2145. '<option value="PLAZA" data-icon="waze-icon-place-outdoors">' + I18n.translations[I18n.currentLocale()].venues.categories.PLAZA + '</option>',
  2146. '<option value="PROMENADE" data-icon="waze-icon-place-outdoors">' + I18n.translations[I18n.currentLocale()].venues.categories.PROMENADE + '</option>',
  2147. '<option value="POOL" data-icon="waze-icon-place-outdoors">' + I18n.translations[I18n.currentLocale()].venues.categories.POOL + '</option>',
  2148. '<option value="SCENIC_LOOKOUT_VIEWPOINT" data-icon="waze-icon-place-outdoors">' + I18n.translations[I18n.currentLocale()].venues.categories.SCENIC_LOOKOUT_VIEWPOINT + '</option>',
  2149. '<option value="SKI_AREA" data-icon="waze-icon-place-outdoors">' + I18n.translations[I18n.currentLocale()].venues.categories.SKI_AREA + '</option>',
  2150. '<option value="NATURAL_FEATURES" data-icon="waze-icon-place-natural" style="font-weight:bold;">' + I18n.translations[I18n.currentLocale()].venues.categories.NATURAL_FEATURES + '</option>',
  2151. '<option value="ISLAND" data-icon="waze-icon-place-natural">' + I18n.translations[I18n.currentLocale()].venues.categories.ISLAND + '</option>',
  2152. '<option value="SEA_LAKE_POOL" data-icon="waze-icon-place-natural">' + I18n.translations[I18n.currentLocale()].venues.categories.SEA_LAKE_POOL + '</option>',
  2153. '<option value="RIVER_STREAM" data-icon="waze-icon-place-natural">' + I18n.translations[I18n.currentLocale()].venues.categories.RIVER_STREAM + '</option>',
  2154. '<option value="FOREST_GROVE" data-icon="waze-icon-place-natural">' + I18n.translations[I18n.currentLocale()].venues.categories.FOREST_GROVE + '</option>',
  2155. '<option value="FARM" data-icon="waze-icon-place-natural">' + I18n.translations[I18n.currentLocale()].venues.categories.FARM + '</option>',
  2156. '<option value="CANAL" data-icon="waze-icon-place-natural">' + I18n.translations[I18n.currentLocale()].venues.categories.CANAL + '</option>',
  2157. '<option value="SWAMP_MARSH" data-icon="waze-icon-place-natural">' + I18n.translations[I18n.currentLocale()].venues.categories.SWAMP_MARSH + '</option>',
  2158. '<option value="DAM" data-icon="waze-icon-place-natural">' + I18n.translations[I18n.currentLocale()].venues.categories.DAM + '</option>',
  2159. '<option value="PARKING_LOT" style="font-weight:bold;">' + I18n.translations[I18n.currentLocale()].venues.categories.PARKING_LOT + '</option>',
  2160. '<option value="RESIDENCE_HOME" data-icon="waze-icon-house" style="font-weight:bold;">' + I18n.translations[I18n.currentLocale()].venues.categories.RESIDENCE_HOME + '</option>',
  2161. '</select>'
  2162. ].join(' '));
  2163.  
  2164. return $places.html();
  2165. }
  2166.  
  2167. function injectCss() {
  2168. var css = [
  2169. // Lock button formatting
  2170. '.btn-lh {cursor:pointer;padding:1px 6px;height:22px;border:solid 1px #c1c1c1;margin-right:3px;}',
  2171. '.btn.btn-lh.btn-lh-selected {background-color:#6999ae;color:white}',
  2172. '.btn.btn-lh.btn-lh-selected:hover {color:white}',
  2173. '.btn.btn-lh.disabled {color:#909090;background-color:#f7f7f7;}',
  2174. '.btn.btn-lh.btn-lh-selected.disabled {color:white;background-color:#6999ae;}',
  2175. //Settings Panel
  2176. '#sidebar .controls-container.pie-controls-container {padding: 0px;}',
  2177. '.select2-choices {-webkit-animation-name: oldCategoryDetected; -webkit-animation-duration: 10s; -webkit-animation-iteration-count: 0; animation-name: oldCategoryDetected; animation-duration: 3s; animation-iteration-count: 0;}',
  2178. //'@keyframes oldCategoryDetected {0% {border-color:rgb(204, 204, 204); border-width:3px;} 50% {border-color:red; border-width:3px;} 100% {border-color:rgb(204, 204, 204); border-width:3px;}}',
  2179. //Image Dialog Enhancement
  2180. '.imgcon {position:relative; margin:0 auto;}',
  2181. '.imnav {color: #ffffff; margin:0 auto; opacity:0.7; display:none; position:absolute; top:0; left:0px; width:100%; height:89%;}',
  2182. '.imgcon:hover .imnav{display:inline-block;}',
  2183. '.control {float:left; height:100%; width:33%; opacity:0;}',
  2184. '.control:hover {opacity:0.7;}',
  2185. '.prim {width:15%; background:url("http://i59.tinypic.com/294s94i.gif")left center no-repeat;}',
  2186. '.zmim {width:70%;}',
  2187. '.neim {width:15%; background:url("http://i62.tinypic.com/2cqfqxf.gif")right center no-repeat;}',
  2188. //PSE
  2189. '.PSESelected {border: 3px solid #ee9900;}'
  2190.  
  2191. ].join(' ');
  2192. $('<style type="text/css">' + css + '</style>').appendTo('head');
  2193. }
  2194.  
  2195. function injectCSSWithID(id, css){
  2196. $('<style type="text/css" id=' + id + '>' + css + '</style>').appendTo('head');
  2197. }
  2198.  
  2199. function loadSettings() {
  2200. var loadedSettings = $.parseJSON(localStorage.getItem("WMEPIE_Settings"));
  2201. var defaultSettings = {
  2202. ShowAreaPlaceSize: false,
  2203. ShowAreaPlaceSizeImperial: false,
  2204. ShowAreaPlaceSizeMetric: false,
  2205. ShowLockButtonsRPP: true,
  2206. NewPlacesList: W.Config.venues.categories.clone(),
  2207. EditRPPAfterCreated: false,
  2208. UseStreetFromClosestSeg: false,
  2209. UseCityFromClosestSeg: false,
  2210. ShowPlaceLocatorCrosshair: false,
  2211. PlaceZoom: 6,
  2212. DefaultLockLevel: 0,
  2213. CreateResidentialPlaceShortcut: "A+r",
  2214. CreateParkingLotShortcut: "A+p",
  2215. UseAltCity: false,
  2216. ShowSearchButton: false,
  2217. AddPlaceCategoriesButtons: false,
  2218. SkipPLR: false,
  2219. ShowParkingLotButton: false,
  2220. ShowPlaceNames: false,
  2221. ShowPlaceNamesPoint: false,
  2222. ShowPlaceNamesArea: false,
  2223. ShowPlaceNamesLock: false,
  2224. ShowCopyPlaceButton: false,
  2225. ShowExternalProviderTooltip: false,
  2226. ShowPlaceNamesPLA: false,
  2227. ClearDescription: true,
  2228. PlaceNameFontSize: "12",
  2229. PlaceNameFontOutlineWidth: 3,
  2230. PlaceNameFontBold: true,
  2231. PlaceNameFontColor: "#FFFFFF",
  2232. PlaceNameFontOutline: "#000000",
  2233. PlaceLocatorCrosshairProdPL: true,
  2234. MoveAddress: false,
  2235. MoveHNEntry: true,
  2236. PLNormalSpotWidth: 3.44,
  2237. PLAngledSpotWidth: 3,
  2238. ShowPLSpotEstimatorButton: false,
  2239. ShowNavPointClosestSegmentOnHover: true,
  2240. ShowClosestSegmentSelected: false
  2241. };
  2242. settings = loadedSettings ? loadedSettings : defaultSettings;
  2243. for (var prop in defaultSettings) {
  2244. if (!settings.hasOwnProperty(prop))
  2245. settings[prop] = defaultSettings[prop];
  2246. }
  2247.  
  2248. if(settings.ShowAreaPlaceSizeImperial === false && settings.ShowAreaPlaceSizeMetric === false)
  2249. if(Waze.prefs.attributes.isImperial)
  2250. settings.ShowAreaPlaceSizeImperial = true;
  2251. else
  2252. settings.ShowAreaPlaceSizeMetric = true;
  2253. }
  2254.  
  2255. function saveSettings() {
  2256. if (localStorage) {
  2257. var localsettings = {
  2258. ShowAreaPlaceSize: settings.ShowAreaPlaceSize,
  2259. ShowAreaPlaceSizeImperial: settings.ShowAreaPlaceSizeImperial,
  2260. ShowAreaPlaceSizeMetric: settings.ShowAreaPlaceSizeMetric,
  2261. ShowLockButtonsRPP: settings.ShowLockButtonsRPP,
  2262. NewPlacesList: settings.NewPlacesList,
  2263. EditRPPAfterCreated: settings.EditRPPAfterCreated,
  2264. UseStreetFromClosestSeg: settings.UseStreetFromClosestSeg,
  2265. UseCityFromClosestSeg: settings.UseCityFromClosestSeg,
  2266. ShowPlaceLocatorCrosshair: settings.ShowPlaceLocatorCrosshair,
  2267. PlaceZoom: settings.PlaceZoom,
  2268. DefaultLockLevel: settings.DefaultLockLevel,
  2269. CreateResidentialPlaceShortcut: settings.CreateResidentialPlaceShortcut,
  2270. CreateParkingLotShortcut: settings.CreateParkingLotShortcut,
  2271. UseAltCity: settings.UseAltCity,
  2272. ShowSearchButton: settings.ShowSearchButton,
  2273. AddPlaceCategoriesButtons: settings.AddPlaceCategoriesButtons,
  2274. SkipPLR: settings.SkipPLR,
  2275. ShowParkingLotButton: settings.ShowParkingLotButton,
  2276. ShowPlaceNames: settings.ShowPlaceNames,
  2277. ShowPlaceNamesPoint: settings.ShowPlaceNamesPoint,
  2278. ShowPlaceNamesArea: settings.ShowPlaceNamesArea,
  2279. ShowPlaceNamesLock: settings.ShowPlaceNamesLock,
  2280. ShowCopyPlaceButton: settings.ShowCopyPlaceButton,
  2281. ShowExternalProviderTooltip: settings.ShowExternalProviderTooltip,
  2282. ShowPlaceNamesPLA: settings.ShowPlaceNamesPLA,
  2283. ClearDescription: settings.ClearDescription,
  2284. PlaceNameFontSize: settings.PlaceNameFontSize,
  2285. PlaceNameFontOutlineWidth: settings.PlaceNameFontOutlineWidth,
  2286. PlaceNameFontBold: settings.PlaceNameFontBold,
  2287. PlaceNameFontColor: settings.PlaceNameFontColor,
  2288. PlaceNameFontOutline: settings.PlaceNameFontOutline,
  2289. PlaceLocatorCrosshairProdPL: settings.PlaceLocatorCrosshairProdPL,
  2290. MoveAddress: settings.MoveAddress,
  2291. MoveHNEntry: settings.MoveHNEntry,
  2292. PLNormalSpotWidth: settings.PLNormalSpotWidth,
  2293. PLAngledSpotWidth: settings.PLAngledSpotWidth,
  2294. ShowPLSpotEstimatorButton: settings.ShowPLSpotEstimatorButton,
  2295. ShowNavPointClosestSegmentOnHover: settings.ShowNavPointClosestSegmentOnHover,
  2296. ShowClosestSegmentSelected: settings.ShowClosestSegmentSelected
  2297. };
  2298.  
  2299. for (var name in Waze.accelerators.Actions) {
  2300. var TempKeys = "";
  2301. if (Waze.accelerators.Actions[name].group == 'wmepie') {
  2302. if (Waze.accelerators.Actions[name].shortcut) {
  2303. if (Waze.accelerators.Actions[name].shortcut.altKey === true) {
  2304. TempKeys += 'A';
  2305. }
  2306. if (Waze.accelerators.Actions[name].shortcut.shiftKey === true) {
  2307. TempKeys += 'S';
  2308. }
  2309. if (Waze.accelerators.Actions[name].shortcut.ctrlKey === true) {
  2310. TempKeys += 'C';
  2311. }
  2312. if (TempKeys !== "") {
  2313. TempKeys += '+';
  2314. }
  2315. if (Waze.accelerators.Actions[name].shortcut.keyCode) {
  2316. TempKeys += Waze.accelerators.Actions[name].shortcut.keyCode;
  2317. }
  2318. } else {
  2319. TempKeys = "-1";
  2320. }
  2321. localsettings[name] = TempKeys;
  2322. }
  2323. }
  2324.  
  2325. localStorage.setItem("WMEPIE_Settings", JSON.stringify(localsettings));
  2326. }
  2327. }
  2328.  
  2329. function loadTranslations() {
  2330. setTranslations({
  2331. en: {
  2332. prefs: {
  2333. title: 'Place Interface Enhancements',
  2334. ShowAreaPlaceSize: 'Show area Place size',
  2335. ShowImperial: 'Show imperial',
  2336. ShowMetric: 'Show metric',
  2337. ShowRPPLockButtons: 'Show lock buttons for RPPs',
  2338. ShowRPPLockButtonsTitle: 'Displays lock level buttons for Residential Place Points',
  2339. ShowPlaceLocatorCrosshair: 'Show Place locator crosshair',
  2340. ShowPlaceLocatorCrosshairTitle: 'Centers the Place on screen and zooms to the defined level',
  2341. Zoom: 'Zoom',
  2342. ZoomTitle: 'The zoom level to use when centering on a Place',
  2343. ShowAddressSearch: 'Show search button next to address',
  2344. ShowAddressSearchTitle: "Show a magnifying glass next to the Place's address. Clicking this button will load the address into the search box",
  2345. ShowPlaceCategoryButtons: 'Add Place category buttons above the categories selection',
  2346. ShowPLAButton: 'Show parking lot button',
  2347. ShowPLAButtonTitle: "Starts creation mode for a Parking Lot Area Place and will set the name to match this Place\'s name when complete",
  2348. ShowCopyPlaceButton: 'Show copy Place button',
  2349. ShowCopyPlaceButtonTitle: 'Copies the selected Place to a new Place with identical settings',
  2350. ShowGPIDTooltip: 'Show External Provider tooltip',
  2351. ShowGPIDTooltipTitle: 'Displays a tooltip with the external provider information',
  2352. NewPlaces: 'New Places',
  2353. EditRPPAfterCreate: 'Edit RPP address after created',
  2354. EditRPPAfterCreateTitle: "Automatically opens the RPP address edit window and focuses on the House Number entry",
  2355. UseStreetFromClosestSegment: 'Use street name from closest segment',
  2356. UseStreetFromClosestSegmentTitle: "Pulls the street name from the closest visible segment and inserts into the new Place's address",
  2357. UseCityFromClosestSegment: 'Use city name from closest segment',
  2358. UseCityFromClosestSegmentTitle: "Pulls the city name from the closest visible segment and inserts into the new Place's address",
  2359. ClosestSegmentAltCity: 'When the primary is "No city" look for an alt city',
  2360. ClosestSegmentAltCityTitle: 'When the primary is \'No city\' try to find an alt street name with a city',
  2361. ClosestSegmentIgnorePLRUnnamedPR: "Ignore PLRs & unnamed PR when using closest segment's name and city",
  2362. ClosestSegmentIgnorePLRUnnamedPRTitle: "When looking for the closest segment, PLRs and unnamed PRs will be ignored",
  2363. LockLevel: 'Lock level',
  2364. LockLevelTitle: 'The lock level to set automatically when creating new Places',
  2365. MapChanges: 'Map Changes',
  2366. ShowPlaceNames: 'Show Place names',
  2367. ShowPlaceNamesTitle: '',
  2368. ShowPointNames: 'Show point names',
  2369. ShowPointNamesTitle: "Will display the Place's name below the Place point",
  2370. ShowAreaNames: 'Show area names',
  2371. ShowAreaNamesTitle: "Will display the Place's name in the middle of the Place area",
  2372. ShowLockLevel: 'Show lock level',
  2373. ShowLockLevelTitle: "Will display the Place's lock level in the middle of the Place area",
  2374. ShowPLAName: 'Show PLA name',
  2375. ShowPLANameTitle: '',
  2376. Item: 'Item',
  2377. PlaceMenuCustomization: "Place Menu Customization",
  2378. ClearDescription: "Show clear description button",
  2379. ClearDescriptionTitle: "Adds a clear button to the top right of the description entry that when clicked will clear all text in the entry field",
  2380. PropertiesPanel: "Properties Panel",
  2381. FontSize: "Font size",
  2382. FontColor: "Font color",
  2383. Bold: "Bold",
  2384. FontOutlineColor: "Font outline color",
  2385. FontOutlineWidth: "Font outline width",
  2386. ProdPL: "Force production PL",
  2387. MoveAddress: "Move address to top of panel",
  2388. MoveAddressTitle: "Moves the address editor to the top of the properties panel",
  2389. MoveHNEntry: "Move HN entry before street entry",
  2390. MoveHNEntryTitle: "Moves the House Number entry before the Street entry in the address editor",
  2391. ShowParkingSpaceEstimatorTool: "Show Parking Space Estimator tool",
  2392. ShowParkingSpaceEstimatorToolTitle: "Shows the button to launch the Parking Space Estimator tool",
  2393. PSEParkingSpaceEstimator: "Parking Space Estimator",
  2394. PSELayoutType: "Layout type",
  2395. PSE90degree: "90 degree",
  2396. PSEAngled: "Angled",
  2397. PSEEstimatedNumOfSpots: "Estimated # of spots: ",
  2398. PSESet: "Set",
  2399. PSESpotWidth: "Spot width (m)",
  2400. PSECal: "Cal",
  2401. PSEDraw90DegreeTitle: "Click to draw a line through an entire 90 degree parking space aisle. Double click to finish drawing and measure the spaces.",
  2402. PSEDrawAngledTitle: "Click to draw a line through an entire angled parking space aisle. Double click to finish drawing and measure the spaces.",
  2403. PSEShowPSEButton: "Show Parking Space Estimator tool button",
  2404. PSEShowPSEButtonTitle: "Shows the button to launch the Parking Space Estimator tool",
  2405. PSEDisplayButtonTitle: "Opens the Parking Space Estimator tool",
  2406. ShowNavPointClosestSegmentOnHover: "Display the nav point and closest segment line on hover",
  2407. ShowClosestSegmentSelected: "Display a line from the nav point to the point on the closest segment"
  2408. }
  2409. },
  2410. "es-419": {
  2411. prefs: {
  2412. title: 'Place Interface Enhancements',
  2413. ShowAreaPlaceSize: 'Mostrar tamaño del área',
  2414. ShowImperial: 'Sistema Imperial',
  2415. ShowMetric: 'Sistema Métrico',
  2416. ShowRPPLockButtons: 'Mostrar botones de bloqueo para RPPs',
  2417. ShowRPPLockButtonsTitle: 'Muestra los botones de nivel de bloqueo para lugares residenciales',
  2418. ShowPlaceLocatorCrosshair: 'Mostrar reticula localizadora del lugar',
  2419. ShowPlaceLocatorCrosshairTitle: 'Centra el lugar en la pantalla y acercamiento al nivel definido',
  2420. Zoom: 'Acercamiento',
  2421. ZoomTitle: 'Nivel de acercamiento a utilizar cuando se centra en un lugar',
  2422. ShowAddressSearch: 'Mostrar el botón de búsqueda junto a la dirección',
  2423. ShowAddressSearchTitle: "Muestra una lupa junto a la dirección del lugar. Al hacer clic en este botón, se cargará la dirección en la barra de búsqueda",
  2424. ShowPlaceCategoryButtons: 'Botones de categorías de lugares',
  2425. ShowPLAButton: 'Mostrar botón de PLAs',
  2426. ShowPLAButtonTitle: 'Inicia el modo de creación de un lugar del área de estacionamiento y establecerá el nombre del estacionamiento para que coincida con el nombre del lugar cuando se complete',
  2427. ShowCopyPlaceButton: 'Mostrar botón de copiado de lugar',
  2428. ShowCopyPlaceButtonTitle: 'Copia el lugar seleccionado en un lugar nuevo con configuraciones idénticas',
  2429. ShowGPIDTooltip: 'Mostrar información del proveedor externo',
  2430. ShowGPIDTooltipTitle: 'Muestra un texto con la información del proveedor externo',
  2431. NewPlaces: 'Nuevos lugares',
  2432. EditRPPAfterCreate: 'Editar la dirección del RPP una vez creada',
  2433. EditRPPAfterCreateTitle: "Automáticamente abre la ventana de edición en la dirección del lugar residencial y se enfoca en el campo de número de casa",
  2434. UseStreetFromClosestSegment: 'Utilizar el nombre de la calle del segmento más cercano',
  2435. UseStreetFromClosestSegmentTitle: "Extrae el nombre de la calle del segmento visible más cercano y lo agrega en la dirección del nuevo lugar",
  2436. UseCityFromClosestSegment: 'Usar el nombre de la ciudad del segmento más cercano',
  2437. UseCityFromClosestSegmentTitle: "Extrae el nombre de la ciudad del segmento visible más cercano y lo agrega en la dirección del nuevo lugar",
  2438. ClosestSegmentAltCity: 'Buscar una ciudad alternativa cuando la ciudad principal sea \'Ninguno\'',
  2439. ClosestSegmentAltCityTitle: 'Cuando la ciudad principal es "Ninguno" trata de encontrar un nombre de calle alternativo con una ciudad',
  2440. ClosestSegmentIgnorePLRUnnamedPR: "Ignorar los PLR y PR sin nombre cuando utilice el nombre y la ciudad del segmento más cercano",
  2441. ClosestSegmentIgnorePLRUnnamedPRTitle: "Ignorar segmentos de estacionamiento o privados al buscar el segmento mas cercano",
  2442. LockLevel: 'Nivel de bloqueo',
  2443. LockLevelTitle: 'El nivel de bloqueo para establecer automáticamente al crear nuevos lugares',
  2444. MapChanges: 'Cambios en el mapa',
  2445. ShowPlaceNames: 'Mostrar nombres de lugares',
  2446. ShowPlaceNamesTitle: '',
  2447. ShowPointNames: 'Mostrar nombres de punto',
  2448. ShowPointNamesTitle: "Muestra el nombre de lugares definidos como punto",
  2449. ShowAreaNames: 'Mostrar nombres de área',
  2450. ShowAreaNamesTitle: "Muestra el nombre de lugares definidos como área",
  2451. ShowLockLevel: 'Mostrar nivel de bloqueo',
  2452. ShowLockLevelTitle: "Muestra el nivel de bloqueo en el centro del lugar",
  2453. ShowPLAName: 'Mostrar nombre de PLA',
  2454. ShowPLANameTitle: 'Muestra el nombre de áreas de estacionamiento (PLAs)',
  2455. Item: 'Opción',
  2456. PlaceMenuCustomization: "Personalización del menú de lugares",
  2457. ClearDescription: "Mostrar botón de borrar descripción",
  2458. ClearDescriptionTitle: "Añade un botón de borrado en la parte superior derecha del campo de descripción que deja vacíos todos los campos",
  2459. PropertiesPanel: "Propiedades del panel",
  2460. FontSize: "Tamaño de letra",
  2461. FontColor: "Color de Letra",
  2462. Bold: "Negrita",
  2463. FontOutlineColor: "Color del contorno de la letra",
  2464. FontOutlineWidth: "Ancho del contorno de la letra",
  2465. ProdPL: "Forzar Permalink de producción",
  2466. MoveAddress: "Move address to top of panel",
  2467. MoveAddressTitle: "Moves the address editor to the top of the properties panel",
  2468. MoveHNEntry: "Move HN entry before street entry",
  2469. MoveHNEntryTitle: "Moves the House Number entry before the Street entry in the address editor",
  2470. ShowParkingSpaceEstimatorTool: "Show Parking Space Estimator tool",
  2471. ShowParkingSpaceEstimatorToolTitle: "Shows the button to launch the Parking Space Estimator tool",
  2472. PSEParkingSpaceEstimator: "Parking Space Estimator",
  2473. PSELayoutType: "Layout type",
  2474. PSE90degree: "90 degree",
  2475. PSEAngled: "Angled",
  2476. PSEEstimatedNumOfSpots: "Estimated # of spots: ",
  2477. PSESet: "Set",
  2478. PSESpotWidth: "Spot width (m)",
  2479. PSECal: "Cal",
  2480. PSEDraw90DegreeTitle: "Click to draw a line through an entire 90 degree parking space aisle. Double click to finish drawing and measure the spaces.",
  2481. PSEDrawAngledTitle: "Click to draw a line through an entire angled parking space aisle. Double click to finish drawing and measure the spaces.",
  2482. PSEShowPSEButton: "Show Parking Space Estimator tool button",
  2483. PSEShowPSEButtonTitle: "Shows the button to launch the Parking Space Estimator tool",
  2484. PSEDisplayButtonTitle: "Opens the Parking Space Estimator tool",
  2485. ShowNavPointClosestSegmentOnHover: "Display the nav point and closest segment line on hover",
  2486. ShowClosestSegmentSelected: "Display a line from the nav point to the point on the closest segment"
  2487. }
  2488. },
  2489. fr: {
  2490. prefs: {
  2491. title: 'Place Interface Enhancements',
  2492. ShowAreaPlaceSize: 'Afficher la tallie de la place',
  2493. ShowImperial: 'Afficher en imperial',
  2494. ShowMetric: 'Afficher en métrique',
  2495. ShowRPPLockButtons: 'Afficher les boutons de lock pour les résidentiels',
  2496. ShowRPPLockButtonsTitle: 'Affiche des boutons pour le niveau de verrouillage des lieux résidentiels',
  2497. ShowPlaceLocatorCrosshair: 'Afficher le repère de localisation du lieu',
  2498. ShowPlaceLocatorCrosshairTitle: "Centre le lieu à l'écran et zoome au niveau défini",
  2499. Zoom: 'Zoom',
  2500. ZoomTitle: "Niveau de zoom utilisé lorsqu'on se centre sur un lieu",
  2501. ShowAddressSearch: "Afficher icône de recherche à côté de l'adresse",
  2502. ShowAddressSearchTitle: "Affiche une loupe à côté de l'adresse du lieu. Cliquer ce bouton chargera l'adresse dans la barre de recherche",
  2503. ShowPlaceCategoryButtons: 'Ajouter des icônes de catégorie au dessus de la sélection de catégories',
  2504. ShowPLAButton: 'Afficher le bouton de création de parking',
  2505. ShowPLAButtonTitle: 'Démarre le mode création de parking pour tracer un parking qui aura le nom du lieu sélectionné',
  2506. ShowCopyPlaceButton: 'Afficher le bouton de clonage de lieu',
  2507. ShowCopyPlaceButtonTitle: 'Clone le lieu sélectionné en nouveau lieu avec les mêmes valeurs',
  2508. ShowGPIDTooltip: 'Afficher en infobulle le fournisseur externe',
  2509. ShowGPIDTooltipTitle: 'Affiche une infobulle avec les informations du fournisseur externe',
  2510. NewPlaces: 'Nouveaux Lieux',
  2511. EditRPPAfterCreate: "Editer l'adresse du résidentiel après création",
  2512. EditRPPAfterCreateTitle: "Ouvre automatiquement la zone d'édition de l'adresse du lieu résidentiel et se positionne sur la saisie du n° de rue",
  2513. UseStreetFromClosestSegment: 'Utiliser le nom de rue du segment le plus proche',
  2514. UseStreetFromClosestSegmentTitle: "Prend le nom de rue du segment visible le plus proche et l'insère dans l'adresse du nouveau lieu",
  2515. UseCityFromClosestSegment: 'Utiliser le nom de ville du segment le plus proche',
  2516. UseCityFromClosestSegmentTitle: "Prend le nom de ville du segment visible le plus proche et l'insère dans l'adresse du nouveau lieu",
  2517. ClosestSegmentAltCity: 'Lorsque le nom principal est «Hors ville» regarder le nom en alt',
  2518. ClosestSegmentAltCityTitle: 'Lorsque le nom principal est «Hors ville» essayer de trouver un nom de rue alternatif avec une ville',
  2519. ClosestSegmentIgnorePLRUnnamedPR: "Ignorer les parkings et voies privées non nommés",
  2520. ClosestSegmentIgnorePLRUnnamedPRTitle: "Lorsque le script regarde le nom du segment visible le plus proche, les parkings et voies privées non nommées seront ignorés",
  2521. LockLevel: 'Verrouillage ',
  2522. LockLevelTitle: 'Le niveau de verrouillage est appliqué automatiquement à la création du lieu',
  2523. MapChanges: 'Changements de carte',
  2524. ShowPlaceNames: 'Afficher le nom des lieux',
  2525. ShowPlaceNamesTitle: '',
  2526. ShowPointNames: 'Afficher le nom des lieux point',
  2527. ShowPointNamesTitle: "Affiche le nom du lieu sous le lieu point",
  2528. ShowAreaNames: 'Afficher le nom des lieux zone',
  2529. ShowAreaNamesTitle: "Affiche le nom du lieu au milieu du lieu zone",
  2530. ShowLockLevel: 'Afficher le niveau de verrouillage',
  2531. ShowLockLevelTitle: "Afficher le niveau de verrouillage du lieu au milieu du lieu zone",
  2532. ShowPLAName: 'Afficher le nom des parkings',
  2533. ShowPLANameTitle: 'Affiche le nom du parking au milieu du lieu zone',
  2534. Item: 'Option',
  2535. PlaceMenuCustomization: "Personnalisation du menu Lieu",
  2536. ClearDescription: "Afficher le bouton «Effacer description»",
  2537. ClearDescriptionTitle: "Ajoute un bouton «Effacer description» en haut à droite de l'entrée de description qui, lorsqu'il est cliqué, effacera tout le texte dans le champ de saisie",
  2538. PropertiesPanel: "Panneau des propriétés",
  2539. FontSize: "Taille de police",
  2540. FontColor: "Couleur de police",
  2541. Bold: "Gras",
  2542. FontOutlineColor: "Couleur surlignage police",
  2543. FontOutlineWidth: "Épaisseur surlignage police",
  2544. ProdPL: "Force production PL",
  2545. MoveAddress: "Déplacer l'adresse en haut du panneau",
  2546. MoveAddressTitle: "Déplace l'édition d'adresse en haut du panneau de propritétés",
  2547. MoveHNEntry: "Placer n° de rue avant nom de rue",
  2548. MoveHNEntryTitle: "Place l'édition du numéro de rue avant le nom de la rue dans l'éditeur d'adresse",
  2549. ShowParkingSpaceEstimatorTool: "Afficher le simulateur de places de stationnement",
  2550. ShowParkingSpaceEstimatorToolTitle: "Affiche un bouton pour lancer le simulateur de places de stationnement",
  2551. PSEParkingSpaceEstimator: "Simulateur places de stationnement",
  2552. PSELayoutType: "Emplacements:",
  2553. PSE90degree: "A 90 degrés",
  2554. PSEAngled: "Inclinés",
  2555. PSEEstimatedNumOfSpots: "Nombre estimé de places: ",
  2556. PSESet: "Set",
  2557. PSESpotWidth: "Largeur place (m)",
  2558. PSECal: "Cal",
  2559. PSEDraw90DegreeTitle: "Cliquez pour dessiner une ligne passant à travers les emplacements de parking à 90°. Double-cliquez pour terminer le tracé et mesurer les espaces.",
  2560. PSEDrawAngledTitle: "Cliquez pour dessiner une ligne passant à travers les emplacements de parking inclinés. Double-cliquez pour terminer le tracé et mesurer les espaces.",
  2561. PSEShowPSEButton: "Afficher le simulateur de places de stationnement",
  2562. PSEShowPSEButtonTitle: "Affiche un bouton pour lancer le simulateur de places de stationnement",
  2563. PSEDisplayButtonTitle: "Ouvre le simulateur de places de stationnement",
  2564. ShowNavPointClosestSegmentOnHover: "Affiche une ligne entre le point d'entrée et le segment le plus proche",
  2565. ShowClosestSegmentSelected: "Display a line from the nav point to the point on the closest segment"
  2566. }
  2567. }
  2568. });
  2569. }
  2570.  
  2571. function setTranslations(translations) {
  2572. I18n.translations[I18n.currentLocale()].pie = translations.en;
  2573. for (var i = 0; i < Object.keys(translations).length; i++) {
  2574. var locale = Object.keys(translations)[i];
  2575. if (I18n.currentLocale() == locale) {
  2576. I18n.translations[locale].pie.prefs = translations[locale].prefs;
  2577. return;
  2578. }
  2579. }
  2580. }
  2581.  
  2582. function listPlaces(){
  2583. var category = "";
  2584. for(i=0; i<W.Config.venues.categories.length; i++){
  2585. category = W.Config.venues.categories[i];
  2586. console.log(category + " Main");
  2587. var subCategories = W.Config.venues.subcategories[category];
  2588. for(var j=0; j<subCategories.length;j++){
  2589. console.log(subCategories[j]);
  2590. }
  2591. }
  2592. }
  2593. })();