Jump to content

User:Dialectric/vector.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Dialectric (talk | contribs) at 02:24, 26 September 2020 (test). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
//------------------------------------------------------
// recolor test
// task: to override inline styles for some table elements to better fit dark theme
// status: testing only - do not use
//------------------------------------------------------
/*

function ready(callback){
    // in case the document is already rendered
    if (document.readyState!='loading') callback();
    // modern browsers
    else if (document.addEventListener) document.addEventListener('DOMContentLoaded', callback);
    // IE <= 8
    else document.attachEvent('onreadystatechange', function(){
        if (document.readyState=='complete') callback();
    });
}

ready(function(){
    // do something
        var target = document.querySelectorAll('div');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
        });
        var target = document.querySelectorAll('h2');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
        });
        var target = document.querySelectorAll('table');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
        });
        var target = document.querySelectorAll('th');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
        });
        var target = document.querySelectorAll('tr');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
        });
        for(i=0;i<target.length;i++){
          if(i%2==0) tblrows[i].style.backgroundColor = '#f22000';
          else tblrows[i].style.backgroundColor = '#a02141';
         }


        var target = document.querySelectorAll('td');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
         element.style.backgroundColor = "#222";
        });
        var target = document.querySelectorAll('caption');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
        });
});

*/

function ready(callback){
    // in case the document is already rendered
    if (document.readyState!='loading') callback();
    // modern browsers
    else if (document.addEventListener) document.addEventListener('DOMContentLoaded', callback);
    // IE <= 8
    else document.attachEvent('onreadystatechange', function(){
        if (document.readyState=='complete') callback();
    });
}

ready(function(){
        var target = document.querySelectorAll('div');
        Array.prototype.forEach.call(target, function(element){
         element.removeAttribute('style');
        });
        for(i=0;i<target.length;i++){
          [i].style.backgroundColor = '#000';
          [i].style.color = '#222';
         }
}