From 9840fc2341f125f64a6089366197ca9012a9026f Mon Sep 17 00:00:00 2001 From: kmeister Date: Thu, 13 Apr 2017 18:32:00 -0400 Subject: [docker-exampe] moved into examples repo https://github.com/ponzu-cms/examples --- examples/docker/web/public/js/main.js | 43 ----------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 examples/docker/web/public/js/main.js (limited to 'examples/docker/web/public/js/main.js') 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 = '

There have not been any Songs added, go add some at /admin

'; - } else { - html = songs.map(function(song) { - return ` -
-

${song.title || 'Unknown'} by ${song.artist || 'Unknown'}

-

rating: ${song.rating}

-
opinion:
-
${song.opinion || 'none'} -
- `; - }).join(); - } - } else { - html = '

The /api endpoint did not respond correctly :-(

'; - } - - document.querySelector('#main').innerHTML = html; - } - } - - document.addEventListener("DOMContentLoaded", loadHomepage); -})(); \ No newline at end of file -- cgit v1.2.3