Export JS fuction to use in other JS not working - javascript

This is my the my js:
//aca Z
var Z = (function () {
var i = "#z-overlay {filter: alpha(opacity=50);opacity:0.5;display:inline-block;position:fixed;top:0;left:0;width:100%;height:100%;background-color: #000;z-index: 1001;}";
var u =
"#z-container {border:1px;float:left; overflow: visible; position: absolute;padding: 0px; display: inline-block; top:5%; left:34%; margin: 0 auto;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius:5px;background-color: #FAFAFA; border:1px solid #FAFAFA;border-top-color:#EDEDED;behavior: url(js/PIE.htc);z-index: 1002;}";
var h = "#z-data {height: 100%; outline: 0px; width: 100%; overflow: visible;display: inline-block;border:1px; -webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius:5px;}";
var t = "#reset{*, *:before, *:after {display: inline-block;-webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;}}";
var l = "#z_hppm_iframe {background-color: #FAFAFA;vertical-align:bottom;z-index:9999;display:block;padding:0px;margin: 0px; border:0px solid #DDD;}";
var e = "requestPage";
var d;
var s;
var c, o;
var b;
var n;
var w = ["tenantId", "id", "token", "signature", "key", "style", "submitEnabled", "url"];
var j = ["creditCardNumber", "cardSecurityCode", "creditCardExpirationYear", "creditCardExpirationMonth", "bankAccountNumber", "bankAccountName", "ipAddress", "achBankAccountNumber", "achBankABACode"];
var r = false;
var m = {};
var f = null;
var v = null;
function a(x) {
return x && typeof x === "function";
}
function p(x) {
var y = {};
for (var z in x) {
if (x.hasOwnProperty(z)) {
y[z] = x[z];
}
}
return y;
}
function k() {
if (s) {
s();
}
}
function g() {
s = null;
}
function q(x) {
if (x.currentStyle) {
return x.currentStyle.display != "none";
} else {
if (document.defaultView && document.defaultView.getComputedStyle) {
return document.defaultView.getComputedStyle(x, null).getPropertyValue("display") != "none";
} else {
return true;
}
}
}
ZXD.receiveMessage(function (y) {
try {
var x = y.data;
ZLOG.debug("Received message[O]: payload=" + x);
x = JSON.parse(x);
if (x.success) {
if (a(m.init)) {
m.init(x);
}
} else {
if (x.success == false) {
Z.deactivateOverlay("z-overlay");
Z.deactivateOverlay("z-container");
if (m.init) {
m.init(x);
}
} else {
if (x.action == "close") {
Z.deactivateOverlay("z-overlay");
Z.deactivateOverlay("z-container");
} else {
if (x.action == "resize") {
Z.receive(x);
} else {
if (x.action == "allowScroll") {
Z.allowScroll(x);
}
}
}
}
}
if (x.action === "validate" && a(m.validate)) {
m.validate(x);
} else {
if (x.action == "customizeErrorMessage" && a(m.customizeErrorMessage)) {
m.customizeErrorMessage(x.key, x.code, x.message, x.rawGatewayInfo);
} else {
if (x.action && a(m[x.action])) {
m[x.action](x);
}
}
}
} catch (z) {
return;
}
});
return {
validateRequiredParams: function (z) {
var x = w.length;
for (index = 0; index < x; index++) {
if (!z.hasOwnProperty(w[index])) {
if (w[index] == "submitEnabled" && z.style.toLowerCase() == "overlay") {
continue;
} else {
var y = "Param with key [" + w[index] + "] is required.";
alert(y);
if (!Z.isIE()) {
console.log(y);
}
return false;
}
}
}
return true;
},
isIE: function () {
var z = window.navigator.userAgent;
var y = z.indexOf("MSIE ");
var x = z.indexOf("Trident/");
if (y > 0) {
return true;
}
if (x > 0) {
var A = z.indexOf("rv:");
return true;
}
return false;
},
validatePCIParams: function (A) {
var x = j.length;
for (index = 0; index < x; index++) {
if (j[index] == "achBankAccountNumber" || j[index] == "achBankABACode") {
return true;
}
var y = "field_" + j[index];
if (A.hasOwnProperty(y)) {
if (0 < A[y].trim().length && A[y].trim().length < 300) {
var z = "Field [" + y + "] for Credit Card payment method type should be encrypted for pre-population";
alert(z);
if (!Z.isIE()) {
console.log(z);
}
return false;
}
}
}
return true;
},
init: function (C, D) {
c = "?method=requestPage&host=" + encodeURIComponent(document.location.href) + "&";
c = c + "fromHostedPage=true&";
var B = Z.validateRequiredParams(C);
if (!B) {
return false;
}
B = Z.validatePCIParams(C);
if (!B) {
return false;
}
var A = JSON.stringify(C, function (F, G) {
if (F != "") {
if ("key" == F) {
b = G;
} else {
if ("url" == F) {
var E = /^https:\/\/([a-z0-9]+(-[a-z0-9]+)*\.)+zuora\.com\/.+$/;
ZLOG.info("HPM integration[O]: url=" + G);
if (!E.test(G)) {
ZLOG.warn("HPM integration[O]: None-official zuora HPM integration url is detected: " + G);
}
d = G;
} else {
c = c + F + "=" + encodeURIComponent(G) + "&";
}
}
}
return G;
});
n = JSON.parse(A);
m.init = D;
var x = j.length;
if (C) {
for (var z = 0; z < x; z++) {
var y = "field_" + j[z];
if (C.hasOwnProperty(y)) {
C[y] = "";
}
}
}
return true;
},
prepopulate: function (z) {
if (threedRedirected) {
return;
}
var A = Z.createIframeURL();
if (A == document.getElementById(ifrmId).src || (document.getElementById(ifrmId).src.indexOf(A) >= 0 && n.hasOwnProperty("customizeErrorRequired") && n.customizeErrorRequired == "true")) {
var x = JSON.stringify(z, function (B, D) {
if (B != "") {
var C = "setField(" + B + ":" + D + ")";
Z.post(ifrmId, C);
}
return D;
});
var y = "setField(key:" + b + ")";
Z.post(ifrmId, y);
Z.post(ifrmId, "setField(style:" + n.style + ")");
if (n.hasOwnProperty("customizeErrorRequired") && n.customizeErrorRequired == "true") {
Z.post(ifrmId, "customizeErrorRequired");
n.customizeErrorRequired = "false";
}
}
},
contains: function (x, z) {
for (var y = 0; y < x.length; y++) {
if (x[y] === z) {
return true;
}
}
return false;
},
renderWithErrorHandler: function (B, D, C, y, z, x, A) {
B.customizeErrorRequired = "true";
Z.render(B, D, C, z, x);
Z.customizeErrorHandler(y);
Z.removeCoverHandler(A);
},
runAfterRender: function (x) {
s = x;
},
render: function (C, B, H, A, I) {
console.log('testRender');
if (A != null && A != undefined) {
f = A;
}
if (I != null && I != undefined) {
v = I;
}
f = Number(f);
v = Number(v);
f = isNaN(f) ? 0 : f;
v = isNaN(v) ? 0 : v;
var F = j.length;
threedRedirected = false;
if (B && B.creditCardCountry && (B.creditCardCountry === "USA" || B.creditCardCountry === "CAN")) {
B.creditCardState = B.creditCardState || " ";
}
if (B) {
for (index = 0; index < F; index++) {
var D = "field_" + j[index];
if (B.hasOwnProperty(j[index])) {
C[D] = B[j[index]];
}
}
}
var J = Z.init(C, H);
if (!J) {
return;
}
if (B) {
var F = Object.keys(B).length;
o = p(B);
for (index = 0; index < F; index++) {
var z = Object.keys(B)[index];
if (Z.contains(j, z)) {
delete o[z];
}
}
} else {
o = null;
}
var y = document.getElementById("zuora_payment");
if (typeof y == "undefined" || !y) {
return { error: "invalid_request", error_description: "The container you specified does not exist" };
}
y.innerHTML = "";
Z.cleanUp(y, "z-overlay");
Z.cleanUp(y, "z-container");
if (n.style == "inline") {
Z.addInlineStyles();
Z.createIframe(y);
return;
}
if (n.style == "overlay") {
Z.addOverlayStyles();
var x = Z.generateDiv("z-overlay", "z-overlay");
y.appendChild(x);
var E = Z.generateDiv("z-container", "z-container");
y.appendChild(E);
var G = Z.generateDiv("z-data", "z-data");
G.tabindex = "-1";
E.appendChild(G);
Z.createIframe(document.getElementById("z-data"));
Z.activateOverlay("z-overlay");
}
},
cleanUp: function (y, x) {
var z = document.getElementById(x);
if (z != null) {
y.removeChild(z);
}
},
activateOverlay: function (y) {
try {
document.getElementById(y).style.display = "inline";
} catch (x) {}
},
deactivateOverlay: function (y) {
try {
document.getElementById(y).style.display = "none";
} catch (x) {}
},
generateDiv: function (A, y, x) {
var z = document.createElement("div");
z.id = A;
z.className = y;
z.border = "0";
if (z.addEventListener) {
z.addEventListener("click", x, false);
} else {
z.attachEvent("click", x);
}
return z;
},
addOverlayStyles: function () {
var B = document.createElement("style");
B.type = "text/css";
var y = document.createTextNode(i);
var C = document.createTextNode(u);
var x = document.createTextNode(h);
var A = document.createTextNode(l);
var z = document.createTextNode(t);
if (B.styleSheet) {
B.styleSheet.cssText = y.nodeValue + " " + C.nodeValue + " " + x.nodeValue + " " + z.nodeValue + " " + A.nodeValue;
} else {
B.appendChild(y);
B.appendChild(C);
B.appendChild(x);
B.appendChild(A);
B.appendChild(z);
}
document.getElementsByTagName("head")[0].appendChild(B);
},
addInlineStyles: function () {
var y = document.createElement("style");
y.type = "text/css";
var x = document.createTextNode(l);
if (y.styleSheet) {
y.styleSheet.cssText = x.nodeValue;
} else {
y.appendChild(x);
}
document.getElementsByTagName("head")[0].appendChild(y);
},
createIframe: function (y) {
var A = Z.createIframeURL();
var z = document.createElement("iframe");
z.setAttribute("src", A);
z.setAttribute("id", ifrmId);
z.setAttribute("overflow", "visible");
z.setAttribute("scrolling", "no");
z.setAttribute("frameBorder", "0");
z.setAttribute("allowtransparency", "true");
z.setAttribute("class", "z_hppm_iframe");
z.setAttribute("width", "100%");
z.setAttribute("height", "0");
var x = false;
z.addEventListener(
"load",
function () {
Z.prepopulate(o);
k();
g();
function B() {
if (q(y)) {
Z.post(ifrmId, "resize");
if (a(m.onloadCallback)) {
m.onloadCallback();
}
} else {
window.requestAnimationFrame(B);
}
}
if (!x) {
window.requestAnimationFrame(B);
x = true;
}
return false;
},
false
);
if (typeof options != "undefined") {
if (typeof options.vertical != "undefined" && options.vertical) {
z.style.width = "100%";
z.style.height = "100%";
}
}
y.appendChild(z);
},
createIframeURL: function () {
var x = d;
return x.concat(c).concat("zlog_level=" + ZLOG.getLevel());
},
post: function (A, z) {
var x = document.getElementById(A);
var y = encodeURIComponent(document.location.href);
var B = x.src;
if (B.indexOf(y) <= -1) {
x.src = B + "#" + y;
}
ZXD.postMessage(z, B, x.contentWindow);
return false;
},
allowScroll: function (y) {
if (ifrmId) {
var x = document.getElementById(ifrmId);
if (x) {
x.setAttribute("scrolling", "yes");
threedRedirected = true;
}
}
},
receive: function (x) {
ZFB.resizeCaller(ifrmId, x.action, x.height, x.width, f, v);
},
validate: function (z) {
if (z == null || z == undefined) {
Z.closeWindow();
var y = "Validate function required.";
alert(y);
if (!Z.isIE()) {
console.log(y);
}
return false;
}
m.validate = z;
var x = "validate";
Z.post(ifrmId, x);
},
customizeErrorHandler: function (y) {
if (y == null || y == undefined) {
Z.closeWindow();
var x = "Customized error message function required.";
alert(x);
if (!Z.isIE()) {
console.log(x);
}
return false;
}
m.customizeErrorMessage = y;
},
removeCoverHandler: function (x) {
if (x == null || x == undefined) {
return false;
}
m.removeCover = x;
},
sendErrorMessageToHpm: function (A, z) {
var y = { action: "customizeErrorMessage", key: A, message: z };
var x = JSON.stringify(y);
Z.post(ifrmId, x);
},
closeWindow: function () {
Z.deactivateOverlay("z-overlay");
Z.deactivateOverlay("z-container");
},
submit: function () {
var x = document.getElementById(ifrmId).src + "#" + encodeURIComponent(document.location.href);
document.getElementById(ifrmId).src = x;
ZXD.postMessage("postPage", x, document.getElementById(ifrmId).contentWindow);
return true;
},
responseHandler: function (x) {
var y = x.redirectUrl;
if (x.success) {
var z = y + "?refId=" + x.refId + "&success=" + x.success + "&signature=" + x.signature + "&token=" + x.token;
window.location.replace(z);
} else {
var z = y + "?errorCode=" + x.errorCode + "&errorMessage=" + x.errorMessage + "&success=" + x.success + "&signature=" + x.signature + "&token=" + x.token;
window.location.replace(z);
}
},
setEventHandler: function (x, y) {
if (x && y) {
m[x] = y;
}
},
setAgreement: function (A, B, z, y) {
if (!Z.validateAgreement(A, B, z)) {
return false;
}
var x = "mitConsentAgreementSrc";
Z.setFieldValue(x, A);
x = "mitCredentialProfileType";
Z.setFieldValue(x, B);
x = "agreementSupportedBrands";
Z.setFieldValue(x, z);
x = "mitConsentAgreementRef";
Z.setFieldValue(x, y);
return true;
},
setFieldValue: function (x, z) {
var y = "setField(" + x + ":" + z + ")";
Z.post(ifrmId, y);
},
validateAgreement: function (y, z, x) {
if (Z.isEmpty(y) && Z.isEmpty(z) && Z.isEmpty(x)) {
return true;
}
if (Z.isEmpty(y)) {
Z.alertRequired("mitConsentAgreementSrc");
return false;
}
if (Z.isEmpty(z)) {
Z.alertRequired("mitProfileType");
return false;
}
if (Z.isEmpty(x)) {
Z.alertRequired("agreementSupportedBrands");
return false;
}
if (y != "External") {
Z.alertIllegal("mitConsentAgreementSrc");
return false;
}
if (z != "Recurring" && z != "Unscheduled") {
Z.alertIllegal("mitProfileType");
return false;
}
return true;
},
isEmpty: function (x) {
return !x || 0 === x.length;
},
alertRequired: function (y) {
var x = "Param mitConsentAgreementSrc, mitProfileType and agreementSupportedBrands for Z.setAgreement should be all empty or not empty. Param " + y + " is empty.";
alert(x);
},
alertIllegal: function (y) {
var x = "Param " + y + " for Z.setAgreement is illegal.";
alert(x);
},
};
})();
export {Z};
I'm trying to export the render function to use in other js that is in the same folder but is not working.
I tried: put export at the beginning of the function (photo) and I also tried
export {render} from './zouralibrary';
but in thiscase is thorow me: Unexpected compilation error: 'default' is not exported by zouralibrary.js, imported by paymentIframeTest.js (3:7)

