summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authortim b <timb@camcompu.home>2010-05-25 01:01:42 -0700
committertim b <timb@camcompu.home>2010-05-25 01:01:42 -0700
commit41025f011fe761b9c5d4e580bf5d7288b05b7e0f (patch)
tree4f9f8bba42e33e79e878eabfcba78c556db72bc8 /static
parentd479c54031401f8e7388c423a33c6d007e1ead1f (diff)
parent0ac15a39f48ee8b0b7453e1dc5aed382f8e518f2 (diff)
Merge branch 'master' of ssh://dump.fm/pichat/repo
Diffstat (limited to 'static')
-rwxr-xr-xstatic/css/dump.css4
-rw-r--r--static/js/pichat.js29
-rw-r--r--static/test/bugchat.html14
-rw-r--r--static/test/bugchat.js138
4 files changed, 159 insertions, 26 deletions
diff --git a/static/css/dump.css b/static/css/dump.css
index 1aa7668..7097a55 100755
--- a/static/css/dump.css
+++ b/static/css/dump.css
@@ -417,7 +417,7 @@ opacity:0.87;
z-index:18;
text-align: left;
}
-#userList a:hover{color:#000;}
+#userList a:hover{color:#ffffff;}
.username{height:30px;
margin-top:6px;
line-height:20px;
@@ -439,7 +439,7 @@ width:100%;
height:100%;
background-image:url(/static/img/moverc.png);
background-repeat:repeat-x;
-color:#000;
+color:#fff;
text-decoration:none;
background-color:#f3f3f3;
border-top-right-radius:5px;
diff --git a/static/js/pichat.js b/static/js/pichat.js
index 84a9b79..e2ab061 100644
--- a/static/js/pichat.js
+++ b/static/js/pichat.js
@@ -352,26 +352,6 @@ function isDuplicateMessage(m) {
}
}
-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 {
@@ -390,9 +370,6 @@ 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);
@@ -976,7 +953,7 @@ function parseDomain(host){
// Away notification
var UnseenMsgCounter = 0;
-var OrigTitle = $('title').text();
+var OrigTitle = "";
var HasFocus = true;
function onFocus() {
@@ -1004,3 +981,7 @@ function startTitleUpdater() {
$(window).focus(onFocus);
setTimeout(titleUpdater, 2000);
}
+
+$(function() {
+ OrigTitle = $('title').text();
+}); \ No newline at end of file
diff --git a/static/test/bugchat.html b/static/test/bugchat.html
new file mode 100644
index 0000000..548eb6d
--- /dev/null
+++ b/static/test/bugchat.html
@@ -0,0 +1,14 @@
+<html>
+ <head>
+ <title>BUG CHAT</title>
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+ <script type="text/javascript" src="/static/test/bugchat.js"></script>
+ <script>
+ $(initClient);
+ </script>
+ </head>
+ <body>
+ <div id="msgs">
+ </div>
+ </body>
+</html>
diff --git a/static/test/bugchat.js b/static/test/bugchat.js
new file mode 100644
index 0000000..5d9a7b5
--- /dev/null
+++ b/static/test/bugchat.js
@@ -0,0 +1,138 @@
+var alphaChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+function generateRandomKey(length) {
+ s = "";
+ for (var i = 0; i < length; i++) {
+ var r = Math.floor(Math.random() * 26);
+ s += alphaChars[r];
+ }
+ return s;
+}
+
+function formatTime() {
+ var a_p = "";
+ var d = new Date();
+ var curr_hour = d.getHours();
+ if (curr_hour < 12)
+ {
+ a_p = "AM";
+ }
+ else
+ {
+ a_p = "PM";
+ }
+ if (curr_hour == 0)
+ {
+ curr_hour = 12;
+ }
+ if (curr_hour > 12)
+ {
+ curr_hour = curr_hour - 12;
+ }
+
+ if (curr_hour.length == 1)
+ curr_hour = "0" + curr_hour;
+
+ var curr_min = d.getMinutes();
+
+ curr_min = curr_min + "";
+
+ if (curr_min.length == 1)
+ {
+ curr_min = "0" + curr_min;
+ }
+ return curr_hour + ":" + curr_min + " " + a_p;
+}
+
+Key = generateRandomKey(10);
+Timestamp = 0;
+Counter = 0;
+ClientMap = {};
+
+function showError(err) {
+ var msg = formatTime() + " " + err;
+ console.error(msg);
+ $('#msgs').append($('<div>').css('color', 'red').text(msg));
+};
+
+
+function handleMessages(msgs) {
+ $.map(msgs, function(m) {
+ var split = m.content.split("-");
+ if (split.length != 2) {
+ showError("Bad message " + m.content);
+ return;
+ }
+ var client = split[0];
+ var i = parseInt(split[1]);
+ console.warn(client + " " + i);
+
+ if (client in ClientMap) {
+ var p = ClientMap[client];
+ if (i - p != 1) {
+ showError("[" + Key + "] Error for client " + client
+ + "! Expected " + (p+1) + ", got " + i);
+ }
+ }
+ ClientMap[client] = i;
+ });
+}
+
+function refresh() {
+ var onSuccess = function(json) {
+ try {
+ Timestamp = json.timestamp;
+ handleMessages(json.messages);
+ } catch(e) {
+ console.error(e);
+ $('#msgs').append($('<div>').css('color', 'red').text(e));
+ }
+ setTimeout(refresh, 1000);
+ };
+ var onError = function(resp, textStatus, errorThrown) {
+ console.error($.trim(resp.responseText));
+ setTimeout(refresh, 1000);
+ };
+
+ $.ajax({
+ type: 'GET',
+ timeout: 5000,
+ url: '/refresh',
+ data: { 'room': 'test', 'since': Timestamp },
+ cache: false,
+ dataType: 'json',
+ success: onSuccess,
+ error: onError
+ });
+}
+
+function postMessageWrapper() {
+ var delay = Math.ceil(1000 + Math.random() * 3000);
+ setTimeout(postMessage, delay);
+}
+
+function postMessage() {
+ var content = Key + "-" + Counter;
+ Counter++;
+ var onError = function(resp, textStatus, errorThrown) {
+ showError("Error posting " + content + ": " + resp.responseText);
+ postMessageWrapper();
+ };
+
+ $.ajax({
+ type: 'POST',
+ timeout: 5000,
+ url: '/msg',
+ data: { 'room': 'test', 'content': content },
+ cache: false,
+ dataType: 'json',
+ success: postMessageWrapper,
+ error: onError
+ });
+}
+
+function initClient() {
+ showError("Initializing client " + Key);
+ refresh();
+ postMessageWrapper();
+}; \ No newline at end of file