This repository has been archived by the owner on Oct 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
52 lines (49 loc) · 1.74 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Simple website for pretty printing JSON responses.">
<meta name="author" content="Herman Zvonimir Došilović">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<title>JSON Pretty Print</title>
<style>
#content {
font-family: 'Courier New', Courier, monospace;
}
</style>
</head>
<body>
<pre id="content"></pre>
<script type="text/javascript">
$(document).ready(function() {
var $content = $("#content");
var url = location.search.substr(1).trim();
if (url === "") {
$content.html("\
<p style=\"color: red;\">Please provide URL.</p>\
<p>Example: https://jsonpp.judge0.com?<strong>https://api.judge0.com/languages</strong></p>\
<small>Source code available on <a href=\"https://github.com/judge0/jsonpp\">GitHub</a>.</small>\
");
}
else {
$.ajax({
url: url,
type: "GET",
success: function(data, textStatus, jqXHR) {
if (typeof data === "object") {
$content.html(JSON.stringify(data, null, 4));
}
else {
$content.html("<p>Response is not a JSON.</p>");
}
},
error: function(jqXHR, textStatus, errorThrown) {
$content.html(`<p>${jqXHR.status}</p>`);
}
});
}
});
</script>
</body>
</html>