summaryrefslogtreecommitdiff
path: root/public/js
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-04-20 18:03:55 +0800
committerCheng-Han, Wu2016-04-20 18:03:55 +0800
commit49b51e478fa75b8d5254662de3265edcf8906004 (patch)
tree3b09213baae129156339b5ad496924f591790e88 /public/js
parente613aeba75aec5ceb4f10ae62881a3635183857d (diff)
Refactor server with Sequelize ORM, refactor server configs, now will show note status (created or updated) and support docs (note alias)
Diffstat (limited to 'public/js')
-rw-r--r--public/js/extra.js15
-rw-r--r--public/js/history.js10
-rw-r--r--public/js/index.js17
-rw-r--r--public/js/pretty.js3
4 files changed, 34 insertions, 11 deletions
diff --git a/public/js/extra.js b/public/js/extra.js
index 41b984dc..be454ed7 100644
--- a/public/js/extra.js
+++ b/public/js/extra.js
@@ -1,15 +1,24 @@
//auto update last change
+var createtime = null;
var lastchangetime = null;
var lastchangeui = {
+ status: $(".ui-status-lastchange"),
time: $(".ui-lastchange"),
user: $(".ui-lastchangeuser"),
nouser: $(".ui-no-lastchangeuser")
}
function updateLastChange() {
- if (lastchangetime && lastchangeui) {
- lastchangeui.time.html(moment(lastchangetime).fromNow());
- lastchangeui.time.attr('title', moment(lastchangetime).format('llll'));
+ if (!lastchangeui) return;
+ if (createtime) {
+ if (createtime && !lastchangetime) {
+ lastchangeui.status.text('created');
+ } else {
+ lastchangeui.status.text('changed');
+ }
+ var time = lastchangetime || createtime;
+ lastchangeui.time.html(moment(time).fromNow());
+ lastchangeui.time.attr('title', moment(time).format('llll'));
}
}
setInterval(updateLastChange, 60000);
diff --git a/public/js/history.js b/public/js/history.js
index edecde1d..b3bae980 100644
--- a/public/js/history.js
+++ b/public/js/history.js
@@ -93,8 +93,14 @@ function clearDuplicatedHistory(notehistory) {
for (var i = 0; i < notehistory.length; i++) {
var found = false;
for (var j = 0; j < newnotehistory.length; j++) {
- var id = LZString.decompressFromBase64(notehistory[i].id);
- var newId = LZString.decompressFromBase64(newnotehistory[j].id);
+ var id = notehistory[i].id;
+ var newId = newnotehistory[j].id;
+ try {
+ id = LZString.decompressFromBase64(id);
+ newId = LZString.decompressFromBase64(newId);
+ } catch (err) {
+ // na
+ }
if (id == newId || notehistory[i].id == newnotehistory[j].id || !notehistory[i].id || !newnotehistory[j].id) {
var time = moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a');
var newTime = moment(newnotehistory[j].time, 'MMMM Do YYYY, h:mm:ss a');
diff --git a/public/js/index.js b/public/js/index.js
index 6cbaf066..0e4fd21a 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -1423,7 +1423,7 @@ function updatePermission(newPermission) {
title = "Only owner can view & edit";
break;
}
- if (personalInfo.userid == owner) {
+ if (personalInfo.userid && personalInfo.userid == owner) {
label += ' <i class="fa fa-caret-down"></i>';
ui.infobar.permission.label.removeClass('disabled');
} else {
@@ -1476,11 +1476,14 @@ socket.emit = function () {
socket.on('info', function (data) {
console.error(data);
switch (data.code) {
+ case 403:
+ location.href = "./403";
+ break;
case 404:
location.href = "./404";
break;
- case 403:
- location.href = "./403";
+ case 500:
+ location.href = "./500";
break;
}
});
@@ -1517,11 +1520,15 @@ socket.on('version', function (data) {
});
function updateLastInfo(data) {
//console.log(data);
- if (lastchangetime !== data.updatetime) {
+ if (data.hasOwnProperty('createtime') && createtime !== data.createtime) {
+ createtime = data.createtime;
+ updateLastChange();
+ }
+ if (data.hasOwnProperty('updatetime') && lastchangetime !== data.updatetime) {
lastchangetime = data.updatetime;
updateLastChange();
}
- if (lastchangeuser !== data.lastchangeuser) {
+ if (data.hasOwnProperty('lastchangeuser') && lastchangeuser !== data.lastchangeuser) {
lastchangeuser = data.lastchangeuser;
lastchangeuserprofile = data.lastchangeuserprofile;
updateLastChangeUser();
diff --git a/public/js/pretty.js b/public/js/pretty.js
index 44d27e54..2d1f27de 100644
--- a/public/js/pretty.js
+++ b/public/js/pretty.js
@@ -20,7 +20,8 @@ renderTOC(markdown);
generateToc('toc');
generateToc('toc-affix');
smoothHashScroll();
-lastchangetime = lastchangeui.time.text();
+createtime = lastchangeui.time.attr('data-createtime');
+lastchangetime = lastchangeui.time.attr('data-updatetime');
updateLastChange();
var url = window.location.pathname;
$('.ui-edit').attr('href', url + '/edit');