diff --git a/src/js/yunohost/controllers/home.js b/src/js/yunohost/controllers/home.js index 021d28c8..08df552c 100644 --- a/src/js/yunohost/controllers/home.js +++ b/src/js/yunohost/controllers/home.js @@ -91,9 +91,10 @@ c.checkInstall(function(isInstalled) { if (isInstalled) { - domain = window.location.hostname; + // Remove loader $('div.loader').remove(); - c.view('login', { 'domain': domain }); + // Pass domain to hide form field + c.view('login', { 'domain': window.location.hostname }); } else if (typeof isInstalled === 'undefined') { if (app.isInstalledTry > 0) { app.isInstalledTry--; @@ -134,6 +135,7 @@ */ app.post('#/login', function (c) { + // Store url from params, it could have change form 'run' state store.set('url', c.params['domain'] +'/yunohost/api'); params = { diff --git a/src/js/yunohost/helpers.js b/src/js/yunohost/helpers.js index 0e57cd38..4b10707f 100644 --- a/src/js/yunohost/helpers.js +++ b/src/js/yunohost/helpers.js @@ -43,10 +43,9 @@ }, checkInstall: function(callback) { - domain = window.location.hostname; $.ajax({ dataType: "json", - url: 'https://'+ domain +'/yunohost/api/installed', + url: 'https://'+ store.get('url') +'/installed', timeout: 3000 }) .success(function(data) { @@ -82,7 +81,7 @@ } jQuery.ajax({ - url: 'https://'+ store.get('url') + uri, + url: 'https://' + store.get('url') + uri, type: method, crossdomain: true, data: data, diff --git a/src/js/yunohost/main.js b/src/js/yunohost/main.js index 11307fc2..4c741efd 100644 --- a/src/js/yunohost/main.js +++ b/src/js/yunohost/main.js @@ -3,25 +3,6 @@ var app = Sammy('#main', function (sam) { - /** - * Application bootstrap - * - */ - sam.bind('run', function () { - - // Flash messages - var flashMessage = $('#flashMessage'); - $('#toggle-btn', flashMessage).click(function(e) { - flashMessage.toggleClass('open'); - }); - $('#clear-btn', flashMessage).click(function(e) { - flashMessage.removeClass('open').find('.messages').html(''); - $('#slider').removeClass('with-flashMessage'); - }); - - }); - - /** * Sammy Configuration * @@ -80,6 +61,28 @@ sam.isInstalledTry = 3; + + /** + * Application bootstrap + * + */ + sam.bind('run', function () { + // Store url + sam.store.set('url', window.location.hostname + '/yunohost/api'); + + // Flash messages + var flashMessage = $('#flashMessage'); + $('#toggle-btn', flashMessage).click(function(e) { + flashMessage.toggleClass('open'); + }); + $('#clear-btn', flashMessage).click(function(e) { + flashMessage.removeClass('open').find('.messages').html(''); + $('#slider').removeClass('with-flashMessage'); + }); + + }); + + /** * Errors */