This commit is contained in:
Jon Atkins 2013-05-10 02:33:21 +01:00
commit 65783ac0b1
12 changed files with 450 additions and 124 deletions

View File

@ -27,24 +27,22 @@ window.setupBackButton = function() {
}
}
window.setupLargeImagePreview = function() {
$('#portaldetails').on('click', '.imgpreview', function() {
var ex = $('#largepreview');
if(ex.length > 0) {
ex.remove();
return;
}
var img = $(this).find('img')[0];
var w = img.naturalWidth/2;
var h = img.naturalHeight/2;
var c = $('#portaldetails').attr('class');
$('body').append(
'<div id="largepreview" class="'+c+'" style="margin-left: '+(-SIDEBAR_WIDTH/2-w-2)+'px; margin-top: '+(-h-2)+'px">' + img.outerHTML + '</div>'
);
$('#largepreview').click(function() { $(this).remove() });
var w = img.naturalWidth, c = $('#portaldetails').attr('class');
var d = dialog({
html: '<span class="' + c + '" style="position: relative; width: 100%; left: 50%; margin-left: ' + -(w / 2) + 'px;">' + img.outerHTML + '</span>',
title: $(this).parent().find('h3.title').html()
});
// We have to dynamically set the width of this dialog, so get the .ui-dialog component
var p = d.parents('.ui-dialog');
// Don't let this dialog get smaller than the default maximum dialog width
var width = Math.max(parseInt(p.css('max-width')), w);
p.css('min-width', width + 'px');
p.css('width', width + 'px');
});
}
@ -341,22 +339,6 @@ window.setupTooltips = function(element) {
}
}
window.setupDialogs = function() {
$('#dialog').dialog({
autoOpen: false,
modal: true,
buttons: [
{ text: 'OK', click: function() { if($(this).data("closeCallback")) {$(this).data("closeCallback")();} $(this).dialog('close'); } }
]
});
window.alert = function(text, isHTML, closeCallback) {
var h = isHTML ? text : window.convertTextToTableMagic(text);
$('#dialog').data("closeCallback", closeCallback);
$('#dialog').html(h).dialog('open');
}
}
window.setupTaphold = function() {
@@INCLUDERAW:external/taphold.js@@
}

239
code/dialog.js Normal file
View File

