MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */

var pageContent = mw.hook('wikipage.content');

function map($class, $function) {	pageContent.add(function($content) {	   var $items = $content.find($class);	    if (!$items.length) return;	    $items.each(function { var $this = $(this); $function($this); });	}); }

map('.att-news', function($div) {	var blogApi = "https://strapi.townshiptale.dev/graphql?query={posts(limit:7,sort:%22date:desc%22,where:{status:%22published%22}){title,date,slug}}&format=txt&format=txt&origin=*";

$div = $div.children(":first"); fetch(blogApi) .then(function(response) {return response.json;}) .then(function(response) {	   	var posts = response.data.posts;	    	$div.children('.rss_item').remove;	    	posts.forEach(function($post) {	   		var itemHtml = ' ' + $post.title + ' ' + $post.date + '  ';	    		$div.append(itemHtml); });	    }); });