summaryrefslogtreecommitdiff
path: root/static/js/pichat.js
diff options
context:
space:
mode:
authorScott Ostler <sostler@deathmachine.local>2010-02-27 18:28:06 -0500
committerScott Ostler <sostler@deathmachine.local>2010-02-27 18:28:06 -0500
commitfa8c89b543bb6e23cc7cac5983cb61818a4e3139 (patch)
tree506827edbf7270715333e2ea34e3ea793a24a989 /static/js/pichat.js
parent4bb4fbe6f3abc01edcd402edd1f2c86bd690c062 (diff)
in-progress topics
Diffstat (limited to 'static/js/pichat.js')
-rwxr-xr-xstatic/js/pichat.js40
1 files changed, 36 insertions, 4 deletions
diff --git a/static/js/pichat.js b/static/js/pichat.js
index b847f58..8917e7c 100755
--- a/static/js/pichat.js
+++ b/static/js/pichat.js
@@ -1,8 +1,11 @@
var cache = {}
-var pendingMessages = {}
+var PendingMessages = {}
var MaxImagePosts = 40
+// Utils
+
+
function escapeHtml(txt) {
if (!txt) { return ""; }
else { return $("<span>").text(txt).html(); }
@@ -30,6 +33,8 @@ function linkReplace(url){
}
}
+// Message Handling
+
var ImageMsgCount = 0
function removeOldMessages(){
// don't count posts that are all text
@@ -73,6 +78,8 @@ function buildUserDiv(user) {
}
}
+// Growl
+
function buildGrowlDataAndPopDatShit(msg) {
var nick = escapeHtml(msg.nick);
nick = '<a href="/u/' + nick + ' " style="color:pink">' + nick + '</a>:'
@@ -95,11 +102,13 @@ function handleMsgError(resp) {
}
}
+// Messages
+
function submitMessage() {
var content = $.trim($('#msgInput').val());
$('#msgInput').val('');
if (content == '') { return; }
- pendingMessages[content] = true;
+ PendingMessages[content] = true;
var msg = { 'nick': Nick, 'content': content };
var div = addNewMessage(msg, true);
@@ -173,14 +182,34 @@ function updateUI(msgs, users) {
}
function isDuplicateMessage(m) {
- if (m.nick == Nick && m.content in pendingMessages) {
- delete pendingMessages[m.content];
+ if (m.nick == Nick && m.content in PendingMessages) {
+ delete PendingMessages[m.content];
return true;
} else {
return false;
}
}
+var CurrentTopic = null;
+
+function isSameTopic(curTopic, newTopic) {
+ if (!!curTopic != !!newTopic) { return false; }
+ else if (!curTopic) { return false; } // => !newTopic also
+ else {
+ return curTopic.topic == newTopic.topic &&
+ curTopic.deadline == newTopic.deadline &&
+ curTopic.maker == newTopic.maker;
+ }
+}
+
+function updateTopic(newTopic) {
+ if (isSameTopic(CurrentTopic, newTopic)) { return; }
+ alert('new topic');
+ CurrentTopic = newTopic;
+ $('#topic').text(topic.topic);
+
+}
+
function refresh() {
var onSuccess = function(json) {
try {
@@ -192,6 +221,9 @@ function refresh() {
if (typeof UnseenMsgCounter !== 'undefined' && !HasFocus) {
UnseenMsgCounter += messages.length;
}
+ if (json.topic) {
+ updateTopic(json.topic);
+ }
} catch(e) {
if (IsAdmin && window.console) {
console.error(e);