diff --git a/BeenThere.js b/BeenThere.js index 1493b83..7d94099 100644 --- a/BeenThere.js +++ b/BeenThere.js @@ -12,7 +12,7 @@ // @require https://greasyfork.org/scripts/27254-clipboard-js/code/clipboardjs.js // @require https://greasyfork.org/scripts/28687-jquery-ui-1-11-4-custom-min-js/code/jquery-ui-1114customminjs.js // @resource jqUI_CSS https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css -// @version 2019.03.14.01 +// @version 2019.04.10.01 // ==/UserScript== //--------------------------------------------------------------------------------------- @@ -24,24 +24,26 @@ /* global _ */ /* global WazeWrap */ /* global require */ +/* global Clipboard */ /* eslint curly: ["warn", "multi-or-nest"] */ - var beenTheresettings = []; - var attributes = { - name: "" - }; - var layerFuture = []; - var pointStyle = { - pointRadius: 3, - fillOpacity: 50, - strokeColor: '#00ece3', - strokeWidth: '2', - strokeLinecap: 'round' - }; - var clickCount = 0; - var userRectPoint1 = null; - var userCircleCenter = null; - var currColor; +var beenTheresettings = []; +var attributes = { + name: "" +}; +var layerFuture = []; +var pointStyle = { + pointRadius: 3, + fillOpacity: 50, + strokeColor: '#00ece3', + strokeWidth: '2', + strokeLinecap: 'round' +}; +var clickCount = 0; +var userRectPoint1 = null; +var userCircleCenter = null; +var currColor; +const updateMessage = "Introducing groups! It is now possible to create groups for projects and keep your on-screen markings separated per project!

Any existing history will automatically be merged into the 'default' group."; (function() { //var jqUI_CssSrc = GM_getResourceText("jqUI_CSS"); @@ -51,7 +53,7 @@ if (W && W.map && W.model && W.loginManager.user && $ && window.jscolor && - WazeWrap.Ready) + WazeWrap.Ready) init(); else if (tries < 1000) setTimeout(function () {bootstrap(tries++);}, 200); @@ -84,7 +86,7 @@ radius: null }; - beenTheresettings.layerHistory.push(groupPoints2); + beenTheresettings.Groups[beenTheresettings.CurrentGroup].push(groupPoints2); DrawFeature(groupPoints2); } @@ -231,7 +233,7 @@ type : "circle" }; - beenTheresettings.layerHistory.push(circleData); + beenTheresettings.Groups[beenTheresettings.CurrentGroup].push(circleData); saveSettings(); DrawFeature(circleData); EndUserCircleMode(); @@ -266,7 +268,7 @@ color: currColor, type: "rectangle" }; - beenTheresettings.layerHistory.push(groupPoints2); + beenTheresettings.Groups[beenTheresettings.CurrentGroup].push(groupPoints2); saveSettings(); DrawFeature(groupPoints2); EndUserRectMode(); @@ -408,8 +410,8 @@ var mro_mapLayers_mapLayerLength = mro_mapLayers[0].features.length; if (mro_mapLayers_mapLayerLength > 0) mro_mapLayers[0].features[mro_mapLayers_mapLayerLength - 1].destroy(); - if(beenTheresettings.layerHistory.length > 0) - layerFuture.push(beenTheresettings.layerHistory.pop()); + if(beenTheresettings.Groups[beenTheresettings.CurrentGroup].length > 0) + layerFuture.push(beenTheresettings.Groups[beenTheresettings.CurrentGroup].pop()); saveSettings(); updateTotalRectCount(); } @@ -417,13 +419,13 @@ function RedoLastBox(){ if(layerFuture.length >0){ var rect = layerFuture.pop(); - beenTheresettings.layerHistory.push(rect); + beenTheresettings.Groups[beenTheresettings.CurrentGroup].push(rect); DrawFeature(rect); } } function RemoveAllBoxes() { - if(beenTheresettings.layerHistory.length > 0) + if(beenTheresettings.Groups[beenTheresettings.CurrentGroup].length > 0) if(confirm("Clearing all boxes cannot be undone.\nPress OK to clear all boxes.")){ var mro_Map = W.map; var mro_mapLayers = mro_Map.getLayersBy("uniqueName", "__beenThere"); @@ -431,7 +433,7 @@ var mro_mapLayers_mapLayerLength = mro_mapLayers[0].features.length; if (mro_mapLayers_mapLayerLength > 0) mro_mapLayers[0].destroyFeatures(); - beenTheresettings.layerHistory = []; + beenTheresettings.Groups[beenTheresettings.CurrentGroup] = []; layerFuture = []; saveSettings(); updateTotalRectCount(); @@ -483,14 +485,14 @@ '
', '',//close left side container '
', //right side container - '', - '', - '', - '', - '', - '', - '', - '', + '', + '', + '', + '', + '', + '', + '', + '', '
' //close right side container ].join(' ')); @@ -535,10 +537,20 @@ saveSettings(); } }); + + $('#BeenThereSettings').draggable({ + stop: function(event, ui) { + beenTheresettings.SettingsLocLeft = $('#BeenThereSettings').css('left'); + beenTheresettings.SettingsLocTop = $('#BeenThereSettings').css('top'); + saveSettings(); + } + }); } initColorPicker(); LoadSettings(); + + WazeWrap.Interface.ShowScriptUpdate("WME BeenThere", GM_info.script.version, updateMessage, "https://greasyfork.org/scripts/27035-wme-beenthere", "https://www.waze.com/forum/viewtopic.php?f=819&t=218182"); } function LayerToggled(checked){ @@ -550,56 +562,73 @@ Takes the settings loaded into the settings obj and loads them into the interface and draws any features that were saved */ function LoadSettings(){ - if(beenTheresettings.layerHistory.length > 0) - for(var i=0;i", {style:"padding:8px 16px", id:"WMEBeenThereSettings"}); $section.html([ - '