MediaWiki:EmailObfuscate.js: Unterschied zwischen den Versionen

Aus Freifunk MWU Wiki
Zur Navigation springen Zur Suche springen
K (link text)
K (Ab sofort kann ich auch mehrere Adressen pro Seite verschleiern..)
Zeile 1: Zeile 1:
 
/* Ich verschleiere Email-Adressen zum Spamschutz */
 
/* Ich verschleiere Email-Adressen zum Spamschutz */
  
var user = document.getElementById('emailuser');
+
var sets = document.getElementsByClassName('emailobfuscated');
var host = document.getElementById('emailhost');
 
var suffix = document.getElementById('emailsuffix');
 
var text = document.getElementById('emailtext');
 
  
var email = document.getElementById('emailobfuscated');
+
if(typeof(sets) != 'undefined' && sets !== null)
 
 
if(typeof(email) != 'undefined' && email !== null)
 
 
{
 
{
     if(typeof(user) != 'undefined' && user !== null && typeof(host) != 'undefined' && host !== null && typeof(suffix) != 'undefined' && suffix !== null)
+
     var i = 0, set;
 +
    while (set = sets[i++])
 
     {
 
     {
         var addr = user.innerHTML.replace(/^\s+|\s+$/g,'') + '@' + host.innerHTML.replace(/^\s+|\s+$/g,'') + '.' + suffix.innerHTML.replace(/^\s+|\s+$/g,'');
+
         var email = document.getElementById('nospam'+i);
        var link = addr;
+
 
         if(typeof(text) != 'undefined' && text !== null)
+
         if(typeof(email) != 'undefined' && email !== null)
 
         {
 
         {
             link = text.innerHTML.replace(/^\s+|\s+$/g,'');
+
             var user = document.getElementById('emailuser'+i);
 +
            var host = document.getElementById('emailhost'+i);
 +
            var suffix = document.getElementById('emailsuffix'+i);
 +
            var text = document.getElementById('emailtext'+i);
 +
 
 +
            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>';
 +
            }
 
         }
 
         }
        email.innerHTML = '<a href="mailto:' + addr + '">' + link + '</a>';
 
 
     }
 
     }
 
}
 
}

Version vom 25. Juni 2014, 23:09 Uhr

/* Ich verschleiere Email-Adressen zum Spamschutz */

var sets = document.getElementsByClassName('emailobfuscated');

if(typeof(sets) != 'undefined' && sets !== null)
{
    var i = 0, set;
    while (set = sets[i++])
    {
        var email = document.getElementById('nospam'+i);

        if(typeof(email) != 'undefined' && email !== null)
        {
            var user = document.getElementById('emailuser'+i);
            var host = document.getElementById('emailhost'+i);
            var suffix = document.getElementById('emailsuffix'+i);
            var text = document.getElementById('emailtext'+i);

            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>';
            }
        }
    }
}