Skip to content

Commit d5614b8

Browse files
committed
localStorage flag to disable permanently
1 parent b7a891b commit d5614b8

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/minicharts/d3fns/geo.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ var _ = require('lodash');
33
// var shared = require('./shared');
44
var debug = require('debug')('scout:minicharts:geo');
55
var mapStyle = require('./mapstyle');
6-
var async = require('async');
7-
var xor = require('xor-it');
6+
// var async = require('async');
7+
// var xor = require('xor-it');
88
var app = require('ampersand-app');
99
var format = require('util').format;
1010

1111

1212
var SHIFTKEY = 16;
13-
var APIKEY = '\u0004;\b\u000e!Cd5\u0007*V\u001d\u0007C\u0003/9HW\u001c>_\u0010\u0017)*\u0017B.7D/!*3\u000f\bX\u0010';
13+
var APIKEY = 'AIzaSyDrhE1qbcnNIh4sK3t7GEcbLRdCNKWjlt0';
1414

15-
function produceKey(text) {
16-
var key = 'Error: Google map could not be loaded, disabling feature';
17-
var res = xor(key, text);
18-
return res;
19-
}
15+
// function produceKey(text) {
16+
// var key = 'Error: Google map could not be loaded, disabling feature';
17+
// var res = xor(key, text);
18+
// return res;
19+
// }
2020

2121
// From: http://davidbcalhoun.com/2014/async.parallel-with-a-simple-timeout-node-js/
2222
// async.parallel with optional timeout (options.timeoutMS)
@@ -60,7 +60,9 @@ var minicharts_d3fns_geo = function() {
6060
// var margin = shared.margin;
6161

6262
function disableMapsFeature() {
63+
// disable both in feature flag (for this run) and localStorage
6364
app.setFeature('Google Map Minicharts', false);
65+
localStorage.disableGoogleMaps = true;
6466
delete window.google;
6567
debug('parent render', options.view.parent.render());
6668
options.view.parent.render();
@@ -83,7 +85,7 @@ var minicharts_d3fns_geo = function() {
8385
var script = document.createElement('script');
8486
script.setAttribute('type', 'text/javascript');
8587
script.src = format('https://maps.googleapis.com/maps/api/js?key=%s&libraries=geometry',
86-
produceKey(APIKEY));
88+
APIKEY);
8789
script.onerror = function() {
8890
done('Error ocurred while loading Google Maps.');
8991
};

src/minicharts/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ module.exports = AmpersandView.extend(QueryBuilderMixin, {
105105
if (this.model.name === 'Coordinates') {
106106
// check if we can load google maps or if we need to fall back to
107107
// a simpler coordinate chart
108-
// @todo (thomasr) add condition on localStorage for permanent disable
109-
if (app.isFeatureEnabled('Google Map Minicharts') && navigator.onLine) {
108+
if (app.isFeatureEnabled('Google Map Minicharts')
109+
&& navigator.onLine
110+
&& !localStorage.disableGoogleMaps) {
110111
this.viewOptions.renderMode = 'html';
111112
this.viewOptions.height = 250;
112113
this.viewOptions.vizFn = vizFns.geo;

0 commit comments

Comments
 (0)