PageSourceSearch

https://www.anne-boleyn.com/wp-content/plugins/pierres-wordspew/ajax_shout.js

js anne-boleyn.com collected 2026-10-02 14:17:29 UTC 18,919 bytes, 572 lines download raw bytes

1var myBox = new Object();
2myBox.onInit = function() {}
3//////////////////////////////////
4// Generic onload by Brothercake
5// http://www.brothercake.com/
6////////////////////////////////
7if(typeof window.addEventListener != 'undefined') {
8	//.. gecko, safari, konqueror and standard
9	window.addEventListener('load', initJavaScript, false);
10}
11else if(typeof document.addEventListener != 'undefined') {
12	//.. opera 7
13	document.addEventListener('load', initJavaScript, false);
14}
15else if(typeof window.attachEvent != 'undefined') {
16	//.. win/ie
17	window.attachEvent('onload', initJavaScript);
18}
19function jal_apply_filters(s) {
20	return filter_smilies(make_links((s)));
21}
22function make_links (s) {
23	target="";
24	if(var_XHTML==0) if (s.indexOf(this.location.href)==-1) target=' target="_blank"';
25	var re = /((http|https|ftp):\/\/[^ ]*)/gi;	
26	text = s.replace(re,"<a href=\"$1\""+target+">&laquo;"+Sht_Link+"&raquo;</a>");
27	return text;
28}
29
30function filter_smilies(s) {
31	for (var i = 0; i < smilies.length; i++) {
32		var replace = '<img src="'+PathToSmiley + smilies[i][1] + '" class="wp-smiley" alt="[smiley]" />';
33		var search = smilies[i][0].replace(/(\(|\)|\$|\?|\*|\+|\^|\[|\.|\|)/gi, "\\$1");
34		re = new RegExp(search, 'gi');
35		s = s.replace(re, replace);
36	}
37	var re =/([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+(\.[-a-z0-9]+)*\.[a-z]{2,6})/gi;
38	s = s.replace(re,"<a href=\"mailto:$1\">&laquo;"+Sht_Email+"&raquo;</a>");
39	return s;
40}
41
42// XHTML live Chat
43// author: alexander kohlhofer
44// version: 1.0
45// http://www.plasticshore.com
46// http://www.plasticshore.com/projects/chat/
47// please let the author know if you put any of this to use
48// XHTML live Chat (including this script) is published under a creative commons license
49// license: http://creativecommons.org/licenses/by-nc-sa/2.0/
50
51var dateExp = new Date();
52dateExp.setTime(dateExp.getTime()+2592000000);
53var DateExpires = dateExp.toGMTString();
54
55var oldval, is_new=1;
56var jal_loadtimes, jal_timeout;
57var httpReceiveChat, httpSendChat;
58var jalSound, shoutboxname, shoutboxU, chatbarText, jal_lastID, outputList, shout_theme;
59
60function initJavaScript() {
61shoutboxname=document.getElementById('shoutboxname');
62shoutboxU=document.getElementById('shoutboxU');
63chatbarText=document.getElementById('chatbarText');
64jal_lastID=document.getElementById('jal_lastID');
65outputList=document.getElementById("outputList");
66shout_theme=document.getElementById('shout_theme');
67jal_timeout = jal_org_timeout;
68ChangeBoxSize(2);
69
70	if (!chatbarText) { return; }
71	if(shout_theme) shout_theme.style.display="";
72//this non standard attribute prevents firefox' autofill function to clash with this script
73	document.forms['chatForm'].elements['chatbarText'].setAttribute('autocomplete','off');
74
75	checkStatus('');
76	checkName();
77	checkUrl();
78	jalSound = (jal_getCookie("jalSound")==null || jal_getCookie("jalSound")==1) ? 1 : 0;
79	jal_loadtimes = 1;
80
81// initiates the two objects for sending and receiving data
82	httpReceiveChat = getHTTPObject();
83	httpSendChat = getHTTPObject();
84
85	setTimeout('receiveChatText()', jal_timeout); //initiates the first data query
86
87	shoutboxname.onblur = checkName;
88	shoutboxU.onblur = checkUrl;
89	chatbarText.onfocus = function () { checkStatus('active'); }	
90	chatbarText.onblur = function () { checkStatus(''); }
91	document.getElementById('submitchat').onclick = sendComment;
92	document.getElementById('chatForm').onsubmit = function () { return false; }
93// When user mouses over shoutbox
94	document.getElementById('chatoutput').onmouseover = ResetChrono;
95	
96	var obj = "";
97	if(show_smiley==1) {
98		ActualSmile="", style="", lib="-";
99		if (jal_getCookie("jalSmiley")==1) {
100			style="display:none";
101			lib="+"
102		}
103		obj+="<a href=\"javascript:ShowHide('SmileyParent','SmileyChild')\" id=\"SmileyParent\" ";
104		obj+="title=\""+Sht_Expand+"\">"+lib+"</a> Smileys :";
105		obj+="<div id='SmileyChild' style=\""+style+"\">";
106		for (var i = 0; i < smilies.length; i++) {
107			if(ActualSmile!=smilies[i][1]) {
108				obj+="<a href=\"javascript:appendSmiley('"+smilies[i][0].replace("'","\\'")+"')\">";
109				obj+="<img src=\""+PathToSmiley+smilies[i][1]+"\" alt=\"\" class=\"wp-smiley\"/></a> ";
110			}
111			ActualSmile=smilies[i][1];
112		}
113		obj+="</div>"	
114		if(document.getElementById("SmileyList")) document.getElementById("SmileyList").innerHTML=obj;
115	}
116}
117
118function ResetChrono() {
119	if (jal_loadtimes > 9) {
120		jal_loadtimes = 1;
121		receiveChatText();
122	}
123	jal_timeout = jal_org_timeout;
124}
125
126function appendSmiley(text) {
127	chatbarText.value+=' '+text;
128	chatbarText.focus();
129}
130	
131function ShowHide(parent, enfant) {
132	txtParent=document.getElementById(parent).innerHTML;
133	etatEnfant=document.getElementById(enfant).style.display;
134	document.getElementById(parent).innerHTML=(txtParent=="+") ? "-" : "+";
135	document.getElementById(enfant).style.display=(etatEnfant=="none") ? "" : "none";
136	jalSmiley = (jal_getCookie("jalSmiley")==1) ? 0 : 1;
137	document.cookie = "jalSmiley="+jalSmiley+";expires="+DateExpires+";path=/;";
138}
139
140//initiates the first data query
141function receiveChatText() {
142	lastID = parseInt(jal_lastID.value)-1;
143	MyCat=encodeURIComponent(document.getElementById("shout_cat").value);
144
145	if (httpReceiveChat.readyState == 4 || httpReceiveChat.readyState == 0) {
146		httpReceiveChat.open("GET",GetChaturl+'&jal_lastID='+lastID+'&shout_cat='+MyCat+'&rand='+Math.floor(Math.random() * 1000000), true);
147		httpReceiveChat.onreadystatechange = handlehHttpReceiveChat; 
148		httpReceiveChat.send(null);
149		jal_loadtimes++;
150		if (jal_loadtimes > 9) jal_timeout = jal_timeout * 5 / 4;
151	}
152	setTimeout('receiveChatText()',jal_timeout);
153}
154
155//deals with the servers' reply to requesting new content
156function handlehHttpReceiveChat() {
157	if (httpReceiveChat.readyState == 4) {
158		firstarray = httpReceiveChat.responseText.split('\n');
159		if (firstarray.length == 2) { // if != 2, it failed, we should skip the processing part
160			results = firstarray[0].split('---');
161			replaceUserOnline(results[0],results[1]);
162			results = firstarray[1].split('---'); //the fields are seperated by ---
163			if (results.length > 4) {
164				for(i=0;i < (results.length-1);i=i+8) { //goes through the result one message at a time
165				insertNewContent(results[i+1],results[i+2],results[i+3], results[i], results[i+4], results[i+5], results[i+6]);
166				jal_lastID.value = parseInt(results[i])+1;
167				}
168				jal_timeout = jal_org_timeout;
169				jal_loadtimes = 1;
170			}
171			else if(results.length==3) {
172				insertNewContent(results[1], results[2], "", parseInt(results[0])+1,"","");
173				jal_lastID.value = parseInt(results[0])+1;
174			}
175			//is_new=1;
176		}
177	}
178}
179
180function setSound() {
181jalSound = (jal_getCookie("jalSound")=="" || jal_getCookie("jalSound")==0) ? 1 : 0;
182document.cookie = "jalSound="+jalSound+";expires="+DateExpires+";path=/;";
183document.getElementById('JalSound').src=(jalSound==1) ? pathToImg+"sound_1.gif": pathToImg+"sound_0.gif";
184}
185
186//inserts the new content into the page
187function insertNewContent(liName, liText, liUrl, liId, liUser, liEmail, liTime) {
188var myClass="";
189if(liUser==1) myClass="jal_user ";
190myClass+=liName.replace(" ","");
191verif=true;
192	if (liText.substr(0,2)=="@@") {
193		verif=false;
194		PosSpace=liText.indexOf(" ");
195		To=liText.substr(2,PosSpace-2);
196		Deb=2+(To.length);
197		shout_user=shout_user.toLowerCase();
198		if(shout_user==To.toLowerCase() || isAdmin==true || shout_user==liName.toLowerCase()) {
199			verif=true;
200			liText="<span class='InfoUser'>"+Sht_Chaine+" "+To+":</span>"+liText.substr(Deb); 
201		}
202	}
203if (verif==true) {
204	if(document.getElementById("TheBox") && jalSound==1 && is_new==1) {
205		document.getElementById("TheBox").SetVariable("method:setUrl", pathToMP3);
206		document.getElementById("TheBox").SetVariable("method:play", "");
207	}
208	oLi = document.createElement('li');
209	oLi.setAttribute('id','comment-new'+liId);
210	
211	if (show_avatar==1) {
212		if(liEmail!="") {
213			avatar = 'http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s='+avatar_size;
214			oDiv = document.createElement('div');
215			oDiv.setAttribute('class','ps_'+avatar_position);
216			oDiv.setAttribute('className','ps_'+avatar_position);
217			oImg = document.createElement('img');
218			oImg.setAttribute('src','http://www.gravatar.com/avatar.php?gravatar_id='+liEmail+'&default='+avatar+'&size='+ avatar_size);
219			oDiv.appendChild(oImg);
220			oLi.appendChild(oDiv);
221		}
222	}
223
224	oSpan = document.createElement('span');
225	oSpan.setAttribute('class',myClass);
226	oSpan.setAttribute('title',liTime);
227
228	oName = document.createTextNode(liName);
229
230	if (liUrl != "http://" && liUrl != '') {
231		oURL = document.createElement('a');
232		oURL.href = liUrl;
233		if(var_XHTML==0) if (liUrl.indexOf(this.location.href)==-1) oURL.setAttribute('target','_blank');
234		oURL.appendChild(oName);
235	} else {
236		oURL = oName;
237	}
238
239	oSpan.appendChild(oURL);
240	oSpan.appendChild(document.createTextNode(' : '));
241	oLi.appendChild(oSpan);
242	oLi.innerHTML += jal_apply_filters(liText);
243
244	if(isAdmin==true) {
245		oSpan = document.createElement('span');
246		oSpan.setAttribute('class','delShout');
247		oSpan.setAttribute('className','delShout');
248		oSpan.setAttribute('title',Sht_Delete);
249		oSpan.onclick = function () { deleteComment(liId); }
250		oSpan.appendChild(document.createTextNode('x'));
251		oLi.appendChild(oSpan);
252	}
253
254	outputList.insertBefore(oLi, outputList.firstChild);
255	if(is_new==1) 
256		Fat.fade_element("comment-new"+liId, 30, fade_length, "#"+fade_from, "#"+fade_to);
257	}
258}
259
260function MasqueSelect() {
261	mabox=document.getElementById('shoutboxOp');
262	posEgal=mabox.options[0].text.indexOf("=");
263	if(mabox.options[mabox.selectedIndex].value==eval(mabox.options[0].text.substr(0,posEgal)))
264	document.getElementById('shoutbox_captcha').style.display="none";
265}
266//stores a new comment on the server
267function sendComment() {
268	currentChatText = chatbarText.value;
269	currentUrl = shoutboxU.value;
270	currentName = shoutboxname.value;
271	shoutboxOp = document.getElementById('shoutboxOp').value;
272	shoutboxControl= document.getElementById('shoutboxControl').value;
273	MyCat=document.getElementById('shout_cat').value;
274
275	if (currentChatText == '') return;
276	if(CheckSpam(currentName+' '+currentChatText, currentUrl)) {
277		if (httpSendChat.readyState == 4 || httpSendChat.readyState == 0) {
278			param = 'n='+ encodeURIComponent(currentName)+'&c='+ encodeURIComponent(currentChatText) +'&u='+ encodeURIComponent(currentUrl)+'&shoutboxOp='+encodeURIComponent(shoutboxOp)+'&shoutboxControl='+encodeURIComponent(shoutboxControl)+'&shout_cat='+encodeURIComponent(MyCat);	
279			httpSendChat.open("POST", SendChaturl, true);
280			httpSendChat.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
281			httpSendChat.onreadystatechange = receiveChatText;
282			httpSendChat.send(param);
283			chatbarText.value = '';
284		}
285	}
286}
287
288function deleteComment(id) {
289	theHTML=document.getElementById('comment-new'+id).innerHTML;
290	var HtmlText = theHTML.replace(/<[a-zA-Z\/][^>]*>x?/g, "");
291	AlertMsg=Sht_Alert1+" \n"+ HtmlText+"\n\n";
292	AlertMsg+=Sht_Alert2;
293	if(confirm(AlertMsg)) {
294		if (httpSendChat.readyState == 4 || httpSendChat.readyState == 0) {
295			param = 'mode=del&id='+ encodeURIComponent(id);
296			httpSendChat.open("POST", SendChaturl, true);
297			httpSendChat.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
298			httpSendChat.onreadystatechange = receiveChatText;
299			httpSendChat.send(param);
300			Fat.fade_element('comment-new'+id,30,1000,"#FF0000");
301			setTimeout('delChild('+id+')',1000);
302		}
303	}
304}
305
306function delChild(id) {
307	var enfant = document.getElementById("comment-new"+id); 
308	var anciennoeud = outputList.removeChild(enfant);
309}
310
311// Piece of code from "TinyMCE Advanced" plugin. Thanks to -> Andrew Ozz : http://www.laptoptips.ca/
312function onBlurEditableSelectInput () {
313MyCat=document.getElementById("shout_cat_theme");
314	if (MyCat.previousSibling.value != '') {
315		var o = new Option(MyCat.previousSibling.value, MyCat.previousSibling.value);
316		MyCat.options[MyCat.options.length] = o;
317		optionvalue=MyCat.previousSibling.value
318	}
319	else optionvalue=oldval;
320	
321	for (var i=0; i<MyCat.options.length; i++) {
322		var option = MyCat.options[i];
323		if (option.value ==optionvalue )
324			option.selected = true;
325		else
326			option.selected = false;
327	}
328
329	MyCat.style.display = 'inline';
330	MyCat.parentNode.removeChild(MyCat.previousSibling);
331	chatbarText.focus();
332	CleanBox();
333}
334
335function onKeyDown(e) {
336	e = e || window.event;
337	if (e.keyCode == 13)
338		onBlurEditableSelectInput();
339}
340
341function CleanBox() {
342var new_val;
343
344document.getElementById("shout_cat").value=document.getElementById("shout_cat_theme").value;
345
346MyCat=document.getElementById("shout_cat_theme");
347if (MyCat.options[MyCat.selectedIndex].value == 'add_custom') {
348	new_val = document.createElement("input");
349	new_val.id = MyCat.id + "_custom";
350	new_val.name = MyCat.name + "_custom";
351	new_val.type = "text";
352
353	new_val.style.width = MyCat.offsetWidth + 'px';
354	MyCat.parentNode.insertBefore(new_val, MyCat);
355	MyCat.style.display = 'none';
356	new_val.focus();
357	new_val.onblur = onBlurEditableSelectInput;
358	new_val.onkeydown = onKeyDown;
359}
360else {
361	if(MyCat.value != oldval) {
362		mycook=encodeURIComponent(MyCat.value);
363		document.cookie = "jalCombo="+mycook+";expires="+DateExpires+";path=/;"
364		jal_lastID.value=0;
365		is_new=0;
366		while (outputList.firstChild) {
367			outputList.removeChild(outputList.firstChild);
368		}
369		receiveChatText();
370	}
371}
372}
373
374// http://www.codingforums.com/showthread.php?t=63818
375function pressedEnter(field,event) {
376	var theCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
377	if (theCode == 13) {
378		is_new=1;
379		sendComment();
380		return false;
381	} 
382	else return true;
383}
384
385//does clever things to the input and submit
386function checkStatus(focusState) {
387	oSubmit = document.forms['chatForm'].elements['submit'];
388	if (chatbarText.value != '' || focusState == 'active') {
389		oSubmit.disabled = false;
390	} else {
391		oSubmit.disabled = true;
392	}
393}
394
395function jal_getCookie(name) {
396	var dc = document.cookie;
397	var prefix = name + "=";
398	var begin = dc.indexOf("; " + prefix);
399	if (begin == -1) {
400		begin = dc.indexOf(prefix);
401		if (begin != 0) return null;
402	} else
403		begin += 2;
404	var end = document.cookie.indexOf(";", begin);
405	if (end == -1)
406		end = dc.length;
407	return unescape(decodeURI(dc.substring(begin + prefix.length, end)));
408}
409
410//autoasigns a random name to a new user
411//If the user has chosen a name, use that
412function checkName() {
413	jalCookie = jal_getCookie("jalUserName");
414	shout_user=shoutboxname.value;
415	if (jalCookie && shoutboxname.value == '') {
416		shoutboxname.value = jalCookie.replace("+"," ");
417	}
418	else {
419		if(shout_user=='') shoutboxname.value=Old_Sname; 
420		else Old_Sname=shout_user;
421		}
422}
423
424function checkUrl() {
425	if(shoutboxU.style.display!="none") {
426		document.cookie = "jalUrl="+shoutboxU.value+";expires="+DateExpires+";path=/;"
427		return;
428	}
429}
430
431function ChangeBoxSize(MyInt) {
432	if(document.getElementById('chatoutput')) {
433		var obj=document.getElementById('chatoutput');
434		if(MyInt==1) {
435			obj.style.height=(obj.offsetHeight+20)+'px';
436			document.cookie = "jalHeight="+(obj.offsetHeight-14)+";expires="+DateExpires+";path=/;"
437		}
438		else if(MyInt==0) {
439			hauteur=(obj.offsetHeight-48);
440			if(parseInt(hauteur)>0) obj.style.height=hauteur+'px';
441			document.cookie = "jalHeight="+(obj.offsetHeight-14)+";expires="+DateExpires+";path=/;"
442		}
443		else {
444			if(jal_getCookie("jalHeight")) obj.style.height=jal_getCookie("jalHeight")+'px';
445		}
446	}
447}
448// This script file contains 2 major sections, one for the AJAX chat, and one for the FAT
449// technique. The AJAX chat script part is below the FAT part
450// @name      The Fade Anything Technique
451// @namespace http://www.axentric.com/aside/fat/
452// @version   1.0-RC1
453// @author    Adam Michela
454var Fat = {
455	make_hex : function (r,g,b) 
456	{
457		r = r.toString(16); if (r.length == 1) r = '0' + r;
458		g = g.toString(16); if (g.length == 1) g = '0' + g;
459		b = b.toString(16); if (b.length == 1) b = '0' + b;
460		return "#" + r + g + b;
461	},
462	fade_all : function ()
463	{
464		var a = document.getElementsByTagName("*");
465		for (var i = 0; i < a.length; i++) 
466		{
467			var o = a[i];
468			var r = /fade-?(\w{3,6})?/.exec(o.className);
469			if (r)
470			{
471				if (!r[1]) r[1] = "";
472				if (o.id) Fat.fade_element(o.id,null,null,"#"+r[1]);
473			}
474		}
475	},
476	fade_element : function (id, fps, duration, from, to) 
477	{
478		if (!fps) fps = 30;
479		if (!duration) duration = 3000;
480		if (!from || from=="#") from = "#FFFF33";
481		if (!to) to = this.get_bgcolor(id);
482
483		var frames = Math.round(fps * (duration / 1000));
484		var interval = duration / frames;
485		var delay = interval;
486		var frame = 0;
487
488		if (from.length < 7) from += from.substr(1,3);
489		if (to.length < 7) to += to.substr(1,3);
490
491		var rf = parseInt(from.substr(1,2),16);
492		var gf = parseInt(from.substr(3,2),16);
493		var bf = parseInt(from.substr(5,2),16);
494		var rt = parseInt(to.substr(1,2),16);
495		var gt = parseInt(to.substr(3,2),16);
496		var bt = parseInt(to.substr(5,2),16);
497		var r,g,b,h;
498		while (frame < frames)
499		{
500			r = Math.floor(rf * ((frames-frame)/frames) + rt * (frame/frames));
501			g = Math.floor(gf * ((frames-frame)/frames) + gt * (frame/frames));
502			b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames));
503			h = this.make_hex(r,g,b);
504		
505			setTimeout("Fat.set_bgcolor('"+id+"','"+h+"')", delay);
506
507			frame++;
508			delay = interval * frame; 
509		}
510		setTimeout("Fat.set_bgcolor('"+id+"','"+to+"')", delay);
511	},
512	set_bgcolor : function (id, c)
513	{
514		var o = document.getElementById(id);
515		if(o) o.style.backgroundColor = c;
516	},
517	get_bgcolor : function (id)
518	{
519		var o = document.getElementById(id);
520		while(o)
521		{
522			var c;
523			if (window.getComputedStyle) c = window.getComputedStyle(o,null).getPropertyValue("background-color");
524			if (o.currentStyle) c = o.currentStyle.backgroundColor;
525			if ((c != "" && c != "transparent") || o.tagName == "BODY") { break; }
526			o = o.parentNode;
527		}
528		if (c == undefined || c == "" || c == "transparent") c = "#FFFFFF";
529		var rgb = c.match(/rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/);
530		if (rgb) c = this.make_hex(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3]));
531		return c;
532	}
533}
534function ChangeURL(id,href,param) {
535cat=document.getElementById('shout_cat').value;
536if(cat!='') href+=param
537document.getElementById(id).href=href+encodeURIComponent(cat);
538}
539
540//initiates the XMLHttpRequest object as found here: http://www.webpasties.com/xmlHttpRequest
541function getHTTPObject() {
542  var xmlhttp;
543  /*@cc_on
544  @if (@_jscript_version >= 5)
545    try {
546      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
547    } catch (e) {
548      try {
549        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
550      } catch (E) {
551        xmlhttp = false;
552      }
553    }
554  @else
555  xmlhttp = false;
556  @end @*/
557  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
558    try {
559      xmlhttp = new XMLHttpRequest();
560    } catch (e) {
561      xmlhttp = false;
562    }
563  }
564  return xmlhttp;
565}
566
567function replaceUserOnline(chrono,useronlinetext) {
568if(useronlinetext!="") {
569	document.getElementById("usersOnline").innerHTML=useronlinetext;
570}
571document.getElementById("responseTime").innerHTML=chrono;
572}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.