From 526f5c7e2eeee21ef9d87bda8668903844e95f53 Mon Sep 17 00:00:00 2001 From: Cheng-Han, Wu Date: Tue, 15 Mar 2016 10:45:02 +0800 Subject: Improved update last info methods, only change DOM when necessary --- public/js/extra.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'public/js/extra.js') diff --git a/public/js/extra.js b/public/js/extra.js index dc3eac3e..a72ca5e1 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -14,16 +14,20 @@ function updateLastChange() { } setInterval(updateLastChange, 60000); -function updateLastChangeUser(data) { - if (data.lastchangeuserprofile) { - var icon = lastchangeui.user.children('i'); - icon.attr('title', data.lastchangeuserprofile.name).tooltip('fixTitle'); - icon.attr('style', 'background-image:url(' + data.lastchangeuserprofile.photo + ')'); - lastchangeui.user.show(); - lastchangeui.nouser.hide(); - } else { - lastchangeui.user.hide(); - lastchangeui.nouser.show(); +var lastchangeuser = null; +var lastchangeuserprofile = null; +function updateLastChangeUser() { + if (lastchangeui) { + if (lastchangeuser && lastchangeuserprofile) { + var icon = lastchangeui.user.children('i'); + icon.attr('title', lastchangeuserprofile.name).tooltip('fixTitle'); + icon.attr('style', 'background-image:url(' + lastchangeuserprofile.photo + ')'); + lastchangeui.user.show(); + lastchangeui.nouser.hide(); + } else { + lastchangeui.user.hide(); + lastchangeui.nouser.show(); + } } } -- cgit v1.2.3