added example deck and added import function

This commit is contained in:
bluesaxman
2020-05-19 17:00:02 -06:00
parent 11fe602f70
commit ea37f2f436
2 changed files with 37 additions and 1 deletions

View File

@@ -8,12 +8,26 @@
Welcome to Deckcard
</body>
<script>
function generateDeck(DDF) {
var cards = [""];
for (var attribute in DDF) {
var tempcards = [];
cards.forEach( function (current) {
DDF[attribute].forEach( function (value) {
tempcards.push(current+value);
} );
} );
cards = tempcards.slice();
}
return cards;
}
var menu = elementPlace("body","menu",null,"div");
buttonAdd("#menu","upload","Upload Deck", function () {
popupDialog("deckLoader","Select Deck definition File",true,inputDialog,{"inputType":"file"},function (f) {
var myFile = new FileReader();
myFile.onload = function (file) {
window.deck = file.target.result;
window.deck = generateDeck(JSON.parse(file.target.result));
}
myFile.readAsText(f[0]);
})