Refactored utility functions
This commit is contained in:
@@ -3,6 +3,7 @@ Rampart;0;Mecha Tower;Provides 1u (1 unit of bandwidth. Play only one Tower card
|
||||
Turret;0;Mecha Tower;Provides 1u (1 unit of bandwidth. Play only one Tower card each turn). This Mecha Tower can't move.;4;2
|
||||
Engineered Earthquake;;Command;Deal 2 damage to all non-flying Mechas (Armour counters protect against this damage as normal).;;
|
||||
Interdictor;3;Mecha;Flight (This unit can't be attacked except by units with Flight or Reach). The cost of all enemy Mechas is increased by 1 (including Mechas in their hand).;1;1
|
||||
Mineshaft;;Command;Play this card on the battlefield with 2 time counters on it (Remove one time counter at the beginning of each turn). At the beginning of your draw phase, if there are no time counters on this card, draw one additional card this turn.;;
|
||||
Potshot;3;Mecha;When a Tower you control is destroyed, deal 1 damage to one target unit an opponent controls.;2;3
|
||||
Gutshot;3;Mecha;When a player plays a command, they must sacrifice one Tower they control.;2;2
|
||||
Snapshot;;Command;Return two Towers from your graveyard to the battlefield under your control.;;
|
||||
@@ -10,4 +11,4 @@ Headshot;;Command;Return two Commands from your graveyard to your hand.;;
|
||||
Signal Jamming;;Command;One target player discards their hand.;;
|
||||
Nuclear Blast;;Command;Destroy all units (Mechas and Towers). Each player discards their hand. Each player puts the top 5 cards of their deck into their graveyard.;;
|
||||
Preplanning;;Command;Search you deck for 5 Towers, and place them on the battlefield. You can't play Towers for the rest of the game.;;
|
||||
Mineshaft;;Command;Play this card on the battlefield with 2 time counters on it (Remove one time counter at the beginning of each turn). At the beginning of your draw phase, if there are no time counters on this card, draw one additional card this turn.;;
|
||||
Rigged to Blow;;Command;Attach this Command to one target Mecha you control in your entry zone. When that unit is destroyed, deal 2 damage to the Mecha that attacked it.;;
|
||||
|
||||
|
+48
-33
@@ -1,4 +1,6 @@
|
||||
var printHTML = function(fname, node) {
|
||||
//PARAM: fname = file to load with an ajax request
|
||||
//PARAM: node = DOM node to store the resulting data
|
||||
function printHTML(fname, node) {
|
||||
var request = new XMLHttpRequest();
|
||||
request.open('GET', fname, true);
|
||||
request.onreadystatechange = function() {
|
||||
@@ -10,15 +12,16 @@ var printHTML = function(fname, node) {
|
||||
node.innerHTML = request.responseText;
|
||||
}
|
||||
else {
|
||||
console.log("printMarkdown status:", request.status);
|
||||
console.log("printHTML status:", request.status);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
request.send();
|
||||
}
|
||||
|
||||
|
||||
var printMarkdown = function(fname, node) {
|
||||
//PARAM: fname = file to load with an ajax request
|
||||
//PARAM: node = DOM node to store the resulting data
|
||||
function printMarkdown(fname, node) {
|
||||
var request = new XMLHttpRequest();
|
||||
request.open('GET', fname, true);
|
||||
request.onreadystatechange = function() {
|
||||
@@ -37,7 +40,9 @@ var printMarkdown = function(fname, node) {
|
||||
request.send();
|
||||
}
|
||||
|
||||
var printCSV = function (fname, node) {
|
||||
//PARAM: fname = file to load with an ajax request
|
||||
//PARAM: node = DOM node to store the resulting data
|
||||
function printCSV(fname, node) {
|
||||
var request = new XMLHttpRequest();
|
||||
request.open('GET', fname, true);
|
||||
request.onreadystatechange = function() {
|
||||
@@ -48,21 +53,6 @@ var printCSV = function (fname, node) {
|
||||
if (request.status === 200) {
|
||||
node.innerHTML = "";
|
||||
|
||||
//build the search bar
|
||||
var div = document.createElement("DIV");
|
||||
div.className = "ui action input";
|
||||
var input = document.createElement("INPUT");
|
||||
input.id = "searchInput";
|
||||
input.type = "text";
|
||||
input.placeholder = "Search...";
|
||||
div.appendChild(input);
|
||||
var button = document.createElement("BUTTON");
|
||||
button.id = "searchButton";
|
||||
button.className = "ui button";
|
||||
button.innerHTML = "Search";
|
||||
button.onclick = searchTable;
|
||||
div.appendChild(button);
|
||||
|
||||
var table = parseCSVToTable(request.responseText, ';');
|
||||
table.id = "table";
|
||||
table.className = "ui celled table unstackable";
|
||||
@@ -71,7 +61,7 @@ var printCSV = function (fname, node) {
|
||||
scrollable.className = "scrollable";
|
||||
|
||||
scrollable.appendChild(table);
|
||||
node.appendChild(div);
|
||||
node.appendChild(buildSearchBar(searchTable, "table"));
|
||||
node.appendChild(scrollable);
|
||||
|
||||
var sorter = tsorter.create("table");
|
||||
@@ -84,7 +74,9 @@ var printCSV = function (fname, node) {
|
||||
request.send();
|
||||
}
|
||||
|
||||
var parseCSVToTable = function(csvText, delim) {
|
||||
//PARAM: csvText = CSV text to be parsed, with delim as the delimiter
|
||||
//PARAM: delim = delimiter of csvText
|
||||
function parseCSVToTable(csvText, delim) {
|
||||
//split
|
||||
var allLines = csvText.split(/\r\n|\n/);
|
||||
|
||||
@@ -129,19 +121,42 @@ var parseCSVToTable = function(csvText, delim) {
|
||||
return table;
|
||||
}
|
||||
|
||||
function searchTable() {
|
||||
var input = document.getElementById("searchInput");
|
||||
var table = document.getElementById("table");
|
||||
//PARAM: searchCallback = function to call on search
|
||||
// ARG: inputValue = text to search for
|
||||
// ARG: callbackArg (optional) = callbackArg passed to buildSearchBar
|
||||
//PARAM: callbackArg (optional) = passed to searchCallback as 2nd arg
|
||||
function buildSearchBar(searchCallback, callbackArg) {
|
||||
//build the search bar
|
||||
var div = document.createElement("DIV");
|
||||
div.className = "ui action input";
|
||||
var input = document.createElement("INPUT");
|
||||
input.id = "searchInput";
|
||||
input.type = "text";
|
||||
input.placeholder = "Search...";
|
||||
div.appendChild(input);
|
||||
var button = document.createElement("BUTTON");
|
||||
button.id = "searchButton";
|
||||
button.className = "ui button";
|
||||
button.innerHTML = "Search";
|
||||
button.onclick = () => { searchCallback(input.value, callbackArg); };
|
||||
div.appendChild(button);
|
||||
return div;
|
||||
}
|
||||
|
||||
var filter = input.value.toUpperCase();
|
||||
var trows = table.getElementsByTagName("tr");
|
||||
//PARAM: searchText = text to search for
|
||||
//PARAM: tableID = id of table to search
|
||||
function searchTable(searchText, tableID) {
|
||||
var table = document.getElementById(tableID);
|
||||
|
||||
for (var i = 1; i < trows.length; i++) {
|
||||
var tds = trows[i].cells;
|
||||
trows[i].style.display = "none";
|
||||
for (var j = 0; j < tds.length; j++) {
|
||||
if (tds[j].innerHTML.toUpperCase().indexOf(filter) > -1) {
|
||||
trows[i].style.display = "";
|
||||
var filter = searchText.toUpperCase();
|
||||
var tRows = table.getElementsByTagName("tr");
|
||||
|
||||
for (var i = 1; i < tRows.length; i++) {
|
||||
var tdArray = tRows[i].cells;
|
||||
tRows[i].style.display = "none";
|
||||
for (var j = 0; j < tdArray.length; j++) {
|
||||
if (tdArray[j].innerHTML.toUpperCase().indexOf(filter) > -1) {
|
||||
tRows[i].style.display = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user