Merge pull request #4 from jonatkins/master

updating fork
This commit is contained in:
reckter
2015-11-17 10:28:44 +01:00
45 changed files with 1072 additions and 1002 deletions

View File

@ -2,7 +2,7 @@
// @id iitc-plugin-basemap-opencyclepam@jonatkins
// @name IITC plugin: OpenCycleMap.org map tiles
// @category Map Tiles
// @version 0.1.1.@@DATETIMEVERSION@@
// @version 0.2.0.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@ -24,21 +24,29 @@
// use own namespace for plugin
window.plugin.mapTileOpenCycleMap = function() {};
window.plugin.mapTileOpenCycleMap = {
addLayer: function() {
//the Thunderforest (OpenCycleMap) tiles are free to use - http://www.thunderforest.com/terms/
window.plugin.mapTileOpenCycleMap.addLayer = function() {
var ocmOpt = {
attribution: 'Tiles © OpenCycleMap, Map data © OpenStreetMap',
maxNativeZoom: 18,
maxZoom: 21,
};
//the Thunderforest (OpenCycleMap) tiles are free to use - http://www.thunderforest.com/terms/
var layers = {
'cycle': 'OpenCycleMap',
'transport': 'Transport',
'transport-dark': 'Transport Dark',
'outdoors': 'Outdoors',
'landscape': 'Landscape',
};
osmAttribution = 'Map data © OpenStreetMap';
var ocmOpt = {attribution: 'Tiles © OpenCycleMap, '+osmAttribution, maxNativeZoom: 18, maxZoom: 21};
var ocmCycle = new L.TileLayer('http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png', ocmOpt);
var ocmTransport = new L.TileLayer('http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png', ocmOpt);
var ocmLandscape = new L.TileLayer('http://{s}.tile3.opencyclemap.org/landscape/{z}/{x}/{y}.png', ocmOpt);
layerChooser.addBaseLayer(ocmCycle, "Thunderforest OpenCycleMap");
layerChooser.addBaseLayer(ocmTransport, "Thunderforest Transport");
layerChooser.addBaseLayer(ocmLandscape, "Thunderforest Landscape");
for(var i in layers) {
var layer = new L.TileLayer('http://{s}.tile.thunderforest.com/' + i + '/{z}/{x}/{y}.png', ocmOpt);
layerChooser.addBaseLayer(layer, 'Thunderforest ' + layers[i]);
}
},
};
var setup = window.plugin.mapTileOpenCycleMap.addLayer;

View File

@ -24,18 +24,27 @@
// use own namespace for plugin
window.plugin.mapTileOpenStreetMap = function() {};
window.plugin.mapTileOpenStreetMap = {
addLayer: function() {
// OpenStreetMap tiles - we shouldn't use these by default - https://wiki.openstreetmap.org/wiki/Tile_usage_policy
// "Heavy use (e.g. distributing an app that uses tiles from openstreetmap.org) is forbidden without prior permission from the System Administrators"
window.plugin.mapTileOpenStreetMap.addLayer = function() {
var osmOpt = {
attribution: 'Map data © OpenStreetMap contributors',
maxNativeZoom: 18,
maxZoom: 21,
};
//OpenStreetMap tiles - we shouldn't use these by default - https://wiki.openstreetmap.org/wiki/Tile_usage_policy
// "Heavy use (e.g. distributing an app that uses tiles from openstreetmap.org) is forbidden without prior permission from the System Administrators"
var layers = {
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png': 'OpenStreetMap',
'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png': 'Humanitarian',
};
osmAttribution = 'Map data © OpenStreetMap contributors';
var osmOpt = {attribution: osmAttribution, maxNativeZoom: 18, maxZoom: 21};
var osm = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', osmOpt);
layerChooser.addBaseLayer(osm, "OpenStreetMap");
for(var url in layers) {
var layer = new L.TileLayer(url, osmOpt);
layerChooser.addBaseLayer(layer, layers[url]);
}
},
};
var setup = window.plugin.mapTileOpenStreetMap.addLayer;

View File

@ -295,26 +295,36 @@
}
// Append a 'star' flag in sidebar.
window.plugin.bookmarks.onPortalSelectedPending = false;
window.plugin.bookmarks.onPortalSelected = function() {
$('.bkmrksStar').remove();
if(window.selectedPortal == null) return;
setTimeout(function() { // the sidebar is constructed after firing the hook
if(typeof(Storage) === "undefined") {
$('#portaldetails > .imgpreview').after(plugin.bookmarks.htmlDisabledMessage);
return;
}
if (!window.plugin.bookmarks.onPortalSelectedPending) {
window.plugin.bookmarks.onPortalSelectedPending = true;
// Prepend a star to mobile status-bar
if(window.plugin.bookmarks.isSmart) {
$('#updatestatus').prepend(plugin.bookmarks.htmlStar);
$('#updatestatus .bkmrksStar').attr('title', '');
}
setTimeout(function() { // the sidebar is constructed after firing the hook
window.plugin.bookmarks.onPortalSelectedPending = false;
$('.bkmrksStar').remove();
if(typeof(Storage) === "undefined") {
$('#portaldetails > .imgpreview').after(plugin.bookmarks.htmlDisabledMessage);
return;
}
// Prepend a star to mobile status-bar
if(window.plugin.bookmarks.isSmart) {
$('#updatestatus').prepend(plugin.bookmarks.htmlStar);
$('#updatestatus .bkmrksStar').attr('title', '');
}
$('#portaldetails > h3.title').before(plugin.bookmarks.htmlStar);
window.plugin.bookmarks.updateStarPortal();
}, 0);
}
$('#portaldetails > h3.title').before(plugin.bookmarks.htmlStar);
window.plugin.bookmarks.updateStarPortal();
}, 0);
}
// Update the status of the star (when a portal is selected from the map/bookmarks-list)

View File

@ -0,0 +1,62 @@
// ==UserScript==
// @id iitc-plugin-cache-details-on-map@jonatkins
// @name IITC plugin: Cache viewed portal details and always show them on the map
// @category Cache
// @version 0.1.0.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Cache the details of recently viewed portals and use this to populate the map when possible
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// @include https://www.ingress.com/mission/*
// @include http://www.ingress.com/mission/*
// @match https://www.ingress.com/mission/*
// @match http://www.ingress.com/mission/*
// @grant none
// ==/UserScript==
@@PLUGINSTART@@
// PLUGIN START ////////////////////////////////////////////////////////
// use own namespace for plugin
window.plugin.cachePortalDetailsOnMap = function() {};
window.plugin.cachePortalDetailsOnMap.MAX_AGE = 12*60*60; //12 hours max age for cached data
window.plugin.cachePortalDetailsOnMap.portalDetailLoaded = function(data) {
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;
var ents = [];
for (var guid in window.plugin.cachePortalDetailsOnMap.cache) {
if (window.plugin.cachePortalDetailsOnMap.cache[guid].loadtime < maxAge) {
delete window.plugin.cachePortalDetailsOnMap.cache[guid];
} else {
ents.push(window.plugin.cachePortalDetailsOnMap.cache[guid].ent);
}
}
data.callback(ents);
};
window.plugin.cachePortalDetailsOnMap.setup = function() {
window.plugin.cachePortalDetailsOnMap.cache = {};
addHook('portalDetailLoaded', window.plugin.cachePortalDetailsOnMap.portalDetailLoaded);
addHook('mapDataEntityInject', window.plugin.cachePortalDetailsOnMap.entityInject);
};
var setup = window.plugin.cachePortalDetailsOnMap.setup;
// PLUGIN END //////////////////////////////////////////////////////////
@@PLUGINEND@@

View File

@ -92,12 +92,16 @@ window.plugin.drawTools.setOptions = function() {
window.plugin.drawTools.setDrawColor = function(color) {
window.plugin.drawTools.currentColor = color;
window.plugin.drawTools.currentMarker = window.plugin.drawTools.getMarkerIcon(color);
window.plugin.drawTools.drawControl.setDrawingOptions({
'polygon': { 'shapeOptions': { color: color } },
'polyline': { 'shapeOptions': { color: color } },
'circle': { 'shapeOptions': { color: color } },
'marker': { 'icon': window.plugin.drawTools.currentMarker },
window.plugin.drawTools.lineOptions.color = color;
window.plugin.drawTools.polygonOptions.color = color;
window.plugin.drawTools.markerOptions.icon = window.plugin.drawTools.currentMarker;
plugin.drawTools.drawControl.setDrawingOptions({
polygon: { shapeOptions: plugin.drawTools.polygonOptions },
polyline: { shapeOptions: plugin.drawTools.lineOptions },
circle: { shapeOptions: plugin.drawTools.polygonOptions },
marker: { icon: plugin.drawTools.markerOptions.icon },
});
}

View File

@ -8,6 +8,9 @@
position: absolute;
overflow: auto;
}
.plugin-mission-pane > button {
padding: 0.3em 2em;
}
.plugin-mission-summary {
padding: 5px;
@ -160,3 +163,11 @@
width: 18px;
}
.plugin-mission-search-result-desc {
display: block;
max-height: 2em;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

View File

@ -2,7 +2,7 @@
// @id iitc-plugin-missions@jonatkins
// @name IITC plugin: Missions
// @category Info
// @version 0.1.1.@@DATETIMEVERSION@@
// @version 0.1.2.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@ -79,6 +79,10 @@ window.plugin.missions = {
// 3 weeks.
portalMissionsCacheTime: 21 * 24 * 3600 * 1E3,
MISSION_COLOR: '#404000',
MISSION_COLOR_ACTIVE: '#7f7f00',
MISSION_COLOR_START: '#A6A600',
SYNC_DELAY: 5000,
enableSync: false,
@ -113,22 +117,17 @@ window.plugin.missions = {
},
openPortalMissions: function() {
var me = this,
portal = window.portals[window.selectedPortal];
if (!portal) {
return;
}
this.loadPortalMissions(window.selectedPortal, function(missions) {
if (!missions.length) {
return;
}
if (missions.length === 1) {
me.loadMission(missions[0].guid, me.showMissionDialog.bind(me));
this.loadMission(missions[0].guid, this.showMissionDialog.bind(this));
} else {
me.showMissionListDialog(missions);
this.showMissionListDialog(missions);
}
});
}.bind(this));
},
openMission: function(guid) {
@ -137,7 +136,7 @@ window.plugin.missions = {
showMissionDialog: function(mission) {
var me = this;
var markers = this.highlightMissionPortals(mission);
var markers = this.drawMission(mission);
var content = this.renderMission(mission);
var id = mission.guid.replace(/\./g, '_'); // dots irritate the dialog framework and are not allowed in HTML IDs
@ -146,7 +145,18 @@ window.plugin.missions = {
this.tabHeaders[id].parentNode.querySelector('.ui-icon-close').click();
}
this.tabMarkers[id] = markers;
var button = content.insertBefore(document.createElement('button'), content.lastChild);
button.textContent = 'Zoom to mission';
button.addEventListener('click', function() {
me.zoomToMission(mission);
show('map');
}, false);
var li = this.tabBar.appendChild(document.createElement('li'));
li.dataset['mission_id'] = id;
var a = li.appendChild(document.createElement('a'));
a.textContent = mission.title;
a.href = '#mission_pane_'+id;
@ -155,10 +165,11 @@ window.plugin.missions = {
span.className = 'ui-icon ui-icon-close';
span.textContent = 'Close mission';
span.addEventListener('click', function() {
this.unhighlightMissionPortals(markers);
this.removeMissionLayers(markers);
li.parentNode.removeChild(li);
content.parentNode.removeChild(content);
delete this.tabHeaders[id];
delete this.tabMarkers[id];
$(this.tabs)
.tabs('refresh')
.find('.ui-tabs-nav')
@ -181,10 +192,13 @@ window.plugin.missions = {
html: content,
width: '450px',
closeCallback: function() {
me.unhighlightMissionPortals(markers);
me.removeMissionLayers(markers);
},
collapseCallback: this.collapseFix,
expandCallback: this.collapseFix,
focus: function() {
me.highlightMissionLayers(markers);
}
}).dialog('option', 'buttons', {
'Zoom to mission': function() {
me.zoomToMission(mission);
@ -214,13 +228,17 @@ window.plugin.missions = {
},
zoomToMission: function(mission) {
map.fitBounds(this.getMissionBounds(mission), {maxZoom: 17});
},
getMissionBounds: function(mission) {
var latlngs = mission.waypoints.filter(function(waypoint) {
return !!waypoint.portal;
}).map(function(waypoint) {
return [waypoint.portal.latE6/1E6, waypoint.portal.lngE6/1E6];
});
map.fitBounds(L.latLngBounds(latlngs), {maxZoom: 17});
return L.latLngBounds(latlngs);
},
loadMissionsInBounds: function(bounds, callback, errorcallback) {
@ -240,7 +258,7 @@ window.plugin.missions = {
}
callback(missions);
}, function(error) {
console.log('Error loading missions in bounds', arguments);
console.error('Error loading missions in bounds', arguments);
if (errorcallback) {
errorcallback(error);
}
@ -255,7 +273,7 @@ window.plugin.missions = {
return;
}
window.postAjax('getTopMissionsForPortal', {
guid: window.selectedPortal
guid: guid,
}, function(data) {
var missions = data.result.map(decodeMissionSummary);
if (!missions) {
@ -274,7 +292,7 @@ window.plugin.missions = {
me.storeCache();
callback(missions);
}, function(error) {
console.log('Error loading portal missions', arguments);
console.error('Error loading portal missions', arguments);
if (errorcallback) {
errorcallback(error);
}
@ -575,7 +593,7 @@ window.plugin.missions = {
else
this.checkedWaypoints[mwpid] = true;
window.runHooks('plugin-missions-waypoint-changed', { mwpid: mwpid, });
window.runHooks('plugin-missions-waypoint-changed', { mwpid: mwpid, local: true, });
if (!dontsave) {
this.checkedWaypointsUpdateQueue[mwpid] = true;
this.storeLocal('checkedWaypoints');
@ -606,7 +624,7 @@ window.plugin.missions = {
else
this.checkedMissions[mid] = true;
window.runHooks('plugin-missions-mission-changed', { mid: mid, });
window.runHooks('plugin-missions-mission-changed', { mid: mid, local: true, });
this.checkedMissionsUpdateQueue[mid] = true;
this.storeLocal('checkedMissions');
this.storeLocal('checkedMissionsUpdateQueue');
@ -725,7 +743,7 @@ window.plugin.missions = {
});
},
highlightMissionPortals: function(mission) {
drawMission: function(mission) {
var markers = [];
var latlngs = [];
@ -734,7 +752,7 @@ window.plugin.missions = {
return;
}
var radius = window.portals[waypoint.portal.guid] ? window.portals[waypoint.portal.guid].options.radius * 1.5 : 5;
var radius = window.portals[waypoint.portal.guid] ? window.portals[waypoint.portal.guid].options.radius * 1.75 : 5;
var ll = [waypoint.portal.latE6 / 1E6, waypoint.portal.lngE6 / 1E6];
latlngs.push(ll);
@ -742,7 +760,7 @@ window.plugin.missions = {
radius: radius,
weight: 3,
opacity: 1,
color: '#222',
color: this.MISSION_COLOR,
fill: false,
dashArray: null,
clickable: false
@ -753,7 +771,7 @@ window.plugin.missions = {
}, this);
var line = L.geodesicPolyline(latlngs, {
color: '#222',
color: this.MISSION_COLOR,
opacity: 1,
weight: 2,
clickable: false,
@ -764,12 +782,25 @@ window.plugin.missions = {
return markers;
},
unhighlightMissionPortals: function(markers) {
removeMissionLayers: function(markers) {
markers.forEach(function(marker) {
this.missionLayer.removeLayer(marker);
}, this);
},
highlightMissionLayers: function(markers) {
// layer.bringToFront() will break if the layer is not visible
var bringToFront = map.hasLayer(plugin.missions.missionLayer);
this.missionLayer.eachLayer(function(layer) {
var active = (markers.indexOf(layer) !== -1);
layer.setStyle({
color: active ? this.MISSION_COLOR_ACTIVE : this.MISSION_COLOR,
});
if(active && bringToFront) layer.bringToFront();
}, this);
},
onPortalChanged: function(type, guid, oldval) {
var portal;
if (type === 'add' || type === 'update') {
@ -787,7 +818,7 @@ window.plugin.missions = {
radius: portal.options.radius + Math.ceil(portal.options.radius / 2),
weight: 3,
opacity: 1,
color: '#555',
color: this.MISSION_COLOR_START,
fill: false,
dashArray: null,
clickable: false
@ -830,10 +861,21 @@ window.plugin.missions = {
},
// called after IITC and all plugin loaded
registerFieldForSyncing: function() {
if(!window.plugin.sync) return;
window.plugin.sync.registerMapForSync('missions', 'checkedMissions', this.syncCallback.bind(this), this.syncInitialed.bind(this));
window.plugin.sync.registerMapForSync('missions', 'checkedWaypoints', this.syncCallback.bind(this), this.syncInitialed.bind(this));
onIITCLoaded: function() {
var match = location.pathname.match(/\/mission\/([0-9a-z.]+)/);
if(match && match[1]) {
var mid = match[1];
this.loadMission(mid, function(mission) {
this.openMission(mid);
this.zoomToMission(mission);
}.bind(this));
}
if(window.plugin.sync) {
window.plugin.sync.registerMapForSync('missions', 'checkedMissions', this.syncCallback.bind(this), this.syncInitialed.bind(this));
window.plugin.sync.registerMapForSync('missions', 'checkedWaypoints', this.syncCallback.bind(this), this.syncInitialed.bind(this));
}
},
// called after local or remote change uploaded
@ -860,9 +902,9 @@ window.plugin.missions = {
this.storeLocal(fieldName + 'UpdateQueue');
if(fieldName === 'checkedMissions') {
window.runHooks('plugin-missions-mission-changed', { mid: e.property, });
window.runHooks('plugin-missions-mission-changed', { mid: e.property, local: false, });
} else if(fieldName === 'checkedWaypoints') {
window.runHooks('plugin-missions-waypoint-changed', { mwpid: e.property, });
window.runHooks('plugin-missions-waypoint-changed', { mwpid: e.property, local: false, });
}
}
},
@ -883,6 +925,77 @@ window.plugin.missions = {
}
},
onSearch: function(query) {
var self = this;
var bounds = window.map.getBounds();
if(query.confirmed) {
this.loadMissionsInBounds(bounds, function(missions) {
self.addMissionsToQuery(query, missions);
});
}
var cachedMissions = Object.keys(this.cacheByMissionGuid).map(function(guid) {
return self.cacheByMissionGuid[guid].data;
});
var cachedMissionsInView = cachedMissions.filter(function(mission) {
return mission.waypoints && mission.waypoints.some(function(waypoint) {
if(!waypoint) return false;
if(!waypoint.portal) return false;
return bounds.contains([waypoint.portal.latE6/1E6, waypoint.portal.lngE6/1E6]);
});
});
self.addMissionsToQuery(query, cachedMissionsInView);
},
addMissionsToQuery: function(query, missions) {
var term = query.term.toLowerCase();
missions.forEach(function(mission) {
if(mission.title.toLowerCase().indexOf(term) === -1
&& ((!mission.description) || mission.description.toLowerCase().indexOf(term) === -1)) {
return;
}
if(query.results.some(function(result) { return result.mission && (result.mission.guid == mission.guid); }))
// mission already in list (a cached mission may be found again via missions in bounds)
return;
var result = {
title: escapeHtmlSpecialChars(mission.title),
description: mission.description
? 'Recently viewed mission: <small class="plugin-mission-search-result-desc">' + escapeHtmlSpecialChars(mission.description) + '</small>'
: 'Mission in view',
icon: 'https://commondatastorage.googleapis.com/ingress.com/img/tm_icons/tm_cyan.png',
onSelected: this.onSearchResultSelected.bind(this),
mission: mission,
layer: null, // prevent a preview, we'll handle this
};
// mission may be a cached mission or contain the full details
if(mission.waypoints) {
result.bounds = this.getMissionBounds(mission);
}
if(mission.typeNum) {
result.icon = this.missionTypeImages[mission.typeNum] || this.missionTypeImages[0];
}
query.addResult(result);
}.bind(this));
},
onSearchResultSelected: function(result, event) {
if(result.bounds) {
map.fitBounds(result.bounds, {maxZoom: 17});
}
this.openMission(result.mission.guid);
return false;
},
setup: function() {
this.cacheByPortalGuid = {};
this.cacheByMissionGuid = {};
@ -906,9 +1019,18 @@ window.plugin.missions = {
this.tabs = this.mobilePane.appendChild(document.createElement('div'));
this.tabBar = this.tabs.appendChild(document.createElement('ul'));
this.tabHeaders = {};
this.tabMarkers = {};
$(this.tabs)
.tabs()
.tabs({
activate: function(event, ui) {
if(!ui.newTab) return;
var header = $(ui.newTab)[0];
var id = header.dataset['mission_id'];
this.highlightMissionLayers(this.tabMarkers[id]);
}.bind(this),
})
.find('.ui-tabs-nav').sortable({
axis: 'x',
stop: function() {
@ -923,6 +1045,8 @@ window.plugin.missions = {
// window.addPortalHighlighter('Mission start point', this.highlight.bind(this));
window.addHook('portalSelected', this.onPortalSelected.bind(this));
window.addHook('search', this.onSearch.bind(this));
/*
I know iitc has portalAdded event but it is missing portalDeleted. So we have to resort to Object.observe
*/
@ -964,13 +1088,8 @@ window.plugin.missions = {
window.addHook('plugin-missions-missions-refreshed', this.onMissionsRefreshed.bind(this));
window.addHook('plugin-missions-waypoint-changed', this.onWaypointChanged.bind(this));
window.addHook('plugin-missions-waypoints-refreshed', this.onWaypointsRefreshed.bind(this));
window.addHook('iitcLoaded', this.registerFieldForSyncing.bind(this));
var match = location.pathname.match(/\/mission\/([0-9a-z.]+)/);
if(match && match[1]) {
var mid = match[1];
this.openMission(mid);
}
window.addHook('iitcLoaded', this.onIITCLoaded.bind(this));
}
};

View File

@ -27,19 +27,22 @@ window.plugin.portalHighlighterInactive = function() {};
window.plugin.portalHighlighterInactive.highlight = function(data) {
var daysUnmodified = (new Date().getTime() - data.portal.options.timestamp) / (24*60*60*1000);
if (data.portal.options.timestamp > 0) {
if (daysUnmodified >= 7) {
var daysUnmodified = (new Date().getTime() - data.portal.options.timestamp) / (24*60*60*1000);
var fill_opacity = Math.min(1,((daysUnmodified-7)/24)*.85 + .15);
if (daysUnmodified >= 7) {
var blue = Math.max(0,Math.min(255,Math.round((daysUnmodified-31)/62*255)));
var fill_opacity = Math.min(1,((daysUnmodified-7)/24)*.85 + .15);
var colour = 'rgb(255,0,'+blue+')';
var blue = Math.max(0,Math.min(255,Math.round((daysUnmodified-31)/62*255)));
var params = {fillColor: colour, fillOpacity: fill_opacity};
var colour = 'rgb(255,0,'+blue+')';
data.portal.setStyle(params);
var params = {fillColor: colour, fillOpacity: fill_opacity};
data.portal.setStyle(params);
}
}
}

View File

@ -27,8 +27,10 @@ window.plugin.portalHighlighterPortalsLevelColor = function() {};
window.plugin.portalHighlighterPortalsLevelColor.colorLevel = function(data) {
var portal_level = data.portal.options.data.level;
var opacity = .6;
data.portal.setStyle({fillColor: COLORS_LVL[portal_level], fillOpacity: opacity});
if (portal_level !== undefined) {
var opacity = .6;
data.portal.setStyle({fillColor: COLORS_LVL[portal_level], fillOpacity: opacity});
}
}
var setup = function() {

View File

@ -30,7 +30,7 @@ window.plugin.portalsMissingResonators.highlight = function(data) {
if(data.portal.options.team != TEAM_NONE) {
var res_count = data.portal.options.data.resCount;
if(res_count < 8) {
if(res_count !== undefined && res_count < 8) {
var fill_opacity = ((8-res_count)/8)*.85 + .15;
var color = 'red';
var params = {fillColor: color, fillOpacity: fill_opacity};

View File

@ -29,7 +29,7 @@ window.plugin.portalHighlighterNeedsRecharge.highlight = function(data) {
var d = data.portal.options.data;
var health = d.health;
if(data.portal.options.team != TEAM_NONE && health < 100) {
if(health !== undefined && data.portal.options.team != TEAM_NONE && health < 100) {
var color,fill_opacity;
if (health > 95) {
color = 'yellow';

View File

@ -2,7 +2,7 @@
// @id iitc-plugin-portal-level-numbers@rongou
// @name IITC plugin: Portal Level Numbers
// @category Layer
// @version 0.1.4.@@DATETIMEVERSION@@
// @version 0.1.5.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@ -88,7 +88,7 @@ window.plugin.portalLevelNumbers.updatePortalLabels = function() {
for (var guid in window.portals) {
var p = window.portals[guid];
if (p._map) { // only consider portals added to the map
if (p._map && p.options.data.level !== undefined) { // only consider portals added to the map, and that have a level set
var point = map.project(p.getLatLng());
portalPoints[guid] = point;
}

View File

@ -2,7 +2,7 @@
// @id iitc-plugin-portal-names@zaso
// @name IITC plugin: Portal Names
// @category Layer
// @version 0.1.5.@@DATETIMEVERSION@@
// @version 0.1.6.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@ -93,7 +93,7 @@ window.plugin.portalNames.updatePortalLabels = function() {
for (var guid in window.portals) {
var p = window.portals[guid];
if (p._map) { // only consider portals added to the map
if (p._map && p.options.data.title) { // only consider portals added to the map and with a title
var point = map.project(p.getLatLng());
portalPoints[guid] = point;
}

View File

@ -2,7 +2,7 @@
// @id iitc-plugin-show-linked-portals@fstopienski
// @name IITC plugin: Show linked portals
// @category Portal Info
// @version 0.3.0.@@DATETIMEVERSION@@
// @version 0.3.1.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@ -43,6 +43,8 @@ window.plugin.showLinkedPortal.portalDetail = function (data) {
var c = 1;
$('<div>',{id:'showLinkedPortalContainer'}).appendTo('#portaldetails');
function renderLinkedPortal(linkGuid) {
if(c > 16) return;
@ -61,7 +63,7 @@ window.plugin.showLinkedPortal.portalDetail = function (data) {
var title;
var data = (portals[guid] && portals[guid].options.data) || portalDetail.get(guid) || null;
if(data) {
if(data && data.title) {
title = data.title;
div.append($('<img/>').attr({
'src': fixPortalImageUrl(data.image),
@ -73,7 +75,7 @@ window.plugin.showLinkedPortal.portalDetail = function (data) {
div
.addClass('outOfRange')
.append($('<span/>')
.html('Portal out of range.<br>' + lengthShort));
.html('Portal not loaded.<br>' + lengthShort));
}
div
@ -89,7 +91,7 @@ window.plugin.showLinkedPortal.portalDetail = function (data) {
.append($('<span/>').html(lengthFull))
.html(),
})
.appendTo('#portaldetails');
.appendTo('#showLinkedPortalContainer');
c++;
}
@ -101,10 +103,10 @@ window.plugin.showLinkedPortal.portalDetail = function (data) {
$('<div>')
.addClass('showLinkedPortalLink showLinkedPortalOverflow')
.text(length-16 + ' more')
.appendTo('#portaldetails');
.appendTo('#showLinkedPortalContainer');
}
$('#portaldetails')
$('#showLinkedPortalContainer')
.on('click', '.showLinkedPortalLink', plugin.showLinkedPortal.onLinkedPortalClick)
.on('mouseover', '.showLinkedPortalLink', plugin.showLinkedPortal.onLinkedPortalMouseOver)
.on('mouseout', '.showLinkedPortalLink', plugin.showLinkedPortal.onLinkedPortalMouseOut);

View File

@ -1,12 +1,12 @@
// ==UserScript==
// @id iitc-plugin-show-more-portals@jonatkins
// @name IITC plugin: Show more portals
// @category Tweaks
// @category Deleted
// @version 0.2.1.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Boost the detail level of portals shown so that unclaimed portals are visible one level saooner.
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Standard intel has changed to show all portals from zoom level 15, which is what this plugin used to force.
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
@ -18,24 +18,3 @@
// @grant none
// ==/UserScript==
@@PLUGINSTART@@
// PLUGIN START ////////////////////////////////////////////////////////
// use own namespace for plugin
window.plugin.showMorePortals = function() {};
window.plugin.showMorePortals.setup = function() {
// NOTE: the logic required is closely tied to the IITC+stock map detail level code - so the logic is moved there now
// and just enabled by this flag
window.CONFIG_ZOOM_SHOW_MORE_PORTALS=true;
};
var setup = window.plugin.showMorePortals.setup;
// PLUGIN END //////////////////////////////////////////////////////////
@@PLUGINEND@@

View File

@ -27,7 +27,7 @@ window.plugin.portalWeakness = function() {};
window.plugin.portalWeakness.highlightWeakness = function(data) {
if(data.portal.options.team != TEAM_NONE) {
if(data.portal.options.data.resCount !== undefined && data.portal.options.data.health !== undefined && data.portal.options.team != TEAM_NONE) {
var res_count = data.portal.options.data.resCount;
var portal_health = data.portal.options.data.health;

View File

@ -2,7 +2,7 @@
// @id iitc-plugin-uniques@3ch01c
// @name IITC plugin: Uniques
// @category Misc
// @version 0.2.3.@@DATETIMEVERSION@@
// @version 0.2.4.@@DATETIMEVERSION@@
// @namespace https://github.com/3ch01c/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@ -99,6 +99,17 @@ window.plugin.uniques.onPublicChatDataAvailable = function(data) {
&& markup[0][0] == 'PLAYER'
&& markup[0][1].plain == nick
&& markup[1][0] == 'TEXT'
&& markup[1][1].plain == ' deployed a Resonator on '
&& markup[2][0] == 'PORTAL') {
// search for "x deployed a Resonator on z"
var portal = markup[2][1];
var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6);
if(guid) plugin.uniques.setPortalVisited(guid);
} else if(plext.plextType == 'SYSTEM_BROADCAST'
&& markup.length==3
&& markup[0][0] == 'PLAYER'
&& markup[0][1].plain == nick
&& markup[1][0] == 'TEXT'
&& markup[1][1].plain == ' captured '
&& markup[2][0] == 'PORTAL') {
// search for "x captured y"
@ -188,6 +199,8 @@ window.plugin.uniques.updateCheckedAndHighlight = function(guid) {
window.plugin.uniques.setPortalVisited = function(guid) {
var uniqueInfo = plugin.uniques.uniques[guid];
if (uniqueInfo) {
if(uniqueInfo.visited) return;
uniqueInfo.visited = true;
} else {
plugin.uniques.uniques[guid] = {
@ -203,6 +216,8 @@ window.plugin.uniques.setPortalVisited = function(guid) {
window.plugin.uniques.setPortalCaptured = function(guid) {
var uniqueInfo = plugin.uniques.uniques[guid];
if (uniqueInfo) {
if(uniqueInfo.visited && uniqueInfo.captured) return;
uniqueInfo.visited = true;
uniqueInfo.captured = true;
} else {
@ -227,6 +242,8 @@ window.plugin.uniques.updateVisited = function(visited, guid) {
};
}
if(visited == uniqueInfo.visited) return;
if (visited) {
uniqueInfo.visited = true;
} else { // not visited --> not captured
@ -249,6 +266,8 @@ window.plugin.uniques.updateCaptured = function(captured, guid) {
};
}
if(captured == uniqueInfo.captured) return;
if (captured) { // captured --> visited
uniqueInfo.captured = true;
uniqueInfo.visited = true;
@ -489,19 +508,83 @@ window.plugin.uniques.setupPortalsList = function() {
});
}
window.plugin.uniques.onMissionChanged = function(data) {
if(!data.local) return;
var mission = window.plugin.missions && window.plugin.missions.getMissionCache(data.mid, false);
if(!mission) return;
window.plugin.uniques.checkMissionWaypoints(mission);
};
window.plugin.uniques.onMissionLoaded = function(data) {
// the mission has been loaded, but the dialog isn't visible yet.
// we'll wait a moment so the mission dialog is opened behind the confirmation prompt
setTimeout(function() {
window.plugin.uniques.checkMissionWaypoints(data.mission);
}, 0);
};
window.plugin.uniques.checkMissionWaypoints = function(mission) {
if(!(window.plugin.missions && window.plugin.missions.checkedMissions[mission.guid])) return;
if(!mission.waypoints) return;
function isValidWaypoint(wp) {
// might be hidden or field trip card
if(!(wp && wp.portal && wp.portal.guid)) return false;
// only use hack, deploy, link, field and upgrade; ignore photo and passphrase
if(wp.objectiveNum <= 0 || wp.objectiveNum > 5) return false;
return true;
}
function isVisited(wp) {
var guid = wp.portal.guid,
uniqueInfo = plugin.uniques.uniques[guid],
visited = (uniqueInfo && uniqueInfo.visited) || false;
return visited;
}
// check if all waypoints are already visited
if(mission.waypoints.every(function(wp) {
if(!isValidWaypoint(wp)) return true;
return isVisited(wp);
})) return;
if(!confirm('The mission ' + mission.title + ' contains waypoints not yet marked as visited.\n\n' +
'Do you want to set them to \'visited\' now?'))
return;
mission.waypoints.forEach(function(wp) {
if(!isValidWaypoint(wp)) return;
if(isVisited(wp)) return;
plugin.uniques.setPortalVisited(wp.portal.guid);
});
};
var setup = function() {
if($.inArray('pluginUniquesUpdateUniques', window.VALID_HOOKS) < 0)
window.VALID_HOOKS.push('pluginUniquesUpdateUniques');
if($.inArray('pluginUniquesRefreshAll', window.VALID_HOOKS) < 0)
window.VALID_HOOKS.push('pluginUniquesRefreshAll');
window.pluginCreateHook('pluginUniquesUpdateUniques');
window.pluginCreateHook('pluginUniquesRefreshAll');
// to mark mission portals as visited
window.pluginCreateHook('plugin-missions-mission-changed');
window.pluginCreateHook('plugin-missions-loaded-mission');
window.plugin.uniques.setupCSS();
window.plugin.uniques.setupContent();
window.plugin.uniques.loadLocal('uniques');
window.addPortalHighlighter('Uniques', window.plugin.uniques.highlighter);
window.addHook('portalDetailsUpdated', window.plugin.uniques.onPortalDetailsUpdated);
window.addHook('publicChatDataAvailable', window.plugin.uniques.onPublicChatDataAvailable);
window.addHook('iitcLoaded', window.plugin.uniques.registerFieldForSyncing);
window.addPortalHighlighter('Uniques', window.plugin.uniques.highlighter);
window.addHook('plugin-missions-mission-changed', window.plugin.uniques.onMissionChanged);
window.addHook('plugin-missions-loaded-mission', window.plugin.uniques.onMissionLoaded);
if(window.plugin.portalslist) {
window.plugin.uniques.setupPortalsList();
} else {