Skip to content

Commit

Permalink
ESLINT
Browse files Browse the repository at this point in the history
changing code to match eslint rules.
function definition syntax
Version bump
  • Loading branch information
MysticJay committed Jul 13, 2021
1 parent ac0dea5 commit 7e38c78
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 53 deletions.
4 changes: 3 additions & 1 deletion plugins/fix-china-map-offset.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// @author modos189
// @name Fix maps offsets in China
// @category Tweaks
// @version 0.3.0
// @version 0.3.1
// @description Show correct maps for China user by applying offset tweaks.


/* exported setup --eslint */
/* global L */
// use own namespace for plugin
var fixChinaMapOffset = {};
window.plugin.fixChinaMapOffset = fixChinaMapOffset;
Expand Down
75 changes: 39 additions & 36 deletions plugins/link-show-direction.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// @author jonatkins
// @name Direction of links on map
// @category Tweaks
// @version 0.2.1
// @version 0.2.2
// @description Show the direction of links on the map by adding short dashes to the line at the origin portal.


/* exported setup --eslint */
/* global L, dialog, addHook, map, links */
// use own namespace for plugin
var linkShowDirection = {};
window.plugin.linkShowDirection = linkShowDirection;

// exposed
window.plugin.linkShowDirection.showDialog = showDialog;
// linkShowDirection.showDialog = showDialog;

var ANIMATE_UPDATE_TIME = 1000; // 1000ms = 1s

Expand All @@ -37,18 +39,19 @@ var styles = {
'0,4,4,6,4,6,4,2',
'0,6,4,6,4,6,4,0',
'2,6,4,6,4,6,2,0',
],
]
};
var dashArray = null;
var activeFrame = 0;
var moving = false;
var activeStyle = '';


var animateLinks = function() {
var frames = styles[mode];
if(!frames) frames = [null];
function animateLinks () {
var frames = styles[activeStyle];
if (!frames) frames = [null];

if(!moving) {
if (!moving) {
var frame = activeFrame;
frame = (frame + 1) % frames.length;
activeFrame = frame;
Expand All @@ -57,7 +60,7 @@ var animateLinks = function() {
addAllLinkStyles();
}

if(frames.length < 2) return; // no animation needed
if (frames.length < 2) return; // no animation needed

// browsers don't render the SVG style changes until after the timer function has finished.
// this means if we start the next timeout in here a lot of the delay time will be taken by the browser itself
Expand All @@ -72,33 +75,35 @@ var animateLinks = function() {
animateLinks,
ANIMATE_UPDATE_TIME);
}, 10);
};
}

var addAllLinkStyles = function() {
function addAllLinkStyles () {
$.each(links,function(guid,link) { addLinkStyle(link); });

if(window.plugin.drawTools && localStorage['plugin-linkshowdirection-drawtools'] == "true") {
if (window.plugin.drawTools && localStorage['plugin-linkshowdirection-drawtools'] === 'true') {
window.plugin.drawTools.drawnItems.eachLayer(function(layer) {
if(layer instanceof L.GeodesicPolyline)
if (layer instanceof L.GeodesicPolyline) {
addLinkStyle(layer);
}
});
}
};
}

var addLinkStyle = function(link) {
function addLinkStyle (link) {
link.setStyle({dashArray: dashArray});
};
}

var removeDrawToolsStyle = function() {
if(!window.plugin.drawTools) return;
function removeDrawToolsStyle () {
if (!window.plugin.drawTools) return;

window.plugin.drawTools.drawnItems.eachLayer(function(layer) {
if(layer instanceof L.GeodesicPolyline)
if (layer instanceof L.GeodesicPolyline) {
layer.setStyle({dashArray: null});
}
});
};
}

function showDialog () {
var showDialog = function () {
var div = document.createElement('div');

$.each(styles, function(style) {
Expand All @@ -107,12 +112,12 @@ function showDialog () {
input.type = 'radio';
input.name = 'plugin-link-show-direction';
input.value = style;
if(style == mode) {
if (style === activeStyle) {
input.checked = true;
}

input.addEventListener('click', function() {
mode = style;
activeStyle = style;
localStorage['plugin-linkshowdirection-mode'] = style;
animateLinks();
}, false);
Expand All @@ -126,21 +131,22 @@ function showDialog () {
' * Static: six segments will indicate each link\'s direction. ' +
'Two long segments are on the origin\'s side, follow by four short segments on the destination\'s side.'));

if(window.plugin.drawTools) {
if (window.plugin.drawTools) {
div.appendChild(document.createElement('br'));

var label = div.appendChild(document.createElement('label'));
var input = label.appendChild(document.createElement('input'));
input.type = 'checkbox';
input.checked = localStorage['plugin-linkshowdirection-drawtools'] == "true";
input.checked = localStorage['plugin-linkshowdirection-drawtools'] === 'true';

input.addEventListener('click', function() {
localStorage['plugin-linkshowdirection-drawtools'] = input.checked.toString();
if(input.checked)

if (input.checked) {
animateLinks();
else
} else {
removeDrawToolsStyle();
}
}, false);

label.appendChild(document.createTextNode(' Apply to DrawTools'));
Expand All @@ -153,23 +159,20 @@ function showDialog () {
});
};

linkShowDirection.setup = function() {
$('#toolbox').append(' <a onclick="window.plugin.linkShowDirection.showDialog()">LinkDirection Opt</a>');

function setup () {
$('#toolbox').append(' <a>LinkDirection Opt</a>').on('click', showDialog);
addHook('linkAdded', function(data) { addLinkStyle(data.link); });

try {
mode = localStorage['plugin-linkshowdirection-mode'];
} catch(e) {
activeStyle = localStorage['plugin-linkshowdirection-mode'];
} catch (e) {
console.warn(e);
mode = 'Disabled';
activeStyle = 'Disabled';
}

animateLinks();

// set up move start/end handlers to pause animations while moving
map.on('movestart', function() { moving = true; });
map.on('moveend', function() { moving = false; });
};

var setup = linkShowDirection.setup;
}
14 changes: 6 additions & 8 deletions plugins/periodic-refresh.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
// @author jonatkins
// @name Periodic refresh
// @category Tweaks
// @version 0.1.0
// @version 0.1.1
// @description For use for unattended display screens only, this plugin causes idle mode to be left once per hour.

/* exported setup --eslint */
/* global idleReset */
// use own namespace for plugin
var periodicRefresh = {};
window.plugin.periodicRefresh = periodicRefresh;

var wakeup = function() {
function wakeup () {
console.log('periodicRefresh: timer fired - leaving idle mode');
idleReset();
}


var setup = function() {

function setup () {
var refreshMinutes = 60;

setInterval (wakeup, refreshMinutes*60*1000 );

};
}
12 changes: 4 additions & 8 deletions plugins/scroll-wheel-zoom-disable.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
// @author jonatkins
// @name Disable mouse wheel zoom
// @category Tweaks
// @version 0.1.0
// @version 0.1.1
// @description Disable the use of mouse wheel to zoom. The map zoom controls or keyboard are still available.


/* exported setup --eslint */
// use own namespace for plugin
// var scrollWheelZoomDisable = {};
// window.plugin.scrollWheelZoomDisable = scrollWheelZoomDisable;

var setup = function() {

function setup () {
window.map.scrollWheelZoom.disable();

};
}

0 comments on commit 7e38c78

Please sign in to comment.