Bug - Not A Bug Relay browser chat reloading

lostcalpolydude

Developer
Staff member
Occasionally, while I'm typing in the chat window in the relay browser, the entire chat pane reloads. This happens infrequently, less than once per session probably, so it's very difficult to narrow down the cause.

I first saw the issue at least two months ago, probably a bit longer than that, but probably not more than 3 months ago.

I'm seeing this in Firefox on Windows. This was finally reported in G-D, and Klimtog and the people they were chatting with all use that setup, so it could be a Firefox bug. If that's the case, any help tracking that down would be appreciated... but now someone using Chrome has also seen it happen.

That post claims it happens when pressing the '1' key. I haven't had a chance to try verifying that.

I initially thought it was due to my chat relay override, but other people seeing it don't use one.

I have no idea where to start looking to figure this one out, so this is just gathering all the details that seem like they might be relevant.
 

xKiv

Active member
That post claims it happens when pressing the '1' key. I haven't had a chance to try verifying that.

Do you/they have *any* greasemonkey script that could react to that?
(for example, I have a script for metroplexity that triggers resting when I press R ... so I can't go to a combobox and press r to select the first item that starts R, because it would make me rest instead)
 

PeKaJe

Member
I've heard a couple people in clan chat complain about that same issue. They were typing and in the middle of doing so, the chat window refreshes. If I see them again, I'll see if they have more details to share.
 

lostcalpolydude

Developer
Staff member
Do you/they have *any* greasemonkey script that could react to that?
(for example, I have a script for metroplexity that triggers resting when I press R ... so I can't go to a combobox and press r to select the first item that starts R, because it would make me rest instead)

None of my greasemonkey scripts accept any keyboard or mouse input. Only one of them runs on KoL at all, and only on the clan activity log page.
 

Veracity

Developer
Staff member
KoLmafia does not accept any keyboard or mouse input from the relay browser except insofar as the browser itself turns it into a request.

I'd be interested in seeing a debug log (including chat requests) of the (small) part of the session in which this happens.
 

Darzil

Developer
I've been playing Chrome the last few months, IE before that (and gone back to IE recently as Chrome kept crashing), never seen this. Playing with non-tabbed chat, no mafia chat open.
 

I ♣ Seals

New member
I'm using Firefox and have experienced this issue. I first noticed the problem when I started using a Logitech wireless keyboard, but I'd imagine that's a coincidence. Only ever happens while I'm typing, but I'm almost positive it's not a result of an accidental key press.
 

Veracity

Developer
Staff member
I ♣ Seals;117093 said:
I first noticed the problem when I started using a Logitech wireless keyboard, but I'd imagine that's a coincidence.
That's what you "imagine", eh?

Things work well.
You change something.
Things don't work well.
And it's a "coincidence"?

"The thing that changed" tends to be my first suspicion.
 

Veracity

Developer
Staff member
I see. So, KoLmafia, which never, ever, sees keystrokes - those are interpreted by the browser, or perhaps Javascript being executed by the browser - which also has not changed in the timeframe lost reported - "two to three months ago" - is a more likely suspect?

Let's see a DEBUG log with "chat events" and "browser interactions" for while this problem is occurring. I predict we'll see the browser making a request which reloads the chat window - a call to lchat.php or mchat.php. And why did it decide to do that? Who knows? Lets see the previous responses KoLmafia sent down to it and see if there is something odd. If there is something odd about the actual key event, we'll not see that, since KoLmafia never sees your key events, but a LOG will be necessary for us to begin to think about understanding what is happening.
 
I don't have a debug log, but I can confirm that this is not due to Greasemonkey. I've seen the same behavior despite having Greasemonkey disabled when I run KoLMafia via the relay browser. I'll try to run with debug logging on to see if something comes up.
 

I ♣ Seals

New member
Firefox v33.0.1 (this will have changed since I started seeing the error a couple of months ago) and Windows 7.

Regarding debug logs, I turned on the requested options in preferences and was able to cause the bug to occur by mashing keys, but no log was generated. However, the session log does now end with the line mchat.php?graf=12.

Edit: A sample of "mashing keys" for the purpose of the above is "hfdgsgfhkjsghfjshgukfhfsukghksfgh" - nothing that should generate an unusual key event.
 
Last edited:

Winterbay

Active member
In order to generate a debug log you click on "start debug log" and when finished on "end debug log". That's the way to do it without having a significant error occur first.
 

Veracity

Developer
Staff member
Well, here's an extract of interesting stuff.

Summary:

GET /newchatmessages.php?j=1&lasttime=1389024176 HTTP/1.1
DNT: 1
Referer: http://127.0.0.1:60080/mchat.php?graf=12

I have no idea what the DNT header is. But, that "referer" is very odd. I've never seen the browser include that in a request to newchatmessages.php.

Retrieved: http://www.kingdomofloathing.com/newchatmessages.php?j=1&pwd
Retrieving server reply
ResponseText has 44 characters.
{"msgs":[],"last":"1389024178","delay":3000}

GET /newchatmessages.php?j=1&lasttime=1389024178 HTTP/1.1
Referer: http://127.0.0.1:60080/mchat.php?graf=12

Another one.

Retrieved: http://www.kingdomofloathing.com/newchatmessages.php?j=1&pwd
ResponseText has 44 characters.
{"msgs":[],"last":"1389024178","delay":3000}

GET /mchat.php?graf=%2Fbuy+1 HTTP/1.1
Referer: http://127.0.0.1:60080/mchat.php?graf=12

Really? it submits mchat.php with graf = "/buy 1"?

Retrieved: http://www.kingdomofloathing.com/mchat.php?graf=%2Fbuy+1
Retrieving server reply
ResponseText has 23131 characters.

And here comes mchat.php

Code:
GET /newchatmessages.php?j=1&lasttime=1389024176 HTTP/1.1
Host: 127.0.0.1:60080
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
X-Requested-With: XMLHttpRequest
Referer: http://127.0.0.1:60080/mchat.php?graf=12
Cookie: charpwd=200; chatpwd=427
Connection: keep-alive
----------
class net.sourceforge.kolmafia.request.ChatRequest
Connecting to newchatmessages.php...

Requesting: http://www.kingdomofloathing.com/newchatmessages.php?j=1&pwd
2 request properties
Field: Cookie = [appserver=www10; PHPSESSID=83v9qpnbji037qoqaglo7o6t83]
Field: User-Agent = [KoLmafia v16.3]

Retrieved: http://www.kingdomofloathing.com/newchatmessages.php?j=1&pwd
10 header fields
Field: null = [HTTP/1.1 200 OK]
Field: Date = [Mon, 27 Oct 2014 20:59:54 GMT]
Field: Content-Length = [44]
Field: Expires = [Thu, 19 Nov 1981 08:52:00 GMT]
Field: Connection = [keep-alive]
Field: Content-Type = [text/html; charset=UTF-8]
Field: X-Powered-By = [PHP/5.3.3]
Field: Server = [nginx/1.0.15]
Field: Pragma = [no-cache]
Field: Cache-Control = [no-store, no-cache, must-revalidate, post-check=0, pre-check=0]

Retrieving server reply
ResponseText has 44 characters.
{"msgs":[],"last":"1389024178","delay":3000}
-----To Browser-----
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Content-Length: 7446
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
----------
-----From Browser-----
GET /newchatmessages.php?j=1&lasttime=1389024178 HTTP/1.1
Host: 127.0.0.1:60080
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
X-Requested-With: XMLHttpRequest
Referer: http://127.0.0.1:60080/mchat.php?graf=12
Cookie: charpwd=200; chatpwd=427
Connection: keep-alive
----------
class net.sourceforge.kolmafia.request.ChatRequest
Connecting to newchatmessages.php...

Requesting: http://www.kingdomofloathing.com/newchatmessages.php?j=1&pwd
2 request properties
Field: Cookie = [appserver=www10; PHPSESSID=83v9qpnbji037qoqaglo7o6t83]
Field: User-Agent = [KoLmafia v16.3]

Retrieving server reply...

Retrieved: http://www.kingdomofloathing.com/newchatmessages.php?j=1&pwd
10 header fields
Field: null = [HTTP/1.1 200 OK]
Field: Date = [Mon, 27 Oct 2014 20:59:57 GMT]
Field: Content-Length = [44]
Field: Expires = [Thu, 19 Nov 1981 08:52:00 GMT]
Field: Connection = [keep-alive]
Field: Content-Type = [text/html; charset=UTF-8]
Field: X-Powered-By = [PHP/5.3.3]
Field: Server = [nginx/1.0.15]
Field: Pragma = [no-cache]
Field: Cache-Control = [no-store, no-cache, must-revalidate, post-check=0, pre-check=0]

Retrieving server reply
ResponseText has 44 characters.
{"msgs":[],"last":"1389024178","delay":3000}
-----To Browser-----
HTTP/1.1 200 OK
Date: Mon Oct 27 20:59:49 GMT 2014
Server: KoLmafia v16.3
Content-Type: text/html; charset=UTF-8
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
Connection: close
-----From Browser-----
GET /newchatmessages.php?j=1&lasttime=1389024178 HTTP/1.1
Host: 127.0.0.1:60080
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
X-Requested-With: XMLHttpRequest
Referer: http://127.0.0.1:60080/mchat.php?graf=12
Cookie: charpwd=200; chatpwd=427
Connection: keep-alive
----------
class net.sourceforge.kolmafia.request.ChatRequest
Connecting to newchatmessages.php...

Requesting: http://www.kingdomofloathing.com/newchatmessages.php?j=1&pwd
2 request properties
Field: Cookie = [appserver=www10; PHPSESSID=83v9qpnbji037qoqaglo7o6t83]
Field: User-Agent = [KoLmafia v16.3]

Retrieving server reply...

Retrieved: http://www.kingdomofloathing.com/newchatmessages.php?j=1&pwd
10 header fields
Field: null = [HTTP/1.1 200 OK]
Field: Date = [Mon, 27 Oct 2014 21:00:00 GMT]
Field: Content-Length = [44]
Field: Expires = [Thu, 19 Nov 1981 08:52:00 GMT]
Field: Connection = [keep-alive]
Field: Content-Type = [text/html; charset=UTF-8]
Field: X-Powered-By = [PHP/5.3.3]
Field: Server = [nginx/1.0.15]
Field: Pragma = [no-cache]
Field: Cache-Control = [no-store, no-cache, must-revalidate, post-check=0, pre-check=0]

Retrieving server reply
ResponseText has 44 characters.
{"msgs":[],"last":"1389024179","delay":3000}
-----To Browser-----
HTTP/1.1 200 OK
Date: Mon Oct 27 20:59:52 GMT 2014
Server: KoLmafia v16.3
Content-Type: text/html; charset=UTF-8
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
Connection: close
----------
-----From Browser-----
GET /mchat.php?graf=%2Fbuy+1 HTTP/1.1
Host: 127.0.0.1:60080
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Referer: http://127.0.0.1:60080/mchat.php?graf=12
Cookie: charpwd=200; chatpwd=427
Connection: keep-alive
----------
class net.sourceforge.kolmafia.request.RelayRequest
Connecting to mchat.php...

Requesting: http://www.kingdomofloathing.com/mchat.php?graf=%2Fbuy+1
2 request properties
Field: Cookie = [appserver=www10; PHPSESSID=83v9qpnbji037qoqaglo7o6t83]
Field: User-Agent = [KoLmafia v16.3]

Retrieving server reply...

Retrieved: http://www.kingdomofloathing.com/mchat.php?graf=%2Fbuy+1
9 header fields
Field: null = [HTTP/1.1 200 OK]
Field: Transfer-Encoding = [chunked]
Field: Date = [Mon, 27 Oct 2014 21:00:02 GMT]
Field: Expires = [Thu, 19 Nov 1981 08:52:00 GMT]
Field: Content-Type = [text/html; charset=UTF-8]
Field: X-Powered-By = [PHP/5.3.3]
Field: Server = [nginx/1.0.15]
Field: Pragma = [no-cache]
Field: Cache-Control = [no-store, no-cache, must-revalidate, post-check=0, pre-check=0]

Retrieving server reply
ResponseText has 23131 characters.
<!doctype html><html><head><title>LoathingChat</title><meta name="viewport" content="width=320, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /><meta http-equiv="X-UA-Compatible" content="IE=9" /><link rel="stylesheet" type="text/css" href="http://images.kingdomofloathing.com/styles.css"><style type=text/css>.stroke { text-stroke: 1px black; -webkit-text-stroke: 1px black;  }input.text, textarea {border: 1px black solid;font-family: Arial, Helvetica,  sans-serif;font-size: 10pt;}#tabs span.label {font-weight: bold;}#tabs .tab {font-size: 12px;display: inline-block;padding: 4px;height: 14px;border: 1px solid black;margin-right: 2px;margin-bottom: 2px;min-width: 30px;text-align: center;background-color: #eee;cursor: pointer;position: relative;}.tab .count {display: none;}#tabs .unread .count {display: block;background-color: #c00;color: #fff;border: 1px solid #600;position: absolute;right: -5px;top: -7px;padding: 2px;font-size: 9px;-moz-border-radius: 4px;-webkey-border-radius: 4px;-o-border-radius: 4px;border-radius: 4px;-webkit-box-shadow: 1px 1px 1px 1px rgba(100, 100, 100, .5);-moz-box-shadow: 1px 1px 1px 1px rgba(100, 100, 100, .5);box-shadow: 1px 1px 1px 1px rgba(100, 100, 100, .5);}#tabs.nounread .tab span.count { display: none; }#tabs.colortabs .unread {background-color: #fcc;}#tabs .active {/* font-weight: bold; */outline: 1px solid black;outline-width-bottom: 0px;background-color: #fff;}.event {color : green; }a.event, a.event:visited, a.event:active {color : green; }.pm {color : blue; }.sys, .sys .player { color: red; }.warn, .warn .player { color: red; }.annc, .annc .player { color: green; }.welcome { color: green; font-style: italic; padding-bottom: 1em }.lastmark { width: 80%; }input.button {border: 1px black solid;font-family: Arial, Helvetica, sans-serif;font-size: 9pt;font-weight: bold;background-color: #FFFFFF;}body {padding: 0px;spacing: 0px;}a, a:active, a:visited { text-decoration: none; color: black; }a.itemlink {color: blue !important;text-decoration: underline !important;}.chatdisplay {position: absolute;padding: 4px;spacing: 0px;top: 2px;left: 2px;font-family: arial;width: 100%;font-size: 12px;height: 300;border: 1px solid black;overflow-y: scroll;overflow-x: hidden;overflow: auto;z-index: 1;padding-top: 18px;}.chatdisplay .header {position: fixed;top: 0px;left: 3px;width: 100%;height: 16px;background-color: #00f;color: #fff;text-align: left;font-weight: bold;font-size: 12px;z-index: 2;}.inputform {position: absolute;border: 1px solid black;bottom: 2px;left: 2px;padding: 2px;spacing: 0px;}.tiny { font-size: 8pt; }.small { font-size: 10pt; }.nounder { text-decoration: none; }div.rcm {position: absolute;font-family: Arial;font-size: 10pt;border: 1px solid black;background-color: #fff;display: none;z-index: 99;}p.rcm {cursor: pointer;background-color: white;margin: 0px;padding: 0px 2px;}p.rcm:hover {background-color: #ccccff;}.afk { font-style: italic; 	filter: alpha(opacity=50); -khtml-opacity: 0.5; -moz-opacity: 0.5; opacity: 0.5; background-color: #ddd; }.player {font-weight: bold; }</style><script type="text/javascript" src="http://images.kingdomofloathing.com/scripts/jquery-1.5.1.js"></script><script type="text/javascript" src="http://images.kingdomofloathing.com/scripts/jquery-ui-1.8.18.custom.min.js"></script><script type="text/javascript">var $$ = jQuery.noConflict(true);</script><script type="text/javascript" src="http://images.kingdomofloathing.com/scripts/window.js"></script><script type="text/javascript" src="http://images.kingdomofloathing.com/scripts/cookie.20100120.js"></script><script type="text/javascript">// ====================================================================//       URLEncode and URLDecode functions//// Copyright Albion Research Ltd. 2002// http://www.albionresearch.com///// You may copy these functions providing that// (a) you leave this copyright notice intact, and// (b) if you use these functions on a publicly accessible//     web site you include a credit somewhere on the web site//     with a link back to http://www.albionresarch.com///// If you find or fix any bugs, please let us know at albionresearch.com//// SpecialThanks to Neelesh Thakur for being the first to// report a bug in URLDecode() - now fixed 2003-02-19.// ====================================================================function URLEncode(x){// The Javascript escape and unescape functions do not correspond// with what browsers actually do...var SAFECHARS = "0123456789" +					// Numeric"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic"abcdefghijklmnopqrstuvwxyz" +"-_.!~*'()";					// RFC2396 Mark charactersvar HEX = "0123456789ABCDEF";var plaintext = x;var encoded = "";for (var i = 0; i < plaintext.length; i++ ) {var ch = plaintext.charAt(i);if (ch=="+") {encoded+="%2B";} else if (ch == " ") {encoded += "+";				// x-www-urlencoded, rather than %20} else if (SAFECHARS.indexOf(ch) != -1) {encoded += ch;} else {var charCode = ch.charCodeAt(0);if (charCode > 255) {alert( "Unicode Character '" + ch + "' cannot be encoded using standard URL encoding.\n" +"(URL encoding only supports 8-bit characters.)\n" +"A space will be substituted." );encoded += "+";} else {encoded += "%";encoded += HEX.charAt((charCode >> 4) & 0xF);encoded += HEX.charAt(charCode & 0xF);}}} // forreturn encoded;};var $cw,$inp,$tabs,CHMAX = 20,chpointer = -1,chcurrent = null,delay = 5000,lastdelay = 5000,chistory = [],payingattention = true,timer,lastrequest,KEYS = {0: 'shiftKey',1: 'ctrlKey',2: 'altKey',3: 'notAKey'},opts = {event: 'active',public: 'own',private: 'own',updatetitle: 0,showtimes: 0,marklast: true,active: "clan",modifier: 0,unreadbadges: 1,colortabs: 0,channeltag: 0,alwayswho: 0,tabsonbottom: 0,buffer: 500,foo: 1},todo = [],playerid = 2400625,pwdhash = "d938b0ee40a3218cec5c3d20ce7f4d60";var log = function (str) {if (typeof console != 'undefined' && console.log) console.log(str);};var msgTemplates = {public99: $$('<div class="msg welcome"><span class="guts"></span></div>'),public98: $$('<div class="msg event"><span class="guts"></span></div>'),public0: $$('<div class="msg"><a class="player" target="mainpane"></a>: <span class="guts"></span></div>'),public1: $$('<div class="msg emote"><span class="guts"></span></div>'),public2: $$('<div class="msg sys"><a class="player" target="mainpane">System Message</a>: <span class="guts"></span></div>'),public3: $$('<div class="msg warn"><a class="player" target="mainpane"></a>: <span class="guts"></span></div>'),public4: $$('<div class="msg annc"><a class="player" target="mainpane">Mod Announcement</a>: <span class="guts"></span></div>'),private: $$('<div class="msg pm"><a class="player" target="mainpane"></a>: <span class="guts"></span></div>'),event: $$('<div class="msg event"><span class="guts"></span></div>'),system: $$('<div class="msg sys"><a class="player" target="mainpane">System Message</a>: <span class="guts"></span></div>')};var formatMessage = function (msg) {var key = msg.type;if (key == 'public') key += msg.format;var out = msgTemplates[key].clone();if (msg.who) {out.find('.player').html(msg.who.name).attr('href', 'showplayer.php?who='+msg.who.id).css('color', msg.who.color || '');}if ((opts.channeltag || msg.ctag) && msg.channel) {var ctag = $$('<span class="ctag"></span>').text('['+msg.channel+'] ');if (msg.channelcolor) ctag.css('color', msg.channelcolor);out.prepend(ctag);}if (msg.mid) {out.attr('id', msg.mid);}if (opts.showtimes && msg.time) {var d = new Date(msg.time*1000);var h = d.getHours();var m = d.getMinutes();var s = d.getSeconds();if (m < 10) m = '' + 0 + m;if (s < 10) s = '' + 0 + s;var ttag = $$('<span class="time"></span>').text('[' + h+ ':' + m + '] ');out.prepend(ttag);}if (msg.type =='event' && msg.link) {out.find('.guts').wrap('<a href="'+msg.link+'" target="mainpane" class="event" />');}out.find('.guts').html(msg.msg);return out;};var tabs = {};var addTab = function (tab) {var link = $$('<a><span class="label"></span><span class="count">0</span></a>').addClass('tab').data('tab', tab).find('span.label').text(tab.data('label')).end();tab.data('handle', link);if ($$('.tab', $tabs).length == 0) link.addClass('active')$tabs.append(link);sizing();return tab;};var getTab = function(msg) {var tkey = msg.type;if (msg.type == 'public') tkey += '-' + msg.channel;else if (msg.type == 'private' && msg['for']) tkey += '-' + msg['for'].id;else tkey += '-' + msg.who.id;if (tabs[tkey]) return tabs[tkey];var div = $$('<div />').addClass('chatdisplay').attr('id', tkey).data('label', msg.type=='public'? msg.channel : (msg['for'] ? msg['for'].name : msg.who.name)).data('tkey', tkey).data('type', msg.type);div.append($$('<div class="header"></div>').html(' ' + div.data('label')));tabs[tkey] = div;$$('body').append(tabs[tkey]);for (var i in tabs) {if (tabs.hasOwnProperty(i)) {tabs[tkey].hide();break;}}var showmain = false;for (i in opts) {if (opts[i] == 'main') {showmain = true;break;}}if (showmain && !tabs['main']) {$cw.data('label', 'events').data('tkey', 'main').data('type', 'main');tabs['main'] = $cw;$cw.append($$('<div class="header"></div>').html(' events'));sizing();addTab($cw);}if (opts.alwayswho && msg.type == 'public') {submitchat('/who ' + msg.channel);}return addTab(tabs[tkey]);};var whereIGo = function (msg) {var where = opts[msg.type == 'system' ? 'event' : msg.type];switch (where) {case 'main':if (msg.type == 'public') { msg.ctag = true};return $cw;case 'own': return getTab(msg);case 'active': return $$('.chatdisplay:visible');//default: console.log('missing! ' + where); return $cw;}};var handleMessage = function (msg, nocount) {var where = whereIGo(msg);var toscroll = (where[0].scrollHeight - (where[0].scrollTop + where[0].offsetHeight) < 4);if (msg.mid && $$('#'+msg.mid).size() > 0) return;where.eq(0).append(formatMessage(msg))var h = where.data('handle');if (h && !nocount && (!msg.who || (msg.who.id != playerid)) && !msg.notnew) {if (!h.hasClass('active')) { h.addClass('unread'); }if (!h.hasClass('active') || !payingattention) {var n = 1 + parseInt(h.find('.count').text());h.find('.count').text(n);}}if (where.css('display') != 'none' && toscroll) {where[0].scrollTop = where[0].scrollHeight;}};var updateUnread = function () {if (opts.updatetitle) {var total = 0;$$('#tabs .count').each(function () {total += parseInt($$(this).text());});window.top.document.title = '(' + total + ') ' + opts.titlecache;if (window.top.newchat && total > 0) window.top.newchat();}};var lastlast = 0;var gotChat = function (res) {if (!res || res == null) return;delay = parseInt(res.delay);if (delay < 1 ||delay > (60*1000)) delay = 5000;for (var i=0; i<res.msgs.length; i++) {handleMessage(res.msgs[i]);}lastlast = res.last;updateUnread();$$('.chatdisplay').each(function () {var $c = $$(this);var cnt = $c.find('div.msg').size();if (cnt > opts.buffer) {$c.find('div.msg:lt('+(cnt - opts.buffer)+')').remove();}});};var cycle = function () {//if (lastrequest && !lastrequest.status) return;if (lastdelay != delay) {clearInterval(timer);timer = setInterval(cycle, delay);}lastrequest = $$.ajax({url: '/newchatmessages.php?j=1&lasttime='+lastlast,dataType: 'json',success: gotChat,timeout: 5000});lastdelay = delay;};var sizing = function () {var	th = $$('#tabs').height(),h = ($$(document).height() - $tabs.height() - (th ? 26 : 18) - $$('#InputForm').height() - 16),w = Math.max(150, $$('body').width() + 2),t = (th +8),b = 0;if (opts.tabsonbottom) {t = 0;b = th + 8;$$('#tabs').css({'bottom': 4, 'position':'absolute'});}else {$$('#tabs').css({'bottom': '', 'position':''});}$$('#InputForm').css({ width: w + 4, bottom: b });$$('.chatdisplay').css({ width: w, height: h, top: t });$$('.chatdisplay .header').css({ top: t +1, width: w + 8});};var nextAction = function () {var next_todo = todo.shift();if (next_todo) {try { eval(next_todo); } catch (e) { }}}var handleClientSide = function (msg) {if (msg.match(/^\/exit/)) {document.location = 'chatlaunch.php';return true;}else if (msg.match(/^\/(clearall|clsa)/)) {$$('.chatdisplay > :not(.header)').remove();return true;}else if (msg.match(/^\/(cls|clear)/)) {$$('.chatdisplay:visible > :not(.header)').empty();return true;}else if (msg.match(/^\/(\?|help)/)) {window.open("doc.php?topic=modern_chat","","height=400,width=550,scrollbars=yes,resizable=yes");return true;}else if (msg.match(/^\/close$/) || msg.match(/^\/close /)) {$$('.chatdisplay:visible').data('handle').dblclick();return true;}else if (msg.match(/^\/mark/)) {var d = new Date();$$('.chatdisplay:visible').append("<center class=tiny>——— " + d.getHours() + ":" + (d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes()) + ":" + (d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds()) + " ———</center>");return true;}return false;};var channelize = function (msg) {if (handleClientSide(msg)) {return false;}var mparts = msg.split(' ');var aid = $$('.chatdisplay:visible').attr('id');var parts = aid.split('-');if (mparts.length == 1 && mparts[0] == '/who') return '/who ' + parts[1];else if (mparts.length == 1 && mparts[0] == '/w') return '/who ' + parts[1];else if (mparts.length == 1 && mparts[0] == '/whois' && parts[0] == 'private') return '/whois ' + parts[1];else if (parts.length < 2) return msg;else if (mparts.length >= 2 && mparts[0] == '/whois') return msg;else if (mparts.length == 2 && mparts[0] == '/who') return msg;/*if (mparts[0].match(/^\//) && !mparts[0].match(/^\/(me|em|who|ann|announce|warn)/)) {return msg;}*/if (parts[0] == 'public') return '/' + parts[1] + ' ' + msg;else if (parts[0] == 'private' && mparts[0].match(/^\/(me|em)/)) return '/msg ' + parts[1] + ' ' + msg;else if (parts[0] == 'private' && !mparts[0].match(/^\//)) return '/msg ' + parts[1] + ' ' + msg;else return msg;}var jstest = /<!--js\((.+?)\)-->/g;var submitchat = function (over, cb) {var txt = $inp.val();if (over && typeof over != 'object') txt = over;else {$inp.val('');over.preventDefault();}if (txt == '') return;if (txt && txt != '' && txt != chistory[0]) {chistory.unshift(txt);}txt = channelize(txt);if (txt === false) return;if (chistory.length > CHMAX) { chistory.pop(); }chpointer = -1;chcurrent = null;var url = '/submitnewchat.php?playerid='+playerid+'&pwd='+pwdhash+'&graf='+URLEncode(txt)+'&j=1';$$.get(url, function (resp) {if (resp && resp.output) {var d = $$('.chatdisplay:visible');if (resp.channel && tabs['public-'+resp.channel]) {d = tabs['public-'+resp.channel];}d.append('<div class="msg">'+resp.output+'</div>');d[0].scrollTop = d[0].scrollHeight;}if (resp && resp.msgs) {for (var i=0; i<resp.msgs.length; i++) handleMessage(resp.msgs[i]);}var ev;while (ev = jstest.exec(resp.output)) {var cmd = ev[1];if (cmd.indexOf('dojax') == -1) cmd += ';setTimeout(nextAction,3000)';todo.push(cmd);}if (cb) cb();nextAction();if (!mobile) $inp[0].focus();cycle();},'json');};var handleKeys = function (e) {if (e[KEYS[opts.modifier]]) {if (e.which == 37 || e.which == 39) {var c;if (e.which == 37) {e.preventDefault();c = $$('#tabs .active').prev();if (!c.length) c = $$('#tabs .tab:last');}else if (e.which == 39) {e.preventDefault();c = $$('#tabs .active').next();if (!c.length) c = $$('#tabs .tab:first');}if (c) c.click();}if (e.which == 38 || e.which == 40) {e.preventDefault();if (chpointer == -1) {chcurrent = $inp.val();}if (e.which == 38) {chpointer++;if (chpointer >= CHMAX || !chistory[chpointer]) {chpointer = -1;tosee = chcurrent;}else { tosee = chistory[chpointer]; }}else if (e.which == 40) {chpointer--;if (chpointer == -1) {tosee = chcurrent;}else if (chpointer < 0) {chpointer = chistory.length - 1;tosee = chistory[chpointer];}else {tosee = chistory[chpointer];}}$inp.val(tosee);}}};var todo = [];function nextAction() {var next_todo = todo.shift();if (next_todo) {eval(next_todo);}}function dojax(dourl, afterFunc, hoverCaller, failureFunc, method, params) {$$.ajax({type: method || 'GET', url: dourl, cache: false,data: params || null,global: false,success: function (out) {nextAction();if (out.match(/no\|/)) {var parts = out.split(/\|/);if (failureFunc) failureFunc(parts[1]);else $$('#ChatWindow').append('<font color="green">Oops!  Sorry, Dave, you appear to be ' + parts[1] + '.</font><br />' + "\n");return;}if (hoverCaller)  {float_results(hoverCaller, out);if (afterFunc) { afterFunc(out); }return;}			var $eff = $$(top.mainpane.document).find('#effdiv');if ($eff.length == 0) {var d = top.mainpane.document.createElement('DIV');d.id = 'effdiv';var b = top.mainpane.document.body;if ($$('#content_').length > 0) {b = $$('#content_ div:first')[0];}b.insertBefore(d, b.firstChild);$eff = $$(d);}$eff.find('a[name="effdivtop"]').remove().end().prepend('<a name="effdivtop"></a><center>' + out + '</center>').css('display','block');if (!window.dontscroll || (window.dontscroll && dontscroll==0)) {top.mainpane.document.location = top.mainpane.document.location + "#effdivtop";}if (afterFunc) { afterFunc(out); }}});}var mobile = 0;var actions = { };var notchat = false;$$(function ($) {$cw = $('#ChatWindow');$inp = $('#graf');$tabs = $('#tabs');$(window).resize(sizing);$('#tabs .tab').live('click', function (e) {e.preventDefault();if (opts.marklast) {$('.chatdisplay:visible').find('hr.lastmark').remove().end().append('<hr class="lastmark" />');}$('.chatdisplay').hide();$('#tabs .tab').removeClass('active');var w = $(this).data('tab');w.show();w[0].scrollTop = w[0].scrollHeight;$(this).removeClass('unread').addClass('active').find('.count').text(0);updateUnread();if (!mobile) $inp[0].focus();}).live('dblclick', function (e) {e.preventDefault();if (confirm('Click OK to close this tab.')) {var k = $(this).data('tab').attr('id');var parts = k.split('-');var tb = this;var endtab = function () {delete tabs[k];$(tb).data('tab').remove();$(tb).remove();sizing();if ($('.chatdisplay:visible').length) return;$('#tabs .tab:first').click();};if (parts[0] == 'public') {submitchat('/listenoff ' + parts[1], endtab);} else endtab();}});$('#InputForm').parent().submit(submitchat);sizing();handleMessage({type:'event',msg:'<span class="welcome">Welcome to <B>LoathingChat</b> version 0.9302<br />' +'Click a tab to switch, double-click to close (and unlisten to) a channel.<br />' +'Ctrl-left and right to change tabs, shift-up and down for chat history.<br />' +'Click and drag to rearrange tabs.<br />' +'Type /? or /help for more information.<br />' +'There are some <a style="font-weight: bold; text-decoration: underline" href="/account.php?tab=chat" target="mainpane" style="font-weight: bold">Configuration options</a>.<br />' +'<br />' +'</span>' +''});if (opts.updatetitle) {if (!window.top || !window.top.document || !window.top.document.title) {opts.updatetitle = false;}}opts.titlecache = window.top.document.title.replace(/^.*The/,'The');if (!opts.unreadbadges) {$('#tabs').addClass('nounread');}if (opts.colortabs) {$('#tabs').addClass('colortabs');}$(document).keyup( handleKeys );$(window.top || window).focus(function () {payingattention = true;$('#tabs .active .count').text(0);}) .blur(function () { payingattention = false; });handleMessage({type:'public', format: '99', channel: 'clan', msg: "This is a chat channel that only members of your clan can use."}, true);handleMessage({type:'public', format: '99', channel: 'dread', msg: "A channel for Dreadsylvanian explorers."}, true);handleMessage({type:'public', format: '99', channel: 'hobopolis', msg: "Hobopolis clan dungeon channel"}, true);handleMessage({type:'public', format: '99', channel: 'newbie', msg: "This channel is a place for new players to ask questions, and for other players to answer them."}, true);if (opts.event == 'active') {$('#tabs .tab:first').click();var m = $('#ChatWindow .welcome');$('.chatdisplay:visible').prepend(m.clone());m.remove();}$('#tabs').sortable({appendTo: 'body',stop: function (e, ui) {var diff = Math.abs(ui.position.left - ui.originalPosition.left);if (diff < 10) ui.item.click();}});cycle();timer = setInterval(cycle, delay);if (!mobile) $inp[0].focus();});</script><script type="text/javascript" src="http://images.kingdomofloathing.com/scripts/rcm.20101215.js"></script><script type="text/javascript">$$(function ($) {$(window).resize(function () {var winW = 300;if (document.body && document.body.offsetWidth) { winW = document.body.offsetWidth; }if (document.compatMode=='CSS1Compat' && document.documentElement && document.documentElement.offsetWidth ) { winW = document.documentElement.offsetWidth; }if (window.innerWidth && window.innerHeight) { winW = window.innerWidth; }setCookie('chatpwd', winW, 365, true);});})</script></head><body><div id="tabs"></div><div id="ChatWindow" class="chatdisplay"></div><form name="chatform"><div id="InputForm" class="inputform"><center><input style="width: 70%;" maxlength="200" class="text" type="text" size="12" name="graf" id="graf" autocomplete="off"><input class="button" type="submit" value="Chat"></center></div></form><div id='menu' class='rcm'></div></body></body></html>
Processing results...
-----To Browser-----
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Content-Length: 23102
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
 
Top