Related

Refresh Code when Infinite Scroll Is Called

How to I call a JavaScript function when Tumblr's infinite scroll loads more posts?
I figure it would have to be some sort of listener function for when tumblrAutoPager.init us called. I found the infinite scroll code online and don't really understand it.
var tumblrAutoPager = {
url: "http://proto.jp/",
ver: "0.1.7",
rF: true,
gP: {},
pp: null,
ppId: "",
LN: location.hostname,
init: function () {
if ($("autopagerize_icon") || navigator.userAgent.indexOf('iPhone') != -1) return;
var tAP = tumblrAutoPager;
var p = 1;
var lh = location.href;
var lhp = lh.lastIndexOf("/page/");
var lht = lh.lastIndexOf("/tagged/");
if (lhp != -1) {
p = parseInt(lh.slice(lhp + 6));
tAP.LN = lh.slice(7, lhp);
} else if (lht != -1) {
tAP.LN = lh.slice(7);
if (tAP.LN.slice(tAP.LN.length - 1) == "/") tAP.LN = tAP.LN.slice(0, tAP.LN.length - 1);
} else if ("http://" + tAP.LN + "/" != lh) {
return;
};
var gPFncs = [];
gPFncs[0] = function (aE) {
var r = [];
for (var i = 0, l = aE.length; i < l; i++) {
if (aE[i].className == "autopagerize_page_element") {
r = gCE(aE[i]);
break;
}
}
return r;
};
gPFncs[1] = function (aE) {
var r = [];
for (var i = 0, l = aE.length; i < l; i++) {
var arr = aE[i].className ? aE[i].className.split(" ") : null;
if (arr) {
for (var j = 0; j < arr.length; j++) {
arr[j] == "post" ? r.push(aE[i]) : null;
}
}
}
return r;
};
gPFncs[2] = function (aE) {
var r = [];
var tmpId = tAP.ppId ? [tAP.ppId] : ["posts", "main", "container", "content", "apDiv2", "wrapper", "projects"];
for (var i = 0, l = aE.length; i < l; i++) {
for (var j = 0; j < tmpId.length; j++) {
if (aE[i].id == tmpId[j]) {
r = gCE(aE[i]);
tAP.ppId = aE[i].id;
break;
}
}
}
return r;
};
for (var i = 0; i < gPFncs.length; i++) {
var getElems = gPFncs[i](document.body.getElementsByTagName('*'));
if (getElems.length) {
tAP.gP = gPFncs[i];
tAP.pp = getElems[0].parentNode;
break;
}
}
function gCE(pElem) {
var r = [];
for (var i = 0, l = pElem.childNodes.length; i < l; i++) {
r.push(pElem.childNodes.item(i))
}
return r;
}
if (!tAP.pp) {
return;
}
sendRequest.README = {
license: 'Public Domain',
url: 'http://jsgt.org/lib/ajax/ref.htm',
version: 0.516,
author: 'Toshiro Takahashi'
};
function chkAjaBrowser() {
var A, B = navigator.userAgent;
this.bw = {
safari: ((A = B.split('AppleWebKit/')[1]) ? A.split('(')[0].split('.')[0] : 0) >= 124,
konqueror: ((A = B.split('Konqueror/')[1]) ? A.split(';')[0] : 0) >= 3.3,
mozes: ((A = B.split('Gecko/')[1]) ? A.split(' ')[0] : 0) >= 20011128,
opera: ( !! window.opera) && ((typeof XMLHttpRequest) == 'function'),
msie: ( !! window.ActiveXObject) ? ( !! createHttpRequest()) : false
};
return (this.bw.safari || this.bw.konqueror || this.bw.mozes || this.bw.opera || this.bw.msie)
}
function createHttpRequest() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest()
} else {
if (window.ActiveXObject) {
try {
return new ActiveXObject('Msxml2.XMLHTTP')
} catch (B) {
try {
return new ActiveXObject('Microsoft.XMLHTTP')
} catch (A) {
return null
}
}
} else {
return null
}
}
};
function sendRequest(E, R, C, D, F, G, S, A) {
var Q = C.toUpperCase() == 'GET',
H = createHttpRequest();
if (H == null) {
return null
}
if ((G) ? G : false) {
D += ((D.indexOf('?') == -1) ? '?' : '&') + 't=' + (new Date()).getTime()
}
var P = new chkAjaBrowser(),
L = P.bw.opera,
I = P.bw.safari,
N = P.bw.konqueror,
M = P.bw.mozes;
if (typeof E == 'object') {
var J = E.onload;
var O = E.onbeforsetheader
} else {
var J = E;
var O = null
}
if (L || I || M) {
H.onload = function () {
J(H);
H.abort()
}
} else {
H.onreadystatechange = function () {
if (H.readyState == 4) {
J(H);
H.abort()
}
}
}
R = K(R, D);
if (Q) {
D += ((D.indexOf('?') == -1) ? '?' : (R == '') ? '' : '&') + R
}
H.open(C, D, F, S, A);
if ( !! O) {
O(H)
}
B(H);
H.send(R);
function B(T) {
if (!L || typeof T.setRequestHeader == 'function') {
T.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8')
}
return T
}
function K(X, V) {
var Z = [];
if (typeof X == 'object') {
for (var W in X) {
Y(W, X[W])
}
} else {
if (typeof X == 'string') {
if (X == '') {
return ''
}
if (X.charAt(0) == '&') {
X = X.substring(1, X.length)
}
var T = X.split('&');
for (var W = 0; W < T.length; W++) {
var U = T[W].split('=');
Y(U[0], U[1])
}
}
}
function Y(b, a) {
Z.push(encodeURIComponent(b) + '=' + encodeURIComponent(a))
}
return Z.join('&')
}
return H
}
function addNextPage(oj) {
if (oj.status == 404) {
tAP.remainFlg = false;
return;
}
var d = document.createElement("div");
d.innerHTML = oj.responseText;
var posts = tAP.gP(d.getElementsByTagName("*"));
if (posts.length < 2) {
tAP.rF = false;
return;
}
d = document.createElement("div");
d.className = "tumblrAutoPager_page_info";
tAP.pp.appendChild(d);
for (var i = 0; i < posts.length; i++) {
tAP.pp.appendChild(posts[i]);
}
var footer = $("footer");
footer ? footer.parentNode.appendChild(footer) : null;
tAP.rF = true;
}
watch_scroll();
function watch_scroll() {
var d = document.compatMode == "BackCompat" ? document.body : document.documentElement;
var r = d.scrollHeight - d.clientHeight - (d.scrollTop || document.body.scrollTop);
if (r < d.clientHeight * 2 && tAP.rF) {
tAP.rF = false;
p++;
sendRequest(addNextPage, "", "GET", "http://" + tAP.LN + "/page/" + p, true);
}
setTimeout(arguments.callee, 200);
};
function $(id) {
return document.getElementById(id)
};
},
switchAutoPage: function () {
this.rF = !this.rF;
var aE = document.getElementsByTagName('*');
for (var i = 0, l = aE.length; i < l; i++) {
if (aE[i].className == "tAP_switch") {
aE[i].firstChild.nodeValue = this.rF ? "AutoPage[OFF]" : "AutoPage[ON]";
}
}
}
};
window.addEventListener ? window.addEventListener('load', tumblrAutoPager.init, false) : window.attachEvent ? window.attachEvent("onload", tumblrAutoPager.init) : window.onload = tumblrAutoPager.init;

Function Conflict with Jquery.min.js

