User:Altales Teriadem/monobook.js

/* Small capitals */

addOnloadHook(function {        /* in general, replace anything in the content div with smallcaps... */        body = document.getElementById('content');        acronymRE = new RegExp('(^|[^</])\\b([A-Z0-9]{2,})\\b', 'g');        for (i = 0; i < body.length; i++)        {                c = body[i];                content = c.innerHTML;                content = content.replace(acronymRE, '$1 $2 ');                c.innerHTML = content;        }        /* ...but NOT in a URI... */        uriRE = new RegExp('(http|ftp|https):([^\\x20\\f\\n\\r\\t\\v]*) ([^\\x20\\f\\n\\r\\t\\v]+) ([^\\x20\\f\\n\\r\\t\\v]*)', 'g');        for(i = 0; i < body.length; i++)        {                c = body[i];                content = c.innerHTML;                content = content.replace(uriRE, '$1:$2$3$4');                c.innerHTML = content;        }        /* ...or in text boxes */        textareas = document.getElementsByTagName('textarea'); abbrRE = new RegExp(' (.*) ', 'g'); for(i = 0; i < textareas.length; i++) {               c = textareas[i]; content = c.innerHTML; content = content.replace(abbrRE, '$1'); c.innerHTML = content; }       inputs = document.getElementsByTagName('input'); for(i = 0; i < inputs.length; i++) {               c = inputs[i]; content = c.innerHTML; content = content.replace(abbrRE, '$1'); c.innerHTML = content; } });