Personal tools
You are here: Home Admin gadgets gadget.xml
"; return out; } function buildTabTable() { var currCellCount = 0; var out = "
 
Document Actions

gadget.xml

by admin last modified 2008-04-09 09:38
var gCampaignPrefs = {"headerImg": "http://www.socialedge.org/admin/images/logos/socialedgegooglegadget.png", "campaignName": "Where Social Entrepreneurs Rise", "defaultTab": "YT", "includeYTPlaylist": true, "YTPlaylist": "http://youtube.com/view_play_list?p=5E8E333FBC9A3116", "includeRSSFeed": true, "RSSFeed": "http://www.socialedge.org/blogs/global-x/rss.xml", "includeGNewsFeed": false, "GNewsFeed": "http://", "includeGetInvolvedTab": true, "ctaMailingList": "http://www.socialedge.org/about-us/site-information/weekly-newsletter", "ctaDonation": "http://", "gadgetBaseUrl": "http://www.socialedge.org/admin/gadgets/"} var kUserPrefs = false; var kTabs = {'RSS':0, 'YT':1, 'GNews':2, 'CallAction':3}; var gadgetTabs = []; var kCurrTab = -1; var kRssNmbItems = 10; var rssOutCache = ""; var gnewsOutCache = ""; var ytAllVideos = []; var ytCurrVideo = -1; var kImg = {ArrowLeft:"/gadget-img/left-arrow.png", ArrowRight:"/gadget-img/right-arrow.png", TabReadBlog:"/gadget-img/tab-read-blog.jpg", TabWatch:"/gadget-img/tab-watch.jpg", TabNews:"/gadget-img/tab-news.jpg", TabGetInvolved:"/gadget-img/tab-get-involved.jpg"}; var kDefaultBaseUrl = "http://www.google.com/webmasters/gadgets/promo"; function gadgetInit() { var url = getCampaignPref('gadgetBaseUrl').replace(/\/$/, ''); if(!getCampaignPref('gadgetBaseUrl') || getCampaignPref('gadgetBaseUrl') == "") url = kDefaultBaseUrl; for(var i in kImg) kImg[i] = _IG_GetImageUrl(url + kImg[i]); placeHeaderFooter(); buildTabTable(); var prefs = new _IG_Prefs(); var lastTab = parseInt(prefs.getString("lastTab")); if(lastTab < 0 || lastTab >= gadgetTabs.length) lastTab = 0; setTimeout("activateTab("+ lastTab +")", 100); } function showGNewsTab() { if(!getCampaignPref('includeGNewsFeed') || !getCampaignPref('GNewsFeed')) return; showLoadingIndicator(); if(typeof gnewsOutCache != "undefined" && gnewsOutCache != "") { _gel('contentDiv').innerHTML = gnewsOutCache; } else { var url = ''; if(getCampaignPref('GNewsFeed').match(/^https?:\/\//)) url = getCampaignPref('GNewsFeed'); else url = "http://news.google.com/news?hl=en&ned=us&ie=UTF-8&scoring=n&output=atom&q="+ encodeURIComponent(getCampaignPref('GNewsFeed')); _IG_FetchFeedAsJSON(url, function(response) { var out = ""; if((out = rssContentHandler(response)) === false) return; gnewsOutCache = out; _gel('contentDiv').innerHTML = out; }, kRssNmbItems, true); } } function showRSSTab() { if(!getCampaignPref('includeRSSFeed') || !getCampaignPref('RSSFeed')) return; showLoadingIndicator(); if(typeof rssOutCache != "undefined" && rssOutCache != "") { _gel('contentDiv').innerHTML = rssOutCache; } else { _IG_FetchFeedAsJSON(getCampaignPref('RSSFeed'), function (response) { var out = ""; if((out = rssContentHandler(response)) === false) return; rssOutCache = out; _gel('contentDiv').innerHTML = out; }, kRssNmbItems, true); } } function rssContentHandler(response) { var out = ""; try { if(response == null || typeof response != "object" || typeof response.Entry == "undefined" || response.Entry.length == "undefined" || response.Entry.length == 0) return false; var newsItems = response.Entry; var out = ""; for(var i = 0; i < newsItems.length; i++) { var link = newsItems[i].Link; var title = newsItems[i].Title; var description = newsItems[i].Summary.replace(/<[^>]+>/g, ' ').replace(/[ ]+/g, ' '); if(description.length > 200) description = description.split(' ').slice(0,32).join(' ') + '...'; out += "
"; out += ""+ title +""; out += "
" + description + "
"; } } catch(E) { } return out; } function prevVideo() { loadVideo((ytCurrVideo - 1 < 0)? ytAllVideos.length - 1 : ytCurrVideo - 1); } function nextVideo() { loadVideo((ytCurrVideo + 1 == ytAllVideos.length)? 0 : ytCurrVideo + 1) } function loadVideo(videoIdx) { if(typeof ytAllVideos == "undefined" || typeof ytAllVideos.length == "undefined" || ytAllVideos.length == 0) return; if(typeof videoIdx == "undefined" || videoIdx < 0 || videoIdx >= ytAllVideos.length) videoIdx = 0; if(!_gel('watchDiv')) return; ytCurrVideo = videoIdx; var vWidth = 260; var vHeight = 150; _IG_EmbedFlash('http://www.youtube.com/v/' + ytAllVideos[videoIdx], 'watchDiv', { swf_version: 6, id: "flashmovie", width: vWidth, height: vHeight, flashvars: 'autoplay=true' }); var out = "
"; out += "
"; out += ""; out += ""; out += (1 + videoIdx) + " OF " + ytAllVideos.length; out += ""; out += ""; out += "
"; _gel('videoArrowsDiv').innerHTML = out; fixPNG(_gel('arrowLeftImg')); fixPNG(_gel('arrowRightImg')); } function showYTTab() { if(!getCampaignPref('includeYTPlaylist') || !getCampaignPref('YTPlaylist')) return; showLoadingIndicator(); if(typeof ytAllVideos == "undefined" || typeof ytAllVideos.length == "undefined" || ytAllVideos.length == 0) { loadYTPlaylist(); } else { if(typeof ytCurrVideo == "undefined" || ytCurrVideo < 0 || ytCurrVideo >= ytAllVideos.length) ytCurrVideo = 0; var out = '
'; _gel('contentDiv').innerHTML = out; setTimeout(function(){ loadVideo(ytCurrVideo); }, 100); } } function loadYTPlaylist() { var playlistIdMatchRe = /p=([^\&]+)/ var playlistIdMatch = playlistIdMatchRe.exec(getCampaignPref('YTPlaylist')); if(typeof playlistIdMatch == "undefined" || !playlistIdMatch || playlistIdMatch.length <= 1) return; var playlistId = playlistIdMatch[1]; _IG_FetchXmlContent("http://www.youtube.com/api2_rest?method=youtube%2Evideos%2Elist%5Fby%5Fplaylist&id=" + playlistId, function (response) { try { if(response == null || typeof response != "object" || response.firstChild == null) return; var videoIds = response.getElementsByTagName("id"); for(var i = 0; i < videoIds.length; i++) ytAllVideos.push(videoIds[i].firstChild.nodeValue); showYTTab(); } catch(E) { } }); } function showCallActionTab() { var out = "
"; if(getCampaignPref('ctaMailingList')) out += ""; if(getCampaignPref('ctaDonation')) { out += "
Make a donation
"; out += "
Click here to make a donation in support of "; if(getCampaignPref('campaignName')) out += "the "+ getCampaignPref('campaignName') +""; else out += "this"; out += " campaign
"; out += "
"; } out += "
"; _gel('contentDiv').innerHTML = out; } function activateTab(tabIdx) { if(typeof gadgetTabs == "undefined" || typeof gadgetTabs.length == "undefined" || gadgetTabs.length < tabIdx) return; if(kCurrTab == tabIdx) return; kCurrTab = tabIdx; var prefs = new _IG_Prefs(); prefs.set("lastTab", String(tabIdx)); for(var i = 0; i < gadgetTabs.length; i++) { if(i == tabIdx) _gel('tab'+ i +'Cell').style.borderBottom = '0px'; else _gel('tab'+ i +'Cell').style.borderBottom = '1px solid #ccc'; } switch(gadgetTabs[tabIdx]) { case kTabs.RSS: showRSSTab(); break; case kTabs.YT: showYTTab(); break; case kTabs.GNews: showGNewsTab(); break; case kTabs.CallAction: showCallActionTab(); break; } } function showLoadingIndicator() { _gel('contentDiv').innerHTML = "
Loading...
"; } function makeTableCell(img, width, idx) { var out = ""; out += "
"; out += ""; out += ""; out += "
"; out += ""; var tabDefs = [{ campaignPref:'includeYTPlaylist', tabImg:kImg.TabWatch, tabImgWidth:65, tabType:kTabs.YT },{ campaignPref:'includeRSSFeed', tabImg:kImg.TabReadBlog, tabImgWidth:66, tabType:kTabs.RSS },{ campaignPref:'includeGNewsFeed', tabImg:kImg.TabNews, tabImgWidth:68, tabType:kTabs.GNews },{ campaignPref:'includeGetInvolvedTab', tabImg:kImg.TabGetInvolved, tabImgWidth:76, tabType:kTabs.CallAction }]; if(getCampaignPref('defaultTab') != '') { for(var i = 0; i < tabDefs.length; i++) { if(tabDefs[i].tabType == kTabs[getCampaignPref('defaultTab')]) { var el = tabDefs.splice(i, 1); if(typeof el.length != "undefined") el = el[0]; tabDefs.unshift(el); break; } } } for(var i = 0; i < tabDefs.length; i++) { var currTab = tabDefs[i]; if(getCampaignPref(currTab.campaignPref) == true) { out += makeTableCell(currTab.tabImg, currTab.tabImgWidth, currCellCount++); gadgetTabs.push(currTab.tabType); } } if(gadgetTabs.length == 0) out += ""; out += ""; out += "
 
Tabs
 
"; _gel('tabsTableDiv').innerHTML = out; } function placeHeaderFooter() { if(getCampaignPref('headerImg') && getCampaignPref('headerImg') != "http://") { _gel('headerImgDiv').innerHTML = ""; fixPNG(_gel('headerImg')); } else _gel('headerImgDiv').innerHTML = "
Header image
"; _gel('tabsTableDiv').style.top = "63px"; _gel('contentDiv').style.top = "83px"; _gel('contentDiv').style.height = "192px"; if(getCampaignPref('campaignName')) _gel('campaignNameDiv').innerHTML = "
"+ getCampaignPref('campaignName') +"
"; else _gel('campaignNameDiv').innerHTML = "
Footer Text
"; _gel('contentDiv').style.height = parseInt(_gel('contentDiv').style.height) - 13 + "px"; } function getCampaignPref(key) { if(kUserPrefs) { var prefs = new _IG_Prefs(); return prefs.getString(key); } else { if(typeof gCampaignPrefs != "undefined" && typeof gCampaignPrefs[key] != "undefined" && gCampaignPrefs[key] != "") return gCampaignPrefs[key]; return false; } } function fixPNG(img) { if (!(/MSIE (5\.5|6).+Win/.test(navigator.userAgent))) return; var arVersion = navigator.appVersion.split("MSIE") var version = parseFloat(arVersion[1]) if ((version >= 5.5) && (document.body.filters)) { var imgName = img.src.toUpperCase() if (imgName.substring(imgName.length-3, imgName.length) == "PNG") { var imgID = (img.id) ? "id='" + img.id + "' " : "" var imgClass = (img.className) ? "class='" + img.className + "' " : "" var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " var imgStyle = "display:inline-block;" + img.style.cssText if (img.align == "left") imgStyle = "float:left;" + imgStyle if (img.align == "right") imgStyle = "float:right;" + imgStyle if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle var strNewHTML = "" img.outerHTML = strNewHTML } } } _IG_RegisterOnloadHandler(gadgetInit);
]]>
Newsletter
Social entrepreneur news. No spam.

Manage Subscription
Top Discussions
Things To Do
Bookmarklets

Bookmark and share.

del.icio.us Digg Yahoo Google Reddit