IITC Dialog Overhaul, part 2

Core changes
* window_management.js => panes.js (clarity, distinction from dialogs)
* Make portal preview use dialogs instead of the large preview "window"
* Use `open' callback instead of `create' callback for all dialogs
* Replace collapse/close buttons with themed buttons inspired by the AP Gain plugin
* Dialogs can now gain and lose focus, with changing title bar
* Tweak the Poslinks window to use dialogs
* Add collapseCallback, expandCallback, collapseExpandCallback, focusCallback, and blurCallback
* Fix http <img> in About dialog that caused Chrome to complain

Plugin changes
* guess-player-level 0.4.1: Use dialogs with titles, typo fix
* portal-counts 0.0.8: Use dialogs with titles, typo fix
* portals-list 0.0.12: Don't hijack every single dialog onscreen, add titles, typo fix
* scoreboard 0.1.8: Use dialogs with titles
This commit is contained in:
Morgan Jones
2013-05-08 03:31:32 -06:00
parent 9b56ac0982
commit dfadadd296
10 changed files with 224 additions and 92 deletions

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');
});
$(".ui-dialog").addClass('ui-dialog-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'
});
// 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,8 +321,8 @@ 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;}' +
'#portalslist table {margin-top:5px; border-collapse: collapse; empty-cells: show; width:100%; clear: both;}' +
'.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; }' +
'#portalslist table tr.enl td { background-color: #017f01; }' +

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>'
@ -361,12 +366,17 @@ window.plugin.scoreboard.display = function() {
+ 'Score is subject to portals available based on zoom level. '
+ 'If names are unresolved try again. For best results wait until updates are fully loaded.</div>';
} else {
scoreHtml += 'You need something in view.';
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() {
$('#players').html(window.plugin.scoreboard.playerTable($(this).data('sort')));
@ -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; }' +