1<!DOCTYPE html> 2<html> 3<head> 4<meta charset="UTF-8"> 5<title>VSDX Importer</title> 6<script type="text/javascript" src="js/app.min.js"></script> 7<script type="text/javascript" src="js/extensions.min.js"></script> 8<script type="text/javascript"> 9 function doImport(vsdxBuff, callback, error, file, customParam) 10 { 11 EditorUi.prototype.createUi = function(){}; 12 EditorUi.prototype.addTrees = function(){}; 13 EditorUi.prototype.updateActionStates = function(){}; 14 var editorUi = new EditorUi(); 15 var blob = file? file : new Blob([vsdxBuff], {type: 'application/octet-stream'}); 16 17 editorUi.importVisio(blob, callback, error, file? file.name : null, customParam); 18 }; 19 20 try 21 { 22 const { ipcRenderer } = require('electron'); 23 24 ipcRenderer.on('import', (event, vsdxBuff) => 25 { 26 doImport(vsdxBuff, function(xml) 27 { 28 ipcRenderer.send('import-success', xml); 29 }, 30 function() 31 { 32 ipcRenderer.send('import-error'); 33 }); 34 }); 35 } 36 catch(e) {} //Ignore 37</script> 38</head> 39<body> 40 <input type="file" id="fileUpload"> 41 <script type="text/javascript"> 42 document.getElementById('fileUpload').addEventListener('change', function() 43 { 44 const curFiles = this.files; 45 46 if(curFiles.length > 0) 47 { 48 function createDoneDiv(msg) 49 { 50 var doneDiv = document.createElement('div'); 51 doneDiv.id = 'doneDiv'; 52 doneDiv.innerHTML = msg; 53 document.body.appendChild(doneDiv); 54 }; 55 56 doImport(null, function(xml) 57 { 58 window.importResXML = xml; 59 createDoneDiv('success'); 60 }, function(err) 61 { 62 console.log(err) 63 createDoneDiv('error'); 64 }, curFiles[0], window.customParam); 65 } 66 }); 67 </script> 68</body> 69</html>