updated examples

This commit is contained in:
mig 2017-05-12 17:00:05 +02:00
parent 5566cfa7e1
commit 0d1ac26cb1
2 changed files with 16 additions and 0 deletions

View file

@ -30,6 +30,7 @@
<button id="save">Save</button>
<input type="file" id="fileElem" accept="application/json" style="display:none"/>
<button id="load">Load</button>
<button id="snapshot">Snapshot</button>
<br/><br/>
<select id="mode">
<option value="self-self">Self / Self</option>

View file

@ -278,6 +278,21 @@ $(document).ready(function () {
});
});
$("#snapshot").on("click",function() {
match.viewControl("takeSnapshot",{
format: "jpeg"
})
.then((snapshot)=>{
var a = document.createElement("a");
a.href = snapshot;
a.setAttribute("download",gameName+".jpg");
a.click();
})
.catch((error)=>{
console.warn("failed:",error);
})
});
// reading file locally
var fileElem = $("#fileElem").on("change",function() {
var fileReader = new FileReader();