1 function require_script_version(v)
3 if(v!="3.a") alert("The board has been upgraded. You need to force a reload in your browser to complete the update.\nThis is usually done by holding down Shift and pressing the reload button.");
10 var style=document.getElementById(id).style;
11 if(style.display) style.display="";
12 else style.display="none";
15 function insert(text,thread)
17 var textarea=document.getElementById("postform"+thread).comment;
20 if(textarea.createTextRange && textarea.caretPos) // IE
22 var caretPos=textarea.caretPos;
23 caretPos.text=caretPos.text.charAt(caretPos.text.length-1)==" "?text+" ":text;
25 else if(textarea.setSelectionRange) // Firefox
27 var start=textarea.selectionStart;
28 var end=textarea.selectionEnd;
29 textarea.value=textarea.value.substr(0,start)+text+textarea.value.substr(end);
30 textarea.setSelectionRange(start+text.length,start+text.length);
34 textarea.value+=text+" ";
40 function w_insert(text,link)
42 if(document.body.className=="mainpage") document.location=link+"#i"+text;
46 function size_field(id,rows) { document.getElementById(id).comment.setAttribute("rows",rows); }
50 function delete_post(thread,post,file)
52 if(confirm("Are you sure you want to delete reply "+post+"?"))
55 var script=document.forms[0].action;
56 var password=document.forms[0].password.value;
58 if(file) fileonly=confirm("Leave the reply text and delete the only file?");
60 document.location=script
62 +"&delete="+thread+","+post
63 +"&password="+password
64 +"&fileonly="+(fileonly?"1":"0");
68 function preview_post(formid,thread)
70 var form=document.getElementById(formid);
71 var preview=document.getElementById("preview"+thread);
73 if(!form||!preview) return;
75 preview.style.display="";
76 preview.innerHTML="<em>Loading...</em>";
80 text+="&comment="+encodeURIComponent(form.comment.value);
81 text+="&markup="+encodeURIComponent(form.markup.value);
82 if(thread) text+="&thread="+thread;
84 var xmlhttp=get_xmlhttp();
85 xmlhttp.open("POST",self);
86 xmlhttp.onreadystatechange=function() {
87 if(xmlhttp.readyState==4) preview.innerHTML=xmlhttp.responseText;
89 if(is_ie()||xmlhttp.setRequestHeader) xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
93 function get_xmlhttp()
96 try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }
99 try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
100 catch(e1) { xmlhttp=null; }
103 if(!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp=new XMLHttpRequest();
110 return(document.all&&!document.opera);
115 function set_new_inputs(id)
117 var el=document.getElementById(id);
119 if(!el||!el.link) return;
121 if(!el.field_a.value) el.field_a.value=get_cookie("name");
122 if(!el.field_b.value) el.field_b.value=get_cookie("link");
123 if(!el.password.value) el.password.value=get_password("password");
124 if(el.markup&&!el.comment.value) el.markup.value=get_cookie("markup");
125 select_markup(el.markup);
128 function set_delpass(id)
130 with(document.getElementById(id)) password.value=get_cookie("password");
133 function make_password()
135 var chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
140 var rnd=Math.floor(Math.random()*chars.length);
141 pass+=chars.substring(rnd,rnd+1);
147 function get_password(name)
149 var pass=get_cookie(name);
150 if(pass) return pass;
151 return make_password();
154 function select_markup(sel)
156 if(!window.markup_descriptions) return;
159 while(el=el.nextSibling) if(el.nodeName.toLowerCase()=="small") break;
161 if(el) el.innerHTML=markup_descriptions[sel.value];
166 function get_cookie(name)
168 with(document.cookie)
170 var regexp=new RegExp("(^|;\\s+)"+name+"=(.*?)(;|$)");
171 var hit=regexp.exec(document.cookie);
172 if(hit&&hit.length>2) return unescape(hit[2]);
177 function set_cookie(name,value,days)
182 date.setTime(date.getTime()+(days*24*60*60*1000));
183 var expires="; expires="+date.toGMTString();
186 document.cookie=name+"="+value+expires+"; path=/";
189 function set_stylesheet(styletitle)
191 var links=document.getElementsByTagName("link");
193 for(var i=0;i<links.length;i++)
195 var rel=links[i].getAttribute("rel");
196 var title=links[i].getAttribute("title");
197 if(rel.indexOf("style")!=-1&&title)
199 links[i].disabled=true; // IE needs this to work. IE needs to die.
200 if(styletitle==title) { links[i].disabled=false; found=true; }
203 if(!found) set_preferred_stylesheet();
206 function set_preferred_stylesheet()
208 var links=document.getElementsByTagName("link");
209 for(var i=0;i<links.length;i++)
211 var rel=links[i].getAttribute("rel");
212 var title=links[i].getAttribute("title");
213 if(rel.indexOf("style")!=-1&&title) links[i].disabled=(rel.indexOf("alt")!=-1);
217 function get_active_stylesheet()
219 var links=document.getElementsByTagName("link");
220 for(var i=0;i<links.length;i++)
222 var rel=links[i].getAttribute("rel");
223 var title=links[i].getAttribute("title");
224 if(rel.indexOf("style")!=-1&&title&&!links[i].disabled) return title;
228 function get_preferred_stylesheet()
230 var links=document.getElementsByTagName("link");
231 for(var i=0;i<links.length;i++)
233 var rel=links[i].getAttribute("rel");
234 var title=links[i].getAttribute("title");
235 if(rel.indexOf("style")!=-1&&rel.indexOf("alt")==-1&&title) return title;
242 window.onunload=function(e)
246 var title=get_active_stylesheet();
247 set_cookie(style_cookie,title,365);
251 window.onload=function(e)
253 if(match=/#i(.+)/.exec(document.location.toString()))
254 if(!document.getElementById("postform").comment.value)
255 insert(unescape(match[1]),"");
260 var cookie=get_cookie(style_cookie);
261 var title=cookie?cookie:get_preferred_stylesheet();
262 set_stylesheet(title);
265 var captcha_key=make_password();