Cimitero:MediaWiki:Common.js/Importanti.js: differenze tra le versioni

Vai alla navigazione Vai alla ricerca
Contenuto aggiunto Contenuto cancellato
m (Applying changes that should make this JS file partially HTTPS-ready. If you have any questions or noticed issues related to this edit, please reach out to us using the Special:Contact page.)
(fix s)
Riga 40: Riga 40:
var innerLink = $('#unwatch-star');
var innerLink = $('#unwatch-star');
}
}
var keyCommand = watchLink.attr('title').match(/\[.*?\]$/) ? watchLink.attr('title').match(/\[.*?\]$/)[0] : '';
var keyCommand = (watchLink.attr('title') || '').match(/\[.*?\]$/) ? watchLink.attr('title').match(/\[.*?\]$/)[0] : '';
watchLink.attr('title', (newText == ajaxWatch.watchMsg ? ajaxWatch.tooltipWatchMsg : ajaxWatch.tooltipUnwatchMsg) + ' ' + keyCommand);
watchLink.attr('title', (newText == ajaxWatch.watchMsg ? ajaxWatch.tooltipWatchMsg : ajaxWatch.tooltipUnwatchMsg) + ' ' + keyCommand);
}
}

Versione delle 18:49, 8 giu 2018

/* Any JavaScript here will be loaded for all users on every page load. */
/***************                  Skin                  ***************/
// Ajax Watch - Permette di aggiungere e togliere una pagina dai preferiti senza passare per la pagina di conferma
var ajaxWatch = new Object();
function startAjaxWatch() {
	ajaxWatch = {
		watchMsg: 'Taco',
		unwatchMsg: 'Detaco',
		watchingMsg: 'Tacoing...',
		unwatchMsg: 'Detacoing...',
		tooltipWatchMsg: 'Aggiungi questa pagina alla tua lista degli Osservati Speciali',
		tooltipUnwatchMsg: 'Elimina questa pagina dalla tua lista degli Osservati Speciali',
		supported: true,
		watching: false,
		inprogress: false,
		timeoutID: null,
		watchLinks: [],
		imgBasePath: ''
	};

	ajaxWatch.setLinkText = function(newText) {
		for(var i = 0; i < ajaxWatch.watchLinks.length; i++) {
			var watchLink = $(ajaxWatch.watchLinks[i]);
			watchLink.text('');
			if(newText == ajaxWatch.watchMsg || newText == ajaxWatch.unwatchMsg) {
				if(!$('#watch-star').length && !$('#unwatch-star').length) {
					var innerLink = $('<img />').attr({
						'src': 'https://images.wikia.nocookie.net/__cb20060516011831/uncyclopedia/images/5/52/Spacer.gif',
						'id': 'watch-star'
					}).css({
						'width': '17px',
						'height': '17px'
					});
					watchLink.append(innerLink);
				}
				else if($('#watch-star').length) {
					var innerLink = $('#watch-star');
				}
				else {
					var innerLink = $('#unwatch-star');
				}
				var keyCommand = (watchLink.attr('title') || '').match(/\[.*?\]$/) ? watchLink.attr('title').match(/\[.*?\]$/)[0] : '';
				watchLink.attr('title', (newText == ajaxWatch.watchMsg ? ajaxWatch.tooltipWatchMsg : ajaxWatch.tooltipUnwatchMsg) + ' ' + keyCommand);
			}
		}
	};

	ajaxWatch.setLinkID = function(newID) {
		$(ajaxWatch.watchLinks[0]).parent().attr('id', newID);
	};

	ajaxWatch.setHref = function(string) {
		for(var i = 0; i < ajaxWatch.watchLinks.length; i++) {
			var watchLink = $(ajaxWatch.watchLinks[i]);
			if(string == 'watch') {
				watchLink.attr('href', watchLink.attr('href').replace(/&action=unwatch/, '&action=watch'));
			}
			else if(string == 'unwatch') {
				watchLink.attr('href', watchLink.attr('href').replace(/&action=watch/, '&action=unwatch'));
			}
		}
	};

	ajaxWatch.ajaxCall = function(event) {
		event.preventDefault();
		if(!ajaxWatch.supported) {
			return true;
		}
		else if(ajaxWatch.inprogress) {
			return false;
		}
		if(!wfSupportsAjax()) {
			ajaxWatch.supported = false;
			return true;
		}
		ajaxWatch.inprogress = true;
		ajaxWatch.setLinkText(ajaxWatch.watching ? ajaxWatch.unwatchingMsg : ajaxWatch.watchingMsg);
		var old_sajax_request_type = sajax_request_type;
		sajax_request_type = 'POST';
		sajax_do_call('wfAjaxWatch', [wgPageName, ajaxWatch.watching ? 'u' : 'w'], ajaxWatch.processResult);
		sajax_request_type = old_sajax_request_type;
		ajaxWatch.timeoutID = setTimeout(function() {ajaxWatch.inprogress = false;}, 10000);
		return false;
	};

	ajaxWatch.processResult = function(request) {
		if(!ajaxWatch.supported) {
			return;
		}
		var response = request.responseText;
		if(response.match(/^<w#>/)) {
			ajaxWatch.watching = true;
			ajaxWatch.setLinkText(ajaxWatch.unwatchMsg);
			ajaxWatch.setLinkID('ca.unwatch');
			ajaxWatch.setHref('unwatch');
		}
		else if(response.match(/^<u#>/)) {
			ajaxWatch.watching = false;
			ajaxWatch.setLinkText(ajaxWatch.watchMsg);
			ajaxWatch.setLinkID('ca-watch');
			ajaxWatch.setHref('watch');
		}
		else {
			window.location.href = $(ajaxWatch.watchLinks[0]).attr('href');
			return;
		}
		if(typeof wgEnableWikiaFollowdPages === 'undefined' || !wgEnableWikiaFollowedPages) {
			jsMsg(response.substr(4), 'watch');
		}
		ajaxWatch.inprogress = false;
		if(ajaxWatch.timeoutID) {
			clearTimeout(ajaxWatch.timeoutID);
		}
		var watchThis = $('#wpWatchthis');
		if(watchThis.length && response.match(/^<[uw]#>/)) {
			watchThis.attr('checked', (response.match(/^<w#>/) ? 'checked' : ''));
		}
	};

	ajaxWatch.onLoad = function() {
		var el1 = $('#ca-unwatch');
		var el2 = null;
		if(!el1.length) {
			el1 = $('#mw-unwatch-link1');
			el2 = $('#mw-unwatch-link2');
		}
		if(el1.length) {
			ajaxWatch.watching = true;
		}
		else {
			ajaxWatch.watching = false;
			el1 = $('#ca-watch');
			if(!el1.length) {
				el1 = $('#mw-watch-link1');
				el2 = $('#mw-watch-link2');
			}
			if(!el1.length) {
				ajaxWatch.supported = false;
				return;
			}
		}
		ajaxWatch.watchLinks.push(el1.prop('tagName').toLowerCase() == 'a' ? el1 : $(':first-child', el1));
		if(el2 && el2.length) {
			ajaxWatch.watchLinks.push(el2);
		}
		for(var i = 0; i < ajaxWatch.watchLinks.length; i++) {
			$(ajaxWatch.watchLinks[i]).click(ajaxWatch.ajaxCall);
			if(ajaxWatch.watching) {
				ajaxWatch.setLinkText(ajaxWatch.unwatchMsg);
			}
			else {
				ajaxWatch.setLinkText(ajaxWatch.watchMsg);
			}
		}
		return;
	};
	ajaxWatch.onLoad();
	return;
}

// Nascondi toolbar con i cookie
// Autore: Genuzzo
function toolbarCookieHide() {
	var cookie = getCookie('tlb');
    if(cookie == 'yes') {
		$('#HidebarToggleInitialState').html('0');
	}
    $('#HidebarToggleLink').click(function() {
        var today = new Date();
        var expire = new Date();
        expire.setTime(today.getTime() + 3600000 * 24 * 356);
        document.cookie = 'tlb=' + (cookie == 'yes' ? 'no' : 'yes') + ';expires=' + expire.toGMTString();
    });
    return;
}

// Funzione per inserire le stellette vicino agli interwiki
function linkAdQ() {
	s = $('#p-lang li').each(function() {
		var t = $(this);
		if($('#' + t.attr('class') + '-fa').length) {
			t.addClass('FA');
			t.attr('title', 'La voce è in vetrina in questa lingua.');
		}
		else if($('#' + t.attr('class') + '-ga').length) {
			t.addClass('GA');
			t.attr('title', 'La voce è di qualità in questa lingua.');
		}
	});
	return;
}

// Funzioni (6) per l'anteprima rapida
// Autore: Sanjilops
var quickSaveCheckText = '';
var quickPreviewFirstLoad = true;
var quickPreviewHiddenCatlist;
var quickPreviewCatNS = 'Categoria:';
var quickPreviewHiddencatsCat = 'Categorie nascoste';
function quickEditor() {
	var sect = $('[name=wpSection]');
	if(!location.search.match(/&?undo=\d+/) && ((sect.length && !sect.eq(0).attr('value')) || !sect.length)) {
		quickSaveLoad();
	}
	if(!(wgTitle.match(/\.(j|cs)s$/) && wgNamespaceNumber % 2 == 0)) {
		quickPreviewLoad();
	}
	$('#wpTextbox1').mouseup(quickEditSwitch).keyup(quickEditSwitch);
	return;
}

function quickSaveLoad() {
	var b = $('<input />').attr({
		'type': 'button',
		'value': 'Salva',
		'id': 'quicksaveButton',
		'accesskey': 1,
		'title': 'Salva e resta nell\'editor [alt-shift-1]'
	}).click(function() {
		quickSave();
	});
	$('#wpPreview').before(b);
	quickSaveCheckText = $('#wpTextbox1').attr('value');
	return;
}

function quickSave() {
	var textBox = $('#wpTextbox1');
	$('#wpTextbox1,#wpSave,#quicksaveButton,#quickpreviewButton').attr('disabled', 'disabled');
	var source = encodeURIComponent(textBox.attr('value'));
	var msgBox = $('#quickSaveMsgBox');
	if(!msgBox.length) {
		msgBox = $('<div></div>').attr('id', 'quickSaveMsgBox');
		$('#firstHeading').before(msgBox);
	}
	else {
		msgBox.html('');
	}
	var param = 'action=edit&format=xml&title=' + encodeURIComponent(wgPageName);
	param += '&token=' + $('[name=wpEditToken]:first').attr('value').replace(/\+\\/, '%2' + "B%5" + 'C');
	if($('#wpSummary').length) {
		param += '&summary=' + encodeURIComponent($('#wpSummary').attr('value'));
	}
	if($('#wpCaptchaId').length) {
		param += '&captchaid=' + $('#wpCaptchaId').attr('value') + '&captchaword=' + encodeURIComponent($('#wpCaptchaWord').attr('value'));
		$('#captcha_box').remove();
	}
	if($('wpMinoredit:checked').length) {
		param += '&minor='
	}
	if($('#wpWatchthis').length) {
		if($('#ca-watch').length && $('#wpWatchthis:checked').length) {
			param += '&watchlist=watch';
		}
		if($('#ca-unwatch').length && !$('#wpWatchthis:checked').length) {
			param += '&watchlist=unwatch';
		}
	}
	param += '&basetimestamp=' + $('[name=wpEdittime]:first').attr('value');
	param += '&starttimestamp=' + $('[name=wpStarttime]:first').attr('value');
	param += '&text=' + source;
	param += '&md5=' + MD5(textBox.attr('value'));
	$.ajax({
		url: wgServer + wgScriptPath + '/api.php',
		type: 'POST',
		headers: {'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': param.length},
		data: param,
		dataType: 'xml',
		timeout: 30000,
		error: function(data, status, error) {
			var msgBox = $('#quickSaveMsgBox');
			if(status == 'timeout') {
				msgBox.text('Salvataggio fallito: il server non risponde.');
			}
			else {
				if(error) {
					msgBox.text('Salvataggio fallito. Risposta del server: ' + error);
				}
				else {
					msgBox.text('Errore nella risposta del server. Controlla nella cronologia se il salvataggio è avvenuto.');
				}
			}
			msgBox.css('color', 'red');
		},
		success: function(data) {
			var result = $('edit', data);
			var msgBox = $('#quickSaveMsgBox');
			if(result.length) {
				if(result.attr('result') == 'Success') {
					msgBox.text('Salvataggio completato.').css('color', '');
					wgCurRevisionId = result.attr('newrevid');
					var param = 'action=query&format=xml&prop=revisions&meta=userinfo&uiprop=hasmsg&rvprop=timestamp%';
					param += '7Cuser&rvlimit=1&rvdir=older&titles=' + encodeURIComponent(wgPageName);
					$.ajax({
						url: wgServer + wgScriptPath + '/api.php',
						type: 'POST',
						headers: {'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': param.length},
						data: param, 
						dataType: 'xml',
						timeout: 30000,
						error: function(data, status, error) {
							var msgBox = $('#quickSaveMsgBox');
							msgBox.text(msgBox.text() + ' Impossibile procedere ad ulteriori salvataggi.');
						},
						success: function(data) {
							var rev = $('rev', data);
							var msgBox = $('#quickSaveMsgBox');
							if(!rev.length) {
								msgBox.text(msgBox.text() + ' Impossibile procedere ad ulteriori salvataggi.');
								return;
							}
							var t = rev.attr('timestamp');
							$('[name=wpEdittime]:first').attr('value', t.replace(/\D/g, ''));
							var d = new Date(t.replace(/(\d\d\d\d)-(\d\d)-(\d\d)T(.+)Z/, "$1/$2/$3 $4"));
							d.setHours(d.getHours() - d.getTimezoneOffset() / 60);
							msgBox.text(msgBox.text() + ' Ultima modifica: ' + rev.attr('user') + ' ' + d.toLocaleString());
							d = new Date();
							$('[name=wpStarttime]:first').attr('value', d.toISOString().replace(/[\-\:A-Za-z]/g, '').replace(/\.[0-9]{3}$/g, ''));
							var userInfo = $('userinfo', data);
							if(!userInfo.length) {
								return;
							}
							var orange = $('#bodyContent div.usermessage:first');
							if(!userInfo.attr('messages')) {
								orange.hide();
								return;
							}
							var name = wgUserName ? wgUserName : userInfo.attr('name');
							if(!orange.length) {
								orange = $('<div></div>').attr('class', 'usermessage');
								$('#wikiPreview').before(orange);
							}
							else {
								orange.css('display', 'block');
								var linkTalk = $('<a></a>').attr({
									'title': 'Discussioni utente:' + name,
									'href': '/index.php?title=Discussioni_utente:' + encodeURI(name) + '&redirect=no'
								}).text('nuovi messaggi');
								var linkDiff = $('<a></a>').attr({
									'title': 'Discussioni utente:' + name,
									'href': '/index.php?title=Discussioni_utente:' + encodeURI(name) + '&diff=cur'
								}).text('differenza con la revisione precedente');
								orange.append('Hai ', linkTalk, ' (', linkDiff, ')');
							}
						},
					});
					$('#wpSummary').attr('value', '');
					quickSaveCheckText = textBox.attr('value');
					if(!wgTitle.match(/\.(j|cs)s$/) || wgNamespaceNumber % 2 == 1) {
						textBox[0].selectionStart = 0;
						textBox[0].selectionEnd = 0;
						quickPreview(true);
					}
					if(wgUserName) {
						if($('#wpWatchthis:checked').length) {
							$('#ca-watch').attr('id', 'ca-unwatch');
							$('#ca-unwatch>a').attr({
								'href': $('#ca-unwatch>a').attr('href').replace(/=watch$/, '=unwatch'),
								'title': $('#ca-unwatch>a').attr('title').replace(/^Rimuovi/, 'Aggiungi')
							}).text('non seguire');
							msgBox.text(msgBox.text() + ' Pagina aggiunta agli osservati speciali.')
						}
						else {
							$('#ca-unwatch').attr('id', 'ca-watch');
							$('#ca-watch>a').attr({
								'href': $('#ca-watch>a').attr('href').replace(/=unwatch$/, '=watch'),
								'title': $('#ca-watch>a').attr('title').replace(/^Aggiungi/, 'Rimuovi')
							}).text('segui');
							msgBox.text(msgBox.text() + ' Pagina rimossa dagli osservati speciali.')
						}
					}
				}
				else if(result.attr('result') == 'Failure') {
					var captcha = $('captcha', result);
					if(!captcha.length) {
						msgBox.text('Salvataggio fallito: errore ignoto').css('color', 'red');
						return;
					}
					var captchaID = $('<input />').attr({
						'type': 'hidden',
						'id': 'wpCaptchaId',
						'value': captcha.attr('id')
					});
					var captchaWord = $('<input />').attr('id', 'wpCaptchaWord').css('margin-bottom', '10px');
					var captchaImg = $('<img />').attr('src', wgScriptPath + '/index.php?title=Special:Captcha/image&wpCaptchaId=' + captcha.attr('value'));
					var captchaLink = $('<a></a>').attr('href', '/wiki/Speciale:Captcha/help" title="Speciale:Captcha/help').text('come funziona?');
					var captchaMsg = $('<p></p>').append('La modifica richiesta aggiunge dei collegamenti esterni alla pagina; come misura precauzionale contro l\'inserimento automatico di spam, si prega di inserire nella casella sottostante la parola che compare distorta in questa immagine (', captchaLink, ')');
					var captchaBox = $('<div></div>').attr('id', 'captchaBox').append(captchaMsg, captchaImg, captchaWord, captchaID);
					$('#toolbar').before(captchaBox);
				}
			}
			var error = $('error', data);
			if(error.length) {
				msgBox.text('Errore nella risposta del server. Controlla nella cronologia se il salvataggio è avvenuto').css('color', 'red');
				switch(error.attr('code')) {
					case 'editconflict':
						$('#wpSave').removeAttr('disabled');
						setTimeout(function() {
							$('#wpSave').click();
							return;
						});
						return;
					case 'noedit':
					case 'noedit-anon':
						msgBox.text('Non sei autorizzato a modificare questa pagina.').css('color', 'red');
						return;
					default:
						msgBox.text('Salvataggio fallito: ' + error.attr('info')).css('color', 'red');
						return;
				}
			}
		},
		complete: function() {
			$('#quickSaveMsgBox')[0].scrollIntoView();
			$('#wpTextbox1,#wpSave,#quicksaveButton,#quickpreviewButton').removeAttr('disabled');
			$('#wikiPreview').html('');
			$('body').css('cursor', 'auto');
		}
	});
	$('body').css('cursor', 'progress');
	return;
}

function quickPreviewLoad() {
	if(wgTitle.match(/\.(j|cs)s$/)) {
		return;
	}
	var buttons = $('div.editButtons:first');
	if(!buttons.length) {
		return;
	}
	var b = $('<input />').attr({
		'type': 'button',
		'value': 'Visualizza anteprima',
		'id': 'quickpreviewButton',
		'accesskey': '2',
		'title': 'Anteprima delle modifiche (consigliata prima di salvare) [alt-shift-2]'
	}).click(function() {
		quickPreview(false);
	});
	var wpButton = $('#wpPreview').css({
		'margin': '0',
		'padding': '0',
		'font-size': '0',
		'width': '0',
		'border-width': '0'
	}).before(b);
	var hotkey = $('#quickpreview-hotkeysuggest').css({
		'left': (b.offset().left - 15) + 'px',
		'visibility': 'visible'
	});
	quickPreviewHiddenCatlist = getCookie('QPhc');
	if (quickPreviewHiddenCatlist == null) {
		$.ajax({
			url: wgServer + wgScriptPath + '/api.php',
			type: 'GET',
			data: 'action=query&list=categorymembers&cmtitle=Category:' + encodeURI(quickPreviewHiddencatsCat) + '&cmlimit=500&format=xml',
			dataType: 'xml',
			success: function(data) {
				var tmp = new Array();
				$('categormembers:first cm', data).each(function() {
					tmp.push($(this).attr('title'));
				});
				quickPreviewHiddenCatlist = tmp.join('|');
				document.cookie = 'QPhc=' + escape(quickPreviewHiddenCatlist);
			}
		});
	}
	return;
}

function quickPreview(afterSave) {
	// Pulizia dell'area di anteprima
	var previewArea = $('#wikiPreview');
	if(!previewArea.length) {
		return;
	}
	previewArea.html('');
	if(quickPreviewFirstLoad) {
		previewArea.css('display', 'block');
		$('#editintro,#mw-anon-edit-warning,#contentSub2,#wpTalkPageText,#explainconflict').hide();
		$('.mw-newarticletext:first,.mw-newarticletextanon:first,.mw-warning-with-logexcerpt:first').hide();
		quickPreviewFirstLoad = false;
	}
	else {
		// Rimuove eventuali css importati precedentemente;
		$('#add-css-link').remove();
	}
	// Imposta il titolo
	$('#firstHeading').html(wgPageName.replace(/_/g, ' '));
	$('#quickpreviewButton').attr('disabled', 'disabled');
	$('body').css('cursor', 'progress');
	var param = 'action=parse&format=xml&prop=text%7Ccategories';
	if(afterSave) {
		param += '&page=' + encodeURIComponent(wgPageName);
	}
	else {
		var textBox = $('#wpTextbox1');
		var start = textBox[0].selectionStart;
		var end = textBox[0].selectionEnd;
		if(start < end) {
			var source = textBox.attr('value').slice(start, end);
		}
		else {
			var source = textBox.attr('value') + '\n';
			if($('[name=wpSection]:first').attr('value') == 'new') {
				source = '== ' + $('wpSummary').attr('value') + ' ==\n' + source;
			}
		}
		source = encodeURIComponent(source);
		param+= '&pst=&title=' + encodeURIComponent(wgPageName) + '&text=' + source;
	}
	$.ajax({
		url: wgServer + wgScriptPath + '/api.php',
		type: 'POST',
		headers: {'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': param.length},
		data: param,
		dataType: 'xml',
		timeout: 30000,
		error: function(data, status, error) {
			if(status == 'timeout') {
				alert('Errore: il server non risponde.');
			}
			else {
				if(error) {
					alert('Anteprima non riuscita. Risposta del server: ' + error);
				}
				else {
					alert('Anteprima non riuscita (errore del parser?)');
				}
			}
		},
		success: function(data) {
			var code = $('text:first', data).text();
			var previewArea = $('#wikiPreview');
			previewArea.html(previewArea.html() + code);
			var showCat = false;
			var catLinksBox = $('#catlinks');
			var r = $('categories:first cl', data);
			if(r.length) {
				if(catLinksBox.length) {
					catLinksBox.html('');
				}
				else {
					catLinksBox = $('<div></div>').attr({
						'id': 'catlinks',
						'class': 'catlinks'
					});
					$('div.visualClear:first').before(catLinksBox);
				}
				var normalCatLinks = new Array();
				var hiddenCatLinks = new Array();
				r.each(function() {
					var catName = $(':first-child', this).text();
					if(quickPreviewHiddenCatlist.match(RegExp(catName.replace(/_/g, ' ')))) {
						var span = $('<span></span>').attr('dir', 'ltr');
						var link = $('<a></a>').attr({
							'href': '/wiki/' + quickPreviewCatNS + encodeURI(catName),
							'title': quickPreviewCatNS + catName.replace(/_/g, ' ')
						}).text(catName.replace(/_/g, ' '));
						span.append(link);
						hiddenCatLinks.push(span);
					}
					else {
						normalCatLinks.push('[[:' + quickPreviewCatNS + catName + '|' + catName.replace(/_/g, ' ') + ']]');
					}
				});
				if(hiddenCatLinks.length) {
					var hiddenCatLinksBox = $('<div></div>').attr({
						'id': 'mw-hidden-catlinks',
						'class': 'mw-hidden-cats-hidden'
					});
					if(!normalCatLinks.length) {
						catLinksBox.addClass('catlinks-allhidden');
					}
					catLinksBox.append(hiddenCatLinksBox);
					var label = 'CategoriX nascostX: ';
					if(hiddenCatLinks.length > 1) {
						hiddenCatLinksBox.append(label.replace('X', 'e'));
						for(var i = 0; i < hiddenCatLinks.length; i++) {
							hiddenCatLinksBox.append(hiddenCatLinks[i]);
							if(i != hiddenCatLinks.length - 1) {
								hiddenCatLinksBox.append('|');
							}
						}
					}
					else {
						hiddenCatLinksBox.append(label.replace('X', 'a'), hiddenCatLinks[0]);
					}
				}
				if(normalCatLinks.length) {
					showCat = true;
					var normalCatsCode = '<div id="mw-normal-catlinks">[[Speciale:Categorie|CategoriX]]: '; // È brutto ma serve come stringa
					if(normalCatLinks.length > 1) {
						normalCatsCode = normalCatsCode.replace('X', 'e') + normalCatLinks.join('|');
					}
					else {
						normalCatsCode = normalCatsCode.replace('X', 'a') + normalCatLinks[0];
					}
					normalCatsCode = (normalCatsCode + '</div>').replace(/&/g, '%2' + '6').replace(/\+/g, '%2' + 'B');
					normalCatsCode = 'action=parse&format=xml&prop=text&text=' + normalCatsCode;
					$.ajax({
						url: wgServer + wgScriptPath + '/api.php',
						type: 'POST',
						headers: {'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': normalCatsCode.length},
						data: normalCatsCode,
						dataType: 'xml',
						timeout: 30000,
						error: function(data, status, error) {
							if(status == 'timeout') {
								alert('Errore del server. Impossibile visualizzare le categorie.');
							}
							else {
								if(error) {
									alert('Impossibile visualizzare le categorie: errore del server ' + error);
								}
								else {
									alert('Impossibile visualizzare le categorie: errore del parser?');
								}
							}
						},
						success: function(data) {
							var catLinksBox = $('#catlinks');
							catLinksBox.prepend($('text:first', data).text()).attr('class', 'catlinks');
						}
					});
				}
				$('#p-logo')[0].scrollIntoView();
				if(window.showTocToggle) {
					window.tocShowText = 'mostra';
					window.tocHideText = 'nascondi';
					showTocToggle();
				}
			}
			else {
				if(catLinksBox.length) {
					catLinksBox.remove();
				}
			}
			hooksCommonRender();
		},
		complete: function() {
			$('#quickpreviewButton').removeAttr('disabled');
			$('body').css('cursor', 'auto');
		}
	});
	return;
}

function quickEditSwitch() {
	var bs = $('#quicksaveButton');
	if(bs.length) {
		if($(this).attr('value') == quickSaveCheckText) {
			bs.attr('disabled', 'disabled');
		}
		else {
			bs.removeAttr('disabled');
		}
	}
	var bp = $('#quickpreviewButton');
	if(bp.length) {
		if(this.selectionStart < this.selectionEnd) {
			bp.attr('value', 'Anteprima selezione');
		}
		else {
			bp.attr('value', 'Visualizza anteprima');
		}
	}
	return;
}