MediaWiki:EmailObfuscate.js: Unterschied zwischen den Versionen

Aus Freifunk MWU Wiki
Zur Navigation springen Zur Suche springen
K (Nanu?)
K (Und?)
Zeile 3: Zeile 3:
 
var user = document.getElementById('emailuser');
 
var user = document.getElementById('emailuser');
 
var host = document.getElementById('emailhost');
 
var host = document.getElementById('emailhost');
var suffix = document.getElementById('emailsuffix');  
+
var suffix = document.getElementById('emailsuffix');
  
 
var email = document.getElementById('emailobfuscated');
 
var email = document.getElementById('emailobfuscated');
  
email.innerHTML = '<a href="mailto:' + user.innerHTML + '@' + host.innerHTML + '.' + suffix.innerHTML + '">' + user.innerHTML + '@' + host.innerHTML + '.' + suffix.innerHTML + '</a>';
+
 
 +
if(typeof(email) != 'undefined' && email !== null)
 +
{
 +
    if(typeof(user) != 'undefined' && user !== null && typeof(host) != 'undefined' && host !== null && typeof(suffix) != 'undefined' && suffix !== null)
 +
    {
 +
        var addr = user.innerHTML.replace(/^\s+|\s+$/g,'') + '@' + host.innerHTML.replace(/^\s+|\s+$/g,'') + '.' + suffix.innerHTML.replace(/^\s+|\s+$/g,'');
 +
        email.innerHTML = '<a href="mailto:' + addr + '">' + addr + '</a>';
 +
    }
 +
}

Version vom 27. Mai 2014, 23:57 Uhr

/* Ich verschleiere Email-Adressen zum Spamschutz */

var user = document.getElementById('emailuser');
var host = document.getElementById('emailhost');
var suffix = document.getElementById('emailsuffix');

var email = document.getElementById('emailobfuscated');


if(typeof(email) != 'undefined' && email !== null)
{
    if(typeof(user) != 'undefined' && user !== null && typeof(host) != 'undefined' && host !== null && typeof(suffix) != 'undefined' && suffix !== null)
    {
        var addr = user.innerHTML.replace(/^\s+|\s+$/g,'') + '@' + host.innerHTML.replace(/^\s+|\s+$/g,'') + '.' + suffix.innerHTML.replace(/^\s+|\s+$/g,'');
        email.innerHTML = '<a href="mailto:' + addr + '">' + addr + '</a>';
    }
}