Користувач:VictorAnyakin/rc.js

Матеріал з Вікіпедії — вільної енциклопедії.
Перейти до навігації Перейти до пошуку

Увага: Після публікування слід очистити кеш браузера, щоб побачити зміни.

  • Firefox / Safari: тримайте Shift, коли натискаєте Оновити, або натисніть Ctrl-F5 чи Ctrl-Shift-R (⌘-R на Apple Mac)
  • Google Chrome: натисніть Ctrl-Shift-R (⌘-Shift-R на Apple Mac)
  • Internet Explorer / Edge: тримайте Ctrl, коли натискаєте Оновити, або натисніть Ctrl-F5
  • Opera: натисніть Ctrl-F5
/* Yahoo YUI toolkit Connection Manager */
mw.loader.load('http://yui.yahooapis.com/combo?2.5.2/build/yahoo/yahoo-min.js&2.5.2/build/yahoo-dom-event/yahoo-dom-event.js&2.5.2/build/connection/connection-min.js');
// mw.loader.load('http://localhost/~victor/wiki/yui-combo.js');

// The RSS feed
//  var vaNewPagesURL = 'http://uk.wikipedia.org/w/index.php?title=%D0%A1%D0%BF%D0%B5%D1%86%D1%96%D0%B0%D0%BB%D1%8C%D0%BD%D0%B0:NewPages&feed=rss';

// Query the MediaWiki API
var vaNewPagesURL = 'http://uk.wikipedia.org/w/api.php?format=xml&action=query&list=recentchanges&rctype=new|edit&rcprop=title|timestamp|user|comment|ids&rcshow=!patrolled|!bot&rclimit=100';

var vaCredibleAuthors = ['Rar', 'Білецький В.С.', 'Oleksii0', 'Володимир Ф',
						 'VictorAnyakin', 'Gutsul', 'Alex K', 'Yakudza',
						 'Tigga', 'Yevhen', 'Texnik', 'Deineka', 'Verdi', 'Albedo',
						 'Yarko', 'Артем В. Коновалов',
						 'Wladik Derevianko', 'Ilyaroz', 'Kamelot', 'Amatorov', 'Yakiv Gluck', 'An-tu',
						 'Ahonc', 'Turzh', 'Movses', 'Darvin', 'AS', 'Andrijko Z.'];

window.vaLoadFeed = function () {

	var vaUpdateFeed = function(o) {
		var div = document.getElementById('feed-contents');
		var root = o.responseXML.documentElement;
		var oTitle = 'Останні редагування';

		var rhtml = "";
		var entries = root.getElementsByTagName('rc');
		rhtml += '<span>total: ' + entries.length + '</span>';
		rhtml += '<table>';

		for (var i = 0; i < entries.length; i++) {
			var ecreator = entries[i].getAttribute('user');

			if (vaCredibleAuthors.indexOf(ecreator) < 0) {
				var item = entries[i];
				var etitle = item.getAttribute('title');
				var elink = 'http://uk.wikipedia.org/wiki/' + etitle;
				var ecreatorlink = '<a href="http://uk.wikipedia.org/wiki/Спеціальна:Contributions/' + ecreator + '">' + ecreator + '</a>';

				rhtml += '<tr><td>' + ecreatorlink + '</td><td><a href="'+ elink + '">' + etitle + '</a></td>';
				var etype = item.getAttribute('type');
				if (etype == 'new') {
					rhtml += '<td>N</td>';
					rhtml += '<td></td>';
				} else {
					var enewid = item.getAttribute('revid');
					var eoldid = item.getAttribute('old_revid');
					rhtml += '<td>E</td>';
					rhtml += '<td><a href="' + elink + '?diff=' + enewid + '&oldid=' + eoldid + '">&Delta;</a></td>';
				}

				if (item.getAttribute('comment') == null) {
					rhtml += '<td></td>';
				} else {
					rhtml += '<td style="font-size: small">' + item.getAttribute('comment') + '</td>';
				}
				rhtml += '</tr>';
			}
		}
		rhtml += '</table>';

	    // Format and display results in the response container.
	    div.innerHTML = rhtml;

		if (setupTooltips != null) {
			setupTooltips(div, false, true);
		} else {
			alert('tooltips are not available');
		}
	};

	var div = document.getElementById('bodyContent');

	var rhtml = '';
	rhtml += '<span id="refresh-feed" class="yui-button yui-push-button"><span class="first-child"><button type="button">Refresh</button></span></span>';
	rhtml += '<div id="feed-contents"></div>'
	div.innerHTML = rhtml;
	YAHOO.util.Event.addListener("refresh-feed", "click",
								 function () {
									 YAHOO.util.Connect.asyncRequest('GET', vaNewPagesURL,
																	 { success: vaUpdateFeed,
																			 failure: function(o) { alert('Failed to load the feed'); },
																			 timeout: 10000 }) });
};

window.vaRecentChangesSetup = function () {

	var vaPrevPanel = YAHOO.util.Dom.get('p-lang');
	if (vaPrevPanel == null) {
		vaPrevPanel = YAHOO.util.Dom.get('p-tb');
	}
	if (vaPrevPanel != null) {
		vaPrevPanel.innerHTML +=
		'</div>'+
		'<div id=my class=portlet>'+
		'<h5>mine</h5>'+
		'<div class=pBody><ul>'+
		'<li><a href=\"/wiki/Special:MyPage/monobook.js\">My monobook.js</a>'+
		'<li><a href=\"/wiki/Special:MyPage/monobook.css\">My monobook.css</a>'+
		'<li><a href="javascript:vaLoadFeed()">Load feed</a></li>' +
		'</ul></div></div>';
	}
};

window.addEventListener('load', vaRecentChangesSetup, false);