<?xml version="1.0" encoding="UTF-8" ?>
<Module>
	
<ModulePrefs title="__UP_title__"
            directory_title="DevX Feeds"
            description="Aggregate 1-10 entries of DevX Feeds. You can choose the feed to read by editing settings"
            author="Alessandro Lacava"
            author_email="alessandrolacava+devxgadget@gmail.com"
            author_affiliation="DevX"
            author_location="Milan, ITALY"
            height="250"
            scrolling="true"
            singleton="false"
            author_link="http://www.alessandrolacava.com">
</ModulePrefs>

<UserPref name="title" display_name="Gadget Title" default_value="DevX Feeds"/>
<UserPref name="showFeedDate" display_name="Include Feed Date" datatype="bool" default_value="true"/>

<UserPref name="feedUrl"  
		display_name="Feed" datatype="enum" 
		default_value="http://services.devx.com/outgoing/devxfeed.xml">
  <EnumValue value="http://services.devx.com/outgoing/devxfeed.xml" display_value="Latest Articles"/>
  <EnumValue value="http://services.devx.com/outgoing/javafeed.xml" display_value="Java"/>
  <EnumValue value="http://services.devx.com/outgoing/dotnet.xml" display_value=".NET"/>
  <EnumValue value="http://services.devx.com/outgoing/xmlfeed.xml" display_value="XML"/>
  <EnumValue value="http://services.devx.com/outgoing/databasefeed.xml" display_value="Database"/>
  <EnumValue value="http://services.devx.com/outgoing/enterprisefeed.xml" display_value="Enterprise"/>
  <EnumValue value="http://services.devx.com/outgoing/cplusfeed.xml" display_value="C++"/>
  <EnumValue value="http://services.devx.com/outgoing/webdevfeed.xml" display_value="Web Development"/>
  <EnumValue value="http://services.devx.com/outgoing/wirelessfeed.xml" display_value="Wireless"/>
  <EnumValue value="http://services.devx.com/outgoing/recentTipsfeed.xml" display_value="Latest Tips"/>
  <EnumValue value="http://services.devx.com/outgoing/openSourcefeed.xml" display_value="Open Source"/>
</UserPref>

<UserPref name="numOfEntries" 
		display_name="Number of Entries" 
		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="newPageTarget" 
		display_name="Open Link In New Page" 
		datatype="bool" 
		default_value="true"/>

<UserPref name="titleFontSize" 
		display_name="Title Font Size" 
		datatype="enum" default_value="12px">
  <EnumValue value="7px"/>
  <EnumValue value="8px"/>
  <EnumValue value="9px"/>
  <EnumValue value="10px"/>
  <EnumValue value="11px"/>
  <EnumValue value="12px"/>
  <EnumValue value="13px"/>
  <EnumValue value="14px"/>
</UserPref>

<UserPref name="dateFontSize" 
		display_name="Date Font Size" 
		datatype="enum" default_value="10px">
  <EnumValue value="7px"/>
  <EnumValue value="8px"/>
  <EnumValue value="9px"/>
  <EnumValue value="10px"/>
  <EnumValue value="11px"/>
  <EnumValue value="12px"/>
  <EnumValue value="13px"/>
  <EnumValue value="14px"/>
</UserPref>
	
