MediaWiki:MakeMarcFieldHelpLink.js: mudanças entre as edições
Ir para navegação
Ir para pesquisar
Sem resumo de edição |
Sem resumo de edição |
||
Linha 1: | Linha 1: | ||
/* jshint esversion: 8 */ |
/* jshint esversion: 8 */ |
||
⚫ | |||
function makeMarcFieldHelpLink() { |
function makeMarcFieldHelpLink() { |
||
const |
const inputs = document.body.querySelectorAll('.instanceMain div table .oo-ui-inputWidget-input'); |
||
inputs.forEach((elem) => { |
|||
const marcFieldHelpLink = document.createElement('a'); |
const marcFieldHelpLink = document.createElement('a'); |
||
marcFieldHelpLink.setAttribute('target', '_blank'); |
marcFieldHelpLink.setAttribute('target', '_blank'); |
||
Linha 17: | Linha 15: | ||
// find the tag value from the chosen dropdown |
// find the tag value from the chosen dropdown |
||
marcFieldHelpLinkClass.addEventListener('mouseover', (event) => { |
marcFieldHelpLinkClass.addEventListener('mouseover', (event) => { |
||
⚫ | |||
tagFromDropdown = |
tagFromDropdown = |
||
event.target |
event.target |
Edição das 10h58min de 15 de março de 2024
/* jshint esversion: 8 */
function makeMarcFieldHelpLink() {
const inputs = document.body.querySelectorAll('.instanceMain div table .oo-ui-inputWidget-input');
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`,
);
}
});
});
}