<?xml version="1.0" encoding="UTF-8" ?> 

<Module>
  <ModulePrefs  
    title="RSS Reader" 
    scrolling="false"/> 

  <UserPref name="url" display_name="URL:" datatype="string" required="true"/>
  <UserPref name="show_date" display_name="Show Dates?" datatype="bool"/>
  <UserPref name="show_summ" display_name="Show Summaries?" datatype="bool"/>
  <UserPref name="num_entries" display_name="Number of Entries:" default_value="5" datatype="enum" >
    <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="font_size" display_name="Font Size:" datatype="string" default_value="100%" required="true" />
  <UserPref name="margin" display_name="Margin:" datatype="string" default_value="5px" required="true" />
  <UserPref name="padding" display_name="Padding:" datatype="string" default_value="5px" required="true" />
  <UserPref name="background_color" display_name="Background Color:" datatype="string" default_value="#FFFFFF" required="true" />
  <UserPref name="border_width" display_name="Border Width:" datatype="string" default_value="1px" required="true" />
  <UserPref name="border_style" display_name="Border Style:" default_value="5" datatype="enum" >
    <EnumValue value="none" />
    <EnumValue value="hidden" />
    <EnumValue value="dotted" />
    <EnumValue value="dashed" />
    <EnumValue value="solid" />
    <EnumValue value="double" />
    <EnumValue value="groove" />
    <EnumValue value="ridge" />
    <EnumValue value="inset" />
    <EnumValue value="outset" />
  </UserPref>

  <Content type="html">
  <![CDATA[ 
<!--
    <style> #content_div { font-size: 90%;  margin: 5px; background-color: #FFFFFF;} </style>
--> 
    <div id=content_div></div>
     <script type="text/javascript">

     // Get userprefs
     var prefs = new _IG_Prefs();
     var url = prefs.getString("url");
     var showdate = prefs.getBool("show_date");
     var summary = prefs.getBool("show_summ");
     var entries = prefs.getInt("num_entries");
     var fontsize = prefs.getString("font_size");
     var margin = prefs.getString("margin");
     var padding = prefs.getString("padding");
     var backgroundcolor = prefs.getString("background_color");
     var borderwidth = prefs.getString("border_width");
     var borderstyle = prefs.getString("border_style");

     // Set up content_div format
     var contentDivStyle = _gel("content_div").style;
     contentDivStyle.fontSize = fontsize;
     contentDivStyle.margin = margin
     contentDivStyle.padding = padding
     contentDivStyle.background = backgroundcolor;
     contentDivStyle.borderWidth = borderwidth;
     contentDivStyle.borderStyle = borderstyle;

     // If user wants to display more than 100 entries, display an error
     // and set the value to 100, the max allowed.
     if (entries > 100)
     {
         alert("You cannot display more than 100 entries.");
         entries = 100;
     }

     // Use the _IG_FetchFeedAsJSON() function to retrieve core feed data from
     // the specified URL. Then combine the data with HTML markup for display in
     // the gadget.
     _IG_FetchFeedAsJSON(url,
              function(feed) { 
              if (feed == null){ 
//                 alert("There is no data.");
                 return;
              }
     
         // Start building HTML string that will be displayed in gadget.
         var html = "";

         // Access the fields in the feed
         html += "<div><b>" + feed.Title + "</b></div>";
         html += "<div>" + feed.Description + "</div><br>";
     
         // 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)
                 { 
                     // The feed entry Date field contains the timestamp in seconds
                     // since Jan. 1, 1970. To convert it to the milliseconds needed
                     // to initialize the JavaScript Date object with the correct date, 
                     // multiply by 1000.
                     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;

     // The rest of the function parameters, which are optional: the number
     // of entries to return, and whether to return summaries.
     }, entries, summary);
 
  </script>

  ]]> 
  </Content>
</Module>