Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draw tools: save color in localStorage, #1237 #1238

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions plugins/draw-tools.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @id iitc-plugin-draw-tools@breunigs
// @name IITC plugin: draw tools
// @category Layer
// @version 0.7.0.@@DATETIMEVERSION@@
// @version 0.8.0.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
Expand All @@ -26,6 +26,11 @@
// use own namespace for plugin
window.plugin.drawTools = function() {};

window.plugin.drawTools.setup = function() {
window.plugin.drawTools.currentColor = localStorage.getItem(plugin_info.pluginId + '-Color') || '#a24ac3';
window.plugin.drawTools.loadExternals();
}

window.plugin.drawTools.loadExternals = function() {
try { console.log('Loading leaflet.draw JS now'); } catch(e) {}
@@INCLUDERAW:external/leaflet.draw.js@@
Expand Down Expand Up @@ -57,7 +62,6 @@ window.plugin.drawTools.getMarkerIcon = function(color) {
});
}

window.plugin.drawTools.currentColor = '#a24ac3';
window.plugin.drawTools.markerTemplate = '@@INCLUDESTRING:images/marker-icon.svg.template@@';

window.plugin.drawTools.setOptions = function() {
Expand Down Expand Up @@ -103,6 +107,10 @@ window.plugin.drawTools.setDrawColor = function(color) {
circle: { shapeOptions: plugin.drawTools.polygonOptions },
marker: { icon: plugin.drawTools.markerOptions.icon },
});

// save color in localStorage
localStorage.setItem(plugin_info.pluginId + '-Color',color);
console.log(plugin_info.pluginId + ': Color ' + color + ' saved');
}

// renders the draw control buttons in the top left corner
Expand Down Expand Up @@ -685,8 +693,7 @@ window.plugin.drawTools.boot = function() {

}


var setup = window.plugin.drawTools.loadExternals;
var setup = window.plugin.drawTools.setup;

// PLUGIN END //////////////////////////////////////////////////////////

Expand Down