Burocratas, emailconfirmed, Administradores da interface, Administradores (Semantic MediaWiki), Curadores (Semantic MediaWiki), Editores (Semantic MediaWiki), Supressores, Administradores
1 023
edições
Sem resumo de edição |
Sem resumo de edição |
||
let tag = '';
let tagFromDropdown = '';
function createMarcFieldHelpLink() {
const tagInputs = document.body.querySelectorAll('.tagInput');
tagInputs.forEach((elem) => {
const marcFieldHelpLink = document.createElement('a');
marcFieldHelpLink.setAttribute('target', '_blank');
marcFieldHelpLink.innerText = '(?)';
const marcFieldHelpLinkClass = elem.closest('table')
.querySelector('.marcFieldHelpLink');
marcFieldHelpLinkClass.innerHTML = "";
marcFieldHelpLinkClass.appendChild(marcFieldHelpLink);
// find the tag value from the chosen dropdown
marcFieldHelpLinkClass.addEventListener('mouseover', (event) => {
tagFromDropdown = event.target.closest('.instanceMain')
.querySelector('.oo-ui-inputWidget-input')
.getAttribute('title') || '00x';
tagFromDropdown = tagFromDropdown.substring(0, 3);
marcFieldHelpLink.setAttribute(
'title',
`Documentação do campo ${tagFromDropdown}`
);
// build the URL
if (window.location.href.match(/A\d{6}/)
|| window.location.href.match(/AutRecord/)) {
marcFieldHelpLink.setAttribute(
'href',
`http://marc.febab.org/a${tagFromDropdown}`
);
} else {
marcFieldHelpLink.setAttribute(
'href',
`https://www.loc.gov/marc/bibliographic/bd${tagFromDropdown}.html`
);
}
});
});
}
function createAuthorityLinks() {
authorityLink.style.display = '';
});
});
}
function rmCarriageReturn() {
const inputs = document.body.querySelectorAll('.instanceMain div table .oo-ui-inputWidget-input');
inputs.forEach((input) => {
const element = input;
element.value = element.value.replace(' ', '');
});
}
function rmHtmlTags() {
const inputs = document.body.querySelectorAll('.instanceMain div table .oo-ui-inputWidget-input');
inputs.forEach((input) => {
const element = input;
element.value = element.value.replace(/<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>/g, '');
});
}
function rmTxtFromHiddenTexareas() {
const inputs = document.body.querySelectorAll('span.hiddenByPF');
inputs.forEach((elem) => {
elem.querySelectorAll('.input.oo-ui-inputWidget-input').forEach((input) => {
const element = input;
element.value = '';
});
});
}
function normalizeInput() {
const inputs = document.body.querySelectorAll('.instanceMain div table .oo-ui-inputWidget-input');
inputs.forEach((input) => {
const normalizedInput = input;
normalizedInput.value = 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');
});
}
// calls main functions
createAuthorityLinks();
// Como instâncias do formulário são criadas pelo botão "Adicionar campo",
const newNodes = mutation.addedNodes; // DOM NodeList
if (newNodes.length !== 0) { // if there are new nodes added
createAuthorityLinks();
}
saveBtn.addEventListener('click', () => {
observer.disconnect();
});
}
|