diff --git a/site/index.js b/site/index.js index c52c1c2..2f78da6 100644 --- a/site/index.js +++ b/site/index.js @@ -186,7 +186,7 @@ async function startVideo(){ //player.initialize(document.querySelector("#videoPlayer"), url, true); //console.log('called startvideo'); while(true){ - if(document.querySelector('#videoPlayer') === null) + if(!document.querySelector('#videoPlayer')) break; if(window.location.pathname.substring(window.location.pathname.length - 1) !== '/'){ diff --git a/templates/base.njk b/templates/base.njk index f832bc3..aa150ed 100644 --- a/templates/base.njk +++ b/templates/base.njk @@ -12,6 +12,29 @@ xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhr.send(""); } + function makeRequest(method, url, payload) { + return new Promise(function (resolve, reject) { + let xhr = new XMLHttpRequest(); + xhr.open(method, url); + xhr.onload = function () { + if (this.status >= 200 && this.status < 300) { + resolve(xhr.response); + } else { + reject({ + status: this.status, + statusText: xhr.statusText + }); + } + }; + xhr.onerror = function () { + reject({ + status: this.status, + statusText: xhr.statusText + }); + }; + !payload ? xhr.send() : xhr.send(payload); + }); + } {% block head %} {% endblock %} diff --git a/templates/user.njk b/templates/user.njk index 09aa4c1..2a637ff 100644 --- a/templates/user.njk +++ b/templates/user.njk @@ -4,13 +4,13 @@ -->