* The jQuery UI js/css file is now taken from ajax.googleapis.com instead of code.jquery.com

* Table or not is now autodetected, removed data-tooltip attributes
* Empty table cells are now possible
* Removed duplicated \t's on some titles
* Some tooltip code cleanup
This commit is contained in:
saithis 2013-02-12 23:16:12 +01:00
parent e0bb10f989
commit 039f9c14b5
8 changed files with 59 additions and 65 deletions

View File

@ -153,15 +153,15 @@ window.setupPlayerStat = function() {
var cls = PLAYER.team === 'ALIENS' ? 'enl' : 'res';
var t = 'Level:\t\t' + level + '\n'
+ 'XM:\t\t\t' + PLAYER.energy + ' / ' + xmMax + '\n'
+ 'AP:\t\t\t' + digits(ap) + '\n'
var t = 'Level:\t' + level + '\n'
+ 'XM:\t' + PLAYER.energy + ' / ' + xmMax + '\n'
+ 'AP:\t' + digits(ap) + '\n'
+ (level < 8 ? 'level up in:\t' + lvlUpAp + ' AP' : 'Congrats! (neeeeerd)')
+ '\n\Invites:\t\t'+PLAYER.available_invites;
+ '\n\Invites:\t'+PLAYER.available_invites;
+ '\n\nNote: your player stats can only be updated by a full reload (F5)';
$('#playerstat').html(''
+ '<h2 title="'+t+'" data-tooltip="title_render">'+level+'&nbsp;'
+ '<h2 title="'+t+'">'+level+'&nbsp;'
+ '<span class="'+cls+'">'+PLAYER.nickname+'</span>'
+ '<div>'
+ '<sup>XM: '+xmRatio+'%</sup>'
@ -196,45 +196,39 @@ window.setupTooltips = function() {
// disable show/hide animation
show: false,
hide: false,
items: "[data-tooltip]",
content: function(){
var type = $(this).attr('data-tooltip');
if(type == 'title'){
return $(this).attr('title');
}
else if(type == 'title_render'){
var title = $(this).attr('title');
var data = [];
var max_columns = 0;
content: function() {
var title = $(this).attr('title');
// parse data
var rows = title.split('\n');
$.each(rows, function(i, row){
data[i] = row.replace(/\t+/g, '\t').split('\t');
if(data[i].length > max_columns) max_columns = data[i].length;
// check if it should be converted to a table
if(!title.match(/\t/)) {
return title.replace(/\n/g, '<br />');
}
var data = [];
var columnCount = 0;
// parse data
var rows = title.split('\n');
$.each(rows, function(i, row) {
data[i] = row.split('\t');
if(data[i].length > columnCount) columnCount = data[i].length;
});
// build the table
var tooltip = '<table>';
$.each(data, function(i, row) {
tooltip += '<tr>';
$.each(data[i], function(k, cell) {
var attributes = '';
if(k === 0 && data[i].length < columnCount) {
attributes = ' colspan="'+(columnCount - data[i].length + 1)+'"';
}
tooltip += '<td'+attributes+'>'+cell+'</td>';
});
// build table
if(max_columns > 1) {
var tooltip = '<table>';
$.each(data, function(i, row){
tooltip += '<tr>';
$.each(data[i], function(k, cell){
var attributes = '';
if(k == 0 && data[i].length < max_columns){
attributes = ' colspan="'+(max_columns - data[i].length + 1)+'"';
}
tooltip += '<td'+attributes+'>'+cell+'</td>';
});
tooltip += '</tr>';
});
tooltip += '</table>';
return tooltip;
}
else {
return title.replace(/\n/g, '<br />');
}
}
tooltip += '</tr>';
});
tooltip += '</table>';
return tooltip;
}
});
}
@ -283,7 +277,7 @@ function asyncLoadScript(a){return function(b,c){var d=document.createElement("s
// contains the default Ingress map style.
var LLGMAPS = 'http://breunigs.github.com/ingress-intel-total-conversion/dist/leaflet_google.js';
var JQUERY = 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js';
var JQUERYUI = 'http://code.jquery.com/ui/1.10.0/jquery-ui.js';
var JQUERYUI = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js';
var LEAFLET = 'http://cdn.leafletjs.com/leaflet-0.5/leaflet.js';
var AUTOLINK = 'http://breunigs.github.com/ingress-intel-total-conversion/dist/autolink.js';

View File

@ -336,7 +336,7 @@ window.chat.handlePublicAutomated = function(data) {
case 'PORTAL':
var latlng = [part[1].latE6/1E6, part[1].lngE6/1E6];
var js = 'window.zoomToAndShowPortal(\''+part[1].guid+'\', ['+latlng[0]+', '+latlng[1]+'])';
tmpmsg += '<a onclick="'+js+'" title="'+part[1].address+'" class="help" data-tooltip="title">'+part[1].name+'</a>';
tmpmsg += '<a onclick="'+js+'" title="'+part[1].address+'" class="help">'+part[1].name+'</a>';
break;
}
});
@ -453,9 +453,9 @@ window.chat.renderMsg = function(msg, nick, time, team) {
var ta = unixTimeToHHmm(time);
var tb = unixTimeToString(time, true);
// help cursor via “#chat time”
var t = '<time title="'+tb+'" data-timestamp="'+time+'" data-tooltip="title">'+ta+'</time>';
var t = '<time title="'+tb+'" data-timestamp="'+time+'">'+ta+'</time>';
var s = 'style="color:'+COLORS[team]+'"';
var title = nick.length >= 8 ? 'title="'+nick+'" class="help" data-tooltip="title"' : '';
var title = nick.length >= 8 ? 'title="'+nick+'" class="help"' : '';
return '<p>'+t+'<span class="invisibleseparator"> &lt;</span><mark '+s+'>'+nick+'</mark><span class="invisibleseparator">&gt; </span><span>'+msg+'</span></p>';
}

View File

@ -72,7 +72,7 @@ window.debug.console.renderLine = function(text, errorType) {
var d = new Date();
var ta = d.toLocaleTimeString(); // print line instead maybe?
var tb = d.toLocaleString();
var t = '<time title="'+tb+'" data-timestamp="'+d.getTime()+'" data-tooltip="title">'+ta+'</time>';
var t = '<time title="'+tb+'" data-timestamp="'+d.getTime()+'">'+ta+'</time>';
var s = 'style="color:'+color+'"';
var l = '<p>'+t+'<mark '+s+'>'+errorType+'</mark><span>'+text+'</span></p>';
$('#debugconsole').prepend(l);

View File

@ -15,7 +15,7 @@ window.updateGameScore = function(data) {
var es = '<span class="enl" style="width:'+ep+'%;">&nbsp;'+Math.round(ep)+'%</span>';
$('#gamestat').html(rs+es).one('click', function() { window.updateGameScore() });
// help cursor via “#gamestat span”
$('#gamestat').attr('title', 'Resistance:\t\t'+r+' MindUnits\nEnlightenment:\t'+e+' MindUnits');
$('#gamestat').attr('title', 'Resistance:\t'+r+' MindUnits\nEnlightenment:\t'+e+' MindUnits');
window.setTimeout('window.updateGameScore', REFRESH_GAME_SCORE*1000);
}

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." data-tooltip="title_render">'+t+'</tt>'; }
function linkExpl(t) { return '<tt title="↳ incoming links\n↴ outgoing links\n• is meant to be the portal.">'+t+'</tt>'; }
var linksText = [linkExpl('links'), linkExpl(' ↳ ' + links.incoming+'&nbsp;&nbsp;•&nbsp;&nbsp;'+links.outgoing+' ↴')];
var player = d.captured && d.captured.capturingPlayerId
@ -62,7 +62,7 @@ window.renderPortalDetails = function(guid) {
.html(''
+ '<h3>'+d.portalV2.descriptiveText.TITLE+'</h3>'
// help cursor via “.imgpreview img”
+ '<div class="imgpreview"><img src="'+img+'" title="'+getPortalDescriptionFromDetails(d)+'\n\nClick to show full image." data-tooltip="title_render"/></div>'
+ '<div class="imgpreview"><img src="'+img+'" title="'+getPortalDescriptionFromDetails(d)+'\n\nClick to show full image."/></div>'
+ '<span id="level">'+Math.floor(getPortalLevel(d))+'</span>'
+ '<div class="mods">'+getModDetails(d)+'</div>'
+ '<div id="randdetails">'+randDetails+'</div>'

View File

@ -56,10 +56,10 @@ window.getModDetails = function(d) {
}
});
var t = '<span'+(modsTitle[0].length ? ' title="'+modsTitle[0]+'" data-tooltip="title_render"' : '')+' style="color:'+modsColor[0]+'">'+mods[0]+'</span>'
+ '<span'+(modsTitle[1].length ? ' title="'+modsTitle[1]+'" data-tooltip="title_render"' : '')+' style="color:'+modsColor[1]+'">'+mods[1]+'</span>'
+ '<span'+(modsTitle[2].length ? ' title="'+modsTitle[2]+'" data-tooltip="title_render"' : '')+' style="color:'+modsColor[2]+'">'+mods[2]+'</span>'
+ '<span'+(modsTitle[3].length ? ' title="'+modsTitle[3]+'" data-tooltip="title_render"' : '')+' style="color:'+modsColor[3]+'">'+mods[3]+'</span>'
var t = '<span'+(modsTitle[0].length ? ' title="'+modsTitle[0]+'"' : '')+' style="color:'+modsColor[0]+'">'+mods[0]+'</span>'
+ '<span'+(modsTitle[1].length ? ' title="'+modsTitle[1]+'"' : '')+' style="color:'+modsColor[1]+'">'+mods[1]+'</span>'
+ '<span'+(modsTitle[2].length ? ' title="'+modsTitle[2]+'"' : '')+' style="color:'+modsColor[2]+'">'+mods[2]+'</span>'
+ '<span'+(modsTitle[3].length ? ' title="'+modsTitle[3]+'"' : '')+' style="color:'+modsColor[3]+'">'+mods[3]+'</span>'
return t;
}
@ -69,7 +69,7 @@ window.getEnergyText = function(d) {
var totalNrg = getTotalPortalEnergy(d);
var inf = currentNrg + ' / ' + totalNrg;
var fill = prettyEnergy(currentNrg) + ' / ' + prettyEnergy(totalNrg)
return ['energy', '<tt title="'+inf+'" data-tooltip="title_render">' + fill + '</tt>'];
return ['energy', '<tt title="'+inf+'">' + fill + '</tt>'];
}
window.getAvgResoDistText = function(d) {
@ -112,15 +112,15 @@ window.getResonatorDetails = function(d) {
// rotates clockwise. So, last one is 7 (southeast).
window.renderResonatorDetails = function(slot, level, nrg, dist, nick, isLeft) {
if(level === 0) {
var meter = '<span class="meter" title="octant:\t' + OCTANTS[slot] + '" data-tooltip="title_render"></span>';
var meter = '<span class="meter" title="octant:\t' + OCTANTS[slot] + '"></span>';
} else {
var max = RESO_NRG[level];
var fillGrade = nrg/max*100;
var inf = 'energy:\t\t' + nrg + ' / ' + max + ' (' + Math.round(fillGrade) + '%)\n'
+ 'level:\t\t' + level + '\n'
var inf = 'energy:\t' + nrg + ' / ' + max + ' (' + Math.round(fillGrade) + '%)\n'
+ 'level:\t' + level + '\n'
+ 'distance:\t' + dist + 'm\n'
+ 'owner:\t\t' + nick + '\n'
+ 'owner:\t' + nick + '\n'
+ 'octant:\t' + OCTANTS[slot];
var style = 'width:'+fillGrade+'%; background:'+COLORS_LVL[level]+';';
@ -131,7 +131,7 @@ window.renderResonatorDetails = function(slot, level, nrg, dist, nick, isLeft) {
var fill = '<span style="'+style+'"></span>';
var meter = '<span class="meter meter-rel" title="'+inf+'" data-tooltip="title_render">' + fill + lbar + '</span>';
var meter = '<span class="meter meter-rel" title="'+inf+'">' + fill + lbar + '</span>';
}
var cls = isLeft ? 'left' : 'right';
var text = '<span class="meter-text '+cls+'">'+(nick||'')+'</span>';
@ -159,10 +159,10 @@ window.getDestroyAP = function(d) {
function tt(text) {
var t = 'Destroy:\n';
t += resoCount + '×\tResonators\t= ' + digits(resoAp) + '\n';
t += linkCount + '×\tLinks\t\t= ' + digits(linkAp) + '\n';
t += fieldCount + '×\tFields\t\t= ' + digits(fieldAp) + '\n';
t += linkCount + '×\tLinks\t= ' + digits(linkAp) + '\n';
t += fieldCount + '×\tFields\t= ' + digits(fieldAp) + '\n';
t += 'Sum: ' + digits(sum) + ' AP';
return '<tt title="'+t+'" data-tooltip="title_render">' + digits(text) + '</tt>';
return '<tt title="'+t+'">' + digits(text) + '</tt>';
}
return [tt('AP Gain'), tt(sum)];

View File

@ -47,7 +47,7 @@ window.renderUpdateStatus = function() {
t += 'Up to date.';
if(renderLimitReached())
t += ' <span style="color:red" class="help" title="Can only render so much before it gets unbearably slow. Not all entities are shown. Zoom in or increase the limit (search for MAX_DRAWN_*)." data-tooltip="title_render">RENDER LIMIT</span> '
t += ' <span style="color:red" class="help" title="Can only render so much before it gets unbearably slow. Not all entities are shown. Zoom in or increase the limit (search for MAX_DRAWN_*).">RENDER LIMIT</span> '
if(window.failedRequestCount > 0)
t += ' <span style="color:red">' + window.failedRequestCount + ' failed</span>.'

View File

@ -58,7 +58,7 @@ document.getElementsByTagName('head')[0].innerHTML = ''
+ '<link rel="stylesheet" type="text/css" href="http://breunigs.github.com/ingress-intel-total-conversion/style.css?@@BUILDDATE@@"/>'
+ '<link rel="stylesheet" type="text/css" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css"/>'
+ '<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Coda"/>'
+ '<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css"/>';
+ '<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/themes/base/jquery-ui.css"/>';
document.getElementsByTagName('body')[0].innerHTML = ''
+ '<div id="map">Loading, please wait</div>'