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