currently working on metal website so i need unit conversion tool like in this site
http://www.theunitconverter.com/unit-conversion-widget.html
i try add the code, but its not working.
and its working when i remove this
<script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
the problem is i need those min.js script for another jquery function.
and i try to add the javascript converter to another file but i couldn't place the correct noconflict function. the js goes like this.
function IsNum(a) {
if (a != null && a != "") {
return !isNaN(a)
}
return false
}
function $(b) {
if (typeof b == "string") {
return document.getElementById(b)
}
return b
}
function v(g) {
var f = $("a").value;
var e = $("b").value;
var j = $("c").value;
var h = $("d").value;
if (g == 0) {
if (!IsNum(f)) {
return false
}
$("c").value = $("a").value * h / e
} else {
if (!IsNum(j)) {
return false
}
$("a").value = $("c").value * e / h
}
}
function o(a) {
var j = $("e").value;
var d = $("f").value;
var c = $("g").value;
var b = $("h").value;
if (a == 0) {
if (!IsNum(j)) {
return false
}
$("g").value = $("e").value * b / d
} else {
if (!IsNum(c)) {
return false
}
$("e").value = $("g").value * d / b
}
}
function r(x) {
var q;
var p;
var ub;
var ud;
var s;
if (x == 1) {
ub = $("b");
ud = $("d");
ua = $("a");
uc = $("c");
s = $("u").value
} else {
ub = $("f");
ud = $("h");
ua = $("e");
uc = $("g");
s = $("s").value
}
var f = eval(s + "f");
var t = eval(s + "t");
var u0 = eval(s + "0");
var u1 = eval(s + "1");
var amount = eval(u0)[t] / eval(u0)[f];
var z = 0;
for (var n in u) {
if (s == u[n]) {
z = 1
}
}
ua.value = "1";
uc.value = amount;
ub.options.length = 0;
ud.options.length = 0;
if (z == 1) {
var o = new Option("Common units", "0");
o.disabled = "false";
var r = new Option("Common units", "0");
r.disabled = "false";
ub.add(o);
ud.add(r);
for (var n in u0) {
p = new Option(n, u0[n]);
if (n == f) {
p.selected = "true"
}
q = new Option(n, u0[n]);
if (n == t) {
q.selected = "true"
}
ub.add(p);
ud.add(q)
}
o = new Option("Other units", "0");
o.disabled = "false";
r = new Option("Other units", "0");
r.disabled = "false";
ub.add(o);
ud.add(r);
for (var n in u1) {
p = new Option(n, u1[n]);
q = new Option(n, u1[n]);
ub.add(p);
ud.add(q)
}
} else {
for (var n in u0) {
p = new Option(n, u0[n]);
q = new Option(n, u0[n]);
if (n == f) {
p.selected = "true"
}
q = new Option(n, u0[n]);
if (n == t) {
q.selected = "true"
}
ub.add(p);
ud.add(q)
}
}
};
Thanks for any kind of help.
Wrap everything inside
(function($) {
...
})(jQuery);
Your code should be
(function($) {
function IsNum(a) {
if (a != null && a != "") {
return !isNaN(a)
}
return false
}
function $(b) {
if (typeof b == "string") {
return document.getElementById(b)
}
return b
}
function v(g) {
var f = $("a").value;
var e = $("b").value;
var j = $("c").value;
var h = $("d").value;
if (g == 0) {
if (!IsNum(f)) {
return false
}
$("c").value = $("a").value * h / e
} else {
if (!IsNum(j)) {
return false
}
$("a").value = $("c").value * e / h
}
}
function o(a) {
var j = $("e").value;
var d = $("f").value;
var c = $("g").value;
var b = $("h").value;
if (a == 0) {
if (!IsNum(j)) {
return false
}
$("g").value = $("e").value * b / d
} else {
if (!IsNum(c)) {
return false
}
$("e").value = $("g").value * d / b
}
}
function r(x) {
var q;
var p;
var ub;
var ud;
var s;
if (x == 1) {
ub = $("b");
ud = $("d");
ua = $("a");
uc = $("c");
s = $("u").value
} else {
ub = $("f");
ud = $("h");
ua = $("e");
uc = $("g");
s = $("s").value
}
var f = eval(s + "f");
var t = eval(s + "t");
var u0 = eval(s + "0");
var u1 = eval(s + "1");
var amount = eval(u0)[t] / eval(u0)[f];
var z = 0;
for (var n in u) {
if (s == u[n]) {
z = 1
}
}
ua.value = "1";
uc.value = amount;
ub.options.length = 0;
ud.options.length = 0;
if (z == 1) {
var o = new Option("Common units", "0");
o.disabled = "false";
var r = new Option("Common units", "0");
r.disabled = "false";
ub.add(o);
ud.add(r);
for (var n in u0) {
p = new Option(n, u0[n]);
if (n == f) {
p.selected = "true"
}
q = new Option(n, u0[n]);
if (n == t) {
q.selected = "true"
}
ub.add(p);
ud.add(q)
}
o = new Option("Other units", "0");
o.disabled = "false";
r = new Option("Other units", "0");
r.disabled = "false";
ub.add(o);
ud.add(r);
for (var n in u1) {
p = new Option(n, u1[n]);
q = new Option(n, u1[n]);
ub.add(p);
ud.add(q)
}
} else {
for (var n in u0) {
p = new Option(n, u0[n]);
q = new Option(n, u0[n]);
if (n == f) {
p.selected = "true"
}
q = new Option(n, u0[n]);
if (n == t) {
q.selected = "true"
}
ub.add(p);
ud.add(q)
}
}
};
})(jQuery);

Make a Section take up full screen

