Plugin AP List: Added a "Unselect all" button in header

This commit is contained in:
Xelio 2013-03-31 01:48:20 +08:00
parent ea8293e533
commit ab80e08036
2 changed files with 41 additions and 17 deletions

View File

@ -66,14 +66,12 @@
width: 100%; width: 100%;
} }
.ap-list-checkbox-mid { .ap-list-checkbox-inner {
display: table-cell; display: table-cell;
vertical-align: middle; vertical-align: middle;
} text-align: center;
width: 12px;
.ap-list-checkbox-inner { height: 12px;
width: 10px;
height: 10px;
border: 1px solid rgb(32, 168, 177); border: 1px solid rgb(32, 168, 177);
margin: 0 auto; margin: 0 auto;
} }
@ -82,6 +80,13 @@
background-color: rgb(32, 168, 177); background-color: rgb(32, 168, 177);
} }
.ap-list-checkbox-header {
width: 8px;
height: 0px;
margin: auto;
border: 1px solid rgb(32, 168, 177);
}
.ap-list-link { .ap-list-link {
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @id iitc-plugin-ap-list@xelio // @id iitc-plugin-ap-list@xelio
// @name IITC plugin: AP List // @name IITC plugin: AP List
// @version 0.5.0.@@DATETIMEVERSION@@ // @version 0.5.1.@@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@@
@ -89,11 +89,12 @@ window.plugin.apList.tableHeaderBuilder = function(side) {
var cssClass = column.headerTooltip ? (column.cssClass + ' help') : column.cssClass; var cssClass = column.headerTooltip ? (column.cssClass + ' help') : column.cssClass;
var title = column.headerTooltip ? column.headerTooltip : ''; var title = column.headerTooltip ? column.headerTooltip : '';
var onclick = column.headerOnClick ? column.headerOnClick: ''; var onclick = column.headerOnClick ? column.headerOnClick: '';
var content = column.headerFunction ? column.headerFunction() : column.header;
headerRow += '<td class="' + cssClass + '" ' headerRow += '<td class="' + cssClass + '" '
+ 'title="' + title + '" ' + 'title="' + title + '" '
+ 'onclick="' + onclick + '" ' + 'onclick="' + onclick + '" '
+ '>' + '>'
+ column.header + content
+ '</td>'; + '</td>';
}); });
@ -115,17 +116,28 @@ window.plugin.apList.tableRowBuilder = function(side,portal) {
return row; return row;
} }
window.plugin.apList.getHeaderCheckbox = function() {
var onClick = 'window.plugin.apList.clearDestroyPortals();';
var content = '<div class="ap-list-checkbox-header" />'
var div = plugin.apList.getCheckbox(onClick, null, content);
return div;
}
window.plugin.apList.getPortalDestroyCheckbox = function(portal) { window.plugin.apList.getPortalDestroyCheckbox = function(portal) {
// Change background color to border color if portal selected for destroy // Change background color to border color if portal selected for destroy
var checkboxClass = plugin.apList.destroyPortalIndex(portal.guid) >= 0 var addedClass = plugin.apList.destroyPortalIndex(portal.guid) >= 0
? 'ap-list-checkbox-inner ap-list-checkbox-selected' ? 'ap-list-checkbox-selected' : '';
: 'ap-list-checkbox-inner';
var onClick = 'window.plugin.apList.destroyPortal(\'' + portal.guid + '\');'; var onClick = 'window.plugin.apList.destroyPortal(\'' + portal.guid + '\');';
// 3 div for centering checkbox horizontally and vertically, var div = plugin.apList.getCheckbox(onClick, addedClass, null);
return div;
}
window.plugin.apList.getCheckbox = function(onClick, addedClass, content) {
// 2 div for centering checkbox horizontally and vertically,
// click event on outest div for people with not so good aiming // click event on outest div for people with not so good aiming
var div = '<div class="ap-list-checkbox-outer" onclick="' + onClick + '">' var div = '<div class="ap-list-checkbox-outer" onclick="' + (onClick || '')+ '">'
+ '<div class="ap-list-checkbox-mid">' + '<div class="ap-list-checkbox-inner ' + (addedClass || '') + '">'
+ '<div class="' + checkboxClass + '"/>' + (content || '')
+ '</div>' + '</div>'
+ '</div>'; + '</div>';
return div; return div;
@ -682,6 +694,13 @@ window.plugin.apList.changeSorting = function(sortBy) {
} }
} }
window.plugin.apList.clearDestroyPortals = function() {
plugin.apList.destroyPortalsGuid = new Array();
plugin.apList.updateSortedPortals();
plugin.apList.updatePortalTable(plugin.apList.displaySide);
}
window.plugin.apList.destroyPortal = function(guid) { window.plugin.apList.destroyPortal = function(guid) {
// Add to destroyPortalsGuid if not yet added, remove if already added // Add to destroyPortalsGuid if not yet added, remove if already added
var portalIndex = plugin.apList.destroyPortalIndex(guid); var portalIndex = plugin.apList.destroyPortalIndex(guid);
@ -796,8 +815,8 @@ window.plugin.apList.setupTableColumns = function() {
// Columns: Checkbox | Portal | AP | Eff. LV // Columns: Checkbox | Portal | AP | Eff. LV
enemyColumns.push({ enemyColumns.push({
header: '', headerFunction: plugin.apList.getHeaderCheckbox,
headerTooltip: 'Select checkbox to \nsimulating destruction', headerTooltip: 'Unselect all',
cssClass: 'ap-list-td-checkbox', cssClass: 'ap-list-td-checkbox',
contentFunction: plugin.apList.getPortalDestroyCheckbox contentFunction: plugin.apList.getPortalDestroyCheckbox
}); });