<Content type="html">
<![CDATA[
  <style type="text/css">
	  .loadingLabel 
	  {
	    font-style: italic;
	    padding-top: 10px;
	    text-align: center;
	    font-size: 12px;
	    color: #0066ff;
	  }
	  .errorLabel 
	  {
	    font-weight: bold;
	    padding-top: 10px;
	    text-align: center;
	    font-size: 14px;
	    color: #ff0000;
	  } 
		a.title:link, a.title:visited, a.title:active
		{
			text-decoration:none;
			padding: 2px;
			margin-bottom: 1em;
			font-size: __UP_titleFontSize__; 
			font-family: monospace;
			font-weight:bold;
			color:#0066ff;
		}
		a.title:hover
		{
			text-decoration:none;
			padding: 2px;
			margin-bottom: 1em;
			font-size: __UP_titleFontSize__;
			font-family: monospace;
			font-weight:bold;
			color:#ff0000; 
		}
		.date
		{
			font-size: __UP_dateFontSize__;
		}	
		.feedTitle
		{
			font-size: 15px;
			font-weight: bold;
			color: #ff6600;
			text-align: center;
		}
		.feedContainer
		{
			border-bottom: 1px dashed #ff6600;
			margin-top: 2px;
			padding-bottom: 2px;
		}
  </style>

  <script type="text/javascript">
  /**
   * Fills some variables needed throughout
   * the page.
   */
  function fillGlobals()
  {
	  var prefs = new _IG_Prefs(__MODULE_ID__);
	  feedUrl = prefs.getString("feedUrl");
	  numOfEntries = prefs.getInt("numOfEntries");
	  container = _gel("feedContainer");
	  showFeedDate = prefs.getBool("showFeedDate");
	  openInNewPage = prefs.getBool("newPageTarget");
	}

  /**
   * Initializes the page.
   * It is called when the page loads.
   */
  function init() 
  {
  	fillGlobals();
    // Display loading message before fetching feed.
    container.innerHTML = '<div class="loadingLabel">Loading...</div>';
    // Fetch feed and return it as a JSON object.
    // parseFeed is the callback function.
    _IG_FetchFeedAsJSON(feedUrl, parseFeed, numOfEntries);    
  }
  
  /**
  	* Retrieves the news for the currently selected feed.
  	* @param String feed The feed URL to fetch
  	*/
  function parseFeed(feed)
  {
		var linkTarget = openInNewPage ? "target='_blank'" : "target='_top'";
    
		if (!feed || !feed.Entry)
		{ // failure
      container.innerHTML = '<div class="errorLabel">Invalid feed URL:<br>' + feedUrl + '</div>';
    } 
    else // success
    {
      // Build the HTML content
      var html = [];
      
      if(feed.Title)
      {
      	html.push('<div id="feedTitle" class="feedTitle">');
      	html.push(feed.Title);
      	html.push('</div>');
      }
      
      html.push(_gel("google-advert").innerHTML);

      var numOfEntries = feed.Entry.length;
      
      // The feed body
      html.push('<div id="feedBody">');
      for (var i = 0; i < numOfEntries; i++) 
      {
        var item = feed.Entry[i];  
        html.push('<div class="feedContainer">');   
	      // Append the title
	      html.push('<div id="itemTitle">');
	      html.push((item.Link != "") ? '<a class="title" ' + linkTarget + ' href="' + _hesc(item.Link) + '">' + _hesc(item.Title) + '</a>' : _hesc(item.Title));
	      html.push('</div>');
	      
	      if (showFeedDate) 
	      {
	      	// Append the date
	        var milliseconds = (feed.Entry[i].Date) * 1000; 
	        var date = new Date(milliseconds); 
	        var dateString = date.toLocaleDateString();
	        var timeString = date.toLocaleTimeString(); 
	        html.push('<div id="itemDate" class="date">');
	       	html.push('(' + dateString + ' - ' + timeString + ')');
	     		html.push('</div>');
	      }
	      
	      html.push('</div>'); 
	      
	      container.innerHTML = html.join("");
    	}
    	html.push('</div>'); 
  	}
	}

  // Set onload event handler to call init()
  _IG_RegisterOnloadHandler(init);
  </script>
  	<div id="google-advert" style="display: none;">
  		<div style="text-align: center;">
	      <script type="text/javascript"><!--
					google_ad_client = "pub-5197429200900262";
					google_ad_width = 234;
					google_ad_height = 60;
					google_ad_format = "234x60_as";
					google_ad_type = "text_image";
					google_ad_channel = "";
					google_color_border = "0066FF";
					google_color_bg = "FFFFFF";
					google_color_link = "0066FF";
					google_color_text = "000000";
					google_color_url = "FF6600";
					//-->
				</script>
				<script type="text/javascript"
				  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
				</script>
			</div>
		</div>
  
  <div id="feedContainer"></div>
]]>
</Content>
</Module>
