MediaWiki:NormalizeMarcData.js: mudanças entre as edições

sem sumário de edição
Sem resumo de edição
Sem resumo de edição
);
instanceMains.forEach((instanceMain) => {
 
function transform(string){
originalString = string;
return originalString.value
// "$a Bar \n$b Baz" > " $a Bar $b Baz"
.replace(/\s*(\$[a-z0-8])\s*/g, ' $1 ')
// "$a Bar\nFoo" > "$a Bar Foo" ou "$a Bar Foo" > "$a Bar Foo"
.replace(/\n|\s\s+|\t/g, ' ')
// replace "|" by "%7C" (Ex.: http://viaf.org/processed/WKP|Q2484404)
.replace('|', '%7C');
// remove consecutive spaces
.replace(/\n|\s\s +|\t(?= )/g, ' ');
}
 
instanceMain
.querySelectorAll('.oo-ui-inputWidget-input')
.forEach((input) => {
const normalizedInput = input;
normalizedInput.value = transform(normalizedInput.value);
// "$a Bar \n$b Baz" > " $a Bar $b Baz"
.replace(/\s*(\$[a-z0-8])\s*/g, ' $1 ')
// "$a Bar\nFoo" > "$a Bar Foo" ou "$a Bar Foo" > "$a Bar Foo"
.replace(/\n|\s\s+|\t/g, ' ')
// replace "|" by "%7C" (Ex.: http://viaf.org/processed/WKP|Q2484404)
.replace('|', '%7C');
});
 
instanceMain.querySelectorAll('textarea').forEach((textarea) => {
const normalizedInput = textarea;
normalizedInput.value = transform(normalizedInput.value);
// "$a Bar \n$b Baz" > " $a Bar $b Baz"
.replace(/\s*(\$[a-z0-8])\s*/g, ' $1 ')
// "$a Bar\nFoo" > "$a Bar Foo" ou "$a Bar Foo" > "$a Bar Foo"
.replace(/\n|\s\s+|\t/g, ' ')
// replace "|" by "%7C" (Ex.: http://viaf.org/processed/WKP|Q2484404)
.replace('|', '%7C');
});
});