Utente:Mcbiofa/vector.js

Da Wikipedia, l'enciclopedia libera.
Vai alla navigazione Vai alla ricerca

Questa pagina definisce alcuni parametri di aspetto e comportamento generale di tutte le pagine. Per personalizzarli vedi Aiuto:Stile utente.


Nota: dopo aver salvato è necessario pulire la cache del proprio browser per vedere i cambiamenti (per le pagine globali è comunque necessario attendere qualche minuto). Per Mozilla / Firefox / Safari: fare clic su Ricarica tenendo premuto il tasto delle maiuscole, oppure premere Ctrl-F5 o Ctrl-R (Command-R su Mac); per Chrome: premere Ctrl-Shift-R (Command-Shift-R su un Mac); per Konqueror: premere il pulsante Ricarica o il tasto F5; per Opera può essere necessario svuotare completamente la cache dal menù Strumenti → Preferenze; per Internet Explorer: mantenere premuto il tasto Ctrl mentre si preme il pulsante Aggiorna o premere Ctrl-F5.

//How many second do I wait before checking if revision 
//I'm reading is the latest one again?
/*
var timeOut = 5;

function notify(data, lastrevid) {
   "use strict";
	var differences_page = window.location.toString().replace("/wiki/" + mw.config.get( 'wgTitle' ),"") +
							"/w/index.php?title=" + mw.config.get( 'wgTitle' ) +
							"&action=historysubmit&diff=" + lastrevid + "&oldid=" + mw.config.get( 'wgCurRevisionId' );
	$.ajax({
			type: "POST",
			url: differences_page,
			success: function(dat) {
				var d = new Date(data.timestamp);
				$.gritter.add({
					title: ' ',
					text: 'On ' + d.toUTCString() + ', user ' + data.user + ' changed this page while you were reading it. Click here for details.',
					sticky: true,
					after_close: function(e, manual_close){
						var foo = function() { queryRevision(lastrevid); };
						window.setTimeout(foo, timeOut * 1000);
					}
				});
				//here i put in the balloon just the tiled differences table from page got by ajax call
				var differences  = $(dat).find(".diff").clone();
				$(differences.children('tbody').children('tr').get(0)).remove();
				$(differences.children('tbody').children('tr').get(0)).remove();
				//http://jquery-howto.blogspot.com/2009/02/how-to-get-full-html-string-including.html
				differences = $('<div>').append(differences.clone()).remove().html();
				$('.gritter-item-wrapper').balloon({ 
					position: "bottom", 
					contents: differences,
					offsetX: 0,
					offsetY: -20,
					css: {
						opacity: '1.0'
						}
					});
			}
		});
}

function queryRevision(curRevId) {
    "use strict";
	//this function looks if current revision is the latest one...
	$.getJSON( 
		window.location.toString().replace("/wiki/" + mw.config.get( 'wgTitle' ),"") + 
		"/w/api.php?action=query&prop=info&titles=" + mw.config.get( 'wgTitle' ) + 
		"&format=json&callback=?",
		function (data) {
			$.each(data.query.pages, function () {
				var lastrevid = this.lastrevid;
				if (curRevId === lastrevid) {
					//...if so, this function will be called after <the value of timeout> seconds...
					var foo = function() { queryRevision(curRevId); };
					window.setTimeout(foo, timeOut * 1000);
				}
				else {
					//...else some infos about latest rev are found: user, timestamp and comment
					$.getJSON( 
						window.location.toString().replace("/wiki/" + mw.config.get( 'wgTitle' ),"") + 
						"/w/api.php?action=query&prop=revisions&revid=" + this.lastrevid + "&rvprop=timestamp|user&titles=" + mw.config.get( 'wgTitle' ) + 
						"&format=json&callback=?",
						function (data) {
							$.each(data.query.pages, function () {
								$.each(this.revisions, function () {
									notify(this, lastrevid);
								});
							});
						});
				}
			});
		});	
}

$(document).ready(function () {
    "use strict";
	//just "normal" pages examined
	if (/\?/i.test(window.location.toString())) {
		return;			
		}
	//http://boedesign.com/blog/2009/07/11/growl-for-jquery-gritter/
	$("head").append($("<link>").attr({
		type: 'text/css',
		rel: 'stylesheet',
		href: 'http://boedesign.com/demos/gritter/css/jquery.gritter.css'
	}));
	$.getScript("http://boedesign.com/demos/gritter/js/jquery.gritter.min.js", function () {
		//http://file.urin.take-uma.net/jquery.balloon.js-Demo.html
		$.getScript("http://file.urin.take-uma.net/jquery.balloon.min.js", function () {
			queryRevision(mw.config.get( 'wgCurRevisionId' ));
		});
	});
});
*/