in my html code, i have the following:
<section id="cta">
.......
</section>
<!-- Footer -->
<footer id="footer">
......
</footer>
How do i actually make my section take up the whole screen when the page loads, whereas the footer actually goes down to a scrollbar. Note that this has to be dynamic since different computers have different screen sizes, i know of the height 100% trick, but in my case there are multiple elements, and is it possible to make a specific one take up the whole screen whereas the other one can be accessed via scroll?
Thanks!
I actually tried removing a js script, and it worked, so i suspect its some css defined inside the js script, but i cant seem to find which is the conflicting css, i tried to add !important to my current css, but it does not overide the one in the js script.
Here is the JS script:
/* skel-layers.js v1.0.4 | (c) n33 | getskel.com | MIT licensed */
(function(e) {
typeof define == "function" && define.amd ? define(["jquery", "skel"], e) : e(jQuery, skel)
})(function(e, t) {
...
...
}
var t;
return typeof e == gt ? H : (e.fn[p] = function() {
var t, n;
if (this[z] > 1) {
for (t = 0; t < this[z]; t++) e(this[t])[p]();
return e(this)
}
return n = e(this), n[S](it, n.data(A)).data(A, ""), n
}, e.fn[Ct] = function() {
var t = e(this),
n = t.parent(),
r = 12;
n[M]().each(function() {
var t = e(this),
n = t[Lt]("class");
n && n.match(/(\s+|^)([0-9]+)u(\s+|$)/) && (r -= parseInt(RegExp.$2))
}), r > 0 && (t[ct](), t[S](E, (t.data(Jt) + r) / 12 * 100 + "%"))
}, e.fn[Ot] = function() {
return e(this).parents()[z] > 0
}, e.fn[ct] = function() {
var t = e(this);
t[Lt]("class").match(/(\s+|^)([0-9]+)u(\s+|$)/) && t.data(Jt, parseInt(RegExp.$2))
}, e.fn[c] = function(r) {
var i, s, o;
if (this[z] > 1) {
for (i = 0; i < this[z]; i++) e(this[i])[c](r);
return e(this)
}
return s = e(this), isNaN(o = parseInt(s.data(ot))) && (o = 0), s.data(A, s[S](it))[S](it, t[n].baseZIndex + o + (r ? r : 1)), s
}, e.fn[u] = function() {
var t = e(this);
return e(this)[At]("form").each(function() {
this.reset()
}), t
}, e.fn[qt] = function(t, n) {
return e(this)[S](t, n)[S](Tt + t, Tt + n)[S](K + t, K + n)[S](Rt + t, Rt + n)[S](Dt + t, Dt + n)
}, e.fn._skel_layers_xcssProperty = function(t, n) {
return e(this)[S](t, n)[S](Tt + t, n)[S](K + t, n)[S](Rt + t, n)[S](Dt + t, n)
}, e.fn._skel_layers_xcssValue = function(t, n) {
return e(this)[S](t, n)[S](t, Tt + n)[S](t, K + n)[S](t, Rt + n)[S](t, Dt + n)
}, Nn[C][lt] = {
none: {
show: function(e) {
var t = e[n],
r = e[h];
r[B](0)[c](t.zIndex)[nn](), t[$] && r[u](), e[d]()
},
hide: function(e) {
var t = e[n],
r = e[h];
r[It]()[p](), e[m]()
}
},
overlayX: {
show: function(e) {
var r = e[n],
i = e[h];
i[B](0)[c](r.zIndex)[S](r[en], Gt + t[Q](t._[w](r[E])) + Qt)[nn](), r[$] && i[u](), t[Ht](sn), e[d](), window[v](function() {
i[s]((r[en] == g ? Gt : "") + t[Q](t._[w](r[E])), 0)
}, 50)
},
hide: function(e) {
var i = e[n],
s = e[h];
s[At](an)[Xt](Nt, [J]), s[r](), window[v](function() {
t[ft](sn), e[m](), s[p]()[It]()
}, t[n][dt] + 50)
}
},
overlayY: {
show: function(e) {
var r = e[n],
i = e[h];
i[B](0)[c](r.zIndex)[S](r[en], Gt + t[Q](t._[w](r[U])) + Qt)[nn](), r[$] && i[u](), t[Ht]("y"), e[d](), window[v](function() {
i[s](0, (r[en] == y ? Gt : "") + t[Q](t._[w](r[U])))
}, 50)
},
hide: function(e) {
var i = e[n],
s = e[h];
s[At](an)[Xt](Nt, [J]), s[r](), window[v](function() {
t[ft]("y"), e[m](), s[p]()[It]()
}, t[n][dt] + 50)
}
},
pushX: {
show: function(e) {
var r = e[n],
a = e[h],
f = t[i][L].add(t[i][o][M]());
a[B](0)[S](r[en], Gt + t[Q](t._[w](r[E])) + Qt)[nn](), r[$] && a[u](), f[c](), t[Ht](sn), e[d](), window[v](function() {
a.add(f)[s]((r[en] == g ? Gt : "") + t[Q](t._[w](r[E])), 0)
}, 50)
},
hide: function(e) {
var s = e[n],
u = e[h],
a = t[i][L].add(t[i][o][M]());
u[At](an)[Xt](Nt, [J]), u.add(a)[r](), window[v](function() {
t[ft](sn), u[It](), e[m](), a[p]()
}, t[n][dt] + 50)
}
},
pushY: {
show: function(e) {
var r = e[n],
a = e[h],
f = t[i][L].add(t[i][o][M]());
a[B](0)[S](r[en], Gt + t[Zt](t._[w](r[U])) + Qt)[nn](), r[$] && a[u](), t[Ht]("y"), e[d](), window[v](function() {
a.add(f)[s](0, (r[en] == y ? Gt : "") + t[Zt](t._[w](r[U])))
}, 50)
},
hide: function(e) {
var s = e[n],
u = e[h],
a = t[i][L].add(t[i][o][M]());
u[At](an)[Xt](Nt, [J]), u.add(a)[r](), window[v](function() {
t[ft]("y"), u[It](), e[m]()
}, t[n][dt] + 50)
}
},
revealX: {
show: function(e) {
var r = e[n],
a = e[h],
f = t[i][L].add(t[i][o][M]());
a[B](0)[nn](), r[$] && a[u](), f[c](), t[Ht](sn), e[d](), window[v](function() {
f[s]((r[en] == g ? Gt : "") + t[Q](t._[w](r[E])), 0)
}, 50)
},
hide: function(e) {
var s = e[n],
u = e[h],
a = t[i][L].add(t[i][o][M]());
u[At](an)[Xt](Nt, [J]), a[r](), window[v](function() {
t[ft](sn), u[It](), a[p](), e[m]()
}, t[n][dt] + 50)
}
}
}, Nn[C][bt] = {
"top-left": {
v: R,
h: k,
side: k
},
"top-right": {
v: R,
h: g,
side: g
},
top: {
v: R,
h: T,
side: R
},
"top-center": {
v: R,
h: T,
side: R
},
"bottom-left": {
v: y,
h: k,
side: k
},
"bottom-right": {
v: y,
h: g,
side: g
},
bottom: {
v: y,
h: T,
side: y
},
"bottom-center": {
v: y,
h: T,
side: y
},
left: {
v: T,
h: k,
side: k
},
"center-left": {
v: T,
h: k,
side: k
},
right: {
v: T,
h: g,
side: g
},
"center-right": {
v: T,
h: g,
side: g
}
}, Nn[C][nn] = function() {
var e, r, s, u, a;
if (this[W]) {
t[i][o][ht](this[j]);
return
}
e = this, r = this[n], s = t._[w](r[tt]), u = this[h], u[S](E, t._[w](r[E]))[S](U, t._[w](r[U])), t._.vars[Mt] == "ios" && (r[U] == "100%" && !r[rt] && u[S](U, "-webkit-calc(" + t._[w](r[U]) + " + 70px)"), u.on(Nt, "input,select,textarea", function(n, r) {
if (r) return;
window[v](function() {
t[i][P][ht](e[j]), window[v](function() {
t[i][o][ht](e[j])
}, 500)
}, 500)
})), a = this[bt][r[b]], u[Bt]("skel-layer-" + r[b]).data(st, r[b]);
switch (a.v) {
case R:
u[S](R, 0);
break;
case y:
u[S](y, 0);
break;
case T:
u[S](R, "50%")[S]("margin-top", Gt + t.getHalf(r[U]))
}
switch (a.h) {
case k:
u[S](k, 0);
break;
case g:
u[S](g, 0);
break;
case T:
u[S](k, "50%")[S]("margin-left", Gt + t.getHalf(r[E]))
}
this[lt][s][nn](this), r[rt] && r.exclusive && (t[i][Kt][Bt](Y), t[i][l] = this), this[W] = J
}, Nn[C][It] = function() {
var e, r;
if (!this[W]) {
t[i][P][ht](this[j]);
return
}
e = this[n], r = t._[w](e[tt]), r in this[lt] || (r = yt), this[lt][r][It](this), e[rt] && e.exclusive && t[i][l] === this && (t[i][Kt][Wt](Y), t[i][l] = x), this[W] = H
}, Nn[C].init = function() {
var r = this[n],
i = e(this[j]),
s = this;
i[O](), i[At](an).each(function() {
t.parseInit(e(this))
}), i[Bt]("skel-layer").data(ot, this.index)[S](it, t[n].baseZIndex)[S](b, "fixed")[S]("-ms-overflow-style", "-ms-autohiding-scrollbar")[S]("-webkit-overflow-scrolling", "touch")[It]();
switch (r.orientation) {
case "vertical":
i[S]("overflow-y", Ft);
break;
case "horizontal":
i[S](D, Ft);
break;
case yt:
default:
}
if (!r[b] || !(r[b] in this[bt])) r[b] = "top-left";
r[en] || (r[en] = this[bt][r[b]][en]);
if (!r[tt] || typeof r[tt] !== $t && !(r[tt] in this[lt])) r[tt] = yt;
r.clickToHide && i[At]("a")[S](nt, zt).on("click.skel-layers", function(r) {
var i, o, u = e(this);
if (u.hasClass("skel-layers-ignore")) return;
r[kt](), r[Et](), s[It]();
if (u.hasClass("skel-layers-ignoreHref")) return;
i = u[Lt]("href"), o = u[Lt]("target"), typeof i !== gt && i != "" && window[v](function() {
o == "_blank" && t._.vars[Mt] != "wp" ? window.open(i) : window.location.href = i
}, t[n][dt] + 10)
}), i.on("touchstart", function(e) {
s[St] = e[et][tn][0].pageX, s[xt] = e[et][tn][0].pageY
}).on("touchmove", function(e) {
var t, n, o, u, a, f, l;
if (s[St] === x || s[xt] === x) return;
t = s[St] - e[et][tn][0].pageX, n = s[xt] - e[et][tn][0].pageY, o = i.outerHeight(), u = i.get(0).scrollHeight - i[B]();
if (r[rt] && r.swipeToHide) {
a = H, f = 20, l = 50;
switch (r[en]) {
case k:
a = n < f && n > -1 * f && t > l;
break;
case g:
a = n < f && n > -1 * f && t < -1 * l;
break;
case R:
a = t < f && t > -1 * f && n > l;
break;
case y:
a = t < f && t > -1 * f && n < -1 * l
}
if (a) return s[St] = x, s[xt] = x, s[It](), H
}
if (i[B]() == 0 && n < 0 || u > o - 2 && u < o + 2 && n > 0) return H
}), this[h] = i
}, Nn[C][Z] = function() {
return this[h] !== x
}, Nn[C][Yt] = function() {
return this[h].is(":visible")
}, Nn[C][d] = function() {
t[i][o][ht](this[h])
}, Nn[C][m] = function() {
if (!this[h][Ot]()) return;
t[i][P][ht](this[h])
}, Nn[C].resume = function(r) {
if (!this[Z]()) return;
this[h][At](an).each(function() {
t.parseResume(e(this))
}), this[n][rt] || this[nn](r)
}, Nn[C].suspend = function() {
if (!this[Z]()) return;
this[h][r](), this[h][At](an).each(function() {
t.parseSuspend(e(this))
}), this[W] && this[It]()
}, t = {
cache: {
visibleWrapper: x,
body: x,
exclusiveLayer: x,
html: x,
htmlbody: x,
hiddenWrapper: x,
layers: {},
window: x,
wrapper: x
},
config: {
baseZIndex: 1e4,
layers: {},
speed: 250,
transform: J,
transformBreakpoints: x,
transformTest: x
},
eventType: "click touchend",
show: function(e) {
t._[Pt](function() {
t[i][I][e][nn]()
})
},
hide: function(e) {
t._[Pt](function() {
t[i][I][e][It]()
})
},
toggle: function(e) {
t._[Pt](function() {
var n = t[i][I][e];
n[Yt]() ? n[It]() : n[nn]()
})
},
getBaseFontSize: function() {
return t._.vars.IEVersion < 9 ? 16.5 : parseFloat(getComputedStyle(t[i][Kt].get(0)).fontSize)
},
getHalf: function(e) {
var t = parseInt(e);
return typeof e == "string" && e.charAt(e[z] - 1) == "%" ? Math.floor(t / 2) + "%" : Math.floor(t / 2) + Qt
},
lockView: function(e) {
t[i][wt]._skel_layers_scrollPos = t[i][wt][B](), e == sn && t[i][on][S](D, rt), t[i][L].on(X, function(e) {
e[kt](), e[Et](), t[i][l] && t[i][l][It]()
}), t[i][wt].on(mt, function(e) {
t[i][l] && t[i][l][It]()
}), t._.vars.isMobile || window[v](function() {
t[i][wt].on(vt, function(e) {
t[i][l] && t[i][l][It]()
})
}, t[n][dt] + 50)
},
parseInit: function(n) {
var r, s, o = n.get(0),
u = n[Lt]("data-action"),
a = n[Lt]("data-args"),
c, h;
u && a && (a = a.split(","));
switch (u) {
case "toggleLayer":
case "layerToggle":
n[S](nt, zt)[S]("cursor", "pointer"), r = function(n) {
n[kt](), n[Et]();
if (t[i][l]) return t[i][l][It](), H;
var r = e(this),
s = t[i][I][a[0]];
s[Yt]() ? s[It]() : s[nn]()
}, n.on(t.eventType, r);
break;
case "navList":
c = e(un + a[0]), r = c[At]("a"), s = [], r.each(function() {
var t = e(this),
n, r;
n = Math.max(0, t.parents("li")[z] - 1), r = t[Lt]("href"), s.push('<a class="link depth-' + n + '"' + (typeof r !== gt && r != "" ? ' href="' + r + '"' : "") + '><span class="indent-' + n + '"></span>' + t.text() + "</a>")
}), s[z] > 0 && n[jt]("<nav>" + s.join("") + "</nav>");
break;
case "copyText":
c = e(un + a[0]), n[jt](c.text());
break;
case "copyHTML":
c = e(un + a[0]), n[jt](c[jt]());
break;
case "moveElementContents":
c = e(un + a[0]), o[f] = function() {
c[M]().each(function() {
var t = e(this);
n[ht](t), t[Bt](_)
})
}, o[N] = function() {
n[M]().each(function() {
var n = e(this);
c[ht](n), n[Wt](_), t.refresh(n)
})
}, o[f]();
break;
case "moveElement":
c = e(un + a[0]), o[f] = function() {
e(V + c[Lt]("id") + '" />').insertBefore(c), n[ht](c), c[Bt](_)
}, o[N] = function() {
e(ut + c[Lt]("id")).replaceWith(c), c[Wt](_), t.refresh(c)
}, o[f]();
break;
case "moveCell":
c = e(un + a[0]), h = e(un + a[1]), o[f] = function() {
e(V + c[Lt]("id") + '" />').insertBefore(c), n[ht](c), c[S](E, Ft), h && h[Ct]()
}, o[N] = function() {
e(ut + c[Lt]("id")).replaceWith(c), c[S](E, ""), h && h[S](E, "")
}, o[f]();
break;
default:
}
},
parseResume: function(e) {
var t = e.get(0);
t[f] && t[f]()
},
parseSuspend: function(e) {
var t = e.get(0);
t[N] && t[N]()
},
recalc: function(e, n) {
var r = t._.parseMeasurement(e),
i;
switch (r[1]) {
case "%":
i = Math.floor(n * (r[0] / 100));
break;
case "em":
i = t.getBaseFontSize() * r[0];
break;
default:
case Qt:
i = r[0]
}
return i
},
recalcH: function(n) {
return t.recalc(n, e(window)[U]())
},
recalcW: function(n) {
return t.recalc(n, e(window)[E]())
},
refresh: function(r) {
var s;
t[n][F] && (r ? s = r.filter(q) : s = e(q), s[O]()[Vt](t[i][o]))
},
unlockView: function(e) {
e == sn && t[i][on][S](D, W), t[i][L].off(X), t[i][wt].off(mt), t._.vars.isMobile || t[i][wt].off(vt)
},
init: function() {
n in t[n] && (t._.extend(t[n], t[n][n]), delete t[n][n]), t._[_t](t[n], function(e) {
t[n][e] && typeof t[n][e] == $t && b in t[n][e] && (t[n][I][e] = t[n][e], delete t[n][e])
}), t[n][ln] && (t[n][F] = t[n][ln]());
if (t[n][F]) {
if (t._.vars[Mt] == "android" && t._.vars.deviceVersion < 4 || t._.vars[Mt] == "wp") t[n][F] = H;
t._.vars.IEVersion < 10 && (t[n][F] = H), t[n][Ut] && !t._.hasActive(t._[fn](t[n][Ut])) && (t[n][F] = H)
}
t[i][wt] = e(window), t.initTransforms(), t.initObjects(), t._[Pt](function() {
t.initLayers(), t.initIncludes(), t._.updateState(), t.refresh()
})
},
initIncludes: function() {
e(".skel-layers-include").each(function() {
t.parseInit(e(this))
})
},
initLayers: function() {
var r, s, o, u = 1;
t._[_t](t[n][I], function(r) {
var s;
if (!(b in t[n][I][r])) return;
if (!t[n][I][r][jt] && (s = e(un + r))[z] == 0) return;
o = new Nn(r, t[n][I][r], u++), t[i][I][r] = o, s && (s[M]()[Vt](o[j]), s.remove())
})
},
initObjects: function() {
t._[Pt](function() {
t[i][jt] = e(jt), t[i][Kt] = e(Kt), t[i][on] = e("html,body"), t[i][Kt].wrapInner('<div id="skel-layers-wrapper" />'), t[i][L] = e("#skel-layers-wrapper"), t[i][L][S](b, rn)[S](k, "0")[S](g, "0")[S](R, "0")[O](), t[i][P] = e('<div id="skel-layers-hiddenWrapper" />')[Vt](t[i][Kt]), t[i][P][S](U, "100%"), t[i][o] = e('<div id="skel-layers-visibleWrapper" />')[Vt](t[i][Kt]), t[i][o][S](b, rn), t._[pt](at, t[i][P][0]), t._[pt]("skel_layers_visibleWrapper", t[i][o][0]), t._[pt]("skel_layers_wrapper", t[i][L][0]), e("[autofocus]").focus()
})
},
initTransforms: function() {
if (t[n][F]) e.fn[r] = function() {
return e(this)[s](0, 0)
}, e.fn[s] = function(t, n) {
return e(this)[S](F, "translate(" + t + "px, " + n + "px)")
}, e.fn[O] = function() {
return e(this)[S]("backface-visibility", rt)[S]("perspective", "500")[qt]("transition", "transform " + t[n][dt] / 1e3 + "s ease-in-out")
};
else {
var o, u = [];
t[i][wt].resize(function() {
if (t[n][dt] != 0) {
var e = t[n][dt];
t[n][dt] = 0, window[v](function() {
t[n][dt] = e, u = []
}, e)
}
}), e.fn[r] = function() {
for (var r = 0; r < this[z]; r++) {
var s = this[r],
o = e(s);
u[s.id] && o.animate(u[s.id], t[n][dt], "swing", function() {
t._[_t](u[s.id], function(e) {
o[S](e, u[s.id][e])
}), t[i][Kt][S](D, W), t[i][L][S](E, Ft)[S](G, 0)
})
}
return e(this)
}, e.fn[s] = function(r, s) {
var o, f, l, c;
r = parseInt(r), s = parseInt(s), r != 0 ? (t[i][Kt][S](D, rt), t[i][L][S](E, t[i][wt][E]())) : l = function() {
t[i][Kt][S](D, W), t[i][L][S](E, Ft)
}, s < 0 ? t[i][L][S](G, Math.abs(s)) : c = function() {
t[i][L][S](G, 0)
};
for (o = 0; o < this[z]; o++) {
var h = this[o],
p = e(h),
d;
if (!u[h.id])
if (d = Nn[C][bt][p.data(st)]) {
u[h.id] = {};
switch (d.v) {
case T:
case R:
u[h.id][R] = parseInt(p[S](R));
break;
case y:
u[h.id][y] = parseInt(p[S](y))
}
switch (d.h) {
case T:
case k:
u[h.id][k] = parseInt(p[S](k));
break;
case g:
u[h.id][g] = parseInt(p[S](g))
}
} else d = p[b](), u[h.id] = {
top: d[R],
left: d[k]
};
a = {}, t._[_t](u[h.id], function(e) {
var n;
switch (e) {
case R:
n = t[Zt](u[h.id][e]) + s;
break;
case y:
n = t[Zt](u[h.id][e]) - s;
break;
case k:
n = t[Q](u[h.id][e]) + r;
break;
case g:
n = t[Q](u[h.id][e]) - r
}
a[e] = n
}), p.animate(a, t[n][dt], "swing", function() {
l && l(), c && c()
})
}
return e(this)
}, e.fn[O] = function() {
return e(this)[S](b, "absolute")
}
}
}
}, t)
}(jQuery))
});
You could use the vh unit for setting the height of an element.
#cta {
height: 100vh;
}
Do check the browser support though: http://caniuse.com/#feat=viewport-units
Use absolute positioning
#cta {
position: absolute;
bottom: 0;
height: 100%;
width: 400px; /* Adjust as needed */
left: 100px; /* To get it centered */
background-color: blue;
}
See working demo here

