wall coloured and split in days,
[redakcja.git] / redakcja / static / email_mangler / email_mangler.js
diff --git a/redakcja/static/email_mangler/email_mangler.js b/redakcja/static/email_mangler/email_mangler.js
new file mode 100755 (executable)
index 0000000..03c1a91
--- /dev/null
@@ -0,0 +1,21 @@
+var rot13 = function(s){
+    return s.replace(/[a-zA-Z]/g, function(c){
+        return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
+    });
+};
+
+(function($) {
+    $(function() {
+
+        $(".mangled").each(function() {
+            $this = $(this);
+            var email = rot13($this.attr('data-addr1')) + '@' +
+                rot13($this.attr('data-addr2'));
+            $this.attr('href', "mailto:" + email);
+            $this.html(email);
+        });
+
+
+    });
+})(jQuery);
+