WME Place Interface Enhancements

Enhancements to various Place interfaces

目前為 2018-02-22 提交的版本,檢視 最新版本

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