<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Hindustan Times: Latest News from India" 
             title_url="http://www.hindustantimes.com" 
             directory_title="Hindustan Times: Latest Breaking News Feeds from India" 
             description="Get Breaking News from India, World, Cricket, Business, Bollywood and more as they happen." 
             author="HindustanTimes.com" 
             author_email="HindustanTimesGadget@gmail.com" 
             author_affiliation="Hindustantimes.com" 
             author_location="New Delhi, India" 
             screenshot="http://hosting.gmodules.com/ig/gadgets/file/115224933383919648270/screenshot.png" 
             thumbnail="http://hosting.gmodules.com/ig/gadgets/file/115224933383919648270/final_logo.png" 
             height="300"
             width="250"
             scrolling="false"
             singleton="false">
  <Require feature="dynamic-height"/>
  <Require feature="setprefs"/>
  <Require feature="tabs"/>
  <Require feature="analytics"/>
</ModulePrefs>
<UserPref name="title" display_name="Gadget Title" default_value="Feeds in Tabs"/>
<UserPref name="tabFontSize" display_name="Tab Font Size" default_value="0.7em"/>
<UserPref name="showFeedDesc" display_name="Feed Descriptions" datatype="bool" default_value="true"/>
<UserPref name="feed1"
  display_name="Feed 1: URL"
  datatype="string"
  default_value="http://www.hindustantimes.com/RSSFeed/RssFeed.ashx?c=Chunk-HT-UI-HomePage-TopStories"/>
<UserPref name="feedTitle1" display_name="Feed 1: Title" datatype="string" default_value="News"/>
<UserPref name="feed2"
  display_name="Feed 2: URL"
  datatype="string"
  default_value="http://www.hindustantimes.com/RSSFeed/RssFeed.ashx?c=Cricket"/>
<UserPref name="feedTitle2" display_name="Feed 2: Title" datatype="string" default_value="Cricket"/>
<UserPref name="feed3"
  display_name="Feed 3: URL"
  datatype="string"
  default_value="http://www.hindustantimes.com/RSSFeed/RssFeed.ashx?c=Cinema"/>
<UserPref name="feedTitle3" display_name="Feed 3: Title" datatype="string" default_value="Cinema"/>
<UserPref name="feed4"
  display_name="Feed 4: URL"
  datatype="string"
  default_value="http://www.hindustantimes.com/RSSFeed/RssFeed.ashx?c=Business"/>
<UserPref name="feedTitle4" display_name="Feed 4: Title" datatype="string" default_value="Business"/>
<UserPref name="feed5"
  display_name="Feed 5: URL"
  datatype="string"
  default_value="http://www.hindustantimes.com/RSSFeed/RssFeed.ashx?c=LifeStyle"/>
<UserPref name="feedTitle5" display_name="Feed 5: Title" datatype="string" default_value="Lifestyle"/>
<UserPref name="entries" display_name="# of Entries" datatype="enum" default_value="10">
  <EnumValue value="3"/>
  <EnumValue value="4"/>
  <EnumValue value="5"/>
  <EnumValue value="6"/>
  <EnumValue value="7"/>
  <EnumValue value="8"/>
  <EnumValue value="9"/>
  <EnumValue value="10"/>
  <EnumValue value="11"/>
  <EnumValue value="12"/>
</UserPref>
<UserPref name="summaries" display_name="Summaries" datatype="enum" default_value="-1">
  <EnumValue value="-1" display_value="none"/>
  <EnumValue value="100" display_value="short"/>
  <EnumValue value="200" display_value="medium"/>
  <EnumValue value="300" display_value="long"/>
  <EnumValue value="400" display_value="longer"/>
  <EnumValue value="0" display_value="show all"/>
