//
// try a 'notifier' decorator
//
function notifier(handler_fn, callback_fn) {
// #helpers
function slc(args, i1, i2) {
return Array.prototype.slice.call(args, i1, i2);
}
function prepend(targetArr, arr) {
Array.prototype.unshift.apply(targetArr, arr);
return targetArr;
}
function thepush(targetArr, arr) {
Array.prototype.push.apply(targetArr, arr);
return targetArr;
}
return (function(cb, args1) {
var origfn = this;
return function() {
var
args = prepend(slc(arguments), args1),
out = origfn.apply(this, args);
cb.apply(this, thepush(args, [out]));
return out;
};
}).call(handler_fn, callback_fn, slc(arguments, 2));
}
var
handlerfn = function (e) {
var
T = e.type.toUpperCase();
(this instanceof Node) && (this.innerHTML = T);
return T;
},
F = notifier(
handlerfn,
function (f1_in, f1_out) {
var
v1 = f1_in;
v1.target.innerHTML += ', coords:[' + v1.clientX + ', ' + v1.clientY +']';
console.log(f1_in, ', ', f1_out);
}
);
document.getElementById('btn_01').onclick = F;
//
//