MediaWiki:Updates.js

window.UPD = {}; //the global object I'm going to use for this script. UPD.post = {}; //storing the post's data UPD.post.imgs = {}; //storing all image urls

//News post functions

UPD.getPost = function(url) { $.get(url, function(html) {		UPD.parsePost($(html).find('article.content'));	}); }

UPD.parsePost = function($post) { //meta info UPD.post.title = $post.find('.articleContent > h2').html; UPD.post.date = $post.find('.articleMeta time').html; UPD.post.category = $post.find('.articleMeta span a').html; //feature above the post UPD.post.hasFeature = $post.children('.feature').length; UPD.post.featureType = $post.find('.feature img').length ? 'image' : 'video'; UPD.post.feature = $post.find('.feature img, .feature iframe').attr('src'); //contents var $content = $post.find('.articleContentText'); $content.find('p').replaceWith(function { //paragraph		return '\n\n' + this.innerHTML;	}); $content.contents.filter(function { //remove HTML comments		return this.nodeType == 8;	}).remove; $content.find('b, strong').replaceWith(function { //bold text		return "" + this.innerHTML + "";	}); $content.find('i, em').replaceWith(function { //italic text		return "" + this.innerHTML + "";	}); $content.find('hr').replaceWith('\n\n'); //horizontal lines $content.find('ul li').replaceWith(function { //unordered list items		return '*' + this.innerHTML;	}); $content.find('ol li').replaceWith(function { //ordered list items		return '#' + this.innerHTML;	}); $content.find('ul, ol').replaceWith(function { //(un)ordered list elements, now that their list items have been parsed		return this.innerHTML;	}); $content.find('span').filter(function { //spans without attributes		return this.attributes.length === 0;	}).replaceWith('function {		return this.innerHTML;	}); //links $content.find('a[href*="://services.runescape.com/m=rswiki/en/"]').replaceWith(function { // JagexWiki		var wikiArticle = $(this).attr('href').replace(/^.*?\/m=rswiki\/en\//, ).replace(/_/g, ' ');		return ;	}); //TODO: the rest of the stuff on http://pastebin.com/phg7Nw9s }