summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xstatic/pichat.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/static/pichat.js b/static/pichat.js
index d51d18d..559e775 100755
--- a/static/pichat.js
+++ b/static/pichat.js
@@ -34,6 +34,13 @@ function buildMessageDiv(msg) {
+ buildMsgContent(msg.content) + '</div>';
}
+function buildGrowlDataAndPopDatShit(msg) {
+ var nick = escapeHtml(msg.nick);
+ nick = '<a href="/u/' + nick + ' " style="color:pink">' + nick + '</a>:'
+ var msg = buildMsgContent(msg.content)
+ growl(nick, msg)
+}
+
function buildUserDiv(user) {
if (user.avatar) {
return '<div class="username"><a href="/u/' + escapeHtml(user.nick) + '">' +
@@ -103,7 +110,10 @@ function delayedScrollToBottom(delay) {
}
function updateUI(msgs, users) {
- if (msgs !== null) {
+ if (window['growlize'] && msgs !== null) {
+ $.map(msgs, buildGrowlDataAndPopDatShit)
+ }
+ else if (msgs !== null) {
var msgStr = $.map(msgs, buildMessageDiv).join('');
var wasScrolledToBottom = isScrolledToBottom($('#messageList')[0]);
$('#messageList').append(msgStr);
@@ -223,3 +233,12 @@ function initLog() {
});
}
+
+function growl(user, msg) {
+ $.gritter.add({
+ // (string | mandatory) the heading of the notification
+ title: user,
+ // (string | mandatory) the text inside the notification
+ text: msg
+ });
+}