MediaWiki:EmailObfuscate.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Spky (Diskussion | Beiträge) K (Und?) |
Spky (Diskussion | Beiträge) K (link text) |
||
Zeile 4: | Zeile 4: | ||
var host = document.getElementById('emailhost'); | var host = document.getElementById('emailhost'); | ||
var suffix = document.getElementById('emailsuffix'); | var suffix = document.getElementById('emailsuffix'); | ||
+ | var text = document.getElementById('emailtext'); | ||
var email = document.getElementById('emailobfuscated'); | var email = document.getElementById('emailobfuscated'); | ||
− | |||
if(typeof(email) != 'undefined' && email !== null) | if(typeof(email) != 'undefined' && email !== null) | ||
Zeile 13: | Zeile 13: | ||
{ | { | ||
var addr = user.innerHTML.replace(/^\s+|\s+$/g,'') + '@' + host.innerHTML.replace(/^\s+|\s+$/g,'') + '.' + suffix.innerHTML.replace(/^\s+|\s+$/g,''); | 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 + '">' + | + | var link = addr; |
+ | if(typeof(text) != 'undefined' && text !== null) | ||
+ | { | ||
+ | link = text.innerHTML.replace(/^\s+|\s+$/g,''); | ||
+ | } | ||
+ | email.innerHTML = '<a href="mailto:' + addr + '">' + link + '</a>'; | ||
} | } | ||
} | } |
Version vom 28. Mai 2014, 00:54 Uhr
/* Ich verschleiere Email-Adressen zum Spamschutz */
var user = document.getElementById('emailuser');
var host = document.getElementById('emailhost');
var suffix = document.getElementById('emailsuffix');
var text = document.getElementById('emailtext');
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,'');
var link = addr;
if(typeof(text) != 'undefined' && text !== null)
{
link = text.innerHTML.replace(/^\s+|\s+$/g,'');
}
email.innerHTML = '<a href="mailto:' + addr + '">' + link + '</a>';
}
}