Improved update last info methods, only change DOM when necessary
This commit is contained in:
parent
30d194bba4
commit
526f5c7e2e
3 changed files with 31 additions and 17 deletions
|
@ -14,11 +14,14 @@ function updateLastChange() {
|
|||
}
|
||||
setInterval(updateLastChange, 60000);
|
||||
|
||||
function updateLastChangeUser(data) {
|
||||
if (data.lastchangeuserprofile) {
|
||||
var lastchangeuser = null;
|
||||
var lastchangeuserprofile = null;
|
||||
function updateLastChangeUser() {
|
||||
if (lastchangeui) {
|
||||
if (lastchangeuser && lastchangeuserprofile) {
|
||||
var icon = lastchangeui.user.children('i');
|
||||
icon.attr('title', data.lastchangeuserprofile.name).tooltip('fixTitle');
|
||||
icon.attr('style', 'background-image:url(' + data.lastchangeuserprofile.photo + ')');
|
||||
icon.attr('title', lastchangeuserprofile.name).tooltip('fixTitle');
|
||||
icon.attr('style', 'background-image:url(' + lastchangeuserprofile.photo + ')');
|
||||
lastchangeui.user.show();
|
||||
lastchangeui.nouser.hide();
|
||||
} else {
|
||||
|
@ -26,6 +29,7 @@ function updateLastChangeUser(data) {
|
|||
lastchangeui.nouser.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get title
|
||||
function getTitle(view) {
|
||||
|
|
|
@ -1481,10 +1481,21 @@ socket.on('version', function (data) {
|
|||
if (data != version)
|
||||
setNeedRefresh();
|
||||
});
|
||||
socket.on('check', function (data) {
|
||||
function updateLastInfo(data) {
|
||||
//console.log(data);
|
||||
if (lastchangetime !== data.updatetime) {
|
||||
lastchangetime = data.updatetime;
|
||||
updateLastChange();
|
||||
updateLastChangeUser(data);
|
||||
}
|
||||
if (lastchangeuser !== data.lastchangeuser) {
|
||||
lastchangeuser = data.lastchangeuser;
|
||||
lastchangeuserprofile = data.lastchangeuserprofile;
|
||||
updateLastChangeUser();
|
||||
}
|
||||
}
|
||||
socket.on('check', function (data) {
|
||||
//console.log(data);
|
||||
updateLastInfo(data);
|
||||
});
|
||||
socket.on('permission', function (data) {
|
||||
updatePermission(data.permission);
|
||||
|
@ -1494,14 +1505,13 @@ var otk = null;
|
|||
var owner = null;
|
||||
var permission = null;
|
||||
socket.on('refresh', function (data) {
|
||||
//console.log(data);
|
||||
docmaxlength = data.docmaxlength;
|
||||
editor.setOption("maxLength", docmaxlength);
|
||||
otk = data.otk;
|
||||
owner = data.owner;
|
||||
updatePermission(data.permission);
|
||||
lastchangetime = data.updatetime;
|
||||
updateLastChange();
|
||||
updateLastChangeUser(data);
|
||||
updateLastInfo(data);
|
||||
if (!loaded) {
|
||||
var nocontent = editor.getValue().length <= 0;
|
||||
if (nocontent) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<div class="ui-infobar container-fluid unselectable hidden-print">
|
||||
<small>
|
||||
<span>
|
||||
<span class="ui-lastchangeuser"> <i class="ui-user-icon small" data-toggle="tooltip" data-placement="right"></i></span>
|
||||
<span class="ui-lastchangeuser" style="display: none;"> <i class="ui-user-icon small" data-toggle="tooltip" data-placement="right"></i></span>
|
||||
<span class="ui-no-lastchangeuser"> <i class="fa fa-clock-o"></i></span>
|
||||
<span class="text-uppercase">changed</span>
|
||||
<span class="ui-lastchange text-uppercase"></span>
|
||||
|
|
Loading…
Reference in a new issue