stefan22
11/14/2017 - 11:14 PM

hides document body helps minimize flickering

hides document body helps minimize flickering

function checkifbodyexist() {
    //globals
    var adiv = document.createElement('div');
    adiv.id = 'main';
    var ap = document.createElement('p');
    ap.className = 'format';
    ap.innerHTML = "some text to see if it works";
    adiv.appendChild(ap);
    
    if (document.body === null) {
        setTimeout(function() {
            checkifbodyexist();
        }, 10);
    } else {
        document.body.style.opacity = 0;
    }
}

checkifbodyexist();



(function(global) {
   debugger;
   var SL = {};
    SL = {
        init: function(data) {
            this.mainCss();
            //this.addClass();
            //this.ajaxComplete();
            //this.attachBan();

        },
        mainCss: function(applyCss) {
            if (applyCss) {
                var style = document.createElement('style');
                style.type = "text/css";
                //enter styles here:
                style.innerHTML = ".noscript {background-color:#fff;color:#000;}\n";
                style.innerHTML += "body {}\n";
                style.innerHTML += ".main {width:500px; height:600px; border:1px solid black;}     \n";
                style.innerHTML +=  ".main {background-color:#080808; }";
                style.innerHTML += ".format {font-size:18px; font-weight:bold;}      \n";
                debugger;
                
                //append to head
                document.getElementsByTagName('head')[0].appendChild(style);
            }
        }
        // addCTA: function(e) {
        //     if (e !== undefined && e !== null) {

        //     }
        // },
        // hasClass: function(el, cls) {
        //     return el.className && new RegExp("(\\s|^)" + cls + "(\\s|$)").test(el.className);
        // },
        // addClass: function() {


           
        // },

        // attachBan: function() {
              
               
               


                        
                     
                



        // },
        


        // ajaxComplete: function() {
        //     $(document).ajaxComplete(function() {
        //         setTimeout(function() {
        //             console.log('something');
                    
        //         }, 500);

        //     });
        // }
    };



   

    SL.init();

    setTimeout(function() {
         document.body.style.opacity = 1;
     }, 500);
     debugger;

            

  


})(window);