<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="ECCC Reports" title_url="http://eccc.hpi-web.de/" author="Satoshi Hada" author_affiliation="IBM" author_email="satoshih at jp ibm com" author_location="Tokyo, Japan" author_link="http://domino.research.ibm.com/comm/research_people.nsf/pages/satoshih.index.html" description="List of the latest ECCC reports in the current year" scrolling="true">
</ModulePrefs>
<UserPref name="count" display_name="Report Count" datatype="enum" default_value="5">
    <EnumValue value="1" />
    <EnumValue value="2" />
    <EnumValue value="3" />
    <EnumValue value="4" />
    <EnumValue value="5" />
    <EnumValue value="6" />
    <EnumValue value="7" />
    <EnumValue value="8" />
    <EnumValue value="9" />
    <EnumValue value="10" />
</UserPref>
<UserPref name="within" display_name="Highlight Period" datatype="enum" default_value="7">
    <EnumValue value="1" />
    <EnumValue value="2" />
    <EnumValue value="3" />
    <EnumValue value="4" />
    <EnumValue value="5" />
    <EnumValue value="6" />
    <EnumValue value="7" />
</UserPref>
<Content type="html">
  <![CDATA[ 
     <script language="JavaScript" type="text/javascript">
       _IG_RegisterOnloadHandler(onload);

       var today=new Date();
       var year=today.getYear();
       if(year < 2000){year+= 1900;}
       today=new Date(year, today.getMonth(), today.getDate());
       //alert(today.toString());

       var prefs = new _IG_Prefs(__MODULE_ID__);
       var pref = prefs.getString("count");
       var c = parseInt(pref);

       pref = prefs.getString("within");
       var within = parseInt(pref);


       function onload(){
         var url="http://eccc.hpi-web.de/eccc-local/Lists/TR-"+year+".html";
         _IG_FetchContent(url, displayResult);
       }

       function displayResult(responseText){
          //alert(responseText.substr(0,400));
          //document.getElementById("eccc-result").innerHTML = responseText;
          var lines = responseText.split("\n");

          for (var i = 0; i < lines.length; i++) {
            if(lines[i].match("<title>404 Not Found</title>")){
              document.getElementById("eccc-result").innerHTML = responseText;
              return;
            }
          }

          var html="<DL>"; 

          var count=0;
          for (var i = 0; i < lines.length; i++) {
            //
            //Try to find a report
            //
            if(lines[i].match(/<DT>/)){
              count++;
              //alert(lines[i]);
              html+=lines[i].replace("/eccc-reports", "http://eccc.hpi-web.de/eccc-reports").replace("<A HREF", "<A TARGET='_blank' HREF");
              html+="</DT>";

              //
              //Authors
              //
              var last;
              var found=false;
              while(true){
                i++;
                if(!found){
                  if(lines[i].match(/<DD>/)){
                    found=true;
                    html+=lines[i];
                    last=lines[i].charAt(lines[i].length-1);
                    if(last==":"){
                      html+="</DD>";
                      break;
                    }
                  }
                }else{
                  html+=lines[i];
                  last=lines[i].charAt(lines[i].length-1);
                  if(last==":"){
                    html+="</DD>";
                    break;
                  }
                }
              }
              //
              //Title
              //
              found=false;
              while(true){
                i++;
                if(!found){
                  if(lines[i].match(/<DD>/)){
                    found=true;
                    html+=lines[i];
                    if(lines[i].match(/<\/EM>/)){
                      html+="</DD>";
                      break;
                    }
                  }
                }else{
                  html+=lines[i];
                  if(lines[i].match(/<\/EM>/)){
                    html+="</DD>";
                    break;
                  }
                }
              }
            }
            if(count==c)
              break;
          }
          html+="</DL>";

          //alert(html);
          
          //
          // Display the reports
          //
          document.getElementById("eccc-result").innerHTML = html;

          //
          // Mark all reports posted within the last X days by pink background highlighting
          //
          var anchorTags = document.getElementsByTagName("a") ; 
          for (var i = 0; i < anchorTags.length ; i++){
            //alert(anchorTags[i]);
            highlight(anchorTags[i]);
          }
       }
       function highlight(anchorTag){
          _IG_FetchContent(anchorTag.href, 
            function(responseText){
               //alert(responseText);
               var lines = responseText.split("\n");
               for (var i = 0; i < lines.length; i++) {
                 //alert(lines[i]);
                 if(lines[i].match(/accepted on/)){
                   //alert(lines[i]);
                   lines[i]=lines[i].replace(".<BR>", "");
                   dateStr=lines[i].substring(lines[i].length-12, lines[i].length);
                   //alert(dateStr);
                   var date=new Date(dateStr);
                   //alert(date.toString());

                   //anchorTag.title=anchorTag.textContent+", accepted on "+dateStr;
                   var dateStr2=dateStr.substring(0, 6);
                   //alert(anchorTag.textContent);
                   anchorTag.textContent+=" ("+dateStr2+")";
                   //alert(anchorTag.textContent);
                   anchorTag.title="Report number with acceptance date";

                   //comparison
                   var t1=today.getTime();
                   var t2=date.getTime();
                   //check if this report was posted within the last X days
                   if(t1-t2 <= within*24*60*60*1000){
                     anchorTag.style.backgroundColor="Pink"; 
                   }
                   break;
                 }
               }
            }
          );
       }

     </script>

     <DIV style="font-size: smaller" id="eccc-result">
       Reading the ECCC reports...
     </DIV>
  ]]> 
</Content>
</Module>