Plugin not working with current jQuery, TypeError in console

Using http://jsfiddle.net/heygrady/j5tHC/light/ as my example, trying to update to current jQuery, in my case 1.11.0
Works with jQuery 1.6.2, when I update to current version it throws an error in the console, "TypeError: f is undefined" I can't figure out why it makes a difference or track the variable, seems like it has the same values in both.
The following code runs the animation:
tween($.curve.bezier, {
x: 0,
y: $canvas[0].height,
points: [
[0, $canvas[0].height / 2],
[$canvas[0].width * 0.5, 0],
[$canvas[0].width * 0.9, $canvas[0].height],
[$canvas[0].width, $canvas[0].height/ 2]
]
});
I believe this is the function that is breaking inside the plugin:
(function (f, g, j, b) {
var h = /progid:DXImageTransform\.Microsoft\.Matrix\(.*?\)/,
c = /^([\+\-]=)?([\d+.\-]+)(.*)$/,
q = /%/;
var d = j.createElement('modernizr'),
e = d.style;
function n(s) {
return parseFloat(s)
}
function l() {
var s = {
transformProperty: '',
MozTransform: '-moz-',
WebkitTransform: '-webkit-',
OTransform: '-o-',
msTransform: '-ms-'
};
for (var t in s) {
if (typeof e[t] != 'undefined') {
return s[t]
}
}
return null
}
function r() {
if (typeof (g.Modernizr) !== 'undefined') {
return Modernizr.csstransforms
}
var t = [
'transformProperty',
'WebkitTransform',
'MozTransform',
'OTransform',
'msTransform'
];
for (var s in t) {
if (e[t[s]] !== b) {
return true
}
}
}
var a = l(),
i = a !== null ? a + 'transform' : false,
k = a !== null ? a + 'transform-origin' : false;
f.support.csstransforms = r();
if (a == '-ms-') {
i = 'msTransform';
k = 'msTransformOrigin'
}
f.extend({
transform: function (s) {
s.transform = this;
this.$elem = f(s);
this.applyingMatrix = false;
this.matrix = null;
this.height = null;
this.width = null;
this.outerHeight = null;
this.outerWidth = null;
this.boxSizingValue = null;
this.boxSizingProperty = null;
this.attr = null;
this.transformProperty = i;
this.transformOriginProperty = k
}
});
f.extend(f.transform, {
funcs: [
'matrix',
'origin',
'reflect',
'reflectX',
'reflectXY',
'reflectY',
'rotate',
'scale',
'scaleX',
'scaleY',
'skew',
'skewX',
'skewY',
'translate',
'translateX',
'translateY'
]
});
f.fn.transform = function (s, t) {
return this.each(function () {
var u = this.transform || new f.transform(this);
if (s) {
u.exec(s, t)
}
})
};
f.transform.prototype = {
exec: function (s, t) {
t = f.extend(true, {
forceMatrix: false,
preserve: false
}, t);
this.attr = null;
if (t.preserve) {
s = f.extend(true, this.getAttrs(true, true), s)
} else {
s = f.extend(true, {
}, s)
}
this.setAttrs(s);
if (f.support.csstransforms && !t.forceMatrix) {
return this.execFuncs(s)
} else {
if (f.browser.msie || (f.support.csstransforms && t.forceMatrix)) {
return this.execMatrix(s)
}
}
return false
},
execFuncs: function (t) {
var s = [
];
for (var u in t) {
if (u == 'origin') {
this[u].apply(this, f.isArray(t[u]) ? t[u] : [
t[u]
])
} else {
if (f.inArray(u, f.transform.funcs) !== - 1) {
s.push(this.createTransformFunc(u, t[u]))
}
}
}
this.$elem.css(i, s.join(' '));
return true
},
execMatrix: function (z) {
var C,
x,
t;
var F = this.$elem[0],
B = this;
function A(N, M) {
if (q.test(N)) {
return parseFloat(N) / 100 * B['safeOuter' + (M ? 'Height' : 'Width')]()
}
return o(F, N)
}
var s = /translate[X|Y]?/,
u = [
];
for (var v in z) {
switch (f.type(z[v])) {
case 'array':
t = z[v];
break;
case 'string':
t = f.map(z[v].split(','), f.trim);
break;
default:
t = [
z[v]
]
}
if (f.matrix[v]) {
if (f.cssAngle[v]) {
t = f.map(t, f.angle.toDegree)
} else {
if (!f.cssNumber[v]) {
t = f.map(t, A)
} else {
t = f.map(t, n)
}
}
x = f.matrix[v].apply(this, t);
if (s.test(v)) {
u.push(x)
} else {
C = C ? C.x(x) : x
}
} else {
if (v == 'origin') {
this[v].apply(this, t)
}
}
}
C = C || f.matrix.identity();
f.each(u, function (M, N) {
C = C.x(N)
});
var K = parseFloat(C.e(1, 1) .toFixed(6)),
I = parseFloat(C.e(2, 1) .toFixed(6)),
H = parseFloat(C.e(1, 2) .toFixed(6)),
G = parseFloat(C.e(2, 2) .toFixed(6)),
L = C.rows === 3 ? parseFloat(C.e(1, 3) .toFixed(6)) : 0,
J = C.rows === 3 ? parseFloat(C.e(2, 3) .toFixed(6)) : 0;
if (f.support.csstransforms && a === '-moz-') {
this.$elem.css(i, 'matrix(' + K + ', ' + I + ', ' + H + ', ' + G + ', ' + L + 'px, ' + J + 'px)')
} else {
if (f.support.csstransforms) {
this.$elem.css(i, 'matrix(' + K + ', ' + I + ', ' + H + ', ' + G + ', ' + L + ', ' + J + ')')
} else {
if (f.browser.msie) {
var w = ', FilterType=\'nearest neighbor\'';
var D = this.$elem[0].style;
var E = 'progid:DXImageTransform.Microsoft.Matrix(M11=' + K + ', M12=' + H + ', M21=' + I + ', M22=' + G + ', sizingMethod=\'auto expand\'' + w + ')';
var y = D.filter || f.curCSS(this.$elem[0], 'filter') || '';
D.filter = h.test(y) ? y.replace(h, E) : y ? y + ' ' + E : E;
this.applyingMatrix = true;
this.matrix = C;
this.fixPosition(C, L, J);
this.applyingMatrix = false;
this.matrix = null
}
}
}
return true
},
origin: function (s, t) {
if (f.support.csstransforms) {
if (typeof t === 'undefined') {
this.$elem.css(k, s)
} else {
this.$elem.css(k, s + ' ' + t)
}
return true
}
switch (s) {
case 'left':
s = '0';
break;
case 'right':
s = '100%';
break;
case 'center':
case b:
s = '50%'
}
switch (t) {
case 'top':
t = '0';
break;
case 'bottom':
t = '100%';
break;
case 'center':
case b:
t = '50%'
}
this.setAttr('origin', [
q.test(s) ? s : o(this.$elem[0], s) + 'px',
q.test(t) ? t : o(this.$elem[0], t) + 'px'
]);
return true
},
createTransformFunc: function (t, u) {
if (t.substr(0, 7) === 'reflect') {
var s = u ? f.matrix[t]() : f.matrix.identity();
return 'matrix(' + s.e(1, 1) + ', ' + s.e(2, 1) + ', ' + s.e(1, 2) + ', ' + s.e(2, 2) + ', 0, 0)'
}
if (t == 'matrix') {
if (a === '-moz-') {
u[4] = u[4] ? u[4] + 'px' : 0;
u[5] = u[5] ? u[5] + 'px' : 0
}
}
return t + '(' + (f.isArray(u) ? u.join(', ') : u) + ')'
},
fixPosition: function (B, y, x, D, s) {
var w = new f.matrix.calc(B, this.safeOuterHeight(), this.safeOuterWidth()),
C = this.getAttr('origin');
var v = w.originOffset(new f.matrix.V2(q.test(C[0]) ? parseFloat(C[0]) / 100 * w.outerWidth : parseFloat(C[0]), q.test(C[1]) ? parseFloat(C[1]) / 100 * w.outerHeight : parseFloat(C[1])));
var t = w.sides();
var u = this.$elem.css('position');
if (u == 'static') {
u = 'relative'
}
var A = {
top: 0,
left: 0
};
var z = {
position: u,
top: (v.top + x + t.top + A.top) + 'px',
left: (v.left + y + t.left + A.left) + 'px',
zoom: 1
};
this.$elem.css(z)
}
};
function o(s, u) {
var t = c.exec(f.trim(u));
if (t[3] && t[3] !== 'px') {
var w = 'paddingBottom',
v = f.style(s, w);
f.style(s, w, u);
u = p(s, w);
f.style(s, w, v);
return u
}
return parseFloat(u)
}
function p(t, u) {
if (t[u] != null && (!t.style || t.style[u] == null)) {
return t[u]
}
var s = parseFloat(f.css(t, u));
return s && s > - 10000 ? s : 0
}
}) (jQuery, this, this.document);

