Jump to content

User:Joshurtree/test.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//<nowiki><pre>

function noRefSize() {
    var text = document.getElementById('wpTextbox1').value;
    var index = text.indexOf('<ref');
    var endIndex = 0;
    var size = 0;

    while (index != -1) {
        size += index - endIndex;
        endIndex = text.indexOf('</ref>', index) + 6;
        index = endIndex > 5 ? text.indexOf('<ref', endIndex) : -1;
    }

    size += text.length - text.lastIndexOf('</ref>') + 6;
    alert('Size of document without refs is ' + size / 1024 + 'k (' + text.length / 1024 + 'k)');
}

addOnloadHook(function() {
    addPortletLink('p-tb', 'javascript:noRefSize()', 'No Ref Size');
});
//</pre></nowiki>