<?xml version="1.0" encoding="UTF-8" ?> 
 <Module>
  <ModulePrefs title="Gnuheter" description="Show the latest headlines from Gnuheter, a swedish portal for free software" title_url="http://kers.se/opensocial/gnuheter.xml" author_email="opensocial@atdt.nu" author_affiliation="kodkultur.org" author_location="Stockholm, Sweden" author_aboutme="Just Another Opensocial Hacker" author_link="http://kodkultur.org/" > 
	 <Require feature="opensocial-0.5" />
  </ModulePrefs> 
  <UserPref name="show_date" display_name="Visa datum?" datatype="bool"/>
  <UserPref name="show_summ" display_name="Visa sammanfattning?" datatype="bool"/>
  <UserPref name="num_entries" display_name="Antal rubriker:" />
  <UserPref name="nick" display_name="Ditt handle:" />
  <UserPref name="blogg" display_name="Din blogg:" />
 <Content type="html">
 <![CDATA[ 
<style> #content_div { font-size: 80%;  margin: 5px; } </style>
<div id=content_div></div>
<script type="text/javascript"> 
// Get userprefs
var prefs = new _IG_Prefs(__MODULE_ID__);
var showdate = prefs.getBool("show_date");
var summary = prefs.getBool("show_summ");
var entries = prefs.getInt("num_entries");
var handle = prefs.getString("nick");

if (entries > 9)
{
    alert("Max 9 rubriker.");
    entries = 9;
}

_IG_FetchFeedAsJSON(
  "http://www.gnuheter.com/rss20.xml",
  function(feed) {    
    if (feed == null){ 
        alert("feeden &auml;r tom!");
    return;
  }
  
    // Start building HTML string that will be displayed in gadget.
    var html = "";
    // Access the fields in the feed
    html += '<img src="http://munnen.handgranat.org/Kers/gnu-liten.png" border="0">'; 
    html += "<div><b>" + feed.Title + "</b></div>";
    html += "<div>Gnuheter sammanst&auml;ller de senaste blogginl&auml;ggen om och runt fri mjukvara.</div><br>";

//    html += "<div><b>" + handle + "</b></div>";
	    
    // Access the data for a given entry
    if (feed.Entry) {
      for (var i = 0; i < feed.Entry.length; i++) {
        html += "<div>"
	      +   "<a target='_blank' href='" + feed.Entry[i].Link + "'>"
	      +      feed.Entry[i].Title
	      +   "</a> ";
          if (showdate==true)
          {    
             var milliseconds = (feed.Entry[i].Date) * 1000;   
             var date = new Date(milliseconds);      
             html += date.toLocaleDateString();
             html += " ";
             html += date.toLocaleTimeString();             
          }          
          if (summary==true) {           
             html += "<br><i>" + feed.Entry[i].Summary + "</i>";
          }
	      html += "</div>";
      }
    }

    _gel("content_div").innerHTML = html;
  }, entries, summary);

    
</script>

  ]]> 
  </Content>
  </Module>
