mirror of
https://bitbucket.org/grumdrig/pq-web.git
synced 2026-09-29 00:34:00 -06:00
Allow backing up and dropping-in of characters
This commit is contained in:
+5
-2
@@ -59,6 +59,9 @@ a.icon.go {
|
|||||||
a.x, a.sheet {
|
a.x, a.sheet {
|
||||||
font-size: 12pt;
|
font-size: 12pt;
|
||||||
}
|
}
|
||||||
|
a.save {
|
||||||
|
font-size: 8px;
|
||||||
|
}
|
||||||
.sig {
|
.sig {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: small;
|
font-size: small;
|
||||||
@@ -132,14 +135,14 @@ img {
|
|||||||
<div class="bs">$bestequip / $bestspell / $beststat</div>
|
<div class="bs">$bestequip / $bestspell / $beststat</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a class="icon x" href="#">☠</a><br>
|
<a class="icon x" href="#" title="Delete game">☠</a><br>
|
||||||
<!-- <a class="sheet" href="#">✏</a> -->
|
<!-- <a class="sheet" href="#">✏</a> -->
|
||||||
|
<a class="save" href="#" title="Download a backup file">💾</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/charsheet" id="sheet">
|
<script type="text/charsheet" id="sheet">
|
||||||
$Traits.Name the $Traits.Race [$hostname]
|
$Traits.Name the $Traits.Race [$hostname]
|
||||||
"$motto"
|
"$motto"
|
||||||
|
|||||||
@@ -7,6 +7,37 @@ function load() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
storage.loadRoster(loadGames);
|
storage.loadRoster(loadGames);
|
||||||
|
|
||||||
|
window.addEventListener("dragover", e => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.dataTransfer.dropEffect = "copy";
|
||||||
|
});
|
||||||
|
window.addEventListener("drop", e => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
let files = e.dataTransfer.files;
|
||||||
|
for (let i = 0; i < files.length; i++) {
|
||||||
|
files[i].text().then(sheet => {
|
||||||
|
try {
|
||||||
|
sheet = sheet.replace(/\s/g, "");
|
||||||
|
sheet = atob(sheet);
|
||||||
|
sheet = JSON.parse(sheet);
|
||||||
|
storage.loadRoster(games => {
|
||||||
|
if (!games[sheet.Traits.Name] ||
|
||||||
|
confirm(`A character named ${sheet.Traits.Name} already exists. Overwrite it?`)) {
|
||||||
|
storage.addToRoster(sheet, () => storage.loadRoster(loadGames));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch(err) {
|
||||||
|
console.log(err);
|
||||||
|
setTimeout(() => alert("Invalid character data", 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadGames(games) {
|
function loadGames(games) {
|
||||||
@@ -38,14 +69,31 @@ function loadGames(games) {
|
|||||||
// TODO: put in a window or whatev
|
// TODO: put in a window or whatev
|
||||||
});
|
});
|
||||||
|
|
||||||
|
br.find("a.save").attr("href",
|
||||||
|
`data:text/plain;name=${name}.pqw,${btoa(JSON.stringify(c))}`);
|
||||||
|
br.find("a.save").attr("download", `${name}.pqw`);
|
||||||
|
|
||||||
if (name === newone)
|
if (name === newone)
|
||||||
br.addClass("lit");
|
br.addClass("lit");
|
||||||
|
|
||||||
/*
|
br.click(e => {
|
||||||
var p = $("<p style='font:6pt verdana'/>");
|
if (e.altKey) {
|
||||||
p.appendTo(roster);
|
let text = btoa(JSON.stringify(c));
|
||||||
p.text(JSON.stringify(c));
|
text = text.match(/.{1,80}/g).join('\n');
|
||||||
*/
|
$("dialog#copy pre").text(text);
|
||||||
|
$("dialog#copy span").text(name);
|
||||||
|
sel = window.getSelection();
|
||||||
|
window.setTimeout(() => {
|
||||||
|
let range = document.createRange();
|
||||||
|
range.selectNodeContents($("dialog#copy pre")[0]);
|
||||||
|
sel.removeAllRanges();
|
||||||
|
sel.addRange(range);
|
||||||
|
}, 1);
|
||||||
|
$("dialog#copy")[0].showModal();
|
||||||
|
// window.prompt("Copy to clipboard", text);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
br.find("a.go").attr("data-downloadurl", `text/plain:${name}.pqw:data:text/plain,${btoa(JSON.stringify(c))}`);
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
});
|
});
|
||||||
@@ -79,10 +127,6 @@ $(document).ready(function () {
|
|||||||
window.location = "newguy.html";
|
window.location = "newguy.html";
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#roll").click(function () {
|
|
||||||
window.location = "newguy.html?online";
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#test").click(function () {
|
$("#test").click(function () {
|
||||||
window.location = "newguy.html?sold";
|
window.location = "newguy.html?sold";
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user