MediaWiki:Gadget-CreditiTraduzione.js: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
rb test |
m dimenticanza |
||
(3 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 43:
* @param {string} prepend - Il wikicodice da inserire prima di quello esistente
* @param {string} summary - L'oggetto di modifica; per default è vuoto
* @param {boolean} minor - 'true' se la modifica dev'essere marcata come minore, 'false'
*/
function autoEdit(prepend, summary
if (prepend) {
// aggiungi il template nel codice
editBox.value = prepend + editBox.value;
Riga 60:
// salva la pagina
setTimeout(function()
bannerMessage('Il pulsante per il salvataggio della pagina è stato cliccato automaticamente. Attendi che la pagina venga salvata.');
document.title = '(' + document.title + ')';
Riga 73:
$( function () {
// controlla se 1) siamo in un namespace di discussione 2) siamo in modalità modifica 3) il token passato in input è valido
if (mw.config.get('wgNamespaceNumber') % 2 === 1 &&
// ricava i parametri HTTP GET
timestamp = mw.util.getParamValue('tdtimestamp'),
oldid = mw.util.getParamValue('tdoldid');
if (lang && title && timestamp && oldid) {
// genera il wikicodice del template ed esegui l'edit automatico
summary = "Aggiungo [[template:Tradotto da]] tramite [[Utente:Horcrux/CreditiTraduzione.js]]";
autoEdit(wikicode, summary, null);
}
}
Line 103 ⟶ 105:
* @param {string} timestamp - Il timestamp di riferimento (formato: "YYYY-MM-DDThh:mm:ssZ")
* @return {Object} Un oggetto thenable contenente un array costituito dall'oldid desiderato e dal relativo timestamp.
*/
function getOtherWikiRevIdAndTimestamp( lang, title, timestamp ) {
return getOtherWikiRevIdAndTimestampAux( lang, title, timestamp, true );
}
/**
* Funzione ausiliaria per getOtherWikiRevIdAndTimestamp
*
* @param {boolean} firstAttempt - Valore booleano ausiliario, per sapere in quale direzione della cronologia effettuare la ricerca
*/
function
// Come da [[mw:API:Cross-site_requests#CORS_usage]]
var apiEndpoint =
var params =
var otherParams = firstAttempt ? '' : '&rvdir=newer';
return fetch(
.then(function(response) { return response.json(); })
.then(function(response) {
if (typeof response.query.pages[0].revisions !== "undefined") {
Line 120 ⟶ 130:
else if (firstAttempt) {
// se nessuna revision è trovata, prova invertendo la direzione di ricerca (rvdir=newer)
return
}
});
Line 256 ⟶ 266:
setResultLabel(' ');
Promise.resolve(revisionId).then( function(revId)
if (!revId) {
setResultLabel('<p>Impossibile trovare la versione specificata. Assicurati di trovarti nella pagina corretta e di indicare una versione valida.</p>');
Line 263 ⟶ 273:
getTimestampByRevisionId(revId),
getTitleByLang(lang)
]).then( function(values)
var
otherWikiTitle = values[1];
if (typeof otherWikiTitle === "undefined") {
setResultLabel(
}
else {
getOtherWikiRevIdAndTimestamp(lang, otherWikiTitle, timestamp).then( function(response)
var
otherWikiTs = response[1];
var autoEditUrl =
window.open(autoEditUrl,"_self");
});
|