add json file upload
This commit is contained in:
parent
b7061259f2
commit
d227db5264
@ -73,7 +73,7 @@
|
|||||||
<button style="position: relative;" id="saveAsJSONBtn" title="Save whiteboard as JSON" type="button" class="whiteboardBtn">
|
<button style="position: relative;" id="saveAsJSONBtn" title="Save whiteboard as JSON" type="button" class="whiteboardBtn">
|
||||||
<i class="far fa-file-alt"></i>
|
<i class="far fa-file-alt"></i>
|
||||||
<i style="position: absolute; top: 3px; left: 2px; color: #000000; background: grey; font-size: 0.5em; " class="fas fa-save"></i>
|
<i style="position: absolute; top: 3px; left: 2px; color: #000000; background: grey; font-size: 0.5em; " class="fas fa-save"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
@ -85,6 +85,7 @@
|
|||||||
<i class="far fa-file-alt"></i>
|
<i class="far fa-file-alt"></i>
|
||||||
<i style="position: absolute; top: 3px; left: 2px; color: #000000; font-size: 0.5em; " class="fas fa-upload"></i>
|
<i style="position: absolute; top: 3px; left: 2px; color: #000000; font-size: 0.5em; " class="fas fa-upload"></i>
|
||||||
</button>
|
</button>
|
||||||
|
<input style="display:none;" id="myFile" type="file"/>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -66,7 +66,26 @@ $(document).ready(function() {
|
|||||||
a.click();
|
a.click();
|
||||||
// Remove anchor from body
|
// Remove anchor from body
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#uploadJsonBtn").click(function() {
|
||||||
|
$("#myFile").click();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#myFile").on("change", function() {
|
||||||
|
var file = document.getElementById("myFile").files[0];
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.onload = function (e) {
|
||||||
|
try {
|
||||||
|
var j = JSON.parse(e.target.result);
|
||||||
|
whiteboard.loadJsonData(j);
|
||||||
|
} catch(e) {
|
||||||
|
alert("File was not a valid JSON!");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
reader.readAsText(file);
|
||||||
|
$(this).val("");
|
||||||
|
});
|
||||||
|
|
||||||
var dragCounter = 0;
|
var dragCounter = 0;
|
||||||
$('#whiteboardContainer').on("dragenter", function(e) {
|
$('#whiteboardContainer').on("dragenter", function(e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user