Team:Warsaw/Calendar-Main/NoAtribution
From 2008.igem.org
(Difference between revisions)
Line 163: | Line 163: | ||
//No proper titles | //No proper titles | ||
- | else if(ans.search("<h3>")<0) document.getElementById("no_author").innerHTML=document.getElementById("no_author").innerHTML+"<br/><a href="+'"'+adresbase+nday+'"'+">"+nday+": "+get_author(ans)+" | + | else if(ans.search("<h3>")<0) document.getElementById("no_author").innerHTML=document.getElementById("no_author").innerHTML+"<br/><a href="+'"'+adresbase+nday+'"'+">"+nday+" No titles: "+get_author(ans)+"</a>"; |
//no proper authors | //no proper authors | ||
- | else if(ans.search("<h4>")<0) document.getElementById("no_author").innerHTML=document.getElementById("no_author").innerHTML+"<br/><a href="+'"'+adresbase+nday+'"'+">"+nday+": "+get_title(ans)+" | + | else if(ans.search("<h4>")<0) document.getElementById("no_author").innerHTML=document.getElementById("no_author").innerHTML+"<br/><a href="+'"'+adresbase+nday+'"'+">"+nday+" No authors:"+get_title(ans)+"</a>"; |
- | else | + | else if (count_authors(ans)==count_titles(ans)) |
{ | { | ||
+ | for (i in authors) | ||
+ | { | ||
+ | |||
if(ans.search("<h4>"+authors[i])>0) { | if(ans.search("<h4>"+authors[i])>0) { | ||
- | document.getElementById(authors[i]).innerHTML=document.getElementById(authors[i]).innerHTML+"<br/><a href="+'"'+adresbase+nday+'"'+">"+nday+"</a>"; | + | document.getElementById(authors[i]).innerHTML=document.getElementById(authors[i]).innerHTML+"<br/><a href="+'"'+adresbase+nday+'"'+">"+nday+": "+get_title_by_author(ans,authors[i])+"</a>"; |
- | + | } | |
- | } | + | }} |
+ | else document.getElementById("no_author").innerHTML=document.getElementById("no_author").innerHTML+"<br/><a href="+'"'+adresbase+nday+'"'+">"+nday+": Author-Title mismatch</a>"; | ||
} | } | ||
if (day==end_day) { | if (day==end_day) { | ||
Line 230: | Line 234: | ||
function get_author(string) { | function get_author(string) { | ||
- | return string.substr(string.indexOf("<h4>")+4,string.indexOf("</h4>") | + | |
+ | return string.substr(string.indexOf("<h4>")+4,string.indexOf("</h4>",string.indexOf("<h4>"))-string.indexOf("<h4>")-4); | ||
} | } | ||
function get_title(string) { | function get_title(string) { | ||
- | return string.substr(string.indexOf("<h3>")+4,string.indexOf("</h3>",string.indexOf("<h3>"))); | + | return string.substr(string.indexOf("<h3>")+4,string.indexOf("</h3>",string.indexOf("<h3>"))-string.indexOf("<h3>")-4); |
} | } | ||
function count_titles(string) { | function count_titles(string) { | ||
+ | var num=0; | ||
+ | var pos=1; | ||
+ | while (string.indexOf("<h3>",pos)>0) | ||
+ | { | ||
+ | num++ | ||
+ | pos=string.indexOf("<h3>",pos)+1; | ||
+ | } | ||
+ | return num; | ||
+ | } | ||
+ | |||
+ | function count_authors(string) { | ||
+ | var num=0; | ||
+ | var pos=1; | ||
+ | while (string.indexOf("<h4>",pos)>0) | ||
+ | { | ||
+ | num++ | ||
+ | pos=string.indexOf("<h4>",pos)+1; | ||
+ | } | ||
+ | return num; | ||
+ | } | ||
+ | |||
+ | function get_title_by_author(string,author) | ||
+ | { | ||
+ | var title_start=string.indexOf("<h3>"); | ||
+ | var title_end; | ||
+ | var author_start; | ||
+ | var author_end; | ||
+ | |||
+ | while (title_start>0) | ||
+ | { | ||
+ | title_end=string.indexOf("</h3>",title_start); | ||
+ | author_start=string.indexOf("<h4>",title_end); | ||
+ | author_end=string.indexOf("</h4>",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("<h3>",author_start); | ||
+ | } | ||
+ | return null; | ||
} | } | ||
- | alert( | + | //alert(get_title_by_author("SD<h3>title1</h3>SADS<h4>author1</h4>fgaf<h3>title2</h3>sffsfd<h4>author2</h4>gdfgfd","author1")); |
/* ]]> */</script> | /* ]]> */</script> |
Revision as of 21:29, 10 October 2008
Attribution analyzer
|