aboutsummaryrefslogtreecommitdiffstats
path: root/public
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2019-03-23 13:43:02 +0100
committerHarald Eilertsen <haraldei@anduin.net>2019-03-23 13:43:02 +0100
commit23abdc9488ef84d852a5029340a2ac3c66943d99 (patch)
tree370ccaa6d4d106b78f9973e5ba6d220138400557 /public
parent2c695e96a81c45d930b351d8dc1445684f4afc2b (diff)
downloadramaskrik-social-23abdc9488ef84d852a5029340a2ac3c66943d99.tar.gz
ramaskrik-social-23abdc9488ef84d852a5029340a2ac3c66943d99.tar.bz2
ramaskrik-social-23abdc9488ef84d852a5029340a2ac3c66943d99.zip
Fetch rooms from database using ajax/json.
Diffstat (limited to 'public')
-rw-r--r--public/index.html4
-rw-r--r--public/js/app.js22
2 files changed, 26 insertions, 0 deletions
diff --git a/public/index.html b/public/index.html
index abb347e..6e6333f 100644
--- a/public/index.html
+++ b/public/index.html
@@ -7,5 +7,9 @@
</head>
<body>
<h1>Ramaskrik 2019</h1>
+ <div id="program">
+ <table id="screening-table">
+ </table>
+ </div>
</body>
</html>
diff --git a/public/js/app.js b/public/js/app.js
index 6f30a1f..6148be4 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -16,6 +16,14 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+function fetch_rooms(data_done) {
+ let req = new XMLHttpRequest()
+ req.addEventListener("load", data_done)
+ req.open("GET", "http://localhost:8000/rooms")
+ req.responseType = "json"
+ req.send()
+}
+
function load_screenings(data_done) {
let req = new XMLHttpRequest()
req.addEventListener("load", data_done)
@@ -42,10 +50,24 @@ function log_film(film) {
}
window.addEventListener("load", function() {
+ /*
load_screenings(function() {
this.response.forEach(function(film) {
log_film(film)
})
})
+ */
+ fetch_rooms(function() {
+ let table = document.getElementById("screening-table")
+ let row = document.createElement("tr")
+ table.appendChild(row)
+
+ this.response.forEach(function(room) {
+ console.log(room["name"])
+ let item = document.createElement("th")
+ item.innerHTML = room["name"]
+ row.appendChild(item)
+ })
+ })
console.log("Holahey!")
})