Skip to content

Commit

Permalink
Merge pull request #20 from modos189/test-pr-8
Browse files Browse the repository at this point in the history
test pr: Removing the PR build from the site after a PR merge
  • Loading branch information
modos189 authored Jul 29, 2022
2 parents 3ddea05 + b7c4540 commit 4159d43
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions plugins/cache-portals-on-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@
// @version 0.1.0
// @description Cache the details of recently viewed portals and use this to populate the map when possible


// use own namespace for plugin
window.plugin.cachePortalDetailsOnMap = function() {};
window.plugin.cachePortalDetailsOnMap = function () {};

window.plugin.cachePortalDetailsOnMap.MAX_AGE = 12*60*60; //12 hours max age for cached data
window.plugin.cachePortalDetailsOnMap.MAX_AGE = 12 * 60 * 60; //12 hours max age for cached data

window.plugin.cachePortalDetailsOnMap.portalDetailLoaded = function(data) {
window.plugin.cachePortalDetailsOnMap.portalDetailLoaded = function (data) {
if (data.success) {
window.plugin.cachePortalDetailsOnMap.cache[data.guid] = { loadtime: Date.now(), ent: data.ent };
window.plugin.cachePortalDetailsOnMap.cache[data.guid] = {
loadtime: Date.now(),
ent: data.ent,
};
}
};

window.plugin.cachePortalDetailsOnMap.entityInject = function(data) {
var maxAge = Date.now() - window.plugin.cachePortalDetailsOnMap.MAX_AGE*1000;
window.plugin.cachePortalDetailsOnMap.entityInject = function (data) {
var maxAge =
Date.now() - window.plugin.cachePortalDetailsOnMap.MAX_AGE * 1000;

var ents = [];
for (var guid in window.plugin.cachePortalDetailsOnMap.cache) {
Expand All @@ -27,16 +30,20 @@ window.plugin.cachePortalDetailsOnMap.entityInject = function(data) {
ents.push(window.plugin.cachePortalDetailsOnMap.cache[guid].ent);
}
}
data.callback(ents, 'detailed');
data.callback(ents, "detailed");
};


window.plugin.cachePortalDetailsOnMap.setup = function() {

window.plugin.cachePortalDetailsOnMap.setup = function () {
window.plugin.cachePortalDetailsOnMap.cache = {};

addHook('portalDetailLoaded', window.plugin.cachePortalDetailsOnMap.portalDetailLoaded);
addHook('mapDataEntityInject', window.plugin.cachePortalDetailsOnMap.entityInject);
addHook(
"portalDetailLoaded",
window.plugin.cachePortalDetailsOnMap.portalDetailLoaded
);
addHook(
"mapDataEntityInject",
window.plugin.cachePortalDetailsOnMap.entityInject
);
};

var setup = window.plugin.cachePortalDetailsOnMap.setup;
var setup = window.plugin.cachePortalDetailsOnMap.setup;

0 comments on commit 4159d43

Please sign in to comment.