@ -0,0 +1,239 @@
// DIALOGS /////////////////////////////////////////////////////////
// Inspired by TES III: Morrowind. Long live House Telvanni. ///////
////////////////////////////////////////////////////////////////////
/* The global ID of onscreen dialogs.
* Starts at 0.
*/
window.DIALOG_ID = 0;
/* All onscreen dialogs, keyed by their ID.
*/
window.DIALOGS = {};
/* The number of dialogs on screen.
*/
window.DIALOG_COUNT = 0;
/* The dialog that has focus.
*/
window.DIALOG_FOCUS = null;
/* Creates a dialog and puts it onscreen. Takes one argument: options, a JS object.
* == Common options
* (text|html): The text or HTML to display in the dialog. Text is auto-converted to HTML.
* title: The dialog's title.
* modal: Whether to open a modal dialog. Implies draggable=false; dialogClass='ui-dialog-modal'.
* Please note that modal dialogs hijack the entire screen and should only be used in very
* specific cases. (If IITC is running on mobile, modal will always be true).
* id: A unique ID for this dialog. If a dialog with id `id' is already open and dialog() is called
* again, it will be automatically closed.
*
* == Callbacks
* closeCallback: A callback to run on close. Takes no arguments.
* collapseCallback: A callback to run on dialog collapse. Takes no arguments.
* expandCallback: A callback to run on dialog expansion. Takes no arguments.
* collapseExpandCallback: A callback to run on both collapse and expand (overrides collapseCallback
* and expandCallback, takes a boolean argument `collapsing' - true if collapsing;
* false if expanding)
* focusCallback: A callback to run when the dialog gains focus.
* blurCallback: A callback to run when the dialog loses focus.
*
* See http://docs.jquery.com/UI/API/1.8/Dialog for a list of all the options. If you previously
* applied a class to your dialog after creating it with alert(), dialogClass may be particularly
* useful.
*/
window.dialog = function(options) {
// Override for smartphones. Preserve default behavior and create a modal dialog.
options = options || {};
if(isSmartphone()) {
options.modal = true;
}
// Build an identifier for this dialog
var id = 'dialog-' + (options.modal ? 'modal' : (options.id ? options.id : 'anon-' + window.DIALOG_ID++));
var jqID = '#' + id;
var html = '';
// Convert text to HTML if necessary
if(options.text) {
html = window.convertTextToTableMagic(options.text);
} else if(options.html) {
html = options.html;
} else {
console.log('window.dialog: warning: no text in dialog');
html = window.convertTextToTableMagic('');
}
// Modal dialogs should not be draggable
if(options.modal) {
options.dialogClass = 'ui-dialog-modal';
options.draggable = false;
}
// Close out existing dialogs.
if(window.DIALOGS[id]) {
try {
var selector = $(window.DIALOGS[id]);
selector.dialog('close');
selector.remove();
} catch(err) {
console.log('window.dialog: Tried to close nonexistent dialog ' + id);
}
}
// Create the window, appending a div to the body
$('body').append('<div id="' + id + '"></div>');
var dialog = $(jqID).dialog($.extend(true, {
autoOpen: false,
modal: false,
draggable: true,
closeText: '&nbsp;',
title: '',
buttons: {
'OK': function() {
$(this).dialog('close');
}
},
open: function() {
var titlebar = $(this).closest('.ui-dialog').find('.ui-dialog-titlebar');
titlebar.find('.ui-dialog-title').addClass('ui-dialog-title-active');
var close = titlebar.find('.ui-dialog-titlebar-close');
// Title should not show up on mouseover
close.removeAttr('title').addClass('ui-dialog-titlebar-button');
if(!$(this).dialog('option', 'modal')) {
// Start out with a cloned version of the close button
var collapse = close.clone();
// Change it into a collapse button and set the click handler
collapse.addClass('ui-dialog-titlebar-button-collapse ui-dialog-titlebar-button-collapse-expanded');
collapse.click($.proxy(function() {
var collapsed = ($(this).data('collapsed') === true);
// Run callbacks if we have them
if($(this).data('collapseExpandCallback')) {
$.proxy($(this).data('collapseExpandCallback'), this)(!collapsed);
} else {
if(collapsed && $(this).data('collapseCallback')) {
$.proxy($(this).data('collapseCallback'), this)();
} else if (!collapsed && $(this).data('expandCallback')) {
$.proxy($(this).data('expandCallback'), this)();
}
}
// Find the button pane and content dialog in this ui-dialog, and add or remove the 'hidden' class.
var dialog = $(this).closest('.ui-dialog');
var selector = dialog.find('.ui-dialog-content,.ui-dialog-buttonpane');
var button = dialog.find('.ui-dialog-titlebar-button-collapse');
if (collapsed) {
$(selector).removeClass('ui-dialog-content-hidden');
$(button).removeClass('ui-dialog-titlebar-button-collapse-collapsed');
$(button).addClass('ui-dialog-titlebar-button-collapse-expanded');
} else {
$(selector).addClass('ui-dialog-content-hidden');
$(button).removeClass('ui-dialog-titlebar-button-collapse-expanded');
$(button).addClass('ui-dialog-titlebar-button-collapse-collapsed');
}
// Toggle collapsed state
$(this).data('collapsed', !collapsed);
}, this));
// Put it into the titlebar
titlebar.prepend(collapse);
close.addClass('ui-dialog-titlebar-button-close');
}
window.DIALOGS[$(this).data('id')] = this;
window.DIALOG_COUNT++;
console.log('window.dialog: ' + $(this).data('id') + ' (' + $(this).dialog('option', 'title') + ') opened. ' + window.DIALOG_COUNT + ' remain.');
},
close: function() {
// Run the close callback if we have one
if($(this).data('closeCallback')) {
$.proxy($(this).data('closeCallback'), this)();
}
// Make sure that we don't keep a dead dialog in focus
if(window.DIALOG_FOCUS && $(window.DIALOG_FOCUS).data('id') === $(this).data('id')) {
window.DIALOG_FOCUS = null;
}
// Finalize
delete window.DIALOGS[$(this).data('id')];
window.DIALOG_COUNT--;
console.log('window.dialog: ' + $(this).data('id') + ' (' + $(this).dialog('option', 'title') + ') closed. ' + window.DIALOG_COUNT + ' remain.');
},
focus: function() {
if($(this).data('focusCallback')) {
$.proxy($(this).data('focusCallback'), this)();
}
// Blur the window currently in focus unless we're gaining focus
if(window.DIALOG_FOCUS && $(window.DIALOG_FOCUS).data('id') !== $(this).data('id')) {
$.proxy(function(event, ui) {
if($(this).data('blurCallback')) {
$.proxy($(this).data('blurCallback'), this)();
}
$(this).closest('.ui-dialog').find('.ui-dialog-title').removeClass('ui-dialog-title-active').addClass('ui-dialog-title-inactive');
}, window.DIALOG_FOCUS)();
}
// This dialog is now in focus
window.DIALOG_FOCUS = this;
$(this).closest('.ui-dialog').find('.ui-dialog-title').removeClass('ui-dialog-title-inactive').addClass('ui-dialog-title-active');
}
}, options));
// Set HTML and IDs
dialog.html(html);
dialog.data('id', id);
dialog.data('jqID', jqID);
// Set callbacks
dialog.data('closeCallback', options.closeCallback);
dialog.data('collapseCallback', options.collapseCallback);
dialog.data('expandCallback', options.expandCallback);
dialog.data('collapseExpandCallback', options.collapseExpandCallback);
dialog.data('focusCallback', options.focusCallback);
dialog.data('blurCallback', options.blurCallback);
// ui-modal includes overrides for modal dialogs
if (options.modal) {
dialog.parent().addClass('ui-modal');
}
// Enable snapping
dialog.dialog().parents('.ui-dialog').draggable('option', 'snap', true);
// Run it
dialog.dialog('open');
return dialog;
}
/* Creates an alert dialog with default settings.
* If you want more configurability, use window.dialog instead.
*/
window.alert = function(text, isHTML, closeCallback) {
var obj = {closeCallback: closeCallback};
if(isHTML) {
obj.html = text;
} else {
obj.text = text;
}
return dialog(obj);
}
window.setupDialogs = function() {
window.DIALOG_ID = 0;
window.DIALOGS = {}
window.DIALOG_COUNT = 0;
window.DIALOG_FOCUS = null;
}

