summaryrefslogtreecommitdiff
path: root/public/js/common.js
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-02-16 20:08:44 -0800
committerCheng-Han, Wu2016-02-16 20:08:44 -0800
commitb2b1be3dda406312add39997ad8bd9494f20b7f8 (patch)
tree997403359ffc0f585fa52752c399ce87287222c3 /public/js/common.js
parent3f2f063e9b6c6d36169f6acefc27df87d0bd176b (diff)
Support set url path and use relative url, move raphael to bower and fixed minor issue in history
Diffstat (limited to 'public/js/common.js')
-rw-r--r--public/js/common.js11
1 files changed, 9 insertions, 2 deletions
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/<urlpath>
+
+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;