CryptoAssist/src/menu.js

35 lines
975 B
JavaScript
Raw Normal View History

2017-02-26 23:38:06 +00:00
var $ = require("jquery");
2017-02-27 10:38:33 +00:00
var events = require("./events.js");
var diagram = require("./diagram");
2017-02-26 23:38:06 +00:00
$("#header>a#export").click(function(){
var fileSaver = require("file-saver");
var exported = require("./diagram/export.js")();
var exportedBlob = new Blob([exported], {type: "text/plain;chartset=utf-8"})
fileSaver.saveAs(exportedBlob, diagram.name + ".json");
});
$("#header>a#import").click(function(){
$("#header>#importUpload").click();
});
$("#header>#importUpload").change(function(){
var reader = new FileReader();
reader.onload = function(){
require("./diagram/import.js")(reader.result);
}
reader.readAsText(this.files[0]);
2017-02-27 10:38:33 +00:00
});
$("#header>a#projectName").click(function(){
do{
diagram.name = prompt("Please enter a name for the diagram", diagram.name);
}
while(!diagram.name);
$("#header>a#projectName").html(diagram.name);
});
events.subscribe("diagramImport", function(){
$("#header>a#projectName").html(diagram.name);
});