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

De Wikincat
Ir para navegação Ir para pesquisar
imported>Jaideraf
m (uma edição)
imported>Jaideraf
Sem resumo de edição
Linha 1: Linha 1:
(function () {
// Função que gera o arquivo ISO
function download(filename, content) {
"use strict";
"use strict";
// Função que gera o arquivo ISO
let element = document.createElement("a");
function download(filename, content) {
element.setAttribute("href", "data:application/marc;charset=utf-8,"
let element = document.createElement("a");
+ encodeURIComponent(content));
element.setAttribute("download", filename);
element.setAttribute("href", "data:application/marc;charset=utf-8,"
+ encodeURIComponent(content));
element.style.display = "none";
element.setAttribute("download", filename);
document.body.appendChild(element);
element.click();
element.style.display = "none";
document.body.removeChild(element);
document.body.appendChild(element);
element.click();
}
document.body.removeChild(element);
// Se tiver uma div "isoFormat" na página/documento,
}
// substititua os caracteres abaixo
if (document.getElementById("isoFormat")) {
// Se tiver uma div "isoFormat" na página/documento,
// substititua os caracteres abaixo
document.getElementById("isoFormat").innerHTML =
document.getElementById("isoFormat").innerHTML.replace(/\u241D/g, String.fromCharCode(29)); // GS
let isoFormat = document.getElementById("isoFormat");
document.getElementById("isoFormat").innerHTML =
if (isoFormat) {
document.getElementById("isoFormat").innerHTML.replace(/\u241E/g, String.fromCharCode(30)); // RS
isoFormat.innerHTML =
document.getElementById("isoFormat").innerHTML =
isoFormat.innerHTML.replace(/\u241D/g, String.fromCharCode(29)); // GS
document.getElementById("isoFormat").innerHTML.replace(/\u241F/g, String.fromCharCode(31)); // US
isoFormat.innerHTML =
document.getElementById("isoFormat").innerHTML =
isoFormat.innerHTML.replace(/\u241E/g, String.fromCharCode(30)); // RS
document.getElementById("isoFormat").innerHTML.replace(/ /g, String.fromCharCode(32)); // &NonBreakingSpace
isoFormat.innerHTML =
isoFormat.innerHTML.replace(/\u241F/g, String.fromCharCode(31)); // US
isoFormat.innerHTML =
isoFormat.innerHTML.replace(/ /g, String.fromCharCode(32)); // &NonBreakingSpace


let content = document.getElementById("isoFormat").textContent;
const content = isoFormat.textContent;
let filename = document.URL.substr(-7) + ".mrc";
const filename = document.URL.slice(-7) + ".mrc";


// Ao clicar no botão "downloadButton", chama a função download() abaixo
// Ao clicar no botão "downloadButton", chama a função download() abaixo
document.getElementById("downloadButton").addEventListener("click",
document.getElementById("downloadButton").addEventListener("click",
() => download(filename, content), false);
function(){
}
download(filename, content);

}, false);
})();
}

Edição das 16h22min de 6 de agosto de 2022

(function () {
    "use strict";
    // Função que gera o arquivo ISO
    function download(filename, content) {
        let element = document.createElement("a");
        element.setAttribute("href", "data:application/marc;charset=utf-8,"
            + encodeURIComponent(content));
        element.setAttribute("download", filename);
        element.style.display = "none";
        document.body.appendChild(element);
        element.click();
        document.body.removeChild(element);
    }
    // Se tiver uma div "isoFormat" na página/documento,
    // substititua os caracteres abaixo
    let isoFormat = document.getElementById("isoFormat");
    if (isoFormat) {
        isoFormat.innerHTML =
            isoFormat.innerHTML.replace(/\u241D/g, String.fromCharCode(29)); // GS
        isoFormat.innerHTML =
            isoFormat.innerHTML.replace(/\u241E/g, String.fromCharCode(30)); // RS
        isoFormat.innerHTML =
            isoFormat.innerHTML.replace(/\u241F/g, String.fromCharCode(31)); // US
        isoFormat.innerHTML =
            isoFormat.innerHTML.replace(/ /g, String.fromCharCode(32)); // &NonBreakingSpace

        const content = isoFormat.textContent;
        const filename = document.URL.slice(-7) + ".mrc";

        // Ao clicar no botão "downloadButton", chama a função download() abaixo
        document.getElementById("downloadButton").addEventListener("click",
            () => download(filename, content), false);
    }

})();