Created
April 2, 2020 12:39
-
-
Save setapolo/e66457d87c230b6ff1e41c68386dc952 to your computer and use it in GitHub Desktop.
Closure Cascading event sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("hello,world"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<meta charset="utf-8"> | |
<html></html> | |
<script type="text/javascript"> | |
//CCas Closure Cascading v.0.03 2020/3/28 moka | |
var tags=function(s){ | |
return function(p){ | |
return function(a){ | |
var e = document.createElement(s); | |
e = Object.assign(e,a); | |
p.appendChild(e); | |
return e | |
} | |
} | |
} | |
var _ns_svg="http://www.w3.org/2000/svg"; | |
var tags2=function(s){ | |
return function(p){ | |
return function(a){ | |
var e = document.createElementNS(_ns_svg,s); | |
Object.keys(a).map(function(c,i){ | |
e.setAttribute(c,a[c]); | |
}) | |
p.appendChild(e); | |
return e | |
} | |
} | |
} | |
script=tags("script"); | |
div=tags("div"); | |
table=tags("table"); | |
tr=tags("tr"); | |
td=tags("td"); | |
svg=tags2("svg"); | |
circle=tags2("circle"); | |
var drag = null; | |
var eve=function(g){ | |
var f=function(c){ | |
var ff=function(){ | |
console.log(drag,Date.now(),arguments); | |
}; | |
ff=(c=="down")?function(e){ | |
drag=e; | |
}:ff; | |
ff=(c=="up")?function(e){ | |
drag=null; | |
}:ff; | |
ff=(c=="move")?function(e){ | |
(drag)?function(){ | |
drag.target.cx.baseVal.value=e.clientX; | |
drag.target.cy.baseVal.value=e.clientY; | |
}():0; | |
}:ff; | |
g[c]=ff; | |
return f; | |
}; | |
return f; | |
}; | |
eve(window)("click"); | |
eve(window)("down"); | |
eve(window)("move"); | |
eve(window)("up"); | |
(function (w,flg){ | |
return function(d,flg){ | |
var a={}; | |
var aa=[null]; | |
var aaa=[]; | |
var lv=[document.body]; | |
var k=null; | |
var parent=document.body; | |
var f= function(c){ | |
var _f = (typeof c=="function")?c:null; | |
(k==null)?(_f!=null)?function(){ | |
aaa.push(a); | |
aa.push(_f); | |
a={}; | |
}():0:0; | |
(c==null)?(function(){ | |
(a!=null)?(aaa.push(a)):0; | |
aa.map(function(cc,i){ | |
console.log("parent",lv[lv.length -1]) | |
parent = (cc!=null)?cc(lv[lv.length -1])(aaa[i]):document.body; | |
(parent != document.body)?lv.push(parent):0; | |
}); | |
lv.pop(); | |
console.log(lv); | |
aaa=[]; | |
aa=[null]; | |
})():0; | |
var v =(k != null)?c:null; | |
k=(typeof c=="string")?(k==null)?c:k:k; | |
((k!=null)&&(v!=null))?a[k]=v:0; | |
k=((k!=null)&&(v!=null))?null:k; | |
return f; | |
} | |
return f; | |
}; | |
})(window) | |
(document) | |
(script) | |
("type")("text/javascript") | |
("src")("cc.js")() | |
(div) | |
("innerHTML")("table Void") | |
("onclick")(click)() | |
(svg) | |
("height")("500") | |
("width")("500") | |
("onmousemove")("move(event)") | |
(circle) | |
("cx")("50") | |
("cy")("50") | |
("r")("40") | |
("fill")("red") | |
("stroke")("black") | |
("onmousedown")("down(event)") | |
("onmouseup")("up(event)")() | |
() | |
() | |
; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment