This repository has been archived by the owner on Aug 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
75 lines (63 loc) · 1.83 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0;" />
<title>Signal backup XML view</title>
<style>
#dropzone {
border: 3px dashed black;
height: 100px;
text-align: center;
padding: 30px;
background-color: #f3f3f3;
display: table-cell; vertical-align: middle;
}
</style>
</head>
<body>
<div id="dropzone">
<strong>Drop SignalPlaintextBackup.xml here</strong>
</div>
<div id="result"></div>
<script>
function dropFile(evt) {
evt.stopPropagation();
evt.preventDefault();
var files = evt.dataTransfer.files; // FileList Objekt
processXML(files[0]);
}
function handleDragOver(evt) {
evt.stopPropagation();
evt.preventDefault();
evt.dataTransfer.dropEffect = 'copy';
}
function processXML(file){
var xslStylesheet;
var xsltProcessor = new XSLTProcessor();
var reader = new FileReader();
var domParser = new window.DOMParser();
var xmlDoc;
// load the xslt file
var myXMLHTTPRequest = new XMLHttpRequest();
myXMLHTTPRequest.open("GET", "SignalBackupTreeView.xsl", false);
myXMLHTTPRequest.send(null);
xslStylesheet = myXMLHTTPRequest.responseXML;
xsltProcessor.importStylesheet(xslStylesheet);
// load and parse the xml file
reader.readAsText(file);
reader.onload = function(e) {
xmlDoc = domParser.parseFromString(e.target.result, "text/xml");
//process XSL transformation
var fragment = xsltProcessor.transformToFragment(xmlDoc, document);
document.getElementById("result").innerHTML = "";
document.getElementById("result").appendChild(fragment);
}
}
// Initialise Drag&Drop EventListener
var dropZone = document.getElementById('dropzone');
dropZone.addEventListener('dragover', handleDragOver, false);
dropZone.addEventListener('drop', dropFile, false);
</script>
</body>
</html>