diff --git a/WMEPIE.js b/WMEPIE.js index d233d8b..98684fb 100644 --- a/WMEPIE.js +++ b/WMEPIE.js @@ -1,7 +1,7 @@ // ==UserScript== // @name WME Place Interface Enhancements // @namespace https://greasyfork.org/users/30701-justins83-waze -// @version 2017.11.24.01 +// @version 2017.11.27.01 // @description Enhancements to various Place interfaces // @include https://www.waze.com/editor* // @include https://www.waze.com/*/editor* @@ -19,7 +19,7 @@ var UpdateObject, MultiAction; (function() { 'use strict'; - var curr_ver = "2017.11.24.01"; + var curr_ver = "2017.11.27.01"; var settings = {}; 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"; //"#edit-buttons > div > div.toolbar-submenu.toolbar-group.toolbar-group-venues.ItemInactive > menu"; @@ -99,6 +99,13 @@ var UpdateObject, MultiAction; $section.html([ '

' + I18n.t('pie.prefs.title') + '

', '
' + curr_ver + '
', + '
', + '

' + I18n.t('pie.filter.PlaceFilterPanel') + '

', + '
' + I18n.t('pie.filter.filter') + '
', + '
', + '
', + '
', + '
', '

' + I18n.t('pie.prefs.PropertiesPanel') + '

', '
', @@ -570,6 +577,9 @@ var UpdateObject, MultiAction; new WazeWrap.Interface.Shortcut('CreateParkingLotShortcut', 'Creates a parking lot Place', 'wmepie', 'Place Interface Enhancements', settings.CreateParkingLotShortcut, function(){startPlacementMode("PARKING_LOT", false);}, null).add(); new WazeWrap.Interface.Shortcut('HideAreaPlacesShortcut', 'Toggle hiding area Places', 'wmepie', 'Place Interface Enhancements', settings.ToggleAreaPlacesShortcut, ToggleHideAreaPlaces, null).add(); + $("#piePlaceFilter").on("propertychange keyup paste input", UpdatePlaceFilter); + $('input[type=radio][name=PlaceFilterToggle]').change(UpdatePlaceFilter); + window.addEventListener("beforeunload", function() { saveSettings(); @@ -711,6 +721,36 @@ var UpdateObject, MultiAction; wazePL.id = 'wazePermalink'; } + function UpdatePlaceFilter(){ + let index = W.map.landmarkLayer.styleMap.styles.default.rules.findIndex(function(e){ return e.name == "PIEPlaceFilter";}); + if(index > -1) + { + W.map.landmarkLayer.styleMap.styles.default.rules.splice(index, 1); + W.map.landmarkLayer.redraw(); + } + if($('#piePlaceFilter').val().trim() != "") + { + let myRule = new W.Rule({ + filter: new OL.Filter.Comparison({ + type: '==', + evaluate: function(venue) { + debugger; + if($("#_rbHidePlaces").prop("checked")) + return (new RegExp($('#piePlaceFilter').val(), "ig").exec(venue.model.attributes.name)); + else + return !(new RegExp($('#piePlaceFilter').val(), "ig").exec(venue.model.attributes.name)); + } + }), + symbolizer: { + display: 'none' + }, + name: "PIEPlaceFilter" + }); + W.map.landmarkLayer.styleMap.styles['default'].rules.push(myRule); + W.map.landmarkLayer.redraw(); + } + } + function ToggleHideAreaPlaces(){ let index = W.map.landmarkLayer.styleMap.styles.default.rules.findIndex(function(e){ return e.name == "PIEHide";}); if(index === -1) @@ -2598,6 +2638,12 @@ var UpdateObject, MultiAction; ShowClosestSegmentSelected: "Display a line from the nav point to the point on the closest segment", NavLink: "Link nav point", 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" + }, + filter: { + PlaceFilterPanel: 'Place Filtering', + filter: 'Filter', + Hide: 'Hide', + Show: 'Show only' } }, "es-419": { @@ -2679,6 +2725,12 @@ var UpdateObject, MultiAction; ShowClosestSegmentSelected: "Display a line from the nav point to the point on the closest segment", NavLink: "Link nav point", 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" + }, + filter: { + PlaceFilterPanel: 'Place Filtering', + filter: 'Filter', + Hide: 'Hide', + Show: 'Show only' } }, fr: { @@ -2760,6 +2812,12 @@ var UpdateObject, MultiAction; ShowClosestSegmentSelected: "Display a line from the nav point to the point on the closest segment", NavLink: "Link nav point", 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" + }, + filter: { + PlaceFilterPanel: 'Place Filtering', + filter: 'Filter', + Hide: 'Hide', + Show: 'Show only' } } });