timer library using JavaScript - javascript

I have a timer library from EasyTimer.
Every time, i start my timer, it will start from 00:00:00
How do i make my timer to start timer from <?php echo $timer; ?>
For example start timer from 00:00.30.
$timer value comes from DB.
source code: https://albert-gonzalez.github.io/easytimer.js/#chronoHtml
PHP:
<!--Timer.Start-->
Timer:
<div id="chronoExample" class="input-group ng-isolate-scope ng-valid ng-dirty ng-valid-parse">
<?php if ($update == true): ?>
<div id="timer1" class="values form-control ng-valid ng-isolate-scope ng-dirty ng-touched"><?php echo $timer; ?></div>
<?php else: ?>
<div id="timer1" class="values form-control ng-valid ng-isolate-scope ng-dirty ng-touched">00:00:00</div>
<?php endif ?>
<div class="input-group-btn">
<button type="button" class="startButton btn btn-default">Start</button>
<button type="button" class="pauseButton btn btn-default">Pause</button>
<button type="button" class="resetButton btn btn-default">Reset</button>
</div>
</div>
<script src="javascript/easytimer.min.js"></script>
<script>
var timerInstance = new Timer();
</script>
<script src="javascript/easytimer.js"></script>
<input type="hidden" id="timerdata" name="timer">
<script>
function change() {
document.getElementById('timerdata').value = document.getElementById('timer1').textContent;
}
</script>
<!--Timer.End-->
Easytimer.js:
var timer = new Timer();
$('#chronoExample .startButton').click(function () {
timer.start();
});
$('#chronoExample .pauseButton').click(function () {
timer.pause();
});
$('#chronoExample .stopButton').click(function () {
timer.stop();
});
$('#chronoExample .resetButton').click(function () {
timer.reset();
});
timer.addEventListener('secondsUpdated', function (e) {
$('#chronoExample .values').html(timer.getTimeValues().toString());
});
timer.addEventListener('started', function (e) {
$('#chronoExample .values').html(timer.getTimeValues().toString());
});
timer.addEventListener('reset', function (e) {
$('#chronoExample .values').html(timer.getTimeValues().toString());
});
Easytimer.min.js:
!function (t, n) {
"object" == typeof exports && "undefined" != typeof module ? module.exports = n() : "function" == typeof define && define.amd ? define(n) : t.Timer = n()
}(this, function () {
"use strict";
function s(t, n, e) {
var o = void 0, i = "";
if (t.length > n) return t;
for (o = 0; o < n; o += 1) i += String(e);
return (i + t).slice(-i.length)
}
function P() {
this.secondTenths = 0, this.seconds = 0, this.minutes = 0, this.hours = 0, this.days = 0, this.toString = function (t, n, e) {
t = t || ["hours", "minutes", "seconds"], n = n || ":", e = e || 2;
var o = [], i = void 0;
for (i = 0; i < t.length; i += 1) void 0 !== this[t[i]] && ("secondTenths" === t[i] ? o.push(this[t[i]]) : o.push(s(this[t[i]], e, "0")));
return o.join(n)
}
}
var t = "undefined" != typeof window ? window.CustomEvent : void 0;
"undefined" != typeof window && "function" != typeof t && ((t = function (t, n) {
n = n || {bubbles: !1, cancelable: !1, detail: void 0};
var e = document.createEvent("CustomEvent");
return e.initCustomEvent(t, n.bubbles, n.cancelable, n.detail), e
}).prototype = window.Event.prototype, window.CustomEvent = t);
var q = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) {
return typeof t
} : function (t) {
return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t
}, I = "secondTenths", O = "seconds", z = "minutes", R = "hours", B = "days",
F = {secondTenths: 100, seconds: 1e3, minutes: 6e4, hours: 36e5, days: 864e5},
G = {secondTenths: 10, seconds: 60, minutes: 60, hours: 24},
H = "undefined" != typeof module && module.exports && "function" == typeof require ? require("events") : void 0;
function J() {
return "undefined" != typeof document
}
function K() {
return H
}
function N(t, n) {
return (t % n + n) % n
}
return function () {
var s = new P, r = new P, i = void 0,
e = J() ? document.createElement("span") : K() ? new H.EventEmitter : void 0, u = !1, d = !1, c = void 0,
a = void 0, f = void 0, v = {}, h = void 0, l = void 0, p = void 0, m = void 0, y = void 0, o = void 0,
b = {detail: {timer: this}};
function w(t, n) {
var e, o, i = r[n];
return o = U(t, F[e = n]), r[e] = o, s[e] = e === B ? o : 0 <= o ? N(o, G[e]) : G[e] - N(o, G[e]), r[n] !== i
}
function t() {
n(), function () {
for (var t in s) s.hasOwnProperty(t) && "number" == typeof s[t] && (s[t] = 0);
for (var n in r) r.hasOwnProperty(n) && "number" == typeof r[n] && (r[n] = 0)
}()
}
function n() {
clearInterval(i), i = void 0, d = u = !1
}
function g(t) {
var n, e, o;
M() ? (y = E(), l = V(h.target)) : (c = "string" == typeof(e = (e = t) || {}).precision ? e.precision : O, f = "function" == typeof e.callback ? e.callback : function () {
}, m = !0 === e.countdown, a = !0 === m ? -1 : 1, "object" === q(e.startValues) ? (o = e.startValues, p = L(o), s.secondTenths = p[0], s.seconds = p[1], s.minutes = p[2], s.hours = p[3], s.days = p[4], r = A(p, r)) : p = null, y = E(), S(), "object" === q(e.target) ? l = V(e.target) : m ? (e.target = {seconds: 0}, l = V(e.target)) : l = null, v = {
precision: c,
callback: f,
countdown: "object" === (void 0 === e ? "undefined" : q(e)) && !0 === e.countdown,
target: l,
startValues: p
}, h = e), n = F[c], C(j(Date.now())) || (i = setInterval(T, n), d = !(u = !0))
}
function E() {
return j(Date.now()) - r.secondTenths * F[I] * a
}
function T() {
var t, n = j(Date.now());
(t = S())[I] && k("secondTenthsUpdated", b), t[O] && k("secondsUpdated", b), t[z] && k("minutesUpdated", b), t[R] && k("hoursUpdated", b), t[B] && k("daysUpdated", b), f(b.detail.timer), C(n) && (D(), k("targetAchieved", b))
}
function S() {
var t = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : j(Date.now()),
n = 0 < a ? t - y : y - t, e = {};
return e[I] = w(n, I), e[O] = w(n, O), e[z] = w(n, z), e[R] = w(n, R), e[B] = w(n, B), e
}
function j(t) {
return Math.floor(t / F[c]) * F[c]
}
function C(t) {
return l instanceof Array && o <= t
}
function L(t) {
var n, e, o, i, s, r = void 0;
if ("object" === (void 0 === t ? "undefined" : q(t))) if (t instanceof Array) {
if (5 !== t.length) throw new Error("Array size not valid");
r = t
} else r = [t.secondTenths || 0, t.seconds || 0, t.minutes || 0, t.hours || 0, t.days || 0];
return n = r[0], e = r[1] + U(n, 10), o = r[2] + U(e, 60), i = r[3] + U(o, 60), s = r[4] + U(i, 24), r[0] = n % 10, r[1] = e % 60, r[2] = o % 60, r[3] = i % 24, r[4] = s, r
}
function U(t, n) {
var e = t / n;
return e < 0 ? Math.ceil(e) : Math.floor(e)
}
function V(t) {
if (t) {
var n = A(l = L(t));
return o = y + n.secondTenths * F[I] * a, l
}
}
function A(t, n) {
var e = n || {};
return e.days = t[4], e.hours = 24 * e.days + t[3], e.minutes = 60 * e.hours + t[2], e.seconds = 60 * e.minutes + t[1], e.secondTenths = 10 * e.seconds + t[[0]], e
}
function D() {
t(), k("stopped", b)
}
function k(t, n) {
J() ? e.dispatchEvent(new CustomEvent(t, n)) : K() && e.emit(t, n)
}
function x() {
return u
}
function M() {
return d
}
void 0 !== this && (this.start = function (t) {
x() || (g(t), k("started", b))
}, this.pause = function () {
n(), d = !0, k("paused", b)
}, this.stop = D, this.reset = function () {
t(), g(h), k("reset", b)
}, this.isRunning = x, this.isPaused = M, this.getTimeValues = function () {
return s
}, this.getTotalTimeValues = function () {
return r
}, this.getConfig = function () {
return v
}, this.addEventListener = function (t, n) {
J() ? e.addEventListener(t, n) : K() && e.on(t, n)
}, this.removeEventListener = function (t, n) {
J() ? e.removeEventListener(t, n) : K() && e.removeListener(t, n)
})
}
});

