<?xml version="1.0" encoding="UTF-8" ?>
<Module>
	<ModulePrefs 
		title="WikiRage" 
		title_url="http://www.wikirage.com"
		directory_title="WikiRage - Wikipedia Activity Monitor"
		description="Monitor the pages receiving the most edits on wikipedia by using the RSS feed from WikiRage.com. This will often give you a view into what is happening in news and pop culture faster and more accurately than news feeds!" 
		author="Matt Kruse" 
		author_email="gadget@mattkruse.com" 
		screenshot="http://www.javascripttoolbox.com/gadget/wikirage/wikirage.png" 
		thumbnail="http://www.javascripttoolbox.com/gadget/wikirage/wikirage_thumb.png"
		author_affiliation="Matt Kruse" 
		author_location="IL, USA" 
		author_link="http://www.JavascriptToolbox.com/" 
		/> 
		<UserPref name="url" display_name="Time Period:" required="true" default_value="http://www.wikirage.com/rss/24/QualityEdits/" datatype="enum">
			<EnumValue value="http://www.wikirage.com/rss/24/QualityEdits/" display_value="Last 24 Hours"/>
			<EnumValue value="http://www.wikirage.com/rss/1/QualityEdits/" display_value="Last 1 Hour"/>
			<EnumValue value="http://www.wikirage.com/rss/6/QualityEdits/" display_value="Last 6 Hours"/>
			<EnumValue value="http://www.wikirage.com/rss/72/QualityEdits/" display_value="Last 3 Days"/>
			<EnumValue value="http://www.wikirage.com/rss/168/QualityEdits/" display_value="Last Week"/>
			<EnumValue value="http://www.wikirage.com/rss/672/QualityEdits/" display_value="Last Month"/>
		</UserPref>
		<UserPref name="num" display_name="Items to show (1-25):" default_value="10"/>
		<UserPref name="link" display_name="Link To:" datatype="enum" default_value="wikipedia">
			<EnumValue value="wikipedia" display_value="Wikipedia Article"/>
			<EnumValue value="wikirage" display_value="WikiRage Summary Page"/>
		</UserPref>
		<UserPref name="format" display_name="Item Format:" default_value="&lt;div class=mc title=&quot;click for details&quot;&gt;&lt;div class=&quot;%A_CLASSNAME%&quot; onclick=&quot;_toggle(this.nextSibling)&quot; style=&quot;cursor:pointer&quot;&gt;&amp;#187;&amp;nbsp;%TITLE%&lt;/div&gt;&lt;div style=&quot;display:none;overflow:auto;font-style:italic;margin-left:20px;white-space:normal;&quot;&gt;%SUMMARY%&lt;br&gt;&lt;b&gt;&lt;a href=&quot;%URL%&quot; target=&quot;%TARGET%&quot;&gt;view article...&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;" />
		<UserPref name="newwindow" display_name="Open Links In A New Window:" datatype="bool" default_value="true" />
		<UserPref name="altbgcolor" display_name="Alt Row Bg Color:" default_value="#f6f6f6" />
		<UserPref name="refresh" display_name="Refresh Interval (minutes):" default_value="5" />
		<Content type="html-inline"> 
		<![CDATA[ 
<script type="text/javascript">
function WikiRageFeed(mId) {
	var me = this;
	var p = this.prefs = new _IG_Prefs(mId);
	this.url = p.getString('url');
	this.interval = null;
	this.num = p.getInt('num');
	this.TPL_entry = p.getString('format');
	this.itemList={};
	this.loaded=false;
	this.link = p.getString('link');
	this.msg = function(txt) {
		_gel("FEED"+mId+"statusmsg").innerHTML = txt;
		_gel("FEED"+mId+"status").style.display = "block";
		_gel("FEED"+mId+"display").style.display = "none";
	};
	this.startRefresh = function() {
		this.interval = setInterval(function(){me.refresh()}, (60000 * p.getInt('refresh')));
	};
	this.clearRefresh = function() { clearInterval(this.interval); };
	this.init = function() { 
		this.startRefresh();
		this.load();
	};
	this.load = function() {
		var url = this.url;
		url += (url.indexOf("?")>-1)?"&":"?";
		url += "random="+new Date().getTime();
		_IG_FetchFeedAsJSON(url,function(){me.render.apply(me,arguments)},this.num,true);
	};
	this.refresh = function() {
		_gel("m_"+mId+"_h").style.backgroundColor = _gel("FEED"+mId+"msg").style.backgroundColor = "#ffffaa";
		this.load();
	};
	this.addEntry = function(index, url, title, summary, date, alternate) {
		var tpl = this.TPL_entry;
		// Correct the URL if necessary
		if (this.link=='wikipedia') {
			url = url.replace(/wikirage.com/i,"wikipedia.org").replace(/\/\s*$/,"");
		}
		tpl = tpl.replace(/\%INDEX\%/g, index).replace(/\%ID\%/g, mId).replace(/\%URL\%/g, _hesc(url));
		var title = _hesc(title);
		var classname = "rsslink"+mId;
		if (alternate) {
			classname += " alternate"+mId;
		}
		tpl = tpl.replace(/\%A_CLASSNAME\%/g, classname);
		tpl = tpl.replace(/\%TITLE\%/g, title);
		tpl = tpl.replace(/\%TARGET\%/g, (p.getBool('newwindow')?"_blank":"") );
		summary = summary.replace(/\<br\>/gi,"\n").replace(/\<[^\>]*\>/gi,"");
		if (summary=="") {
			summary = "(No Summary Provided)";
		};
		tpl = tpl.replace(/\%SUMMARY\%/g, _hesc(summary));
		_gel("FEED"+mId+"entries").innerHTML += tpl;
		return tpl;
	};
	this.render = function(obj) {
		_gel("m_"+mId+"_h").style.backgroundColor = "";
		_gel("FEED"+mId+"msg").style.backgroundColor = "";
		if (!this.loaded && !obj) {this.retry("Information is temporarily unavailable.");return;}
		if (!this.loaded && obj.ErrorMsg && obj.ErrorMsg != "") {this.retry(obj.ErrorMsg);return;}
		if (!this.loaded && (!obj.Entry || obj.Entry.length == 0)) {
			this.retry("Information is temporarily unavailable.");return;
		}
		_gel("FEED"+mId+"status").style.display = "none";
		if (obj.Entry) {
			_gel("FEED"+mId+"entries").innerHTML = "";
			var count = 0;
			for (var i = 0; i < obj.Entry.length; i++) {
				if (count==0) {
					_gel("FEED"+mId+"display").style.display = "block";
				}
				this.addEntry(i,obj.Entry[i].Link,obj.Entry[i].Title,obj.Entry[i].Summary,obj.Entry[i].Date,!!(count++%2==1));
			}
		}
		this.loaded = true;
	};
	this.retry = function(msg) {
		if (msg) {
			this.msg(msg);
		}
		this.clearRefresh();
		setTimeout(function(){me.refresh()},5*1000);
	};
	_IG_RegisterOnloadHandler(function(){me.init()});
}
var rss__MODULE_ID__ = new WikiRageFeed("__MODULE_ID__");
</script>
<style>
#m___MODULE_ID___title {
	padding-left:20px;
	background:transparent url(http://images.wikirage.com/favicon.ico) top left no-repeat;
}
#m___MODULE_ID__ div.mc, #m___MODULE_ID__ div.mc * {
	padding:0px;
	color:#333;
}
.rsslink__MODULE_ID__ { 
	display:block;
	text-decoration:none;
	color:black;
}
.alternate__MODULE_ID__ {
	background-color: __UP_altbgcolor__; 
}
A.rsslink__MODULE_ID__:hover, .group_subject___MODULE_ID__:hover { 
	background-color:__UP_hovercolor__; 
}
#m___MODULE_ID__ div.mc, #m___MODULE_ID__ div.mc * {
	white-space:nowrap;overflow:hidden;text-overflow:eillipsis;
}
</style>
<div id="FEED__MODULE_ID__status">
<div id="FEED__MODULE_ID__msg"><table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%"><tr><td>
	<center><i><font size="-1" color="#666666"><div id="FEED__MODULE_ID__statusmsg">Loading...</div></font></i></center>
</td></tr></table>
</div>
</div>
<div id="FEED__MODULE_ID__display" style="display:none;">
	<div id="FEED__MODULE_ID__entries"></div>
</div>
     ]]> 
   </Content> 
</Module>
