<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="__UP_title__"
            directory_title="Daily Pursuit of Happiness"
            description="Get a daily emotional boost from Jackie Lewis and The Happy 365.We all say 'I want to be happy'. However, we are often caught in the busy daily life dealing with deadlines, financial struggles, partners, prepare lunch boxes for the kids. The list could go on and on. It seems we just don't have the time to be happy. Then we started experiencing stress, anger, depression, and health problems. After that, we experience break ups, divorces, low performance at work, alcohol and drug problem and even worse, some people commit suicide. This gadget is intended to remind people daily to create a life worth living and build a community that people share their stories, skills to cope with whatever the difficulties they are experiencing and help each other. Ultimately we are one."
            category="lifestyle"
            category2="wellbeing"
            author="Jackie Lewis"
            author_email="jackie@thehappy365.com"
            author_affiliation="The Happy 365"
            author_location="Mountain View, CA"
            screenshot="http://farm3.static.flickr.com/2477/4048795017_542609fbc5_o.jpg"
            thumbnail="http://farm3.static.flickr.com/2434/4049542812_cff205c500_o.jpg"
            height="250"
            width="325"
            scrolling="true"
            singleton="false">
  <Require feature="setprefs"/>
  <Require feature="tabs"/>
  <Require feature="analytics"/>
  <Require feature="dynamic-height"/>
</ModulePrefs>
<UserPref name="title" display_name="Daily Pursuit of Happiness" default_value="Pursuit of Happiness"/>
<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://thehappy365.com/blog/category/pursuit-of-happiness/feed"/>
<UserPref name="feedTitle1" display_name="Feed 1: Title" datatype="string" default_value="Pursuit of Happiness"/>
<UserPref name="entries" display_name="# of Entries" datatype="enum" default_value="1">
  <EnumValue value="2"/>
  <EnumValue value="3"/>
  <EnumValue value="4"/>
  <EnumValue value="5"/>
</UserPref>
<UserPref name="summaries" display_name="Summaries" datatype="enum" default_value="0">
  <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="true"/>
<UserPref name="selectedTab" datatype="hidden"/>
<Content type="html"><![CDATA[
  <style type="text/css">
  a { color:#3399cc;text-decoration:none; }
  a:hover { text-decoration:underline; }
  .tablib_table {
    font-size: __UP_tabFontSize__;
  }
  a:visited { color:#3399cc; }
  .tablib_selected, .tablib_unselected {
    width: 23%;
  }
  .feedlist li { clear:right; }
  .entrySummary img { float:right;margin:2px 2px 2px 10px; }
  .tablib_selected { border-color:#eee;color:#777; }
  .tablib_emptyTab { border-bottom:1px solid #eee; }
  .tablib_unselected { background:#f2f2f2;border-color:#eee; }
  .tablib_spacerTab { border-color:#eee; }
  .tablib_table { margin-top:5px; }

  .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: 0.7em;
    margin: 0px;
    padding: 0px 0px 5px 0px;
  }
  .feedList li {
    margin-top: 5px;
    padding: 3px 3px 0px 3px;
    border-top: 1px solid #eee;
  }
  .feedList li div.entryTitle a {
    font-weight: bold;
  }
  .feedList li div.entryTimestamp {
    font-size: 0.95em;
    font-style: italic;
    color: #676767;
  }
  .entrySummary { font-size:12px;font-weight:bold;color:#333; }
  #logo { display:block;width:300px;height:50px;background:url('http://farm3.static.flickr.com/2616/4048547565_b9237b4f77_o.jpg') no-repeat; }
  .feedList a { font-size:13px; }
  .feedList p { margin:2px 0 5px 0; }
  .tablib_table { display:none; }
  </style>
  <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.
   */
    
  var happy_images = ['http://farm4.static.flickr.com/3090/2597112669_6213bda26b_s.jpg','http://farm1.static.flickr.com/188/404742934_77a34cb9bd_s.jpg','http://farm4.static.flickr.com/3185/2851721507_4f893cf083_s.jpg','http://farm4.static.flickr.com/3168/3012575580_cf3f37d110_s.jpg','http://farm1.static.flickr.com/107/304109861_85966e2aa0_s.jpg','http://farm4.static.flickr.com/3021/2759345502_37d4e665cb_s.jpg','http://farm4.static.flickr.com/3502/3210901199_af60121fd8_s.jpg','http://farm4.static.flickr.com/3351/3182600529_f76f52feb7_s.jpg','http://farm4.static.flickr.com/3181/3083584491_92429932ea_s.jpg','http://farm3.static.flickr.com/2073/2183538064_be93b1e838_s.jpg','http://farm3.static.flickr.com/2073/2183538064_be93b1e838_s.jpg','http://farm3.static.flickr.com/2357/2146844723_ef4f02227b_s.jpg','http://farm3.static.flickr.com/2254/2073627958_9d32c452f9_s.jpg','http://farm3.static.flickr.com/2453/3554269539_075daa8d7f_s.jpg','http://farm3.static.flickr.com/2194/1837033181_2765a36da0_s.jpg','http://farm2.static.flickr.com/1014/527881405_9f8065f9ed_s.jpg'];    
  var img_ln = happy_images.length;
  var happy_image = happy_images[Math.floor(Math.random()*img_ln)];
  function init() {
    var f1 = _trim(prefs.getString("feed1"));

    var ft1 = _trim(prefs.getString("feedTitle1"));

    if (f1 != "") {
      tabs.addDynamicTab(((ft1 == "") ? "Feed 1" : ft1), _IG_Callback(callbackTab, f1));
    }
  };

  /**
   * 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><a id="logo" target="_blank" href="http://thehappy365.com"></a></div>');
          html.push('<div><a style="font-size:11px;text-decoration:underline;float:right;" target="_blank" href="http://astore.amazon.com/thehappy365-20?_encoding=UTF8&node=1">Must read relationship books &raquo;</a>&nbsp;&nbsp;<br style="clear:both;" /></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('<img src="'+happy_image+'" style="float:right;margin-left:10px;" />');
            html.push('<a target="_blank" href="' + entry.Link + '">' + _hesc(entry.Title.replace(/.*: /g,"")) + ':</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>');
            }
    
          html.push('</li>');
          }
          html.push('</ul>');
          
          html.push('<div style="clear:both;padding-top:10px;"><a style="float:right;font-size:11px;color:#888;" target="_blank" href="http://thehappy365.com/blog/category/pursuit-of-happiness">MORE</a></div>');
          html.push('<a target="_blank" href="http://astore.amazon.com/thehappy365-20"><img style="border:none;" src="http://farm3.static.flickr.com/2690/4086856563_3004b37c6c_o.jpg" /></a>');        
          container.innerHTML = html.join("");
        }
      },
      entries,
      (summaries > -1)
    );
  }

  // Set onload event handler to call init()
  _IG_RegisterOnloadHandler(init);
  _IG_Analytics("UA-10704671-1", "/iGoogle_daily_happiness");
   
  gadgets.window.adjustHeight();
  </script>
]]>
</Content>
</Module>

