Commit f2da72ed authored by jan.koester's avatar jan.koester
Browse files

test

parent 4cf9af08
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -8,13 +8,15 @@ var EditorApi = (function() {
    function request(method, url, data) {
        return new Promise(function(resolve, reject) {
            var xhr = new XMLHttpRequest();
            xhr.open(method, url, true);
            // Strip the leading slash so the URL resolves against the document
            // <base href> (set in <head>) and honours the proxy prefix (/editor).
            xhr.open(method, url.replace(/^\//, ''), true);
            xhr.setRequestHeader('Content-Type', 'application/json');
            xhr.onreadystatechange = function() {
                if (xhr.readyState !== 4) return;
                if (xhr.status === 401) {
                    // Not authenticated — redirect to login
                    window.location.href = '/login.html';
                    window.location.href = 'login.html';
                    return;
                }
                if (xhr.status >= 200 && xhr.status < 300) {
@@ -45,12 +47,12 @@ var EditorApi = (function() {
    function requestCancellable(method, url, data) {
        var xhr = new XMLHttpRequest();
        var promise = new Promise(function(resolve, reject) {
            xhr.open(method, url, true);
            xhr.open(method, url.replace(/^\//, ''), true);
            xhr.setRequestHeader('Content-Type', 'application/json');
            xhr.onreadystatechange = function() {
                if (xhr.readyState !== 4) return;
                if (xhr.status === 401) {
                    window.location.href = '/login.html';
                    window.location.href = 'login.html';
                    return;
                }
                if (xhr.status >= 200 && xhr.status < 300) {
+2 −2
Original line number Diff line number Diff line
@@ -219,9 +219,9 @@

        document.getElementById('btn-logout').addEventListener('click', function() {
            EditorApi.logout().then(function() {
                window.location.href = '/login.html';
                window.location.href = 'login.html';
            }).catch(function() {
                window.location.href = '/login.html';
                window.location.href = 'login.html';
            });
        });

+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ var I18n = (function() {

    function load(callback) {
        var xhr = new XMLHttpRequest();
        xhr.open('GET', '/api/i18n', true);
        xhr.open('GET', 'api/i18n', true);
        xhr.onreadystatechange = function() {
            if (xhr.readyState !== 4) return;
            if (xhr.status === 200) {
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ var Preview = (function() {
    function refresh() {
        // Fetch render data (blogUrl, authid, html) then POST directly
        // to the blog's /render endpoint inside the iframe.
        fetch('/api/preview/page')
        fetch('api/preview/page')
            .then(function(r) { return r.json(); })
            .then(function(data) {
                if (data.error) {