<?xml version="1.0" encoding="UTF-8" ?> 
<Module>
  <ModulePrefs title="New Inventors: Latest Inventions"
               description="Lists the latest inventions featured on ABCs New Inventors show website."
               author="Tim Lucas"
               author_email="t.lucas+gadgets@gmail.com"
               author_link="http://www.toolmantim.com"
               author_aboutme="Rails hacker and interaction designer from Syd Oz"
               title_url="http://abc.net.au/tv/newinventors/"
               singleton="true"
               scrolling="true" />
  <Content type="html">
     <![CDATA[ 
     <div id="inventors">Loading...</div>
     <script type="text/javascript">
       function initInventors() {
         var url = 'http://abc.net.au/tv/newinventors/inventions/';
         var pattern = "(http:\/\/www\.abc\.net\.au\/tv\/newinventors\/txt\/.*?\.htm)\"><strong>(.*?)<\/strong><\/a>";
         var maxItems = 10;
         var loadingElem = document.getElementById("loading");
         var containerElem = document.getElementById("inventors");

         function addInvention(name, url) {
           containerElem.innerHTML += '<a href="' + url + '" target="_blank">' + name + '</a><br/>';
         }
       
         function parse(unsemantic_poo) {
           var regex = new RegExp(pattern, "mig");
           for (var i = 0; i < maxItems; i++) {
             var match = regex.exec(unsemantic_poo);
             if (match) {
               addInvention(match[2], match[1]);
             }
           }
         }
       
         _IG_FetchContent(url, function (responseText) {
           if (!responseText) {
             containerElem.innerHTML = "There was a problem fetching the latest inventions";
             return;
            }
           containerElem.removeChild(containerElem.childNodes[0]);
           parse(responseText);
         });
       }
       _IG_RegisterOnloadHandler(initInventors);
     </script>
     ]]>
  </Content> 
</Module>