</UserPref>
<UserPref name="renderHtml" display_name="Render HTML" datatype="bool" default_value="true"/>
<UserPref name="showTimestamp" display_name="Show Timestamp" datatype="bool" default_value="false"/>
<UserPref name="selectedTab" datatype="hidden"/>
<Content type="html"><![CDATA[
<style type="text/css">.tablib_table{font-size:__UP_tabFontSize__}.tablib_selected{background-color:#fff;border-color:#676767;border-style:solid;border-width:1px 1px 0;color:#000;cursor:default;font-weight:bold;padding:2px}.tablib_unselected{font-weight:bold;padding:2px 0;background-color:#ddd;border:1px solid #aaa;border-bottom-color:#676767;color:#36c;cursor:pointer;width:20%}.statusLabel{font-size:0.75em;font-style:italic;padding-top:10px;text-align:center}.feedHeader{padding-top:5px;font-size:0.7em}.feedHeader .feedTitle{font-weight:bold;font-size:1.1em}.feedHeader .feedAuthor{font-weight:normal;font-size:0.8em;color:#676767}.feedList{font-size:12px;font-family:Georgia;margin:0;padding:0 0 5px 0;border-bottom:1px solid #fff;text-decoration:none}.feedList li{margin-top:5px;padding:3px 3px 0 3px;border-top:1px solid #fff;text-decoration:none}.feedList li div.entryTitle a{font-weight:normal;text-decoration:none}.feedList li div.entryTimestamp{font-size:0.95em;font-style:italic;color:#676767}.feedfooter{width:100%;background:url(http://hosting.gmodules.com/ig/gadgets/file/115224933383919648270/logobg.gif);font-weight:normal;text-decoration:none}.newfeedlist{text-decoration:none;font-weight:normal;font-family:georgia;font-size:12px;background:url(http://hosting.gmodules.com/ig/gadgets/file/115224933383919648270/arrow.gif) no-repeat 0 4px;padding:0 0 0 15px;display:block}.newfeedlist a:hover{text-decoration:none;font-weight:normal;font-family:georgia;font-size:12px;background:url(http://www.hindustantimes.com/widget/images/arrow1.gif) no-repeat 0 4px}.newfeedlist a:visited{text-decoration:none;font-weight:normal;font-family:georgia;font-size:12px;background:url(http://www.hindustantimes.com/widget/images/arrow1.gif) no-repeat 0 4px}#footerart{width:100%;position:absolute;top:276px;padding-left:2px}</style>
<!-- <div style="width:100%; background-image:url(http://www.hindustantimes.com/gadget/logobg.gif);padding-left:2px"><a href="http://www.hindustantimes.com" target="_blank"><img src="http://hosting.gmodules.com/ig/gadgets/file/115224933383919648270/toplogonew.gif" border="0" alt="Click here to Read Latest Breaking News from India" title="Click here to Read Latest Breaking News from India"></a></div> -->
  <script>
  // Global variables
  var prefs = new _IG_Prefs(__MODULE_ID__);
  var tabs = new _IG_Tabs(__MODULE_ID__);

  /**
   * Initialize tabs when page loads.
   * Create tab for each userpref only if userpref is not empty.
   */
  function init() {
    var f1 = _trim(prefs.getString("feed1"));
    var f2 = _trim(prefs.getString("feed2"));
    var f3 = _trim(prefs.getString("feed3"));
    var f4 = _trim(prefs.getString("feed4"));
    var f5 = _trim(prefs.getString("feed5"));
    var ft1 = _trim(prefs.getString("feedTitle1"));
    var ft2 = _trim(prefs.getString("feedTitle2"));
    var ft3 = _trim(prefs.getString("feedTitle3"));
    var ft4 = _trim(prefs.getString("feedTitle4"));
    var ft5 = _trim(prefs.getString("feedTitle5"));

    if (f1 != "") {
      tabs.addDynamicTab(((ft1 == "") ? "Feed 1" : ft1), _IG_Callback(callbackTab, f1));
    }
    if (f2 != "") {
      tabs.addDynamicTab(((ft2 == "") ? "Feed 2" : ft2), _IG_Callback(callbackTab, f2));
    }
    if (f3 != "") {
      tabs.addDynamicTab(((ft3 == "") ? "Feed 3" : ft3), _IG_Callback(callbackTab, f3));
    }
    if (f4 != "") {
      tabs.addDynamicTab(((ft4 == "") ? "Feed 4" : ft4), _IG_Callback(callbackTab, f4));
    }
    if (f5 != "") {
      tabs.addDynamicTab(((ft4 == "") ? "Feed 5" : ft5), _IG_Callback(callbackTab, f5));
    }
  };

  /**
   * Fetches an Atom or RSS feed and generates content inside the
   * selected tab's content container.  This function is called whenever
   * a tab is selected.
   */
  function callbackTab(tabId, feedUrl) {
    var showFeedDesc = prefs.getBool("showFeedDesc");
    var summaries = prefs.getInt("summaries");
    var entries = prefs.getInt("entries");
    var renderHtml = prefs.getBool("renderHtml");
    var showTimestamp = prefs.getBool("showTimestamp");
    var container = _gel(tabId);

    // Display loading message before fetching feed.
    container.innerHTML = '<div class="statusLabel">Loading...</div>';

    // Fetch feed and return it as a JSON object.
    // Callback function is defined within local scope.
    _IG_FetchFeedAsJSON(
      feedUrl,
      function(feed) {
        if (typeof feed == "undefined" || typeof feed.Entry == "undefined") {
          container.innerHTML = '<div class="statusLabel">Invalid feed URL:<br>' + feedUrl + '</div>';
        } else {
          // Fetch feed successful.  Generate HTML content from returned JSON object.
          // Create feed header containing title and description.
          var html = new Array();
          html.push('<div class="feedHeader">');
          html.push('<div class="feedTitle">');
          // html.push((feed.Link != "") ? '<a target="_blank" href="' + _hesc(feed.Link) + '">' + _hesc(feed.Title) + '</a>' : _hesc(feed.Title));
          html.push((feed.Author != "") ? '<span class="feedAuthor"> by ' + _hesc(feed.Author) + '</span>' : "");
          html.push('</div>');
           if (showFeedDesc) {
            html.push('<div class="feedDesc">' + _hesc(feed.Description) + '</div>');
           }
          html.push('</div>');
          
          // Iterate through each feed entry and generate list of content.
          html.push('<ul class="feedList">');
          for (var n = 0; n < feed.Entry.length; n++) {
            var entry = feed.Entry[n];
            html.push('<li>');
            html.push('<a class="newfeedlist" target="_blank" href="' + entry.Link + '">' + _hesc(entry.Title) + '</a>');
            if (typeof entry.Summary != "undefined" && entry.Summary != "") {
              var summary = document.createElement("div");
              summary.innerHTML = (summaries == 0) ? entry.Summary : entry.Summary.substr(0, summaries);
              html.push('<div class="entrySummary">');
              html.push((renderHtml ? summary.innerHTML : _hesc(summary.innerHTML)));
              html.push('</div>');
            }
            if (!isNaN(entry.Date) && showTimestamp) {
              html.push('<div class="entryTimestamp">[' + new Date(entry.Date * 1000).toLocaleString() + ']</div>');  
            }
            html.push('</li>');
          }
          html.push('</ul>');
          html.push('<div id="footerart" class="feedfooter"><a href="www.hindustantimes.com" target="_blank"><img src="http://hosting.gmodules.com/ig/gadgets/file/115224933383919648270/toplogonew.gif" border="0" alt="Click here to Read Latest Breaking News from India" title="Click here to Read Latest Breaking News from India"></a></div>');
          container.innerHTML = html.join("");
        }

        // Resize iframe height to fit content.
        _IG_AdjustIFrameHeight();
      },
      entries,
      (summaries > -1)
    );
  }

  // Set onload event handler to call init()
  _IG_RegisterOnloadHandler(init);
  _IG_Analytics("UA-1431719-1", "/igoogle/newsfeed300x250");
  </script>
]]>
</Content>
</Module>
