Team:Warsaw/JSTest2
From 2008.igem.org
(Difference between revisions)
Line 1: | Line 1: | ||
{{WarHead}} | {{WarHead}} | ||
<html> | <html> | ||
+ | |||
+ | <h3>Attribution analyzer</h3> | ||
+ | <form name="params" action="JavaScript:analyze()"> | ||
+ | <table class="month" width="100%"> | ||
+ | |||
+ | <tr><td width="50%">Start date</td><td>End date</td></tr> | ||
+ | <tr><td width="50%"> | ||
+ | <input type="text" value="4" size=1 name="start_day"> | ||
+ | <select name="start_month"> | ||
+ | <option value="January">January</option> | ||
+ | <option value="February">February</option> | ||
+ | <option value="March">March</option> | ||
+ | <option value="April">April</option> | ||
+ | <option value="May" selected="selected">May</option> | ||
+ | <option value="June">June</option> | ||
+ | <option value="July">July</option> | ||
+ | <option value="August">August</option> | ||
+ | <option value="September">September</option> | ||
+ | <option value="October">October</option> | ||
+ | <option value="November">November</option> | ||
+ | <option value="December">December</option> | ||
+ | </select> | ||
+ | <input type="text" value="2008" size=3 name="start_year" disabled="disabled"> | ||
+ | </td> | ||
+ | <td> | ||
+ | <input type="text" value="16" size=1 name="end_day"> | ||
+ | <select name="end_month"> | ||
+ | <option value="January">January</option> | ||
+ | <option value="February">February</option> | ||
+ | <option value="March">March</option> | ||
+ | <option value="April">April</option> | ||
+ | <option value="May" selected="selected">May</option> | ||
+ | <option value="June">June</option> | ||
+ | <option value="July">July</option> | ||
+ | <option value="August">August</option> | ||
+ | <option value="September">September</option> | ||
+ | <option value="October">October</option> | ||
+ | <option value="November">November</option> | ||
+ | <option value="December">December</option> | ||
+ | </select> | ||
+ | <input type="text" value="2008" size=3 name="end_year" disabled="disabled"> | ||
+ | </td></tr></table> | ||
+ | <input type="submit" value="Go!"> | ||
+ | </form> | ||
<a id="anch">Jump</a> | <a id="anch">Jump</a> | ||
- | <div id=" | + | <div id="progress"></div> |
<script type="text/javascript"> | <script type="text/javascript"> | ||
/* <![CDATA[ */ | /* <![CDATA[ */ | ||
- | |||
- | |||
function removeHTMLTags(strInputCode ){ | function removeHTMLTags(strInputCode ){ | ||
Line 20: | Line 62: | ||
} | } | ||
+ | |||
+ | var codebase="https://2008.igem.org/wiki/index.php?title=Team:Warsaw/JSTest"+String.fromCharCode(38); | ||
+ | |||
+ | var months=['January','February','March','April','May','June','July','August','September','October','November','December']; | ||
+ | |||
+ | var adresbase='https://2008.igem.org/Team:Warsaw/Calendar-Main/'; | ||
+ | |||
+ | 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 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; | ||
+ | } | ||
+ | |||
+ | var eday="empty"; | ||
+ | eday=eday.replace("y","yday"); | ||
+ | |||
+ | var topics=new Array(); | ||
+ | |||
+ | function find_topics(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; | ||
+ | |||
+ | 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) | ||
+ | { | ||
+ | var a_t=get_topics(ans); | ||
+ | for (var i=0;i<a_t.length;i++) | ||
+ | { | ||
+ | if (topics[a_t[i]]==undefined)topics[a_t[i]]=day+';'; | ||
+ | else topics[a_t[i]]+=day+';'; | ||
+ | |||
+ | } | ||
+ | } | ||
+ | if (day==end_day) { | ||
+ | document.getElementById("progress").innerHTML="Done"; | ||
+ | alert(topics); | ||
+ | return true; | ||
+ | } | ||
+ | else { find_topics(nday,end_day); } | ||
+ | |||
+ | } | ||
+ | } | ||
+ | |||
+ | }; //koniec wewnętrznej funkcji | ||
+ | |||
+ | req.open('GET', adresbase+nday, true); | ||
+ | req.send(null); | ||
+ | } | ||
+ | |||
+ | 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; | ||
+ | } | ||
+ | |||
+ | find_topics(start_date,end_date); | ||
+ | } | ||
+ | |||
+ | function trimStr(str) | ||
+ | { | ||
+ | return str.replace(/^\s+|\s+$/g, ''); | ||
+ | } | ||
+ | |||
+ | |||
+ | function get_topics(ans) | ||
+ | { | ||
+ | var ans_topics=new Array(); | ||
+ | h3=new RegExp(/<h3.*>(.*)<\/h3>/ig); | ||
+ | var titles=ans.match(h3); | ||
+ | for (var i=0;i<titles.length;i++) | ||
+ | { | ||
+ | if (titles[i].search("h3")>0) | ||
+ | { | ||
+ | var notags=titles[i].split(/(<h3>)|(<\/h3>)/i); | ||
+ | |||
+ | var currtitle=removeHTMLTags(notags[3]); | ||
+ | currtitle=trimStr(currtitle.replace('+',' ')); | ||
+ | ans_topics.push(currtitle); | ||
+ | } | ||
+ | } | ||
+ | return ans_topics; | ||
+ | } | ||
+ | |||
+ | |||
+ | function and(cond1,cond2) | ||
+ | { | ||
+ | if (cond1==true) if (cond2==true) return true; | ||
+ | return false; | ||
+ | } | ||
+ | |||
var title='Preparation of <a href="https://2008.igem.org/Wiki/Team:Warsaw/vectors/pMPM-T5-AID">pMPMT5+AID</a> construct'; | var title='Preparation of <a href="https://2008.igem.org/Wiki/Team:Warsaw/vectors/pMPM-T5-AID">pMPMT5+AID</a> construct'; | ||
+ | |||
var days=['6_May_2008','7_May_2008']; | var days=['6_May_2008','7_May_2008']; | ||
Line 31: | Line 230: | ||
params+="name="+escape(removeHTMLTags(title)); | params+="name="+escape(removeHTMLTags(title)); | ||
- | |||
document.getElementById("anch").href=codebase+params; | document.getElementById("anch").href=codebase+params; | ||
+ | |||
Revision as of 09:07, 26 October 2008
Attribution analyzerJump |