Team:Warsaw/Calendar-Main/NoAtribution

.wide { position: fixed; left: 10px; right: 10px; top: 1px; bottom: 10px; width: 99%; overflow: auto; background-color:white; }

.float { position:fixed; right:10px; top:2px; }

.narrow { position: relative; left: 5px; background-color: transparent; width: 99%; }

.stretched { position: relative; left: 5px; right: 5px; background-color: transparent; width: 300%; }

Attribution analyzer   Toggle source core dump



/* <![CDATA[ */

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; }; var months=['January','February','March','April','May','June','July','August','September','October','November','December'];

var authors=['Michał K.','Piotr','Antoni','Michał L.','Paweł', 'Emilia', 'Weronika'];

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

function longmonth(mon) { var long=['May','July','August','October']; if (long.indexOf(mon,0,false)>=0) return true; return false; }

function nextday(date) { date=date.replace(' ','_'); date=date.replace(' ','_'); var date_array=date.split('_'); var d=parseInt(date_array[0]); var m=date_array[1]; //var y="2008"; var y=parseInt(date_array[2]); var next_day;

if (d+1<31) { next_day=(d+1)+'_'+m+'_'+y; } else { var next_month=months[(parseInt(months.indexOf(m,0,false))+1)]; next_day='1'+'_'+next_month+'_'+y; } if (longmonth(m)) if((d+1)==31) { next_day=(d+1)+'_'+m+'_'+y; }

return next_day; }

function prevday(date) { date=date.replace(' ','_'); date=date.replace(' ','_'); var date_array=date.split('_'); var d=parseInt(date_array[0]); var m=date_array[1]; var y="2008"; var prev_day="";

if (d-1>0) { prev_day=(d-1)+'_'+m+'_'+y; } else { var prev_month=months[(parseInt(months.indexOf(m,0,false))-1)]; if (longmonth(prev_month)) { prev_day='31'+'_'+prev_month+'_'+y; } else { prev_day='30'+'_'+prev_month+'_'+y; } }

return prev_day; }

var eday="empty"; eday=eday.replace("y","yday");

function find_authors(day,end_day) {

var nday=nextday(day);

document.getElementById("progress").innerHTML="Processing: "+day;

if (window.XMLHttpRequest) { // Mozilla, Safari, Opera ... var req = new XMLHttpRequest; } else if (window.ActiveXObject) { // IE  var req = new ActiveXObject("Microsoft.XMLHTTP"); } var ans; var has_author=false; has_author=false; 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; if(ans.search(eday)<0) {               //No proper author or title specified if(and(ans.search(" ")<0,ans.search(" ")<0)) document.getElementById("no_author").innerHTML=document.getElementById("no_author").innerHTML+" "+nday+": no authors, no titles";

//No proper titles else if(ans.search(" ")<0) document.getElementById("no_author").innerHTML=document.getElementById("no_author").innerHTML+" "+nday+" No titles: "+removeHTMLTags(get_author(ans))+""; //no proper authors else if(ans.search(" ")<0) document.getElementById("no_author").innerHTML=document.getElementById("no_author").innerHTML+" "+nday+" No authors:"+removeHTMLTags(get_title(ans))+"";

else if (and(count_authors(ans)==count_titles(ans),count_authors(ans)>0)) {                 for (var i=0;i0) { document.getElementById(authors[i]).innerHTML=document.getElementById(authors[i]).innerHTML+" "+nday+": "+removeHTMLTags(get_title_by_author(ans,authors[i]))+""; }                 }}                  else document.getElementById("no_author").innerHTML=document.getElementById("no_author").innerHTML+" "+nday+": Author-Title mismatch</a>"; }               if (day==end_day) { document.getElementById("progress").innerHTML="Done"; document.getElementById("dump").value=document.getElementById("result").innerHTML; return true; }               else { find_authors(nday,end_day); } } }

}; //koniec wewnętrznej funkcji

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

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

function analyze { var start_day=parseInt(document.params.start_day.value); var start_month=document.params.start_month.value; var start_year=parseInt(document.params.start_year.value); var end_day=parseInt(document.params.end_day.value); var end_month=document.params.end_month.value; var end_year=parseInt(document.params.end_year.value);

if (start_day>0) if (start_day<32) var start_date=start_day+'_'+start_month+'_'+start_year; else { document.getElementById("progress").innerHTML="Start day error" return; } if (end_day>0) if (end_day<32) var end_date=end_day+'_'+end_month+'_'+end_year; else { document.getElementById("progress").innerHTML="End day error" return; }

if (start_month==end_month) if(end_day<start_day) { document.getElementById("progress").innerHTML="Wrong date range" return; }

//document.getElementById("progress").innerHTML="Start: "+start_date+" End: "+end_date; find_authors(start_date,end_date); }

function get_author(string) {

return string.substr(string.indexOf(" ")+4,string.indexOf(" ",string.indexOf(" "))-string.indexOf(" ")-4); }

function get_title(string) { return string.substr(string.indexOf(" ")+4,string.indexOf(" ",string.indexOf(" "))-string.indexOf(" ")-4); }

function count_titles(string) { var num=0; var pos=1; while (string.indexOf(" ",pos)>0) { num++ pos=string.indexOf(" ",pos)+1; } return num; }

function count_authors(string) { var num=0; var pos=1; while (string.indexOf(" ",pos)>0) { num++ pos=string.indexOf(" ",pos)+1; } return num; }

function get_title_by_author(string,author) { var title_start=string.indexOf(" "); var title_end; var author_start; var author_end;

while (title_start>0) { title_end=string.indexOf(" ",title_start); author_start=string.indexOf(" ",title_end); author_end=string.indexOf(" ",author_start);

if (string.substr(author_start,author_end-author_start).search(author)>0) return get_title(string.substr(title_start,title_end-title_start+5));

title_start=string.indexOf(" ",author_start); }

return ""; }

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

//alert(get_title_by_author("SD title1 SADS author1 fgaf title2 sffsfd author2 gdfgfd","author1")); var zoomed=false; function ToggleZoom { if (zoomed) { document.getElementById("outer").className = 'narrow'; document.getElementById("result").className = 'narrow'; document.getElementById("tf").className = ''; zoomed=false; } else { document.getElementById("outer").className = 'wide'; document.getElementById("tf").className = 'float'; document.getElementById("result").className = 'stretched'; zoomed=true; }

}

var dump_visible=false; function toggle_dump { if (dump_visible) { document.getElementById("dump").className="hidden"; dump_visible=false; } else { document.getElementById("dump").className="visible"; dump_visible=true; } }

/* ]]> */