Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function (a) {
- var b = !1,
- c = [],
- d = function () {
- if (!b && (b = !0, a.htmlNode = geByTag1("html"), a.bodyNode = geByTag1("body"), c)) {
- for (var d = null; d = c.shift();) d.call(document);
- c = null
- }
- };
- document.addEventListener ? document.addEventListener("DOMContentLoaded", function () {
- document.removeEventListener("DOMContentLoaded", arguments.callee, !1);
- d()
- }, !1) : document.attachEvent && document.attachEvent("onreadystatechange", function () {
- "complete" === document.readyState && (document.detachEvent("onreadystatechange", arguments.callee), d())
- });
- a.addEventListener ? a.addEventListener("load", d, !1) : a.attachEvent ? a.attachEvent("onload", d) : a.onload = d;
- a.onDOMReady = function (a) {
- b ? a.call(document) : c.push(a)
- }
- })(window);
- if (!window._ua) var _ua = navigator.userAgent.toLowerCase();
- var browser = {
- version: (_ua.match(/.+(?:me|ox|on|rv|it|era|ie)[\/: ]([\d.]+)/) || [0, "0"])[1],
- opera: /opera/i.test(_ua),
- msie: /msie/i.test(_ua) && !/opera/i.test(_ua),
- msie6: /msie 6/i.test(_ua) && !/opera/i.test(_ua),
- msie7: /msie 7/i.test(_ua) && !/opera/i.test(_ua),
- msie8: /msie 8/i.test(_ua) && !/opera/i.test(_ua),
- msie9: /msie 9/i.test(_ua) && !/opera/i.test(_ua),
- mozilla: /firefox/i.test(_ua),
- chrome: /chrome/i.test(_ua),
- safari: !/chrome/i.test(_ua) && /webkit|safari|khtml/i.test(_ua),
- iphone: /iphone/i.test(_ua),
- ipod: /ipod/i.test(_ua),
- iphone4: /iphone.*OS 4/i.test(_ua),
- ipod4: /ipod.*OS 4/i.test(_ua),
- ipad: /ipad/i.test(_ua),
- android: /android/i.test(_ua),
- bada: /bada/i.test(_ua),
- opera_mini: /opera mini/i.test(_ua),
- mobile: /iphone|ipod|ipad|opera mini|opera mobi|iemobile/i.test(_ua),
- msie_mobile: /iemobile/i.test(_ua),
- safari_mobile: /iphone|ipod|ipad/i.test(_ua),
- opera_mobile: /opera mini|opera mobi/i.test(_ua),
- mac: /mac/i.test(_ua)
- };
- browser.desktop = (browser.opera || browser.msie || browser.mozilla || browser.chrome || browser.safari) && !browser.mobile;
- var isTouch = "ontouchstart" in window;
- function setDocumentDomain() {
- var a = (document.domain || "").match(/(m\.)?([a-zA-Z]+\.[a-zA-Z]+\.?)$/);
- window.locDomain = "https:" == location.protocol ? a[2] : a[0];
- a = navigator.userAgent.toLowerCase();
- if (/opera/i.test(a) || !/msie 6/i.test(a) || document.domain != locDomain) document.domain = locDomain
- }
- function isFunction(a) {
- return "[object Function]" === Object.prototype.toString.call(a)
- }
- function isArray(a) {
- return "[object Array]" === Object.prototype.toString.call(a)
- }
- function isObject(a) {
- return "[object Object]" === Object.prototype.toString.call(a)
- }
- function escapeRE(a) {
- return a ? a.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1") : ""
- }
- function htsc(a) {
- return a.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/\'/g, "'").replace(/%/g, "%")
- }
- function escapeAttr(a) {
- return a.replace(/&/g, "&").replace(/"/g, """).replace(/\'/g, "'")
- }
- function replaceEntities(a) {
- return ce("textarea", {
- innerHTML: (a || "").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """)
- }).value
- }
- function stripTags(a) {
- return a.replace(/<[^>]+>/g, "")
- }
- function vkNow() {
- return +new Date
- }
- function intval(a) {
- return !0 === a ? 1 : parseInt(a) || 0
- }
- function qs2obj(a) {
- if (!a) return {};
- var b = {};
- a = a.toString().split("&");
- for (var c = 0, d = a.length; c < d; c++) {
- var e = a[c].split("=");
- e[0] && (b[decodeURIComponent(e[0])] = decodeURIComponent(e[1] || ""))
- }
- return b
- }
- function obj2qs(a) {
- if (!a) return "";
- var b = [],
- c;
- for (c in a) b.push(encodeURIComponent(c) + "=" + encodeURIComponent(a[c].toString() || ""));
- return b.length ? "?" + b.join("&") : ""
- }
- function parseJSON(a) {
- try {
- return JSON.parse(a)
- } catch (b) {
- return eval("(" + a + ")")
- }
- }
- function lsSet(a, b) {
- if ("undefined" !== typeof b) try {
- return localStorage.setItem(a, b)
- } catch (c) {} else try {
- return localStorage.removeItem(a)
- } catch (d) {}
- return !1
- }
- function lsGet(a) {
- try {
- return localStorage.getItem(a)
- } catch (b) {}
- return !1
- }
- function ssSet(a, b) {
- if ("undefined" !== typeof b) try {
- return sessionStorage.setItem(a, b)
- } catch (c) {} else try {
- return sessionStorage.removeItem(a)
- } catch (d) {}
- return !1
- }
- function ssGet(a) {
- try {
- return sessionStorage.getItem(a)
- } catch (b) {}
- return !1
- }
- function getValues(a) {
- if (!isArray(a)) return a.call ? a() : a;
- for (var b = [], c = 0, d = a.length; c < d; c++) b.push(getValues(a[c]));
- return b
- }
- function len(a) {
- if (isArray(a)) return a.length;
- if (isObject(a)) {
- var b = 0,
- c;
- for (c in a) b++;
- return b
- }
- return 0
- }(function () {
- var a = vkNow();
- window.clog = function (b) {
- if (vk.__debug) try {
- if (window.console && console.log) {
- var c = Array.prototype.slice.call(arguments);
- c.unshift("[" + (vkNow() - a) / 1E3 + "] ");
- browser.msie || browser.mobile ? console.log(c.join(" ")) : console.log.apply(console, c)
- }
- } catch (d) {}
- }
- })();
- function each(a, b) {
- var c, d = 0,
- e = a.length;
- if ("undefined" === typeof e) for (c in a) {
- if (!1 === b.call(a[c], c, a[c])) break
- } else for (c = a[0]; d < e && !1 !== b.call(c, d, c); c = a[++d]);
- return a
- }
- function copy(a) {
- return isArray(a) ? a.concat([]) : isObject(a) ? extend({}, a) : a
- }
- var rf = function () {
- return !1
- };
- function addEvent(a, b, c) {
- a = ge(a);
- c = c || rf;
- if (a && !(3 == a.nodeType || 8 == a.nodeType)) {
- a.setInterval && a != window && (a = window);
- b = b.split(" ");
- for (var d = 0, e = b.length; d < e; d++) {
- var f = b[d];
- a.addEventListener ? a.addEventListener(f, c, !1) : a.attachEvent && a.attachEvent("on" + f, c)
- }
- }
- }
- function removeEvent(a, b, c) {
- a = ge(a);
- c = c || rf;
- if (a && !(3 == a.nodeType || 8 == a.nodeType)) {
- b = b.split(" ");
- for (var d = 0, e = b.length; d < e; d++) {
- var f = b[d];
- a.removeEventListener ? a.removeEventListener(f, c, !1) : a.detachEvent && a.detachEvent("on" + f, c)
- }
- }
- }
- function cancelEvent(a) {
- a = a || window.event;
- if (!a) return !1;
- a = a.originalEvent || a;
- a.preventDefault && a.preventDefault();
- a.stopPropagation && a.stopPropagation();
- a.cancelBubble = !0;
- return a.returnValue = !1
- }
- function checkEvent(a) {
- return (a = a || window.event) && ("click" == a.type || "mousedown" == a.type || "mouseup" == a.type) && (1 < a.which || 1 < a.button || a.ctrlKey || a.shiftKey || a.metaKey)
- }
- function onCtrlEnter(a, b, c) {
- b = b || window.event;
- if (10 == b.keyCode || 13 == b.keyCode && (b.ctrlKey || b.metaKey && browser.mac)) c.call(a), cancelEvent(b)
- }
- function submitBtn(a) {
- if (!a) return !1;
- a = (a = a.form || gpeByTag("form", a)) ? geByClass("btn", a, "input") : !1;
- if (!a) return !1;
- for (var b in a) {
- var c = a[b];
- if ("submit" == c.type && !c.name) break
- }
- return c
- }
- function parseCyr(a, b) {
- for (var c = a, d = "yo zh kh ts ch sch shch sh eh yu ya YO ZH KH TS CH SCH SHCH SH EH YU YA '".split(" "), e = "\u0451\u0436\u0445\u0446\u0447\u0449\u0449\u0448\u044d\u044e\u044f\u0401\u0416\u0425\u0426\u0427\u0429\u0429\u0428\u042d\u042e\u042f\u044c".split(""), f = 0, g = d.length; f < g; f++) c = b ? c.split(d[f]).join(e[f]) : c.split(e[f]).join(d[f]);
- f = 0;
- for (g = 48; f < g; f++) c = b ? c.split("abvgdezijklmnoprstufhcyABVGDEZIJKLMNOPRSTUFHCY\u0451\u0401".charAt(f)).join("\u0430\u0431\u0432\u0433\u0434\u0435\u0437\u0438\u0439\u043a\u043b\u043c\u043d\u043e\u043f\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u044b\u0410\u0411\u0412\u0413\u0414\u0415\u0417\u0418\u0419\u041a\u041b\u041c\u041d\u041e\u041f\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u042b\u0435\u0415".charAt(f)) : c.split("\u0430\u0431\u0432\u0433\u0434\u0435\u0437\u0438\u0439\u043a\u043b\u043c\u043d\u043e\u043f\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u044b\u0410\u0411\u0412\u0413\u0414\u0415\u0417\u0418\u0419\u041a\u041b\u041c\u041d\u041e\u041f\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u042b\u0435\u0415".charAt(f)).join("abvgdezijklmnoprstufhcyABVGDEZIJKLMNOPRSTUFHCY\u0451\u0401".charAt(f));
- return c == a ? null : c
- }
- function parseLat(a) {
- return parseCyr(a, !0)
- }
- function parseRusKeys(a, b, c) {
- if (!b) return null;
- b = a;
- for (var d = 0; 68 > d; d++) b = c ? b.split("qwertyuiop[]asdfghjkl;'zxcvbnm,./`QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>?~".charAt(d)).join("\u0439\u0446\u0443\u043a\u0435\u043d\u0433\u0448\u0449\u0437\u0445\u044a\u0444\u044b\u0432\u0430\u043f\u0440\u043e\u043b\u0434\u0436\u044d\u044f\u0447\u0441\u043c\u0438\u0442\u044c\u0431\u044e.\u0451\u0419\u0426\u0423\u041a\u0415\u041d\u0413\u0428\u0429\u0417\u0425\u042a\u0424\u042b\u0412\u0410\u041f\u0420\u041e\u041b\u0414\u0416\u042d\u042f\u0427\u0421\u041c\u0418\u0422\u042c\u0411\u042e,\u0401".charAt(d)) : b.split("\u0439\u0446\u0443\u043a\u0435\u043d\u0433\u0448\u0449\u0437\u0445\u044a\u0444\u044b\u0432\u0430\u043f\u0440\u043e\u043b\u0434\u0436\u044d\u044f\u0447\u0441\u043c\u0438\u0442\u044c\u0431\u044e.\u0451\u0419\u0426\u0423\u041a\u0415\u041d\u0413\u0428\u0429\u0417\u0425\u042a\u0424\u042b\u0412\u0410\u041f\u0420\u041e\u041b\u0414\u0416\u042d\u042f\u0427\u0421\u041c\u0418\u0422\u042c\u0411\u042e,\u0401".charAt(d)).join("qwertyuiop[]asdfghjkl;'zxcvbnm,./`QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>?~".charAt(d));
- return b == a ? null : b
- }
- function parseLatKeys(a, b) {
- return parseRusKeys(a, b, !0)
- }
- function scrollTop(a, b) {
- if ("undefined" === typeof a) return htmlNode.scrollTop || bodyNode.scrollTop || window.scrollY || 0;
- b ? setTimeout(function () {
- window.scrollTo(0, Math.max(browser.android ? 1 : 0, a))
- }, b) : window.scrollTo(0, Math.max(browser.android ? 1 : 0, a))
- }
- function se() {
- var a = [],
- b = Array.prototype.slice.call(arguments);
- return function (c) {
- if (c) if (c.apply) a.push(c);
- else if ("__clear" === c) a = [];
- else {
- var d = Array.prototype.slice.call(arguments);
- d.shift();
- for (var e = 0, f = a.length; e < f; e++) a[e].apply(window, getValues(b).concat(d))
- }
- }
- }
- window.onBodyScroll = se(scrollTop);
- window.onBodyResize = se();
- addEvent(window, "scroll touchmove", function () {
- onBodyScroll(!0)
- });
- addEvent(window, "error", function (a) {
- console.log("line: " + a.lineno)
- });
- function initAutoScroll(a, b, c) {
- a && b && onBodyScroll(function (d) {
- var e = getValues(a);
- if (e) {
- var f = getY(e),
- g = getCh();
- f - d - g < (c || g) && b.call(e)
- }
- })
- }
- function autoScroll(a, b, c, d) {
- var e = getValues(a),
- f = ge("show_more_loading"),
- g = function () {
- ajax.click(this, b, {
- use_cache: !c
- })
- };
- !e && f && g.call(f);
- initAutoScroll(a, g, d)
- }
- function scrollToEl(a, b, c) {
- a = ge(a) || window;
- a = (a === window ? 1 : getY(a)) - (b || 0);
- scrollTop(a, c)
- }
- function scrollToHash(a) {
- a = a || nav.hash || location.hash;
- "#" === a[0] && (a = a.substr(1));
- if (a) {
- var b = geBySel("a[name]");
- !1 === b && (b = geByTag("a"));
- each(b, function (b, d) {
- if (d.name == a) return scrollToEl(d), !1
- })
- }
- }
- function lockButton(a) {
- a = ge(a);
- if ("input" == tag(a) && hasClass("btn", a)) {
- var b = ce("button", {
- id: a.id,
- className: "locked" + (hasClass("sbtn", a) ? " sbtn" : ""),
- innerHTML: "<span><b>" + (a.value || "") + "</b></span>",
- onclick: function (a) {
- return cancelEvent(a)
- },
- real_btn: a
- });
- a.fake_btn = b;
- before(b, a);
- remove(a)
- }
- }
- function unlockButton(a) {
- a = ge(a);
- a.real_btn ? (before(a.real_btn, a), remove(a)) : a.fake_btn && (before(a, a.fake_btn), remove(a.fake_btn))
- }
- function extend() {
- var a = Array.prototype.slice.call(arguments),
- b = a.shift();
- if (!a.length) return b;
- for (var c = 0, d = a.length; c < d; c++) for (var e in a[c]) b[e] = a[c][e];
- return b
- }
- function ge(a) {
- return "string" === typeof a ? document.getElementById(a) : a
- }
- function geByClass(a, b, c) {
- b = ge(b) || document;
- c = c || "*";
- if (b.getElementsByClassName) {
- b = b.getElementsByClassName(a);
- if ("*" == c) return Array.prototype.slice.call(b);
- var d = [];
- c = c.toUpperCase();
- a = 0;
- for (var e = b.length; a < e; a++) b[a].tagName.toUpperCase() == c && d.push(b[a]);
- return d
- }
- b = geByTag(c, b);
- d = [];
- c = RegExp("(^|\\s)" + escapeRE(a) + "(\\s|$)");
- a = 0;
- for (e = b.length; a < e; a++) c.test(b[a].className) && d.push(b[a]);
- return d
- }
- function geByClass1(a, b, c) {
- return geByClass(a, b, c)[0]
- }
- function gpeByClass(a, b) {
- b = ge(b);
- if (!b) return null;
- for (; b = b.parentNode;) if (hasClass(a, b)) return b;
- return null
- }
- function geByTag(a, b) {
- return (ge(b) || document).getElementsByTagName(a)
- }
- function geByTag1(a, b) {
- return geByTag(a, b)[0]
- }
- function gpeByTag(a, b) {
- b = ge(b);
- if (!b) return null;
- for (a = a.toUpperCase(); b = b.parentNode;) if (b.tagName.toUpperCase() == a) return b;
- return null
- }
- function geBySel(a, b) {
- b = ge(b) || document;
- return b.querySelectorAll ? b.querySelectorAll(a) : !1
- }
- function geBySel1(a, b) {
- b = ge(b) || document;
- return b.querySelector ? b.querySelector(a) : !1
- }
- function append(a, b) {
- (b = ge(b)) && b.appendChild(ge(a))
- }
- function before(a, b) {
- (b = ge(b)) && b.parentNode && b.parentNode.insertBefore(ge(a), b)
- }
- function after(a, b) {
- (b = ge(b)) && b.parentNode && (b.nextSibling ? b.parentNode.insertBefore(ge(a), b.nextSibling) : b.parentNode.appendChild(ge(a)))
- }
- function remove(a) {
- return (a = ge(a)) && a.parentNode ? a.parentNode.removeChild(a) : !1
- }
- function clone(a) {
- return (a = ge(a)) ? a.cloneNode(!0) : !1
- }
- function tag(a) {
- a = ge(a);
- return (a && a.tagName || "").toLowerCase()
- }
- function outer(a) {
- a = ge(a);
- return !a ? "" : val(ce("div").appendChild(clone(a)).parentNode)
- }
- function show(a) {
- if (a = ge(a)) a.style.display = a.oldstyle || ("span" == tag(a) || hasClass("i", a) ? "inline" : "block")
- }
- function hide(a) {
- if (a = ge(a)) "none" != a.style.display && (a.oldstyle = a.style.display), a.style.display = "none"
- }
- function isVisible(a) {
- a = ge(a);
- return !a || !a.style ? !1 : "none" != a.style.display
- }
- function toggle(a, b) {
- "undefined" === typeof b && (b = !isVisible(a));
- (b ? show : hide)(a)
- }
- function ce(a, b, c) {
- a = document.createElement(a);
- b && extend(a, b);
- c && extend(a.style, c);
- return a
- }
- window.cdf = function (a) {
- var b = a.createDocumentFragment(),
- c = a.createElement("div"),
- d = a.createRange && a.createRange();
- b && b.appendChild(c);
- d && d.selectNodeContents && d.selectNodeContents(c);
- return !b ? function (a) {
- return ce("div", {
- innerHTML: a
- })
- } : d && d.createContextualFragment ? function (b) {
- return !b ? a.createDocumentFragment() : d.createContextualFragment(b)
- } : function (b) {
- if (!b) return a.createDocumentFragment();
- c.innerHTML = b;
- for (b = a.createDocumentFragment(); c.firstChild;) b.appendChild(c.firstChild);
- return b
- }
- }(document);
- function elfocus(a, b, c) {
- a = ge(a);
- try {
- a.focus();
- if ("undefined" === typeof b || !1 === b) b = a.value.length;
- if ("undefined" === typeof c || !1 === c) c = b;
- if (a.createTextRange) {
- var d = a.createTextRange();
- d.collapse(!0);
- d.moveEnd("character", b);
- d.moveStart("character", c);
- d.select()
- } else a.setSelectionRange && a.setSelectionRange(b, c)
- } catch (e) {}
- }
- function elblur(a) {
- (a = ge(a)) && a.blur && a.blur()
- }
- function val(a, b) {
- if (a = ge(a)) {
- var c = a.tagName.toLowerCase(),
- d = "input" == c || "textarea" == c || "select" == c;
- if ("undefined" === typeof b) return d ? a.value : a.innerHTML;
- d ? a.value = b : (a.innerHTML = b, "a" != c && (ajax.prepare_nav(a), ajax.prepare_click(a), ajax.onPrepared(!0, a)))
- }
- }
- function attr(a, b, c) {
- if (a = ge(a)) {
- if ("undefined" === typeof c) return a.getAttribute && a.getAttribute(b) || !1;
- if (!1 === c) return a.removeAttribute && a.removeAttribute(b) || !1;
- a.setAttribute && a.setAttribute(b, c)
- }
- }
- function style(a, b, c) {
- if ((a = ge(a)) && a.style) {
- if (isObject(b)) return each(b, function (b, c) {
- style(a, b, c)
- });
- var d = "number" === typeof c;
- d && /height|width/i.test(b) && (c = Math.abs(c));
- a.style[b] = d && !/z-?index|font-?weight|opacity|zoom|line-?height/i.test(b) ? c + "px" : c
- }
- }
- function hasClass(a, b) {
- if (b = ge(b)) return RegExp("(^|\\s)" + escapeRE(a) + "(\\s|$)").test(b.className)
- }
- function addClass(a, b) {
- if ((b = ge(b)) && !hasClass(a, b)) b.className = (b.className ? b.className + " " : "") + a
- }
- function removeClass(a, b, c) {
- if (b = ge(b)) b.className = (b.className || "").replace(RegExp("(^|\\s)" + (c ? a : escapeRE(a)) + "(\\s|$)"), function (a, b, c) {
- return b && c ? " " : ""
- })
- }
- function toggleClass(a, b, c) {
- ("undefined" === typeof c ? hasClass(a, b) : !c) ? removeClass(a, b) : addClass(a, b)
- }
- function replaceClass(a, b, c, d) {
- removeClass(a, c, d);
- addClass(b, c)
- }
- function switchClass(a, b, c) {
- hasClass(a, c) ? replaceClass(a, b, c) : replaceClass(b, a, c)
- }
- function getXY(a) {
- a = ge(a);
- if (!a) return [0, 0];
- var b = 0,
- c = 0;
- if (a.offsetParent) {
- do b += a.offsetLeft, c += a.offsetTop;
- while (a = a.offsetParent)
- }
- return [b, c]
- }
- function getX(a) {
- return getXY(a)[0]
- }
- function getY(a) {
- return getXY(a)[1]
- }
- function getW(a) {
- return (a = ge(a)) && a.offsetWidth || 0
- }
- function getH(a) {
- return (a = ge(a)) && a.offsetHeight || 0
- }
- function getCw() {
- return Math.max(window.innerWidth || 0, (window.htmlNode || {}).clientWidth || 0)
- }
- function getCh() {
- return Math.max(window.innerHeight || 0, (window.htmlNode || {}).clientHeight || 0)
- }
- function evalJs(a) {
- window.execScript ? window.execScript(a) : eval.call(window, a)
- }
- function alLoadingFix(a, b) {
- b = b || "al_loading";
- var c = ge(b);
- if (c) {
- if (!a) {
- var d = ge("m").offsetHeight || 0,
- e = ge("mfoot").offsetHeight || 0;
- a = getCh() - d + e
- }
- c.style.height = a + "px";
- addClass(b, c)
- }
- }
- function getHref(a) {
- if (!a) return !1;
- var b = !1;
- a.getAttribute && (b = a.getAttribute("data-href") || a.getAttribute("href"));
- b || (b = a.pathname ? a.pathname + a.search + a.hash : a);
- return b || !1
- }
- function ajx2q(a) {
- var b = [],
- c = function (a) {
- try {
- return encodeURIComponent(a)
- } catch (b) {
- return a
- }
- }, d;
- for (d in a) if (!(null == a[d] || isFunction(a[d]))) if (isArray(a[d])) for (var e = 0, f = 0, g = a[d].length; e < g; ++e) null == a[d][e] || isFunction(a[d][e]) || (b.push(c(d) + "[" + f + "]=" + c(a[d][e])), ++f);
- else b.push(c(d) + "=" + c(a[d]));
- b.sort();
- return b.join("&")
- }
- function indexOf(a, b, c) {
- c = c || 0;
- for (var d = (a || []).length; c < d; c++) if (a[c] == b) return c;
- return -1
- }
- function langNumeric(a, b, c) {
- if (!b || !window.langConfig) return a;
- var d;
- isArray(b) ? (d = b[1], a != Math.floor(a) ? d = b[langConfig.numRules["float"]] : each(langConfig.numRules["int"], function (c, e) {
- if ("*" == e[0] || -1 != indexOf(e[1], e[0] ? a % e[0] : a)) return d = b[e[2]], !1
- })) : d = b;
- if (c) {
- c = a.toString().split(".");
- for (var e = [], f = c[0].length - 3; - 3 < f; f -= 3) e.unshift(c[0].slice(0 < f ? f : 0, f + 3));
- c[0] = e.join(langConfig.numDel);
- a = c.join(langConfig.numDec)
- }
- return d = (d || "%s").replace("%s", a)
- }
- function setNotify(a) {
- a = intval(a);
- var b = ge("header_msgs"),
- c = geByClass1("pcont main");
- b && (val(b, "<i></i>" + (0 < a ? "<em>" + a + "</em>" : "")), 0 < a ? removeClass("no_notify", b) : addClass("no_notify", b), c && (b = geByClass1("mail", geByClass1("main_menu", c)), geByTag1("a", b), b = geByTag1("span", b), c = geByTag1("em", b), 0 < a ? c ? val(c, a) : append(ce("em", {
- innerHTML: a
- }), b) : remove(c)))
- }
- function getNotify() {
- var a = ge("header_msgs");
- return !a ? 0 : intval(val(geByTag1("em", a)))
- }
- window.cur = {};
- window.lang = {};
- var geo = {
- _def_opts: {
- enableHighAccuracy: !0,
- maximumAge: 3E5,
- timeout: 6E4
- },
- _provider: null,
- initW3C: function () {
- geo._provider = navigator.geolocation;
- geo.getCurrentPosition = function (a, b, c) {
- geo._provider.getCurrentPosition(function (b) {
- "undefined" !== typeof b.latitude ? a(extend(b, {
- coords: extend(b.coords || {}, {
- latitude: b.latitude,
- longitude: b.longitude
- })
- })) : a(b)
- }, b, c)
- }
- },
- initGears: function () {
- clog("initGears");
- geo._provider = google.gears.factory.create("beta.geolocation")
- },
- initSymbian: function () {
- clog("initSymbian");
- geo._provider = device.getServiceObject("Service.Location", "ILocation");
- geo.getCurrentPosition = function (a, b) {
- geo._provider.ILocation.GetLocation({
- LocationInformationClass: "BasicLocationInformation"
- }, function (c, d, e) {
- 4 == d ? b({
- code: 2,
- message: "Position unavailable"
- }) : a({
- timestamp: null,
- coords: {
- latitude: e.ReturnValue.Latitude,
- longitude: e.ReturnValue.Longitude,
- altitude: e.ReturnValue.Altitude,
- heading: e.ReturnValue.Heading
- }
- })
- })
- }
- },
- initPalm: function () {
- clog("initPalm");
- geo.getCurrentPosition = function (a, b, c) {
- var d = {};
- c && (c.enableHighAccuracy && !0 == c.enableHighAccuracy && (d.accuracy = 1), c.maximumAge && (d.maximumAge = c.maximumAge), c.responseTime && (5 > c.responseTime ? d.responseTime = 1 : 20 > c.responseTime ? d.responseTime = 2 : d.timeout = 3));
- new Mojo.Service.Request("palm://com.palm.location", {
- method: "getCurrentPosition",
- parameters: d,
- onSuccess: function (b) {
- a({
- timestamp: b.timestamp,
- coords: {
- latitude: b.latitude,
- longitude: b.longitude,
- heading: b.heading
- }
- })
- },
- onFailure: function (a) {
- 1 == a.errorCode ? b({
- code: 3,
- message: "Timeout"
- }) : 2 == a.errorCode ? b({
- code: 2,
- message: "Position unavailable"
- }) : b({
- code: 0,
- message: "Unknown Error: webOS-code" + errorCode
- })
- }
- })
- }
- },
- getCurrentPosition: function (a, b, c) {
- geo._provider.getCurrentPosition(a, b, extent(geo._def_opts, c || {}))
- },
- init: function () {
- try {
- if ("undefined" !== typeof navigator.geolocation) geo.initW3C();
- else if ("undefined" !== typeof window.google && "undefined" !== typeof google.gears) geo.initGears();
- else if ("undefined" !== typeof device && "undefined" !== typeof device.getServiceObject) geo.initSymbian();
- else if ("undefined" !== typeof Mojo && "Mojo.Service.Request" !== typeof Mojo.Service.Request) geo.initPalm();
- else return !1
- } catch (a) {
- return !1
- }
- return !0
- }
- }, ajax = {
- _tStart: !1,
- _tAlStart: !1,
- _init: function () {
- try {
- new XMLHttpRequest && (ajax._req = function () {
- return new XMLHttpRequest
- })
- } catch (a) {
- try {
- new ActiveXObject("Msxml2.XMLHTTP") && (ajax._req = function () {
- return new ActiveXObject("Msxml2.XMLHTTP")
- })
- } catch (b) {
- try {
- new ActiveXObject("Microsoft.XMLHTTP") && (ajax._req = function () {
- return new ActiveXObject("Microsoft.XMLHTTP")
- })
- } catch (c) {
- ajax._req = !1
- }
- }
- }
- },
- _getreq: function () {
- ajax._req || ajax._init();
- return ajax._req()
- },
- _al_reqs: [],
- _last_req: null,
- save_req: function (a) {
- ajax._al_reqs.push(a || ajax._last_req)
- },
- abort_reqs: function () {
- var a = [];
- each(ajax._al_reqs, function (b, c) {
- a.push(c.readyState);
- 4 > c.readyState && c.abort()
- });
- ajax._al_reqs = [];
- clog(a)
- },
- plainpost: function (a, b, c, d, e) {
- var f = ajax._last_req = ajax._getreq();
- b = "string" != typeof b ? ajx2q(b) : b;
- f.onreadystatechange = function () {
- 4 == f.readyState && (200 <= f.status && 300 > f.status ? c && c(f.responseText, f) : d && d(f.responseText, f))
- };
- try {
- f.open("POST", a, !0)
- } catch (g) {
- return !1
- }
- e || (f.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"), f.setRequestHeader("X-Requested-With", "XMLHttpRequest"));
- f.send(b);
- return f
- },
- post: function (a, b, c) {
- "/" != a.substr(0, 1) && (a = "/" + a);
- return ajax._post(a, b, c || {})
- },
- onPrepared: se(),
- prepare_click: function (a) {
- if (isTouch && window.al && al.ver) {
- var b = [],
- c = !1;
- a && "a" == (a.tagName || "").toLowerCase() ? b.push(a) : isArray(a) ? b = a : (b = geByTag("a", a), c = !0);
- if (b[0] && b[0].getAttribute) {
- a = 0;
- for (var d = b.length; a < d; a++) {
- var e = b[a],
- f = attr(e, "onclick") || "",
- g = e && e.target || "";
- if ((!c || !attr(e, "data-href") && f && "_blank" != g) && null != attr(e, "href")) attr(e, "data-href", getHref(e)), attr(e, "href", !1)
- }
- }
- }
- },
- click: function (a, b, c) {
- b = b || {};
- var d = !1,
- e = {
- _ajax: 1
- }, f = extend(b, {
- link: a
- });
- c = c || {};
- if (b.onStart) {
- var g = ajax.tAlGetParam();
- ajax.tAlStart = (new Date).getTime();
- g && (e._talstat = g)
- }
- if (c.use_cache) {
- var j = ge(!0 === c.use_cache ? "preload_data" : c.use_cache),
- e = j.innerHTML.replace(/(^\x3c!--|--\x3e$)/g, ""),
- g = e.split("--\x3e\x3c!--");
- e ? (j.innerHTML = "", b.onStart && b.onStart.apply(f), c.nav && nav.go(d, null, {
- push_only: !0
- }), b.onDone && b.onDone.apply(f, g), (a = geByClass1("show_more", geByClass1("pcont", "mcont"))) && ajax.click(a, {
- onDone: function () {
- var a = "";
- each(arguments, function (b, c) {
- a += "\x3c!--" + (c || "") + "--\x3e"
- });
- j.innerHTML = a;
- ge("show_more_loading") && ajax.click(!1, b, c)
- }
- })) : (b.onStart && b.onStart.apply(f), c.nav && nav.go(d, null, {
- push_only: !0
- }));
- return !1
- }
- if (!a) return !0;
- if (a.form) {
- var g = a.form,
- l = {}, d = (g.action || "").replace(/^https?:\/\/[^\/]+/i, "");
- each(g, function (b, c) {
- if (!c.name || c.disabled || "radio" === c.type && !c.checked || "checkbox" === c.type && !c.checked || "button" === c.type || "submit" === c.type && c !== a || "image" === c.type && c !== a) return !0;
- l[c.name] = c.value
- });
- !g.method || "get" == g.method ? d = d.split("?", 1).shift() + obj2qs(l) : extend(e, l)
- } else a.getAttribute && (d = a.getAttribute("data-href") || a.getAttribute("href"));
- d || (d = a.pathname ? a.pathname + a.search + a.hash : a);
- if (!d) return !0;
- extend(e, c.url_params || {});
- if (e = ajax.post(d, e, {
- onDone: function () {
- c.lock && unlockButton(a);
- b.onDone && b.onDone.apply(f, arguments);
- (c.nav || c.scroll) && scrollToHash()
- },
- onFail: function () {
- c.lock && unlockButton(a);
- b.onFail && b.onFail.apply(f, arguments);
- (c.nav || c.scroll) && scrollToHash()
- }
- })) b.onStart && b.onStart.apply(f), c.nav && nav.go(d, null, {
- push_only: !0
- }), c.lock && lockButton(a);
- return !e
- },
- prepare_nav: function (a) {
- if (window.al && al.ver) {
- var b = [],
- c = !1;
- a && "a" == tag(a) ? b.push(a) : isArray(a) ? b = a : (b = geByTag("a", a), c = !0);
- for (var d = 0, e = b.length; d < e; d++) {
- var f = b[d];
- addEvent(f, "touchstart", thover.start);
- if (!c || !attr(f, "onclick") && attr(f, "href")) {
- var g = f.hostname || (/^(https?:)\/\/([^:\/]+)?(?::(\d+))?\/?(.*)$/i.exec(f.href) || [])[2];
- "_blank" !== f.target && g == location.hostname && attr(f, "onclick", "return nav.go(this, event);")
- }
- }
- a = geByTag("input", a);
- d = 0;
- for (e = a.length; d < e; d++) b = a[d], b.form && ("submit" == b.type && !b.getAttribute("onclick")) && attr(b, "onclick", "return nav.go(this, event);")
- }
- },
- nav: function (a, b) {
- b = b || {};
- b.nav = b.nav || {};
- var c = getHref(a),
- d, e = page.getHash(b.nav);
- if (!(c = nav.checkUrl(c))) return !1;
- "/" != c.substr(0, 1) && (c = "/" + c);
- menu.close(null, !0);
- var f = ajax.tGetParam();
- ajax.tStart = (new Date).getTime();
- b.need_restore && menu && menu.closeSearch();
- if (b.need_restore && b.nav.push && page.restore(e)) return ajax.abort_reqs(), nav.set(b), ajax.tModule = cur.module, ajax.tRestoreRender = (new Date).getTime(), !0;
- var g = !1,
- j = !1;
- if (b.fast) g = !0, page.set(e, !1, {
- before: !0,
- beforeAppend: b.beforeAppend,
- afterAppend: b.afterAppend
- });
- else if (b.target && b.target.className) {
- var l = (d = /(?:^|\s)(al_([a-z_]+)(-?[0-9]+)?)(?:\s|$)/i.exec(b.target.className)) && d[1] || !1,
- h = d && d[2] || !1,
- k;
- switch (h) {
- case "menu":
- g = !0;
- page.set(e, !1, {
- before: !0,
- beforeAppend: function (a) {
- val(geByClass1("mcont", a), '<div class="pcont bl_cont"><div id="al_loading"></div></div>');
- var c = b.target.getAttribute("data-header") || "",
- d = geByClass1("mhead", a);
- geByClass1("btn logo", d) ? val(d, "" + (window.al && window.al.menu ? '<div class="btn home"><a href="/" class="b" accesskey="*" onclick="return menu.toggle(event);"><i></i></a></div>' : '<div class="btn home vk_home"><a href="/" class="b" accesskey="*"><i></i></a></div>') + '<div class="btn notify">' + val(geByClass1("btn notify", a)) + '</div><div class="btn back"><div class="b"><div class="title"><h1>' + (c || " ") + "</h1></div></div></div>") : c && val(geByClass1("btn back", a), '<div class="b"><div class="title"><h1>' + c + "</h1></div></div>")
- },
- afterAppend: function () {
- hasClass("_lms", bodyNode) && menu.enabled(!0);
- alLoadingFix();
- scrollTop(0)
- }
- });
- break;
- case "tab":
- g = !0;
- page.set(e, !1, {
- before: !0,
- beforeAppend: function (a) {
- hasClass("_tclose", b.target) && removeClass("tabs_opened", geByClass1("tabs_wrapper", a));
- hasClass("_thide", b.target) && each(geByClass("_hide", a), function (a, b) {
- hide(b)
- });
- val(geByClass1("upanel", a), '<div id="al_loading"></div>');
- var c = geByClass1("tabs_wrapper", a) || geByClass1("tabs", a),
- d = geByClass1("active", c);
- d && (removeClass("cur", geByClass1("cur", c)), addClass("cur", d.parentNode));
- (k = b.target.getAttribute("data-header")) && val(geByClass1("btn back", a), '<div class="b"><div class="title"><h1>' + k + "</h1></div></div>")
- },
- afterAppend: function () {
- alLoadingFix()
- }
- }, b);
- break;
- case "post":
- g = !0;
- page.set(e, !1, {
- before: !0,
- beforeAppend: function (a) {
- var c = clone(gpeByClass("post", b.target)),
- d = c.id,
- e, f = outer(gpeByTag("a", geByClass1("u", c, "img"))),
- g = gpeByTag("div", geByClass1("author", c)),
- p = remove(geByClass1("date", c)),
- q = outer(remove(geByClass1("explain", g))),
- g = outer(g),
- c = geByClass1("cc", c),
- h = geByClass1("more", c),
- j = geByClass1("info", c),
- k = geByClass1("links", c),
- t = geByClass1("replies_link", k),
- j = val(remove(geByClass1("replies", j))) ? val(t) : lang.mobile_wall_post_replies_title,
- t = t ? '<a name="comments"></a><h5>' + (j || "") + '</h5><div id="al_loading"></div>' : "";
- h && (h.nextSibling.style.display = "inline", h.style.display = "none");
- val(k, outer(geByClass1("like_wrap", c)));
- (e = b.target.getAttribute("data-header")) && val(geByClass1("btn back", a), '<div class="b"><div class="title"><h1>' + e + "</h1></div></div>");
- e = val;
- a = geByClass1("mcont", a);
- p = val(p);
- c = val(c);
- e(a, '<div class="pcont wall bl_cont"><div class="panel">' + (f || "") + '<div class="cont">' + (g || "") + '<div class="info"><span class="date">' + (p || "") + '</span></div></div></div><div id="' + (d || "") + '" class="post one"><div class="cont"><div class="ch">' + (q || "") + '</div><div class="cc">' + (c || "") + "</div></div></div>" + (t || "") + "</div>")
- },
- afterAppend: function (a) {
- (a = geByTag1("h5", a)) && alLoadingFix(b.nav.hash ? getCh() - a.offsetHeight : 0);
- b.nav.hash ? scrollToHash(b.nav.hash) : scrollTop(0)
- }
- }, b);
- break;
- case "pinfo":
- g = !0;
- page.set(e, !1, {
- before: !0,
- beforeAppend: function (a) {
- var b = geByClass1("pcont", a),
- c = geByClass1("panel", a),
- d = geByClass1("u", c, "img"),
- e = geByTag1("h2", c),
- f = geByTag1("b", e),
- p = geByClass1("lv", c),
- g = ce("div");
- addClass("prof_finfo", b);
- val(c, '<img src="' + attr(d, "src") + '" class="u" align="left"><div class="cont"><h2>' + stripTags(val(e)) + '</h2><div class="lvl">' + (f ? lang.mobile_online : val(p)) + '</div></div><div class="cb"></div>');
- each(geByClass("_pinfo", a), function (a, b) {
- g.appendChild(b)
- });
- val(geByClass1("upanel", a), "<div>" + val(g) + '</div><div id="al_loading"></div>')
- },
- afterAppend: function () {
- alLoadingFix();
- scrollTop(0, 10)
- }
- }, b);
- break;
- case "player":
- g = !0;
- page.set(e, !1, {
- before: !0,
- beforeAppend: function (a) {
- var b = audio.playlist(),
- c = audio.playlist_q(),
- b = ((b[0] || {}).id || "").split("_").slice(2).join("_") || "",
- d = nav.path + (nav.params ? "?" + nav.params : "");
- val(geByClass1("btn back", a), '<a class="b al_back" data-href="' + d + '" onclick="return nav.go(this, event);"><i> </i><div class="title"><h1>' + lang.mobile_menu_player_head_title + "</h1></div></a>");
- val(geByClass1("mcont", a), '<div class="pcont audios"><div class="panel np"><form action="/audio" class="oneline qsearch"><input type="hidden" name="act" value="player"><input type="hidden" name="list" value="' + escapeAttr(b) + '"><table><tr><td width="100%"><div class="iwrap"><input id="qsearch_fld" type="text" class="text" name="q" placeholder="' + lang.mobile_audio_search_placeholder + '"></div></td><td class="last"><input id="qsearch_btn" class="btn" type="submit" value="' + lang.mobile_audio_search_btn + '" /></td></tr></table></form></div><div class="upanel"><div class="audios_wrap audios_list bl_cont" data-query="' + escapeAttr(c) + '"></div></div></div>');
- val("m", a.innerHTML)
- }
- }, b);
- j = function () {
- var a = audio.playlist(),
- b = ((a[0] || {}).id || "").split("_").slice(2).join("_") || "",
- b = "/audio" + obj2qs({
- act: "player",
- list: b
- }),
- c = [],
- d = {};
- each(a, function (a, b) {
- c.push(b.id);
- d[b.id] = [b.artist + " " + b.title, b.id, b.src, b.artist, b.title, b.dur, b.can_add, !1]
- });
- qsearch.init({
- action: b,
- al_action: b,
- container: geByClass1("upanel", "mcont"),
- field: ge("qsearch_fld"),
- btn: ge("qsearch_btn"),
- top_items: c,
- _cache: d,
- hl_fields: [2, 3],
- tpl: function (a, b, c, d) {
- return b ? d ? d : "" == d ? '<div class="audio_wrap audios_list" data-query="' + escapeAttr(b) + '">' + a + "</div>" : '<div class="audio_wrap audios_list" data-query="' + escapeAttr(b) + '"><div class="al_loading qs_loading"> </div></div>' : '<div class="audio_wrap audios_list" data-query="' + escapeAttr(audio.playlist_q()) + '">' + a + "</div>"
- },
- item_tpl: function (a, b, c, d, e, r, f) {
- return audioplayer && audioplayer.getDOMFromAudio({
- id: a,
- src: b,
- dur: e,
- artist: c,
- title: d,
- can_add: r,
- can_del: f
- }, !0, this.q) || ""
- },
- null_tpl: function (a) {
- return '<div class="m"><div class="null">' + (a ? lang.mobile_audio_search_not_found.replace("%s", htsc(a)) : lang.mobile_audio_no_audio) + "</div></div>"
- },
- soft_filter: !0,
- need_invalid_keys: browser.desktop,
- top_len: 50,
- global_search: !0,
- onRendered: function () {
- audioplayer && audioplayer.initAudio()
- },
- al_need: !0,
- init_offset: 0
- });
- a = audio.getCurrentId();
- if (a = ge("audio" + a)) a = getY(a) + a.offsetHeight / 2 - getCh() / 2, scrollTop(a)
- };
- break;
- case "photo":
- g = !0;
- page.set(e, !1, {
- before: !0,
- beforeAppend: function (a) {
- var c = geByTag1("img", b.target),
- d = c && c.src || "/images/blank.gif",
- e = "",
- f = "",
- g = (attr(c, "data-photo") || "").split("|"),
- p = g[0],
- q = +g[1] || 0,
- g = +g[2] || 0,
- h = !0;
- if (!q || !g) q = c && c.width || 0, g = c && c.height || 0, h = !1;
- if (p) {
- if (q && g) var c = Math.min(604, getCw()) / q,
- j = Math.min(604, Math.ceil(1 <= c && h ? g : g * c)),
- e = e + ("height:" + j + "px;");
- e += "background:url(" + d + ") #f7f7f7 no-repeat center top;";
- 100 < j && each(["-moz-", "-o-", "-webkit-", ""], function (a, b) {
- e += b + "background-size:contain;"
- });
- d = p
- } else f += "width:100%;";
- val(geByClass1("btn back", a), '<div class="b"><i> </i><div class="title"><h1>' + lang.mobile_photos_photo_head_title + "</h1></div></div>");
- val(geByClass1("mcont", a), '<div class="pcont photoview bl_cont"><div class="summary"> <div class="loading" style="float:left;"><i></i></div></div><div class="photo_wrap"><div class="pv" style="' + (e || "") + '"><img src="' + d + '" alt="" style="' + (f || "") + '" /></div></div><div id="al_fill"></div></div>')
- },
- afterAppend: function () {
- alLoadingFix(0, "al_fill");
- scrollTop(0)
- }
- }, b);
- break;
- case "u":
- case "g":
- case "p":
- case "e":
- g = !0;
- page.set(e, !1, {
- before: !0,
- beforeAppend: function (a) {
- var c, d = l.substr(2),
- e = geByClass1(d, a, "a") || geByClass1(d, a, "span"),
- e = stripTags(attr(b.target, "data-name") || attr(e, "data-name") || val(e) || ""),
- d = (d = geByClass1(d, a, "img")) && d.src || attr(b.target, "data-photo") || "/images/blank.gif",
- f = geByClass1("mhead", a);
- "u" == h ? c = e.split(" ").shift() : "g" == h ? c = lang.mobile_group_head_title : "p" == h ? c = lang.mobile_public_head_title : "e" == h && (c = lang.mobile_event_head_title);
- geByClass1("btn logo", f) ? val(f, "" + (window.al && window.al.menu ? '<div class="btn home"><a href="/" class="b" accesskey="*" onclick="return menu.toggle(event);"><i></i></a></div>' : '<div class="btn home vk_home"><a href="/" class="b" accesskey="*"><i></i></a></div>') + '<div class="btn notify">' + val(geByClass1("btn notify", a)) + '</div><div class="btn back"><div class="b"><div class="title"><h1>' + (c || " ") + "</h1></div></div></div>") : c && val(geByClass1("btn back", a), '<div class="b"><div class="title"><h1>' + c + "</h1></div></div>");
- val(geByClass1("mcont", a), '<div class="pcont prof bl_cont"><div class="panel prof_panel"><img src="' + (d || "") + '" class="u" align="left"><div class="cont"><h2>' + (e || "") + '<h2/></div></div><div id="al_loading"></div>')
- },
- afterAppend: function () {
- alLoadingFix();
- scrollTop(0)
- }
- }, b);
- break;
- default:
- cur.al_fast && cur.al_fast[h] && (g = !0, page.set(e, !1, cur.al_fast[h](b), b))
- }
- }
- g && (nav.set(b), ajax.tModule = cur.module, ajax.tFastRender = (new Date).getTime());
- ajax.abort_reqs();
- b.local ? (c = !0, page.set(e, {}, {
- after: !0,
- no_scroll: !0,
- force: !0
- }, !1), j && j()) : (j = b.params || {}, f && (j._tstat = f), c = ajax._post(c, j, {
- onPageDone: function (a, c, d, f, u) {
- ajax.tProcess = (new Date).getTime();
- page.set(e, {
- title: a,
- html: c,
- js: d,
- lm: f,
- bc: u
- }, {
- after: g,
- no_scroll: g
- }, g ? !1 : b);
- ajax.tModule = cur.module;
- ajax.tRender = (new Date).getTime()
- }
- }), ajax.save_req());
- return c
- },
- confirm: function (a, b, c, d) {
- return confirm(b) ? ajax.click(a, d, {
- url_params: {
- hash: c
- }
- }) : !1
- },
- _post: function (a, b, c) {
- var d = function (a, b) {
- c.onFail && c.onFail.call(window, 0, a, b)
- };
- return ajax.plainpost(a, b, function (b) {
- var f = !1;
- try {
- f = parseJSON(b)
- } catch (g) {
- f = !1
- }
- if (!1 === f) d();
- else {
- var j = f.shift(),
- l = f.shift();
- b = f.shift();
- j = window.al && j != al.ver || !menu.refreshCounters(l);
- !1 !== l && setNotify(l[2]);
- switch (b) {
- case 0:
- if (j) return nav.hard_go(nav.cur, null, {
- replace: !0
- });
- b = f.shift();
- c.onDone && (isArray(f) ? c.onDone.apply(window, b) : c.onDone.call(window, b));
- break;
- case 1:
- l = f.shift();
- f = f.shift();
- j || f ? nav.hard_go(l) : nav.go(l, null, {
- ignore_cur_process: !0
- });
- break;
- case 2:
- l = f.shift();
- c.onFail ? (f.unshift(l), f.unshift(b), c.onFail.apply(window, f)) : nav.hard_go(l);
- break;
- case 3:
- page.need_hard_go = j;
- if ((b = f[3]) && b.rdr && window.al && al.menu && 614 <= getW("vk_wrap")) {
- nav.go(b.rdr, null, {
- replace: !0
- });
- break
- }
- c.onPageDone || (c.onPageDone = function (b, c, d, e, f) {
- nav.go(a, null, {
- push_only: !0
- });
- page.set(page.getHash(nav), {
- title: b,
- html: c,
- js: d,
- lm: e,
- bc: f
- })
- });
- c.onPageDone.apply(window, f)
- }
- }
- }, d)
- },
- tGetParam: function () {
- if (ajax.tStart && ajax.tModule) {
- var a = ajax.tFastRender - ajax.tStart,
- b = ajax.tRestoreRender - ajax.tStart,
- c = ajax.tProcess - ajax.tStart,
- d = ajax.tRender - ajax.tProcess,
- a = ["/" == ajax.tModule.substr(0, 1) ? ajax.tModule.substr(1) : ajax.tModule, a, b, c, d],
- e;
- for (e in a) if (!a[e] || 0 > a[e]) a[e] = 0;
- ajax.tStart = !1;
- return a.join(",")
- }
- },
- tAlGetParam: function () {
- if (ajax.tAlStart && ajax.tAlModule) {
- var a = ajax.tAlProcess - ajax.tAlStart,
- b = ajax.tAlRender - ajax.tAlProcess,
- a = ["al_" + ("/" == ajax.tAlModule.substr(0, 1) ? ajax.tAlModule.substr(1) : ajax.tAlModule), a, b],
- c;
- for (c in a) if (!a[c] || 0 > a[c]) a[c] = 0;
- ajax.tAlStart = !1;
- return a.join(",")
- }
- }
- }, thover = {
- obj: null,
- highlight: !1,
- start: function (a) {
- thover.clear();
- thover.end(a);
- thover.obj = this || null;
- thover.obj && (thover.highlight = !0, addClass("hover", thover.obj))
- },
- cancel: function (a) {
- thover.obj && (thover.highlight = !1, thover.end(a))
- },
- end: function () {
- thover.obj && (removeClass("hover", thover.obj), thover.highlight && (thover.clear(), addClass("active", thover.obj)), thover.obj = null, thover.highlight = !1)
- },
- clear: function () {
- removeClass("active", geByClass1("active", "vk_wrap"))
- }
- };
- addEvent(document, "touchmove touchcancel", thover.cancel);
- addEvent(document, "touchend", thover.end);
- function fixHeight() {
- if (browser.safari_mobile || browser.android || browser.opera_mobile && !browser.opera_mini) {
- getCh();
- var a = scrollTop();
- bodyNode.style.overflow = "hidden";
- bodyNode.style.minHeight = "5000px";
- scrollTop(10);
- var b = getCh() + 1;
- scrollTop(a);
- bodyNode.style.minHeight = b + "px";
- bodyNode.style.overflow = "auto"
- }
- }
- var page = {
- fast_load: !1,
- need_hard_go: !1,
- getHash: function (a) {
- return "#player" == a.hash ? !1 : a.path + (a.params ? "?" + a.params : "")
- },
- getAlias: function (a) {
- if (!a) return !1;
- var b = (a || "").split("?");
- a = b[0];
- b = qs2obj(b[1]);
- delete b.from;
- delete b.offset;
- return a + obj2qs(b)
- },
- set: function (a, b, c, d) {
- c = c || {};
- var e = scrollTop(),
- f = null;
- c.force || (f = remove("m"));
- if (!c.after && (clog("st " + e), !page.fast_load)) {
- var g = page.getHash(nav);
- page.save(g, {
- html: null,
- st: e,
- page: f,
- state: page.stash()
- }, !0)
- }
- c.before || page.clear();
- if (c.before || !c.before && !c.after) window.lm_qsearch_counter ? lm_qsearch_counter++ : lm_qsearch_counter = 1;
- if (c.before) page.fast_load = !0, d && d.target && addClass("__al_target", d.target), b = f.cloneNode(!0), d && d.target && removeClass("__al_target", d.target), d = geByClass1("__al_target", b), removeClass("__al_target", d), c.beforeAppend && c.beforeAppend(b, d), append(b, "vk_wrap"), cur.toggleHeaderSearch && cur.toggleHeaderSearch(!1), c.afterAppend && c.afterAppend(b), menu && menu.clear_hover(), menu && menu.closeSearch();
- else {
- d && nav.set(d);
- if (page.need_hard_go) return nav.hard_go(nav.cur, null, {
- replace: !0
- });
- c.force || (b.title && (document.title = b.title), f = b.page, f || (f = ce("div", {
- id: "m"
- }), val(f, b.html)), menu.opened() && (g = ce("div", {
- id: "m_helper",
- onclick: menu.close
- }), append(g, f)), append(f, "vk_wrap"));
- page.fast_load = !1;
- thover.clear();
- c.force || (b.js && evalJs(b.js), b.state && page.stash(b.state), page.save(a, b));
- b.lm && menu.refresh(b.lm);
- b.bc && (bodyNode.className = b.bc);
- d = d ? d.nav && d.nav.hash : nav.hash;
- b.st || !d ? scrollTop(b.st || 0, 10) : c.no_scroll && !c.force ? scrollTop(e, 10) : scrollToHash();
- audioplayer && audioplayer.initAudio()
- }
- },
- save: function (a, b, c) {
- if (a) {
- var d = c ? nav.page_get(a) : {};
- d && (nav.page_set(a, extend(d, b), page.getAlias(a)), clog((c ? "add " : "set ") + a))
- }
- },
- restore: function (a) {
- var b = nav.page_get(a);
- b || (b = nav.page_get(page.getAlias(a)));
- return b ? (b.lm && extend(b.lm, {
- tn: !1,
- bn: !1
- }), page.set(a, b), clog("get " + a), clog("scrolled to " + b.st), !0) : !1
- },
- stash: function (a) {
- return window.cur && cur.stash && cur.stash(a) || !1
- },
- clear: function () {
- onBodyScroll("__clear");
- onBodyResize("__clear");
- menu && menu.initEvents();
- window.cur && cur.destroy && cur.destroy();
- window.cur = {}
- }
- }, nav = function () {
- function a(a) {
- var b;
- if (b = /^(https?:)\/\/([^:\/]+)?(?::(\d+))?\/?(.*)$/i.exec(a)) {
- if (b[1] != location.protocol || b[2] && b[2] != location.hostname || b[3] && b[3] != location.port) return !1;
- a = b[4]
- }
- return a
- }
- function b(a, b, c) {
- if (checkEvent(b) || c && c.push_only) return !0;
- c && c.replace ? location.replace(a) : a && (location.href = getHref(a));
- return !0
- }
- function c(a, c, d) {
- cancelEvent(c);
- a = getHref(a);
- if (window.al && al.ver && (d && d.push_only || ajax.nav(a, d))) return !0;
- b(a, c, d)
- }
- function d(b, d, f) {
- f = extend({
- no_push: !1,
- push_only: !1,
- replace: !1
- }, f);
- if (checkEvent(d) || !b) return !0;
- var m = b,
- g = "",
- h = "",
- p = "";
- !b.href && b.getAttribute && (m = b.getAttribute("data-href"));
- if (("input" == tag(b) || "button" == tag(b)) && "submit" == b.type && b.form) {
- var q = b.form,
- j = {}, m = q.action || "",
- k = !1;
- each(q, function (a, c) {
- if (!c.name || c.disabled || "radio" === c.type && !c.checked || "checkbox" === c.type && !c.checked || "button" === c.type || "submit" === c.type && c !== b || "image" === c.type && c !== b) return !0;
- if ("file" === c.type) return k = !0, !1;
- j[c.name] = c.value
- });
- if (k) {
- var l = ce("iframe");
- attr(l, "id", "upload_iframe");
- attr(l, "name", "upload_iframe");
- attr(l, "width", "0");
- attr(l, "height", "0");
- attr(l, "border", "0");
- attr(l, "style", "width:0;height:0;border:none;position:absolute;left:-1000px;");
- append(l, q.parentNode);
- window.frames.upload_iframe.name = "upload_iframe";
- var l = ge("upload_iframe"),
- t = !1;
- each(q, function (a, b) {
- if ("submit" === b.type) return t = b, !1
- });
- addEvent(l, "load", function C() {
- removeEvent(l, "load", C);
- setTimeout(function () {
- remove(l);
- unlockButton(t)
- }, 2E3)
- });
- setDocumentDomain();
- attr(q, "target", "upload_iframe");
- attr(q, "method", "post");
- attr(q, "enctype", "multipart/form-data");
- attr(q, "encoding", "multipart/form-data");
- append(ce("input", {
- type: "hidden",
- id: "__extra",
- name: "__extra",
- value: 1
- }), q);
- q.submit();
- lockButton(t);
- setTimeout(function () {
- remove("__extra")
- }, 0);
- return !1
- }
- if (!(m = a(m))) return !0;
- !q.method || "get" == q.method ? m = m.split("?", 1).shift() + obj2qs(j) : f.params = j;
- clog(q.method);
- clog(m);
- clog(obj2qs(f.params))
- }
- if ("string" !== typeof m) g = m.pathname, "/" !== g.substr(0, 1) && (g = "/" + g), h = m.search.substr(1), p = m.hash, m = g + m.search + p;
- else if (g = m.split("#"), q = g.shift(), p = g.length ? "#" + g.join("#") : "", q = q.split("?"), g = q.shift(), h = q.join("?"), (p || h) && !g) g = nav.path, q || (h = nav.params), m = g + (h ? "?" + h : "") + p;
- d && (m.split("#").shift() == nav.cur.split("#").shift() && p) && (scrollToHash(p), f.push_only = !0);
- if (f.no_push && nav.cur == m) return !1;
- if (f.push_only) return e(extend(f, {
- nav: {
- push: m,
- path: g,
- params: h,
- hash: p
- }
- })), !1;
- addClass("active", f.link || b);
- hasClass("al_back", b) && (f.need_restore = !0);
- d = extend(f, b.tagName ? {
- target: b
- } : {}, {
- nav: {
- push: m,
- path: g,
- params: h,
- hash: p
- }
- });
- !d.ignore_cur_process && cur.processNav && cur.processNav(d) ? (e(d), menu.close(null, !0)) : c(d.nav.push, null, d);
- return !1
- }
- function e(a) {
- if (!a.no_push && nav.cur != a.nav.push) try {
- var c = a.nav.push;
- if (g) c = "/" == c.substr(0, 1) ? c : "/" + c, a.replace ? history.replaceState(null, null, c) : history.pushState(null, null, c), clog(a.replace ? "replace: " + c : "push: " + c);
- else {
- var d = "/" == c.substr(0, 1) ? c : "/" + c;
- ge("base").href = d;
- a.replace ? location.replace(location.pathname + location.search + "#" + d) : (j = d, location.hash = d);
- clog(a.replace ? "replace hash: " + c : "push hash: " + c)
- }
- } catch (e) {
- return b(a.nav.push, null, a)
- }
- nav.cur = a.nav.push;
- nav.path = a.nav.path;
- nav.params = a.nav.params;
- nav.hash = a.nav.hash
- }
- function f() {
- var a = (location.hash || "").substr(1);
- j !== a && (j = a, l(!0));
- setTimeout(f, 100)
- }
- var g = !(!window.history || !history.pushState),
- j = null,
- l = se(function () {
- return j
- }),
- h = [];
- if (g) addEvent(window, "popstate", function () {
- clog("popstate: " + location.href);
- d(location, null, {
- no_push: !0,
- need_restore: !0
- })
- });
- else {
- var k = location.hash || "";
- "#/" == k.substr(0, 2) && b(k.substr(1), null, {
- replace: !0
- });
- "onhashchange" in window ? addEvent(window, "hashchange", function () {
- var a = (location.hash || "").substr(1);
- a || (a = location);
- d(a, null, {
- no_push: !0,
- need_restore: !0
- })
- }) : (f(), l(function (a) {
- clog("popstate hash: " + a);
- d(a, null, {
- no_push: !0,
- need_restore: !0
- })
- }))
- }
- return {
- go: d,
- al_go: c,
- app_go: function (a, b, c) {
- if (!c || checkEvent(b)) return !0;
- remove("app_go_frame");
- var d = getHref(a);
- a = ce("iframe", {
- id: "app_go_frame",
- src: c,
- onload: function () {
- remove("app_go_frame");
- d && nav.hard_go(d)
- }
- }, {
- display: "none"
- });
- bodyNode.appendChild(a);
- return !1
- },
- hard_go: b,
- page_set: function (a, b, c) {
- clog("SET", "hash:", a, "alias:", c);
- for (var d = h.length - 1; 0 <= d; --d) if (h[d].h == a || h[d].a == a) {
- h[d] = {
- h: a,
- d: b,
- a: c
- };
- return
- }
- h.push({
- h: a,
- d: b,
- a: c
- });
- 7 < h.length && h.shift()
- },
- page_get: function (a) {
- clog("GET", "hash:", a);
- for (var b = h.length - 1; 0 <= b; --b) if (h[b].h == a || h[b].a == a) return h = h.slice(0, b + 1), clog("found", "hash:", h[b].h, "alias:", h[b].a), h[b].d;
- return !1
- },
- set: e,
- checkUrl: a,
- cur: location.pathname + location.search + location.hash,
- path: location.pathname,
- params: location.search.substr(1),
- hash: location.hash
- }
- }();
- ajax._init();
- ajax.enabled = ajax._req ? !0 : !1;
- ajax.enabled && (onDOMReady(function () {
- remove("app_go_frame");
- ajax.prepare_nav();
- ajax.prepare_click();
- menu && menu.initTouch();
- audioplayer && audioplayer.initAudio();
- addClass("_js", "vk_wrap")
- }), page.clear());
- addEvent(window, "orientationchange", fixHeight);
- setTimeout(function () {
- !location.hash && scrollTop(0)
- }, 0);
- onDOMReady(fixHeight);
- var Like = {
- onDone: function (a, b, c, d) {
- var e = ge(a) || geByClass1("like_box");
- if (e && a) {
- geByClass1("info", e);
- a = geByClass1("like", e);
- var f = geByClass1("repost", e),
- e = geByClass1("like_wrap", e);
- a && (a.innerHTML = b || "", toggle(a, b));
- f && (f.innerHTML = c || "", toggle(f, c));
- e && val(e, d || "")
- }
- },
- onFail: function () {
- var a = Array.prototype.slice.call(arguments);
- switch (a.shift()) {
- case 2:
- nav.hard_go(a[0])
- }
- }
- }, PhotoLike = {
- onDone: function (a, b, c, d) {
- Like.onDone.apply(this, arguments);
- if (this.photo_id) {
- var e = photo.get(this.photo_id);
- if (e) {
- var f = ce("div", {
- innerHTML: e.likes
- });
- val(geByClass1("like", f), b);
- e.likes = val(f);
- e.publish = '<span class="repost">' + c + "</span>";
- var f = ce("div", {
- innerHTML: e.actions
- }),
- g = geByClass1("like_wrap", f);
- val(g, d);
- e.actions = val(f);
- photo.save(e)
- }
- }
- },
- onFail: Like.onFail
- }, PhotoTag = {
- onDone: function () {
- if (this.photo_id) {
- var a = photo.get(this.photo_id);
- a && (a.tag_info = "", photo.save(a));
- a = geByClass1("photoview");
- a = geByClass1("tag_info_wrap", a);
- val(a, "")
- }
- }
- }, PhotoDelete = {
- onDone: function (a, b, c) {
- var d = geByClass1("photoview"),
- e = geByClass1("photo_msg"),
- f = !! b;
- if (d && e) {
- val(e, b || "");
- toggleClass("photo_deleted", d, f);
- if (a = photo.get(a)) a.deleted = b, photo.save(a);
- c && menu && menu.refresh({
- pp: c
- })
- }
- }
- }, Poll = {
- onDone: function (a, b) {
- val(a, b)
- }
- }, ToggleMenu = {
- onStart: function () {
- addClass("loading", this.link)
- },
- onDone: function (a) {
- this.link && val(this.link.parentNode, a)
- }
- }, Comment = {
- onDone: function (a, b) {
- if (a) {
- remove(a + "_msg");
- var c = ge(a);
- if (c) {
- if (b) {
- var d = ce("div", {
- id: a + "_msg",
- className: "post post_msg"
- });
- val(d, '<div class="cont">' + b + "</div>");
- after(d, c);
- hide(c)
- } else show(a);
- if (this.photo_id && (c = photo.get(this.photo_id))) d = geByClass1("photoview"), d = geByClass1("comments_wrap", d), c.comments_html = val(d)
- }
- }
- }
- }, Wall = {
- onStart: function () {
- var a = gpeByClass("show_more_wrap", this.link) || this.link,
- b = ce("div", {
- id: "show_more_loading",
- className: "show_more_loading",
- innerHTML: "<i> </i>"
- }),
- c = ce("div", {
- id: "show_more_wrap",
- className: "show_more_wrap"
- });
- attr(b, "data-href", getHref(a));
- c.appendChild(b);
- before(c, a);
- remove(a)
- },
- onDone: function (a) {
- ajax.tAlProcess = (new Date).getTime();
- var b = ge("show_more_wrap");
- a = cdf(a);
- before(a, b);
- remove(b);
- ajax.prepare_nav("mcont");
- ajax.prepare_click("mcont");
- onBodyScroll(!0);
- ajax.tAlModule = cur.module;
- ajax.tAlRender = (new Date).getTime()
- }
- }, Photos = {
- onStart: Wall.onStart,
- onDone: function (a, b) {
- ajax.tAlProcess = (new Date).getTime();
- var c = geByClass1("pv_all", geByClass1("photos", "mcont")),
- d = ge("show_more_wrap"),
- e = cdf(b);
- a = a.replace(/<img src="([^"]+)"/gi, '<img data-src="$1" class="_i"');
- var f = cdf(a);
- c && c.appendChild(f);
- before(e, d);
- remove(d);
- ajax.prepare_nav("mcont");
- ajax.prepare_click("mcont");
- setTimeout(function () {
- onBodyScroll(!0)
- }, 100);
- ajax.tAlModule = cur.module;
- ajax.tAlRender = (new Date).getTime()
- }
- }, Audios = {
- onStart: Wall.onStart,
- onDone: function (a, b) {
- ajax.tAlProcess = (new Date).getTime();
- var c = geByClass1("audios_wrap", geByClass1("audios", "mcont")),
- d = ge("show_more_wrap"),
- e = cdf(b),
- f = cdf(a);
- c && c.appendChild(f);
- before(e, d);
- remove(d);
- ajax.prepare_nav("mcont");
- ajax.prepare_click("mcont");
- ajax.tAlModule = cur.module;
- ajax.tAlRender = (new Date).getTime()
- }
- }, FixPost = {
- onDone: function (a) {
- val(this.link.parentNode, a)
- }
- }, Notify = {
- onStart: function () {
- for (var a = this.link; a = a.parentNode;) if (hasClass("notify", a)) {
- hasClass("notify_panel", a.parentNode) ? remove(a.parentNode) : remove(a);
- break
- }
- }
- }, Dialog = {
- onStart: function () {
- var a = geByClass("pages", "mcont");
- each(a, function (a, c) {
- before(ce("div", {
- className: "loading",
- innerHTML: "<i></i>"
- }), c.firstChild)
- })
- },
- onDone: function (a, b) {
- var c = ge("messages" + b);
- c && (val(c, a), !this.save && scrollToEl());
- this.save && mail.saveDialog({
- messages: a
- }, this.save);
- this.clear && (val(geByTag1("textarea", "write_form"), ""), remove(geByClass1("medias", "write_form")))
- },
- onFail: function () {
- switch (Array.prototype.slice.call(arguments).shift()) {
- case 2:
- this.link.form && this.link.form.submit()
- }
- }
- }, Dialogs = {
- onStart: function () {
- var a = geByClass("pages", "mcont");
- each(a, function (a, c) {
- before(ce("div", {
- className: "loading",
- innerHTML: "<i></i>"
- }), c.firstChild)
- })
- },
- onDone: function (a, b) {
- var c = ge("dialogs");
- c && (val(c, a), !this.no_scroll && scrollToEl(), mail.cacheDialogsPage());
- mail.save(b)
- }
- }, reply = {
- show: function (a, b) {
- if (checkEvent(b)) return !0;
- reply.hideall();
- addClass("reply_to", geByClass1("reply_wrap", "wall_reply" + a));
- addClass("reply_to", "reply_add" + a);
- replaceClass("add_reply", "reply_to", geByClass1("pcont", "mcont"));
- elfocus(geByTag1("textarea", "reply_add" + a));
- return !1
- },
- hide: function (a) {
- if (checkEvent(a)) return !0;
- reply.edithide();
- elfocus(geByTag1("textarea", "reply_add"));
- return !1
- },
- hideall: function () {
- for (var a = geByClass1("replies", "mcont"), a = geByClass("post", a), b = 0, c = a.length; b < c; b++) {
- var d = a[b],
- e = ge(d.id.replace("wall_reply", "reply_add")),
- f = ge(d.id.replace("wall_reply", "edit_reply"));
- removeClass("reply_to", geByClass1("reply_wrap", d));
- removeClass("reply_to", e);
- removeClass("edit", d);
- removeClass("edit", f)
- }
- return !1
- },
- editshow: function (a, b) {
- if (checkEvent(b)) return !0;
- reply.hideall();
- addClass("edit", "wall_reply" + a);
- addClass("edit", "edit_reply" + a);
- addClass("edit_post", geByClass1("pcont", "mcont"));
- elfocus(geByTag1("textarea", "edit_reply" + a));
- return !1
- },
- edithide: function (a) {
- if (checkEvent(a)) return !0;
- replaceClass("reply_to", "add_reply", geByClass1("pcont", "mcont"));
- removeClass("edit_post", geByClass1("pcont", "mcont"));
- return !1
- },
- greeting: function (a, b) {
- var c = geByTag1("textarea", b || geByClass1("post_add", "mcont"));
- if (!c) return !0;
- var d = c.value.match(/\[post\d+\|[^\]]+\]/g),
- e = 0,
- f;
- for (f in d || {})++e;
- 10 > e && (c.value += a);
- edit.hide();
- elfocus(c);
- return !1
- }
- }, edit = {
- show: function (a, b) {
- if (checkEvent(b)) return !0;
- edit.hideall();
- addClass("edit", "post" + a);
- addClass("edit", "edit_post" + a);
- addClass("edit_post", geByClass1("pcont", "mcont"));
- elfocus(geByTag1("textarea", "edit_post" + a));
- return !1
- },
- hide: function (a) {
- if (checkEvent(a)) return !0;
- removeClass("edit_post", geByClass1("pcont", "mcont"));
- return !1
- },
- hideall: function () {
- for (var a = geByClass1("msgs", "mcont"), a = geByClass("post", a), b = 0, c = a.length; b < c; b++) {
- var d = a[b],
- e = ge(d.id.replace("post", "edit_post"));
- removeClass("edit", d);
- removeClass("edit", e)
- }
- return !1
- }
- }, post = {
- add_attach: function (a, b) {
- var c = gpeByTag("form", a),
- d = ce("input", {
- type: "hidden",
- name: "add_attach",
- value: 1
- });
- if (c) {
- var e = !1;
- each(c, function (a, b) {
- if ("submit" === b.type) return e = b, !1
- });
- if (e) return append(d, c), window.al && al.ver ? nav.go(e, b) : c.submit()
- }
- return !0
- },
- toggleGif: function (a, b, c) {
- return !a || checkEvent(b) ? !0 : hasClass("cur_gif", a.parentNode) ? post.hideGif(a, b) : post.showGif(a, b, c)
- },
- showGif: function (a, b, c) {
- if (!a || checkEvent(b)) return !0;
- if (c) {
- cur.loadedGifs || (cur.loadedGifs = {});
- if (!cur.loadedGifs[a.href] && !confirm(c)) return !1;
- cur.loadedGifs[a.href] = !0
- }
- var d = a.parentNode;
- c = getY(d);
- var e = scrollTop();
- each(geByClass("cur_gif", "mcont"), function (a, b) {
- post.hideGif(geByTag1("a", b))
- });
- scrollTop(e - (c - getY(d)));
- var f = ce("image", {
- src: a.href,
- className: "gif_original"
- });
- addClass("cur_gif gif_loading", d);
- append(f, a);
- a = function (a) {
- if (getW(f) && getH(f) || a) clearInterval(g), hasClass("cur_gif", d) && replaceClass("gif_loading", "gif_opened", d)
- };
- var g = setInterval(a, 100);
- f.onload = a;
- return cancelEvent(b)
- },
- hideGif: function (a, b) {
- if (!a || checkEvent(b)) return !0;
- var c = a.parentNode;
- removeClass("cur_gif", c);
- removeClass("gif_opened", c);
- removeClass("gif_loading", c);
- remove(geByClass1("gif_original", c));
- return cancelEvent(b)
- }
- }, menu = {
- enabled: function (a) {
- if (!window.al || !window.al.menu) return removeClass("_lm", bodyNode), !1;
- "undefined" !== typeof a && (toggleClass("_lm", bodyNode, a), a || removeClass("qs_opened", "vk_wrap"));
- return hasClass("_lm", bodyNode)
- },
- opened: function () {
- return hasClass("lm_opened", bodyNode)
- },
- toggle: function (a, b) {
- if (checkEvent(a) || !window.al || !window.al.menu) return !0;
- menu.opened() ? menu.close(a, b) : menu.open(a, b);
- return !1
- },
- open: function (a) {
- if (checkEvent(a) || !window.al || !window.al.menu) return !0;
- if (menu.opened()) return !1;
- if (!menu.enabled()) return nav.go("/"), !1;
- menu.clear_hover();
- var b = ce("div", {
- id: "m_helper",
- onclick: menu.close
- });
- a = menu._st || 0;
- var c = scrollTop(),
- d = ge("l"),
- e = ge("m"),
- f = ge("vk_wrap").offsetWidth,
- g = e.offsetWidth;
- mh = e.offsetHeight;
- if (!(882 <= f)) return append(b, "m"), addClass("lm_opened", bodyNode), b = d.offsetHeight, 480 <= f ? a = c <= b - getCh() ? Math.min(c, b - getCh()) : 0 : c < a ? a = c : c - a > mh - b && mh > b && (a = c - mh + b), menu._st = Math.max(0, c - a), menu._mw = g, menu.fix_size(), scrollTop(a), ajax.post("/", {
- _ajax: 1,
- act: "ping"
- }), window.lm_qsearch_counter ? lm_qsearch_counter-- : lm_qsearch_counter = -1, lm_qsearch_counter && menu.cancelSearch(), !1
- },
- close: function (a) {
- if (checkEvent(a) || !window.al || !window.al.menu) return !0;
- if (!menu.opened()) return !1;
- remove("m_helper");
- menu.clear_hover();
- a = scrollTop();
- var b = menu._st + a;
- ge("l");
- var c = 480 <= ge("vk_wrap").offsetWidth;
- removeClass("lm_opened", bodyNode);
- menu._st = c ? 0 : a;
- menu.fix_size(!0);
- scrollTop(b);
- window.lm_qsearch_focused && menu.cancelSearch();
- return !1
- },
- fix_size: function (a) {
- var b = ge("l"),
- c = ge("m");
- menu._mw || Math.min(690, getCw());
- var d = ge("mhead"),
- d = d && d.offsetHeight || 0,
- e = menu._st || 0;
- b && (a ? (c.style.minHeight = "0", c.style.marginTop = "0") : (e = e > d ? e : 0, b.style.minHeight = getCh() + "px", c.style.minHeight = b.offsetHeight + e + "px", c.style.marginTop = -e + "px"))
- },
- clear_hover: function () {
- thover.clear()
- },
- refreshCounters: function (a) {
- if (!a || !a.length || !window.al || !window.al.menu) return !0;
- if (a.length != window.al.menu.length) return !1;
- var b = geByClass1("main_menu", "l");
- each(a, function (a, d) {
- if ("undefined" === typeof d) return !0;
- var e = al.menu[a],
- f = geByClass1(e[0], b),
- g = geByTag1("a", f),
- f = geByTag1("span", f),
- j = geByTag1("em", f);
- attr(g, "data-href", !1);
- d ? (e[2] && attr(g, "href", e[2]), j ? val(j, d) : append(ce("em", {
- innerHTML: d
- }), f)) : (e[1] && attr(g, "href", e[1]), remove(j));
- ajax.prepare_click(g)
- });
- return !0
- },
- refresh: function (a) {
- a = a || {};
- a.fv_link && attr("lm_fv_link", "href", a.fv_link);
- "undefined" !== typeof a.pp && !1 !== a.pp && val("lm_prof_panel", a.pp);
- "undefined" !== typeof a.tn && !1 !== a.tn && val("lm_top_notify", a.tn);
- "undefined" !== typeof a.bn && !1 !== a.bn && val("lm_bottom_notify", a.bn)
- },
- initEvents: function () {
- onBodyResize(function () {
- var a = ge("vk_wrap").offsetWidth,
- b = menu._st || 0;
- 882 <= a && 44 < b && menu.close()
- })
- },
- initTouch: function () {
- function a(a) {
- var b = a.touches;
- return {
- x: a.pageX || b && b[0] && b[0].pageX || 0,
- y: a.pageY || b && b[0] && b[0].pageY || 0
- }
- }
- menu.initEvents();
- addEvent(document, "orientationchange", function () {
- var a = ge("vk_wrap").offsetWidth,
- b = menu._st || 0;
- 882 <= a && 44 < b && menu.close()
- });
- addEvent(document, "keydown", function (a) {
- if (a && a.shiftKey && (a.ctrlKey || a.metaKey)) 37 == a.keyCode ? (cancelEvent(a), menu.close()) : 39 == a.keyCode && (cancelEvent(a), menu.open())
- });
- if (isTouch) {
- var b = !1,
- c = !1,
- d = Math.min(604, getCw()) / 3;
- addEvent(document, "touchstart", function (d) {
- geByClass1("btn home", "mhead") && (b = c = a(d))
- });
- addEvent(document, "touchmove touchend touchcancel", function (e) {
- if (b) {
- "touchmove" == e.type && (c = a(e));
- var f;
- f = c.x - b.x;
- var g = c.y - b.y;
- f = Math.sqrt(f * f + g * g);
- g = Math.abs(180 * Math.atan2(b.y - c.y, c.x - b.x) / Math.PI);
- if ("touchend" == e.type || "touchcancel" == e.type) if (b = !1, "touchcancel" == e.type) return;
- 10 > f || (menu.opened() && (g = 180 - g), 30 < g ? b = !1 : (e && cancelEvent(e), f > d && (b = !1, menu.toggle())))
- }
- })
- }
- },
- closeSearch: function () {
- if (!window.al || !window.al.menu) return !0;
- lm_qsearch && lm_qsearch.blur();
- removeClass("qs_opened", "vk_wrap");
- return !1
- },
- cancelSearch: function () {
- if (!window.al || !window.al.menu) return !0;
- lm_qsearch && lm_qsearch.clear();
- removeClass("qs_opened", "vk_wrap");
- return !1
- },
- headerAction: function () {
- return menu.toggle()
- }
- }, mail = function () {
- function a() {
- if (g) {
- var a = [];
- each(geByClass("_unread"), function (b, c) {
- var d = /(?:^|\s)_msg([0-9]+)(?:\s|$)/i.exec(c.className)[1] || 0;
- d && a.push(d)
- });
- a.length && mail.sendMarkAsRead(g, a)
- }
- }
- function b(a, b) {
- b ? -1 == b ? replaceClass("lvi", "mlvi", a) : replaceClass("mlvi", "lvi", a) : (removeClass("lvi", a), removeClass("mlvi", a))
- }
- var c = {}, d, e, f, g = null,
- j = !1,
- l = {}, h = {}, k = {}, s = null;
- return {
- init: function (b, c) {
- b && (g = b, c && mail.saveDialog(c, b));
- j || (j = !0, addEvent(document, isTouch ? "touchstart" : "click", a));
- im.on()
- },
- clear: function () {
- c = {};
- f = e = d = void 0;
- l = {};
- g = null;
- removeEvent(document, isTouch ? "touchstart" : "click", a);
- j = !1;
- im.off()
- },
- send: function (a, b) {
- return ajax.click(a, extend({
- clear: !0,
- save: b
- }, Dialog), {
- lock: !0
- })
- },
- save: function (a) {
- each(a, function (a, b) {
- c[a] && b.last_msg == c[a].last_msg && delete b.messages;
- mail.saveDialog(b, a)
- })
- },
- saveDialog: function (a, b) {
- c[b] || (c[b] = {});
- var d = c[b];
- extend(d, a);
- d.msgs && each(d.msgs, function (a, c) {
- l[c] = b
- })
- },
- getPeerByMsg: function (a) {
- return l[a] || !1
- },
- cacheDialogsPage: function () {
- d = val("m");
- e = nav.cur
- },
- keyup: function (a, b, c) {
- var d = s || "";
- a = a.value || "";
- if (d.length != a.length || d != a) mail.myTyping(b, c), s = a
- },
- myTyping: function (a, b) {
- if (!(0 >= a)) {
- var c = vkNow();
- k[a] && 5E3 > c - k[a] || (k[a] = c, ajax.post("/mail", {
- _ajax: 1,
- act: "typing",
- peer: a,
- hash: b
- }))
- }
- },
- typing: function (a, b) {
- b = b || a;
- 2E9 < a ? (h[a] || (h[a] = {}), h[a][b] = vkNow()) : h[a] = vkNow();
- mail.updateTyping(a)
- },
- updateTyping: function (a) {
- var b = ge("dialog_near" + a),
- c = geByClass1("write_to", b),
- d = geByClass1("typing", b);
- if (b) {
- var e = [],
- f = vkNow();
- if (2E9 < a) each(h[a] || {}, function (a, b) {
- attr(d, "data-u" + a) && (b && 6E3 > f - b) && e.push(a)
- });
- else {
- var g = h[a];
- attr(d, "data-u" + a) && (g && 6E3 > f - g) && e.push(a)
- }
- if (e.length) {
- if (1 == e.length) {
- var j = e[0],
- g = attr(d, "data-u" + j),
- j = attr(d, "data-s" + j);
- val(d, "<i></i>" + (lang.mobile_mail_typing[j] || "").replace("{user}", g))
- } else each(e, function (a, b) {
- e[a] = attr(d, "data-u" + b)
- }), g = e.pop(), val(d, "<i></i>" + (lang.mobile_mail_multi_typing || "").replace("{users}", e.join(", ")).replace("{last_user}", g));
- c.offsetWidth && style(d, "minWidth", c.offsetWidth);
- addClass("is_typing", b);
- setTimeout(function () {
- addClass("animated", b)
- }, 10);
- setTimeout(function () {
- mail.updateTyping(a)
- }, 2E3)
- } else val(d, ""), style(d, "minWidth", 0), removeClass("animated", b), removeClass("is_typing", b)
- }
- },
- updateOnline: function (a, d) {
- var e = ge("messages" + a);
- e && remove(geByClass1("activity", e));
- each(geByClass("_lv" + a, "mcont"), function (a, c) {
- b(c, d)
- });
- c[a] && (c[a].write_form && (e = ce("div", {
- innerHTML: c[a].write_form
- }), each(geByClass("_lv" + a, e), function (a, c) {
- b(c, d)
- }), c[a].write_form = val(e)), c[a].messages && (e = ce("div", {
- innerHTML: c[a].messages
- }), remove(geByClass1("activity", e)), c[a].messages = val(e)))
- },
- sendMarkAsRead: function (a, b) {
- isArray(b) || (b = [b]);
- var d = c[a];
- d && d.hash && ajax.post("/mail", {
- _ajax: 1,
- act: "mark_read",
- peer: a,
- msgs: b.join(","),
- hash: d.hash
- }, {
- onDone: function (c) {
- c && each(b, function (b, c) {
- mail.markAsRead(a, c)
- })
- }
- })
- },
- markAsRead: function (a, b) {
- var d = ge("messages" + a);
- if (d && (removeClass("new", geByClass1("_msg" + b, d)), (d = c[a]) && d.messages)) {
- var e = ce("div", {
- innerHTML: d.messages
- });
- removeClass("new", geByClass1("_msg" + b, e));
- d.messages = val(e)
- }
- },
- markAsDeleted: function (a, b) {
- var d = ge("messages" + a);
- if (d && (remove(geByClass1("_msg" + b, d)), (d = c[a]) && d.messages)) {
- var e = ce("div", {
- innerHTML: d.messages
- });
- remove(geByClass1("_msg" + b, e));
- d.messages = val(e)
- }
- },
- addMessage: function (a, b, d, e) {
- 2E9 > a ? delete h[a] : h[a] && delete h[a][d];
- mail.updateTyping(a);
- if (!0 === e) ge("dialogs") && "/mail" == nav.path && (e = qs2obj(nav.params), !e.act && (!e.offset && !e.q) && ajax.click("/mail", extend({
- no_scroll: !0
- }, Dialogs)));
- else if (a && b && (l[b] = a), !geByClass1("_msg" + b)) if ((d = c[a]) && d.messages) {
- d.msgs && d.msgs.push(b);
- var f = ce("div", {
- innerHTML: d.messages
- });
- (b = geByClass1("activity", f)) ? (after(cdf(e), b), d.messages = val(f)) : d.messages = e + d.messages;
- (a = ge("messages" + a)) && val(a, d.messages)
- } else if (a = ge("messages" + a))(b = geByClass1("activity", a)) ? after(cdf(e), b) : val(a, e + val(a))
- },
- getMsgHTML: function (a, b, d, e, f, g, h) {
- var j = b & 2 ? vk.id : h && h.from || d;
- if (!j) return !1;
- if (!ge("messages" + d)) return !0;
- if (h.attach1 || h.fwd || h.geo || h.emoji || !c[d] || !c[d].hash) return !1;
- h = "_u" + j;
- var k = geByClass1(h, "mcont", "a"),
- j = stripTags(attr(k, "data-name") || val(k) || ""),
- k = getHref(k),
- l = geByClass1(h, "mcont", "img"),
- l = l && l.src || "",
- t = b & 32768;
- if (!j || !k || !l) return !1;
- d = intval(d);
- a = intval(a);
- f = f && -1 == f.toString().indexOf(" ... ") && 2E9 > d ? f : "";
- msg_class = b & 1 ? " new" : "";
- !(b & 2) && b & 1 && (msg_class += msg_class ? " _unread" : "");
- g = g.replace(/([a-zA-Z\-_\.0-9]+@[a-zA-Z\-_0-9]+\.[a-zA-Z\-_\.0-9]+[a-zA-Z\-_0-9]+)/g, function (a) {
- return '<a href="/write?email=' + a + '">' + a + "</a>"
- });
- g = g.replace(/(https?:\/\/)?(([A-Za-z\u0410-\u042f\u0430-\u044f\u0401\u04510-9@][A-Za-z\u0410-\u042f\u0430-\u044f\u0401\u04510-9@\-\_\.]*[A-Za-z\u0410-\u042f\u0430-\u044f\u0401\u04510-9@])(\/([A-Za-z\u0410-\u042f\u0430-\u044f0-9@\-\_#%&?+\/\.=;:~]*[^\.\,;\(\)\?<\&\s:])?)?)/ig, function (a, b, c, d) {
- b = b || "http://";
- if (-1 == d.indexOf(".") || -1 != d.indexOf("..")) return a;
- var e = d.split(".").pop();
- if (5 < e.length || -1 == indexOf("info name aero arpa coop museum mobi travel xxx asia biz com net org gov mil edu int tel ac ad ae af ag ai al am an ao aq ar as at au aw ax az ba bb bd be bf bg bh bi bj bm bn bo br bs bt bv bw by bz ca cc cd cf cg ch ci ck cl cm cn co cr cu cv cx cy cz de dj dk dm do dz ec ee eg eh er es et eu fi fj fk fm fo fr ga gd ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il im in io iq ir is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc li lk lr ls lt lu lv ly ma mc md me mg mh mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl pm pn pr ps pt pw py qa re ro ru rs rw sa sb sc sd se sg sh si sj sk sl sm sn so sr st su sv sy sz tc td tf tg th tj tk tl tm tn to tp tr tt tv tw tz ua ug uk um us uy uz va vc ve vg vi vn vu wf ws ye yt yu za zm zw \u0440\u0444 cat pro local".split(" "), e) || -1 != a.indexOf("@")) return a;
- try {
- a = decodeURIComponent(a)
- } catch (f) {}
- 55 < a.length && (a = a.substr(0, 53) + "..");
- a = htsc(a);
- return !t && d.match(/^([a-zA-Z0-9\.\_\-]+\.)?(vkontakte\.ru|vk\.com|vkadre\.ru|vshtate\.ru|userapi\.com)$/) ? (c = replaceEntities(c).replace(/([^a-zA-Z0-9#%;_\-.\/?&=\[\]])/g, encodeURIComponent), '<a href="' + (b + c).replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">") + '">' + a + "</a>") : '<a href="/away?to=' + encodeURIComponent(b + replaceEntities(c)) + '" target="_blank">' + a + "</a>"
- });
- a = '<a name="msg' + a + '"></a><div class="msg _msg' + a + msg_class + '"><div class="i"><a class="al' + h + '" href="' + k + '"><img src="' + l + '" class="u ' + h + '" align="left"></a></div><div class="cont"><div class="ch"><a class="date" href="/mail?act=msg&id=' + a + '">';
- b = new Date(1E3 * e);
- e = b.getHours();
- b = b.getMinutes();
- return a + (e + ":" + (10 > b ? "0" : "") + b) + '</a><a class="user al' + h + " " + h + '" href="' + k + '" data-name="' + escapeAttr(j) + '">' + j.split(" ").shift() + '</a></div><div class="cc">' + (f ? '<div class="title">' + f + "</div>" : "") + '<div class="text">' + g + '</div></div></div><div class="cb"></div></div>'
- },
- showDialog: function (a, b, d) {
- f = scrollTop();
- var e = c[b];
- if (e) {
- var h = ce("div", {
- innerHTML: val("m")
- }),
- p = geByClass1("btn back", geByClass1("mhead", h)),
- j;
- e.header && val(p, e.header);
- (j = geByTag1("a", p)) && j.setAttribute("onclick", "return nav.go(this, event);");
- val(geByClass1("pcont", geByClass1("mcont", h)), e.write_form + (b ? '<div id="messages' + b + '" class="messages">' + (e.messages || "") + '<div id="al_loading"></div></div>' : ""));
- e.fv_link && (attr(geByClass1("fv_link", h), "href", e.fv_link), attr("lm_fv_link", "href", e.fv_link));
- attr(geByClass1("app_link", h), "onclick", e.app_link ? "return nav.app_go(this, event, '" + escapeAttr(e.app_link) + "');" : !1);
- val("m", h.innerHTML);
- alLoadingFix();
- g = b;
- a = getHref(a);
- nav.go(a, null, {
- push_only: !0,
- no_push: d
- });
- b ? (s = null, mail.updateTyping(b), ajax.click(a, extend({
- save: b
- }, Dialog), {
- scroll: !0
- })) : qsearch.init({
- init_once: !0,
- action: "/mail?act=write&fast=1",
- container: geByClass1("peers", "mcont"),
- field: ge("qsearch_fld"),
- btn: ge("qsearch_btn"),
- top_items: [],
- _cache: {},
- hl_fields: [2],
- item_tpl: function (a, b, c, d, e) {
- return 2E9 < this.id || -1 == this.id ? '<div class="member' + (-1 == this.id ? " null" : "") + '"><a href="' + (a || "") + '" class="tap">' + (b || "") + '<div class="cont"><span class="user">' + (c || "") + "</span>" + (d || "") + (e ? '<div class="status">' + e + "</div>" : "") + "</div></a></div>" : '<a href="' + (a || "") + '" class="inline_item_tap" onclick="return mail.showDialog(this, ' + (this.id || 0) + ');"><div class="inline_item">' + (b || "") + '<span class="user">' + (c || "") + "</span>" + (d || "") + "</div></a>"
- },
- null_tpl: function () {
- return '<div class="m"><div class="null">' + lang.mobile_friends_no_friends + "</div></div>"
- },
- need_invalid_keys: browser.desktop,
- onLoaded: function (a) {
- for (var b in a) mail.saveDialog(a[b][a[b].length - 1], b)
- }
- });
- scrollTop(0, 10)
- } else nav.al_go(e && e.cur_link || getHref(a) || nav.cur);
- return !1
- },
- backToDialogs: function (a) {
- if (d) nav.go(e, null, {
- push_only: !0,
- no_push: a
- }), ajax.click(e, extend({
- no_scroll: !0
- }, Dialogs)), val("m", d), attr("lm_fv_link", "href", attr("fv_link", "href") || attr("fv_link", "data-href")), g = null, scrollTop(f || 0);
- else {
- var b = e || "/mail";
- nav.go(b, null, {
- push_only: !0,
- no_push: a
- });
- nav.al_go(b)
- }
- }
- }
- }(),
- im = function () {
- function a() {
- 64 > d && (d *= 2)
- }
- var b = null,
- c = {}, d = 1,
- e = null,
- f = !1,
- g = !1;
- return {
- init: function (a, c) {
- b || (setDocumentDomain(), b = ce("iframe", {
- src: a
- }, {
- display: "none"
- }), onDOMReady(function () {
- append(b, bodyNode)
- }));
- im.refreshParams(c);
- setTimeout(im.check, 1E3)
- },
- on: function () {
- clog("longpoll start");
- f = !0;
- setTimeout(im.check, 1E3)
- },
- off: function () {
- clog("longpoll pause");
- f = !1
- },
- refreshParams: function (a) {
- extend(c, a || {});
- extend(im, c)
- },
- getKey: function () {
- if (e) try {
- e.abort()
- } catch (b) {}
- e = ajax.post("/mail", {
- _ajax: 1,
- act: "im_get_key"
- }, {
- onDone: function (a) {
- /[0-9a-f]{40}/i.test(a) ? (im.refreshParams({
- key: a
- }), im.check()) : clog("invalid key")
- },
- onFail: function () {
- setTimeout(im.getKey, 1E3 * d);
- clog("from getKey delaying getKey for " + d + "secs");
- a()
- }
- })
- },
- check: function () {
- if (f && !g) {
- im.makeRequest || setTimeout(im.check, 1E3);
- try {
- im.makeRequest(function (b, c) {
- g = !1;
- if (vk.__debug) {
- var e = im.checked(parseJSON(c));
- clog("success", e);
- e && (im.check(), d = 1)
- } else try {
- e = im.checked(parseJSON(c)), clog("success", e), e && (im.check(), d = 1)
- } catch (f) {
- try {
- clog("error", f.message || "no message", f.type || "no type", f.stack || "no stack")
- } catch (j) {}
- setTimeout(im.check, 1E3 * d);
- a()
- }
- }, function () {
- g = !1;
- setTimeout(im.check, 1E3 * d);
- a()
- }), g = !0
- } catch (b) {
- clog("makeRequest failed")
- }
- }
- },
- checked: function (b) {
- var e = b.failed;
- if (1 == e || c.ts >= b.ts + 256) {
- if (im.refreshParams({
- ts: b.ts
- }), e) return !0
- } else {
- if (2 == e) return clog("delaying getKey for " + d + "secs"), setTimeout(im.getKey, 1E3 * d), a(), !1;
- if (e) {
- clog(b);
- return
- }
- }
- clog("ts", b.ts, c.ts);
- im.refreshParams({
- ts: b.ts
- });
- if (b.updates) {
- var e = [],
- f = [],
- g;
- for (g in b.updates) {
- var s = b.updates[g],
- r = intval(s[0]),
- n = intval(s[1]),
- m = intval(s[2]),
- u = intval(s[3]);
- clog(s);
- 51 != r && (61 == r ? mail.typing(n) : 62 == r ? mail.typing(2E9 + m, n) : 8 == r ? e.push(-n) : 9 == r ? mail.updateOnline(-n, 0) : u && (4 == r ? (r = m & 2 ? vk.id : s[7] && s[7].from || u, (s = mail.getMsgHTML(n, m, u, s[4], s[5], s[6], s[7])) ? (mail.addMessage(u, n, r, s), m & 2 || (n = getNotify() + 1, setNotify(n), window.al && window.al.menu && (m = Array(al.menu.length), m[2] = n, menu.refreshCounters(m)))) : f.push({
- peer: u,
- msg_id: n,
- from_id: r
- })) : 0 == r ? mail.markAsDeleted(n) : 2 == r ? m & 128 && mail.markAsDeleted(u, n) : 3 == r && m & 1 && mail.markAsRead(u, n)))
- }
- e.length && ajax.post("/mail", {
- _ajax: 1,
- act: "get_onlines",
- uids: e.join(",")
- }, {
- onDone: function (a) {
- each(a, function (a, b) {
- mail.updateOnline(a, b)
- })
- }
- });
- if (f.length) {
- var x = [];
- each(f, function (a, b) {
- x.push(b.msg_id)
- });
- ajax.post("/mail", {
- _ajax: 1,
- act: "get_messages",
- msgs: x.join(",")
- }, {
- onDone: function (a) {
- each(f, function (b, c) {
- a[c.msg_id] && mail.addMessage(c.peer, c.msg_id, c.from_id, a[c.msg_id])
- })
- }
- })
- }
- }
- return !0
- }
- }
- }(),
- geoloc = function () {
- function a(a, b) {
- var c = ge("medias_map"),
- d = ge("attached_wrap");
- c || (c = ce("div", {
- id: "medias_map",
- className: "medias"
- }), d.appendChild(c));
- var d = a.latitude,
- e = a.longitude,
- k = geByClass1("row map", c),
- s = b ? '<div class="close"><i> </i></div><div class="label">' + b + "</div>" : "";
- map_field = '<input type="hidden" name="map" value="' + (d + "_" + e + "_0") + '">';
- k ? val(k, s + "" + map_field) : val(c, '<div class="row map" onclick="geoloc.remove();">' + s + "" + map_field + "</div>");
- show(c)
- }
- function b(b) {
- if (b && b.coords) {
- var e = d = {
- latitude: +b.coords.latitude || 0,
- longitude: +b.coords.longitude || 0
- };
- ajax.post("/places.php", {
- _ajax: 1,
- act: "map_label",
- lat: e.latitude,
- lng: e.longitude
- }, {
- onDone: function (b) {
- hide("geo_waiting");
- a(e, b)
- },
- onFail: c
- })
- }
- }
- function c() {
- geoloc.remove();
- hide("geo_waiting")
- }
- var d = null,
- e = !1;
- return {
- toggle: function () {
- e ? geoloc.remove() : geoloc.add()
- },
- add: function (f) {
- if (f || !e) e = !0, addClass("sel", "geo_btn"), f && (f.latitude || f.longitude) ? (d = {
- latitude: +f.latitude || 0,
- longitude: +f.longitude || 0
- }, a(d, f.label)) : (geo.getCurrentPosition(b, c), show("geo_waiting"))
- },
- remove: function () {
- e && (e = !1, removeClass("sel", "geo_btn"), d = null, remove("medias_map"))
- },
- init: function (a) {
- a && geoloc.add(a);
- return geo.init()
- }
- }
- }(),
- checkin = function () {
- function a(a, b) {
- ajax.post("/places.php", {
- _ajax: 1,
- act: "search",
- lat: a.latitude,
- lng: a.longitude
- }, {
- onDone: function (d, e, f) {
- hide("geo_waiting");
- r = d || {};
- n = e || [];
- m = f || 0;
- if (u) return c();
- if (!b) {
- if (e.length) return c();
- g(a)
- }
- },
- onFail: function () {
- checkin.remove();
- hide("geo_waiting")
- }
- })
- }
- function b(a) {
- s = !1;
- var b = ge("medias_map"),
- c = ge("attached_wrap");
- b || (b = ce("div", {
- id: "medias_map",
- className: "medias"
- }), c.appendChild(b));
- var c = +a[1] || 0,
- d = a[3] || "",
- e = a[4] || "",
- f = a[5] || "";
- a = (+a[6].lat || 0) + "_" + (+a[6].lng || 0);
- var v = geByClass1("row link checkin", b),
- d = '<div class="close" onclick="checkin.remove();"><i> </i></div><div class="label" onclick="checkin.changePlace();">' + d + (f ? ", " + f : e ? ", " + e : "") + "</div>";
- checkin_field = '<input type="hidden" name="place_id" value="' + c + '"><input type="hidden" name="place" value="' + a + '">';
- v ? val(v, d + checkin_field) : (d = '<div class="row map">' + d + checkin_field + "</div>", val(b, d));
- addClass("sel", "geo_btn");
- k = !0;
- show(b)
- }
- function c(a) {
- u || (u = val("m"));
- var b = ce("div", {
- innerHTML: u
- });
- val(geByClass1("btn back", b), '<a class="b" onclick="checkin.back(); return false;"><i> </i><div class="title"><h1>' + lang.mobile_geo_head_title + "</h1></div></a>");
- var c = Math.min(604, getCw()) || 0,
- d = Math.ceil(c / 2) || 0,
- e = h.latitude,
- f = h.longitude,
- v = 1.5 <= window.devicePixelRatio ? "/images/x_map_point.png" : "/images/map_point.png",
- g = 1.5 <= window.devicePixelRatio ? 2 : 1,
- c = !hasClass("ioff", bodyNode) ? '<div style="background: url(//maps.googleapis.com/maps/api/staticmap?center=' + e + "," + f + "&zoom=14&size=" + c + "x" + d + "&scale=" + g + "&sensor=true&language=ru) #fff no-repeat center; background-size: " + c + "px " + d + 'px;"><div class="img" style="width: 100%; height: ' + d + "px; background: url(" + v + ') no-repeat center; background-size: 180px 70px;"></div></div>' : "";
- val(geByClass1("pcont", geByClass1("mcont", b)), '<div class="checkin_map" onclick="checkin.refreshCurrentPosition();">' + c + '</div><div id="places_box"><div class="panel"><form class="oneline qsearch" onsubmit="qsearch.go(event); return false;"><table><tr><td width="100%"><div class="iwrap"><input id="qsearch_fld" type="text" class="text" name="q" value="" placeholder="' + lang.mobile_geo_places_placeholder + '"></div></td><td class="last"><input id="qsearch_btn" type="submit" class="btn" value="' + lang.mobile_search_btn + '" onclick="return qsearch.go(event);"></td></tr></tbody></table></form></div><div class="items blt_cont"></div></div><div id="place_add_box" style="display:none;"></div>');
- val("m", b.innerHTML);
- scrollTop(0);
- nav.go(nav.path + (nav.params ? "?" + nav.params : "") + "#select_place", null, {
- push_only: !0,
- no_push: a
- });
- a = "/places.php?act=search&lat=" + e + "&lng=" + f;
- qsearch.init({
- action: a,
- al_action: a,
- container: geByClass1("items", "mcont"),
- field: ge("qsearch_fld"),
- btn: ge("qsearch_btn"),
- top_items: n || [],
- _cache: r || {},
- hl_fields: [2, 3],
- tpl: function (a, b) {
- var c = b ? lang.mobile_geo_place_add_link.replace("%s", htsc(b)) : lang.mobile_geo_place_add_item,
- d = escapeAttr(b || ""),
- e = escapeAttr(checkin.getCurrentAddress());
- return a + '<div class="member new_place"><a class="tap" onclick="checkin.addPlaceShow(\'' + d + "', '" + e + "'); return false;\">" + (a ? '<div class="i"></div>' : "") + '<div class="cont"><span class="user">' + c + "</span>" + (e ? '<div class="info">' + e + "</div>" : "") + "</div></a></div>"
- },
- item_tpl: function (a, b, c, d) {
- return '<div class="member place"><a class="tap" onclick="return checkin.selectPlace(this, ' + (this.id || 0) + ');">' + (b || "") + '<div class="cont"><span class="user">' + (c || "") + "</span>" + (d ? '<div class="info">' + d + "</div>" : "") + "</div></a></div>"
- },
- null_tpl: function () {
- return ""
- },
- top_len: 10,
- need_invalid_keys: browser.desktop,
- load_limit: m,
- onLoaded: function (a) {
- extend(r, a)
- },
- al_need: !0
- });
- return !1
- }
- function d() {
- val("place_add_box", "");
- hide("place_add_box");
- show("places_box")
- }
- function e(a, c) {
- f();
- var d = r[c];
- d && (h = {
- latitude: +d[6].lat || 0,
- longitude: +d[6].lng || 0
- }, c ? b(d) : g(h, d))
- }
- function f(a) {
- if (!u) return !0;
- val("m", u);
- u = null;
- scrollToEl(geByClass1("post_add", geByClass1("wall_edit")));
- nav.go(nav.path + (nav.params ? "?" + nav.params : ""), null, {
- push_only: !0,
- no_push: a
- });
- return !1
- }
- function g(a, b) {
- s = !0;
- var c = ge("medias_map"),
- d = ge("attached_wrap");
- c || (c = ce("div", {
- id: "medias_map",
- className: "medias"
- }), d.appendChild(c));
- var d = a.latitude,
- e = a.longitude,
- f = b && b[4] || !1,
- v = geByClass1("row map", c),
- f = f ? '<div class="close" onclick="checkin.remove();"><i> </i></div><div class="label" onclick="checkin.changePlace();">' + f + "</div>" : "";
- map_field = '<input type="hidden" name="map" value="' + (d + "_" + e + "_0") + '">';
- v ? val(v, f + "" + map_field) : val(c, '<div class="row map">' + f + "" + map_field + "</div>");
- k = !0;
- addClass("sel", "geo_btn");
- show(c)
- }
- function j(b) {
- b && b.coords && (h = {
- latitude: +b.coords.latitude || 0,
- longitude: +b.coords.longitude || 0
- }, a(h))
- }
- function l() {
- checkin.remove();
- hide("geo_waiting")
- }
- var h = null,
- k = !1,
- s = !1,
- r = {}, n = [],
- m = 0,
- u = null,
- x = "";
- return {
- toggle: function () {
- k ? checkin.remove() : checkin.add()
- },
- addNewPlace: function () {
- var a = val("place_name_fld"),
- b = val("place_address_fld");
- if (!a) return elfocus("place_name_fld"), !1;
- lockButton("place_add_btn");
- ajax.post("/places.php", {
- _ajax: 1,
- act: "add_place",
- latitude: h.latitude,
- longitude: h.longitude,
- title: a,
- address: b,
- hash: x
- }, {
- onDone: function (a, b) {
- unlockButton("place_add_btn");
- if (a) {
- var c = {};
- c[a] = b;
- extend(r, c);
- n.splice(n[0] ? 0 : 1, 0, a);
- d();
- e(null, a)
- }
- },
- onFail: function () {
- unlockButton("place_add_btn");
- var a = Array.prototype.slice.call(arguments).shift(),
- b = ge("place_add_form");
- switch (a) {
- case 2:
- b && b.submit()
- }
- }
- });
- return !1
- },
- addPlaceShow: function (a, b) {
- var c = "/places.php" + obj2qs({
- act: "add_place",
- latitude: h.latitude,
- longitude: h.longitude,
- hash: x
- });
- val("place_add_box", "<h4>" + lang.mobile_geo_new_place_header + '</h4><form id="place_add_form" action="' + c + '" method="post" class="place_add_box"><div class="cont"><dl><dt>' + lang.mobile_geo_place_name_label + '</dt><dd class="iwrap"><input type="text" class="text" id="place_name_fld" name="title" /></dd></dl><dl><dt>' + lang.mobile_geo_place_address_label + '</dt><dd class="iwrap"><input type="text" class="text" id="place_address_fld" name="address" /></dd></dl><div class="near_box"><input class="btn" type="submit" id="place_add_btn" value="' + lang.mobile_geo_place_add_btn + '" onclick="return checkin.addNewPlace(this);" /><div class="near_btn"><a onclick="checkin.addPlaceCancel(); return false;">' + lang.mobile_cancel + "</a></div></div></div></form>");
- val("place_name_fld", a || "");
- val("place_address_fld", b || "");
- hide("places_box");
- show("place_add_box");
- a ? elfocus("place_address_fld") : elfocus("place_name_fld")
- },
- addPlaceCancel: d,
- selectPlace: e,
- changePlace: c,
- back: f,
- refreshCurrentPosition: function () {
- geo.getCurrentPosition(j, l)
- },
- getCurrentAddress: function () {
- return r[0] && r[0][5] || ""
- },
- add: function (d) {
- if (!d && k) return c();
- d && (d.latitude || d.longitude) && d.place ? (h = {
- latitude: +d.latitude || 0,
- longitude: +d.longitude || 0
- }, d.place[1] ? b(d.place) : g(h, d.place), a(h, !0)) : (geo.getCurrentPosition(j, l), show("geo_waiting"))
- },
- remove: function () {
- k = !1;
- removeClass("sel", "geo_btn");
- h = null;
- r = {};
- n = [];
- m = 0;
- remove("medias_map")
- },
- stash: function (a) {
- if (a) h = a[0], k = a[1], s = a[2], r = a[3], n = a[4], m = a[5], u = a[6];
- else return [h, k, s, r, n, m, u]
- },
- init: function (a, b) {
- h = null;
- s = k = !1;
- r = {};
- n = [];
- m = 0;
- u = null;
- x = b || "";
- a && checkin.add(a);
- return geo.init()
- }
- }
- }();
- function QuickSearch(a) {
- function b(a) {
- a = a.replace(/https?:\/\/(m\.)?vk\.com\/([^#]+#\/)?/, "");
- var b, c, d = F;
- a = [a, b = parseRusKeys(a, d) || a, c = parseLatKeys(a, d) || a, parseLat(b), parseCyr(c)];
- c = {};
- for (var d = [], e = 0, f = a.length; e < f; e++) a[e] && !c[a[e]] && (c[a[e]] = !0, b = escapeRE(a[e]), b = b.replace(/[\u0435\u0451]/gi, "[\u0435\u0451]").replace(/(e|yo)/gi, "(?:e|yo)"), d.push(RegExp("(^|\\s|\\(|>)(" + b + ")", "gi")));
- return d
- }
- function c(a, v, g) {
- clearTimeout(z);
- if (!g) return z = setTimeout(function () {
- c(a, v, !0)
- }, 10), !1;
- g = val(a) || "";
- if (q == g) return !1;
- var h = "_" + g,
- w = m[h],
- C = b(g),
- j;
- if (!w && 2 < g.length && m["_" + g.slice(0, -2)]) {
- var k = "_" + g.slice(0, -2);
- if (m[k] && (x[k] && !m[k].length) && (!K || K && !u[k])) x[h] = !0, w = m[h] = [], K && (u[h] = "")
- }
- if (w) clog("`" + g + "`: from cache");
- else {
- w = [];
- k = 0;
- if (!g && r.length) for (var t = B, l = B + Math.min(E, r.length); t < l; t++) w.push([r[t]]), k++;
- else {
- for (var L = {}, p = 0, t = 0, l = r.length; t < l; t++) {
- var D = r[t];
- if (n[D]) {
- L[D] = !0;
- if (j = e(C, n[D][0])) if (w.push([D, j]), ++p >= M) break;
- k++
- }
- }
- if (p < M) for (D in n) if (!L[D] && (j = e(C, n[D][0]))) {
- w.push([D, j]);
- if (++p >= M) break;
- k++
- }
- }
- clog("`" + g + "`: analyse " + k + " peers, " + w.length + " found");
- x[h] = x[h] || !g && r.length || w.length > 2 * E;
- x[h] = x[h] || K && w.length > E
- }
- if (!x[h] && (G || K)) clog("`" + g + "`: need load"), d(a, g);
- m[h] = w;
- q = g;
- f(w, u[h]);
- R && R(g);
- H && !q && (I = E);
- return !1
- }
- function d(a, c, v) {
- clearTimeout(A);
- if (!v) return A = setTimeout(function () {
- d(a, c, !0)
- }, 200), !1;
- ajax.post(g, {
- _ajax: 1,
- q: c
- }, {
- onDone: function (d, v, g) {
- L && L.apply(null, arguments);
- for (var h = "_" + c, w = m[h] || [], C = {}, j = b(c), k, t = 0, l = w.length; t < l; t++) C[w[t][0]] = !0;
- t = 0;
- for (l = v.length; t < l; t++) {
- var D = v[t];
- C[D] || ((k = e(j, d[D][0])) || J || !c) && w.push([D, k])
- }
- clog("`" + c + "`: loaded. now " + w.length + " peers");
- x[h] = !0;
- m[h] = w;
- K && (u[h] = g || "");
- n = extend(d, n);
- G = !y || len(n) < y;
- q == c ? f(w, u[h]) : delete m[h];
- removeClass("loading", a)
- },
- onFail: function () {
- delete m["_" + c];
- removeClass("loading", a)
- }
- });
- geByClass1("al_loading", l) || addClass("loading", a)
- }
- function e(a, b) {
- if (!b) return !1;
- for (var c = 0, d = a.length; c < d; c++) if (-1 !== b.search(a[c])) return a[c];
- return !1
- }
- function f(a, b) {
- var c = "";
- if (C && l) {
- for (var d = 0, e = a.length; d < e; d++) {
- var f = a[d][0],
- g = a[d][1];
- if (n[f]) {
- var j = n[f].slice(1);
- if (g) for (var k in t) {
- var m = t[k];
- j[m] && (j[m] = j[m].replace(g, "$1<em>$2</em>"))
- }
- c += C.apply({
- id: f,
- q: q,
- highlight: function (a) {
- return (a || "").replace(g, "$1<em>$2</em>")
- }
- }, j)
- }
- }
- if (!c && !x["_" + q] && (G || K)) removeClass("loading", h), c = q ? '<div class="al_loading qs_loading"> </div>' : '<div id="al_loading"></div>';
- !c && w && (c = w(q));
- clog("rendered");
- val(l, v ? v(c, q, H, b) : c + (b || ""));
- s && (q ? show(s) : hide(s));
- !q && alLoadingFix();
- D && D()
- }
- }
- var g, j, l, h, k, s, r = [],
- n = {}, m = {}, u = {}, x = {}, p = !1,
- q = null,
- z = null,
- A = null,
- B = 0,
- t = [],
- v = null,
- C = null,
- w = null,
- J = !1,
- F = !1,
- E = 10,
- M = 30,
- G = !0,
- y = !1,
- H = !1,
- K = !1,
- L, R, D, P, I = 0,
- N = 0,
- Q = !1;
- extend(this, {
- go: function (a) {
- if (!h) return !0;
- c(h, a, !0);
- h.blur();
- cancelEvent(a);
- return !1
- },
- redraw: function () {
- var a = "_" + q;
- f(m[a], u[a])
- },
- clear: function (a, b) {
- val(h, "");
- b ? elfocus(h) : elblur(h);
- c(h, a, !0);
- cancelEvent(a);
- return !1
- },
- blur: function () {
- elblur(h)
- },
- init: function (a) {
- clog(a);
- a = a || {};
- l = ge(a.container) || null;
- h = ge(a.field) || null;
- k = ge(a.btn) || null;
- s = ge(a.clear_btn) || null;
- q = null;
- if (!p || g != a.action || !a.init_once) m = {}, u = {}, x = {}, g = a.action || "", j = a.al_action || g, r = a.top_items || [], n = a._cache || {}, t = a.hl_fields || [], v = a.tpl || null, C = a.item_tpl || null, w = a.null_tpl || null, J = a.soft_filter || !1, F = a.need_invalid_keys || !1, E = a.top_len || 10, y = a.load_limit || !1, L = a.onLoaded || !1, R = a.onFiltered || !1, D = a.onRendered || !1, P = a.onFocusChanged || !1, H = a.al_need || !1, B = !H && a.init_offset || 0, K = a.global_search || !1;
- var b = null;
- if (g && l && h && C) {
- G = !0 !== g && (!y || len(n) < y);
- addEvent(h, "focus", function (a) {
- var d = function (e) {
- !e && c(h, a, !0);
- b = setTimeout(d, 100)
- };
- clearTimeout(b);
- P && P.call({
- q: q
- }, !0);
- d(!0)
- });
- addEvent(h, "keydown keypress change blur", function (a) {
- "blur" == a.type && (clearTimeout(b), P && P.call({
- q: q
- }, !1));
- c(h, a, "keydown" != a.type && "keypress" != a.type)
- });
- a._new || k && !attr(k, "onclick") && attr(k, "onclick", "return qsearch.go(event);");
- if (H && (!p || !a.init_once)) I = E, N = len(n), initAutoScroll(function () {
- var a = l.childNodes;
- return a[I] || a[a.length - 1]
- }, function () {
- if (!Q && !q) if (I + E > N && G) Q = !0, ajax.post(j, {
- _ajax: 1,
- offset: N
- }, {
- onDone: function (a, b) {
- L && L.apply(null, arguments);
- var c = len(a);
- Q = !1;
- y || (r = r.slice(0, N).concat(b));
- N += c;
- n = extend(a, n);
- G = !0 !== g && (!y && c || len(n) < y);
- if (!q) {
- I += E;
- for (var c = [], d = 0, e = Math.min(I, r.length); d < e; d++) c.push([r[d]]);
- clog("scroll loaded. show " + c.length + " peers");
- f(c, u._)
- }
- },
- onFail: function () {
- Q = !1
- }
- });
- else if (I < r.length) {
- I += E;
- for (var a = [], b = 0, c = Math.min(I, r.length); b < c; b++) a.push([r[b]]);
- clog("scroll from cache. show " + a.length + " peers");
- f(a, u._)
- }
- });
- !a.skip_init_filter && c(h, null, !0);
- p = !0
- }
- }
- });
- a && this.init(a)
- }
- var qsearch = new QuickSearch,
- photo = function () {
- function a() {
- h = geByClass1("photoview");
- if (!h) return nav.al_go(nav.cur), !1;
- k = geByClass1("summary", h);
- pm = geByClass1("photo_msg", h);
- pt = geByClass1("tag_info_wrap", h);
- n = geByClass1("photo_wrap", h);
- m = geByClass1("pv", n);
- r = geByClass1("nav", n);
- u = geByTag1("a", m);
- x = geByTag1("img", m);
- p = geByClass1("desc", h);
- q = geByClass1("actions", h);
- z = geByClass1("comments_wrap", h);
- if (!(s = geByClass1("loading", k))) s = ce("div", {
- innerHTML: "<i></i>",
- className: "loading"
- }, {
- display: "none"
- }), k.appendChild(s);
- if (r) {
- var a = geByTag("a", r);
- A = a[0];
- B = a[1];
- A && A.setAttribute("onclick", "return photo.prev(event);");
- B && B.setAttribute("onclick", "return photo.next(event);");
- u && u.setAttribute("onclick", "return photo.next(event);");
- ajax.prepare_click([A, B, u])
- }
- removeEvent(window, "orientationchange", f);
- addEvent(window, "orientationchange", f);
- return !0
- }
- function b(a) {
- var b = [];
- each(a, function (a, c) {
- if (!c) return !0;
- b.push(t[c.id] = c)
- });
- return b
- }
- function c(a) {
- return t[a] || {}
- }
- function d(a, c, d) {
- null === c ? delete v[a] : (v[a] || (v[a] = Array(d ? d : d(c))), b(c), a = v[a], F && a.reverse(), extend(a, c), F && (w = copy(a), a.reverse()))
- }
- function e(a) {
- if ("string" !== typeof a) return a;
- a = v[a] || [];
- return F ? copy(a).reverse() : a
- }
- function f() {
- nav.hash || onDOMReady(function () {
- if (geByClass1("photoview")) {
- var a = scrollTop();
- n && getY(n) < a && scrollToEl(n)
- }
- })
- }
- function g(a, b, c) {
- var e = w[a],
- v = 1 == w.length;
- if (e) {
- f();
- var t = {};
- E && (t.list = E);
- F && (t.rev = 1);
- M && (t.from = M);
- var m = obj2qs(t),
- t = "photo" + e.id + m,
- n = e.photo,
- r = (j(a - 1) || {}).id;
- a = (j(a + 1) || {}).id;
- v || (u.href = "/photo" + a + m, A.href = "/photo" + r + m, B.href = "/photo" + a + m, ajax.prepare_click([A, B, u]));
- x && x.src != n && (x.onload = null, remove(x), x = ce("img", {
- src: n,
- alt: ""
- }), append(x, u));
- toggleClass("photo_deleted", h, !! e.deleted);
- val(geByTag1("span", k), y + 1);
- val(pm, e.deleted || "");
- val(pt, e.tag_info || "");
- v = "";
- e.caption && (v += '<div class="text">' + e.caption + "</div>");
- e.album_link && (v += "<dl><dt>" + lang.mobile_photos_photo_album_label + "</dt><dd>" + e.album_link + "</dd></dl>");
- e.author_link && (v += "<dl><dt>" + lang.mobile_photos_photo_author_label + "</dt><dd>" + e.author_link + "</dd></dl>");
- if (e.date || e.likes || e.publish) v += '<div class="info">' + (e.date || "") + (e.likes || "") + (e.publish || "") + "</div>";
- val(p, v);
- val(q, e.actions || "");
- val(z, e.comments_html || "");
- e.fv_link && (attr("fv_link", "href", e.fv_link), attr("lm_fv_link", "href", e.fv_link));
- attr("app_link", "onclick", e.app_link ? "return nav.app_go(this, event, '" + escapeAttr(e.app_link) + "');" : !1);
- nav.go("/" + t, null, {
- no_push: b,
- push_only: !0,
- replace: c
- })
- }
- if (!G) {
- if (!H) {
- b = !1;
- c = 1;
- for (e = 0; 5 > e; e++) v = e + y, t = j(v), t || (b = v, c = 1);
- if (!1 === b) for (e = -1; - 3 < e; e--) v = e + y, t = j(v), t || (b = v, c = -1);
- if (!1 !== b && (e = j(y))) H = !0, show(s), ajax.post("/photos.php", {
- _ajax: 1,
- oid: e.owner_id,
- list: J,
- offset: b,
- direction: c,
- rev: F ? 1 : 0
- }, {
- onDone: function (a) {
- hide(s);
- H = !1;
- d(J, a, w.length);
- g(y, !0)
- }
- })
- }
- b = 0;
- for (c = y + 1; b < l; b++) {
- var O = (e = j(b + c)) && e.photo;
- O && !C[O] && (e = C[O] = new Image, e.src = O, e.onload = function () {
- C[O] = !0
- })
- }
- }
- }
- function j(a) {
- a = 0 < a ? a % w.length : (100 * w.length + a) % w.length;
- return w[a]
- }
- var l = 1,
- h, k, s, r, n, m, u, x, p, q, z, A, B, t = {}, v = {}, C = {}, w = null,
- J = null,
- F = !1,
- E = null,
- M = null,
- G = !0,
- y = 0,
- H = !1;
- return {
- save: b,
- get: c,
- saveSource: d,
- getSource: e,
- clear: function () {
- removeEvent(window, "orientationchange", f)
- },
- open: function (b, d, f, v, h) {
- if (checkEvent(f) || !a()) return !0;
- F = !1;
- "/rev" == d.substr(-4) && (d = d.slice(0, -4), F = !0);
- M = v || null;
- d ? J = d : (d = c(b), J = d.album ? "album" + d.album : "");
- E = qs2obj(nav.params).list ? J : "";
- w = e(J);
- a: {
- (d = w) || (d = w);
- for (var C in d) if (w[C].id == b) {
- y = +C;
- break a
- }
- y = -1
- }
- if (-1 === y) if (d = c(b), d.id) w = [d],
- y = 0;
- else return !1;
- G = 2 > w.length;
- b = w[y] && b != w[y].id;
- g(y, h && !b, b);
- return !1
- },
- prev: function (b) {
- if (checkEvent(b)) return !0;
- if (H && !j(y - 1)) return !1;
- if (!a()) return !0;
- if (G) return photo.close();
- 0 > --y && (y = w.length - 1);
- g(y);
- return !1
- },
- next: function (b) {
- if (checkEvent(b)) return !0;
- if (H && !j(y + 1)) return !1;
- if (!a()) return !0;
- if (G) return !1;
- ++y >= w.length && (y = 0);
- g(y);
- return !1
- },
- close: function (a) {
- return checkEvent(a) ? !0 : !1
- },
- init: function (a, b, c, d, e, f, v) {
- l = "undefined" !== typeof v ? v : 1;
- F = !! e;
- photo.saveSource(a, b, c);
- onDOMReady(function () {
- photo.open(d, a + (e ? "/rev" : ""), null, f, !0)
- })
- }
- }
- }(),
- audio = function () {
- function a() {
- return n[m] || !1
- }
- function b() {
- return a().id || !1
- }
- function c(a) {
- a && (k.src = a.src, k.load(), audio.onSelect(!0, a))
- }
- function d() {
- var a = b();
- ssSet("audio_id", a);
- ssSet("audio_pos", 0);
- clog("saved");
- A && (document.cookie = A + "=" + a + "; expires=" + (new Date(vkNow() + 864E5)).toUTCString() + "; path=" + B)
- }
- var e = !1,
- f = !1,
- g = !1,
- j = !1,
- l = function (a) {
- clog("play after document click");
- if (e || !1 !== j) if (clog("playing: " + (p ? "true" : "false")), e = !1, !p || !1 !== j) g = !0, k.pause(), clog("audio paused after document click");
- cancelEvent(a);
- removeEvent(k, "play", l);
- removeEvent(document, isTouch ? "touchstart" : "click", h)
- }, h = function () {
- f && (f = !1, clog("document clicked"), e = !0, k.play(), removeEvent(document, isTouch ? "touchstart" : "click", h))
- }, k, s = window.Audio ? new Audio : ce("audio");
- s.autobuffer = !0;
- j = g = e = q = z = s.muted = !1;
- addEvent(s, "play", function () {
- p || (p = !0, audio.onPlay(!0), ssSet("audio_play", "1"))
- });
- addEvent(s, "pause", function () {
- g ? g = !1 : p && (p = !1, audio.onPause(!0), ssSet("audio_play", "0"))
- });
- addEvent(s, "progress", function () {
- audio.onProgress(!0)
- });
- addEvent(s, "timeupdate", function () {
- g || (audio.onProgress(!0), audio.onPositionChanged(!0, audio.position(), audio.duration()), ssSet("audio_pos", audio.position()), !z && 0.5 > k.duration - k.currentTime && (z = !0), q && (q = !1, audio.next()))
- });
- addEvent(s, "ended", function () {
- audio.onEnded(!0);
- z ? (z = !1, audio.next()) : q = !0
- });
- addEvent(s, "play", l);
- addEvent(s, "progress canplaythrough", function () {
- clog("progress fired, fix_update " + (!j ? "not " : "") + "found");
- !1 !== j && j()
- });
- addEvent(document, isTouch ? "touchstart" : "click", h);
- k = s;
- var r = Math.random().toString(36).substr(2),
- n = [],
- m = null,
- u = {}, x = "",
- p = !1,
- q = !1,
- z = !1,
- A = !1,
- B = !1;
- setInterval(function () {
- var a = lsGet("audio_current_player");
- r != a && p && audio.pause()
- }, 100);
- return {
- init: function (a) {
- if (!audio.support) return !1;
- a.cookie && (A = a.cookie, B = a.cookie_path || "/");
- onDOMReady(function () {
- a.playlist && audio.playlist(a.playlist, {
- q: a.playlist_q || ""
- });
- var b = ssGet("audio_id");
- if (b) {
- var c = ssGet("audio_pos"),
- d = ssGet("audio_vol"),
- e = ssGet("audio_play");
- audio.select(b);
- "1" == e && (null !== c && audio.position(c), null !== d && audio.volume(d), f = !0, audio.play());
- clog(["restored", b, c, d, e].join(", "))
- }
- })
- },
- support: k.canPlayType && k.canPlayType("audio/mpeg") && "no" != k.canPlayType("audio/mpeg") || !1,
- onPlay: se(b),
- onPause: se(b),
- onDeselect: se(b, function () {
- return audio.duration()
- }),
- onSelect: se(),
- onProgress: se(b, function () {
- return audio.loaded()
- }, function () {
- return audio.duration()
- }),
- onPositionChanged: se(b),
- onVolumeChanged: se(b, function () {
- return k.volume
- }),
- onEnded: se(b),
- onNotFoundError: se(),
- onEmptyPlaylistError: se(),
- getCurrent: a,
- getCurrentId: b,
- operate: function (a) {
- if (!audio.support) return !1;
- a && (!n[m] || a != n[m].id) ? audio.play(a) : p ? audio.pause() : audio.play()
- },
- playing: function () {
- return p
- },
- select: function (a) {
- if (!audio.support) return !1;
- if (a) if (n.length) {
- if (n[u[a]]) return b() && audio.onDeselect(!0), m = u[a], c(n[m]), d(), !0;
- audio.onNotFoundError(!0, a)
- } else audio.onEmptyPlaylistError(!0, a)
- },
- play: function (a) {
- if (!audio.support) return !1;
- if (a) {
- p && audio.pause();
- if (!audio.select(a)) return;
- try {
- k.currentTime = 0.01
- } catch (b) {}
- }
- p || (k.muted = !1, k.play(), p = !0, audio.onPlay(!0), ssSet("audio_play", "1"), lsSet("audio_current_player", r))
- },
- pause: function () {
- if (!audio.support) return !1;
- p && (k.pause(), p = !1, audio.onPause(!0), ssSet("audio_play", "0"))
- },
- position: function (a, b) {
- if (!audio.support) return !1;
- if ("undefined" !== typeof a) {
- b && (a *= audio.duration());
- a = Math.max(0, Math.min(a, audio.duration()));
- var c = p;
- clog("fix_update: " + j);
- c && (p = !1, k.pause());
- try {
- k.currentTime = a, audio.onPositionChanged(!0, audio.position(), audio.duration()), ssSet("audio_pos", a), c && (p = !0, k.muted = !1, k.play())
- } catch (d) {
- audio.onPositionChanged(!0, a, audio.duration()), clog("need to set position"), j = function () {
- clog("set position");
- j = !1;
- clog("pos: " + a + ", playing: " + p);
- audio.position(a);
- clog("p.currentTime: " + k.currentTime)
- }, c && (p = !0)
- }
- } else return k.currentTime
- },
- volume: function (a) {
- if (!audio.support) return !1;
- if ("undefined" !== typeof a) {
- try {
- k.volume = a || 0
- } catch (b) {}
- audio.onVolumeChanged(!0);
- ssSet("audio_vol", a || 0)
- } else return k.volume
- },
- loaded: function () {
- return k.buffered && k.buffered.length && k.buffered.end(k.buffered.length - 1) || 0
- },
- duration: function () {
- return n[m] && n[m].dur || k.duration || 0
- },
- next: function () {
- if (!audio.support) return !1;
- p && audio.pause();
- audio.onDeselect(!0);
- ++m >= n.length && (m = 0);
- c(n[m]);
- d();
- f = !0;
- audio.play()
- },
- prev: function () {
- if (!audio.support) return !1;
- p && audio.pause();
- audio.onDeselect(!0);
- 0 >= --m && (m = n.length - 1);
- c(n[m]);
- d();
- f = !0;
- audio.play()
- },
- playlist: function (b, c) {
- if (!audio.support) return !1;
- if ("undefined" !== typeof b) {
- p && audio.pause();
- if (a()) audio.onDeselect(!0);
- n = b;
- x = c && c.q || "";
- m = null;
- u = {};
- each(b, function (a, b) {
- u[b.id] = a
- });
- var d = x;
- ssSet("audio_query", d);
- A && (document.cookie = A + "q=" + encodeURIComponent(d) + "; expires=" + (new Date(vkNow() + 864E5)).toUTCString() + "; path=" + B)
- } else return n
- },
- playlist_q: function () {
- return x
- }
- }
- }(),
- audioplayer = function () {
- function a(a) {
- if (a) {
- show("lm_player");
- var b = ge("lm_audio");
- b && (val(geByClass1("artist", b), a.artist), val(geByClass1("title", b), a.title));
- if (a = ge("audio" + a.id)) j(a, 0), l(a, 0), g(a, r(0, audio.duration())), h(a, audio.volume()), addClass("audio_current", a)
- } else hide("lm_player")
- }
- function b(a, b) {
- var c = ge("audio" + a);
- removeClass("playing", "lm_audio");
- c && (g(c, s(b)), removeClass("playing", c), removeClass("audio_current", c))
- }
- function c(a, b, c) {
- if (a = ge("audio" + a)) z || l(a, b / c), g(a, audioplayer.getFormatedTime(b, c))
- }
- function d(a) {
- var b = gpeByClass("audios_list", "audio" + a),
- c = geByClass("audio", b),
- d = [],
- e = !1;
- each(c, function (b, c) {
- c = k(c);
- if (!c) return !0;
- d.push(c);
- c.id == a && (e = !0)
- });
- audio.playlist(d, {
- q: attr(b, "data-query")
- });
- e && audio.play(a)
- }
- function e(a) {
- if (z) {
- var b = gpeByClass("audio", z),
- c = f(z, a);
- a && cancelEvent(a);
- B && l(b, c);
- t && (h(b, c), audio.volume(c));
- A = c
- }
- }
- function f(a, b) {
- var c = hasClass("touch", bodyNode) ? 10 : 8,
- d = (b.pageX || b.touches && b.touches[0] && b.touches[0].pageX || 0) - getX(a) - c / 2;
- return (c = a.offsetWidth - c) ? Math.max(0, Math.min(d / c, 1)) : 0
- }
- function g(a, b) {
- if (a) {
- var c = geByClass1("dur", a);
- val(c, b)
- }
- }
- function j(a, b) {
- if (a) {
- var c = geByClass1("progress_wrap", a);
- geByClass1("load_line", c).style.width = 100 * Math.max(0, Math.min(b, 1)) + "%"
- }
- }
- function l(a, b) {
- if (a) {
- var c = geByClass1("progress_wrap", a),
- c = geByClass1("progress_line", c);
- geByClass1("slider", c);
- c.style.width = 100 * b + "%"
- }
- }
- function h(a, b) {
- if (a) {
- var c = geByClass1("volume_wrap", a),
- c = geByClass1("progress_line", c);
- geByClass1("slider", c);
- c.style.width = 100 * b + "%"
- }
- }
- function k(a) {
- a = ge(a);
- if (!a || !attr(a, "data-id") || hasClass("deleted", a)) return !1;
- var b = attr(a, "data-id"),
- c = val(geByTag1("input", a)),
- d = attr(geByClass1("dur", a), "data-dur"),
- e = val(geByClass1("artist", a)),
- f = val(geByClass1("title", a)),
- g = !! geByClass1("add", a);
- a = !! geByClass1("del", a);
- return {
- id: b,
- src: c,
- dur: d,
- artist: htsc(stripTags(e)),
- title: htsc(stripTags(f)),
- can_add: g,
- can_del: a
- }
- }
- function s(a) {
- var b, c, d = 0 > a;
- a = Math.round(d ? -a : a);
- b = a % 60;
- a = Math.floor(a / 60);
- c = a % 60;
- b = c + ":" + (10 > b ? "0" + b : b);
- a = Math.floor(a / 60);
- 0 < a && (10 > c && (b = "0" + b), b = a + ":" + b);
- d && (b = "-" + b);
- return b
- }
- function r(a, b) {
- return s(u && b ? a - b : a)
- }
- function n(a) {
- cur.deletedAudios || (cur.deletedAudios = {});
- cur.deletedAudios[a] = !0
- }
- function m(a) {
- cur.deletedAudios && delete cur.deletedAudios[a]
- }
- var u = "1" == lsGet("audio_time_left"),
- x = "",
- p = "",
- q = "";
- audio.onPlay(function (a) {
- addClass("playing", "lm_audio");
- if (a = ge("audio" + a)) addClass("playing", a), addClass("audio_current", a)
- });
- audio.onPause(function (a) {
- removeClass("playing", "lm_audio");
- if (a = ge("audio" + a)) removeClass("playing", a), addClass("audio_current", a)
- });
- audio.onSelect(a);
- audio.onDeselect(b);
- audio.onProgress(function (a, b, c) {
- a = ge("audio" + a);
- audio.playing() ? (addClass("playing", a), addClass("playing", "lm_audio")) : (removeClass("playing", a), removeClass("playing", "lm_audio"));
- a && (j(a, b / c), addClass("audio_current", a))
- });
- audio.onPositionChanged(c);
- audio.onVolumeChanged(function (a, b) {
- var c = ge("audio" + a);
- c && h(c, b)
- });
- audio.onEnded(function (a) {
- (a = ge("audio" + a)) && l(a, 1)
- });
- audio.onNotFoundError(d);
- audio.onEmptyPlaylistError(d);
- var z = null,
- A = null,
- B = !1,
- t = !1;
- addEvent(document, isTouch ? "touchend touchcancel" : "mouseup", function (a) {
- if (z) {
- var b = gpeByClass("audio", z),
- c = f(z, a) || A;
- a && cancelEvent(a);
- B && (l(b, c), audio.position(c, !0));
- t && h(b, c);
- z = A = null;
- B = t = !1
- }
- });
- addEvent(document, isTouch ? "touchmove" : "mousemove", e);
- return {
- init: function (a) {
- if (!audio.support) return !1;
- x = a.add_hash || "";
- p = a.del_hash || "";
- q = a.res_hash || ""
- },
- initAudio: function () {
- each(geByClass("audio_current"), function (a, c) {
- c = k(c);
- b(c.id, c.dur)
- });
- var d = audio.getCurrentId(),
- d = ge("audio" + d),
- e = audio.loaded(),
- f = audio.position(),
- g = audio.duration();
- audio.playing() ? (addClass("playing", d), addClass("playing", "lm_audio")) : (removeClass("playing", d), removeClass("playing", "lm_audio"));
- a(audio.getCurrent());
- j(d, e / g);
- c(audio.getCurrentId(), f, g)
- },
- getDOMFromAudio: function (a, b, c) {
- if (!a) return "";
- var d = htsc(a.id),
- e = htsc(a.src),
- f = +a.dur,
- g = a.artist,
- h = a.title,
- j = a.can_add;
- a = a.can_del;
- var k = h ? " – " : "",
- m = isTouch ? "ontouchstart" : "onmousedown",
- l = "",
- n = "",
- p;
- p = cur.deletedAudios ? cur.deletedAudios[d] : !1;
- if (p) {
- if (c) return "";
- l += " deleted"
- }
- c = cur.addedAudios ? cur.addedAudios[d] : !1;
- c && (l += " added");
- a ? (l += " have_btn", n = '<div class="del" onclick="audioplayer.del(\'' + d + "', event);\"><i></i></div>") : j && (l += " have_btn", n = '<div class="add" onclick="audioplayer.add(\'' + d + "', event);\"><i></i></div>");
- d == audio.getCurrentId() && (audio.playing() && (l += " playing"), l += " audio_current");
- return '<div id="audio' + d + '" data-id="' + d + '" class="audio' + l + '" onclick="audioplayer.playPause(\'' + d + "'" + (b ? ", true" : "") + ');"><div class="audio_info"><div class="play"><i></i></div>' + n + '<div class="audio_cont"><div class="dur" data-dur="' + f + '" onclick="audioplayer.switchTimeFormat(this, event);"><span>' + s(f) + '</span></div><div class="audio_label"><span class="artist">' + g + "</span>" + k + '<span class="title">' + h + '</span></div><input type="hidden" value="' + e + '"></div></div><div class="controls"><table cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td class="line_wrap progress_wrap"><div class="line" ' + m + '="audioplayer.setPosition(this, event);" onclick="cancelEvent(event);"><div class="ln back_line" onclick="cancelEvent(event);"></div><div class="ln load_line" onclick="cancelEvent(event);"></div><div class="ln progress_line_wrap" onclick="cancelEvent(event);"><div class="ln progress_line" onclick="cancelEvent(event);"><div class="slider" onclick="cancelEvent(event);"></div></div></div></div></td><td class="line_wrap volume_wrap"><div class="line" ' + m + '="audioplayer.setVolume(this, event);" onclick="cancelEvent(event);"><div class="ln back_line" onclick="cancelEvent(event);"></div><div class="ln progress_line_wrap" onclick="cancelEvent(event);"><div class="ln progress_line" onclick="cancelEvent(event);"><div class="slider" onclick="cancelEvent(event);"></div></div></div></div></td></tr></table></div></div>'
- },
- add: function (a, b) {
- audio.support && !hasClass("added", "audio" + a) && (addClass("added", "audio" + a), cur.addedAudios || (cur.addedAudios = {}), cur.addedAudios[a] = !0, ajax.post("/audio", {
- _ajax: 1,
- act: "add",
- audio: a,
- hash: x
- }, {
- onDone: function (b) {
- b || (removeClass("added", "audio" + a), cur.addedAudios && delete cur.addedAudios[a])
- },
- onFail: function () {
- removeClass("added", "audio" + a);
- cur.addedAudios && delete cur.addedAudios[a];
- switch (Array.prototype.slice.call(arguments).shift()) {
- case 2:
- nav.go("/audio?act=add&audio=" + a + "&hash=" + x)
- }
- }
- }), b && cancelEvent(b))
- },
- del: function (a, b) {
- if (audio.support && ge("audio" + a)) {
- var c = hasClass("deleted", "audio" + a);
- toggleClass("deleted", "audio" + a, !c);
- c ? m(a) : n(a);
- ajax.post("/audio", {
- _ajax: 1,
- act: c ? "restore" : "delete",
- audio: a,
- hash: c ? q : p
- }, {
- onDone: function (b) {
- b || (toggleClass("deleted", "audio" + a, c), c ? n(a) : m(a))
- },
- onFail: function () {
- toggleClass("deleted", "audio" + a, c);
- c ? n(a) : m(a);
- switch (Array.prototype.slice.call(arguments).shift()) {
- case 2:
- nav.go("/audio?act=" + (c ? "restore" : "delete") + "&audio=" + a + "&hash=" + (c ? q : p))
- }
- }
- });
- b && cancelEvent(b)
- }
- },
- playPause: function (a, b) {
- if (audio.support) {
- var c = ge("audio" + a);
- if (!c || !hasClass("deleted", c)) b && a != audio.getCurrentId() ? d(a, !0) : audio.operate(a)
- } else alert(lang.mobile_audio_player_not_support)
- },
- getFormatedTime: r,
- switchTimeFormat: function (a, b) {
- if (hasClass("audio_current", gpeByClass("audio", a))) {
- u = !u;
- lsSet("audio_time_left", u ? "1" : "0");
- var c = ge("audio" + audio.getCurrentId());
- g(c, r(audio.position(), audio.duration()));
- b && cancelEvent(b)
- }
- },
- setPosition: function (a, b) {
- z || (z = a, B = !0, e(b))
- },
- setVolume: function (a, b) {
- z || (z = a, t = !0, e(b))
- },
- openPlayer: function (a, b) {
- var c = nav.path,
- d = nav.params,
- e = c + (d ? "?" + d : "") + "#player";
- return nav.al_go(e, null, {
- local: !0,
- target: a,
- nav: {
- push: e,
- path: c,
- params: d,
- hash: "#player"
- },
- no_push: b
- })
- }
- }
- }();
Add Comment
Please, Sign In to add comment