<?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs title="Agenda do Gabeira">
    <Require feature="opensocial-0.7"/>
  </ModulePrefs>
  <Content type="html">
  <![CDATA[
    <div id="content_div"></div>
    <script type="text/javascript">

    function makeDOMRequest() {    
      var params = {};  
      params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.DOM;  
      var url = "http://www.google.com/calendar/feeds/gabeira43%40gmail.com/public/full";  
      gadgets.io.makeRequest(url, response, params);
    };

    function response(obj) { 
      // obj.data contains a Document DOM element corresponding to the
      // page that was requested
      var domdata = obj.data;
      var title = "Agenda do Gabeira";
      var html = "<h2>" + title + "</h2>";
      
      // Get a list of the <item> element nodes in the file
      var itemList = domdata.getElementsByTagName("entry");
 
      // Loop through all <item> nodes
      for (var i = 0; i < itemList.length ; i++) { 
        // For each <food> node, get child nodes.
        var nodeList = itemList.item(i).childNodes;

        // Loop through child nodes. Extract data from the text nodes that are
        // the children of the associated name, price, and calories element nodes.
        for (var j = 0; j < nodeList.length ; j++) {
          var node = nodeList.item(j);
          if (node.nodeName == "title") {
            var name = node.firstChild.nodeValue;
          }         
          if (node.nodeName == "id") {
            var vlink = node.firstChild.nodeValue;
          }

        }
        html += "<br /><b>" + name + "</b> - ";        
		html += "<a href=" + vlink + ">saiba mais</a><br />";
      }
      html += "</div>";
      document.getElementById('content_div').innerHTML = html;
    };
    makeDOMRequest();
    </script>
  ]]>
  </Content>
</Module>
