-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
258 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
|
||
<title>Jikka Gallery</title> | ||
<meta name="description" content="" /> | ||
<link | ||
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" | ||
rel="stylesheet" | ||
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" | ||
crossorigin="anonymous" | ||
/> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" | ||
integrity="sha384-doAc3Z0i+SBp0Img0yrmvdUG7+DLbBYeol0n0hqTTKNgz9MINQa16YnwWGIcCzqz" | ||
crossorigin="anonymous" | ||
/> | ||
<script | ||
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" | ||
crossorigin="anonymous" | ||
></script> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/default.min.css" | ||
integrity="sha384-bVi32MzPMHhQQoX43XwbzyE2I2YlQETXzSzS0rnURpcv/pkxtPnZ8QpbAN9AzEu5" | ||
crossorigin="anonymous" | ||
/> | ||
<script | ||
src="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js" | ||
integrity="sha384-385VkHYTcYER9bopCYIl/TMrS6E92YLBFzSpK3C7aeWw4kyfHy6ZHJ5/AA1UwYbM" | ||
crossorigin="anonymous" | ||
></script> | ||
<script | ||
src="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/languages/haskell.min.js" | ||
integrity="sha384-hP6+W7Cbc2Vq7E5YIwkiT+03DZqfu7d0VS5UwnqZDCS/Z3GR0jytu0rtkjZl2koX" | ||
crossorigin="anonymous" | ||
></script> | ||
<script src="index.js"></script> | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark"> | ||
<div class="container-fluid"> | ||
<a class="navbar-brand" href="#">Jikka Gallery</a> | ||
</div> | ||
</nav> | ||
|
||
<div class="container"> | ||
<h2 class="mt-3 mb-3">Jikka Gallery</h2> | ||
|
||
<div id="gallery" class="container-md">loading...</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
function loadData() { | ||
const req = new XMLHttpRequest(); | ||
req.open("GET", "data.json", false); | ||
req.send(); | ||
if (req.status != 200) { | ||
throw Error(req.statusText); | ||
} | ||
return JSON.parse(req.responseText); | ||
} | ||
|
||
function appendHeader(div, level, text) { | ||
const h = document.createElement("h" + level.toString()); | ||
h.textContent = text; | ||
div.appendChild(h); | ||
} | ||
|
||
function appendPreCode(div, text, lang) { | ||
const pre = document.createElement("pre"); | ||
const code = document.createElement("code"); | ||
code.classList.add("language-" + lang); | ||
code.textContent = text; | ||
pre.appendChild(code); | ||
div.appendChild(pre); | ||
return pre; | ||
} | ||
|
||
function appendCommon(gallery, example) { | ||
appendHeader(gallery, 3, example["path"]); | ||
|
||
// Use two panes | ||
const div = document.createElement("div"); | ||
div.classList.add("row"); | ||
const left = document.createElement("div"); | ||
const right = document.createElement("div"); | ||
left.classList.add("col-lg-6"); | ||
right.classList.add("col-lg-6"); | ||
div.appendChild(left); | ||
div.appendChild(right); | ||
gallery.appendChild(div); | ||
|
||
appendHeader(left, 4, "Input"); | ||
appendHeader(right, 4, "Output"); | ||
|
||
appendHeader(left, 5, "Python"); | ||
appendPreCode(left, example["python"], "python"); | ||
return right; | ||
} | ||
|
||
function appendExample(gallery, example) { | ||
const right = appendCommon(gallery, example); | ||
// appendPreCode(right, example["rpython"], "python"); | ||
appendHeader(right, 5, "core"); | ||
appendPreCode(right, example["core"], "haskell"); | ||
appendHeader(right, 5, "C++"); | ||
appendPreCode(right, example["cxx"], "cxx"); | ||
} | ||
|
||
function appendError(gallery, example) { | ||
const right = appendCommon(gallery, example); | ||
appendPreCode(right, example["error"], "plain"); | ||
} | ||
|
||
window.addEventListener("DOMContentLoaded", function () { | ||
const gallery = document.getElementById("gallery"); | ||
let data; | ||
try { | ||
data = loadData(); | ||
} catch (error) { | ||
console.error(error); | ||
gallery.textContent = "error: " + error; | ||
return; | ||
} | ||
|
||
while (gallery.lastChild) { | ||
gallery.removeChild(gallery.lastChild); | ||
} | ||
for (const example of data["examples"]) { | ||
appendExample(gallery, example); | ||
} | ||
for (const example of data["errors"]) { | ||
appendError(gallery, example); | ||
} | ||
document.querySelectorAll("pre code").forEach((el) => { | ||
hljs.highlightElement(el); | ||
}); | ||
}); |
Oops, something went wrong.