Merge pull request #411 from Xosofox/master

Update in ipas plugin to forward link info
This commit is contained in:
Jon Atkins 2013-07-10 15:57:00 -07:00
commit 718857b861

View File

@ -42,35 +42,70 @@ window.plugin.ipasLink.getHash = function (d) {
hashParts = []; hashParts = [];
$.each(d.portalV2.linkedModArray, function (ind, mod) { $.each(d.portalV2.linkedModArray, function (ind, mod) {
//shields only, so far... // s - shields
var modCodes={ // h - heat sink
c: "cs", // i - intentionally left in
r: "rs", // t - turret
v: "vrs" //
}; // f - force amp
// m - multi-hack
var s = "0"; // l - link-amp
if (mod) { //
if (mod.type === "RES_SHIELD") { var modCodes = {
s = mod.rarity.charAt(0).toLowerCase(); "RES_SHIELD": "s",
s=modCodes[s]; "HEATSINK": "h",
s = s + mod.stats.MITIGATION; "TURRET": "t",
"FORCE_AMP": "f",
"MULTIHACK": "m",
"LINK_AMPLIFIER": "l"
} }
}
hashParts.push(s); var mc = "0";
}); if (mod) {
var shields = hashParts.join(","); if (mod.type in modCodes) {
return resos + "|" + shields; mc = modCodes[mod.type] + mod.rarity.charAt(0).toLowerCase();
}
//special for shields to distinguish old/new mitigation
if (mod.type == "RES_SHIELD") {
mc += mod.stats.MITIGATION;
}
}
}
hashParts.push(mc);
});
var shields = hashParts.join(",");
var linkParts = [];
var edges = d.portalV2.linkedEdges;
var portalL = new L.LatLng(d.locationE6.latE6 / 1E6, d.locationE6.lngE6 / 1E6)
$.each(edges, function (ind, edge) {
//calc distance in m here
var distance = 1; //default to 1m, so a low level portal would support it
//Try to find other portals details
var guid = edge.otherPortalGuid
if (window.portals[guid] !== undefined) {
//get other portals details as o
var o = window.portals[guid].options.details;
var otherPortalL = new L.LatLng(o.locationE6.latE6 / 1E6, o.locationE6.lngE6 / 1E6);
var distance = Math.round(portalL.distanceTo(otherPortalL));
}
if (!(edge.isOrigin)) {
distance = distance * -1;
}
linkParts.push(distance);
});
var links = linkParts.join(",");
return resos + "/" + shields + "/" + links; //changed with IPAS 1.1 to / instead of |
}
var setup = function () { var setup = function () {
window.plugin.ipasLink.setupCallback(); window.plugin.ipasLink.setupCallback();
} }
var setup = function() {
window.plugin.ipasLink.setupCallback();
}
// PLUGIN END ////////////////////////////////////////////////////////// // PLUGIN END //////////////////////////////////////////////////////////
@@PLUGINEND@@ @@PLUGINEND@@