From: Robert Kaiser Date: Mon, 20 Nov 2017 18:26:17 +0000 (+0100) Subject: Merge branch 'master' of linz:/srv/git/lantea X-Git-Tag: production~22 X-Git-Url: https://git-public.kairo.at/?a=commitdiff_plain;h=c53a1969fd519687ca4d581077c8dc3792169bb8;hp=-c;p=lantea.git Merge branch 'master' of linz:/srv/git/lantea --- c53a1969fd519687ca4d581077c8dc3792169bb8 diff --combined js/ui.js index 263a139,1a0e23e..60abf40 --- a/js/ui.js +++ b/js/ui.js @@@ -17,11 -17,6 +17,6 @@@ var gBackendURL = "https://backend.lant var gAuthClientID = "lantea"; window.onload = function() { - if (/\/login\.html/.test(window.location)) { - // If we are in the login window, call a function to complete the process and don't do anything else here. - completeLoginWindow(); - return; - } gAction = document.getElementById("action"); gActionLabel = document.getElementById("actionlabel"); @@@ -175,16 -170,6 +170,6 @@@ function prepareLoginButton(aCallback) ); } - function completeLoginWindow() { - if (window.opener) { - window.opener.finishLogin(getParameterByName("code"), getParameterByName("state")); - window.close(); - } - else { - document.getElementById("logininfo").textContent = "You have called this document outside of the login flow, which is not supported."; - } - } - function finishLogin(aCode, aState) { if (aState == authData["state"]) { fetchBackend("login?code=" + aCode + "&state=" + aState + "&redirect_uri=" + encodeURIComponent(getRedirectURI()), "GET", null, @@@ -527,31 -512,21 +512,31 @@@ function uploadTrack() if (aStatusCode >= 400) { reportUploadStatus(false, aResult); } - else { + else if (aResult["id"]) { reportUploadStatus(true); } + else { // If no ID is returned, we assume a general error. + reportUploadStatus(false); + } } ); } -function reportUploadStatus(aSuccess, aMessage) { +function reportUploadStatus(aSuccess, aResponse) { document.getElementById("uploadStatusCloseButton").disabled = false; document.getElementById("uploadInProgress").style.display = "none"; if (aSuccess) { document.getElementById("uploadSuccess").style.display = "block"; } - else if (aMessage) { - document.getElementById("uploadErrorMsg").textContent = aMessage; + else if (aResponse["message"]) { + document.getElementById("uploadErrorMsg").textContent = aResponse["message"]; + if (aResponse["errortype"]) { + document.getElementById("uploadErrorMsg").textContent += " (" + aResponse["errortype"] + ")"; + } + document.getElementById("uploadError").style.display = "block"; + } + else if (aResponse) { + document.getElementById("uploadErrorMsg").textContent = aResponse; document.getElementById("uploadError").style.display = "block"; } else { @@@ -729,11 -704,3 +714,3 @@@ function fetchBackend(aEndpoint, aMetho aCallback(e, 500, aCallbackForwards); } } - - function getParameterByName(aName) { - // from http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript - name = aName.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); - var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), - results = regex.exec(location.search); - return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); - }