View File

@ -18,7 +18,7 @@ window.renderPortalDetails = function(guid) {
if(d.portalV2.linkedEdges) $.each(d.portalV2.linkedEdges, function(ind, link) {
links[link.isOrigin ? 'outgoing' : 'incoming']++;
});
function linkExpl(t) { return '<tt title="↳ incoming links\n↴ outgoing links\n• is meant to be the portal.">'+t+'</tt>'; }
function linkExpl(t) { return '<tt title="↳ incoming links\n↴ outgoing links\n• is the portal">'+t+'</tt>'; }
var linksText = [linkExpl('links'), linkExpl(' ↳ ' + links.incoming+'&nbsp;&nbsp;•&nbsp;&nbsp;'+links.outgoing+' ↴')];
var player = d.captured && d.captured.capturingPlayerId
@ -50,14 +50,13 @@ window.renderPortalDetails = function(guid) {
var perma = '/intel?ll='+lat+','+lng+'&z=17&pll='+lat+','+lng;
var imgTitle = 'title="'+getPortalDescriptionFromDetails(d)+'\n\nClick to show full image."';
var poslinks = 'window.showPortalPosLinks('+lat+','+lng+',\'' + d.portalV2.descriptiveText.TITLE + '\')';
var postcard = 'Send in a postcard. Will put it online after receiving. Address:\\n\\nStefan Breunig\\nINF 305 R045\\n69120 Heidelberg\\nGermany';
$('#portaldetails')
.attr('class', TEAM_TO_CSS[getTeam(d)])
.html(''
+ '<h3 class="title">'+d.portalV2.descriptiveText.TITLE+'</h3>'
+ '<span class="close" onclick="unselectOldPortal();" title="Close">X</span>'
// help cursor via “.imgpreview img”
// help cursor via ".imgpreview img"
+ '<div class="imgpreview" '+imgTitle+' style="background-image: url('+img+')">'
+ '<img class="hide" src="'+img+'"/>'
+ '<span id="level">'+Math.floor(getPortalLevel(d))+'</span>'
@ -73,7 +72,7 @@ window.renderPortalDetails = function(guid) {
);
// try to resolve names that were required for above functions, but
// werent available yet.
// weren't available yet.
resolvePlayerNames();
runHooks('portalDetailsUpdated', {portalDetails: d});
@ -107,7 +106,7 @@ window.clearPortalIndicators = function() {
// highlights portal with given GUID. Automatically clears highlights
// on old selection. Returns false if the selected portal changed.
// Returns true if its still the same portal that just needs an
// Returns true if it's still the same portal that just needs an
// update.
window.selectPortal = function(guid) {
var update = selectedPortal === guid;

View File

@ -1,5 +1,6 @@
// REDEEMING /////////////////////////////////////////////////////////
// REDEEMING ///////////////////////////////////////////////////////
// Heuristic passcode redemption that tries to guess unknown items /
////////////////////////////////////////////////////////////////////
/* Resource type names mapped to actual names and abbreviations.
* Add more here if necessary.
@ -93,11 +94,16 @@ window.REDEEM_HINTS = {
};
window.handleRedeemResponse = function(data, textStatus, jqXHR) {
var passcode = this.passcode, to_alert, to_log;
var passcode = this.passcode, to_dialog, to_log, dialog_title, dialog_buttons;
if(data.error) {
to_alert = '<strong>' + data.error + '</strong><br />' + (window.REDEEM_ERRORS[data.error] || 'There was a problem redeeming the passcode. Try again?');
// What to display
to_dialog = '<strong>' + data.error + '</strong><br />' + (window.REDEEM_ERRORS[data.error] || 'There was a problem redeeming the passcode. Try again?');
to_log = '[ERROR] ' + data.error;
// Dialog options
dialog_title = 'Error: ' + passcode;
dialog_buttons = {};
} else if(data.result) {
var encouragement = window.REDEEM_ENCOURAGEMENT[Math.floor(Math.random() * window.REDEEM_ENCOURAGEMENT.length)];
var payload = {};
@ -190,7 +196,7 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) {
// Let the user know if we had to guess
if (inferred.length > 0) {
results.table.push('<td style="font-family: monospace;">*</td><td style="font-family: monospace;">Guessed (check console)</td>');
results.table.push('<td>*</td><td>Guessed (check console)</td>');
$.each(inferred, function (idx, val) {
console.log(passcode +
' => [INFERRED] ' + val.type + ':' + val.key + ' :: ' +
@ -198,23 +204,35 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) {
});
}
// Add table footers
results.table.push('<td style="font-family: monospace;">&gt;</td><td><a href="javascript:alert(\'' +
escape('<span style="font-family: monospace;"><strong>' + encouragement + '</strong><br />' + results.html.join('/') + '</span>') +
'\', true);" style="font-family: monospace;">[plaintext]</a>');
// Display formatted versions in a table, plaintext, and the console log
to_alert = '<table class="redeem-result">' + results.table.map(function(a) {return '<tr>' + a + '</tr>';}).join("\n") + '</table>';
to_dialog = '<table class="redeem-result-table">' +
results.table.map(function(a) {return '<tr>' + a + '</tr>';}).join("\n") +
'</table>';
to_log = '[SUCCESS] ' + results.plain.join('/');
dialog_title = 'Passcode: ' + passcode;
dialog_buttons = {
'PLAINTEXT' : function() {
dialog({
title: 'Rewards: ' + passcode,
html: '<span class="redeem-result-html">' + results.html.join('/') + '</span>'
});
}
}
}
alert(to_alert, true);
// Display it
dialog({
title: dialog_title,
buttons: dialog_buttons,
html: to_dialog
});
console.log(passcode + ' => ' + to_log);
}
window.setupRedeem = function() {
$("#redeem").keypress(function(e) {
if((e.keyCode ? e.keyCode : e.which) !== 13) return;
if((e.keyCode ? e.keyCode : e.which) !== 13 || !$(this).val()) return;
var data = {passcode: $(this).val()};
window.postAjax('redeemReward', data, window.handleRedeemResponse,
@ -225,7 +243,10 @@ window.setupRedeem = function() {
} else {
extra = 'No status code was returned.';
}
alert('<strong>The HTTP request failed.</strong> ' + extra);
dialog({
title: 'Request failed: ' + data.passcode,
html: '<strong>The HTTP request failed.</strong> ' + extra
});
});
});
}

View File

@ -19,7 +19,7 @@ window.aboutIITC = function(){
+ ' </ul>'
+ ' </div>'
+ ' <div>'
+ ' MapQuest OSM tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">'
+ ' MapQuest OSM tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="https://developer.mapquest.com/content/osm/mq_logo.png">'
+ ' </div>'
+ ' <hr>'
+ ' <div>Version: ' + v + '</div>'
@ -27,8 +27,11 @@ window.aboutIITC = function(){
+ ' <div>' + attrib + '</div>'
+ ' <hr>'
+ ' <div>' + contrib + '</div>';
alert(a, true, function() {$('.ui-dialog').removeClass('ui-dialog-aboutIITC');});
$('.ui-dialog').addClass('ui-dialog-aboutIITC');
dialog({
title: 'IITC ' + v,
html: a,
dialogClass: 'ui-dialog-aboutIITC'
});
}
@ -135,19 +138,23 @@ window.rangeLinkClick = function() {
}
window.showPortalPosLinks = function(lat, lng, name) {
var portal_name = '';
var encoded_name = '';
if(name !== undefined) {
portal_name = encodeURIComponent(' (' + name + ')');
encoded_name = encodeURIComponent(' (' + name + ')');
}
if (typeof android !== 'undefined' && android && android.intentPosLink) {
android.intentPosLink(lat, lng, portal_name);
} else {
var qrcode = '<div id="qrcode"></div>';
var script = '<script>$(\'#qrcode\').qrcode({text:\'GEO:'+lat+','+lng+'\'});</script>';
var gmaps = '<a href="https://maps.google.com/?q='+lat+','+lng+portal_name+'">Google maps</a>';
var gmaps = '<a href="https://maps.google.com/?q='+lat+','+lng+encoded_name+'">Google Maps</a>';
var osm = '<a href="http://www.openstreetmap.org/?mlat='+lat+'&mlon='+lng+'&zoom=16">OpenStreetMap</a>';
var latLng = '<span>'+lat+','+lng +'</span>';
alert('<div style="text-align: center;">' + qrcode + script + gmaps + ' ' + osm + '<br />' + latLng + '</div>');
var latLng = '<span>&lt;' + lat + ',' + lng +'&gt;</span>';
dialog({
html: '<div style="text-align: center;">' + qrcode + script + gmaps + '; ' + osm + '<br />' + latLng + '</div>',
title: name,
id: 'poslinks'
});
}
}

View File

@ -61,7 +61,8 @@ document.getElementsByTagName('head')[0].innerHTML = ''
+ '<style>@@INCLUDESTRING:style.css@@</style>'
+ '<style>@@INCLUDESTRING:external/leaflet.css@@</style>'
//note: smartphone.css injection moved into code/smartphone.js
+ '<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Coda"/>';
+ '<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Coda"/>'
+ '<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Roboto"/>';
document.getElementsByTagName('body')[0].innerHTML = ''
+ '<div id="map">Loading, please wait</div>'
@ -97,8 +98,7 @@ document.getElementsByTagName('body')[0].innerHTML = ''
+ ' </div>'
+ ' </div>'
+ '</div>'
+ '<div id="updatestatus"></div>'
+ '<div id="dialog"></div>';
+ '<div id="updatestatus"></div>';
// putting everything in a wrapper function that in turn is placed in a
// script tag on the website allows us to execute in the sites context

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @id iitc-plugin-guess-player-levels@breunigs
// @name IITC plugin: guess player level
// @version 0.4.0.@@DATETIMEVERSION@@
// @version 0.4.1.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@ -101,7 +101,7 @@ window.plugin.guessPlayerLevels.guess = function() {
});
});
var s = 'the players have at least the following level:\n\n';
var s = 'Players have at least the following level:\n\n';
s += 'Resistance:\t&nbsp;&nbsp;&nbsp;\tEnlightened:\t\n';
var namesR = plugin.guessPlayerLevels.sort(playersRes);
@ -132,7 +132,10 @@ window.plugin.guessPlayerLevels.guess = function() {
s += '\nAverage level:\t'+averageR.toFixed(2)+'\tAverage level:\t'+averageE.toFixed(2);
s += '\n\nIf there are some unresolved names, simply try again.'
//console.log(s);
alert(s);
dialog({
text: s,
title: 'Player levels: R' + averageR.toFixed(2) + ', E' + averageE.toFixed(2)
});
}
window.plugin.guessPlayerLevels.sort = function(playerHash) {

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @id iitc-plugin-portals-count@yenky
// @name IITC plugin: Show total counts of portals
// @version 0.0.7.@@DATETIMEVERSION@@
// @version 0.0.8.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@ -13,6 +13,7 @@
// ==/UserScript==
/* whatsnew
* 0.0.8 : use dialog() instead of alert()
* 0.0.6 : ignoring outside bounds portals (even if close to)
* 0.0.5 : changed table layout, added some colors
* 0.0.4 : reverse show order of portals, using MAX_PORTAL_LEVEL now for array, changed table layout to be more compact, cleaned up code
@ -74,7 +75,7 @@ window.plugin.portalcounts.getPortals = function(){
var counts = '<table>';
if(retval) {
counts += '<tr><th></th><th class="enl">Enlightment</th><th class="res">Resistance</th></tr>'; //'+window.plugin.portalcounts.enlP+' Portal(s)</th></tr>';
counts += '<tr><th></th><th class="enl">Enlightened</th><th class="res">Resistance</th></tr>'; //'+window.plugin.portalcounts.enlP+' Portal(s)</th></tr>';
for(var level = window.MAX_PORTAL_LEVEL; level > 0; level--){
counts += '<tr><td class="L'+level+'">Level '+level+'</td>';
if(minlvl > level)
@ -90,12 +91,18 @@ window.plugin.portalcounts.getPortals = function(){
else
counts += window.plugin.portalcounts.neuP;
counts += ' Portal(s)</td></tr>';
counts += '<tr class="enl"><th colspan="2">Enlightment:</th><td>'+window.plugin.portalcounts.enlP+' Portal(s)</td></tr>';
counts += '<tr class="enl"><th colspan="2">Enlightened:</th><td>'+window.plugin.portalcounts.enlP+' Portal(s)</td></tr>';
counts += '<tr class="res"><th colspan="2">Resistance:</th><td>'+window.plugin.portalcounts.resP+' Portal(s)</td></tr>';
} else
counts += '<tr><td>No Portals in range !</td></tr>';
counts += '<tr><td>No Portals in range!</td></tr>';
counts += '</table>';
alert('<div id="portalcounts">'+counts+'</div>');
var total = window.plugin.portalcounts.enlP + window.plugin.portalcounts.resP + window.plugin.portalcounts.neuP;
dialog({
html: '<div id="portalcounts">' + counts + '</div>',
title: 'Portal counts: ' + total + ' ' + (total == 1 ? 'portal' : 'portals'),
});
}
var setup = function() {

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @id iitc-plugin-portals-list@teo96
// @name IITC plugin: show list of portals
// @version 0.0.11.@@DATETIMEVERSION@@
// @version 0.0.12.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@ -13,6 +13,7 @@
// ==/UserScript==
/* whatsnew
* 0.0.12: Use dialog() instead of alert so the user can drag the box around
* 0.0.11: Add nominal energy column and # links, fix sort bug when opened even amounts of times, nits
* 0.0.10: Fixed persistent css problem with alert
* 0.0.9 : bugs hunt
@ -120,13 +121,15 @@ window.plugin.portalslist.displayPL = function() {
if (window.plugin.portalslist.getPortals()) {
html += window.plugin.portalslist.portalTable('level', window.plugin.portalslist.sortOrder,window.plugin.portalslist.filter);
} else {
html = '<table><tr><td>Nothing to Show !</td></tr></table>';
html = '<table><tr><td>Nothing to show!</td></tr></table>';
};
alert('<div id="portalslist">' + html + '</div>', true, function() {
$(".ui-dialog").removeClass('ui-dialog-portalslist');
$(document).off('.portalslist');
dialog({
html: '<div id="portalslist">' + html + '</div>',
dialogClass: 'ui-dialog-portalslist',
title: 'Portal list: ' + window.plugin.portalslist.listPortals.length + ' ' + (window.plugin.portalslist.listPortals.length == 1 ? 'portal' : 'portals'),
id: 'portal-list'
});
$(".ui-dialog").addClass('ui-dialog-portalslist');
// Setup sorting
$(document).on('click.portalslist', '#portalslist table th', function() {
@ -264,7 +267,7 @@ window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) {
html += '</table>';
html += '<div class="disclaimer">Click on portals table headers to sort by that column. '
+ 'Click on <b>All Portals, Resistant Portals, Enlightened Portals</b> to filter<br>'
+ 'Click on <b>All Portals, Resistance Portals, Enlightened Portals</b> to filter<br>'
+ 'Thanks to @vita10gy & @xelio for their IITC plugins who inspired me. A <a href="https://plus.google.com/113965246471577467739">@teo96</a> production. Vive la Résistance !</div>';
window.plugin.portalslist.sortOrder = window.plugin.portalslist.sortOrder*-1;
@ -275,7 +278,7 @@ window.plugin.portalslist.stats = function(sortBy) {
//console.log('** stats');
var html = '<table><tr>'
+ '<td class="filterAll" style="cursor:pointer" onclick="window.plugin.portalslist.portalTable(\'level\',-1,0)"><a href=""></a>All Portals : (click to filter)</td><td class="filterAll">' + window.plugin.portalslist.listPortals.length + '</td>'
+ '<td class="filterRes" style="cursor:pointer" class="sorted" onclick="window.plugin.portalslist.portalTable(\'level\',-1,1)">Resistant Portals : </td><td class="filterRes">' + window.plugin.portalslist.resP +' (' + Math.floor(window.plugin.portalslist.resP/window.plugin.portalslist.listPortals.length*100) + '%)</td>'
+ '<td class="filterRes" style="cursor:pointer" class="sorted" onclick="window.plugin.portalslist.portalTable(\'level\',-1,1)">Resistance Portals : </td><td class="filterRes">' + window.plugin.portalslist.resP +' (' + Math.floor(window.plugin.portalslist.resP/window.plugin.portalslist.listPortals.length*100) + '%)</td>'
+ '<td class="filterEnl" style="cursor:pointer" class="sorted" onclick="window.plugin.portalslist.portalTable(\'level\',-1,2)">Enlightened Portals : </td><td class="filterEnl">'+ window.plugin.portalslist.enlP +' (' + Math.floor(window.plugin.portalslist.enlP/window.plugin.portalslist.listPortals.length*100) + '%)</td>'
+ '</tr>'
+ '</table>';
@ -318,7 +321,7 @@ window.plugin.portalslist.getPortalLink = function(portal,guid) {
var setup = function() {
$('#toolbox').append(' <a onclick="window.plugin.portalslist.displayPL()" title="Display a list of portals in the current view">Portals list</a>');
$('head').append('<style>' +
'.ui-dialog-portalslist {position: absolute !important; top: 10px !important; left: 30px !important;max-width:800px !important; width:auto !important;}' +
'.ui-dialog-portalslist {max-width: 800px !important; width: auto !important;}' +
'#portalslist table {margin-top:5px; border-collapse: collapse; empty-cells: show; width:100%; clear: both;}' +
'#portalslist table td, #portalslist table th {border-bottom: 1px solid #0b314e; padding:3px; color:white; background-color:#1b415e}' +
'#portalslist table tr.res td { background-color: #005684; }' +

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @id iitc-plugin-scoreboard@vita10gy
// @name IITC plugin: show a localized scoreboard.
// @version 0.1.7.@@DATETIMEVERSION@@
// @version 0.1.8.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@ -298,6 +298,7 @@ window.plugin.scoreboard.display = function() {
var resMu = scores['team'][TEAM_RES]['mu'];
var enlMu = scores['team'][TEAM_ENL]['mu'];
var scoreHtml = '';
var title = '';
if(somethingInView) {
@ -307,6 +308,10 @@ window.plugin.scoreboard.display = function() {
+ window.plugin.scoreboard.percentSpan(resMuPercent, 'res')
+ window.plugin.scoreboard.percentSpan(100-resMuPercent, 'enl')
+ '</div>';
title = window.digits(resMu) + ' R (' + resMuPercent + '%), ' + window.digits(enlMu) + ' E (' + (100-resMuPercent) + '%)';
}
else {
title = 'no MU in view';
}
scoreHtml += '<table>'
@ -362,10 +367,15 @@ window.plugin.scoreboard.display = function() {
+ 'If names are unresolved try again. For best results wait until updates are fully loaded.</div>';
} else {
scoreHtml += 'You need something in view.';
title = 'nothing in view';
}
alert('<div id="scoreboard">' + scoreHtml + '</div>', true, function() {$(".ui-dialog").removeClass('ui-dialog-scoreboard');});
$(".ui-dialog").addClass('ui-dialog-scoreboard');
dialog({
html: '<div id="scoreboard">' + scoreHtml + '</div>',
title: 'Scoreboard: ' + title,
dialogClass: 'ui-dialog-scoreboard',
id: 'scoreboard'
});
// Setup sorting
$(document).on('click', '#players table th', function() {
@ -393,7 +403,7 @@ window.plugin.scoreboard.fieldArea = function(field) {
var setup = function() {
$('#toolbox').append(' <a onclick="window.plugin.scoreboard.display()" title="Display a scoreboard per team for the current view">Scoreboard</a>');
$('head').append('<style>' +
'.ui-dialog-scoreboard {max-width:600px !important; width:600px !important;}' +
'.ui-dialog-scoreboard {width: auto !important; min-width: 400px !important; max-width: 600px !important;}' +
'#scoreboard table {margin-top:10px; border-collapse: collapse; empty-cells: show; width:100%; clear: both;}' +
'#scoreboard table td, #scoreboard table th {border-bottom: 1px solid #0b314e; padding:3px; color:white; background-color:#1b415e}' +
'#scoreboard table tr.res td { background-color: #005684; }' +

123
style.css
View File

@ -503,7 +503,7 @@ h3 {
.mods span {
background-color: rgba(0, 0, 0, 0.3);
/* cant use inline-block because Webkits implementation is buggy and
/* cant use inline-block because Webkit's implementation is buggy and
* introduces additional margins in random cases. No clear necessary,
* as thats solved by setting height on .mods. */
display: block;
@ -666,7 +666,6 @@ h3 {
font-size: 16px;
}
/* update status */
#updatestatus {
background-color: rgba(8, 48, 78, 0.9);
@ -685,22 +684,8 @@ h3 {
box-sizing: border-box;
}
/* preview */
#largepreview {
left: 50%;
position: fixed;
top: 50%;
z-index: 2000;
}
#largepreview img {
box-shadow: 0 0 40px #000;
border: 2px solid #f8ff5e;
background-color: rgba(8, 48, 78, 0.9); /* as some images - eg ZipCar - have transparency */
}
/* tooltips, dialogs */
/* Dialogs
*/
.ui-tooltip, .ui-dialog {
max-width: 300px;
position: absolute;
@ -708,10 +693,29 @@ h3 {
background-color: rgba(8, 48, 78, 0.9);
border: 1px solid #20A8B1;
color: #eee;
font: 13px/15px "Helvetica Neue", Arial, Helvetica, sans-serif;
font: 13px/15px Roboto, Arial, Helvetica, sans-serif;
padding: 2px 4px;
}
.ui-widget-overlay {
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
z-index: 10000;
background: #444;
opacity: 0.6;
}
.ui-modal {
z-index: 10001 !important;
}
.ui-tooltip {
z-index: 10002 !important;
}
.ui-tooltip, .ui-dialog a {
color: #FFCE00;
}
@ -721,19 +725,61 @@ h3 {
border-radius: 2px;
}
.ui-widget-overlay {
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
z-index:9998;
background: #444;
opacity: 0.6;
.ui-dialog-modal .ui-dialog-titlebar-close {
display: none;
}
.ui-dialog-titlebar {
display: none;
text-align: center;
padding: 4px;
background-color: rgba(8, 60, 78, 0.9);
min-width: 250px;
}
.ui-dialog-title {
padding: 2px;
font-weight: bold;
}
.ui-dialog-title-active {
color: #ffce00;
}
.ui-dialog-title-inactive {
color: #ffffff;
}
.ui-dialog-titlebar-button {
position: absolute;
display: table-cell;
vertical-align: middle;
text-align: center;
width: 17px;
height: 17px;
top: 3px;
cursor: pointer;
border: 1px solid rgb(32, 168, 177);
background-color: rgba(0, 0, 0, 0);
}
.ui-dialog-titlebar-button:active {
background-color: rgb(32, 168, 177);
}
.ui-dialog-titlebar-button-close {
right: 4px;
}
.ui-dialog-titlebar-button-collapse {
right: 25px;
}
.ui-dialog-titlebar-button-collapse-expanded {
/* For future changes */
}
.ui-dialog-titlebar-button-collapse-collapsed {
background-color: rgb(32, 168, 177);
}
.ui-dialog-content {
@ -744,8 +790,12 @@ h3 {
max-width: 700px !important;
}
.ui-dialog-content-hidden {
display: none !important;
}
.ui-dialog-buttonpane {
padding: 12px;
padding: 6px;
border-top: 1px solid #20A8B1;
}
@ -756,7 +806,7 @@ h3 {
.ui-dialog-buttonset button,
.ui-dialog-content button {
padding: 2px;
min-width: 80px;
min-width: 40px;
color: #FFCE00;
border: 1px solid #FFCE00;
background-color: rgba(8, 48, 78, 0.9);
@ -767,8 +817,9 @@ h3 {
}
.ui-dialog-aboutIITC {
width: auto !important;
min-width: 400px !important;
max-width: 600px !important;
width: 600px !important;
}
td {
@ -785,9 +836,9 @@ td + td {
}
/* redeem results *****************************************************/
.redeem-result {
.redeem-result-table {
font-size: 14px;
font-family: arial,helvetica,sans-serif;
font-family: Roboto, Arial, Helvetica, sans-serif;
table-layout: fixed;
}
@ -796,6 +847,10 @@ td + td {
text-align: right;
}
.redeem-result-html {
font-family: Inconsolata, Consolas, Menlo, "Courier New", monospace;
}
.pl_nudge_date {
background-color: #724510;
border-left: 1px solid #ffd652;