What is this strange javascript use for? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I am not sure if I can ask this question here but:
I have a JavaScript block which I don't understand:
var _0x3a04=["$(3C).4Z(2(){3 o=\x2218\x22,y=\x224r\x22,u=\x223F.\x22,s=\x223v\x22,t=\x22.3D\x22,x=\x223G\x22,w=\x223o\x22,q=\x22.m\x22,p=\x222s\x22,l=q+p,v=\x224H\x22,z=\x223q\x22,r=\x223B\x22;5($(\x22.2s\x22+y+\x22x\x22).1d(\x22a\x22).2M(o)==\x221g://\x22+u+\x22i\x22+s+\x22h\x22+r+\x22s.1D\x22\x26\x26$(\x22.2s\x22+y+\x22x\x22).1d(l).2M(o)==\x221g://\x22+x+\x22r-s\x22+w+\x22.3t\x22+v+\x22t\x22+t+\x22m\x22){1m.3A=(2(){3 a=2(c){3 f=c||{},b=f.1Z||1m.21.2a,g=f.3k||\x221g://1.2q.2g.1D/-2w/2x/2y/2C/2E/2H.2o\x22,d=f.4C||50,e=f.3m||0;(2(j){3 h=j(\x22#1E-2n-3y\x22),k=h.1d(\x22:2m\x22);h.2A(\x27\x3C12 3E=\x222n-1x\x22\x3E\x3C/12\x3E\x27);3 i=j(\x22#2n-1x\x22);h.2F(\x223H\x22,2(){3 m=k.4i();i.4q().15(\x221M...\x22);j.1E({1w:\x221g://\x22+b+\x22/1O/2l/1C?1v=1X-1f-20\x26q=\x22+m+\x22\x262k-22=2B\x22,1s:\x2224\x22,26:\x2227\x22,28:2(I){3 H=I.1B.2e,E,D,G,F,A=\x22\x22;5(H!==1Q){A=\x22\x3C1r\x3E3w 22 1a 3z \x262D;\x22+m+\x22\x262D;\x3C/1r\x3E\x22;A+=\x27\x3Ca 11=\x221U\x22 18=\x22/\x22\x3E\x262j;\x3C/a\x3E\x3C2J\x3E\x27;1a(3 C=0;C\x3CH.16;C++){3 n=46 4a(m,\x224f\x22),G=H[C].1G.$t.1i(n,\x22\x3C25\x3E\x22+m+\x22\x3C/25\x3E\x22);1a(3 B=0;B\x3CH[C].14.16;B++){5(H[C].14[B].1n==\x2229\x22){F=H[C].14[B].18}}5(\x221A\x221f H[C]){E=H[C].1A.$t}17{5(\x221C\x221f H[C]){E=H[C].1C.$t}17{E=\x22\x22}}E=E.1i(/\x3C\x5CS[^\x3E]*\x3E/g,\x22\x22);5(E.16\x3Ee){E=E.1y(0,e)+\x22...\x22}E=E.1i(n,\x22\x3C25\x3E\x22+m+\x22\x3C/25\x3E\x22);5(\x222f$1H\x221f H[C]){D=H[C].2f$1H.1w.1i(/\x5C/s[0-9]+\x5C-c/g,\x22/s\x22+d+\x22-c\x22)}17{D=g}A+=\x27\x3C7\x3E\x3Ca 18=\x22\x27+F+\x27\x22 1K=\x221L\x22\x3E\x3C13\x3E\x3C1N 2p=\x22\x27+d+\x27\x22 1b=\x22\x27+d+\x27\x22 1P=\x22\x27+D+\x27\x22/\x3E\x3C/13\x3E\x3Cb\x3E\x27+G+\x22\x3C/b\x3E\x3C/a\x3E\x3Cp\x3E\x22+E+\x22\x3C/p\x3E\x3C/7\x3E\x22}A+=\x22\x3C/2J\x3E\x22;i.15(A)}17{i.15(\x27\x3Ca 11=\x221U\x22 18=\x22/\x22\x3E\x262j;\x3C/a\x3E\x3C1h\x3E1R 1x!\x3C/1h\x3E\x27)}},1S:2(){i.15(\x27\x3Ca 11=\x221U\x22 18=\x22/\x22\x3E\x262j;\x3C/a\x3E\x3C1h\x3E1T 4p 1B.\x3C/1h\x3E\x27)}});1j 1t});h.2F(\x224s\x22,\x22.1U\x22,2(){i.4x();1j 1t})})(1c)};1j 2(b){a(b)}})();1m.4D=(2(){3 a=2(A){3 d=A||{},h=d.1Z||1m.21.2a,n=d.4G||8,g=d.3f||\x22#3g\x22,e=d.3h||3i,c=d.3j||1W,f=d.3l||4,b=d.3n||2G,m=d.3p||1Y,j=d.3r||1t,k=d.3s||\x222I\x22,i=d.3u||\x221g://1.2q.2g.1D/-2w/2x/2y/2C/2E/2H.2o\x22;$.1E({1w:\x221g://\x22+h+\x22/1O/2l/2h?1v=1X-1f-20\x262k-22=\x22+n+\x22\x22,1s:\x2224\x22,26:\x2227\x22,28:2(G){3 I,B,H,K,M,J,D=\x22\x22,L=G.1B.2e;5(L!==1Q){5(j){D=\x22\x3C1e 11=\x272U 2V\x27\x3E\x22}17{D=\x22\x3C1e 11=\x272V\x27\x3E\x22}1a(3 F=0;F\x3CL.16;F++){1a(3 E=0;E\x3CL[F].14.16;E++){5(L[F].14[E].1n==\x2229\x22){I=L[F].14[E].18;1q}}1a(3 C=0;C\x3CL[F].14.16;C++){5(L[F].14[C].1n==\x222Y\x22\x26\x26L[F].14[C].1s==\x222m/15\x22){H=L[F].14[C].1G.30(\x22 \x22)[0];1q}}5(\x221A\x221f L[F]){K=L[F].1A.$t}17{5(\x221C\x221f L[F]){K=L[F].1C.$t}17{K=\x22\x22}}5(\x222f$1H\x221f L[F]){M=L[F].2f$1H.1w.1i(/\x5C/s[0-9]+\x5C-c/g,\x22/s\x22+e+\x22-c\x22)}17{M=i}K=K.1i(/\x3C\x5CS[^\x3E]*\x3E/g,\x22\x22);5(K.16\x3Ec){K=K.1y(0,c)+\x22...\x22}B=L[F].1G.$t;J=L[F].31.$t.1y(0,10),J=J.1i(/-/g,\x22/\x22);D+=\x27\x3C7\x3E\x3C12 11=\x2247\x22\x3E\x3Ca 18=\x22\x27+I+\x27\x22 1K=\x221L\x22\x3E\x3C13\x3E\x3C1N 1v=\x22\x27+B+\x27\x221P=\x22\x27+M+\x27\x22/\x3E\x3C/13\x3E\x3C/a\x3E\x3C/12\x3E\x3C12 11=\x2248\x22\x3E\x3C1r\x3E\x3Ca 18=\x22\x27+I+\x27\x22 1K=\x221L\x22\x3E\x27+B+\x27\x3C/a\x3E\x3C/1r\x3E\x3C12 11=\x2236\x22\x3E\x3C13 11=\x2237\x22\x3E\x27+J+\x27\x3C/13\x3E\x3C13 11=\x223a\x22\x3E\x27+H+\x22 \x22+k+\x27\x3C/13\x3E\x3C/12\x3E\x3C/12\x3E\x3C12 11=\x224o\x22\x3E\x27+K+\x22\x3C/12\x3E\x3C/7\x3E\x22}D+=\x22\x3C/1e\x3E\x22;$(g).15(D);(2(N){N.2u.2v=2(O,Q,P){O=O||4;Q=Q||2z;P=P||1Y;1j 19.2b(2(){3 X=N(19),W=1F,V=[],U=O,R=X.1d(\x22\x3E 7:2i\x22).1b(),T=0;2 S(){5(W){3 Y=N(V[U]).1u({1b:0,1o:0}).2K(X);X.1d(\x22\x3E 7:2L\x22).1p({1o:0},P,2(){Y.1p({1b:R},P).1p({1o:1},P);N(19).23()});U++;5(U\x3E=T){U=0}}2N(S,Q)}X.1d(\x22\x3E 7\x22).2b(2(){V.2O(\x22\x3C7\x3E\x22+N(19).15()+\x22\x3C/7\x3E\x22)});T=V.16;X.2P(\x27\x3C12 11=\x223x\x22 /\x3E\x27).2Q().1u({1b:R*O});X.1d(\x22\x3E 7\x22).2R(\x22:2S(\x22+(O-1)+\x22)\x22).23();X.1k(\x221J\x22,2(){W=1t}).1k(\x221I\x22,2(){W=1F});S()})}})(1c);1c(2(){5(j){1c(\x221e.2U\x22).2v(f,b,m).1k(\x222W\x22,2(){1c(19).2c(\x221J\x22)}).1k(\x222X\x22,2(){1c(19).2c(\x221I\x22)})}})}17{$(g).15(\x22\x3C13\x3E1R 1x!\x3C/13\x3E\x22)}},1S:2(){$(g).15(\x22\x3C1h\x3E1T 1M 2r!\x3C/1h\x3E\x22)}})};1j 2(b){a(b)}})();1m.3I=(2(){3 a=2(B){3 e=B||{},k=e.1Z||1m.21.2a,c=e.3J||\x22#3K\x22,m=e.3L||6,j=e.3M||3N,i=e.3O||1t,b=e.3P||4,h=e.3Q||2G,g=e.3R||1Y,f=e.3S||1W,A=e.3T||\x221g://4.2q.2g.1D/-3U/3V/3W/3X/3Y/3Z-40-41.42\x22,n=e.43||50,d=e.44||\x22\x22;$.1E({1w:\x221g://\x22+k+\x22/1O/45/2h?1v=1X-1f-20\x22,1s:\x2224\x22,26:\x2227\x22,28:2(Q){3 I,K=Q.1B.2e;5(K!==1Q){I=\x22\x3C1e 11=\x272Z\x27\x3E\x22;1V=0;1a(3 H=0;H\x3Cn;H++){3 G,M,J,C,L,E;5(H==K.16){1q}5(1V\x3E=m){1q}3 P=K[H];1a(3 F=0;F\x3CP.14.16;F++){5(P.14[F].1n==\x2229\x22){G=P.14[F].18}}1a(3 O=0;O\x3CP.1z.16;O++){M=P.1z[O].49.$t;J=P.1z[O].32$4b.1P}5(M!=d\x26\x261V\x3Cm){1V++;I+=\x22\x3C7\x3E\x22;5(J==\x221g://4c.4d.1D/1N/4e.2o\x22){C=A}17{C=J.1i(/\x5C/s[0-9]+(\x5C-c|\x5C/)/,\x22/s\x22+j+\x22$1\x22)}3 E=(P.1z[0].33)?P.1z[0].33.$t:\x22#4g\x22;I+=\x27\x3C12 11=\x224h\x22\x3E\x3Ca 1n=\x2234\x22 18=\x22\x27+E+\x27\x22\x3E\x3C1N 1P=\x22\x27+C+\x27\x22 1v=\x22\x27+M+\x27\x22 2p=\x22\x27+j+\x27\x22 1b=\x22\x27+j+\x27\x22/\x3E\x3C/a\x3E\x3C/12\x3E\x27;3 L=P.32$4j[1].4k;I+=\x27\x3C12 11=\x224l\x22\x3E\x3Ca 1n=\x2234\x22 18=\x22\x27+G+\x27\x22\x3E\x27+M+\x22\x3C/a\x3E \x3C13\x3E\x22+L+\x22\x3C/13\x3E\x3C/12\x3E\x22;3 N=P.1A.$t;3 D=N.1i(/(\x3C([^\x3E]+)\x3E)/4m,\x22\x22);5(D!=\x22\x22\x26\x26D.16\x3Ef){D=D.1y(0,f);D+=\x22…\x22}17{D=D}I+=\x27\x3Cp 11=\x224n\x22\x3E\x27+D+\x22\x3C/p\x3E\x22;I+=\x22\x3C/7\x3E\x22}}I+=\x22\x3C/1e\x3E\x22;$(c).15(I);(2(R){R.2u.35=2(S,U,T){S=S||4;U=U||2z;T=T||1Y;1j 19.2b(2(){3 1l=R(19),2d=1F,Z=[],Y=S,V=1l.1d(\x22\x3E 7:2i\x22).1b(),X=0;2 W(){5(2d){3 38=R(Z[Y]).1u({1b:0,1o:0}).2K(1l);1l.1d(\x22\x3E 7:2L\x22).1p({1o:0},T,2(){38.1p({1b:V},T).1p({1o:1},T);R(19).23()});Y++;5(Y\x3E=X){Y=0}}2N(W,U)}1l.1d(\x22\x3E 7\x22).2b(2(){Z.2O(\x22\x3C7\x3E\x22+R(19).15()+\x22\x3C/7\x3E\x22)});X=Z.16;1l.2P(\x27\x3C12 11=\x224t\x22 /\x3E\x27).2Q().1u({1b:V*S});1l.1d(\x22\x3E 7\x22).2R(\x22:2S(\x22+(S-1)+\x22)\x22).23();1l.1k(\x221J\x22,2(){2d=1t}).1k(\x221I\x22,2(){2d=1F});W()})}})(1c);1c(2(){5(i){1c(\x221e.2Z\x22).35(b,h,g).1k(\x222W\x22,2(){1c(19).2c(\x221J\x22)}).1k(\x222X\x22,2(){1c(19).2c(\x221I\x22)})}})}17{$(c).15(\x22\x3C13\x3E1R 1x!\x3C/13\x3E\x22)}},1S:2(){$(c).15(\x22\x3C1h\x3E1T 1M 2r!\x3C/1h\x3E\x22)}})};1j 2(b){a(b)}})();1m.4u=(2(){3 a=2(d){3 g=d||{},b=g.1Z||1m.21.2a,f=g.4v||8,e=g.4w||\x22#2t\x22,h=g.4y||1F,c=g.4z||\x222I\x22;$.1E({1w:\x221g://\x22+b+\x22/1O/2l/2h?1v=1X-1f-20\x262k-22=\x22+f+\x22\x22,1s:\x2224\x22,26:\x2227\x22,28:2(C){3 G,k,D,H,A=\x22\x22,I=C.1B.2e;5(I!==1Q){A=\x22\x3C1e\x3E\x22;1a(3 E=0;E\x3CI.16;E++){1a(3 B=0;B\x3CI[E].14.16;B++){5(I[E].14[B].1n==\x2229\x22){G=I[E].14[B].18;1q}}1a(3 m=0;m\x3CI[E].14.16;m++){5(I[E].14[m].1n==\x222Y\x22\x26\x26I[E].14[m].1s==\x222m/15\x22){D=I[E].14[m].1G.30(\x22 \x22)[0];1q}}k=I[E].1G.$t;H=I[E].31.$t.1y(0,10);H=H.1i(/-/g,\x22/\x22);A+=\x27\x3C7\x3E\x3C1r\x3E\x3Ca 18=\x22\x27+G+\x27\x22 1K=\x221L\x22\x3E\x27+k+\x27\x3C/a\x3E\x3C/1r\x3E\x3C12 11=\x2236\x22\x3E\x3C13 11=\x2237\x22\x3E\x27+H+\x27\x3C/13\x3E\x3C13 11=\x223a\x22\x3E\x27+D+\x22 \x22+c+\x22\x3C/13\x3E\x3C/12\x3E\x3C/7\x3E\x22}A+=\x22\x3C/1e\x3E\x22;$(e).15(A);5(h){2 F(){$(\x22#2t 1e 7:2i\x22).1p({1o:0},4A,2(){$(19).4B($(\x22#2t 1e\x22)).1u(\x221o\x22,1)})}3 n=3b(2(){F()},3c);$(e).4E(2(){4F(n)},2(){3b(2(){F()},3c)})}}17{$(e).15(\x22\x3C13\x3E1R 1x!\x3C/13\x3E\x22)}},1S:2(){$(e).15(\x22\x3C1h\x3E1T 1M 2r!\x3C/1h\x3E\x22)}})};1j 2(b){a(b)}})()}17{$(z).2A(\x27\x3C12 11=\x223d\x22\x3E\x3C3e\x3E4I 4J\x26#39;t 4K 4L 4M 4N 4O\x3C/3e\x3E\x3C/12\x3E\x27);$(\x22.3d\x22).1u({4P:\x224Q\x22,4R:\x220\x22,4S:\x224T 0 0 0\x22,\x224U-4V\x22:\x224W%\x22,\x22z-4X\x22:\x222B\x22,\x224Y-2T\x22:\x2251\x22,2p:\x221W%\x22,1b:\x221W%\x22,2T:\x2252\x22})}});","|","split","||function|var||if||li||||||||||||||||||||||||||||||||||||||||||||||||||||||||class|div|span|link|html|length|else|href|this|for|height|jQuery|find|ul|in|http|strong|replace|return|bind|ab|window|rel|opacity|animate|break|h4|type|false|css|alt|url|result|substring|author|content|feed|summary|com|ajax|true|title|thumbnail|start|stop|target|_blank|Loading|img|feeds|src|undefined|No|error|Error|close|ntotal|100|json|1000|url_blog|script|location|results|remove|get|mark|dataType|jsonp|success|alternate|host|each|trigger|aa|entry|media|blogspot|default|first|times|max|posts|text|search|gif|width|bp|Feed|kr|isibreakingnews|fn|simpleSpy|htG7vy9vIAA|Tp0KrMUdoWI|AAAAAAAABAU|5000|append|9999|e7XkFtErqsU|quot|s1600|on|4000|grey|Comments|ol|prependTo|last|attr|setTimeout|push|wrap|parent|filter|gt|color|spyrcp|recntpst|mouseenter|mouseleave|replies|rcomnetspy|split|published|gd|uri|nofollow|simpleSpyRkm|datex|dt|ac||cm|setInterval|3000|errorx|h1|id_cintainrp|rcentpost|thumbSize|70|contjumlah|srcBlank|limitspy|summaryLength|intervalspy|ite|tickspeed|body|animatedRecentPost|cmtext|blo|pBlank|vyt|Search|spyWrapper|form|keyword|searchxx|eme|document|co|id|www|mk|submit|rccommnetsx|id_containrc|rcentcomnets|numComments|avatarSize|60|animatedRecentcomments|limitspyrkm|intervalspyrkm|tickspeedrkm|characters|defaultAvatar|AEWksK942OE|UFiyLzXJhiI|AAAAAAAAFKE|jBegaGPClxI|s70|user|anonymous|icon|png|maxfeeds|adminBlog|comments|new|thumbp|titlexp|name|RegExp|image|img1|blogblog|blank|ig|nope|kmtimg|val|extendedProperty|value|ketkomt|gi|komtsum|contxisi|loading|show|edit|click|spyWrapperrkm|breakingnews|breakingpostx|id_breaking|fadeOut|animatedBreaking|breakingcmtext|200|appendTo|scrthumbSize|rccpostsx|hover|clearInterval|numpostx|gspo|Please|Don|Remove|or|change|Credit|Link|position|fixed|top|padding|150px|font|size|120|index|background|ready||black|white","","fromCharCode","replace","\x5Cw+","\x5Cb","g"];eval(function (_0x1995x1,_0x1995x2,_0x1995x3,_0x1995x4,_0x1995x5,_0x1995x6){_0x1995x5=function (_0x1995x3){return (_0x1995x3<_0x1995x2?_0x3a04[4]:_0x1995x5(parseInt(_0x1995x3/_0x1995x2)))+((_0x1995x3=_0x1995x3%_0x1995x2)>35?String[_0x3a04[5]](_0x1995x3+29):_0x1995x3.toString(36));} ;if(!_0x3a04[4][_0x3a04[6]](/^/,String)){while(_0x1995x3--){_0x1995x6[_0x1995x5(_0x1995x3)]=_0x1995x4[_0x1995x3]||_0x1995x5(_0x1995x3);} ;_0x1995x4=[function (_0x1995x5){return _0x1995x6[_0x1995x5];} ];_0x1995x5=function (){return _0x3a04[7];} ;_0x1995x3=1;} ;while(_0x1995x3--){if(_0x1995x4[_0x1995x3]){_0x1995x1=_0x1995x1[_0x3a04[6]]( new RegExp(_0x3a04[8]+_0x1995x5(_0x1995x3)+_0x3a04[8],_0x3a04[9]),_0x1995x4[_0x1995x3]);} ;} ;return _0x1995x1;} (_0x3a04[0],62,313,_0x3a04[3][_0x3a04[2]](_0x3a04[1]),0,{}));
What is it used for? How can such code be written?
That's obfuscated JavaScript.
If you don't know, where it is coming from, it is most likely your site was hacked and this JavaScript is malicious!
What is it used for? How can such code be written?
It is used to hide your code. The reason may be different: Some think they can protect their own code by such things. This, however, is futile as you can see below. Another usecase is for hackers to hide their code from detection. People who often use scripts found on the internet might not see, that this code is invalid and think it is part of some script they wanted to use. Furthermore it hinders the automatic detection of malicious scripts for the same reasons.
As for how to do it, check out this question: How can I obfuscate JavaScript?
The somehow un-obfuscated code:
$(document).ready(function () {
var o = "href",
y = "edit",
u = "www.",
s = "vyt",
t = ".co",
x = "mk",
w = "ite",
q = ".m",
p = "kr",
l = q + p,
v = "gspo",
z = "body",
r = "eme";
if ($(".kr" + y + "x").find("a").attr(o) == "http://" + u + "i" + s + "h" + r + "s.com" && $(".kr" + y + "x").find(l).attr(o) == "http://" + x + "r-s" + w + ".blo" + v + "t" + t + "m") {
window.searchxx = (function () {
var a = function (c) {
var f = c || {}, b = f.url_blog || window.location.host,
g = f.srcBlank || "http://1.bp.blogspot.com/-htG7vy9vIAA/Tp0KrMUdoWI/AAAAAAAABAU/e7XkFtErqsU/s1600/grey.gif",
d = f.scrthumbSize || 50,
e = f.summaryLength || 0;
(function (j) {
var h = j("#ajax-search-form"),
k = h.find(":text");
h.append('<div id="search-result"></div>');
var i = j("#search-result");
h.on("submit", function () {
var m = k.val();
i.show().html("Loading...");
j.ajax({
url: "http://" + b + "/feeds/posts/summary?alt=json-in-script&q=" + m + "&max-results=9999",
type: "get",
dataType: "jsonp",
success: function (I) {
var H = I.feed.entry,
E, D, G, F, A = "";
if (H !== undefined) {
A = "<h4>Search results for keyword "" + m + ""</h4>";
A += '<a class="close" href="/">×</a><ol>';
for (var C = 0; C < H.length; C++) {
var n = new RegExp(m, "ig"),
G = H[C].title.$t.replace(n, "<mark>" + m + "</mark>");
for (var B = 0; B < H[C].link.length; B++) {
if (H[C].link[B].rel == "alternate") {
F = H[C].link[B].href
}
}
if ("content" in H[C]) {
E = H[C].content.$t
} else {
if ("summary" in H[C]) {
E = H[C].summary.$t
} else {
E = ""
}
}
E = E.replace(/<\S[^>]*>/g, "");
if (E.length > e) {
E = E.substring(0, e) + "..."
}
E = E.replace(n, "<mark>" + m + "</mark>");
if ("media$thumbnail" in H[C]) {
D = H[C].media$thumbnail.url.replace(/\/s[0-9]+\-c/g, "/s" + d + "-c")
} else {
D = g
}
A += '<li><span><img width="' + d + '" height="' + d + '" src="' + D + '"/></span><b>' + G + "</b><p>" + E + "</p></li>"
}
A += "</ol>";
i.html(A)
} else {
i.html('<a class="close" href="/">×</a><strong>No result!</strong>')
}
},
error: function () {
i.html('<a class="close" href="/">×</a><strong>Error loading feed.</strong>')
}
});
return false
});
h.on("click", ".close", function () {
i.fadeOut();
return false
})
})(jQuery)
};
return function (b) {
a(b)
}
})();
window.rccpostsx = (function () {
var a = function (A) {
var d = A || {}, h = d.url_blog || window.location.host,
n = d.numpostx || 8,
g = d.id_cintainrp || "#rcentpost",
e = d.thumbSize || 70,
c = d.contjumlah || 100,
f = d.limitspy || 4,
b = d.intervalspy || 4000,
m = d.tickspeed || 1000,
j = d.animatedRecentPost || false,
k = d.cmtext || "Comments",
i = d.pBlank || "http://1.bp.blogspot.com/-htG7vy9vIAA/Tp0KrMUdoWI/AAAAAAAABAU/e7XkFtErqsU/s1600/grey.gif";
$.ajax({
url: "http://" + h + "/feeds/posts/default?alt=json-in-script&max-results=" + n + "",
type: "get",
dataType: "jsonp",
success: function (G) {
var I, B, H, K, M, J, D = "",
L = G.feed.entry;
if (L !== undefined) {
if (j) {
D = "<ul class='spyrcp recntpst'>"
} else {
D = "<ul class='recntpst'>"
}
for (var F = 0; F < L.length; F++) {
for (var E = 0; E < L[F].link.length; E++) {
if (L[F].link[E].rel == "alternate") {
I = L[F].link[E].href;
break
}
}
for (var C = 0; C < L[F].link.length; C++) {
if (L[F].link[C].rel == "replies" && L[F].link[C].type == "text/html") {
H = L[F].link[C].title.split(" ")[0];
break
}
}
if ("content" in L[F]) {
K = L[F].content.$t
} else {
if ("summary" in L[F]) {
K = L[F].summary.$t
} else {
K = ""
}
}
if ("media$thumbnail" in L[F]) {
M = L[F].media$thumbnail.url.replace(/\/s[0-9]+\-c/g, "/s" + e + "-c")
} else {
M = i
}
K = K.replace(/<\S[^>]*>/g, "");
if (K.length > c) {
K = K.substring(0, c) + "..."
}
B = L[F].title.$t;
J = L[F].published.$t.substring(0, 10), J = J.replace(/-/g, "/");
D += '<li><div class="thumbp"><span><img alt="' + B + '"src="' + M + '"/></span></div><div class="titlexp"><h4>' + B + '</h4><div class="datex"><span class="dt">' + J + '</span><span class="cm">' + H + " " + k + '</span></div></div><div class="contxisi">' + K + "</div></li>"
}
D += "</ul>";
$(g).html(D);
(function (N) {
N.fn.simpleSpy = function (O, Q, P) {
O = O || 4;
Q = Q || 5000;
P = P || 1000;
return this.each(function () {
var X = N(this),
W = true,
V = [],
U = O,
R = X.find("> li:first").height(),
T = 0;
function S() {
if (W) {
var Y = N(V[U]).css({
height: 0,
opacity: 0
}).prependTo(X);
X.find("> li:last").animate({
opacity: 0
}, P, function () {
Y.animate({
height: R
}, P).animate({
opacity: 1
}, P);
N(this).remove()
});
U++;
if (U >= T) {
U = 0
}
}
setTimeout(S, Q)
}
X.find("> li").each(function () {
V.push("<li>" + N(this).html() + "</li>")
});
T = V.length;
X.wrap('<div class="spyWrapper" />').parent().css({
height: R * O
});
X.find("> li").filter(":gt(" + (O - 1) + ")").remove();
X.bind("stop", function () {
W = false
}).bind("start", function () {
W = true
});
S()
})
}
})(jQuery);
jQuery(function () {
if (j) {
jQuery("ul.spyrcp").simpleSpy(f, b, m).bind("mouseenter", function () {
jQuery(this).trigger("stop")
}).bind("mouseleave", function () {
jQuery(this).trigger("start")
})
}
})
} else {
$(g).html("<span>No result!</span>")
}
},
error: function () {
$(g).html("<strong>Error Loading Feed!</strong>")
}
})
};
return function (b) {
a(b)
}
})();
window.rccommnetsx = (function () {
var a = function (B) {
var e = B || {}, k = e.url_blog || window.location.host,
c = e.id_containrc || "#rcentcomnets",
m = e.numComments || 6,
j = e.avatarSize || 60,
i = e.animatedRecentcomments || false,
b = e.limitspyrkm || 4,
h = e.intervalspyrkm || 4000,
g = e.tickspeedrkm || 1000,
f = e.characters || 100,
A = e.defaultAvatar || "http://4.bp.blogspot.com/-AEWksK942OE/UFiyLzXJhiI/AAAAAAAAFKE/jBegaGPClxI/s70/user-anonymous-icon.png",
n = e.maxfeeds || 50,
d = e.adminBlog || "";
$.ajax({
url: "http://" + k + "/feeds/comments/default?alt=json-in-script",
type: "get",
dataType: "jsonp",
success: function (Q) {
var I, K = Q.feed.entry;
if (K !== undefined) {
I = "<ul class='rcomnetspy'>";
ntotal = 0;
for (var H = 0; H < n; H++) {
var G, M, J, C, L, E;
if (H == K.length) {
break
}
if (ntotal >= m) {
break
}
var P = K[H];
for (var F = 0; F < P.link.length; F++) {
if (P.link[F].rel == "alternate") {
G = P.link[F].href
}
}
for (var O = 0; O < P.author.length; O++) {
M = P.author[O].name.$t;
J = P.author[O].gd$image.src
}
if (M != d && ntotal < m) {
ntotal++;
I += "<li>";
if (J == "http://img1.blogblog.com/img/blank.gif") {
C = A
} else {
C = J.replace(/\/s[0-9]+(\-c|\/)/, "/s" + j + "$1")
}
var E = (P.author[0].uri) ? P.author[0].uri.$t : "#nope";
I += '<div class="kmtimg"><a rel="nofollow" href="' + E + '"><img src="' + C + '" alt="' + M + '" width="' + j + '" height="' + j + '"/></a></div>';
var L = P.gd$extendedProperty[1].value;
I += '<div class="ketkomt"><a rel="nofollow" href="' + G + '">' + M + "</a> <span>" + L + "</span></div>";
var N = P.content.$t;
var D = N.replace(/(<([^>]+)>)/gi, "");
if (D != "" && D.length > f) {
D = D.substring(0, f);
D += "…"
} else {
D = D
}
I += '<p class="komtsum">' + D + "</p>";
I += "</li>"
}
}
I += "</ul>";
$(c).html(I);
(function (R) {
R.fn.simpleSpyRkm = function (S, U, T) {
S = S || 4;
U = U || 5000;
T = T || 1000;
return this.each(function () {
var ab = R(this),
aa = true,
Z = [],
Y = S,
V = ab.find("> li:first").height(),
X = 0;
function W() {
if (aa) {
var ac = R(Z[Y]).css({
height: 0,
opacity: 0
}).prependTo(ab);
ab.find("> li:last").animate({
opacity: 0
}, T, function () {
ac.animate({
height: V
}, T).animate({
opacity: 1
}, T);
R(this).remove()
});
Y++;
if (Y >= X) {
Y = 0
}
}
setTimeout(W, U)
}
ab.find("> li").each(function () {
Z.push("<li>" + R(this).html() + "</li>")
});
X = Z.length;
ab.wrap('<div class="spyWrapperrkm" />').parent().css({
height: V * S
});
ab.find("> li").filter(":gt(" + (S - 1) + ")").remove();
ab.bind("stop", function () {
aa = false
}).bind("start", function () {
aa = true
});
W()
})
}
})(jQuery);
jQuery(function () {
if (i) {
jQuery("ul.rcomnetspy").simpleSpyRkm(b, h, g).bind("mouseenter", function () {
jQuery(this).trigger("stop")
}).bind("mouseleave", function () {
jQuery(this).trigger("start")
})
}
})
} else {
$(c).html("<span>No result!</span>")
}
},
error: function () {
$(c).html("<strong>Error Loading Feed!</strong>")
}
})
};
return function (b) {
a(b)
}
})();
window.breakingnews = (function () {
var a = function (d) {
var g = d || {}, b = g.url_blog || window.location.host,
f = g.breakingpostx || 8,
e = g.id_breaking || "#isibreakingnews",
h = g.animatedBreaking || true,
c = g.breakingcmtext || "Comments";
$.ajax({
url: "http://" + b + "/feeds/posts/default?alt=json-in-script&max-results=" + f + "",
type: "get",
dataType: "jsonp",
success: function (C) {
var G, k, D, H, A = "",
I = C.feed.entry;
if (I !== undefined) {
A = "<ul>";
for (var E = 0; E < I.length; E++) {
for (var B = 0; B < I[E].link.length; B++) {
if (I[E].link[B].rel == "alternate") {
G = I[E].link[B].href;
break
}
}
for (var m = 0; m < I[E].link.length; m++) {
if (I[E].link[m].rel == "replies" && I[E].link[m].type == "text/html") {
D = I[E].link[m].title.split(" ")[0];
break
}
}
k = I[E].title.$t;
H = I[E].published.$t.substring(0, 10);
H = H.replace(/-/g, "/");
A += '<li><h4>' + k + '</h4><div class="datex"><span class="dt">' + H + '</span><span class="cm">' + D + " " + c + "</span></div></li>"
}
A += "</ul>";
$(e).html(A);
if (h) {
function F() {
$("#isibreakingnews ul li:first").animate({
opacity: 0
}, 200, function () {
$(this).appendTo($("#isibreakingnews ul")).css("opacity", 1)
})
}
var n = setInterval(function () {
F()
}, 3000);
$(e).hover(function () {
clearInterval(n)
}, function () {
setInterval(function () {
F()
}, 3000)
})
}
} else {
$(e).html("<span>No result!</span>")
}
},
error: function () {
$(e).html("<strong>Error Loading Feed!</strong>")
}
})
};
return function (b) {
a(b)
}
})()
} else {
$(z).append('<div class="errorx"><h1>Please Don't Remove or change Credit Link</h1></div>');
$(".errorx").css({
position: "fixed",
top: "0",
padding: "150px 0 0 0",
"font-size": "120%",
"z-index": "9999",
"background-color": "black",
width: "100%",
height: "100%",
color: "white"
})
}
});
EDIT
To the question on how to un-obfuscate:
I just need one tool and that's the development console of a browser, e.g., Firebug.
Then search the code above for the call of eval(). Here it was just called once, sometimes it is called multiple times (even recursive calls can happen). Replace each occurrence of eval() with something like console.log(). That way instead of running the code, it is just printed to the console.
Then run it through an online js-beautifier like http://jsbeautifier.org/ and you have the above code.

Categories