Team:Warsaw/Calendar-Main/NoAtribution
From 2008.igem.org
(Difference between revisions)
(20 intermediate revisions not shown) | |||
Line 2: | Line 2: | ||
<html> | <html> | ||
+ | <!-- | ||
+ | NoAttribution script by Michał Lower. | ||
+ | --> | ||
+ | |||
+ | <style> | ||
+ | |||
+ | .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%; | ||
+ | } | ||
+ | |||
+ | |||
+ | </style> | ||
+ | |||
<h3>Attribution analyzer</h3> | <h3>Attribution analyzer</h3> | ||
<form name="params" action="JavaScript:analyze()"> | <form name="params" action="JavaScript:analyze()"> | ||
Line 26: | Line 67: | ||
</td> | </td> | ||
<td> | <td> | ||
- | <input type="text" value=" | + | <input type="text" value="29" size=1 name="end_day"> |
<select name="end_month"> | <select name="end_month"> | ||
<option value="January">January</option> | <option value="January">January</option> | ||
Line 33: | Line 74: | ||
<option value="April">April</option> | <option value="April">April</option> | ||
<option value="May">May</option> | <option value="May">May</option> | ||
- | <option value="June | + | <option value="June">June</option> |
<option value="July">July</option> | <option value="July">July</option> | ||
<option value="August">August</option> | <option value="August">August</option> | ||
- | <option value="September">September</option> | + | <option value="September" selected="selected">September</option> |
<option value="October">October</option> | <option value="October">October</option> | ||
<option value="November">November</option> | <option value="November">November</option> | ||
Line 45: | Line 86: | ||
<input type="submit" value="Go!"> | <input type="submit" value="Go!"> | ||
</form> | </form> | ||
- | <h4 id="progress"></h4> | + | <div id="outer"> |
- | <table id="result"> | + | <table width="98%" class="month"> |
+ | <tr><td width="70%"><h4 id="progress"></h4></td><td align="right"><a href="JavaScript:ToggleZoom()" id="tf">Toggle Fullscreen mode</a></td></tr> | ||
+ | </table> | ||
+ | <table id="result" class="narrow"> | ||
<tr> | <tr> | ||
<td>Michał K.</td> | <td>Michał K.</td> | ||
- | <td>Michał L.</td> | + | <td>Michał L., Ewa, Marcin</td> |
<td>Piotr</td> | <td>Piotr</td> | ||
<td>Antoni</td> | <td>Antoni</td> | ||
<td>Paweł</td> | <td>Paweł</td> | ||
- | <td> | + | <td>Emilia</td> |
+ | <td>Weronika</td> | ||
+ | <td>Errors</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
- | <td id="Michał K."></td> | + | <td id="Michał K." valign="top"></td> |
- | <td id="Michał L."></td> | + | <td id="Michał L." valign="top"></td> |
- | <td id="Piotr"></td> | + | <td id="Piotr" valign="top"></td> |
- | <td id="Antoni"></td> | + | <td id="Antoni" valign="top"></td> |
- | <td id="Paweł"></td> | + | <td id="Paweł" valign="top"></td> |
- | <td id="no_author"></td> | + | <td id="Emilia" valign="top"></td> |
+ | <td id="Weronika" valign="top"></td> | ||
+ | <td id="no_author" valign="top"></td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
- | + | </div> | |
- | + | <div align="right"><a href="javascript:toggle_dump()">Toggle source</a></div> | |
+ | <textarea id="dump" readonly="true" class="hidden" style="width:100%;height:400px">core dump</textarea> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
Line 80: | Line 129: | ||
var months=['January','February','March','April','May','June','July','August','September','October','November','December']; | var months=['January','February','March','April','May','June','July','August','September','October','November','December']; | ||
- | var authors=['Michał K.','Piotr','Antoni','Michał L.','Paweł']; | + | var authors=['Michał K.','Piotr','Antoni','Michał L.','Paweł', 'Emilia', 'Weronika']; |
var adresbase='https://2008.igem.org/Team:Warsaw/Calendar-Main/'; | var adresbase='https://2008.igem.org/Team:Warsaw/Calendar-Main/'; | ||
Line 159: | Line 208: | ||
if(ans.search(eday)<0) | if(ans.search(eday)<0) | ||
{ | { | ||
- | for (i | + | //No proper author or title specified |
+ | if(and(ans.search("<h3>")<0,ans.search("<h4>")<0)) document.getElementById("no_author").innerHTML=document.getElementById("no_author").innerHTML+"<br/><a href="+'"'+adresbase+nday+'"'+">"+nday+": no authors, no titles</a>"; | ||
+ | |||
+ | //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+" No titles: "+removeHTMLTags(get_author(ans))+"</a>"; | ||
+ | //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+" No authors:"+removeHTMLTags(get_title(ans))+"</a>"; | ||
+ | |||
+ | else if (and(count_authors(ans)==count_titles(ans),count_authors(ans)>0)) | ||
+ | { | ||
+ | |||
+ | for (var i=0;i<authors.length;i++) // IE doesn't support for ... in - learn standards M$ lamers | ||
{ | { | ||
if(ans.search(authors[i])>0) { | if(ans.search(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+": "+removeHTMLTags(get_title_by_author(ans,authors[i]))+"</a>"; | |
- | + | ||
- | } | + | } |
- | + | }} | |
- | document.getElementById("no_author").innerHTML=document.getElementById("no_author").innerHTML+"<br/><a href="+'"'+adresbase+nday+'"'+">"+nday+"</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) { | ||
document.getElementById("progress").innerHTML="Done"; | document.getElementById("progress").innerHTML="Done"; | ||
+ | document.getElementById("dump").value=document.getElementById("result").innerHTML; | ||
return true; | return true; | ||
} | } | ||
Line 186: | Line 245: | ||
} | } | ||
- | + | function and(cond1,cond2) | |
+ | { | ||
+ | if (cond1==true) if (cond2==true) return true; | ||
+ | //if (cond1==false) if (cond2==false) return true; | ||
+ | return false; | ||
+ | } | ||
function analyze() | function analyze() | ||
Line 220: | Line 284: | ||
} | } | ||
+ | function get_author(string) { | ||
+ | return string.substr(string.indexOf("<h4>")+4,string.indexOf("</h4>",string.indexOf("<h4>"))-string.indexOf("<h4>")-4); | ||
+ | } | ||
+ | |||
+ | |||
+ | function get_title(string) { | ||
+ | return string.substr(string.indexOf("<h3>")+4,string.indexOf("</h3>",string.indexOf("<h3>"))-string.indexOf("<h3>")-4); | ||
+ | } | ||
+ | |||
+ | 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 ""; | ||
+ | } | ||
+ | |||
+ | 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<h3>title1</h3>SADS<h4>author1</h4>fgaf<h3>title2</h3>sffsfd<h4>author2</h4>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; | ||
+ | } | ||
+ | } | ||
/* ]]> */</script> | /* ]]> */</script> |
Latest revision as of 11:57, 26 October 2008
Attribution analyzer
|