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