From b2b1be3dda406312add39997ad8bd9494f20b7f8 Mon Sep 17 00:00:00 2001 From: Cheng-Han, Wu Date: Tue, 16 Feb 2016 20:08:44 -0800 Subject: Support set url path and use relative url, move raphael to bower and fixed minor issue in history --- public/js/common.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'public/js/common.js') diff --git a/public/js/common.js b/public/js/common.js index e6928e98..e84bc169 100644 --- a/public/js/common.js +++ b/public/js/common.js @@ -1,5 +1,12 @@ //common -var domain = 'change this'; +var domain = 'change this'; // domain name +var urlpath = ''; // sub url path, like: www.example.com/ + +var port = window.location.port; +var serverurl = window.location.protocol + '//' + domain + (port ? ':' + port : '') + (urlpath ? '/' + urlpath : ''); +var noteid = urlpath ? window.location.pathname.slice(urlpath.length + 1, window.location.pathname.length).split('/')[1] : window.location.pathname.split('/')[1]; +var noteurl = serverurl + '/' + noteid; + var checkAuth = false; var profile = null; var lastLoginState = getLoginState(); @@ -53,7 +60,7 @@ function checkIfAuth(yesCallback, noCallback) { if (checkLoginStateChanged()) checkAuth = false; if (!checkAuth || typeof cookieLoginState == 'undefined') { - $.get('/me') + $.get(serverurl + '/me') .done(function (data) { if (data && data.status == 'ok') { profile = data; -- cgit v1.2.3