OLD | NEW |
(Empty) | |
| 1 var hideElements = function() |
| 2 { |
| 3 // no need to invoke if already invoked on another event |
| 4 if ({{BRIDGE}}.isElementsHidden()) |
| 5 { |
| 6 {{DEBUG}} console.log('already hidden, exiting'); |
| 7 return; |
| 8 } |
| 9 |
| 10 // hide using element visibility (to be replaced with script body) |
| 11 {{HIDE}} |
| 12 |
| 13 {{BRIDGE}}.setElementsHidden(true); // set flag not to do it again |
| 14 }; |
| 15 |
| 16 if ({{BRIDGE}}.getAddDomListener() && document.readyState != 'complete') |
| 17 { |
| 18 {{BRIDGE}}.setAddDomListener(false); |
| 19 |
| 20 // onreadystatechange event |
| 21 document.onreadystatechange = function() |
| 22 { |
| 23 {{DEBUG}} console.log('onreadystatechange() event fired (' + document.readyS
tate + ')') |
| 24 if (document.readyState == 'interactive') |
| 25 { |
| 26 hideElements(); |
| 27 } |
| 28 } |
| 29 |
| 30 // load event |
| 31 window.addEventListener('load', function(event) |
| 32 { |
| 33 {{DEBUG}} console.log('load() event fired'); |
| 34 hideElements(); |
| 35 }); |
| 36 |
| 37 // DOMContentLoaded event |
| 38 document.addEventListener('DOMContentLoaded', function() |
| 39 { |
| 40 {{DEBUG}} console.log('DOMContentLoaded() event fired'); |
| 41 hideElements(); |
| 42 }, false); |
| 43 |
| 44 }; |
OLD | NEW |