Usuária:IJuulia/Ajustes 2.js: diferenças entre revisões

Conteúdo apagado Conteúdo adicionado
IJuulia (discussão | contribs)
m
IJuulia (discussão | contribs)
m
Linha 268:
sumario: 'ajustando datas'
},
 
tradpred: {
cond: [
Linha 834 ⟶ 833:
sumario: 'traduzindo nome/parâmetro'
},
obsoleto: {
cond: [
Linha 960 ⟶ 958:
sumario: 'parâmetros sem suporte'
},
geral: {
cond: [
/* {
while (true) {
reg: /((<ref name=['"]?[\w\d]+['"]?)>[^<]+<\/ref>)([\s\S]+)\1/, subs: function(achou) {
return achou[1] + achou[3] + achou[2] + "/>";
}
return achou[0];
}
}, */
{
reg: /\|\s*(?:acc?ess?ado?em|dataacc?ess?o)\s*=/, subs: function(achou) {
Linha 1 108 ⟶ 1 097:
sumario: 'ajustes gerais'
},
idiomas: {
cond: [
Linha 1 404 ⟶ 1 392:
sumario: 'formatando idiomas'
},
duplicado: {
sumario: 'rm duplicados'
Linha 1 810 ⟶ 1 797:
}];
 
function substApenas(texto, cond, apenas) {
excecoes = [];
 
function substComExcecao(texto, cond, excecoes) {
var tmp = '';
 
for (var j = 0; j < cond.length; j++) {
while (texto) {
var pos = texto.search(cond[j].reg);
while (excecoes.length > 0 && pos != -1) {
var exce = -1;
for (var i = 0; i < excecoes.length; i++) {
var _exce = texto.search(excecoes[i]);
if ((exce == -1) || (_exce != -1 && _exce < exce))
exce = _exce;
}
if (exce == -1) {
pos = texto.search(cond[j].reg);
break;
}
if (pos < exce) {
pos = texto.search(cond[j].reg);
break;
}
var bloco = 0;
var exceInicial = exce;
for (; exce < texto.length; exce++) {
if (texto.charAt(exce) == '{' && texto.charAt(exce + 1) == '{') {
bloco++;
exce++;
}
else if (texto.charAt(exce) == '}' && texto.charAt(exce + 1) == '}') {
bloco--;
exce++;
}
if (bloco == 0) break;
}
if (bloco != 0) {
var linhas = (tmp + texto.substring(0, exceInicial)).split('\n');
var erro = "Erro: O bloco da predefinição na linha: "
+ linhas.length + ", e posição: "
+ (linhas[linhas.length - 1].length + 1) + " nunca é fechado";
 
mw.notify(erro);
throw erro;
}
tmp += texto.substring(0, exce);
texto = texto.substring(exce);
pos = texto.search(cond[j].reg);
}
 
if (pos > -1) {
tmp += texto.substring(0, pos);
texto = texto.substring(pos);
var achou = texto.match(cond[j].reg);
texto = texto.replace(achou[0], '');
tmp += cond[j].subs(achou);
} else {
tmp += texto;
texto = "";
}
}
texto = tmp;
tmp = '';
}
return texto;
}
 
function substApenas(texto, cond, apenas, excecoes) {
var tmp = '';
 
Linha 1 915 ⟶ 1 835:
throw erro;
}
if (excecoes) {
apenInicial++;
tmp += texto.substring(0, apenInicial)
+ substComExcecao(texto.substring(apenInicial, apen), cond, excecoes);
} else tmp += texto.substring(0, apenInicial)
+ substituir(texto.substring(apenInicial, apen), cond);
texto = texto.substring(apen);
}
 
return tmp;
}
Linha 2 215 ⟶ 2 127:
}
if (sumario) sumario += ' nas citações';
 
escape = 0;
do {
if (escape == 20) {
mw.notify("Parece haver algo errado ao aplicar ajustes gerais. Parando a execução");
return;
}
escape++;
comp = temp;
temp = substComExcecao(temp, foraDePredef, [/\{\{/]);
if ((!mudou.outros) && comp != temp) {
sumGeral = true;
}
} while (comp != temp);
 
escape = 0;