Skip to content
This repository has been archived by the owner on Oct 29, 2022. It is now read-only.

Commit

Permalink
Mark nicks in the backlog as clickable (#114 #113)
Browse files Browse the repository at this point in the history
* Apply highlighting changes immediately

* Mark nicks in the backlog as clickable

* Fix scoping issues
  • Loading branch information
xDashh authored and sztanpet committed Aug 8, 2016
1 parent f164fcb commit b219c41
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
10 changes: 6 additions & 4 deletions static/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,14 +593,16 @@ chat.prototype.handleCommand = function(str) {
}

nick = parts[1].toLowerCase();
if (command == "unhighlight") {
delete(highlightnicks[nick]);
this.gui.push(new ChatInfoMessage("No longer highlighting: " + nick));
} else {
var dohighlight = command == "highlight";
if (dohighlight) {
highlightnicks[nick] = true;
this.gui.push(new ChatInfoMessage("Now highlighting: " + nick));
} else {
delete(highlightnicks[nick]);
this.gui.push(new ChatInfoMessage("No longer highlighting: " + nick));
}

this.gui.renewHighlight(nick, dohighlight);
this.gui.setPreference('highlightnicks', highlightnicks);
break;

Expand Down
17 changes: 16 additions & 1 deletion static/chat/js/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,13 @@
return;
}

// parse backlog preliminarily to initialize nicks so the formatter will mark them as such (clickable)
for (var i = 0, j = this.backlog.length; i < j; i++){
var obj = JSON.parse(this.backlog[i].substring(this.backlog[i].indexOf(' ')));
if(obj.nick)
this.engine.users[obj.nick] = "";
}

for (var i = 0, j = this.backlog.length; i < j; i++)
this.engine.parseAndDispatch({
data: this.backlog[i]
Expand Down Expand Up @@ -708,6 +715,14 @@
}
},

renewHighlight: function(nick, dohighlight){
if (dohighlight){
this.lines.children('div[data-username="'+nick.toLowerCase()+'"]').addClass("highlight");
} else {
this.lines.children('div[data-username="'+nick.toLowerCase()+'"]').removeClass("highlight");
}
},

handleHighlight: function(message){
if (!message.user || !message.user.username || message.user.username == this.engine.user.username || !this.getPreference('highlight'))
return false;
Expand Down Expand Up @@ -1099,4 +1114,4 @@
};
// END EMOTE COUNT

})(jQuery);
})(jQuery);

0 comments on commit b219c41

Please sign in to comment.