The EasyTimer.js Docs has an example of setting the start time.
Essentially, you just need to pass the start time to the timer object
<script>
var timerInstance = new Timer();
<?php if ($update == true): ?>
timerInstance.start({precision: 'seconds', startValues: <?php echo $timer; ?>});
<?php endif ?>
</script>
But you may have to change the way you store or echo the $timer in the <script> tag.

This is my final code, if someone need it.
Timer:
<div id="chronoExample" class="input-group ng-isolate-scope ng-valid ng-dirty ng-valid-parse">
<div class="days input-group-addon" id="id_days"><?php if ($update == true): ?><?php echo $days; ?><?php else: ?>0<?php endif ?></div>
<div class="hours input-group-addon" id="id_hours"><?php if ($update == true): ?><?php echo $hours; ?><?php else: ?>0<?php endif ?></div>
<div class="minutes input-group-addon" id="id_minutes"><?php if ($update == true): ?><?php echo $minutes; ?><?php else: ?>0<?php endif ?></div>
<div class="seconds input-group-addon" id="id_seconds"><?php if ($update == true): ?><?php echo $seconds; ?><?php else: ?>0<?php endif ?></div>
<div class="input-group-btn">
<button type="button" class="startButton btn btn-default">Start</button>
<button type="button" class="pauseButton btn btn-default">Pause</button>
<button type="button" class="resetButton btn btn-default">Reset</button>
</div>
</div>
<script src="javascript/easytimer.min.js"></script>
<script>
var timer = new Timer();
$('#chronoExample .startButton').click(function () {
timer.start({
precision: "seconds",
startValues: {seconds: <?php if ($update == true): ?><?php echo $total_seconds; ?><?php else: ?>0<?php endif ?>}
});
});
$('#chronoExample .pauseButton').click(function () {
timer.pause();
});
$('#chronoExample .stopButton').click(function () {
timer.stop();
});
$('#chronoExample .resetButton').click(function () {
timer.reset();
});
timer.addEventListener('secondsUpdated', function (e) {
$('#chronoExample .values').html(timer.getTimeValues().toString());
});
timer.addEventListener('started', function (e) {
$('#chronoExample .values').html(timer.getTimeValues().toString());
});
timer.addEventListener('reset', function (e) {
$('#chronoExample .values').html(timer.getTimeValues().toString());
});
timer.addEventListener('secondsUpdated', function (e) {
$('#chronoExample .days').html(timer.getTimeValues().days);
$('#chronoExample .hours').html(timer.getTimeValues().hours);
$('#chronoExample .minutes').html(timer.getTimeValues().minutes);
$('#chronoExample .seconds').html(timer.getTimeValues().seconds);
<!--Total Seconds -->
$('#gettingTotalValues .seconds').html(timer.getTotalTimeValues().seconds);
});
</script>

Related

the search bar does not display result

