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