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");
);
}
-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,
if (aSuccess) {
document.getElementById("uploadSuccess").style.display = "block";
}
- else if (aResponse["message"]) {
+ else if (aResponse && aResponse["message"]) {
document.getElementById("uploadErrorMsg").textContent = aResponse["message"];
if (aResponse["errortype"]) {
document.getElementById("uploadErrorMsg").textContent += " (" + aResponse["errortype"] + ")";
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, " "));
-}