forked from GitHub-Mirrors/foundry-sw5e
Added Dialog.
Added the Dialog. However, been unable to get json upload to work. Will change my method to use a textarea input instead.
This commit is contained in:
parent
af2eb1e97e
commit
892be9986e
2 changed files with 37 additions and 19 deletions
1
examples/Mushu.json
Normal file
1
examples/Mushu.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"flavor":{"faction":"","environment":"","description":"","nameIsProper":true,"imageUrl":"https://static.wikia.nocookie.net/disney/images/1/17/Profile_-_Mushu.jpeg/revision/latest?cb=20190425004614","descriptionHtml":""},"stats":{"size":"Small","race":"Dragon","alignment":"Unaligned","armorType":"Natural Armor","armorClass":16,"numHitDie":15,"speed":"40 ft.","abilityScores":{"strength":16,"dexterity":12,"constitution":15,"intelligence":8,"wisdom":14,"charisma":8},"proficiencyBonus":0,"damageVulnerabilities":[],"damageResistances":[],"damageImmunities":["Fire"],"conditionImmunities":[],"senses":["darkvision 60ft.","Passive Oerception 12"],"languages":["Draconic"],"challengeRating":2,"experiencePoints":450,"legendaryActionsPerRound":3,"legendaryActionsDescription":"","savingThrows":[{"ability":"dexterity","proficient":false,"value":1,"modifier":1,"modifierStr":"Dex +1","$$hashKey":"object:1076"},{"ability":"wisdom","proficient":false,"value":2,"modifier":2,"modifierStr":"Wis +2","$$hashKey":"object:1077"}],"skills":[],"additionalAbilities":[],"actions":[{"name":"Bite","description":"<i>Melee Weapon Attack:</i> +5 to hit, reach 5 ft., one target. <i>Hit:</i> 4 (1d6) piercing and 2 fire damage.\n<avrae hidden>Bite|+5|1d6 [piercing]+2 [fire]</avrae>","descriptionHtml":{},"$$hashKey":"object:1060"}],"reactions":[{"name":"Infused Strikes.","description":"When another creature within 30 feet of the drake that it can see hits with a weapon attack, the drake infuses the strike with its essence, causing the attack to deal an extra 1d6 [fire] damage","descriptionHtml":{},"$$hashKey":"object:1065"}],"legendaryActions":[],"hitDieSize":10,"armorTypeStr":"(Natural Armor)","abilityScoreModifiers":{"strength":3,"dexterity":1,"constitution":2,"intelligence":-1,"wisdom":2,"charisma":-1},"abilityScoreStrs":{"strength":"16 (+3)","dexterity":"12 (+1)","constitution":"15 (+2)","intelligence":"8 (–1)","wisdom":"14 (+2)","charisma":"8 (–1)"},"extraHealthFromConstitution":30,"hitPoints":112,"hitPointsStr":"112 (15d10 + 30)","passivePerception":12,"challengeRatingStr":"2"},"sharing":{"linkSharingEnabled":true},"_id":"5fd0466f60c2d632c8613e3d","name":"Mushu","__v":0,"publishedBestiaryId":"5fd045c660c2d632c8613e19"}
|
|
@ -1295,29 +1295,46 @@ export default class CharacterImporter {
|
||||||
newSearch.appendTo(header);
|
newSearch.appendTo(header);
|
||||||
|
|
||||||
let characterImportButton = $("#cs-import-button");
|
let characterImportButton = $("#cs-import-button");
|
||||||
characterImportButton.click(e => {
|
characterImportButton.click(ev => {
|
||||||
let file;
|
console.log("FISH: character import button pressed. 2")
|
||||||
let content = '<h1>Saved Character JSONImport</h1> '
|
let files = [];
|
||||||
|
let content = '<h1>Saved Character JSON Import</h1> '
|
||||||
+ '<input class="file-picker" type="file" id="sw5e-character-json" accept=".json" multiple name="sw5e-character-json">'
|
+ '<input class="file-picker" type="file" id="sw5e-character-json" accept=".json" multiple name="sw5e-character-json">'
|
||||||
+ '<hr>'
|
+ '<hr>'
|
||||||
+ '<div class="sw5e-file-import"></div>';
|
+ '<div class="sw5e-file-import"></div>';
|
||||||
let importDialog = new Dialog({
|
let importDialog = new Dialog({
|
||||||
title: "Import Character from SW5e.com",
|
title: "Import Character from SW5e.com",
|
||||||
content: "HTML Content",
|
content: content,
|
||||||
buttons: "The buttons which are disapled as action chjoices for teh dialog",
|
buttons: {
|
||||||
render: "A callback function invoed when teh dialog is rendered",
|
"Import": {
|
||||||
close: "Common callback operations to perform when the dialog is closed"
|
icon: '<i class="fas fa-file-import"></i>',
|
||||||
}
|
label: "Import Character",
|
||||||
|
callback: (e) => {
|
||||||
|
files = document.querySelector('#sw5e-character-json').files;
|
||||||
|
if (files){
|
||||||
|
for (let i = 0; i < files.length; i++){
|
||||||
|
console.log("Importing character...");
|
||||||
|
console.log(JSON.stringify(files));
|
||||||
|
const readerooni = new FileReader();
|
||||||
|
readerooni.onload = async (x) => {
|
||||||
|
const characterData = JSON.parse(x.target.result);
|
||||||
|
|
||||||
|
}
|
||||||
|
readerooni.readAsText(files[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("No files selected...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Cancel": {
|
||||||
|
icon: '<i class="fas fa-times-circle"></i>',
|
||||||
|
label: "Cancel",
|
||||||
|
callback: () => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
importDialog.render(true);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
var c = new CharacterImporter().import('filename').transform();
|
|
||||||
*/
|
|
Loading…
Add table
Add a link
Reference in a new issue