Added focus link in the toolbox. Some renaming. Removed div to use sidebar style.
This commit is contained in:
parent
11f7c31ce7
commit
e34fd27e9e
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @id iitc-plugin-players-resonators@rbino
|
// @id iitc-plugin-players-resonators@rbino
|
||||||
// @name IITC plugin: Player's Resonators
|
// @name IITC plugin: Player's Resonators
|
||||||
// @version 0.1.3.@@DATETIMEVERSION@@
|
// @version 0.1.4.@@DATETIMEVERSION@@
|
||||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||||
// @updateURL @@UPDATEURL@@
|
// @updateURL @@UPDATEURL@@
|
||||||
// @downloadURL @@DOWNLOADURL@@
|
// @downloadURL @@DOWNLOADURL@@
|
||||||
@ -12,12 +12,15 @@
|
|||||||
// @match http://www.ingress.com/intel*
|
// @match http://www.ingress.com/intel*
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
// Changelog:
|
/*********************************************************************************************************
|
||||||
//
|
* Changelog:
|
||||||
// 0.1.3 Effective player name (with wrong capitalization) if it finds some reso
|
*
|
||||||
// 0.1.2 Made nickname case insensitive
|
* 0.1.4 Added focus link in the toolbox. Some renaming. Removed div to use sidebar style.
|
||||||
// 0.1.1 Added mouseover for portal location. Dirty hack to not show mousehover when the alert is fired.
|
* 0.1.3 Effective player name (with wrong capitalization) if it finds some reso
|
||||||
// 0.1.0 First public release
|
* 0.1.2 Made nickname case insensitive
|
||||||
|
* 0.1.1 Added mouseover for portal location. Dirty hack to not show mousehover when the alert is fired.
|
||||||
|
* 0.1.0 First public release
|
||||||
|
*********************************************************************************************************/
|
||||||
|
|
||||||
function wrapper() {
|
function wrapper() {
|
||||||
// ensure plugin framework is there, even if iitc is not yet loaded
|
// ensure plugin framework is there, even if iitc is not yet loaded
|
||||||
@ -32,30 +35,31 @@ window.plugin.playersResonators = function() {};
|
|||||||
window.plugin.playersResonators.findReso = function(playername) {
|
window.plugin.playersResonators.findReso = function(playername) {
|
||||||
var s = "";
|
var s = "";
|
||||||
var portalSet = {};
|
var portalSet = {};
|
||||||
var effectiveName = "";
|
var effectiveNick = "";
|
||||||
var nickFind = playername.toLowerCase();
|
// Assuming there can be no agents with same nick with different lower/uppercase
|
||||||
|
var nickToFind = playername.toLowerCase();
|
||||||
$.each(window.portals, function(ind, portal){
|
$.each(window.portals, function(ind, portal){
|
||||||
var r = portal.options.details.resonatorArray.resonators;
|
var r = portal.options.details.resonatorArray.resonators;
|
||||||
$.each(r, function(ind, reso) {
|
$.each(r, function(ind, reso) {
|
||||||
if (!reso) return true;
|
if (!reso) return true;
|
||||||
var nick = getPlayerName(reso.ownerGuid);
|
var nick = getPlayerName(reso.ownerGuid);
|
||||||
if (nick.toLowerCase() === nickFind){
|
if (nick.toLowerCase() === nickToFind){
|
||||||
if (!effectiveName) {
|
if (!effectiveNick) {
|
||||||
effectiveName = nick;
|
effectiveNick = nick;
|
||||||
}
|
}
|
||||||
if (!portalSet.hasOwnProperty(portal.options.guid)){
|
if (!portalSet.hasOwnProperty(portal.options.guid)){
|
||||||
portalSet[portal.options.guid] = true;
|
portalSet[portal.options.guid] = true;
|
||||||
console.log(portalSet);
|
console.log(portalSet);
|
||||||
var latlng = [portal.options.details.locationE6.latE6/1E6, portal.options.details.locationE6.lngE6/1E6].join();
|
var latlng = [portal.options.details.locationE6.latE6/1E6, portal.options.details.locationE6.lngE6/1E6].join();
|
||||||
var guid = portal.options.guid;
|
var guid = portal.options.guid;
|
||||||
var jsDoubleClick = 'window.zoomToAndShowPortal(\''+guid+'\', ['+latlng+']);return false';
|
var zoomPortal = 'window.zoomToAndShowPortal(\''+guid+'\', ['+latlng+']);return false';
|
||||||
var perma = '/intel?latE6='+portal.options.details.locationE6.latE6+'&lngE6='+portal.options.details.locationE6.lngE6+'&z=17&pguid='+guid;
|
var perma = '/intel?latE6='+portal.options.details.locationE6.latE6+'&lngE6='+portal.options.details.locationE6.lngE6+'&z=17&pguid='+guid;
|
||||||
var a = $('<a>',{
|
var a = $('<a>',{
|
||||||
"class": 'help',
|
"class": 'help',
|
||||||
text: portal.options.details.portalV2.descriptiveText.TITLE,
|
text: portal.options.details.portalV2.descriptiveText.TITLE,
|
||||||
title: portal.options.details.portalV2.descriptiveText.ADDRESS,
|
title: portal.options.details.portalV2.descriptiveText.ADDRESS,
|
||||||
href: perma,
|
href: perma,
|
||||||
onClick: jsDoubleClick
|
onClick: zoomPortal
|
||||||
})[0].outerHTML;
|
})[0].outerHTML;
|
||||||
s += a + "\n";
|
s += a + "\n";
|
||||||
}
|
}
|
||||||
@ -63,18 +67,19 @@ window.plugin.playersResonators.findReso = function(playername) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
if (s) {
|
if (s) {
|
||||||
fakeLinkPlayer = '<a href="#" onClick="return false;">' + effectiveName + '</a>'
|
// Showing the playername as a "fake" link to avoid the auto-mouseover effect on the first portal
|
||||||
|
fakeLinkPlayer = '<a href="#" onClick="return false;">' + effectiveNick + '</a>'
|
||||||
s = fakeLinkPlayer + " has resonators on these portals:\n\n" + s;
|
s = fakeLinkPlayer + " has resonators on these portals:\n\n" + s;
|
||||||
} else {
|
} else {
|
||||||
fakeLinkPlayer = '<a href="#" onClick="return false;">' + playername + '</a>'
|
|
||||||
s = fakeLinkPlayer + " has no resonators in this range\n";
|
s = fakeLinkPlayer + " has no resonators in this range\n";
|
||||||
}
|
}
|
||||||
alert(s);
|
alert(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
var setup = function() {
|
var setup = function() {
|
||||||
var content = '<div id="player-reso">' + '<input id="playerReso" placeholder="Type player name to find resonators..." type="text" style="width:300px;"/>';
|
var content = '<input id="playerReso" placeholder="Type player name to find resonators..." type="text">';
|
||||||
$('#sidebar').append(content);
|
$('#sidebar').append(content);
|
||||||
|
$('#toolbox').append(' <a onclick=$("#playerReso").focus() title="Find all portals with resonators of a certain player">Player\'s Reso</a>');
|
||||||
$("#playerReso").keypress(function(e) {
|
$("#playerReso").keypress(function(e) {
|
||||||
if((e.keyCode ? e.keyCode : e.which) !== 13) return;
|
if((e.keyCode ? e.keyCode : e.which) !== 13) return;
|
||||||
var data = $(this).val();
|
var data = $(this).val();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user