-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
45 lines (43 loc) · 1.52 KB
/
example.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Markdom Javascript Handler example</title>
<script type="text/javascript" src="src/common/string-builder.js"></script>
<script type="text/javascript" src="src/common/simple-markdom-event-dispatcher.js"></script>
<script type="text/javascript" src="src/common/html-tag-builder.js"></script>
<script type="text/javascript" src="src/json-dispatcher.js"></script>
<script type="text/javascript" src="src/debug-handler.js"></script>
<script type="text/javascript" src="src/html-handler.js"></script>
</head>
<body>
<pre id="debug-output"></pre>
<div id="output"></div>
<script type="text/javascript">
function fetch(path, callback) {
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState === 4) {
if (httpRequest.status === 200) {
if (callback) callback(httpRequest.responseText);
}
}
};
httpRequest.open('GET', path);
httpRequest.send();
}
fetch('example-data.json', function (jsonString) {
var jsonDispatcher = new JsonDispatcher(jsonString);
var debugHandler = new DebugHandler();
jsonDispatcher.dispatchTo(debugHandler);
document.getElementById('debug-output').innerText = debugHandler.getResult();
var htmlHandler = new HtmlHandler();
htmlHandler
.setEscapeHtml(true)
.setBreakSoftBreaks(true);
jsonDispatcher.dispatchTo(htmlHandler);
document.getElementById('output').innerHTML = htmlHandler.getResult();
});
</script>
</body>
</html>