Skip to content

Instantly share code, notes, and snippets.

@DanH42
Forked from ceci21/adding-in-javascript.js
Last active July 7, 2018 05:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanH42/9ef55a4aafe97f173b43e0c5f7eda877 to your computer and use it in GitHub Desktop.
Save DanH42/9ef55a4aafe97f173b43e0c5f7eda877 to your computer and use it in GitHub Desktop.
let's do math but with jQuery
(function($) {
$.fn.add = function(sep = " = ") {
(function($this) {
const re = /([0-9]+)/g;
const n1 = re.exec($this.text());
const n2 = re.exec($this.text());
if ((n1 && n2) === null) return function(){};
const a = parseInt(n1[0]);
const b = parseInt(n2[0]);
const y = b;
var n = 0;
let o, G, u, R = 0;
var Q = false;
return () =>
(function(x) {
var e = [].forEach(function() {
return Object.assign({}, { j: 7, c: Math.random() * this.j });
});
return {
func: function() {
const { v } = this;
let F = null,
B = 0,
d = null;
function bar(q) {
o = Math.pow;
return foo(q).k + F();
}
const foo = (t = (G) ? G : () => {}) => {
return ((z, s = 9) => {
this.q = z;
F = () =>
b - ((p = b, j = 1) => {
n = (a > 0) ?
Math.pow(a, !+[]+!+[] - !![]) :
((a === 0) ? 0 : -a);
e = function(W) {
let r = 0;
if (b > 0) {
r = o(b, 4) / o(b, 4) - W - 2;
} else if (b === 0) {
r = -W + o(b, 4) - o(b, 4) - 1;
} else if (b < 0) {
r = -(o(b, 4) / o(b, 4)) - W;
}
return r + W;
};
d = (lmnop, abcde = lmnop) => {
if (lmnop <= 1 && lmnop >= -1) {
return abcde;
}
return d((abcde < 0) ? abcde + 1 : abcde - 1);
};
G = t;
t();
return (j = p + 4 + (!!{} - Math.pow(256 / 1024, -1)));
})(z, u);
return this;
})(y);
u = a;
};
function biz() {
let w = n;
let H = (a === 1) ? b + 2 : 0;
if (bar(function() { if (Q) { B = u; Q = true; } })) {
const E = bar() + d(((y === 0 || y === 1) ? 12 : y), 12);
const J = -e(B) + y + R;
H = E + J;
}
return H + w - 1;
}
$this.append(sep + biz());
},
k: a + a - b - a + b,
v: Math.pow(2, 4)
}['func']();
})(a);
})($(this))();
}
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment