MediaWiki:MakeMarcFieldHelpLink.js
Ir para navegação
Ir para pesquisar
Nota: Após publicar, você pode ter que limpar o "cache" do seu navegador para ver as alterações.
- Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
- Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
- Internet Explorer/Edge: PressioneCtrl enquanto clica Recarregar, ou Pressione Ctrl-F5
- Opera: Pressione Ctrl-F5.
/* jshint esversion: 8 */
function makeMarcFieldHelpLink() {
const inputs = document.body.querySelectorAll('[mappingtemplate="BibRecord/tags"]');
inputs.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) => {
let tagFromDropdown = '';
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`,
);
}
});
});
}