Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var leafs = (function getLeafNodes(master) {
- var nodes = Array.prototype.slice.call(master.getElementsByTagName("*"), 0);
- var leafNodes = nodes.filter(function(elem) {
- return !elem.hasChildNodes() || elem.innerText!="";
- });
- return leafNodes;
- })(document);
- for(var i=0; i<leafs.length; i++) {
- var el = leafs[i];
- el.funOn = (Math.random()+0.1)*2;
- el.funOff = (Math.random()+0.1)*2;
- el.funT = 0;
- el.funState = el.style.visibility==="hidden"?"disabled":true;
- }
- var td = 100;
- function doFun() {
- for(var i=0; i<leafs.length; i++) {
- var el = leafs[i];
- el.funT+=td/1000;
- if(el.funT>=el.funOn && el.funState===true) {
- el.funT = 0;
- el.funState=false;
- el.style.visibility="hidden";
- }
- else if(el.funT>=el.funOff && el.funState===false) {
- el.funT = 0;
- el.funState=true;
- el.style.visibility="visible";
- }
- }
- setTimeout(doFun, td);
- }
- setTimeout(doFun, td);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement