summaryrefslogtreecommitdiff
path: root/examples/docker/web/public/js/main.js
diff options
context:
space:
mode:
authorkmeister <kris@aliencom.net>2017-04-13 18:32:00 -0400
committerkmeister <kris@aliencom.net>2017-04-13 18:32:00 -0400
commit9840fc2341f125f64a6089366197ca9012a9026f (patch)
tree991d793c31ab49655ce258629a6b52f07c8fc2b8 /examples/docker/web/public/js/main.js
parentc77e28d30ee407b073bd71f12951571b8fe63959 (diff)
[docker-exampe] moved into examples repo https://github.com/ponzu-cms/examples
Diffstat (limited to 'examples/docker/web/public/js/main.js')
-rw-r--r--examples/docker/web/public/js/main.js43
1 files changed, 0 insertions, 43 deletions
diff --git a/examples/docker/web/public/js/main.js b/examples/docker/web/public/js/main.js
deleted file mode 100644
index f9ae5fc..0000000
--- a/examples/docker/web/public/js/main.js
+++ /dev/null
@@ -1,43 +0,0 @@
-(function() {
-
- function loadHomepage() {
- const xhr = new XMLHttpRequest();
- xhr.open('GET', '/api/contents?type=Song');
- xhr.onreadystatechange = renderHomepage;
- xhr.send(null);
- }
-
- function renderHomepage(event) {
- const DONE = 4;
- const OK = 200;
- let xhr = event.currentTarget;
- let html = '';
-
- if (xhr.readyState === DONE) {
- if (xhr.status === OK) {
- const songs = window.JSON.parse(xhr.responseText).data;
- console.log(songs);
- if(songs.length === 0){
- html = '<p><strong>There have not been any Songs added, <a href="/admin">go add some at /admin</a></strong></p>';
- } else {
- html = songs.map(function(song) {
- return `
- <article>
- <h3>${song.title || 'Unknown'} by ${song.artist || 'Unknown'}</h3>
- <p>rating: ${song.rating}</p>
- <h6>opinion:</h6>
- <div>${song.opinion || 'none'}
- </article>
- `;
- }).join();
- }
- } else {
- html = '<p><strong>The /api endpoint did not respond correctly :-(</strong></p>';
- }
-
- document.querySelector('#main').innerHTML = html;
- }
- }
-
- document.addEventListener("DOMContentLoaded", loadHomepage);
-})(); \ No newline at end of file