franta-hg@84: /** franta-hg@84: * XML Web generátor – program na generování webových stránek franta-hg@84: * Copyright © 2012 František Kučera (frantovo.cz) franta-hg@84: * franta-hg@84: * This program is free software: you can redistribute it and/or modify franta-hg@84: * it under the terms of the GNU General Public License as published by franta-hg@136: * the Free Software Foundation, version 3 of the License. franta-hg@84: * franta-hg@84: * This program is distributed in the hope that it will be useful, franta-hg@84: * but WITHOUT ANY WARRANTY; without even the implied warranty of franta-hg@84: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the franta-hg@84: * GNU General Public License for more details. franta-hg@84: * franta-hg@84: * You should have received a copy of the GNU General Public License franta-hg@84: * along with this program. If not, see . franta-hg@84: */ franta-hg@11: franta-hg@84: /** franta-hg@84: * XML Web generátor – jmenný prostor franta-hg@84: */ franta-hg@84: var xwg = { franta-hg@84: /** franta-hg@84: * Zašifruje/dešifruje obsah elementu pomocí Rot13. franta-hg@84: * @param id ID elementu, jehož text chceme změnit. franta-hg@84: */ franta-hg@84: rot13: function(id) { franta-hg@84: var e = document.getElementById(id); franta-hg@84: e.textContent = e.textContent.rot13(); franta-hg@93: }, franta-hg@93: franta-hg@93: /** franta-hg@93: * Vloží klikatelný odkaz. franta-hg@93: * @param id ID span elementu obsahujícího data franta-hg@93: */ franta-hg@93: odkazNaElektronickouPoštu: function(id) { franta-hg@93: var spanČesky = document.getElementById(id); franta-hg@93: var spanObsah = document.getElementById(id + "b"); franta-hg@93: var česky = spanČesky.innerHTML; franta-hg@125: var adresa = česky franta-hg@125: .replace(new RegExp(" zavináč ", "g"), "@") franta-hg@125: .replace(new RegExp(" tečka ", "g"),"."); franta-hg@93: franta-hg@93: var odkaz = document.createElement("a"); franta-hg@93: odkaz.href = "mailto:" + adresa; franta-hg@93: if (spanObsah.innerHTML.length > 0) { franta-hg@93: odkaz.innerHTML = spanObsah.innerHTML; franta-hg@93: } else { franta-hg@93: odkaz.innerHTML = adresa; franta-hg@93: } franta-hg@93: franta-hg@93: spanČesky.parentNode.insertBefore(odkaz, spanČesky); franta-hg@93: spanČesky.parentNode.removeChild(spanČesky); franta-hg@93: spanObsah.parentNode.removeChild(spanObsah); franta-hg@93: }, franta-hg@93: franta-hg@84: }; franta-hg@84: franta-hg@84: /** franta-hg@84: * Vrací hodnotu textového řetězce zašifrovanou/dešifrovanou algoritmem Rot13 franta-hg@84: */ franta-hg@84: String.prototype.rot13 = function() { franta-hg@84: return this.replace(/[a-zA-Z]/g, function(z) { franta-hg@84: return String.fromCharCode((z <= "Z" ? 90 : 122) >= (z = z.charCodeAt(0) + 13) ? z : z - 26); franta-hg@84: }); franta-hg@84: }; franta-hg@84: