Team:Warsaw/JSTest



/* <![CDATA[ */

/* Client-side access to querystring name=value pairs Version 1.3 28 May 2008 License (Simplified BSD): http://adamv.com/dev/javascript/qslicense.txt function Querystring(qs) { // optionally pass a querystring to parse this.params = {}; if (qs == null) qs = location.search.substring(1, location.search.length); if (qs.length == 0) return;

// Turn back to // See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1 qs = qs.replace(/\+/g, ' '); var args = qs.split(String.fromCharCode(38)); // parse out name/value pairs separated via & // split out each name=value pair for (var i = 0; i < args.length; i++) { var pair = args[i].split('='); var name = decodeURIComponent(pair[0]); var value = (pair.length==2) ? decodeURIComponent(pair[1]) : name; this.params[name] = value; } }

Querystring.prototype.get = function(key, default_) { var value = this.params[key]; return (value != null) ? value : default_; }

Querystring.prototype.contains = function(key) { var value = this.params[key]; return (value != null); }

Array.prototype.indexOf = function( v, b, s ) { for( var i = +b || 0, l = this.length; i < l; i++ ) { if( this[i]===v || s ) if ( this[i]==v ) { return i; } } return -1; };

function and(cond1,cond2) { if (cond1==true) if (cond2==true) return true; return false; }

function removeHTMLTags(strInputCode2 ){ var strInputCode=new String; strInputCode=strInputCode2; //if (strInputCode==undefined) return; /*               strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){			return (p1 == "lt")? "<" : ">";		}); */               strInputCode = strInputCode.replace(/&(lt);/g,"<"); strInputCode = strInputCode.replace(/&(gt);/g,">"); var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, ""); return strTagStrippedText; }

var months=['January','February','March','April','May','June','July','August','September','October','November','December'];

var adresbase='http://2008.igem.org/Team:Warsaw/Calendar-Main/';

function merge(days) { document.getElementById("title").innerHTML=removeHTMLTags(title);

for (var i=0;i'+days[i]+' '+"[Edit]"+' '; div.setAttribute("id",days[i]); document.getElementById("merg").appendChild(h); document.getElementById("merg").appendChild(div); fill(days[i]);

} }

function fill(day) { if (window.XMLHttpRequest) { // Mozilla, Safari, Opera ... var req = new XMLHttpRequest; } else if (window.ActiveXObject) { // IE  var req = new ActiveXObject("Microsoft.XMLHTTP"); } var ans; if (window.overrideMimeType) req.overrideMimeType('text/xml'); req.onreadystatechange = function { //początek wewnętrznej funkcji if (req.readyState == 4) { if (req.status == 200) { ans=req.responseText; ans=ans.substr(ans.search(" "),ans.search(" ")-ans.search(" ")); document.getElementById(day).innerHTML=trimStr(trimContents(ans,title)); } }

}; //koniec wewnętrznej funkcji

req.open('GET', adresbase+day, true); req.send(null); }

function trimStr(str) { return str.replace(/^\s+|\s+$/g, ''); }

function trimContents(ans, title) { ans=ans.replace(/ <\/h3>/ig,""); h3=new RegExp(/(.*)<\/h3>/ig); title=removeHTMLTags(trimStr(title));

var titles=ans.match(h3); for (var i=0;i0) { //alert(titles[i].split(/|(<\/h3>)/i)); var notags=titles[i].split(/|(<\/h3>)/i); if (notags[3]==undefined) var currtitle=removeHTMLTags(notags[0]); //dirty IE hack else var currtitle=removeHTMLTags(notags[3]); currtitle=trimStr(currtitle.replace(/\+/g,' ')); //alert ("C: "+currtitle+"\nT: "+title); if (currtitle==title) { if (i+10) merge(tgt);

/* ]]> */