in the home page the search bar doesn't work by entering a keyword it goes into a loop and we don't display the list of search results from the console we display these errors advice to solve the problem, below is the code where we find the error if it helps
we think this is the code related to the problem, we await feedback and suggestions to solve the problem
try {
r.send(i.hasContent && i.data || null)
} catch (e) {
if (o) throw e
}
}, abort: function() {
o && o()
}
}
}), S.ajaxPrefilter(function(e) {
e.crossDomain && (e.contents.script = !1)
}), S.ajaxSetup({
accepts: {
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
},
contents: {
script: /\b(?:java|ecma)script\b/
},
converters: {
"text script": function(e) {
return S.globalEval(e), e
}
}
}), S.ajaxPrefilter("script", function(e) {
void 0 === e.cache && (e.cache = !1), e.crossDomain && (e.type = "GET")
}), S.ajaxTransport("script", function(n) {
var r, i;
if (n.crossDomain || n.scriptAttrs) return {
send: function(e, t) {
r = S("<script>").attr(n.scriptAttrs || {}).prop({
charset: n.scriptCharset,
src: n.url
}).on("load error", i = function(e) {
r.remove(), i = null, e && t("error" === e.type ? 404 : 200, e.type)
}), E.head.appendChild(r[0])
},
abort: function() {
i && i()
}
}
});
var Ut, Xt = [],
Vt = /(=)\?(?=&|$)|\?\?/;
S.ajaxSetup({
jsonp: "callback",
jsonpCallback: function() {
var e = Xt.pop() || S.expando + "_" + Ct.guid++;
return this[e] = !0, e
}
}), S.ajaxPrefilter("json jsonp", function(e, t, n) {
var r, i, o, a = !1 !== e.jsonp && (Vt.test(e.url) ? "url" : "string" == typeof e.data && 0 === (e.contentType || "").indexOf("application/x-www-form-urlencoded") && Vt.test(e.data) && "data");
if (a || "jsonp" === e.dataTypes[0]) return r = e.jsonpCallback = m(e.jsonpCallback) ? e.jsonpCallback() : e.jsonpCallback, a ? e[a] = e[a].replace(Vt, "$1" + r) : !1 !== e.jsonp && (e.url += (Et.test(e.url) ? "&" : "?") + e.jsonp + "=" + r), e.converters["script json"] = function() {
return o || S.error(r + " was not called"), o[0]
}, e.dataTypes[0] = "json", i = C[r], C[r] = function() {
o = arguments
}, n.always(function() {
void 0 === i ? S(C).removeProp(r) : C[r] = i, e[r] && (e.jsonpCallback = t.jsonpCallback, Xt.push(r)), o && m(i) && i(o[0]), o = i = void 0
}), "script"
}), v.createHTMLDocument = ((Ut = E.implementation.createHTMLDocument("").body).innerHTML = "<form></form><form></form>", 2 === Ut.childNodes.length), S.parseHTML = function(e, t, n) {
return "string" != typeof e ? [] : ("boolean" == typeof t && (n = t, t = !1), t || (v.createHTMLDocument ? ((r = (t = E.implementation.createHTMLDocument("")).createElement("base")).href = E.location.href, t.head.appendChild(r)) : t = E), o = !n && [], (i = N.exec(e)) ? [t.createElement(i[1])] : (i = xe([e], t, o), o && o.length && S(o).remove(), S.merge([], i.childNodes)));
var r, i, o
}, S.fn.load = function(e, t, n) {
var r, i, o, a = this,
s = e.indexOf(" ");
return -1 < s && (r = yt(e.slice(s)), e = e.slice(0, s)), m(t) ? (n = t, t = void 0) : t && "object" == typeof t && (i = "POST"), 0 < a.length && S.ajax({
url: e,
type: i || "GET",
dataType: "html",
data: t
}).done(function(e) {
o = arguments, a.html(r ? S("<div>").append(S.parseHTML(e)).find(r) : e)
}).always(n && function(e, t) {
a.each(function() {
n.apply(this, o || [e.responseText, t, e])
})
}), this
}, S.expr.pseudos.animated = function(t) {
return S.grep(S.timers, function(e) {
return t === e.elem
}).length
}, S.offset = {
setOffset: function(e, t, n) {
var r, i, o, a, s, u, l = S.css(e, "position"),
c = S(e),
f = {};
"static" === l && (e.style.position = "relative"), s = c.offset(), o = S.css(e, "top"), u = S.css(e, "left"), ("absolute" === l || "fixed" === l) && -1 < (o + u).indexOf("auto") ? (a = (r = c.position()).top, i = r.left) : (a = parseFloat(o) || 0, i = parseFloat(u) || 0), m(t) && (t = t.call(e, n, S.extend({}, s))), null != t.top && (f.top = t.top - s.top + a), null != t.left && (f.left = t.left - s.left + i), "using" in t ? t.using.call(e, f) : c.css(f)
}
}, S.fn.extend({
offset: function(t) {
if (arguments.length) return void 0 === t ? this : this.each(function(e) {
S.offset.setOffset(this, t, e)
});
var e, n, r = this[0];
return r ? r.getClientRects().length ? (e = r.getBoundingClientRect(), n = r.ownerDocument.defaultView, {
top: e.top + n.pageYOffset,
left: e.left + n.pageXOffset
}) : {
top: 0,
left: 0
} : void 0
},
position: function() {
if (this[0]) {
var e, t, n, r = this[0],
i = {
top: 0,
left: 0
};
if ("fixed" === S.css(r, "position")) t = r.getBoundingClientRect();
else {
t = this.offset(), n = r.ownerDocument, e = r.offsetParent || n.documentElement;
while (e && (e === n.body || e === n.documentElement) && "static" === S.css(e, "position")) e = e.parentNode;
e && e !== r && 1 === e.nodeType && ((i = S(e).offset()).top += S.css(e, "borderTopWidth", !0), i.left += S.css(e, "borderLeftWidth", !0))
}
return {
top: t.top - i.top - S.css(r, "marginTop", !0),
left: t.left - i.left - S.css(r, "marginLeft", !0)
}
}
},
offsetParent: function() {
return this.map(function() {
var e = this.offsetParent;
while (e && "static" === S.css(e, "position")) e = e.offsetParent;
return e || re
})
}
}), S.each({
scrollLeft: "pageXOffset",
scrollTop: "pageYOffset"
}, function(t, i) {
var o = "pageYOffset" === i;
S.fn[t] = function(e) {
return B(this, function(e, t, n) {
var r;
if (x(e) ? r = e : 9 === e.nodeType && (r = e.defaultView), void 0 === n) return r ? r[i] : e[t];
r ? r.scrollTo(o ? r.pageXOffset : n, o ? n : r.pageYOffset) : e[t] = n
}, t, e, arguments.length)
}
}), S.each(["top", "left"], function(e, n) {
S.cssHooks[n] = _e(v.pixelPosition, function(e, t) {
if (t) return t = Be(e, n), Pe.test(t) ? S(e).position()[n] + "px" : t
})
}), S.each({
Height: "height",
Width: "width"
}, function(a, s) {
S.each({
padding: "inner" + a,
content: s,
"": "outer" + a
}, function(r, o) {
S.fn[o] = function(e, t) {
var n = arguments.length && (r || "boolean" != typeof e),
i = r || (!0 === e || !0 === t ? "margin" : "border");
return B(this, function(e, t, n) {
var r;
return x(e) ? 0 === o.indexOf("outer") ? e["inner" + a] : e.document.documentElement["client" + a] : 9 === e.nodeType ? (r = e.documentElement, Math.max(e.body["scroll" + a], r["scroll" + a], e.body["offset" + a], r["offset" + a], r["client" + a])) : void 0 === n ? S.css(e, t, i) : S.style(e, t, n, i)
}, s, n ? e : void 0, n)
}
})
}), S.each(["ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend"], function(e, t) {
S.fn[t] = function(e) {
return this.on(t, e)
}
}), S.fn.extend({
bind: function(e, t, n) {
return this.on(e, null, t, n)
},
unbind: function(e, t) {
return this.off(e, null, t)
},
delegate: function(e, t, n, r) {
return this.on(t, e, n, r)
},
undelegate: function(e, t, n) {
return 1 === arguments.length ? this.off(e, "**") : this.off(t, e || "**", n)
},
hover: function(e, t) {
return this.mouseenter(e).mouseleave(t || e)
}
}), S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "), function(e, n) {
S.fn[n] = function(e, t) {
return 0 < arguments.length ? this.on(n, null, e, t) : this.trigger(n)
}
});
var Gt = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;
S.proxy = function(e, t) {
var n, r, i;
if ("string" == typeof t && (n = e[t], t = e, e = n), m(e)) return r = s.call(arguments, 2), (i = function() {
return e.apply(t || this, r.concat(s.call(arguments)))
}).guid = e.guid = e.guid || S.guid++, i
}, S.holdReady = function(e) {
e ? S.readyWait++ : S.ready(!0)
}, S.isArray = Array.isArray, S.parseJSON = JSON.parse, S.nodeName = A, S.isFunction = m, S.isWindow = x, S.camelCase = X, S.type = w, S.now = Date.now, S.isNumeric = function(e) {
var t = S.type(e);
return ("number" === t || "string" === t) && !isNaN(e - parseFloat(e))
}, S.trim = function(e) {
return null == e ? "" : (e + "").replace(Gt, "$1")
}, "function" == typeof define && define.amd && define("jquery", [], function() {
return S
});
var Yt = C.jQuery,
Qt = C.$;
return S.noConflict = function(e) {
return C.$ === S && (C.$ = Qt), e && C.jQuery === S && (C.jQuery = Yt), S
}, "undefined" == typeof e && (C.jQuery = C.$ = S), S
});
jQuery.noConflict();

How to add factorial calculation to a WordPress plugin by JavaScript?

