User:Joeytje50/JWB/feed.js

/** This script generates a list of most recent edits for each of the relevant pages for JWB. * This is used to check most recent changes, and whether the git repo needs updating. * The git repo is located at https://github.com/Joeytje50/JWB. * If you want to use this script as well (idk why but okay), you can install it using:

User:Joeytje50/JWB.js/load.js

* This script is not a subpage of JWB.js because it doesn't affect the actual JWB script itself. * */ if (mw.config.get('wgPageName') === 'User:Joeytje50/JWB') { window.JWB = { imports: {i18n: {}}, messages: {}, };	$(function {		var feed = $('#JWB-feed');		function getJWBFeed {			feed.closest('table').show;			feed.html(' ');			var table = feed.find('table.wikitable')							.append(' Github repo ');			var api = new mw.Api;			api.get({ action: 'query', prop: 'revisions', format: 'json', titles: ['User:Joeytje50/JWB', 'User:Joeytje50/JWB/Changelog', 'User:Joeytje50/JWB.js', 'User:Joeytje50/JWB.css', 'User:Joeytje50/JWB.js/load.js', 'User:Joeytje50/JWB.js/i18n.js', 'User:Joeytje50/JWB.js/worker.js', 'User:Joeytje50/RETF.js', 'User:Joeytje50/RETF'], rvprop: ['timestamp', 'user', 'parsedcomment', 'ids'] }).done(function(data) { var pages = data.query.pages; for (var id in pages) { var rev = pages[id].revisions[0]; var row = $(' ').appendTo(table); row.append(' '+pages[id].title+' ') .append(' '+rev.user+' ') .append(' '+(new Date(rev.timestamp)).toLocaleDateString("en-US", { year: 'numeric', month: 'long', day: 'numeric' })+' ') .append(' '+rev.parsedcomment+' '); }			});		}		getJWBFeed;		table.find('caption').attr('title', 'Refresh').click(getJWBFeed);	}); $.getScript('//en.wikipedia.org/w/index.php?title=User:Joeytje50/JWB.js/i18n.js&action=raw&ctype=text/javascript', function {		var langs = [];		var codes = [];		for (let lang in JWB.imports.i18n) {			langs.push(JWB.imports.i18n[lang]);			codes.push(lang);		}		$.when.apply($, langs.map(url => $.getScript(url))).done(function { // loaded all i18n files. Check which messages are missing. var feed = $('#JWB-feed'); var langtbl = $(' '); var missing = {}; for (var c of codes) { missing[c] = []; for (var msg in JWB.messages.en) { if (JWB.messages[c][msg] === undefined) { missing[c].push(msg); }				}				if (missing[c].length === 0) continue; langtbl.append('  ' + missing[c].reduce((acc, cur) => { if (acc.length) { // don't open a new if this is the first missing message. acc += ' '; }					return acc + '  ' + JWB.messages.en[cur] + '  '; }, )); // initialValue =  to start off with an empty string. }			feed.append(langtbl); });	}); }