franta-hg@84
|
1 |
/**
|
franta-hg@84
|
2 |
* XML Web generátor – program na generování webových stránek
|
franta-hg@84
|
3 |
* Copyright © 2012 František Kučera (frantovo.cz)
|
franta-hg@84
|
4 |
*
|
franta-hg@84
|
5 |
* This program is free software: you can redistribute it and/or modify
|
franta-hg@84
|
6 |
* it under the terms of the GNU General Public License as published by
|
franta-hg@84
|
7 |
* the Free Software Foundation, either version 3 of the License, or
|
franta-hg@84
|
8 |
* (at your option) any later version.
|
franta-hg@84
|
9 |
*
|
franta-hg@84
|
10 |
* This program is distributed in the hope that it will be useful,
|
franta-hg@84
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
franta-hg@84
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
franta-hg@84
|
13 |
* GNU General Public License for more details.
|
franta-hg@84
|
14 |
*
|
franta-hg@84
|
15 |
* You should have received a copy of the GNU General Public License
|
franta-hg@84
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
franta-hg@84
|
17 |
*/
|
franta-hg@11
|
18 |
|
franta-hg@84
|
19 |
/**
|
franta-hg@84
|
20 |
* XML Web generátor – jmenný prostor
|
franta-hg@84
|
21 |
*/
|
franta-hg@84
|
22 |
var xwg = {
|
franta-hg@84
|
23 |
/**
|
franta-hg@84
|
24 |
* Zašifruje/dešifruje obsah elementu pomocí Rot13.
|
franta-hg@84
|
25 |
* @param id ID elementu, jehož text chceme změnit.
|
franta-hg@84
|
26 |
*/
|
franta-hg@84
|
27 |
rot13: function(id) {
|
franta-hg@84
|
28 |
var e = document.getElementById(id);
|
franta-hg@84
|
29 |
e.textContent = e.textContent.rot13();
|
franta-hg@93
|
30 |
},
|
franta-hg@93
|
31 |
|
franta-hg@93
|
32 |
/**
|
franta-hg@93
|
33 |
* Vloží klikatelný odkaz.
|
franta-hg@93
|
34 |
* @param id ID span elementu obsahujícího data
|
franta-hg@93
|
35 |
*/
|
franta-hg@93
|
36 |
odkazNaElektronickouPoštu: function(id) {
|
franta-hg@93
|
37 |
var spanČesky = document.getElementById(id);
|
franta-hg@93
|
38 |
var spanObsah = document.getElementById(id + "b");
|
franta-hg@93
|
39 |
var česky = spanČesky.innerHTML;
|
franta-hg@93
|
40 |
var adresa = česky.replace(" zavináč ", "@").replace(" tečka ",".");
|
franta-hg@93
|
41 |
|
franta-hg@93
|
42 |
var odkaz = document.createElement("a");
|
franta-hg@93
|
43 |
odkaz.href = "mailto:" + adresa;
|
franta-hg@93
|
44 |
if (spanObsah.innerHTML.length > 0) {
|
franta-hg@93
|
45 |
odkaz.innerHTML = spanObsah.innerHTML;
|
franta-hg@93
|
46 |
} else {
|
franta-hg@93
|
47 |
odkaz.innerHTML = adresa;
|
franta-hg@93
|
48 |
}
|
franta-hg@93
|
49 |
|
franta-hg@93
|
50 |
spanČesky.parentNode.insertBefore(odkaz, spanČesky);
|
franta-hg@93
|
51 |
spanČesky.parentNode.removeChild(spanČesky);
|
franta-hg@93
|
52 |
spanObsah.parentNode.removeChild(spanObsah);
|
franta-hg@93
|
53 |
},
|
franta-hg@93
|
54 |
|
franta-hg@84
|
55 |
};
|
franta-hg@84
|
56 |
|
franta-hg@84
|
57 |
/**
|
franta-hg@84
|
58 |
* Vrací hodnotu textového řetězce zašifrovanou/dešifrovanou algoritmem Rot13
|
franta-hg@84
|
59 |
*/
|
franta-hg@84
|
60 |
String.prototype.rot13 = function() {
|
franta-hg@84
|
61 |
return this.replace(/[a-zA-Z]/g, function(z) {
|
franta-hg@84
|
62 |
return String.fromCharCode((z <= "Z" ? 90 : 122) >= (z = z.charCodeAt(0) + 13) ? z : z - 26);
|
franta-hg@84
|
63 |
});
|
franta-hg@84
|
64 |
};
|
franta-hg@84
|
65 |
|