-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
44 lines (40 loc) · 1.12 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>News viewer</title>
<script src="./index.js" charset="utf-8"></script>
</head>
<body>
<h3>List of news</h3>
<div id="show-news"></div>
</body>
<script type="text/javascript">
var request = new XMLHttpRequest();
request.open("GET", "./latest_news.json", false);
request.send(null);
var value = JSON.parse(request.responseText);
window.onload = function() {
appendJSON(value);
};
function buttonClickHandler() {
console.log('click');
appendJSON(document.getElementById('text-area').value)
}
function getJSONfile(event) {
event.preventDefault();
const jsonAddress = document.getElementById('json-file').value;
fetch(jsonAddress)
.then(response => response.json())
.then(data => {
appendJSON(data);
});
}
function appendJSON(data) {
const htmlToString = false;
const jsonHTML = jsonToHTML(data)(true)(htmlToString);
document.getElementById('show-news').innerHTML = jsonHTML;
setClickListeners();
}
</script>
</html>