basic video tile

This commit is contained in:
lukas-heiligenbrunner
2020-03-31 11:44:52 +02:00
parent e8f6da345c
commit 237a5742cf
5 changed files with 72 additions and 1 deletions

33
js/BaseRequest.js Normal file
View File

@@ -0,0 +1,33 @@
class Req {
static post(url, data, callback) {
const xhttp = new XMLHttpRequest();
xhttp.open("POST",url,true);
xhttp.onload = function(){
if (this.readyState == 4 && this.status == 200) {
callback(JSON.parse(xhttp.responseText));
}
}
xhttp.onerror = function () {
console.log("error")
};
xhttp.send(data);
}
static get(url, callback) {
const xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function(){
if (this.readyState == 4 && this.status == 200) {
callback(JSON.parse(xhttp.responseText));
}else{
console.log("err")
}
}
xhttp.open("GET",url,true);
xhttp.send();
}
static ready(callback){
document.addEventListener('DOMContentLoaded', callback);
}
}

9
js/index.js Normal file
View File

@@ -0,0 +1,9 @@
Req.ready((event) => {
Req.post("php/movie.php", "action=getMovies", function (dta) {
console.log(dta);
// for (const ii in dta.movies) {
// document.getElementsByClassName("mediawrapper").item(0).insertAdjacentHTML('beforeend', `
// <div class="mediatile">${dta.movies[ii].title}</div>`);
// }
});
});