I want to add factorial (n!) calculation to Calculated Fields Form WordPress plugin. I found out that module_public.js (in this direction: wp-content\plugins\calculated-fields-form\js\modules\01_mathematical_logical\public) contains the code for math operations and I added these codes, but they did not work (I can make a button for factorial by adding code to module_admin.js and the button works but I can't get the result).
Can anyone help me?
My codes that I added to line 209 in module_public.js:
if(window.FAC == undefined)
{
window.FAC = window.fac = function ()
{
var ans=1;
for (var i = 2; i <= FAC; i++)
ans = ans * i;
return ans;
};
} // End if window.FAC
original code of module_public.js:
fbuilderjQuery = ( typeof fbuilderjQuery != 'undefined' ) ? fbuilderjQuery : jQuery;
fbuilderjQuery[ 'fbuilder' ] = f
builderjQuery[ 'fbuilder' ] || {};
fbuilderjQuery[ 'fbuilder' ][ 'modules' ] = fbuilderjQuery[ 'fbuilder' ][ 'mo
dules' ] || {};
fbuilderjQuery[ 'fbuilder' ][ 'modules' ][ 'default' ] = {
'prefix' : '',
'callback' : function()
{
if(Number.prototype.LENGTH == undefined)
{
// Only LENGTH in uppercase to prevent a conflict with Lottie
Number.prototype.LENGTH = function(){return this.valueOf().toString().length;};
}
function ROUNDx(operation, num, y)
{
if(y && y != 0)
{
var r = operation(num/y)*y, p = (new String(y)).split('.');
if(p.length == 2) r = PREC(r,p[1].length);
return r;
}
else
{
return operation(num);
}
};
if(window.ROUND == undefined)
{
window.ROUND = window.round = function(num, y)
{
if(y) return ROUNDx(Math.round, num, y);
return ROUNDx(Math.round, num);
}
}
if(window.FLOOR == undefined)
{
window.FLOOR = window.floor = function(num, y)
{
if(y) return ROUNDx(Math.floor, num, y);
return ROUNDx(Math.floor, num);
}
}
if(window.CEIL == undefined)
{
window.CEIL = window.ceil = function(num, y)
{
if(y) return ROUNDx(Math.ceil, num, y);
return ROUNDx(Math.ceil, num);
}
}
if(window.PREC == undefined)
{
window.PREC = window.prec = function (num, pr)
{
if('undefined' == typeof pr) pr = 0;
if(/^\d+$/.test(pr) && $.isNumeric(num))
{
var f = POW(10,pr);
num = ROUND(num*f)/f;
return num.toFixed(pr);
}
return num;
};
} // End if window.PREC
if(window.CDATE == undefined)
{
window.CDATE = window.cdate = function ( num, format )
{
format = ( typeof format != 'undefined' ) ? format : ( ( typeof window.DATETIMEFORMAT != 'undefined' ) ? window.DATETIMEFORMAT : 'dd/mm/yyyy' );
if(isFinite(num*1))
{
num = Math.round(num*86400000);
var date = new Date(num),
d = date.getDate(),
m = date.getMonth()+1,
y = date.getFullYear(),
h = date.getHours(),
i = date.getMinutes(),
s = date.getSeconds(),
a = '';
m = (m < 10) ? '0'+m : m;
d = (d < 10) ? '0'+d : d;
if( /a/.test( format ) )
{
a = ( h >= 12 ) ? 'pm' : 'am';
h = h % 12;
h = ( h == 0 ) ? 12: h;
}
h = (h < 10) ? '0'+h : h;
i = (i < 10) ? '0'+i : i;
s = (s < 10) ? '0'+s : s;
return format.replace( /y+/i, y)
.replace( /m+/i, m)
.replace( /d+/i, d)
.replace( /h+/i, h)
.replace( /i+/i, i)
.replace( /s+/i, s)
.replace( /a+/i, a);
}
return num;
};
} // End if window.CDATE
if(window.SUM == undefined)
{
window.SUM = window.sum = function ()
{
var r = 0, t;
for(var i in arguments)
{
if(Array.isArray(arguments[i])) r += SUM.apply(this,arguments[i]);
else
{
t = arguments[i]*1;
if(!isNaN(t)) r += t;
}
}
return r;
};
} // End if window.SUM
if(window.CONCATENATE == undefined)
{
window.CONCATENATE = window.concatenate = function ()
{
var r = '';
for(var i in arguments)
if(Array.isArray(arguments[i])) r += CONCATENATE.apply(this,arguments[i]);
else r += (new String(arguments[i]));
return r;
};
} // End if window.CONCATENATE
if(window.AVERAGE == undefined)
{
window.AVERAGE = window.average = function ()
{
return SUM.apply(this,arguments)/arguments.length;
};
} // End if window.AVERAGE
if(window.GCD == undefined)
{
window.GCD = window.gcd = function( a, b)
{
if ( ! b) return a;
return GCD(b, a % b);
};
} // End if window.GCD
if(window.LCM == undefined)
{
window.LCM = window.lcm = function( a, b)
{
return (!a || !b) ? 0 : ABS((a * b) / GCD(a, b));
};
} // End if window.LCM
if(window.LOGAB == undefined)
{
window.LOGAB = window.logab = function( a, b)
{
return LOG(a)/LOG(b);
};
} // End if window.LOGAB
var math_prop = ["LN10", "PI", "E", "LOG10E", "SQRT2", "LOG2E", "SQRT1_2", "LN2", "cos", "pow", "log", "tan", "sqrt", "asin", "abs", "exp", "atan2", "atanh", "random", "acos", "atan", "sin"];
for(var i = 0, h = math_prop.length; i < h; i++)
{
if( !window[ math_prop[ i ] ] )
{
window[ math_prop[ i ] ] = window[ math_prop[ i ].toUpperCase() ] = Math[ math_prop[ i ] ];
}
}
if(window.MIN == undefined)
{
window.MIN = window.min = function ()
{
var l = [];
for(var i in arguments)
var l = l.concat(arguments[i]);
return Math.min.apply(this, l);
};
} // End if window.MIN
if(window.MAX == undefined)
{
window.MAX = window.max = function ()
{
var l = [];
for(var i in arguments)
var l = l.concat(arguments[i]);
return Math.max.apply(this, l);
};
} // End if window.MAX
if(window.RADIANS == undefined)
{
window.RADIANS = window.radians = function(a){ return a*PI/180;};
}
if(window.DEGREES == undefined)
{
window.DEGREES = window.degrees = function(a){ return a*180/PI;};
}
fbuilderjQuery[ 'fbuilder' ][ 'extend_window' ]( fbuilderjQuery[ 'fbuilder' ][ 'modules' ][ 'default' ][ 'prefix' ], CF_LOGICAL );
},
'validator' : function( v )
{
return ( typeof v == 'number' ) ? isFinite( v ) : ( typeof v != 'undefined' );
}
};
try to paste the code below!
fbuilderjQuery = ( typeof fbuilderjQuery != 'undefined' ) ? fbuilderjQuery : jQuery;
fbuilderjQuery[ 'fbuilder' ] = f
builderjQuery[ 'fbuilder' ] || {};
fbuilderjQuery[ 'fbuilder' ][ 'modules' ] = fbuilderjQuery[ 'fbuilder' ][ 'mo
dules' ] || {};
fbuilderjQuery[ 'fbuilder' ][ 'modules' ][ 'default' ] = {
'prefix' : '',
'callback' : function()
{
if(Number.prototype.LENGTH == undefined)
{
// Only LENGTH in uppercase to prevent a conflict with Lottie
Number.prototype.LENGTH = function(){return this.valueOf().toString().length;};
}
function ROUNDx(operation, num, y)
{
if(y && y != 0)
{
var r = operation(num/y)*y, p = (new String(y)).split('.');
if(p.length == 2) r = PREC(r,p[1].length);
return r;
}
else
{
return operation(num);
}
};
if(window.ROUND == undefined)
{
window.ROUND = window.round = function(num, y)
{
if(y) return ROUNDx(Math.round, num, y);
return ROUNDx(Math.round, num);
}
}
if(window.FLOOR == undefined)
{
window.FLOOR = window.floor = function(num, y)
{
if(y) return ROUNDx(Math.floor, num, y);
return ROUNDx(Math.floor, num);
}
}
if(window.CEIL == undefined)
{
window.CEIL = window.ceil = function(num, y)
{
if(y) return ROUNDx(Math.ceil, num, y);
return ROUNDx(Math.ceil, num);
}
}
if(window.PREC == undefined)
{
window.PREC = window.prec = function (num, pr)
{
if('undefined' == typeof pr) pr = 0;
if(/^\d+$/.test(pr) && $.isNumeric(num))
{
var f = POW(10,pr);
num = ROUND(num*f)/f;
return num.toFixed(pr);
}
return num;
};
} // End if window.PREC
if(window.CDATE == undefined)
{
window.CDATE = window.cdate = function ( num, format )
{
format = ( typeof format != 'undefined' ) ? format : ( ( typeof window.DATETIMEFORMAT != 'undefined' ) ? window.DATETIMEFORMAT : 'dd/mm/yyyy' );
if(isFinite(num*1))
{
num = Math.round(num*86400000);
var date = new Date(num),
d = date.getDate(),
m = date.getMonth()+1,
y = date.getFullYear(),
h = date.getHours(),
i = date.getMinutes(),
s = date.getSeconds(),
a = '';
m = (m < 10) ? '0'+m : m;
d = (d < 10) ? '0'+d : d;
if( /a/.test( format ) )
{
a = ( h >= 12 ) ? 'pm' : 'am';
h = h % 12;
h = ( h == 0 ) ? 12: h;
}
h = (h < 10) ? '0'+h : h;
i = (i < 10) ? '0'+i : i;
s = (s < 10) ? '0'+s : s;
return format.replace( /y+/i, y)
.replace( /m+/i, m)
.replace( /d+/i, d)
.replace( /h+/i, h)
.replace( /i+/i, i)
.replace( /s+/i, s)
.replace( /a+/i, a);
}
return num;
};
} // End if window.CDATE
if(window.SUM == undefined)
{
window.SUM = window.sum = function ()
{
var r = 0, t;
for(var i in arguments)
{
if(Array.isArray(arguments[i])) r += SUM.apply(this,arguments[i]);
else
{
t = arguments[i]*1;
if(!isNaN(t)) r += t;
}
}
return r;
};
} // End if window.SUM
if(window.CONCATENATE == undefined)
{
window.CONCATENATE = window.concatenate = function ()
{
var r = '';
for(var i in arguments)
if(Array.isArray(arguments[i])) r += CONCATENATE.apply(this,arguments[i]);
else r += (new String(arguments[i]));
return r;
};
} // End if window.CONCATENATE
if(window.AVERAGE == undefined)
{
window.AVERAGE = window.average = function ()
{
return SUM.apply(this,arguments)/arguments.length;
};
} // End if window.AVERAGE
if(window.GCD == undefined)
{
window.GCD = window.gcd = function( a, b)
{
if ( ! b) return a;
return GCD(b, a % b);
};
} // End if window.GCD
if(window.LCM == undefined)
{
window.LCM = window.lcm = function( a, b)
{
return (!a || !b) ? 0 : ABS((a * b) / GCD(a, b));
};
} // End if window.LCM
if(window.LOGAB == undefined)
{
window.LOGAB = window.logab = function( a, b)
{
return LOG(a)/LOG(b);
};
} // End if window.LOGAB
var math_prop = ["LN10", "PI", "E", "LOG10E", "SQRT2", "LOG2E", "SQRT1_2", "LN2", "cos", "pow", "log", "tan", "sqrt", "asin", "abs", "exp", "atan2", "atanh", "random", "acos", "atan", "sin"];
for(var i = 0, h = math_prop.length; i < h; i++)
{
if( !window[ math_prop[ i ] ] )
{
window[ math_prop[ i ] ] = window[ math_prop[ i ].toUpperCase() ] = Math[ math_prop[ i ] ];
}
}
if(window.MIN == undefined)
{
window.MIN = window.min = function ()
{
var l = [];
for(var i in arguments)
var l = l.concat(arguments[i]);
return Math.min.apply(this, l);
};
} // End if window.MIN
if(window.MAX == undefined)
{
window.MAX = window.max = function ()
{
var l = [];
for(var i in arguments)
var l = l.concat(arguments[i]);
return Math.max.apply(this, l);
};
} // End if window.MAX
if(window.FAC == undefined)
{
window.FAC = window.fac = function (num)
{
let sm=num;
if(num == 0)
return 1;
else{
for(let i=num-1; i>=1; i--){
sm *= (num-i);
console.log(sm);
}
return sm;
}
if(window.RADIANS == undefined)
{
window.RADIANS = window.radians = function(a){ return a*PI/180;};
}
if(window.DEGREES == undefined)
{
window.DEGREES = window.degrees = function(a){ return a*180/PI;};
}
fbuilderjQuery[ 'fbuilder' ][ 'extend_window' ]( fbuilderjQuery[ 'fbuilder' ][ 'modules' ][ 'default' ][ 'prefix' ], CF_LOGICAL );
},
'validator' : function( v )
{
return ( typeof v == 'number' ) ? isFinite( v ) : ( typeof v != 'undefined' );
}
};

JavaScript errors after changing HTML file directory

Having javascript errors after changing the directories of html files. In inspect mode each time when I scroll the page javascript errors keep increasing kindly help me out with this issue. Also have changed the javascript files directory. I am sharing an image of errors.
Directory of files
Here is the part which is having errors in Total.min.js
function e(y) {
var b, w, x, $ = !1;
function S(t, e) {
if (C.getComputedStyle || -1 === e.indexOf("%")) return e;
var i = t.style,
s = i.left,
n = t.runtimeStyle,
o = n && n.left;
return o && (n.left = t.currentStyle.left), i.left = e, e = i.pixelLeft, i.left = s, o && (n.left = o), e
}
return function(t) {
if (function() {
if (!$) {
$ = !0;
var i, e = C.getComputedStyle;
if (i = e ? function(t) {
return e(t, null)
} : function(t) {
return t.currentStyle
}, b = function(t) {
var e = i(t);
return e || T("Style returned " + e + "."), e
}, w = y("boxSizing")) {
var t = document.createElement("div");
t.style.width = "200px", t.style.padding = "1px 2px 3px 4px", t.style.borderStyle = "solid", t.style.borderWidth = "1px 2px 3px 4px", t.style[w] = "border-box";
var s = document.body || document.documentElement;
s.appendChild(t);
var n = b(t);
x = 200 === _(n.width), s.removeChild(t)
}
}
}(), "string" == typeof t && (t = document.querySelector(t)), t && "object" == typeof t && t.nodeType) {
var e = b(t);
if ("none" === e.display) return function() {
for (var t = {
width: 0,
height: 0,
innerWidth: 0,
innerHeight: 0,
outerWidth: 0,
outerHeight: 0
}, e = 0, i = I.length; e < i; e++) t[I[e]] = 0;
return t
}();
var i = {};
i.width = t.offsetWidth, i.height = t.offsetHeight;
for (var s = i.isBorderBox = !(!w || !e[w] || "border-box" !== e[w]), n = 0, o = I.length; n < o; n++) {
var a = I[n],
r = e[a];
r = S(t, r);
var l = parseFloat(r);
i[a] = isNaN(l) ? 0 : l
}
var h = i.paddingLeft + i.paddingRight,
c = i.paddingTop + i.paddingBottom,
d = i.marginLeft + i.marginRight,
u = i.marginTop + i.marginBottom,
p = i.borderLeftWidth + i.borderRightWidth,
f = i.borderTopWidth + i.borderBottomWidth,
m = s && x,
g = _(e.width);
!1 !== g && (i.width = g + (m ? 0 : h + p));
var v = _(e.height);
return !1 !== v && (i.height = v + (m ? 0 : c + f)), i.innerWidth = i.width - (h + p), i.innerHeight = i.height - (c + f), i.outerWidth = i.width + d, i.outerHeight = i.height + u, i
}
}
}
"function" == typeof define && define.amd ? define("get-size/get-size", ["get-style-property/get-style-property"], e) : "object" == typeof exports ? module.exports = e(require("desandro-get-style-property")) : C.getSize = e(C.getStyleProperty)
}(window),
function(e) {
var i = e.document,
s = [];
function n(t) {
"function" == typeof t && (n.isReady ? t() : s.push(t))
}
function o(t) {
var e = "readystatechange" === t.type && "complete" !== i.readyState;
n.isReady || e || a()
}
function a() {
n.isReady = !0;
for (var t = 0, e = s.length; t < e; t++) {
(0, s[t])()
}
}
function t(t) {
return "complete" === i.readyState ? a() : (t.bind(i, "DOMContentLoaded", o), t.bind(i, "readystatechange", o), t.bind(e, "load", o)), n
}
n.isReady = !1, "function" == typeof define && define.amd ? define("doc-ready/doc-ready", ["eventie/eventie"], t) : "object" == typeof exports ? module.exports = t(require("eventie")) : e.docReady = t(e.eventie)
}(window),
function(n) {
"use strict";
var t, i = function() {
if (n.matches) return "matches";
if (n.matchesSelector) return "matchesSelector";
for (var t = ["webkit", "moz", "ms", "o"], e = 0, i = t.length; e < i; e++) {
var s = t[e] + "MatchesSelector";
if (n[s]) return s
}
}();
Errors during inspecting site in console

Javascript - Jquery not displaying values passed in a form

I have found this bootstrap script that allows the user to enter a review.
Issue: i am trying to display the comment + Name and I'm getting undefined for comment and how could i display the stars selected by the user?
Also Is there a way to save the comment and name so it will display all the time after hitting submit button. (Without a database)
Here is my code
(function(e) {
var t, o = {
className: "autosizejs",
append: "",
callback: !1,
resizeDelay: 10
},
i = '<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; padding: 0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',
n = ["fontFamily", "fontSize", "fontWeight", "fontStyle", "letterSpacing", "textTransform", "wordSpacing", "textIndent"],
s = e(i).data("autosize", !0)[0];
s.style.lineHeight = "99px", "99px" === e(s).css("lineHeight") && n.push("lineHeight"), s.style.lineHeight = "", e.fn.autosize = function(i) {
return this.length ? (i = e.extend({}, o, i || {}), s.parentNode !== document.body && e(document.body).append(s), this.each(function() {
function o() {
var t, o;
"getComputedStyle" in window ? (t = window.getComputedStyle(u, null), o = u.getBoundingClientRect().width, e.each(["paddingLeft", "paddingRight", "borderLeftWidth", "borderRightWidth"], function(e, i) {
o -= parseInt(t[i], 10)
}), s.style.width = o + "px") : s.style.width = Math.max(p.width(), 0) + "px"
}
function a() {
var a = {};
if (t = u, s.className = i.className, d = parseInt(p.css("maxHeight"), 10), e.each(n, function(e, t) {
a[t] = p.css(t)
}), e(s).css(a), o(), window.chrome) {
var r = u.style.width;
u.style.width = "0px", u.offsetWidth, u.style.width = r
}
}
function r() {
var e, n;
t !== u ? a() : o(), s.value = u.value + i.append, s.style.overflowY = u.style.overflowY, n = parseInt(u.style.height, 10), s.scrollTop = 0, s.scrollTop = 9e4, e = s.scrollTop, d && e > d ? (u.style.overflowY = "scroll", e = d) : (u.style.overflowY = "hidden", c > e && (e = c)), e += w, n !== e && (u.style.height = e + "px", f && i.callback.call(u, u))
}
function l() {
clearTimeout(h), h = setTimeout(function() {
var e = p.width();
e !== g && (g = e, r())
}, parseInt(i.resizeDelay, 10))
}
var d, c, h, u = this,
p = e(u),
w = 0,
f = e.isFunction(i.callback),
z = {
height: u.style.height,
overflow: u.style.overflow,
overflowY: u.style.overflowY,
wordWrap: u.style.wordWrap,
resize: u.style.resize
},
g = p.width();
p.data("autosize") || (p.data("autosize", !0), ("border-box" === p.css("box-sizing") || "border-box" === p.css("-moz-box-sizing") || "border-box" === p.css("-webkit-box-sizing")) && (w = p.outerHeight() - p.height()), c = Math.max(parseInt(p.css("minHeight"), 10) - w || 0, p.height()), p.css({
overflow: "hidden",
overflowY: "hidden",
wordWrap: "break-word",
resize: "none" === p.css("resize") || "vertical" === p.css("resize") ? "none" : "horizontal"
}), "onpropertychange" in u ? "oninput" in u ? p.on("input.autosize keyup.autosize", r) : p.on("propertychange.autosize", function() {
"value" === event.propertyName && r()
}) : p.on("input.autosize", r), i.resizeDelay !== !1 && e(window).on("resize.autosize", l), p.on("autosize.resize", r), p.on("autosize.resizeIncludeStyle", function() {
t = null, r()
}), p.on("autosize.destroy", function() {
t = null, clearTimeout(h), e(window).off("resize", l), p.off("autosize").off(".autosize").css(z).removeData("autosize")
}), r())
})) : this
}
})(window.jQuery || window.$);
var __slice = [].slice;
(function(e, t) {
var n;
n = function() {
function t(t, n) {
var r, i, s, o = this;
this.options = e.extend({}, this.defaults, n);
this.$el = t;
s = this.defaults;
for (r in s) {
i = s[r];
if (this.$el.data(r) != null) {
this.options[r] = this.$el.data(r)
}
}
this.createStars();
this.syncRating();
this.$el.on("mouseover.starrr", "span", function(e) {
return o.syncRating(o.$el.find("span").index(e.currentTarget) + 1)
});
this.$el.on("mouseout.starrr", function() {
return o.syncRating()
});
this.$el.on("click.starrr", "span", function(e) {
return o.setRating(o.$el.find("span").index(e.currentTarget) + 1)
});
this.$el.on("starrr:change", this.options.change)
}
t.prototype.defaults = {
rating: void 0,
numStars: 5,
change: function(e, t) {}
};
t.prototype.createStars = function() {
var e, t, n;
n = [];
for (e = 1, t = this.options.numStars; 1 <= t ? e <= t : e >= t; 1 <= t ? e++ : e--) {
n.push(this.$el.append("<span class='glyphicon .glyphicon-star-empty'></span>"))
}
return n
};
t.prototype.setRating = function(e) {
if (this.options.rating === e) {
e = void 0
}
this.options.rating = e;
this.syncRating();
return this.$el.trigger("starrr:change", e)
};
t.prototype.syncRating = function(e) {
var t, n, r, i;
e || (e = this.options.rating);
if (e) {
for (t = n = 0, i = e - 1; 0 <= i ? n <= i : n >= i; t = 0 <= i ? ++n : --n) {
this.$el.find("span").eq(t).removeClass("glyphicon-star-empty").addClass("glyphicon-star")
}
}
if (e && e < 5) {
for (t = r = e; e <= 4 ? r <= 4 : r >= 4; t = e <= 4 ? ++r : --r) {
this.$el.find("span").eq(t).removeClass("glyphicon-star").addClass("glyphicon-star-empty")
}
}
if (!e) {
return this.$el.find("span").removeClass("glyphicon-star").addClass("glyphicon-star-empty")
}
};
return t
}();
return e.fn.extend({
starrr: function() {
var t, r;
r = arguments[0], t = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return this.each(function() {
var i;
i = e(this).data("star-rating");
if (!i) {
e(this).data("star-rating", i = new n(e(this), r))
}
if (typeof r === "string") {
return i[r].apply(i, t)
}
})
}
})
})(window.jQuery, window);
$(function() {
return $(".starrr").starrr()
})
$(function() {
$('#new-review').autosize({
append: "\n"
});
var reviewBox = $('#post-review-box');
var newReview = $('#new-review');
var openReviewBtn = $('#open-review-box');
var closeReviewBtn = $('#close-review-box');
var ratingsField = $('#ratings-hidden');
openReviewBtn.click(function(e) {
reviewBox.slideDown(400, function() {
$('#new-review').trigger('autosize.resize');
newReview.focus();
});
openReviewBtn.fadeOut(100);
closeReviewBtn.show();
});
closeReviewBtn.click(function(e) {
e.preventDefault();
reviewBox.slideUp(300, function() {
newReview.focus();
openReviewBtn.fadeIn(200);
});
closeReviewBtn.hide();
});
$('.starrr').on('starrr:change', function(e, value) {
ratingsField.val(value);
});
});
$(document).ready(function() {
$("#form").validate({
rules: {
firstname: "required",
comment: "required",
},
messages: {
firstname: "Please enter your first name",
comment: "Please enter your Comment",
}
});
$('#form').submit(function() {
if ($('#form').valid()) {
var str = '';
str += $('#firstname').val() + '<br />';
str += $('#comment').val() + '<br />';
$('.display').append(str);
}
return false;
});
});
.animated {
-webkit-transition: height 0.2s;
-moz-transition: height 0.2s;
transition: height 0.2s;
}
.stars {
margin: 20px 0;
font-size: 24px;
color: #d17581;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.0/jquery.validate.min.js"></script>
<div class="container">
<div class="row" style="margin-top:40px;">
<div class="col-md-6">
<div class="well well-sm">
<div class="text-right">
<a class="btn btn-success btn-green" href="#reviews-anchor" id="open-review-box">Leave a Review</a>
</div>
<div class="row" id="post-review-box" style="display:none;">
<div class="col-md-12">
<form id="form" accept-charset="UTF-8" action="" method="post">
<input type="text" class="form-control animated" name="firstname" id="firstname" type="hidden" placeholder="Enter your Name">
<br>
<input id="ratings-hidden" name="rating" type="hidden">
<textarea class="form-control animated" cols="50" id="new-review" name="comment" placeholder="Enter your review here..." rows="5"></textarea>
<div class="text-right">
<div class="stars starrr" data-rating="0"></div>
<a class="btn btn-danger btn-sm" href="#" id="close-review-box" style="display:none; margin-right: 10px;">
<span class="glyphicon glyphicon-remove"></span>Cancel</a>
<button class="btn btn-success btn-lg" type="submit">Save</button>
</div>
</form>
<div class="display"></div>
</div>
</div>
</div>
</div>
</div>
</div>
You can check the webiste here here
Since your javascript code says to select textarea with id comment
$('#form').submit(function() {
if ($('#form').valid()) {
var str = '';
str += $('#firstname').val() + '<br />';
str += $('#comment').val() + '<br />';
$('.display').append(str);
}
return false;
});
Change the id of textarea from new-review to comment
<textarea class="form-control animated" cols="50" id="comment" name="comment" placeholder="Enter your review here..." rows="5"></textarea>

Uncaught TypeError: Cannot read property 'getSelection' of null

I am using following code to simulate mouse click event on an element.
var composeEl = $('.asf.T-I-J3.J-J5-Ji:visible')[0];
if (composeEl) {
//Trigger mouse down event
var mouseDown = document.createEvent('MouseEvents');
mouseDown.initEvent('mousedown', true, false);
composeEl.dispatchEvent(mouseDown)
//Trigger mouse up event
var mouseUp = document.createEvent('MouseEvents');
mouseUp.initEvent('mouseup', true, false);
composeEl.dispatchEvent(mouseUp)
}
it works fine, its clicking but throw this error in console
Uncaught TypeError: Cannot read property 'getSelection' of null.
What is wrong with this javascript code?
Chrome show error in content.js file. I am not including this file.
error is on this line
var c=b.view.getSelection(); in below code
var m;if (!window.a) {
var t = function() {
var b = window.self === window.top;
this.k = (this.G = b) ? 0 : null;
this.s = this.d = !1;
this.j = this.i = -1;
this.F = 1;
this.c = {};
this.q = [];
var c = chrome.extension.connect({
name: b ? "top" : "sub"
});
this.a = c;
this.r = c.a || Math.ceil(975 * Math.random());
c.onMessage.addListener(this.onMessage.bind(this));
c.onDisconnect.addListener(this.v.bind(this));
this.b(window, "scroll", this.O, !0);
this.b(window, "keydown", this.u, !0);
this.b(window, "keyup", this.u, !0);
this.b(window, "mousedown", this.L, !0);
this.b(window, "mouseup",
this.M, !0);
this.b(window, "blur", this.K, !0);
this.b(document, "beforeload", this.I, !0);
this.b(document, "DOMContentLoaded", this.J);
b && this.b(window, "resize", this.N)
};
window.a = !0;
var x = {
16: !0,
17: !0,
18: !0,
45: !0,
46: !0
},
C = ["VIDEO", "AUDIO", "OBJECT", "EMBED"],
D = new RegExp(atob("eXRwbGF5ZXJcLmNvbmZpZ1xzKj1ccypcew=="));
m = t.prototype;
m.A = function(b, c, e, f) {
try {
var d = document.activeElement,
n = d && 0 <= C.indexOf(d.tagName) ? d : null;
n || (n = (d = document.elementFromPoint(this.i, this.j)) && 0 <= C.indexOf(d.tagName) ? d : null);
for (var k =
0, p, q, r, h, l = 0; l < C.length; l++) {
for (var g = document.getElementsByTagName(C[l]), w = 0; w < g.length; w++)
if (d = g[w], 3 != l || "application/x-shockwave-flash" == d.type.toLowerCase()) {
var s = d.src || d.data;
if (s && (s == b || s == c)) {
p = d;
break
}
if (!n && !q)
if (!s || s != e && s != f) {
var u = d.clientWidth,
v = d.clientHeight;
if (u && v) {
var y = d.getBoundingClientRect();
if (!(0 >= y.right + window.scrollX || 0 >= y.bottom + window.scrollY)) {
var z = window.getComputedStyle(d);
if (!z || "hidden" != z.visibility) {
var A = u * v;
A > k && 1.35 * u > v && u < 3 * v && (k = A, r = d);
h || (h = d)
}
}
}
} else q =
d
}
if (p) break
}
b = p || n || q || r || h;
if (!b) return null;
if ("EMBED" == b.tagName && !b.clientWidth && !b.clientHeight) {
var B = b.parentElement;
"OBJECT" == B.tagName && (b = B)
}
return this.g(b)
} catch (E) {}
};
m.w = function(b, c, e) {
try {
for (var f = [], d, f = Array.prototype.concat.apply(f, document.getElementsByTagName("FRAME")), f = Array.prototype.concat.apply(f, document.getElementsByTagName("IFRAME")), n = 0; n < f.length; n++) {
var k = f[n];
if (parseInt(k.getAttribute("__idm_frm__")) == b) {
d = k;
break
}
if (!d) {
var p = k.src;
!p || p != c && p != e || (d = k)
}
}
return this.g(d)
} catch (q) {}
};
m.p = function() {
var b = window.devicePixelRatio,
c = document.width,
e = document.body.scrollWidth;
c && e && (b = c == e ? 0 : c / e);
return b
};
m.n = function(b) {
try {
var c = b.getBoundingClientRect(),
e = Math.round(c.width),
f = Math.round(c.height);
if (15 > e || 15 > f) return null;
var d = document.documentElement,
n = d.scrollHeight || d.clientHeight,
k = Math.round(c.left) + b.clientLeft,
p = Math.round(c.top) + b.clientTop;
return k >= (d.scrollWidth || d.clientWidth) || p >= n ? null : {
left: k,
top: p,
right: k + e,
bottom: p + f,
zoom: this.p()
}
} catch (q) {}
};
m.o = function() {
this.a.postMessage([21,
window.location.href
])
};
m.f = function(b) {
if (b) {
if (!this.H) {
this.H = !0;
this.b(window, "message", this.P);
var c = document.createElement("script");
c.src = chrome.extension.getURL("document.js");
c.onload = function() {
c.parentNode.removeChild(c)
};
document.documentElement.appendChild(c)
}
window.setTimeout(function() {
window.postMessage([1], "/")
}, 3E3)
} else if ("loading" == document.readyState) this.t = !0;
else {
this.t = !1;
b = document.getElementsByTagName("SCRIPT");
for (var e = 0; e < b.length; e++)
if (c = b[e], !c.src && D.test(c.innerText)) {
b =
this.h();
this.a.postMessage([34, b, -1, c.outerHTML]);
break
}
}
};
m.P = function(b) {
var c = b.data;
c instanceof Array && b.origin == (document.origin || location.origin) && 2 == c[0] && this.a.postMessage([34, c[1], -1, c[2]])
};
m.D = function(b) {
var c = b[2] || this.w(b[3], b[4], b[5]),
e = c && this.c[c],
e = e && this.n(e);
this.a.postMessage([22, b[1], b[3], c, e])
};
m.C = function(b) {
var c = !b[2],
e = b[2] || this.A(b[3], b[4], b[5], b[6]);
b = [23, b[1], e, !1];
var f = e && this.c[e];
if (f) {
var d = this.n(f);
d && (b[4] = d);
c ? (b[5] = f.tagName, b[6] = f.src || f.data, b[7] = this.h()) :
d || document.contains(f) || (b[3] = !0, delete this.c[e])
}
this.a.postMessage(b)
};
m.g = function(b) {
try {
var c = parseInt(b.getAttribute("__idm_id__"));
c || (c = this.r << 10 | this.F++, b.setAttribute("__idm_id__", c));
this.c[c] = b;
return c
} catch (e) {}
};
m.h = function(b) {
var c;
try {
c = window.top.document.title
} catch (e) {}
if (c)
if (c = c.replace(/[ \t\r\n\u25B6]+/g, " ").trim(), b) this.a.postMessage([24, b, c]);
else return c
};
m.e = function(b) {
if (!this.l) {
var c = "\\b\\w+://(?:[%T]*(?::[%T]*)?#)?[%H.]+\\.[%H]+(?::\\d+)?(?:/(?:(?: +(?!\\w+:))?[%T/~;])*)?(?:\\?[%Q]*)?(?:#[%T]*)?".replace(/%\w/g,
function(b) {
return this[b]
}.bind({
"%H": "\\w\\-\u00a0-\ufeff",
"%T": "\\w\\-.+*()$!,%\u00a0-\ufeff",
"%Q": "^\\s\\[\\]{}()"
}));
this.l = new RegExp(c, "gi")
}
for (var e = []; c = this.l.exec(b);) e.push(c.shift());
return e
};
m.m = function(b, c, e) {
var f = [],
d = {},
n = "",
k = "",
p = !e,
q;
if (e && (q = b.getSelection(), !q || q.isCollapsed)) return f;
var r = b.getElementsByTagName("A");
if (r)
for (var h = 0; h < r.length; h++) {
var l = r[h];
if (l && (p || q.containsNode(l, !0))) {
var g = l.href;
g && !d[g] && c.test(g) && (d[g] = f.push([g, 2, l.innerText || l.title]));
e &&
d[g] && (n += l.innerText, n += "\n")
}
}
if (r = b.getElementsByTagName("AREA"))
for (h = 0; h < r.length; h++)(l = r[h]) && (p || q.containsNode(l, !0)) && (g = l.href) && !d[g] && c.test(g) && (d[g] = f.push([g, 2, l.alt]));
if (r = p && b.getElementsByTagName("IFRAME"))
for (h = 0; h < r.length; h++)(l = r[h]) && (p || q.containsNode(l, !0)) && (g = l.src) && !d[g] && c.test(g) && (d[g] = f.push([g, 4]));
if (h = e && q.toString())
for (l = this.e(h), n = this.e(n), h = 0; h < l.length; h++)(g = l[h]) && !d[g] && c.test(g) && 0 > n.indexOf(g) && (d[g] = f.push([g, 1]));
if (n = (p || !f.length) && b.getElementsByTagName("IMG"))
for (h =
0; h < n.length; h++)(l = n[h]) && (p || q.containsNode(l, !0)) && ((g = l.src) && !d[g] && c.test(g) && (d[g] = f.push([g, 3, "<<<=IDMTRANSMITIMGPREFIX=>>>" + l.alt])), p && l.onclick && (k += l.onclick, k += "\n"));
if (b = p && b.getElementsByTagName("SCRIPT")) {
for (h = 0; h < b.length; h++) k += b[h].innerText, k += "\n";
for (k = this.e(k); k.length;)(g = k.shift()) && !d[g] && c.test(g) && (d[g] = f.push([g, 5]))
}
return f
};
m.B = function(b, c) {
for (var e = this.m(document, b, c), f = document.getElementsByTagName("IFRAME"), d = Array.prototype.push, n = 0; n < f.length; n++) try {
var k =
f[n],
p = k.contentDocument;
p && !k.src && d.apply(e, this.m(p, b, c))
} catch (q) {}
return e
};
m.u = function(b) {
x[b.keyCode] && this.a.postMessage([31, b.keyCode, "keydown" == b.type])
};
m.L = function(b) {
this.s && this.a.postMessage([28]);
if (0 == b.button) {
var c = b.view.getSelection();
this.d = c && c.isCollapsed;
this.a.postMessage([32, b.button, !0])
}
};
m.M = function(b) {
if (0 == b.button && (this.i = b.clientX, this.j = b.clientY, this.a.postMessage([32, b.button, !1]), this.d)) {
this.d = !1;
var c = b.view.getSelection();
c && !c.isCollapsed && this.a.postMessage([26,
b.clientX, b.clientY, this.p()
])
}
};
m.K = function() {
this.d = !1;
this.a.postMessage([33])
};
m.O = function() {
this.a.postMessage([29])
};
m.N = function(b) {
b = b.target;
this.a.postMessage([30, b.innerWidth, b.innerHeight])
};
m.I = function(b) {
var c = b.target,
e = c.tagName;
0 <= C.indexOf(e) && b.url && (c = this.g(c), this.a.postMessage([25, c, e, b.url]))
};
m.J = function() {
this.t && this.f()
};
m.onMessage = function(b) {
switch (b[0]) {
case 11:
var c = b[2];
if (c) {
this.k = c;
try {
window.frameElement && window.frameElement.setAttribute("__idm_frm__", c)
} catch (e) {}
}
b[3] &&
this.o();
b[4] && this.f();
break;
case 17:
b[1] && this.o();
b[2] && this.f(!0);
break;
case 12:
var c = this.B(b[4] ? new RegExp(b[4], "i") : null, b[2]),
f = [27, b[1], this.k, c.length];
b[3] || (f[4] = c, f[5] = window.location.href, this.G && (f[6] = window.location.href, f[7] = document.title));
this.a.postMessage(f);
break;
case 13:
this.s = b[1];
break;
case 14:
this.h(b[1]);
break;
case 15:
this.C(b);
break;
case 16:
this.D(b)
}
};
m.b = function(b) {
var c = Array.prototype.slice.call(arguments);
c[2] = c[2].bind(this);
this.q.push(c);
b.addEventListener.apply(b,
c.slice(1))
};
m.v = function() {
for (var b; b = this.q.shift();) {
var c = b.shift();
c.removeEventListener.apply(c, b)
}
this.a = this.r = null;
window.a = !1
};
new t
};
It looks like one of your chrome extensions is throwing a javascript error. Please disable all of your chrome extensions and test. Especially disable Internet Download Manager if you have it installed.
Thanks Clayton Leis, I disabled the Internet Download Manager extension and error is gone. content script of idm extension was creating problem, Thanks again :).

Categories

Resources