JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<head>
<script src="fr.js"></script>
<title>trouble</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<script>
function mj(data) {
if(typeof(data) != 'object') {
if(!data) {
data = document.body;
} else {
if(data.substr(0,1) == '.') {
data = document.getElementsByClassName(data.substr(1,data.length));
} else if(data.substr(0,1) == '#') {
data = document.getElementById(data.substr(1,data.length));
} else {
data = document;
}
}
}
if(!data.oper) {
data.oper = new Operation(data);
}
return data.oper;
}
function Operation(data) {
this.obj = data;
/*if(data) {
if(typeof(data) === 'object') {
this.obj = data;
} else if(data.substr(0,1) == '.') {
this.obj = document.getElementsByClassName(data);
} else if(data.substr(0,1) == '#') {
this.obj = document.getElementById(data.substr(1,data.length));
} else {
this.obj = document.getElementsByTagName(data);
}
}*/
this.arrLaunch = {
onmousemove: [],
onclick: [],
onmousedown: [],
onmouseup: []
}
return this;
}
//binders
Operation.prototype = {
mousemove: function(func) {
var self = this;
this.arrLaunch['onmousemove'].push(func);
if(!this.obj.onmousemove) this.obj.onmousemove = function(e) { self.launch('onmousemove'); };
},
click: function(func) {
var self = this;
this.arrLaunch['onclick'].push(func);
if(!this.obj.onclick) this.obj.onclick = function(e) { self.launch('onclick'); };
},
mousedown: function(func) {
var self = this;
this.arrLaunch['onmousedown'].push(func);
if(!this.obj.onmousedown) this.obj.onmousedown = function(e) { self.launch('onmousedown'); };
},
mouseup: function(func) {
var self = this;
this.arrLaunch['onmouseup'].push(func);
if(!this.obj.onmouseup) this.obj.onmouseup = function(e) { self.launch('onmouseup'); };
...