All pastes #17500 Raw Edit

Mine

public javascript v1 · immutable
#17500 ·published 2005-07-12 00:00 UTC
rendered paste body
<?php 	header("Cache-Control: must-revalidate");	$offset = 60*60*24*80;	$ExpStr = "Expires: ".gmdate("D, d M Y H:i:s",time() + $offset)." GMT";	header($ExpStr);	header('Content-Type: application/x-javascript');	// The length of time, in seconds, that cookies should remain. Default: 3 months	$cookietime = 60*60*24*30*3;?>var SendDemocracy = "<?php echo dirname($_SERVER['PHP_SELF']); ?>/democracy.php?demSend=true";var GetDemocracy = "<?php echo dirname($_SERVER['PHP_SELF']); ?>/democracy.php?demGet=true";function initDemocracy() {	// initiates the two objects for sending and receiving data	httpReceiveVotes = dem_getHTTPObject();	httpSendVotes = dem_getHTTPObject();		        view_results = document.getElementById('view_results');        if (view_results) {      view_results.href = "javascript: SeeResults();";    }        addAnswer = document.getElementById('jalAddAnswer');        if (addAnswer) {    	addAnswer.onclick = function () {    	this.style.display = "none";		document.getElementById('jalAddAnswerRadio').style.display = "inline";		document.getElementById('jalAddAnswerRadio').setAttribute('checked','checked');		document.getElementById('jalAddAnswerInput').style.display = "inline";        	all_inputs = document.getElementsByTagName('input');        	for (var i = 0; i < all_inputs.length; i++) {    		if (all_inputs[i].getAttribute('name') == "poll_aid" && all_inputs[i].value != "newAnswer") {    			all_inputs[i].onclick = function () {    								document.getElementById('jalAddAnswerRadio').style.display = "none";					document.getElementById('jalAddAnswerInput').style.display = "none";					document.getElementById('jalAddAnswerInput').value = "";					document.getElementById('jalAddAnswer').style.display = "inline";						    		    			}    		}    	}        return false;    		}    }    }function ReadVote () {  var the_vote;  the_poll = document.getElementById("democracyForm");  for (x = 0; x < the_poll.poll_aid.length; x++) {	 if (the_poll.poll_aid[x].checked) {	   the_vote = the_poll.poll_aid[x].value;	 }   }  if (!the_vote) {    alert ("You must vote first!");  } else {    SendVote(the_vote);  }  return false;}function SeeResults() {    poll_id = document.getElementById("poll_id").value;	if (httpReceiveVotes.readyState == 4 || httpReceiveVotes.readyState == 0) {  		httpReceiveVotes.open("GET",GetDemocracy + '&poll_id='+poll_id+'&rand='+Math.floor(Math.random() * 1000000), true);		httpReceiveVotes.onreadystatechange = function () {			if (httpReceiveVotes.readyState == 4) {				results = httpReceiveVotes.responseText;		    	the_poll = document.getElementById("democracy");    			the_poll.innerHTML = results;		     }		}  		httpReceiveVotes.send(null);  	} else {  	setTimeout('SeeResults()', 500);  	}}function jal_getCookie(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;  return unescape(dc.substring(begin + prefix.length, end));}function SendVote (the_vote) {    poll_id = document.getElementById("poll_id").value;    cookie = jal_getCookie('demVoted_'+poll_id);    if (cookie) {        alert("Go stuff the ballot box elsewhere!");        return;    } else {    	    	new_vote = document.getElementById('jalAddAnswerInput');				if (new_vote && new_vote.value != "") {			param = 'vote='+new_vote.value+'&new_vote=true&poll_id='+poll_id;		} else {			param = 'vote='+the_vote+'&poll_id='+poll_id;		}				document.cookie = "demVoted_"+poll_id+"="+the_vote+";expires=<?php echo gmdate("D, d M Y H:i:s",time() + $cookietime)." UTC"; ?>;path=/;";				if (httpSendVotes.readyState == 4 || httpSendVotes.readyState == 0) {			httpSendVotes.open("POST", SendDemocracy, true);			httpSendVotes.setRequestHeader('Content-Type','application/x-www-form-urlencoded');  			httpSendVotes.send(param);  		} else {  		 setTimeout('SendVote('+the_vote+')', 400)  		}  	}   	   	// Let the query take some time to run..  	setTimeout('SeeResults()', 400);  	}// brothercake's generic onload// http://www.brothercake.com/site/resources/scripts/onload/if(typeof window.addEventListener != 'undefined'){	//.. gecko, safari, konqueror and standard	window.addEventListener('load', initDemocracy, false);}else if(typeof document.addEventListener != 'undefined'){	//.. opera 7	document.addEventListener('load', initDemocracy, false);}else if(typeof window.attachEvent != 'undefined'){	//.. win/ie	window.attachEvent('onload', initDemocracy);}	//initiates the XMLHttpRequest object//as found here: http://www.webpasties.com/xmlHttpRequestfunction dem_getHTTPObject() {  var xmlhttp;  /*@cc_on  @if (@_jscript_version >= 5)    try {      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");    } catch (e) {      try {        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");      } catch (E) {        xmlhttp = false;      }    }  @else  xmlhttp = false;  @end @*/  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {    try {      xmlhttp = new XMLHttpRequest();    } catch (e) {      xmlhttp = false;    }  }  return xmlhttp;}