vstup/js/skript.js
author František Kučera <franta-hg@frantovo.cz>
Wed, 11 Jan 2012 17:01:59 +0100
changeset 84 f866267d7b3c
parent 11 vstup/js/javascript.js@78a8dd1eeb2b
child 93 5b55827de220
permissions -rw-r--r--
ROT13 – šifrování #18
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@84
    30
	}
franta-hg@84
    31
};
franta-hg@84
    32
franta-hg@84
    33
/**
franta-hg@84
    34
 * Vrací hodnotu textového řetězce zašifrovanou/dešifrovanou algoritmem Rot13 
franta-hg@84
    35
 */
franta-hg@84
    36
String.prototype.rot13 = function() {
franta-hg@84
    37
	return this.replace(/[a-zA-Z]/g, function(z) {
franta-hg@84
    38
		return String.fromCharCode((z <= "Z" ? 90 : 122) >= (z = z.charCodeAt(0) + 13) ? z : z - 26);
franta-hg@84
    39
	});
franta-hg@84
    40
};
franta-hg@84
    41