var WMP = 0; var QT = 0; var lineHeight; var checksum=-1; var expanded_names = new Array(); var time_offset = 0; var pending_comments = new Array(); var last_update = 0; var interval=5000; var dt = new Date(); var lastspoke = dt.getTime(); var req = new Array(); function getFolder() { return "http://www.nshsa.org.uk/public"; } function decrypt(comment) { return comment; var decrypted = ""; for(i=0; i=65&&o<=90) { o--; if(o<65) o+=26; } if(o>=97&&o<=122) { o--; if(o<97) o+=26; }*/ decrypted += String.fromCharCode(o); } return decrypted; // return comment; } function encrypt(comment) { return comment; var encrypted = ""; for(i=0; i=65&&o<=90) { o++; if(o<65) o+=26; } if(o>=ord('a')&&o<=ord('z')) { o++; if(o<97) o+=26; }*/ encrypted += String.fromCharCode(o); } return encrypted; // return comment; } function trim(str) { return str.replace(/^\s*|\s*$/g,""); } function enter() { var dt = new Date(); lastspoke = dt.getTime(); var c=document.enter_form.a.value; var comment_id=document.enter_form.comment_id.value; document.enter_form.comment_id.value=parseInt(comment_id)+1; c = trim(c); if(c!="") { c = replaceAll(c,"\r",""); c = replaceAll(c,"\n",""); // swearing and mortification here c = deswear(c); c = mortify(c); var offset = get_cookie("time_offset");///60; var today = new Date(); var unixtime = today.getTime(); var h = today.getHours(); var m = today.getMinutes(); var s = today.getSeconds(); var secs = ((h*3600)+(m*60)+s-offset); while(secs<0) secs += (24*60*60); time = Math.floor(secs/60); h = Math.floor(time/60); m = Math.floor(time%60); h = h%24; m = m%60; if(h<10) h = "0"+h; if(m<10) m = "0"+m; var user = get_cookie("username"); pending_comments[pending_comments.length] = comment_id+":"+unixtime+";"+comment_id+";"+c; writeline(h+":"+m,user,c,comment_id); if(get_cookie("online")=="on") document.forms['quicksettings_form'].elements['dozing_ctl'].checked = 0; // c = encrypt(c); // c = replaceAll(c,"#","!£hash!£"); c = escape(c); //alert("http://www.nshsa.org.uk/public/enterhandler.php?cid="+comment_id+"&"+c); loadXMLDoc("http://www.nshsa.org.uk/public/enterhandler.php?cid="+comment_id+"&time="+unixtime+"&"+c,8); } document.getElementById('enter_text').style.visibility = 'visible'; document.getElementById('enter_area').style.visibility = 'hidden'; document.forms['enter_form'].elements['enter_text'].value = ""; document.forms['enter_form'].elements['enter_area'].value = ""; document.getElementById('enter_size_ref').style.width = document.getElementById('enter_area').offsetWidth; document.getElementById('enter_size_ref').innerHTML = ""; document.forms['enter_form'].elements['enter_text'].focus(); document.getElementById('chat').style.borderBottomWidth = 25; scroll(); interval-=1500; if(interval<1000) interval=1000; if(interval>3000) interval=3000; } function replaceAll( str, from, to ) { var s = ""; while(s!=str) { s = str; str = str.replace( RegExp(from), to ); } return str; } function replace(comment,start,length,word) { if(comment.charAt(start+2)<'a') word = word.toUpperCase(); else if(comment.charAt(start)<'a') word = word.charAt(0).toUpperCase()+word.substring(1); comment = comment.substring(0,start)+word+comment.substring(start+length); return comment; } function deswear(comment) { var comment_nourls = comment; var at=0; var start, rep, n; while(1) { start = comment_nourls.toLowerCase().indexOf("http://",at); if( start != -1 ) { end = comment_nourls.indexOf(" ",start); if(end==-1) end = comment_nourls.length; rep = ""; for(n=0; n<(end-start); n++) rep += "-"; comment_nourls = comment_nourls.substring(0,start)+rep+comment_nourls.substring(end); } else break; } for(n=0; nnow-get_cookie("time_offset"))&&(get_cookie('shocked')0) { r = Math.random()*(comment.length); newcomment += comment.substr(r,1); comment = comment.substr(0,r)+comment.substr(r+1); } comment = newcomment; } else delete_cookie('shocked'); return comment; } function setfocus() { if(document.getElementById('enter_area').style.visibility == 'visible') document.forms['enter_form'].elements['enter_area'].focus(); else document.forms['enter_form'].elements['enter_text'].focus(); } function scroll() { if(get_cookie("autoscroll")!=="off") { // scrollTop doesn't always work first time in IE or Opera so we do it a few times for(var n=0; n<10; n++){ var then,now; then=new Date().getTime(); now=then; while((now-then)<20) {now=new Date().getTime();} document.getElementById('chat').scrollTop = 999999; } } } function set_cookie(name, value) { delete_cookie(name); document.cookie= name + "=" + escape(value); } function get_cookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else { begin += 2; } var end = document.cookie.indexOf(";", begin); if (end == -1) { end = dc.length; } dc = dc.replace(/\+/g," "); dc = unescape(dc.substring(begin + prefix.length, end)); if(dc=="-deleted-") dc=""; return dc; } function delete_cookie(name) { if (get_cookie(name)) { document.cookie= name + "=-deleted-"; document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } var _xmlHttp=null; function getXMLHTTP(){ var A=null; try{ A=new ActiveXObject("Msxml2.XMLHTTP") }catch(e){ try{ A=new ActiveXObject("Microsoft.XMLHTTP") } catch(oc){ A=null } } if(!A && typeof XMLHttpRequest != "undefined") { A=new XMLHttpRequest() } return A } function loadXMLDoc(url,type) { var h = 0; if(type==1) h = processXMLReqChange; else if(type==2) h = loadOptions; else if(type==3) h = loadHistory; else if(type==4) h = loadHistoryAdv; else if(type==5) h = loadHistoryMonth; else if(type==6) h = doUpdate; else if(type==7) h = displayHistory; else if(type==8) h = entryHandled; else type = 0; // branch for native XMLHttpRequest object if (window.XMLHttpRequest) { req[type] = new XMLHttpRequest(); if(h!=0) req[type].onreadystatechange = h; req[type].open("GET", url, true); req[type].send(null); // branch for IE/Windows ActiveX version } else if (window.ActiveXObject) { req[type] = new ActiveXObject("Microsoft.XMLHTTP"); if (req[type]) { if(h!=0) req[type].onreadystatechange = h; req[type].open("GET", url, true); req[type].send(); } } } function findURL(comment,domain,at) { var n, domain_at, s; for(n=0; n<20; n++) // should loop until it returns but limit it to be safe { domain_at = comment.toLowerCase().indexOf(domain,at); s=domain_at; if(s==-1) return -1; if(comment.length==s+domain.length || comment.charAt(s+domain.length)==' ' || comment.charAt(s+domain.length)=='/' || comment.charAt(s+domain.length)=='.' || comment.charAt(s+domain.length)==',' || comment.charAt(s+domain.length)=='?' || comment.charAt(s+domain.length)==')') { while(s-1>-1 && comment.charAt(s-1)!=' ') s--; if(s>=at) return s; } at = domain_at+1; } return -1; } var domains = new Array(".com",".org",".net",".co",".me",".biz",".info",".tv"); function writeline(time,user,comment,cid) { d=document; var message = false; var server_message = false; if(time=="" && user=="") message=true; if(!message) comment = time+" "+user+": "+comment; if(message && comment=="Trouble connecting to server. Messages may not be sent or received.") server_message = true; if(server_message && document.getElementById("server_message")!=null) return; comment = trim(comment); comment = unescape(comment); at=0; p=d.createElement('P'); if(message) { if(server_message) { p.setAttribute("id","server_message"); } i=d.createElement("i"); x=d.createTextNode(comment); i.appendChild(x); p.appendChild(i); } else { p.setAttribute("id","comment"+cid); while(1) { prefix = ""; start = comment.toLowerCase().indexOf("http://",at); start2 = comment.toLowerCase().indexOf("www.",at); for(j=0; j0 && (url.indexOf("/")==-1 || url.indexOf("/") > url.indexOf("@")) && prefix == "http://") { // it's an email address prefix = "mailto:"; } if(url.length>50) urlshort = url.substring(0,47)+"..."; else urlshort = url; x=d.createTextNode(comment.substring(0,start)); p.appendChild(x); a=d.createElement("a"); ax=d.createTextNode(urlshort); a.appendChild(ax); a.setAttribute("href", prefix+url); a.setAttribute("title", prefix+url); a.setAttribute("target", "new"); a.setAttribute("onclick", "javascript:setfocus();"); p.appendChild(a); comment = comment.substring(end); } else break; } x=d.createTextNode(comment); p.appendChild(x); } d.getElementById('chat').appendChild(p); } function writehistoryline(time,day,month,year,disptime,user,comment) { d=document; comment = disptime+" "+user+": "+comment; comment = trim(comment); //comment = replaceUnicode(comment); comment = unescape(comment); at=0; p=d.createElement('P'); while(1) { start = comment.toLowerCase().indexOf("http://",at); if( start != -1 ) { end = comment.indexOf(" ",start); if(end==-1) end = comment.length; url = comment.substring(start,end); if(url.length>50) urlshort = url.substring(0,47)+"..."; else urlshort = url; a=d.createElement("a"); a.setAttribute('name',time); ax=d.createTextNode(comment.substring(0,start)); a.appendChild(ax); a.setAttribute("href", "showhistory.php?day="+day+"&month="+month+"&year="+year+"#"+time); a.setAttribute("target", "new"); p.appendChild(a); a=d.createElement("a"); ax=d.createTextNode(urlshort); a.appendChild(ax); a.setAttribute("href", url); a.setAttribute("title", url); a.setAttribute("target", "new"); p.appendChild(a); comment = comment.substring(end); } else break; } a=d.createElement("a"); ax=d.createTextNode(comment); a.appendChild(ax); a.setAttribute("name",time); a.setAttribute("href", "showhistory.php?day="+day+"&month="+month+"&year="+year+"#"+time); a.setAttribute("target", "new"); p.appendChild(a); d.getElementById('search').appendChild(p); } function entryHandled() { if (req[8].readyState == 4) { if (req[8].status == 200) { cid = req[8].responseText; for(j=0; j2) { var s = ""; for(var n=2; n"+response[n]+""; } s += "
"; if(n%4==1) s+= "
"; document.getElementById('history'+response[0]+'_'+response[1]).innerHTML = s; } } } } function processXMLReqChange() { // only if req shows "complete" if (req[1].readyState == 4) { // only if "OK" if (req[1].status == 200) { if(document.getElementById("server_message")!=null) d.getElementById('chat').removeChild(document.getElementById("server_message")); var j, today, z, cid; today = new Date(); var now = today.getTime(); last_update = now; response = req[1].responseText.split("\r\n"); var op = output; var server_h = -1; var server_m, server_s; outputted = false; i=0 line = ""; if(ioutput) { time = response[i]; name = response[i+1]; comment = response[i+2]; writeline(time,name,comment,0); outputted = true; output = response[i+3]; } i+=4; } else { cid = response[i].substring(1); output = response[i+1]; for(j=0; j"; else below_txt+=response[i]+"
"; if(response[i]=="Ignored:") ignored=true; } else { name = unescape(response[i].substring(1)); i++; title = unescape(response[i].substring(1)); i++; allow_nudges = unescape(response[i].substring(1)); i++; regular = unescape(response[i].substring(1)); text = ""+name+""; text += "
"; text += "
"; text += ""; if(title) text += ""+title+"
"; if(allow_nudges==1) text += "Nudge "+name+"
"; text += "Unignore "+name+"
"; else text += "ignore="+name+"',6); setfocus();\">Ignore "+name+"
"; text += "
"; text += "
"; if(!below) above_txt+=text; else below_txt+=text; } } document.getElementById('onlineabove').innerHTML = above_txt; document.getElementById('onlinebelow').innerHTML = below_txt; if(i3000) interval=3000; } else if(outputted==false) { interval+=250; if(interval>15000) interval=15000; } //alert(pending_comments.length); for(j=0; jserver_time-3600000) // if it's over an hour old, forget it. Mainly to avoid having to address midnight issues { z = pending_comments[j].substring(pending_comments[j].indexOf(';')+1); z = z.substring(z.indexOf(';')+1); writeline("","","The following comment could not be sent: "+z); scroll(); pending_comments[j]=pending_comments[pending_comments.length-1]; pending_comments.length--; j--; } else if(time