-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwexpviewer.html
86 lines (75 loc) · 2.98 KB
/
twexpviewer.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
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="./css/twexpviewer.css" />
<link rel="stylesheet" href="./css/hjs/styles/zenburn.css" />
<script src="./js/hjs/highlight.pack.js"></script>
<script src="./js/nomnoml/lib/lodash.min.js"></script>
<script src="./js/nomnoml/lib/dagre.min.js"></script>
<script src="./js/nomnoml/nomnoml.js"></script>
<script src="./js/twexpviewer_model.js"></script>
<script src="./js/twexpviewer_checks.js"></script>
<script src="./js/twexpviewer_ui.js"></script>
<script src="./js/twexpviewer.js"></script>
<title>Thingworx Export Viewer</title>
<script>
function openXML(file_name) {
let xhttp = new XMLHttpRequest();
xhttp.open("GET", EXPORTS_DIR + file_name, false);
xhttp.send();
return xhttp.responseXML;
}
function importXSL(file_name = "./xsl/twexpviewer.xsl") {
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
XSLT_PROCESSOR.importStylesheet(this.responseXML);
}
};
xhttp.open("GET", file_name, true);
xhttp.send();
}
function importXML(xml) {
XSLT_PROCESSOR.setParameter(null, "source", "fromhtml");
const fragment = XSLT_PROCESSOR.transformToFragment(xml, document);
document.getElementById('loader').style.display = "none";
document.body.appendChild(fragment);
loadAll(xml);
}
function fileOpenCB(e) {
let file = e.target.files[0];
if (!file) {
return;
}
const xml = openXML(file.name);
importXML(xml);
}
function onloadFromHTML() {
document.getElementById('xml-file').addEventListener('change', fileOpenCB, false);
let url = window.location.href;
document.getElementById('xml-dir').innerHTML = url.substr(0, url.lastIndexOf('/')+1) + EXPORTS_DIR;
}
</script>
</head>
<body onload="onloadFromHTML()">
<script>
const EXPORTS_DIR = "./exports/";
const XSLT_PROCESSOR = new XSLTProcessor();
importXSL();
</script>
<div id="loader">
<h2>ThingWorx Export Viewer - <mark>Firefox only</mark></h2>
<h3>Usage :</h3>
<ol>
<li>Copy the ThingWorx XML export into <b><span id="xml-dir"></span></b></li>
<li>Open the XML with : <input type="file" id="xml-file" placeholder="AllEntities.xml"/></li>
</ol>
<h3>Important :</h3>
<p>The following setting is required with recent versions of Firefox :</p>
<ul>
<li>Open <b><a href="about:config">about:config</a></b> from the browser url and set <b>security.fileuri.strict_origin_policy</b> option to <b>false</b></li>
</ul>
</div>
</body>
</html>