From b6d28c06ecae8fdf92b58d6963955a392cbca9ee Mon Sep 17 00:00:00 2001 From: bylampa <157304712+bylampa@users.noreply.github.com> Date: Fri, 1 Nov 2024 14:39:47 +0300 Subject: [PATCH] Delete app.min.js --- app.min.js | 38952 --------------------------------------------------- 1 file changed, 38952 deletions(-) delete mode 100644 app.min.js diff --git a/app.min.js b/app.min.js deleted file mode 100644 index f143e70..0000000 --- a/app.min.js +++ /dev/null @@ -1,38952 +0,0 @@ -(function () { - 'use strict'; - - if (!Object.assign) { - Object.defineProperty(Object, 'assign', { - enumerable: false, - configurable: true, - writable: true, - value: function value(target, firstSource) { - - if (target === undefined || target === null) { - throw new TypeError('Cannot convert first argument to object'); - } - - var to = Object(target); - - for (var i = 1; i < arguments.length; i++) { - var nextSource = arguments[i]; - - if (nextSource === undefined || nextSource === null) { - continue; - } - - var keysArray = Object.keys(Object(nextSource)); - - for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) { - var nextKey = keysArray[nextIndex]; - var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); - - if (desc !== undefined && desc.enumerable) { - to[nextKey] = nextSource[nextKey]; - } - } - } - - return to; - } - }); - } - - if (!('remove' in Element.prototype)) { - Element.prototype.remove = function () { - if (this.parentNode) this.parentNode.removeChild(this); - }; - } - - if (!('find' in Element.prototype)) { - Element.prototype.find = function (query) { - return this.querySelector(query); - }; - } - - if (!('text' in Element.prototype)) { - Element.prototype.text = function (text) { - this.innerText = text; - return this; - }; - } - - if (!('html' in Element.prototype)) { - Element.prototype.html = function (html) { - if (typeof html == 'string') this.innerHTML = html;else { - this.innerHTML = ''; - this.append(html); - } - return this; - }; - } - - if (!('removeClass' in Element.prototype)) { - Element.prototype.removeClass = function (classes) { - var _this = this; - - classes.split(' ').forEach(function (c) { - _this.classList.remove(c); - }); - return this; - }; - } - - if (!('addClass' in Element.prototype)) { - Element.prototype.addClass = function (classes) { - var _this2 = this; - - classes.split(' ').forEach(function (c) { - _this2.classList.add(c); - }); - return this; - }; - } - - if (!('toggleClass' in Element.prototype)) { - Element.prototype.toggleClass = function (classes, status) { - var _this3 = this; - - classes.split(' ').forEach(function (c) { - var has = _this3.classList.contains(c); - - if (status && !has) _this3.classList.add(c);else if (!status && has) _this3.classList.remove(c); - }); - return this; - }; - } - - if (!('empty' in Element.prototype)) { - Element.prototype.empty = function () { - this.innerHTML = ''; - return this; - }; - } - - if (!('append' in Element.prototype)) { - Element.prototype.append = function (child) { - this.appendChild(child); - return this; - }; - } - - if (!('on' in Element.prototype)) { - Element.prototype.on = function (on, call, options) { - var _this4 = this; - - on.split(' ').forEach(function (e) { - _this4.addEventListener(e, call, options); - }); - return this; - }; - } - - Number.prototype.pad = function (zeros) { - var numberString = String(this); - var zerosToAdd = zeros - numberString.length; - var leadingZeros = ""; - - for (var i = 0; i < zerosToAdd; i++) { - leadingZeros += "0"; - } - - return leadingZeros + numberString; - }; - - if (!Math.trunc) { - Math.trunc = function (v) { - v = +v; - return v - v % 1 || (!isFinite(v) || v === 0 ? v : v < 0 ? -0 : 0); - }; - } - - if (!Array.from) { - Array.from = function () { - var toStr = Object.prototype.toString; - - var isCallable = function isCallable(fn) { - return typeof fn === 'function' || toStr.call(fn) === '[object Function]'; - }; - - var toInteger = function toInteger(value) { - var number = Number(value); - - if (isNaN(number)) { - return 0; - } - - if (number === 0 || !isFinite(number)) { - return number; - } - - return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number)); - }; - - var maxSafeInteger = Math.pow(2, 53) - 1; - - var toLength = function toLength(value) { - var len = toInteger(value); - return Math.min(Math.max(len, 0), maxSafeInteger); - }; // Свойство length метода from равно 1. - - - return function from(arrayLike - /* , mapFn, thisArg */ - ) { - // 1. Положим C равным значению this. - var C = this; // 2. Положим items равным ToObject(arrayLike). - - var items = Object(arrayLike); // 3. ReturnIfAbrupt(items). - - if (arrayLike == null) { - throw new TypeError('Array.from requires an array-like object - not null or undefined'); - } // 4. Если mapfn равен undefined, положим mapping равным false. - - - var mapFn = arguments.length > 1 ? arguments[1] : void undefined; - var T; - - if (typeof mapFn !== 'undefined') { - // 5. иначе - // 5. a. Если вызов IsCallable(mapfn) равен false, выкидываем - // исключение TypeError. - if (!isCallable(mapFn)) { - throw new TypeError('Array.from: when provided, the second argument must be a function'); - } // 5. b. Если thisArg присутствует, положим T равным thisArg; - // иначе положим T равным undefined. - - - if (arguments.length > 2) { - T = arguments[2]; - } - } // 10. Положим lenValue равным Get(items, "length"). - // 11. Положим len равным ToLength(lenValue). - - - var len = toLength(items.length); // 13. Если IsConstructor(C) равен true, то - // 13. a. Положим A равным результату вызова внутреннего метода - // [[Construct]] - // объекта C со списком аргументов, содержащим единственный элемент - // len. - // 14. a. Иначе, положим A равным ArrayCreate(len). - - var A = isCallable(C) ? Object(new C(len)) : new Array(len); // 16. Положим k равным 0. - - var k = 0; // 17. Пока k < len, будем повторять... (шаги с a по h) - - var kValue; - - while (k < len) { - kValue = items[k]; - - if (mapFn) { - A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k); - } else { - A[k] = kValue; - } - - k += 1; - } // 18. Положим putStatus равным Put(A, "length", len, true). - - - A.length = len; // 20. Вернём A. - - return A; - }; - }(); - } // https://tc39.github.io/ecma262/#sec-array.prototype.find - - - if (!Array.prototype.find) { - Object.defineProperty(Array.prototype, 'find', { - value: function value(predicate) { - // 1. Let O be ? ToObject(this value). - if (this == null) { - throw new TypeError('"this" is null or not defined'); - } - - var o = Object(this); // 2. Let len be ? ToLength(? Get(O, "length")). - - var len = o.length >>> 0; // 3. If IsCallable(predicate) is false, throw a TypeError - // exception. - - if (typeof predicate !== 'function') { - throw new TypeError('predicate must be a function'); - } // 4. If thisArg was supplied, let T be thisArg; else let T be - // undefined. - - - var thisArg = arguments[1]; // 5. Let k be 0. - - var k = 0; // 6. Repeat, while k < len - - while (k < len) { - // a. Let Pk be ! ToString(k). - // b. Let kValue be ? Get(O, Pk). - // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, - // k, O »)). - // d. If testResult is true, return kValue. - var kValue = o[k]; - - if (predicate.call(thisArg, kValue, k, o)) { - return kValue; - } // e. Increase k by 1. - - - k++; - } // 7. Return undefined. - - - return undefined; - }, - configurable: true, - writable: true - }); - } // https://tc39.github.io/ecma262/#sec-array.prototype.includes - - - if (!Array.prototype.includes) { - Object.defineProperty(Array.prototype, 'includes', { - value: function value(searchElement, fromIndex) { - if (this == null) { - throw new TypeError('"this" is null or not defined'); - } // 1. Let O be ? ToObject(this value). - - - var o = Object(this); // 2. Let len be ? ToLength(? Get(O, "length")). - - var len = o.length >>> 0; // 3. If len is 0, return false. - - if (len === 0) { - return false; - } // 4. Let n be ? ToInteger(fromIndex). - // (If fromIndex is undefined, this step produces the value 0.) - - - var n = fromIndex | 0; // 5. If n ≥ 0, then - // a. Let k be n. - // 6. Else n < 0, - // a. Let k be len + n. - // b. If k < 0, let k be 0. - - var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); - - function sameValueZero(x, y) { - return x === y || typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y); - } // 7. Repeat, while k < len - - - while (k < len) { - // a. Let elementK be the result of ? Get(O, ! ToString(k)). - // b. If SameValueZero(searchElement, elementK) is true, return - // true. - if (sameValueZero(o[k], searchElement)) { - return true; - } // c. Increase k by 1. - - - k++; - } // 8. Return false - - - return false; - } - }); - } - - if (!String.prototype.includes) { - String.prototype.includes = function (search, start) { - - if (search instanceof RegExp) { - throw TypeError('first argument must not be a RegExp'); - } - - if (start === undefined) { - start = 0; - } - - return this.indexOf(search, start) !== -1; - }; - } - - if (!Object.entries) { - Object.entries = function (obj) { - var ownProps = Object.keys(obj), - i = ownProps.length, - resArray = new Array(i); // preallocate the Array - - while (i--) { - resArray[i] = [ownProps[i], obj[ownProps[i]]]; - } - - return resArray; - }; - } - - if (!Function.prototype.bind) { - Function.prototype.bind = function (oThis) { - if (typeof this !== 'function') { - // ближайший аналог внутренней функции - // IsCallable в ECMAScript 5 - throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable'); - } - - var aArgs = Array.prototype.slice.call(arguments, 1), - fToBind = this, - fNOP = function fNOP() {}, - fBound = function fBound() { - return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); - }; - - fNOP.prototype = this.prototype; - fBound.prototype = new fNOP(); - return fBound; - }; - } - - (function () { - - var _slice = Array.prototype.slice; - - try { - // Не может использоваться с элементами DOM в IE < 9 - _slice.call(document.documentElement); - } catch (e) { - // В IE < 9 кидается исключение - // Функция будет работать для истинных массивов, массивоподобных объектов, - // NamedNodeMap (атрибуты, сущности, примечания), - // NodeList (например, getElementsByTagName), HTMLCollection (например, childNodes) - // и не будет падать на других объектах DOM (как это происходит на элементах DOM в IE < 9) - Array.prototype.slice = function (begin, end) { - // IE < 9 будет недоволен аргументом end, равным undefined - end = typeof end !== 'undefined' ? end : this.length; // Для родных объектов Array мы используем родную функцию slice - - if (Object.prototype.toString.call(this) === '[object Array]') { - return _slice.call(this, begin, end); - } // Массивоподобные объекты мы обрабатываем самостоятельно - - - var i, - cloned = [], - size, - len = this.length; // Обрабатываем отрицательное значение begin - - var start = begin || 0; - start = start >= 0 ? start : len + start; // Обрабатываем отрицательное значение end - - var upTo = end ? end : len; - - if (end < 0) { - upTo = len + end; - } // Фактически ожидаемый размер среза - - - size = upTo - start; - - if (size > 0) { - cloned = new Array(size); - - if (this.charAt) { - for (i = 0; i < size; i++) { - cloned[i] = this.charAt(start + i); - } - } else { - for (i = 0; i < size; i++) { - cloned[i] = this[start + i]; - } - } - } - - return cloned; - }; - } - })(); - /*! - * Shim for MutationObserver interface - * Author: Graeme Yeates (github.com/megawac) - * Repository: https://github.com/megawac/MutationObserver.js - * License: WTFPL V2, 2004 (wtfpl.net). - * Though credit and staring the repo will make me feel pretty, you can modify and redistribute as you please. - * Attempts to follow spec (https://www.w3.org/TR/dom/#mutation-observers) as closely as possible for native javascript - * See https://github.com/WebKit/webkit/blob/master/Source/WebCore/dom/MutationObserver.cpp for current webkit source c++ implementation - */ - - /** - * prefix bugs: - - https://bugs.webkit.org/show_bug.cgi?id=85161 - - https://bugzilla.mozilla.org/show_bug.cgi?id=749920 - * Don't use WebKitMutationObserver as Safari (6.0.5-6.1) use a buggy implementation - */ - - - if (!window.MutationObserver) { - window.MutationObserver = function (undefined$1) { - /** - * @param {function(Array., MutationObserver)} listener - * @constructor - */ - - function MutationObserver(listener) { - /** - * @type {Array.} - * @private - */ - this._watched = []; - /** @private */ - - this._listener = listener; - } - /** - * Start a recursive timeout function to check all items being observed for mutations - * @type {MutationObserver} observer - * @private - */ - - - function startMutationChecker(observer) { - (function check() { - var mutations = observer.takeRecords(); - - if (mutations.length) { - // fire away - // calling the listener with context is not spec but currently consistent with FF and WebKit - observer._listener(mutations, observer); - } - /** @private */ - - - observer._timeout = setTimeout(check, MutationObserver._period); - })(); - } - /** - * Period to check for mutations (~32 times/sec) - * @type {number} - * @expose - */ - - - MutationObserver._period = 30 - /*ms+runtime*/ - ; - /** - * Exposed API - * @expose - * @final - */ - - MutationObserver.prototype = { - /** - * see https://dom.spec.whatwg.org/#dom-mutationobserver-observe - * not going to throw here but going to follow the current spec config sets - * @param {Node|null} $target - * @param {Object|null} config : MutationObserverInit configuration dictionary - * @expose - * @return undefined - */ - observe: function observe($target, config) { - /** - * Using slightly different names so closure can go ham - * @type {!Object} : A custom mutation config - */ - var settings = { - attr: !!(config.attributes || config.attributeFilter || config.attributeOldValue), - // some browsers enforce that subtree must be set with childList, attributes or characterData. - // We don't care as spec doesn't specify this rule. - kids: !!config.childList, - descendents: !!config.subtree, - charData: !!(config.characterData || config.characterDataOldValue) - }; - var watched = this._watched; // remove already observed target element from pool - - for (var i = 0; i < watched.length; i++) { - if (watched[i].tar === $target) watched.splice(i, 1); - } - - if (config.attributeFilter) { - /** - * converts to a {key: true} dict for faster lookup - * @type {Object.} - */ - settings.afilter = reduce(config.attributeFilter, function (a, b) { - a[b] = true; - return a; - }, {}); - } - - watched.push({ - tar: $target, - fn: createMutationSearcher($target, settings) - }); // reconnect if not connected - - if (!this._timeout) { - startMutationChecker(this); - } - }, - - /** - * Finds mutations since last check and empties the "record queue" i.e. mutations will only be found once - * @expose - * @return {Array.} - */ - takeRecords: function takeRecords() { - var mutations = []; - var watched = this._watched; - - for (var i = 0; i < watched.length; i++) { - watched[i].fn(mutations); - } - - return mutations; - }, - - /** - * @expose - * @return undefined - */ - disconnect: function disconnect() { - this._watched = []; // clear the stuff being observed - - clearTimeout(this._timeout); // ready for garbage collection - - /** @private */ - - this._timeout = null; - } - }; - /** - * Simple MutationRecord pseudoclass. No longer exposing as its not fully compliant - * @param {Object} data - * @return {Object} a MutationRecord - */ - - function MutationRecord(data) { - var settings = { - // technically these should be on proto so hasOwnProperty will return false for non explicitly props - type: null, - target: null, - addedNodes: [], - removedNodes: [], - previousSibling: null, - nextSibling: null, - attributeName: null, - attributeNamespace: null, - oldValue: null - }; - - for (var prop in data) { - if (has(settings, prop) && data[prop] !== undefined$1) settings[prop] = data[prop]; - } - - return settings; - } - /** - * Creates a func to find all the mutations - * - * @param {Node} $target - * @param {!Object} config : A custom mutation config - */ - - - function createMutationSearcher($target, config) { - /** type {Elestuct} */ - var $oldstate = clone($target, config); // create the cloned datastructure - - /** - * consumes array of mutations we can push to - * - * @param {Array.} mutations - */ - - return function (mutations) { - var olen = mutations.length, - dirty; - - if (config.charData && $target.nodeType === 3 && $target.nodeValue !== $oldstate.charData) { - mutations.push(new MutationRecord({ - type: "characterData", - target: $target, - oldValue: $oldstate.charData - })); - } // Alright we check base level changes in attributes... easy - - - if (config.attr && $oldstate.attr) { - findAttributeMutations(mutations, $target, $oldstate.attr, config.afilter); - } // check childlist or subtree for mutations - - - if (config.kids || config.descendents) { - dirty = searchSubtree(mutations, $target, $oldstate, config); - } // reclone data structure if theres changes - - - if (dirty || mutations.length !== olen) { - /** type {Elestuct} */ - $oldstate = clone($target, config); - } - }; - } - /* attributes + attributeFilter helpers */ - // Check if the environment has the attribute bug (#4) which cause - // element.attributes.style to always be null. - - - var hasAttributeBug = document.createElement("i"); - hasAttributeBug.style.top = 0; - hasAttributeBug = hasAttributeBug.attributes.style.value != "null"; - /** - * Gets an attribute value in an environment without attribute bug - * - * @param {Node} el - * @param {Attr} attr - * @return {String} an attribute value - */ - - function getAttributeSimple(el, attr) { - // There is a potential for a warning to occur here if the attribute is a - // custom attribute in IE<9 with a custom .toString() method. This is - // just a warning and doesn't affect execution (see #21) - return attr.value; - } - /** - * Gets an attribute value with special hack for style attribute (see #4) - * - * @param {Node} el - * @param {Attr} attr - * @return {String} an attribute value - */ - - - function getAttributeWithStyleHack(el, attr) { - // As with getAttributeSimple there is a potential warning for custom attribtues in IE7. - return attr.name !== "style" ? attr.value : el.style.cssText; - } - - var getAttributeValue = hasAttributeBug ? getAttributeSimple : getAttributeWithStyleHack; - /** - * fast helper to check to see if attributes object of an element has changed - * doesnt handle the textnode case - * - * @param {Array.} mutations - * @param {Node} $target - * @param {Object.} $oldstate : Custom attribute clone data structure from clone - * @param {Object} filter - */ - - function findAttributeMutations(mutations, $target, $oldstate, filter) { - var checked = {}; - var attributes = $target.attributes; - var attr; - var name; - var i = attributes.length; - - while (i--) { - attr = attributes[i]; - name = attr.name; - - if (!filter || has(filter, name)) { - if (getAttributeValue($target, attr) !== $oldstate[name]) { - // The pushing is redundant but gzips very nicely - mutations.push(MutationRecord({ - type: "attributes", - target: $target, - attributeName: name, - oldValue: $oldstate[name], - attributeNamespace: attr.namespaceURI // in ie<8 it incorrectly will return undefined - - })); - } - - checked[name] = true; - } - } - - for (name in $oldstate) { - if (!checked[name]) { - mutations.push(MutationRecord({ - target: $target, - type: "attributes", - attributeName: name, - oldValue: $oldstate[name] - })); - } - } - } - /** - * searchSubtree: array of mutations so far, element, element clone, bool - * synchronous dfs comparision of two nodes - * This function is applied to any observed element with childList or subtree specified - * Sorry this is kind of confusing as shit, tried to comment it a bit... - * codereview.stackexchange.com/questions/38351 discussion of an earlier version of this func - * - * @param {Array} mutations - * @param {Node} $target - * @param {!Object} $oldstate : A custom cloned node from clone() - * @param {!Object} config : A custom mutation config - */ - - - function searchSubtree(mutations, $target, $oldstate, config) { - // Track if the tree is dirty and has to be recomputed (#14). - var dirty; - /* - * Helper to identify node rearrangment and stuff... - * There is no gaurentee that the same node will be identified for both added and removed nodes - * if the positions have been shuffled. - * conflicts array will be emptied by end of operation - */ - - function resolveConflicts(conflicts, node, $kids, $oldkids, numAddedNodes) { - // the distance between the first conflicting node and the last - var distance = conflicts.length - 1; // prevents same conflict being resolved twice consider when two nodes switch places. - // only one should be given a mutation event (note -~ is used as a math.ceil shorthand) - - var counter = -~((distance - numAddedNodes) / 2); - var $cur; - var oldstruct; - var conflict; - - while (conflict = conflicts.pop()) { - $cur = $kids[conflict.i]; - oldstruct = $oldkids[conflict.j]; // attempt to determine if there was node rearrangement... won't gaurentee all matches - // also handles case where added/removed nodes cause nodes to be identified as conflicts - - if (config.kids && counter && Math.abs(conflict.i - conflict.j) >= distance) { - mutations.push(MutationRecord({ - type: "childList", - target: node, - addedNodes: [$cur], - removedNodes: [$cur], - // haha don't rely on this please - nextSibling: $cur.nextSibling, - previousSibling: $cur.previousSibling - })); - counter--; // found conflict - } // Alright we found the resorted nodes now check for other types of mutations - - - if (config.attr && oldstruct.attr) findAttributeMutations(mutations, $cur, oldstruct.attr, config.afilter); - - if (config.charData && $cur.nodeType === 3 && $cur.nodeValue !== oldstruct.charData) { - mutations.push(MutationRecord({ - type: "characterData", - target: $cur, - oldValue: oldstruct.charData - })); - } // now look @ subtree - - - if (config.descendents) findMutations($cur, oldstruct); - } - } - /** - * Main worker. Finds and adds mutations if there are any - * @param {Node} node - * @param {!Object} old : A cloned data structure using internal clone - */ - - - function findMutations(node, old) { - var $kids = node.childNodes; - var $oldkids = old.kids; - var klen = $kids.length; // $oldkids will be undefined for text and comment nodes - - var olen = $oldkids ? $oldkids.length : 0; // if (!olen && !klen) return; // both empty; clearly no changes - // we delay the intialization of these for marginal performance in the expected case (actually quite signficant on large subtrees when these would be otherwise unused) - // map of checked element of ids to prevent registering the same conflict twice - - var map; // array of potential conflicts (ie nodes that may have been re arranged) - - var conflicts; - var id; // element id from getElementId helper - - var idx; // index of a moved or inserted element - - var oldstruct; // current and old nodes - - var $cur; - var $old; // track the number of added nodes so we can resolve conflicts more accurately - - var numAddedNodes = 0; // iterate over both old and current child nodes at the same time - - var i = 0, - j = 0; // while there is still anything left in $kids or $oldkids (same as i < $kids.length || j < $oldkids.length;) - - while (i < klen || j < olen) { - // current and old nodes at the indexs - $cur = $kids[i]; - oldstruct = $oldkids[j]; - $old = oldstruct && oldstruct.node; - - if ($cur === $old) { - // expected case - optimized for this case - // check attributes as specified by config - if (config.attr && oldstruct.attr) - /* oldstruct.attr instead of textnode check */ - findAttributeMutations(mutations, $cur, oldstruct.attr, config.afilter); // check character data if node is a comment or textNode and it's being observed - - if (config.charData && oldstruct.charData !== undefined$1 && $cur.nodeValue !== oldstruct.charData) { - mutations.push(MutationRecord({ - type: "characterData", - target: $cur, - oldValue: oldstruct.charData - })); - } // resolve conflicts; it will be undefined if there are no conflicts - otherwise an array - - - if (conflicts) resolveConflicts(conflicts, node, $kids, $oldkids, numAddedNodes); // recurse on next level of children. Avoids the recursive call when there are no children left to iterate - - if (config.descendents && ($cur.childNodes.length || oldstruct.kids && oldstruct.kids.length)) findMutations($cur, oldstruct); - i++; - j++; - } else { - // (uncommon case) lookahead until they are the same again or the end of children - dirty = true; - - if (!map) { - // delayed initalization (big perf benefit) - map = {}; - conflicts = []; - } - - if ($cur) { - // check id is in the location map otherwise do a indexOf search - if (!map[id = getElementId($cur)]) { - // to prevent double checking - // mark id as found - map[id] = true; // custom indexOf using comparitor checking oldkids[i].node === $cur - - if ((idx = indexOfCustomNode($oldkids, $cur, j)) === -1) { - if (config.kids) { - mutations.push(MutationRecord({ - type: "childList", - target: node, - addedNodes: [$cur], - // $cur is a new node - nextSibling: $cur.nextSibling, - previousSibling: $cur.previousSibling - })); - numAddedNodes++; - } - } else { - conflicts.push({ - // add conflict - i: i, - j: idx - }); - } - } - - i++; - } - - if ($old && // special case: the changes may have been resolved: i and j appear congurent so we can continue using the expected case - $old !== $kids[i]) { - if (!map[id = getElementId($old)]) { - map[id] = true; - - if ((idx = indexOf($kids, $old, i)) === -1) { - if (config.kids) { - mutations.push(MutationRecord({ - type: "childList", - target: old.node, - removedNodes: [$old], - nextSibling: $oldkids[j + 1], - // praise no indexoutofbounds exception - previousSibling: $oldkids[j - 1] - })); - numAddedNodes--; - } - } else { - conflicts.push({ - i: idx, - j: j - }); - } - } - - j++; - } - } // end uncommon case - - } // end loop - // resolve any remaining conflicts - - - if (conflicts) resolveConflicts(conflicts, node, $kids, $oldkids, numAddedNodes); - } - - findMutations($target, $oldstate); - return dirty; - } - /** - * Utility - * Cones a element into a custom data structure designed for comparision. https://gist.github.com/megawac/8201012 - * - * @param {Node} $target - * @param {!Object} config : A custom mutation config - * @return {!Object} : Cloned data structure - */ - - - function clone($target, config) { - var recurse = true; // set true so childList we'll always check the first level - - return function copy($target) { - var elestruct = { - /** @type {Node} */ - node: $target - }; // Store current character data of target text or comment node if the config requests - // those properties to be observed. - - if (config.charData && ($target.nodeType === 3 || $target.nodeType === 8)) { - elestruct.charData = $target.nodeValue; - } // its either a element, comment, doc frag or document node - else { - // Add attr only if subtree is specified or top level and avoid if - // attributes is a document object (#13). - if (config.attr && recurse && $target.nodeType === 1) { - /** - * clone live attribute list to an object structure {name: val} - * @type {Object.} - */ - elestruct.attr = reduce($target.attributes, function (memo, attr) { - if (!config.afilter || config.afilter[attr.name]) { - memo[attr.name] = getAttributeValue($target, attr); - } - - return memo; - }, {}); - } // whether we should iterate the children of $target node - - - if (recurse && (config.kids || config.charData || config.attr && config.descendents)) { - /** @type {Array.} : Array of custom clone */ - elestruct.kids = map($target.childNodes, copy); - } - - recurse = config.descendents; - } - - return elestruct; - }($target); - } - /** - * indexOf an element in a collection of custom nodes - * - * @param {NodeList} set - * @param {!Object} $node : A custom cloned node - * @param {number} idx : index to start the loop - * @return {number} - */ - - - function indexOfCustomNode(set, $node, idx) { - return indexOf(set, $node, idx, JSCompiler_renameProperty("node")); - } // using a non id (eg outerHTML or nodeValue) is extremely naive and will run into issues with nodes that may appear the same like
  • - - - var counter = 1; // don't use 0 as id (falsy) - - /** @const */ - - var expando = "mo_id"; - /** - * Attempt to uniquely id an element for hashing. We could optimize this for legacy browsers but it hopefully wont be called enough to be a concern - * - * @param {Node} $ele - * @return {(string|number)} - */ - - function getElementId($ele) { - try { - return $ele.id || ($ele[expando] = $ele[expando] || counter++); - } catch (o_O) { - // ie <8 will throw if you set an unknown property on a text node - try { - return $ele.nodeValue; // naive - } catch (shitie) { - // when text node is removed: https://gist.github.com/megawac/8355978 :( - return counter++; - } - } - } - /** - * **map** Apply a mapping function to each item of a set - * @param {Array|NodeList} set - * @param {Function} iterator - */ - - - function map(set, iterator) { - var results = []; - - for (var index = 0; index < set.length; index++) { - results[index] = iterator(set[index], index, set); - } - - return results; - } - /** - * **Reduce** builds up a single result from a list of values - * @param {Array|NodeList|NamedNodeMap} set - * @param {Function} iterator - * @param {*} [memo] Initial value of the memo. - */ - - - function reduce(set, iterator, memo) { - for (var index = 0; index < set.length; index++) { - memo = iterator(memo, set[index], index, set); - } - - return memo; - } - /** - * **indexOf** find index of item in collection. - * @param {Array|NodeList} set - * @param {Object} item - * @param {number} idx - * @param {string} [prop] Property on set item to compare to item - */ - - - function indexOf(set, item, idx, prop) { - for (; idx < set.length; idx++) { - // start idx is always given as this is internal - if ((prop ? set[idx][prop] : set[idx]) === item) return idx; - } - - return -1; - } - /** - * @param {Object} obj - * @param {(string|number)} prop - * @return {boolean} - */ - - - function has(obj, prop) { - return obj[prop] !== undefined$1; // will be nicely inlined by gcc - } // GCC hack see https://stackoverflow.com/a/23202438/1517919 - - - function JSCompiler_renameProperty(a) { - return a; - } - - return MutationObserver; - }(void 0); - } - /** - * map-polyfill - A Map polyfill written in TypeScript, unit tested using Jasmine and Karma. - * - * @author Brenden Palmer - * @version v0.0.1-alpha.2 - * @license MIT - */ - - - !function () { - - var t; - !function (t) { - var e = function () { - function t(t, e) { - this.index = 0, this.map = null, this.done = !1, this.map = t, this.type = e; - } - - return t.prototype.next = function () { - var t; - return this.map.keyArray.length > this.index ? ("entries" === this.type ? t = [this.map.keyArray[this.index], this.map.get(this.map.keyArray[this.index])] : "keys" === this.type ? t = this.map.keyArray[this.index] : "values" === this.type && (t = this.map.get(this.map.keyArray[this.index])), this.index++) : this.done = !0, { - value: t, - done: this.done - }; - }, t; - }(); - - t.MapIterator = e; - }(t || (t = {})); - var t; - !function (t) { - var e = function () { - function t() {} - - return Object.defineProperty(t, "MAP_KEY_IDENTIFIER", { - get: function get() { - return "MAP_KEY_IDENTIFIER_OZAbzyeCu3_spF91dwX14"; - }, - enumerable: !0, - configurable: !0 - }), Object.defineProperty(t, "MAP_SET_THROWABLE_MESSAGE", { - get: function get() { - return "Invalid value used as map key"; - }, - enumerable: !0, - configurable: !0 - }), t; - }(); - - t.MapConstants = e; - }(t || (t = {})); - var t; - !function (t) { - var e = function () { - function t() { - if (null !== t.instance) throw "Get the instance of the MapSequencer using the getInstance method."; - this.identifier = 0; - } - - return t.getInstance = function () { - return null === t.instance && (t.instance = new t()), t.instance; - }, t.prototype.next = function () { - return "Map_CJPOYUrpwK_aHBtMHXsTM" + String(this.identifier++); - }, t.instance = null, t; - }(); - - t.MapSequencer = e; - }(t || (t = {})); - var t; - !function (t) { - var e = function () { - function e() {} - - return e.defineProperty = function (n) { - var r; - if (e.isValidObject(n) === !1) throw new TypeError(t.MapConstants.MAP_SET_THROWABLE_MESSAGE); - - if ("undefined" == typeof n[t.MapConstants.MAP_KEY_IDENTIFIER]) { - r = t.MapSequencer.getInstance().next(); - - try { - Object.defineProperty(n, t.MapConstants.MAP_KEY_IDENTIFIER, { - enumerable: !1, - configurable: !1, - get: function get() { - return r; - } - }); - } catch (i) { - throw new TypeError(t.MapConstants.MAP_SET_THROWABLE_MESSAGE); - } - } else r = n[t.MapConstants.MAP_KEY_IDENTIFIER]; - - return r; - }, e.getProperty = function (n) { - return e.isValidObject(n) === !0 ? n[t.MapConstants.MAP_KEY_IDENTIFIER] : void 0; - }, e.isValidObject = function (t) { - return t === Object(t); - }, e; - }(); - - t.MapUtils = e; - }(t || (t = {})); - var t; - !function (t) { - var e = function () { - function e(t) { - void 0 === t && (t = []), this.map = {}, this.keyArray = []; - - for (var e = 0; e < t.length; e++) { - var n = t[e]; - n && n.length >= 2 && this.set(n[0], n[1]); - } - } - - return e.prototype.get = function (e) { - if (this.has(e) === !0) { - var n = t.MapUtils.getProperty(e); - return void 0 === n && (n = String(e)), this.map[n]; - } - }, e.prototype.has = function (e) { - var n = t.MapUtils.getProperty(e); - return void 0 === n && (n = String(e)), void 0 !== n && "undefined" != typeof this.map[n]; - }, e.prototype["delete"] = function (e) { - if (this.has(e) === !0) { - var n = t.MapUtils.getProperty(e); - return void 0 === n && (n = String(e)), this.keyArray.splice(this.keyArray.indexOf(e), 1), delete this.map[n], !0; - } - - return !1; - }, e.prototype.set = function (e, n) { - this["delete"](e); - var r; - - try { - r = String(t.MapUtils.defineProperty(e)); - } catch (i) { - r = String(e); - } - - this.keyArray.push(e), this.map[r] = n; - }, e.prototype.entries = function () { - return new t.MapIterator(this, "entries"); - }, e.prototype.keys = function () { - return new t.MapIterator(this, "keys"); - }, e.prototype.values = function () { - return new t.MapIterator(this, "values"); - }, e.prototype.forEach = function (t, e) { - for (var n = 0, r = this.keyArray; n < r.length; n++) { - var i = r[n]; - e ? t.call(e, this.get(i), i, this) : t(this.get(i), i, this); - } - }, e.prototype.clear = function () { - this.map = {}, this.keyArray = []; - }, e; - }(); - - t.Map = e; - }(t || (t = {})); - var t; - !function (t) { - window.Map || (window.Map = t.Map); - }(t || (t = {})); - }(); - - function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - - if (enumerableOnly) { - symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - }); - } - - keys.push.apply(keys, symbols); - } - - return keys; - } - - function _objectSpread2(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - - if (i % 2) { - ownKeys(Object(source), true).forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } else if (Object.getOwnPropertyDescriptors) { - Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); - } else { - ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); - } - } - - return target; - } - - function _typeof(obj) { - "@babel/helpers - typeof"; - - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof = function (obj) { - return typeof obj; - }; - } else { - _typeof = function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - } - - return _typeof(obj); - } - - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } - - function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - return Constructor; - } - - function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; - } - - function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }); - if (superClass) _setPrototypeOf(subClass, superClass); - } - - function _getPrototypeOf(o) { - _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _getPrototypeOf(o); - } - - function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - - return _setPrototypeOf(o, p); - } - - function _isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; - - try { - Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); - return true; - } catch (e) { - return false; - } - } - - function _assertThisInitialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return self; - } - - function _possibleConstructorReturn(self, call) { - if (call && (typeof call === "object" || typeof call === "function")) { - return call; - } else if (call !== void 0) { - throw new TypeError("Derived constructors may only return object or undefined"); - } - - return _assertThisInitialized(self); - } - - function _createSuper(Derived) { - var hasNativeReflectConstruct = _isNativeReflectConstruct(); - - return function _createSuperInternal() { - var Super = _getPrototypeOf(Derived), - result; - - if (hasNativeReflectConstruct) { - var NewTarget = _getPrototypeOf(this).constructor; - - result = Reflect.construct(Super, arguments, NewTarget); - } else { - result = Super.apply(this, arguments); - } - - return _possibleConstructorReturn(this, result); - }; - } - - function _superPropBase(object, property) { - while (!Object.prototype.hasOwnProperty.call(object, property)) { - object = _getPrototypeOf(object); - if (object === null) break; - } - - return object; - } - - function _get(target, property, receiver) { - if (typeof Reflect !== "undefined" && Reflect.get) { - _get = Reflect.get; - } else { - _get = function _get(target, property, receiver) { - var base = _superPropBase(target, property); - - if (!base) return; - var desc = Object.getOwnPropertyDescriptor(base, property); - - if (desc.get) { - return desc.get.call(receiver); - } - - return desc.value; - }; - } - - return _get(target, property, receiver || target); - } - - function _slicedToArray(arr, i) { - return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); - } - - function _arrayWithHoles(arr) { - if (Array.isArray(arr)) return arr; - } - - function _iterableToArrayLimit(arr, i) { - var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; - - if (_i == null) return; - var _arr = []; - var _n = true; - var _d = false; - - var _s, _e; - - try { - for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { - _arr.push(_s.value); - - if (i && _arr.length === i) break; - } - } catch (err) { - _d = true; - _e = err; - } finally { - try { - if (!_n && _i["return"] != null) _i["return"](); - } finally { - if (_d) throw _e; - } - } - - return _arr; - } - - function _unsupportedIterableToArray(o, minLen) { - if (!o) return; - if (typeof o === "string") return _arrayLikeToArray(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(o); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); - } - - function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) len = arr.length; - - for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; - - return arr2; - } - - function _nonIterableRest() { - throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - - /** - * @this {Promise} - */ - function finallyConstructor(callback) { - var constructor = this.constructor; - return this.then(function (value) { - // @ts-ignore - return constructor.resolve(callback()).then(function () { - return value; - }); - }, function (reason) { - // @ts-ignore - return constructor.resolve(callback()).then(function () { - // @ts-ignore - return constructor.reject(reason); - }); - }); - } - - function allSettled(arr) { - var P = this; - return new P(function (resolve, reject) { - if (!(arr && typeof arr.length !== 'undefined')) { - return reject(new TypeError(_typeof(arr) + ' ' + arr + ' is not iterable(cannot read property Symbol(Symbol.iterator))')); - } - - var args = Array.prototype.slice.call(arr); - if (args.length === 0) return resolve([]); - var remaining = args.length; - - function res(i, val) { - if (val && (_typeof(val) === 'object' || typeof val === 'function')) { - var then = val.then; - - if (typeof then === 'function') { - then.call(val, function (val) { - res(i, val); - }, function (e) { - args[i] = { - status: 'rejected', - reason: e - }; - - if (--remaining === 0) { - resolve(args); - } - }); - return; - } - } - - args[i] = { - status: 'fulfilled', - value: val - }; - - if (--remaining === 0) { - resolve(args); - } - } - - for (var i = 0; i < args.length; i++) { - res(i, args[i]); - } - }); - } - /** - * @constructor - */ - - - function AggregateError(errors, message) { - this.name = 'AggregateError', this.errors = errors; - this.message = message || ''; - } - - AggregateError.prototype = Error.prototype; - - function any$1(arr) { - var P = this; - return new P(function (resolve, reject) { - if (!(arr && typeof arr.length !== 'undefined')) { - return reject(new TypeError('Promise.any accepts an array')); - } - - var args = Array.prototype.slice.call(arr); - if (args.length === 0) return reject(); - var rejectionReasons = []; - - for (var i = 0; i < args.length; i++) { - try { - P.resolve(args[i]).then(resolve)["catch"](function (error) { - rejectionReasons.push(error); - - if (rejectionReasons.length === args.length) { - reject(new AggregateError(rejectionReasons, 'All promises were rejected')); - } - }); - } catch (ex) { - reject(ex); - } - } - }); - } // Store setTimeout reference so promise-polyfill will be unaffected by - // other code modifying setTimeout (like sinon.useFakeTimers()) - - - var setTimeoutFunc = setTimeout; - - function isArray$1(x) { - return Boolean(x && typeof x.length !== 'undefined'); - } - - function noop() {} // Polyfill for Function.prototype.bind - - - function bind$4(fn, thisArg) { - return function () { - fn.apply(thisArg, arguments); - }; - } - /** - * @constructor - * @param {Function} fn - */ - - - function Promise$1(fn) { - if (!(this instanceof Promise$1)) throw new TypeError('Promises must be constructed via new'); - if (typeof fn !== 'function') throw new TypeError('not a function'); - /** @type {!number} */ - - this._state = 0; - /** @type {!boolean} */ - - this._handled = false; - /** @type {Promise|undefined} */ - - this._value = undefined; - /** @type {!Array} */ - - this._deferreds = []; - doResolve(fn, this); - } - - function handle(self, deferred) { - while (self._state === 3) { - self = self._value; - } - - if (self._state === 0) { - self._deferreds.push(deferred); - - return; - } - - self._handled = true; - - Promise$1._immediateFn(function () { - var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected; - - if (cb === null) { - (self._state === 1 ? resolve : reject)(deferred.promise, self._value); - return; - } - - var ret; - - try { - ret = cb(self._value); - } catch (e) { - reject(deferred.promise, e); - return; - } - - resolve(deferred.promise, ret); - }); - } - - function resolve(self, newValue) { - try { - // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure - if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.'); - - if (newValue && (_typeof(newValue) === 'object' || typeof newValue === 'function')) { - var then = newValue.then; - - if (newValue instanceof Promise$1) { - self._state = 3; - self._value = newValue; - finale(self); - return; - } else if (typeof then === 'function') { - doResolve(bind$4(then, newValue), self); - return; - } - } - - self._state = 1; - self._value = newValue; - finale(self); - } catch (e) { - reject(self, e); - } - } - - function reject(self, newValue) { - self._state = 2; - self._value = newValue; - finale(self); - } - - function finale(self) { - if (self._state === 2 && self._deferreds.length === 0) { - Promise$1._immediateFn(function () { - if (!self._handled) { - Promise$1._unhandledRejectionFn(self._value); - } - }); - } - - for (var i = 0, len = self._deferreds.length; i < len; i++) { - handle(self, self._deferreds[i]); - } - - self._deferreds = null; - } - /** - * @constructor - */ - - - function Handler(onFulfilled, onRejected, promise) { - this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; - this.onRejected = typeof onRejected === 'function' ? onRejected : null; - this.promise = promise; - } - /** - * Take a potentially misbehaving resolver function and make sure - * onFulfilled and onRejected are only called once. - * - * Makes no guarantees about asynchrony. - */ - - - function doResolve(fn, self) { - var done = false; - - try { - fn(function (value) { - if (done) return; - done = true; - resolve(self, value); - }, function (reason) { - if (done) return; - done = true; - reject(self, reason); - }); - } catch (ex) { - if (done) return; - done = true; - reject(self, ex); - } - } - - Promise$1.prototype['catch'] = function (onRejected) { - return this.then(null, onRejected); - }; - - Promise$1.prototype.then = function (onFulfilled, onRejected) { - // @ts-ignore - var prom = new this.constructor(noop); - handle(this, new Handler(onFulfilled, onRejected, prom)); - return prom; - }; - - Promise$1.prototype['finally'] = finallyConstructor; - - Promise$1.all = function (arr) { - return new Promise$1(function (resolve, reject) { - if (!isArray$1(arr)) { - return reject(new TypeError('Promise.all accepts an array')); - } - - var args = Array.prototype.slice.call(arr); - if (args.length === 0) return resolve([]); - var remaining = args.length; - - function res(i, val) { - try { - if (val && (_typeof(val) === 'object' || typeof val === 'function')) { - var then = val.then; - - if (typeof then === 'function') { - then.call(val, function (val) { - res(i, val); - }, reject); - return; - } - } - - args[i] = val; - - if (--remaining === 0) { - resolve(args); - } - } catch (ex) { - reject(ex); - } - } - - for (var i = 0; i < args.length; i++) { - res(i, args[i]); - } - }); - }; - - Promise$1.any = any$1; - Promise$1.allSettled = allSettled; - - Promise$1.resolve = function (value) { - if (value && _typeof(value) === 'object' && value.constructor === Promise$1) { - return value; - } - - return new Promise$1(function (resolve) { - resolve(value); - }); - }; - - Promise$1.reject = function (value) { - return new Promise$1(function (resolve, reject) { - reject(value); - }); - }; - - Promise$1.race = function (arr) { - return new Promise$1(function (resolve, reject) { - if (!isArray$1(arr)) { - return reject(new TypeError('Promise.race accepts an array')); - } - - for (var i = 0, len = arr.length; i < len; i++) { - Promise$1.resolve(arr[i]).then(resolve, reject); - } - }); - }; // Use polyfill for setImmediate for performance gains - - - Promise$1._immediateFn = // @ts-ignore - typeof setImmediate === 'function' && function (fn) { - // @ts-ignore - setImmediate(fn); - } || function (fn) { - setTimeoutFunc(fn, 0); - }; - - Promise$1._unhandledRejectionFn = function _unhandledRejectionFn(err) { - if (typeof console !== 'undefined' && console) { - console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console - } - }; - /** @suppress {undefinedVars} */ - - - var globalNS = function () { - // the only reliable means to get the global object is - // `Function('return this')()` - // However, this causes CSP violations in Chrome apps. - if (typeof self !== 'undefined') { - return self; - } - - if (typeof window !== 'undefined') { - return window; - } - - if (typeof global !== 'undefined') { - return global; - } - - throw new Error('unable to locate global object'); - }(); // Expose the polyfill if Promise is undefined or set to a - // non-function value. The latter can be due to a named HTMLElement - // being exposed by browsers for legacy reasons. - // https://github.com/taylorhakes/promise-polyfill/issues/114 - - - if (typeof globalNS['Promise'] !== 'function') { - globalNS['Promise'] = Promise$1; - } else { - if (!globalNS.Promise.prototype['finally']) { - globalNS.Promise.prototype['finally'] = finallyConstructor; - } - - if (!globalNS.Promise.allSettled) { - globalNS.Promise.allSettled = allSettled; - } - - if (!globalNS.Promise.any) { - globalNS.Promise.any = any$1; - } - } - - var object$2 = { - author: 'Yumata', - github: 'https://github.com/yumata/lampa-source', - css_version: '2.9.0', - app_version: '2.1.6', - cub_domain: 'cub.red' - }; - var plugins$1 = []; - Object.defineProperty(object$2, 'app_digital', { - get: function get() { - return parseInt(object$2.app_version.replace(/\./g, '')); - } - }); - Object.defineProperty(object$2, 'css_digital', { - get: function get() { - return parseInt(object$2.css_version.replace(/\./g, '')); - } - }); - Object.defineProperty(object$2, 'plugins', { - get: function get() { - return plugins$1; - }, - set: function set(plugin) { - if (_typeof(plugin) == 'object' && typeof plugin.type == 'string') { - plugins$1.push(plugin); - } - } - }); - - function toObject(a) { - if (Object.prototype.toString.call(a) === '[object Object]') return a;else { - a = {}; - return a; - } - } - - function toArray(a) { - if (Object.prototype.toString.call(a) === '[object Object]') { - var b = []; - - for (var i in a) { - b.push(a[i]); - } - - return b; - } else if (typeof a == 'string' || a == null || typeof a == 'number' || typeof a == 'undefined') return [];else return a; - } - - function decodeJson(string, empty) { - var json = empty || {}; - - if (string) { - try { - json = JSON.parse(string); - } catch (e) {} - } - - return json; - } - - function isObject(a) { - return Object.prototype.toString.call(a) === '[object Object]'; - } - - function isArray(a) { - return Object.prototype.toString.call(a) === '[object Array]'; - } - - function extend(a, b, replase) { - for (var i in b) { - if (_typeof(b[i]) == 'object') { - if (a[i] == undefined) a[i] = Object.prototype.toString.call(b[i]) == '[object Array]' ? [] : {}; - this.extend(a[i], b[i], replase); - } else if (a[i] == undefined || replase) a[i] = b[i]; - } - } - - function empty$1(a, b) { - for (var i in b) { - if (!a[i]) a[i] = b[i]; - } - } - - function getKeys(a, add) { - var k = add || []; - - for (var i in a) { - k.push(i); - } - - return k; - } - - function getValues(a, add) { - var k = add || []; - - for (var i in a) { - k.push(a[i]); - } - - return k; - } - - function remove$4(from, need) { - var inx = from.indexOf(need); - if (inx >= 0) from.splice(inx, 1); - } - - function clone$1(a) { - return JSON.parse(JSON.stringify(a)); - } - - function insert(where, index, item) { - where.splice(index, 0, item); - } - - function destroy$a(arr) { - var call_function = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'destroy'; - var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; - var where = toArray(arr); - - for (var i = where.length - 1; i >= 0; i--) { - if (where[i] && where[i][call_function]) where[i][call_function](value); - } - } - - function groupBy(xs, key) { - return xs.reduce(function (rv, x) { - (rv[x[key]] = rv[x[key]] || []).push(x); - return rv; - }, {}); - } - - function removeNoIncludes(where, items) { - for (var i = where.length - 1; i >= 0; i--) { - if (items.indexOf(where[i]) === -1) remove$4(where, where[i]); - } - - return where; - } - - function shuffle(array) { - for (var i = array.length - 1; i > 0; i--) { - var j = Math.floor(Math.random() * (i + 1)); - var temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } - - return array; - } - - function removeDuplicates(array, key) { - var seen = []; - return array.filter(function (a) { - if (seen.indexOf(a[key]) == -1) { - seen.push(a[key]); - return true; - } else return false; - }); - } - - var Arrays = { - toObject: toObject, - toArray: toArray, - decodeJson: decodeJson, - isObject: isObject, - isArray: isArray, - extend: extend, - getKeys: getKeys, - getValues: getValues, - insert: insert, - clone: clone$1, - remove: remove$4, - destroy: destroy$a, - empty: empty$1, - groupBy: groupBy, - removeNoIncludes: removeNoIncludes, - shuffle: shuffle, - removeDuplicates: removeDuplicates - }; - - function Subscribe() { - this.add = function (type, listener) { - if (this._listeners === undefined) this._listeners = {}; - var listeners = this._listeners; - if (listeners[type] === undefined) listeners[type] = []; - if (listeners[type].indexOf(listener) === -1) listeners[type].push(listener); - return this; - }; - - this.follow = function (type, listener) { - var _this = this; - - type.split(',').forEach(function (name) { - _this.add(name, listener); - }); - return this; - }; - - this.has = function (type, listener) { - if (this._listeners === undefined) return false; - var listeners = this._listeners; - return listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1; - }; - - this.remove = function (type, listener) { - if (this._listeners === undefined) return this; - var listeners = this._listeners; - var listenerArray = listeners[type]; - - if (listenerArray !== undefined) { - var index = listenerArray.indexOf(listener); - - if (index !== -1) { - listenerArray.splice(index, 1); - } - } - - return this; - }; - - this.send = function (type) { - var event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - if (this._listeners === undefined) return this; - var listeners = this._listeners; - var listenerArray = listeners[type]; - - if (listenerArray !== undefined) { - //if(Arrays.isObject(event)) event.target = this - var array = listenerArray.slice(0); - - for (var i = 0, l = array.length; i < l; i++) { - array[i].call(this, event); - } - } - - return this; - }; - - this.destroy = function () { - this._listeners = {}; - }; - } - - function start$8() { - return new Subscribe(); - } - - var html$1Z = "
    \n
    \n
    \n \n
    \n\n
    \n \n \n \n
    \n\n
    \n \n
    \n
    \n \n \n \n \n
    \n\n
    \n \n \n \n \n
    \n\n
    \n \n \n \n \n
    \n\n
    \n \n \n \n
    \n\n
    \n \n \n \n
    \n\n
    \n \n \n \n \n
    \n\n
    \n \n
    \n\n
    \n \n \n \n \n \n \n
    \n
    \n\n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "; - - var html$1Y = "
    \n
    \n
    \n
    "; - - var html$1X = "
    \n\n
    \n
      \n
    • \n
      \n \n \n \n \n
      \n
      #{menu_main}
      \n
    • \n\n
    • \n
      \n \n \n \n
      \n
      #{menu_feed}
      \n
    • \n\n
    • \n
      \n \n \n \n \n \n \n \n \n \n
      \n
      #{menu_movies}
      \n
    • \n\n
    • \n
      \n \n \n \n \n
      \n
      #{menu_tv}
      \n
    • \n\n
    • \n
      \n \n
      \n
      #{title_persons}
      \n
    • \n\n
    • \n
      \n \n \n \n \n \n \n \n
      \n
      #{menu_catalog}
      \n
    • \n
    • \n
      \n \n \n \n \n \n \n \n \n \n
      \n
      #{menu_filter}
      \n
    • \n
    • \n
      \n \n \n \n \n \n
      \n
      #{menu_relises}
      \n
    • \n
    • \n
      \n \n \n \n \n \n \n
      \n
      #{menu_anime}
      \n
    • \n \n
    • \n
      \n \n \n \n
      \n
      #{settings_input_links}
      \n
    • \n\n\n
    • \n
      \n \n \n \n \n \n \n \n
      \n
      #{menu_history}
      \n
    • \n\n
    • \n
      \n \n \n \n \n \n
      \n
      #{title_subscribes}
      \n
    • \n\n
    • \n
      \n \n \n \n \n \n \n \n \n \n \n \n
      \n
      #{menu_timeline}
      \n
    • \n\n
    • \n
      \n \n \n \n \n \n
      \n
      #{menu_torrents}
      \n
    • \n
    \n
    \n\n
    \n\n
    \n
      \n
    • \n
      \n \n \n \n \n
      \n
      #{menu_settings}
      \n
    • \n\n
    • \n
      \n \n \n \n
      \n
      #{menu_about}
      \n
    • \n\n
    • \n
      \n \n \n \n \n \n \n
      \n
      #{menu_console}
      \n
    • \n
    \n
    \n
    "; - - var html$1W = "
    \n
    \n
    "; - - var html$1V = "
    \n
    \n
    \n
    "; - - var html$1U = "
    \n
    \u041E\u0436\u0438\u0434\u0430\u044E
    \n
    \u041D\u0430\u0436\u043C\u0438\u0442\u0435 (\u0432\u043D\u0438\u0437) \u0434\u043B\u044F \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u044F \u0430\u043A\u0442\u0438\u0432\u043D\u043E\u0441\u0442\u0438.
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "; - - var html$1T = "
    \n
    \n
    \n \n
    \n
    \n
    "; - - var html$1S = "
    \n
    \n
    \n
    \n
    #{title_settings}
    \n
    \n
    \n
    \n
    "; - - var html$1R = "
    \n
    \n
    \n \n \n \n \n \n \n
    \n
    #{settings_cub_sync}
    \n
    \n
    \n
    \n \n
    \n
    #{settings_main_interface}
    \n
    \n
    \n
    \n \n
    \n
    #{settings_main_player}
    \n
    \n
    \n
    \n \n
    \n
    #{settings_main_parser}
    \n
    \n
    \n
    \n \n
    \n
    #{settings_main_torrserver}
    \n
    \n
    \n
    \n \n \n \n
    \n
    TMDB
    \n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n
    \n
    #{settings_main_plugins}
    \n
    \n
    \n
    \n \n
    \n
    #{title_parental_control}
    \n
    \n
    \n
    \n \n
    \n
    #{settings_main_rest}
    \n
    \n \n
    "; - - var html$1Q = "
    \n
    \n
    #{settings_interface_lang}
    \n
    \n
    \n\n
    \n
    #{settings_interface_type}
    \n
    \n
    \n\n
    \n
    #{settings_interface_size}
    \n
    \n
    \n\n
    #{settings_interface_background}
    \n\n
    \n
    #{settings_interface_background_use}
    \n
    \n
    \n\n
    \n
    #{settings_interface_background_type}
    \n
    \n
    \n\n
    \n
    #{settings_interface_black_style}
    \n
    \n
    \n\n
    #{title_card}
    \n\n
    \n
    #{settings_interface_card_interfice}
    \n
    \n
    \n\n
    \n
    #{settings_interface_card_poster}
    \n
    \n
    \n\n
    \n
    #{settings_interface_card_cover}
    \n
    \n
    \n\n
    \n
    #{settings_interface_card_reactions}
    \n
    \n
    \n\n
    #{settings_interface_glass}
    \n\n
    \n
    #{settings_interface_glass}
    \n
    \n
    #{settings_interface_glass_descr}
    \n
    \n\n
    \n
    #{settings_interface_glass_opacity}
    \n
    \n
    \n\n
    \n
    #{settings_interface_sound}
    \n\n
    \n
    #{settings_interface_sound_play}
    \n
    \n
    \n\n
    \n
    #{settings_interface_sound_level}
    \n
    \n
    \n
    \n\n
    #{settings_interface_performance}
    \n\n\n
    \n
    #{settings_interface_animation}
    \n
    \n
    #{settings_interface_animation_descr}
    \n
    \n\n
    \n
    #{settings_interface_advanced_animation}
    \n
    \n
    \n\n
    \n
    #{settings_interface_attenuation}
    \n
    \n
    #{settings_interface_attenuation_descr}
    \n
    \n\n
    \n
    #{settings_interface_scroll}
    \n
    \n
    \n\n
    \n
    #{settings_interface_view_card}
    \n
    \n
    #{settings_interface_view_card_descr}
    \n
    \n\n
    \n
    #{settings_interface_hide_outside_the_screen}
    \n
    \n
    #{settings_interface_hide_outside_the_screen_descr}
    \n
    \n
    "; - - var html$1P = "
    \n
    \n
    #{settings_parser_use}
    \n
    \n
    #{settings_parser_use_descr}
    \n
    \n
    \n
    \n
    #{settings_parser_type}
    \n
    \n
    \n\n
    \n
    Jackett
    \n\n
    \n
    #{settings_parser_jackett_link}
    \n
    \n
    #{settings_parser_jackett_link_descr}
    \n
    \n\n
    \n
    #{settings_parser_jackett_key}
    \n
    \n
    #{settings_parser_jackett_key_descr}
    \n
    \n\n
    \n
    #{settings_parser_jackett_interview}
    \n
    \n
    \n
    \n \n
    \n
    Prowlarr
    \n\n
    \n
    #{settings_parser_jackett_link}
    \n
    \n
    #{settings_parser_prowlarr_link_descr}
    \n
    \n\n
    \n
    #{settings_parser_jackett_key}
    \n
    \n
    #{settings_parser_prowlarr_key_descr}
    \n
    \n
    \n\n
    #{more}
    \n\n
    \n
    #{settings_parser_search}
    \n
    \n
    #{settings_parser_search_descr}
    \n
    \n
    \n
    #{settings_parser_timeout_title}
    \n
    \n
    #{settings_parser_timeout_descr}
    \n
    \n
    \n
    #{settings_parser_in_search}
    \n
    \n
    #{settings_parser_in_search_descr}
    \n
    \n
    \n
    "; - - var html$1O = "
    \n
    \n
    #{settings_server_client}
    \n
    \n
    #{settings_server_client_descr}
    \n
    \n\n
    \n
    \n
    #{settings_server_link}
    \n
    \n
    \n\n
    #{settings_server_links}
    \n\n
    \n
    #{settings_server_link_one}
    \n
    \n
    #{settings_server_link_one_descr}
    \n
    \n
    \n\n
    \n
    #{settings_server_link_two}
    \n
    \n
    #{settings_server_link_two_descr}
    \n
    \n
    \n \n \n
    #{settings_server_additionally}
    \n\n
    \n
    #{settings_server_base}
    \n
    \n
    #{settings_server_base_descr}
    \n
    \n \n
    \n
    #{settings_server_preload}
    \n
    \n
    #{settings_server_preload_descr}
    \n
    \n\n
    #{settings_server_auth}
    \n\n
    \n
    #{settings_server_password_use}
    \n
    \n
    \n \n
    \n
    \n
    #{settings_server_login}
    \n
    \n
    \n\n
    \n
    #{settings_server_password}
    \n
    \n
    \n
    \n
    \n
    "; - - var html$1N = "
    \n
    \n
    #{settings_player_type}
    \n
    \n
    #{settings_player_type_descr}
    \n
    \n\n
    \n
    #{settings_player_iptv_type}
    \n
    \n
    #{settings_player_iptv_type_descr}
    \n
    \n\n
    \n
    #{settings_player_torrent_type}
    \n
    \n
    #{settings_player_torrent_type_descr}
    \n
    \n\n
    \n
    #{settings_player_launch_trailers}
    \n
    \n
    \n \n
    \n
    #{settings_player_reset}
    \n
    \n
    #{settings_player_reset_descr}
    \n
    \n\n
    \n
    #{settings_player_path}
    \n
    \n
    #{settings_player_path_descr}
    \n
    \n\n
    \n
    #{settings_player_normalization}
    \n
    \n
    #{settings_player_normalization_descr}
    \n
    \n \n
    \n
    #{settings_player_next_episode}
    \n
    \n
    #{settings_player_next_episode_descr}
    \n
    \n\n
    \n
    #{settings_player_timecode}
    \n
    \n
    #{settings_player_timecode_descr}
    \n
    \n\n
    \n
    #{settings_player_scale}
    \n
    \n
    #{settings_player_scale_descr}
    \n
    \n\n
    \n
    #{settings_player_hls_title}
    \n
    \n
    #{settings_player_hls_descr}
    \n
    \n\n
    \n
    #{settings_player_rewind_title}
    \n
    \n
    #{settings_player_rewind_descr}
    \n
    \n \n
    \n
    #{settings_player_subs}
    \n\n
    \n
    #{settings_player_subs_use}
    \n
    \n
    #{settings_player_subs_use_descr}
    \n
    \n\n
    \n
    #{settings_player_subs_size}
    \n
    \n
    #{settings_player_subs_size_descr}
    \n
    \n \n
    \n
    #{settings_player_subs_stroke_use}
    \n
    \n
    #{settings_player_subs_stroke_use_descr}
    \n
    \n \n
    \n
    #{settings_player_subs_backdrop_use}
    \n
    \n
    #{settings_player_subs_backdrop_use_descr}
    \n
    \n
    \n\n
    #{more}
    \n\n
    \n
    #{settings_player_quality}
    \n
    \n
    #{settings_player_quality_descr}
    \n
    \n
    "; - - var html$1M = "
    \n
    \n
    #{settings_rest_start}
    \n
    \n
    #{settings_rest_start_descr}
    \n
    \n\n
    \n
    #{settings_rest_source_use}
    \n
    \n
    #{settings_rest_source_descr}
    \n
    \n\n
    \n
    #{settings_rest_protocol_use}
    \n
    \n
    #{settings_rest_protocol_descr}
    \n
    \n\n
    \n
    #{settings_rest_cache_images}
    \n
    \n
    #{settings_rest_cache_images_descr}
    \n
    \n\n
    #{settings_rest_screensaver}
    \n\n
    \n
    #{settings_rest_screensaver_use}
    \n
    \n
    \n\n
    \n
    #{settings_rest_screensaver_type}
    \n
    \n
    \n\n
    \n
    #{settings_rest_screensaver_time}
    \n
    \n
    \n\n
    #{settings_rest_helper}
    \n\n
    \n
    #{settings_rest_helper_use}
    \n
    \n
    \n\n
    \n
    #{settings_rest_helper_reset}
    \n
    \n \n
    #{more}
    \n\n
    \n
    #{settings_rest_pages}
    \n
    \n
    #{settings_rest_pages_descr}
    \n
    \n\n
    \n
    #{settings_rest_time}
    \n
    \n
    \n\n
    \n
    #{settings_rest_navigation}
    \n
    \n
    \n\n
    \n
    #{settings_rest_keyboard}
    \n
    \n
    \n\n\n
    \n
    #{settings_rest_card_quality}
    \n
    \n
    #{settings_rest_card_quality_descr}
    \n
    \n\n
    \n
    #{settings_rest_card_episodes}
    \n
    \n
    #{settings_rest_card_episodes_descr}
    \n
    \n\n
    \n
    #{settings_rest_device}
    \n
    \n
    \n\n
    \n
    #{settings_rest_cache}
    \n
    #{title_left} - #{player_unknown}
    \n
    \n
    "; - - var html$1L = "
    \n
    \n
    TMDB
    \n
    \n
    #{settings_rest_tmdb_lang}
    \n
    \n\n
    \n
    #{settings_rest_tmdb_posters}
    \n
    \n
    \n\n
    \n
    #{settings_rest_tmdb_prox_auto}
    \n
    \n
    \n\n
    \n
    #{settings_rest_tmdb_prox}
    \n
    \n
    \n\n
    \n
    Api
    \n
    \n
    #{settings_rest_tmdb_api_descr}
    \n
    \n\n
    \n
    Image
    \n
    \n
    #{settings_rest_tmdb_image_descr}
    \n
    \n
    "; - - var html$1K = "
    \n
    \n
    #{settings_plugins_add}
    \n
    #{settings_plugins_add_descr}
    \n
    \n
    \n
    #{settings_plugins_install}
    \n
    #{settings_plugins_install_descr}
    \n
    \n
    "; - - var html$1J = "
    \n
    \n
    \u0421\u0438\u043D\u0445\u0440\u043E\u043D\u0438\u0437\u0430\u0446\u0438\u044F
    \n
    \n
    \u0421\u0438\u043D\u0445\u0440\u043E\u043D\u0438\u0437\u0430\u0446\u0438\u044F \u0434\u0430\u0451\u0442 \u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E\u0441\u0442\u044C \u0441\u0438\u043D\u0445\u0440\u043E\u043D\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0432\u0430\u0448\u0438 \u0437\u0430\u043A\u043B\u0430\u0434\u043A\u0438, \u0438\u0441\u0442\u043E\u0440\u0438\u044E \u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u043E\u0432, \u043C\u0435\u0442\u043A\u0438 \u0438 \u0442\u0430\u0439\u043C-\u043A\u043E\u0434\u044B. \u0418\u043D\u0441\u0442\u0440\u0443\u043A\u0446\u0438\u044F \u043F\u043E \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u044E https://github.com/yumata/lampa/wiki
    \n
    \n\n
    \u0410\u0432\u0442\u043E\u0440\u0438\u0437\u0430\u0446\u0438\u044F
    \n\n
    \n
    Token
    \n
    \n
    \n\n
    \u0421\u0442\u0430\u0442\u0443\u0441
    \n\n
    \n
    \n
    \n
    \n
    "; - - var html$1I = "
    \n
    \n
    #{settings_cub_sync}
    \n
    \n
    #{settings_cub_sync_descr}
    \n
    \n\n
    #{settings_cub_account} Premium
    \n\n
    \n
    #{settings_cub_logged_in_as}
    \n
    \n
    \n\n
    \n
    #{settings_cub_profile}
    \n
    \n
    \n\n
    \n
    #{settings_cub_logout}
    \n
    \n\n
    #{settings_cub_signin}
    \n\n
    \n
    #{settings_cub_signin_button}
    \n
    \n
    \n\n
    #{settings_cub_status}
    \n\n
    \n
    \n
    \n
    \n\n
    #{more}
    \n\n
    \n
    #{settings_cub_sync_btn}
    \n
    #{settings_cub_sync_btn_descr}
    \n
    \n\n
    \n
    #{settings_cub_backup}
    \n
    #{settings_cub_backup_descr}
    \n
    \n\n
    CUB Premium
    \n\n
    \n
    #{settings_cub_sync_filters}
    \n
    \n
    \n
    \n
    #{settings_cub_sync_calendar}
    \n
    \n
    \n
    \n
    #{settings_cub_sync_timecodes}
    \n
    \n
    \n
    \n
    #{settings_cub_sync_search}
    \n
    \n
    \n
    "; - - var html$1H = "
    \n
    \n
    {title}
    \n
    \n
    \n
    "; - - var html$1G = "
    \n
    \n \n\n
    \n
    \n \n
    \n
    \n
    \n\n
    {title}
    \n
    {release_year}
    \n
    "; - - var html$1F = "
    \n
    {Title}
    \n\n
    \n
    \n
    #{torrent_item_seeds}: {Seeders}
    \n
    #{torrent_item_grabs}: {Peers}
    \n
    \n
    {size}
    \n
    \n
    "; - - var html$1E = "
    \n
    \n
    \n
    \n
    "; - - var html$1D = "
    \n
    \n
    \n
    \n \n
    \n\n
    \n
    {num}
    \n
    {name}
    \n
    {date}
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n\n
    \n
    {title}
    \n
    {release_year}
    \n
    \n
    \n
    "; - - var html$1C = "
    \n\n
    \n
    \n
    \n \n
    \n
    \n\n
    \n
    \n
    {rating}
    TMDB
    \n\n
    IMDB
    \n
    KP
    \n\n
    \n
    \n\n
    {title}
    \n
    {original_title}
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    {countries}
    \n
    \n
    \n
    {genres}
    \n
    \n
    \n
    {time}
    \n
    \n
    \n
    {seasons}
    \n
    \n
    \n
    {episodes}
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n
    #{reactions_none}
    \n
    \n\n \n
    \n
    \n\n
    \n
    \n\n
    \n
    \n \n \n \n\n #{full_torrents}\n
    \n\n
    \n \n \n \n\n #{full_trailers}\n
    \n\n
    \n \n \n \n\n
    \n\n
    \n \n \n \n \n\n
    \n\n
    \n \n \n \n \n\n
    \n
    \n
    \n
    "; - - var html$1B = "
    \n\n
    \n
    \n
    \n \n
    \n
    \n\n
    \n
    \n
    {title}
    \n
    {tagline}
    \n
    \n
    {rating}
    TMDB
    \n
    IMDB
    \n
    KP
    \n\n
    \n
    \n
    \n
    \n
    \n
    #{reactions_none}
    \n
    \n\n
    \n
    \n \n \n \n \n\n #{title_watch}\n
    \n\n
    \n \n \n \n\n #{settings_input_links}\n
    \n\n
    \n \n \n \n \n\n #{title_reactions}\n
    \n\n
    \n \n \n \n \n\n #{title_subscribe}\n
    \n
    \n
    \n
    \n\n
    \n
    \n \n \n \n\n #{full_torrents}\n
    \n\n
    \n \n \n \n\n #{full_trailers}\n
    \n
    \n
    "; - - var html$1A = "
    \n
    \n
    {text}
    \n\n
    \n
    \n
    #{full_date_of_release}
    \n
    {relise}
    \n
    \n\n
    \n
    #{full_budget}
    \n
    {budget}
    \n
    \n\n
    \n
    #{full_countries}
    \n
    {countries}
    \n
    \n
    \n\n
    \n
    \n\n \n
    "; - - var html$1z = "
    \n
    \n \n
    \n\n
    \n
    {name}
    \n
    {role}
    \n
    \n
    "; - - var html$1y = "
    \n
    {text}
    \n\n
    #{full_like}: {like_count}
    \n
    "; - - var html$1x = "
    \n
    \n \n
    \n\n
    \n
    {num}
    \n
    {name}
    \n
    {date}
    \n
    \n
    "; - - var html$1w = "
    \n \n
    "; - - var html$1v = "
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n
    \n \n \n \n
    \n
    001
    \n
    \n \n \n \n
    \n
    \n
    \n\n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n \n \n \n \n
    \n
    \n \n \n \n \n
    \n\n
    \n
    \n
    \n
    \n \n \n \n \n
    \n
    \n \n \n \n \n \n
    \n
    \n \n \n \n \n
    \n
    \n
    \n \n \n \n
    \n
    \n \n \n \n \n
    \n
    \n
    \n \n \n \n \n
    \n
    \n \n \n \n \n \n
    \n
    \n \n \n \n \n
    \n
    \n
    \n
    auto
    \n
    \n \n \n \n \n \n
    \n
    \n \n \n \n
    \n
    \n \n \n \n \n \n
    \n
    \n \n \n \n \n \n \n
    \n
    \n \n \n \n \n
    \n \n
    \n
    \n
    \n \n \n \n \n
    \n
    \n \n \n \n \n \n \n
    \n
    \n
    \n
    \n
    "; - - var html$1u = "
    \n
    \n
    \n
    \n \n \n \n \n
    \n
    \n \u25C0\u25C0\u25C0\n
    \n
    \n \u25B6\u25B6\u25B6\n
    \n
    \n
    \n
    \n
    "; - - var html$1t = "
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n
    \n #{loading}...\n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n\n
    \n
    \n
    "; - - var html$1s = "
    \n \n
    "; - - var html$1r = ""; - - var html$1q = "
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "; - - var html$1p = "
    \n
    {title}
    \n
    {subtitle}
    \n
    "; - - var html$1o = "
    \n
    {icon}
    \n
    \n
    {title}
    \n
    {subtitle}
    \n
    \n
    "; - - var html$1n = "
    \n
    \n
    \n
    \n
    \n \n \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "; - - var html$1m = "
    \n
    \n \n \n \n \n
    \n
    \n
    \n #{filter_sorted}
    \n
    \n\n
    \n #{filter_filtred}
    \n
    \n
    "; - - var html$1l = "
    \n
    \n
    \n #{more}\n
    \n
    \n
    "; - - var html$1k = "
    \n
    #{search_input}...
    \n
    \n
    \n
    \n
    \n
    "; - - var html$1j = "
    \n
    \n
    \n\n
    \n\n
    #{settings_input_links}
    \n
    \n
    "; - - var html$1i = "
    \n
    \n
    \n
    {title}
    \n
    \n
    \n \n
    \n
    \n
    "; - - var html$1h = "
    \n
    \n
    \n \n
    \n
    \n\n
    \n
    {name}
    \n
    {place}
    \n
    \n
    "; - - var html$1g = "
    \n \n
    "; - - var html$1f = "
    \n
    \n
    {text}
    \n
    "; - - var html$1e = "
    \n\n
    \n
    \n
    \n \n
    \n
    \n\n
    \n
    \n
    \n
    {birthday}
    \n
    \n
    \n \n
    {name}
    \n
    {place}
    \n\n
    \n
    \n \n \n \n
    \n\n
    \n \n \n \n \n\n \n
    \n
    \n
    \n
    \n
    "; - - var html$1d = "
    \n
    \n
    {title}
    \n
    {descr}
    \n
    "; - - var html$1c = "
    \n
    #{empty_title}
    \n
    #{empty_text}
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "; - - var html$1b = "
    \n
    \n
    {title}
    \n
    {time}
    \n
    \n \n
    {descr}
    \n
    "; - - var html$1a = "
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    {title}
    \n
    {time}
    \n
    \n \n
    {descr}
    \n
    \n
    "; - - var html$19 = "
    \n
    {title}
    \n
    \n
    \n
    {date}
    \n
    {tracker}
    \n\n
    #{torrent_item_bitrate}: {bitrate} #{torrent_item_mb}
    \n
    #{torrent_item_seeds}: {seeds}
    \n
    #{torrent_item_grabs}: {grabs}
    \n \n
    {size}
    \n
    \n
    "; - - var html$18 = "
    \n
    {title}.{exe}
    \n
    {size}
    \n
    "; - - var html$17 = "
    \n
    \n
    \n \n
    \n\n
    \n
    {title}
    \n
    {original_title}
    \n
    \n
    \n
    \n \n
    \n
    "; - - var html$16 = "
    \n
    #{about_text}
    \n\n\n
    \n
    \n
    \n #{about_channel}
    \n @lampa_plugins_uncensored\n
    \n\n
    \n #{about_version}
    \n \n
    \n\n
    \n #{about_version} Android APK
    \n \n
    \n
    \n
    \n\n
    \n

    #{termsofuse_t_01}

    \n\n

    #{termsofuse_t_02}

    \n\n
      \n
    1. \n
      #{termsofuse_t_03}
      \n\n
        \n
      1. #{termsofuse_t_04}

      2. \n\n
      3. #{termsofuse_t_05}

      4. \n\n
      5. #{termsofuse_t_06}

      6. \n\n
      7. #{termsofuse_t_07}

      8. \n
      \n \n
    2. \n\n
    3. \n
      #{termsofuse_t_08}
      \n\n
        \n
      1. #{termsofuse_t_09}

      2. \n
      3. #{termsofuse_t_10}

      4. \n
      \n
    4. \n\n
    5. \n
      #{termsofuse_t_11}
      \n\n
        \n
      1. #{termsofuse_t_12}

      2. \n
      3. #{termsofuse_t_13}

      4. \n
      \n
    6. \n
    \n
    \n
    "; - - var html$15 = "
    \n
    \n
    \n
    {title}
    \n
    {text}
    \n
    \n
    "; - - var html$14 = "
    \n
    \n \"\"\n
    \n
    \n
    \n
    \n
    {title}
    \n
    {time}
    \n
    \n\n
    \n\n
    \n
    {info}
    \n
    {quality}
    \n
    \n
    \n
    "; - - var html$13 = "
    \n \n \n \n {rate}\n
    "; - - var html$12 = "
    \n
    {name}
    \n
    {head}
    \n
    {overview}
    \n
    "; - - var html$11 = "
    \n
    \n
    \n
    {title}
    \n
    {text}
    \n
    \n
    \n\n
    \n
    \n
    \u041F\u0440\u0438\u0447\u0438\u043D\u044B
    \n
      \n
    • \u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u0442\u0441\u044F \u0430\u0434\u0440\u0435\u0441: {ip}
    • \n
    • \u0422\u0435\u043A\u0443\u0449\u0438\u0439 \u0430\u0434\u0440\u0435\u0441 {ip} \u044F\u0432\u043B\u044F\u0435\u0442\u0441\u044F \u043D\u0435\u0432\u0435\u0440\u043D\u044B\u043C!
    • \n
    • \u0422\u0435\u043A\u0443\u0449\u0438\u0439 \u043E\u0442\u0432\u0435\u0442: {echo}
    • \n
    \n
    \n\n
    \n
    \u041A\u0430\u043A \u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u043E?
    \n
      \n
    • \u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 \u0430\u0434\u0440\u0435\u0441: 192.168.0.\u0445\u0445\u0445:8090
    • \n
    • \u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 \u0432\u0435\u0440\u0441\u0438\u044E Matrix
    • \n
    \n
    \n\n
    \n
    \u041A\u0430\u043A \u043F\u0440\u043E\u0432\u0435\u0440\u0438\u0442\u044C?
    \n
      \n
    • \u041D\u0430 \u044D\u0442\u043E\u043C \u0436\u0435 \u0443\u0441\u0442\u0440\u043E\u0439\u0441\u0442\u0432\u0435, \u043E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0438 \u0437\u0430\u0439\u0434\u0438\u0442\u0435 \u043F\u043E \u0430\u0434\u0440\u0435\u0441\u0443 {ip}/echo
    • \n
    • \u0415\u0441\u043B\u0438 \u0436\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043D\u0435 \u043E\u0442\u0432\u0435\u0442\u0438\u0442, \u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u043B\u0438 TorrServe, \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0435\u0433\u043E.
    • \n
    • \u0415\u0441\u043B\u0438 \u0436\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043E\u0442\u0432\u0435\u0442\u0438\u043B, \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044C \u0447\u0442\u043E \u0432 \u043E\u0442\u0432\u0435\u0442\u0435 \u0435\u0441\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0430 MatriX
    • \n
    \n
    \n
    "; - - var html$10 = "
    \n
    \n
    \n
    {title}
    \n
    {text}
    \n
    \n
    \n\n
    \n
    \n
    \u041F\u0440\u0438\u0447\u0438\u043D\u044B
    \n
      \n
    • \u0417\u0430\u043F\u0440\u043E\u0441 \u043D\u0430 \u043F\u0438\u043D\u0433 \u0432\u0435\u0440\u043D\u0443\u043B \u043D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0444\u043E\u0440\u043C\u0430\u0442
    • \n
    • \u041E\u0442\u0432\u0435\u0442 \u043E\u0442 TorServer: {echo}
    • \n
    \n
    \n\n
    \n
    \u0427\u0442\u043E \u0434\u0435\u043B\u0430\u0442\u044C?
    \n
      \n
    • \u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044C \u0447\u0442\u043E \u0443 \u0432\u0430\u0441 \u0441\u0442\u043E\u0438\u0442 \u0432\u0435\u0440\u0441\u0438\u044F Matrix
    • \n
    \n
    \n\n
    \n
    \u041A\u0430\u043A \u043F\u0440\u043E\u0432\u0435\u0440\u0438\u0442\u044C?
    \n
      \n
    • \u041E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0438 \u0437\u0430\u0439\u0434\u0438\u0442\u0435 \u043F\u043E \u0430\u0434\u0440\u0435\u0441\u0443 {ip}/echo
    • \n
    • \u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044C \u0447\u0442\u043E \u0432 \u043E\u0442\u0432\u0435\u0442\u0435 \u0435\u0441\u0442\u044C \u043D\u0430\u043B\u0438\u0447\u0438\u0435 \u043A\u043E\u0434\u0430 MatriX
    • \n
    \n
    \n
    "; - - var html$$ = "
    \n
    \n
    \n
    {title}
    \n
    {text}
    \n
    \n
    \n\n
    \n
    \n
    #{torent_nohash_reasons}
    \n
      \n
    • #{torent_nohash_reason_one}
    • \n
    • #{torent_nohash_reason_two}: {echo}
    • \n
    • #{torent_nohash_reason_three}: {url}
    • \n
    \n
    \n\n
    \n
    #{torent_nohash_do}
    \n
      \n
    • #{torent_nohash_do_one}
    • \n
    • #{torent_nohash_do_two}
    • \n
    • #{torent_nohash_do_three}
    • \n
    \n
    \n\n
    \n
    #{torent_nohash_do}
    \n
      \n
    • #{torent_nohash_do_four}
    • \n
    • #{torent_nohash_do_five}
    • \n
    \n
    \n
    "; - - var html$_ = "
    \n
    \n \n
    \n
    \n
    #{torrent_install_need}
    \n
    #{torrent_install_text}
    \n \n
    #{torrent_install_contact}
    \n\n
    \n
    \n
    LG - Samsung
    \n
    @lampa_group
    \n
    \n\n
    \n
    Android
    \n
    @lampa_android
    \n
    \n
    \n
    \n
    "; - - var html$Z = "
    \n
    #{torrent_error_text}
    \n\n
    \n
    \n
    \n
    \n\n
    \n
    \n
      \n
    • #{torrent_error_step_1}
    • \n
    • #{torrent_error_step_2}
    • \n
    • #{torrent_error_step_3}
    • \n
    • #{torrent_error_step_4}
    • \n
    • #{torrent_error_step_5}
    • \n
    • #{torrent_error_step_6}
    • \n
    \n
    \n\n
    \n
    #{torrent_error_info_1}
    \n
    #{torrent_error_info_2}
    \n
    #{torrent_error_info_3}
    \n
    #{torrent_error_info_4}
    \n
    #{torrent_error_info_5}
    \n
    #{torrent_error_info_6}
    \n
    #{torrent_error_info_7}
    \n
    \n
    \n\n
    \n
    #{torrent_error_start}
    \n
    \n
    "; - - var html$Y = "
    \n \n
    \n
    \n
    {fname}
    \n
    #{torrent_serial_season} - {season}#{torrent_serial_date} - {air_date}
    \n
    \n
    \n
    {size}
    \n
    .{exe}
    \n
    \n
    \n
    \n
    {episode}
    \n
    "; - - var html$X = "
    \n
    \n
    \n
    "; - - var html$W = "
    \n
    \n
    \n
    "; - - var html$V = "\n\n\n\n"; - - var html$U = "\n\n\n\n\n"; - - var html$T = "\n\n"; - - var html$S = "\n\n\n\n"; - - var html$R = "
    \n
    \n
    "; - - var html$Q = "\n#{time_viewed} - {time} / {percent} #{time_from} {duration}\n"; - - var html$P = "
    \n
    #{empty_title}
    \n
    #{empty_text}
    \n
    "; - - var html$O = "
    \n
    \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    "; - - var html$N = "
    \n\n
    \n
    #{plugins_catalog_work}
    \n
    #{plugins_catalog_work_descr}
    \n
    \n \n
    \n
    \n\n
    \n
    #{plugins_catalog_popular}
    \n
    #{plugins_catalog_popular_descr}
    \n
    \n \n
    \n
    \n
    "; - - var html$M = "
    \n
    {text}
    \n\n
    \n\n
    \n \n
    \n
    "; - - var html$L = "
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    "; - - var html$K = "
    \n
    \n
    "; - - var html$J = "
    \n
    \n
    {title}
    \n
    \n
    \n
    "; - - var html$I = "
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n
    \n
    \n
    \n
    #{player_disabled}
    \n
    \n
    "; - - var html$H = "
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    #{player_disabled}
    \n
    \n
    \n
    "; - - var html$G = "
    \n
    \n
    \n\n
    \n
    "; - - var html$F = "
    \n
    \n \n
    \n
    \n
    \n
    \n
    "; - - var html$E = "
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    "; - - var html$D = "
    \n
    \n \n
    \n
    "; - - var html$C = "
    \n
    \n \n \n \n \n
    \n\n
    \n #{account_create}\n
    \n
    "; - - var html$B = "
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n\n
    \n #{account_limited}\n
    \n
    "; - - var html$A = "
    \n
    CUB Premium
    \n
    \n #{account_premium}\n
    \n
    #{account_premium_more}
    \n
    www.cub.red/premium
    \n
    "; - - var html$z = "
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n CUB Premium\n
    \n
    \n #{account_premium}\n
    \n
    \n
    \n
    #{account_premium_include_1}#{account_premium_include_text_1}
    \n
    #{filter_rating_from} 360 #{filter_rating_to} 5 040
    \n
    \n
    \n
    #{account_premium_include_2}#{account_premium_include_text_2}
    \n
    #{filter_rating_from} 100 #{filter_rating_to} 500
    \n
    \n
    \n
    #{account_premium_include_3}#{account_premium_include_text_3}
    \n
    #{filter_rating_from} 1 000 #{filter_rating_to} 10 000
    \n
    \n
    \n
    #{account_premium_include_4}#{account_premium_include_text_4}
    \n
    #{filter_rating_from} 3 #{filter_rating_to} 8
    \n
    \n
    \n
    #{account_premium_include_5}#{account_premium_include_text_5}
    \n
    \n
    \n
    \n
    #{account_premium_include_6}#{account_premium_include_text_6}
    \n
    \n
    \n
    \n
    #{account_premium_more}
    \n
    www.cub.red/premium
    \n
    "; - - var html$y = "
    \n
    \n
    \n
    \n
    \n
    \n \"\"\n
    \n
    \n
    \n
    \n
    \n \n \n \n \n
    \n
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    "; - - var html$x = "
    \n \n \n \n \n \n \n
    "; - - var html$w = "
    \n
    \n \n \n \n \n \n \n \n \n \n
    \n
    \n #{https_text}\n
    \n
    "; - - var html$v = "
    \n
    \n
    \n
    \n \n \n \n
    \n
    #{back}
    \n
    \n\n
    \n
    \n \n \n \n
    \n
    #{title_main}
    \n
    \n\n
    \n
    \n \n \n \n \n
    \n
    #{search}
    \n
    \n\n
    \n
    \n \n \n \n \n
    \n
    #{menu_settings}
    \n
    \n
    \n
    "; - - var html$u = "
    \n
    \n \n \n \n
    \n
    {title}
    \n
    "; - - var html$t = "
    \n \n\n
    \n #{account_code_where}\n
    \n\n
    #{account_code_input}
    \n
    "; - - var html$s = "
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n\n
    \n
    \n \n
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    "; - - var html$r = "
    \n
    \n \n
    \n\n
    \n
    \n
    \n
    \n
    "; - - var html$q = "
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n\n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n
    "; - - var html$p = "
    \n
    \n
    \n
    "; - - var html$o = "
    \n
    \n \n \n \n \n \n \n \n \n\n \n 0\n \n \n 5\n \n \n 10\n \n \n 15\n \n \n 20\n \n \n 30\n \n \n 60\n \n \n 100\n \n \n 200\n \n \n 500\n \n \n 0.000\n Mbps\n \n \n\n \n \n \n
    \n
    "; - - var html$n = "
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n
    "; - - var html$m = "
    \n \n\n
    \n
    \n\n
    \n \n \n \n \n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n\n
    \n
    "; - - var html$l = "
    \n
    \n
    \n #{discuss_rules_title}\n
    \n\n
    \n
    #{discuss_rules_rule_1}
    \n
    #{discuss_rules_rule_2}
    \n
    #{discuss_rules_rule_3}
    \n
    #{discuss_rules_rule_4}
    \n
    #{discuss_rules_rule_5}
    \n
    #{discuss_rules_rule_6}
    \n
    #{discuss_rules_rule_7}
    \n
    \n
    \n
    "; - - var templates = { - head: html$1Z, - wrap: html$1Y, - menu: html$1X, - activitys: html$1W, - activity: html$1V, - activity_wait_refresh: html$1U, - settings: html$1S, - settings_main: html$1R, - settings_interface: html$1Q, - settings_parser: html$1P, - settings_server: html$1O, - settings_player: html$1N, - settings_more: html$1M, - settings_tmdb: html$1L, - settings_plugins: html$1K, - settings_cloud: html$1J, - settings_account: html$1I, - scroll: html$1T, - items_line: html$1H, - card: html$1G, - card_parser: html$1F, - card_watched: html$1E, - card_episode: html$1D, - full_start: html$1C, - full_start_new: html$1B, - full_descr: html$1A, - full_person: html$1z, - full_review: html$1y, - full_episode: html$1x, - player: html$1w, - player_panel: html$1v, - player_video: html$1u, - player_info: html$1t, - player_footer: html$1s, - player_footer_card: html$1r, - selectbox: html$1q, - selectbox_item: html$1p, - info: html$1n, - more: html$1l, - search: html$1k, - settings_input: html$1j, - modal: html$1i, - company: html$1h, - modal_loading: html$1g, - modal_pending: html$1f, - person_start: html$1e, - empty: html$1d, - empty_filter: html$1c, - notice: html$1b, - notice_card: html$1a, - torrent: html$19, - torrent_file: html$18, - files: html$17, - about: html$16, - error: html$15, - torrent_noconnect: html$11, - torrent_file_serial: html$Y, - torrent_nocheck: html$10, - torrent_nohash: html$$, - torrent_install: html$_, - torrent_error: html$Z, - filter: html$1m, - search_box: html$X, - console: html$W, - icon_star: html$V, - icon_viewed: html$U, - icon_lock: html$T, - icon_like: html$S, - timeline: html$R, - timeline_details: html$Q, - list_empty: html$P, - screensaver: html$O, - plugins_catalog: html$N, - broadcast: html$M, - lang_choice: html$L, - extensions: html$K, - extensions_block: html$J, - extensions_item: html$I, - extensions_recomend: html$H, - extensions_info: html$G, - extensions_theme: html$F, - extensions_screensaver: html$E, - iframe: html$D, - account: html$C, - account_limited: html$B, - cub_premium: html$A, - cub_premium_modal: html$z, - selectbox_icon: html$1o, - explorer: html$y, - explorer_button_back: html$x, - https: html$w, - navigation_bar: html$v, - head_backward: html$u, - account_add_device: html$t, - feed_item: html$s, - feed_head: html$r, - feed_episode: html$q, - register: html$p, - speedtest: html$o, - season_episode: html$14, - season_episode_rate: html$13, - season_info: html$12, - ad_bot: html$n, - ad_video_block: html$m, - discuss_rules: html$l - }; - var created = {}; - - function get$e(name) { - var vars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var like_static = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - var tpl = templates[name]; - if (!tpl) throw 'Template [' + name + '] not found'; - tpl = Lang.translate(tpl); - - for (var n in vars) { - tpl = tpl.replace(new RegExp('{' + n + '}', 'g'), vars[n]); - } - - tpl = tpl.replace(/{\@([a-z_-]+)}/g, function (e, s) { - return templates[s] || ''; - }); - return like_static ? tpl : $(tpl); - } - - function build$a(tree) { - function create(item) { - var elem = item.elem.cloneNode(); //document.createElement(item.tag) - - /* - if(!item.elem && item.attributes){ - for(let i = 0; i < item.attributes.length; i++){ - elem.setAttribute(item.attributes[i].name, item.attributes[i].value) - } - } - */ - - item.clildrens.forEach(function (child_data) { - var child = create(child_data); - elem.appendChild(child); - }); - return elem; - } - - var root = create(tree); - return root; - } - - function js(name, vars) { - if (!created[name]) { - var extract = function extract(elem) { - var data = { - tag: elem.tagName, - attributes: elem.attributes, - elem: elem, - clildrens: [] - }; - - for (var i = 0; i < elem.childNodes.length; i++) { - if (elem.childNodes[i].tagName) data.clildrens.push(extract(elem.childNodes[i])); - } - - return data; - }; - - var tpl = get$e(name); - var tree = extract(tpl[0]); - created[name] = tree; - } - - return build$a(created[name]); - } - - function add$d(name, html) { - templates[name] = html; - } - - function all$4() { - return templates; - } - - var Template$1 = { - get: get$e, - js: js, - add: add$d, - all: all$4 - }; - - var Base64 = { - // private property - _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", - // public method for encoding - encode: function encode(input) { - var output = ""; - var chr1, chr2, chr3, enc1, enc2, enc3, enc4; - var i = 0; - input = Base64._utf8_encode(input); - - while (i < input.length) { - chr1 = input.charCodeAt(i++); - chr2 = input.charCodeAt(i++); - chr3 = input.charCodeAt(i++); - enc1 = chr1 >> 2; - enc2 = (chr1 & 3) << 4 | chr2 >> 4; - enc3 = (chr2 & 15) << 2 | chr3 >> 6; - enc4 = chr3 & 63; - - if (isNaN(chr2)) { - enc3 = enc4 = 64; - } else if (isNaN(chr3)) { - enc4 = 64; - } - - output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); - } - - return output; - }, - // public method for decoding - decode: function decode(input) { - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - - while (i < input.length) { - enc1 = this._keyStr.indexOf(input.charAt(i++)); - enc2 = this._keyStr.indexOf(input.charAt(i++)); - enc3 = this._keyStr.indexOf(input.charAt(i++)); - enc4 = this._keyStr.indexOf(input.charAt(i++)); - chr1 = enc1 << 2 | enc2 >> 4; - chr2 = (enc2 & 15) << 4 | enc3 >> 2; - chr3 = (enc3 & 3) << 6 | enc4; - output = output + String.fromCharCode(chr1); - - if (enc3 != 64) { - output = output + String.fromCharCode(chr2); - } - - if (enc4 != 64) { - output = output + String.fromCharCode(chr3); - } - } - - output = Base64._utf8_decode(output); - return output; - }, - // private method for UTF-8 encoding - _utf8_encode: function _utf8_encode(string) { - string = string.replace(/\r\n/g, "\n"); - var utftext = ""; - - for (var n = 0; n < string.length; n++) { - var c = string.charCodeAt(n); - - if (c < 128) { - utftext += String.fromCharCode(c); - } else if (c > 127 && c < 2048) { - utftext += String.fromCharCode(c >> 6 | 192); - utftext += String.fromCharCode(c & 63 | 128); - } else { - utftext += String.fromCharCode(c >> 12 | 224); - utftext += String.fromCharCode(c >> 6 & 63 | 128); - utftext += String.fromCharCode(c & 63 | 128); - } - } - - return utftext; - }, - // private method for UTF-8 decoding - _utf8_decode: function _utf8_decode(utftext) { - var string = ""; - var i = 0; - var c = 0; - var c2 = 0; - - while (i < utftext.length) { - c = utftext.charCodeAt(i); - - if (c < 128) { - string += String.fromCharCode(c); - i++; - } else if (c > 191 && c < 224) { - c2 = utftext.charCodeAt(i + 1); - string += String.fromCharCode((c & 31) << 6 | c2 & 63); - i += 2; - } else { - c2 = utftext.charCodeAt(i + 1); - c3 = utftext.charCodeAt(i + 2); - string += String.fromCharCode((c & 15) << 12 | (c2 & 63) << 6 | c3 & 63); - i += 3; - } - } - - return string; - } - }; - - var html$k = $('
    '), - body$4 = html$k.find('.noty__text'), - time$4; - - function show$a(text) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - clearTimeout(time$4); - html$k.attr('class', 'noty'); - if (params.style) html$k.addClass('noty--style--' + params.style); - time$4 = setTimeout(function () { - html$k.removeClass('noty--visible'); - }, params.time || 3000); - body$4.html(text); - html$k.addClass('noty--visible'); - } - - function render$i() { - return html$k; - } - - var Noty = { - show: show$a, - render: render$i - }; - - var reqCallback = {}; - var timeCallback = {}; - - function exit$1() { - if (checkVersion(1)) AndroidJS.exit();else $('')[0].click(); - } - - function playHash(SERVER) { - var magnet = "magnet:?xt=urn:btih:" + SERVER.hash; - - if (checkVersion(10)) { - var intentExtra = ""; - - if (SERVER.movie) { - intentExtra = { - title: "[LAMPA] " + (SERVER.movie.title || 'No title').replace(/\s+/g, ' ').trim(), - poster: SERVER.movie.img, - data: { - lampa: true, - movie: SERVER.movie - } - }; - } - - AndroidJS.openTorrentLink(magnet, JSON.stringify(intentExtra)); - } else { - $('')[0].click(); - } - } - - function openTorrent(SERVER) { - if (checkVersion(10)) { - var intentExtra = { - title: "[LAMPA] " + (SERVER.movie.title || 'No title').replace(/\s+/g, ' ').trim(), - poster: SERVER.object.poster, - data: { - lampa: true, - movie: SERVER.movie - } - }; - AndroidJS.openTorrentLink(SERVER.object.MagnetUri || SERVER.object.Link, JSON.stringify(intentExtra)); - } else { - $('')[0].click(); - } - } - - function openPlayer(link, data) { - if (checkVersion(98, true)) { - if (data.timeline) { - data.timeline.time = Math.round(data.timeline.time); - data.timeline.duration = Math.round(data.timeline.duration); // Lampa.Noty.show('time: ' + data.timeline.time) - // console.log('Timecode', data.timeline) - - timeCallback[data.timeline.hash] = data; - } - } - - if (checkVersion(10)) AndroidJS.openPlayer(link, JSON.stringify(data));else $('')[0].click(); - } - - function openYoutube(link) { - if (checkVersion(15)) AndroidJS.openYoutube(link);else $('')[0].click(); - } - - function resetDefaultPlayer() { - if (checkVersion(15)) AndroidJS.clearDefaultPlayer(); - } - - function httpReq(data, call) { - var index = Math.floor(Math.random() * 5000); - reqCallback[index] = { - data: data, - call: call - }; - if (checkVersion(16)) AndroidJS.httpReq(JSON.stringify(data), index);else call.error({ - responseText: "No Native request" - }); - } - - function httpCall(index, callback) { - var req = reqCallback[index]; - - if (req && req.call[callback]) { - var resp = AndroidJS.getResp(index); - - if (!req.data.dataType || req.data.dataType && req.data.dataType.toLowerCase() == 'json' || callback === 'error') { - try { - resp = JSON.parse(resp); - } catch (e) {} - } - - delete reqCallback[index]; - req.call[callback](resp); - } - } - - function timeCall(timeline) { - var hash = timeline.hash; - - if (timeCallback[hash]) { - timeCallback[hash].timeline.handler(timeline.percent, timeline.time, timeline.duration); - timeCallback[hash].timeline.percent = timeline.percent; - timeCallback[hash].timeline.duration = timeline.duration; - timeCallback[hash].timeline.time = timeline.time; - delete timeCallback[hash]; - } - } - - function voiceStart() { - if (checkVersion(25)) AndroidJS.voiceStart();else Lampa.Noty.show("Работает только на Android TV"); - } - - function updateChannel(where) { - if (checkVersion(28)) AndroidJS.updateChannel(where); - } - - function checkVersion(needVersion) { - var silent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - - if (typeof AndroidJS !== 'undefined') { - try { - var current = AndroidJS.appVersion().split('-'); - var versionCode = current.pop(); - - if (parseInt(versionCode, 10) >= needVersion) { - return true; - } else { - if (!silent) Lampa.Noty.show("Обновите приложение.
    Требуется версия: " + needVersion + "
    Текущая версия: " + versionCode); - return false; - } - } catch (e) { - Lampa.Noty.show("Обновите приложение.
    Требуется версия: " + needVersion); - return false; - } - } else return false; - } - - var Android = { - exit: exit$1, - openTorrent: openTorrent, - openPlayer: openPlayer, - playHash: playHash, - openYoutube: openYoutube, - resetDefaultPlayer: resetDefaultPlayer, - httpReq: httpReq, - voiceStart: voiceStart, - httpCall: httpCall, - timeCall: timeCall, - updateChannel: updateChannel - }; - - function secondsToTime(sec, _short) { - var sec_num = parseInt(sec, 10); - var hours = Math.floor(sec_num / 3600); - var minutes = Math.floor((sec_num - hours * 3600) / 60); - var seconds = sec_num - hours * 3600 - minutes * 60; - - if (hours < 10) { - hours = "0" + hours; - } - - if (minutes < 10) { - minutes = "0" + minutes; - } - - if (seconds < 10) { - seconds = "0" + seconds; - } - - if (isNaN(hours)) hours = '00'; - if (isNaN(minutes)) minutes = '00'; - if (isNaN(seconds)) seconds = '00'; - if (_short) return hours + ':' + minutes; - return hours + ':' + minutes + ':' + seconds; - } - - function capitalizeFirstLetter(string) { - string = string + ''; - return string.charAt(0).toUpperCase() + string.slice(1); - } - - function substr(txt, len) { - txt = txt || ''; - return txt.length > len ? txt.substr(0, len) + '...' : txt; - } - - function numberWithSpaces(x) { - return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "); - } - - function bytesToSize(bytes, speed) { - if (bytes == 0) { - return Lang.translate('size_zero'); - } - - var unitMultiple = 1024; - var unitNames = [Lang.translate('size_byte'), Lang.translate('size_kb'), Lang.translate('size_mb'), Lang.translate('size_gb'), Lang.translate('size_tb'), Lang.translate('size_pp')]; - - if (speed) { - unitMultiple = 1000; - unitNames = [Lang.translate('speed_bit'), Lang.translate('speed_kb'), Lang.translate('speed_mb'), Lang.translate('speed_gb'), Lang.translate('speed_tb'), Lang.translate('speed_pp')]; - } - - var unitChanges = Math.floor(Math.log(bytes) / Math.log(unitMultiple)); - return parseFloat((bytes / Math.pow(unitMultiple, unitChanges)).toFixed(2)) + ' ' + unitNames[unitChanges]; - } - - function sizeToBytes(str) { - var gsize = str.match(/([0-9\\.,]+)\s+(Mb|МБ|GB|ГБ|TB|ТБ)/i); - - if (gsize) { - var size = parseFloat(gsize[1].replace(',', '.')); - if (/gb|гб/.test(gsize[2].toLowerCase())) size *= 1024; - if (/tb|тб/.test(gsize[2].toLowerCase())) size *= 1048576; - return size * 1048576; - } - - return 0; - } - - function calcBitrate(byteSize, minutes) { - if (!minutes) return 0; - var sec = minutes * 60; - var bitSize = byteSize * 8; - return (bitSize / Math.pow(1000, 2) / sec).toFixed(2); - } - - function getMoths(ended) { - var need = ended ? '_e' : ''; - var all = []; - - for (var i = 1; i <= 12; i++) { - all.push(Lang.translate('month_' + i + need)); - } - - return all; - } - - function time$3(html) { - var create = function create() { - var where = html instanceof jQuery ? html[0] : html; - var months = getMoths(); - var months_end = getMoths(true); - var days = [Lang.translate('day_7'), Lang.translate('day_1'), Lang.translate('day_2'), Lang.translate('day_3'), Lang.translate('day_4'), Lang.translate('day_5'), Lang.translate('day_6')]; - var elem_clock = where.querySelector('.time--clock'); - var elem_week = where.querySelector('.time--week'); - var elem_day = where.querySelector('.time--day'); - var elem_moth = where.querySelector('.time--moth'); - var elem_full = where.querySelector('.time--full'); - - this.tik = function () { - var date = new Date(), - time = date.getTime(), - ofst = parseInt((localStorage.getItem('time_offset') == null ? 'n0' : localStorage.getItem('time_offset')).replace('n', '')); - date = new Date(time + ofst * 1000 * 60 * 60); - time = [date.getHours(), date.getMinutes(), date.getSeconds(), date.getFullYear()]; - - if (time[0] < 10) { - time[0] = "0" + time[0]; - } - - if (time[1] < 10) { - time[1] = "0" + time[1]; - } - - if (time[2] < 10) { - time[2] = "0" + time[2]; - } - - var current_time = [time[0], time[1]].join(':'), - current_week = date.getDay(), - current_day = date.getDate(); - if (elem_clock) elem_clock.innerText = current_time; - if (elem_week) elem_week.innerText = days[current_week]; - if (elem_day) elem_day.innerText = current_day; - if (elem_moth) elem_moth.innerText = months[date.getMonth()]; - if (elem_full) elem_full.innerText = current_day + ' ' + months_end[date.getMonth()] + ' ' + time[3]; - }; - - this.timer = setInterval(this.tik.bind(this), 60000); - this.tik(); - }; - - return new create(); - } - - function parseToDate(str) { - if (typeof str == 'string') { - str = str.toLowerCase().split('t')[0].replace(/-/g, '/'); - } - - return new Date(str); - } - - function parseTime(str) { - var months = getMoths(); - var months_end = getMoths(true); - var days = [Lang.translate('day_7'), Lang.translate('day_1'), Lang.translate('day_2'), Lang.translate('day_3'), Lang.translate('day_4'), Lang.translate('day_5'), Lang.translate('day_6')]; - var date = parseToDate(str); - var time = [date.getHours(), date.getMinutes(), date.getSeconds(), date.getFullYear()]; - - if (time[0] < 10) { - time[0] = "0" + time[0]; - } - - if (time[1] < 10) { - time[1] = "0" + time[1]; - } - - if (time[2] < 10) { - time[2] = "0" + time[2]; - } - - var current_time = [time[0], time[1]].join(':'), - current_week = date.getDay(), - current_day = date.getDate(); - return { - time: current_time, - week: days[current_week], - day: current_day, - mouth: months[date.getMonth()], - full: current_day + ' ' + months_end[date.getMonth()] + (new Date().getFullYear() == time[3] ? '' : ' ' + time[3]), - "short": current_day + ' ' + months_end[date.getMonth()], - briefly: current_day + ' ' + months_end[date.getMonth()] + ' ' + current_time - }; - } - - function secondsToTimeHuman(sec_num) { - var hours = Math.trunc(sec_num / 3600); - var minutes = Math.floor((sec_num - hours * 3600) / 60); - return (hours ? hours + ' ' + Lang.translate('time_h') + ' ' : '') + (minutes ? minutes + ' ' + Lang.translate('time_m') + ' ' : Math.round(sec_num) + ' ' + Lang.translate('time_s')); - } - - function strToTime(str) { - var date = new Date(str); - return date.getTime(); - } - - function checkHttp(url, http_only) { - url = url + ''; - if (url.indexOf("http://") == 0 || url.indexOf("https://") == 0) return url; - url = (http_only ? 'http://' : protocol()) + url; - return url; - } - - function checkEmptyUrl(url) { - url = url + ''; - if (url.indexOf("http://") == 0 || url.indexOf("https://") == 0) return url; - url = (window.location.protocol == 'https:' ? 'https://' : 'http://') + url; - return url; - } - - function rewriteIfHTTPS(u) { - return window.location.protocol == 'https:' ? u.replace(/(http:\/\/|https:\/\/)/g, 'https://') : u; - } - - function shortText(fullStr, strLen, separator) { - if (fullStr.length <= strLen) return fullStr; - separator = separator || '...'; - var sepLen = separator.length, - charsToShow = strLen - sepLen, - frontChars = Math.ceil(charsToShow / 2), - backChars = Math.floor(charsToShow / 2); - return fullStr.substr(0, frontChars) + separator + fullStr.substr(fullStr.length - backChars); - } - - function protocol() { - return window.location.protocol == 'https:' ? 'https://' : (localStorage.getItem('protocol') || 'https') + '://'; - } - - function addUrlComponent(url, params) { - return url + (/\?/.test(url) ? '&' : '?') + params; - } - - function putScript(items, complite, error, success, show_logs) { - var p = 0; - var l = typeof show_logs !== 'undefined' ? show_logs : true; - - function next() { - if (p == items.length) return complite(); - var u = items[p]; - - if (!u) { - p++; - return next(); - } - - u = u.replace('cub.watch', Lampa.Manifest.cub_domain); - if (l) console.log('Script', 'create:', u); - var s = document.createElement('script'); - - s.onload = function () { - if (l) console.log('Script', 'include:', u); - if (success) success(u); - next(); - }; - - s.onerror = function () { - if (l) console.log('Script', 'error:', u); - if (error) error(u); - next(); - }; - - s.setAttribute('src', u); - document.body.appendChild(s); - p++; - } - - next(); - } - - function putScriptAsync(items, complite, error, success, show_logs) { - var p = 0; - var l = typeof show_logs !== 'undefined' ? show_logs : true; - - function check() { - p++; - if (p == items.length && complite) complite(); - } - - function put(u) { - u = u.replace('cub.watch', Lampa.Manifest.cub_domain); - if (l) console.log('Script', 'create:', u); - var s = document.createElement('script'); - - s.onload = function () { - if (l) console.log('Script', 'include:', u); - if (success) success(u); - check(); - }; - - s.onerror = function () { - if (l) console.log('Script', 'error:', u); - if (error) error(u); - check(); - }; - - s.setAttribute('src', u); - document.body.appendChild(s); - } - - for (var i = 0; i < items.length; i++) { - put(items[i]); - } - } - - function putStyle(items, complite, error) { - var p = 0; - - function next() { - if (p >= items.length) return complite(); - var u = items[p]; - $.get(u, function (css) { - css = css.replace(/\.\.\//g, './'); - var style = document.createElement('style'); - style.type = 'text/css'; - - if (style.styleSheet) { - // This is required for IE8 and below. - style.styleSheet.cssText = css; - } else { - style.appendChild(document.createTextNode(css)); - } - - document.body.appendChild(style); - next(); - }, function () { - if (error) error(u); - next(); - }, 'TEXT'); - p++; - } - - next(items[0]); - } - - function clearTitle(title) { - return title.replace(/[^a-zа-я0-9\s]/gi, ''); - } - - function cardImgBackground(card_data) { - if (Storage.field('background')) { - if (Storage.field('background_type') == 'poster' && window.innerWidth > 790) { - return card_data.backdrop_path ? Api.img(card_data.backdrop_path, 'w1280') : card_data.background_image ? card_data.background_image : ''; - } - - return card_data.poster_path || card_data.profile_path ? Api.img(card_data.poster_path || card_data.profile_path) : card_data.poster || card_data.img || ''; - } - - return ''; - } - - function cardImgBackgroundBlur(card_data) { - var uri = card_data.poster_path || card_data.profile_path ? Api.img(card_data.poster_path || card_data.profile_path, 'w200') : card_data.poster || card_data.img || ''; - var pos = window.innerWidth > 400 && Storage.field('background_type') == 'poster'; - - if (Storage.field('background')) { - if (card_data.backdrop_path) uri = Api.img(card_data.backdrop_path, pos ? 'w1280' : 'w200');else if (card_data.background_image && pos) uri = card_data.background_image; - } - - return uri; - } - - function stringToHslColor(str, s, l) { - var hash = 0; - - for (var i = 0; i < str.length; i++) { - hash = str.charCodeAt(i) + ((hash << 5) - hash); - } - - var h = hash % 360; - return 'hsl(' + h + ', ' + s + '%, ' + l + '%)'; - } - - function pathToNormalTitle(path) { - var add_exe = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; - var name = path.split('.'); - var exe = name[name.length - 1]; - name = name.join('.'); - return (name + '').replace(/_|\./g, ' ') + (add_exe ? ' .' + exe + '' : ''); - } - - function hash$2(input) { - var str = (input || '') + ''; - var hash = 0; - if (str.length == 0) return hash; - - for (var i = 0; i < str.length; i++) { - var _char = str.charCodeAt(i); - - hash = (hash << 5) - hash + _char; - hash = hash & hash; // Convert to 32bit integer - } - - return Math.abs(hash) + ''; - } - - function uid(len) { - var ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - var ID_LENGTH = len || 8; - var id = ''; - - for (var i = 0; i < ID_LENGTH; i++) { - id += ALPHABET.charAt(Math.floor(Math.random() * ALPHABET.length)); - } - - return id; - } - - function copyTextToClipboard(text, succes, error) { - if (!text) return error && error(); - var textArea = document.createElement("textarea"); - textArea.value = text; - textArea.style.top = "0"; - textArea.style.left = "0"; - textArea.style.position = "fixed"; - document.body.appendChild(textArea); - textArea.focus(); - textArea.select(); - - try { - var successful = document.execCommand('copy'); - if (successful) succes();else error(); - } catch (err) { - error(); - } - - document.body.removeChild(textArea); - } - - function imgLoad(image, src, onload, onerror) { - var img = $(image)[0]; - - img.onload = function () { - if (onload) onload(); - }; - - img.onerror = function (e) { - img.src = './img/img_broken.svg'; - if (onerror) onerror(); - }; - - img.src = src; - } - - function isTouchDevice() { - var touch = ('ontouchstart' in window); - var points = navigator.maxTouchPoints > 0 && navigator.maxTouchPoints !== 256 || navigator.msMaxTouchPoints > 0 && navigator.msMaxTouchPoints !== 256; - var win = navigator.userAgent.toLowerCase().indexOf('windows nt') !== -1; - return touch || points && !win; - } - - function canFullScreen() { - var doc = window.document; - var elem = doc.documentElement; - return elem.requestFullscreen || elem.mozRequestFullScreen || elem.webkitRequestFullScreen || elem.msRequestFullscreen; - } - - function toggleFullscreen() { - // Check if the User-Agent string contains the word "Tesla" - if (navigator.userAgent.indexOf("Tesla") >= 0) { - // Get the current domain from the URL - var currentDomain = window.location.hostname; // Construct the YouTube redirect URL with the current domain - - var targetURL = "https://www.youtube.com/redirect?q=".concat(currentDomain); // If it's Tesla's browser, redirect to the YouTube URL (which will open the current domain in full-screen, thank you Elon, sarcasm) - - location.href = targetURL; - } else { - var doc = window.document; - var elem = doc.documentElement; - var requestFullScreen = elem.requestFullscreen || elem.mozRequestFullScreen || elem.webkitRequestFullScreen || elem.msRequestFullscreen; - var cancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen; - - if (!doc.fullscreenElement && !doc.mozFullScreenElement && !doc.webkitFullscreenElement && !doc.msFullscreenElement) { - requestFullScreen.call(elem); - } else { - cancelFullScreen.call(doc); - } - } - } - - function countSeasons(movie) { - var seasons = movie.seasons || []; - var count = 0; - - for (var i = 0; i < seasons.length; i++) { - if (seasons[i].episode_count > 0) count++; - } - - if (count > movie.number_of_seasons) count = movie.number_of_seasons; - return count; - } - - function countDays(time_a, time_b) { - var d1 = new Date(time_a); - var d2 = new Date(time_b); - var days = (d2 - d1) / (1000 * 60 * 60 * 24); - days = Math.round(days); - return days <= 0 ? 0 : days; - } - - function decodePG(pg) { - var lang = Storage.field('language'); - var keys = { - 'G': '3+', - 'PG': '6+', - 'PG-13': '13+', - 'R': '17+', - 'NC-17': '18+', - 'TV-Y': '0+', - 'TV-Y7': '7+', - 'TV-G': '3+', - 'TV-PG': '6+', - 'TV-14': '14+', - 'TV-MA': '17+' - }; - - if (lang == 'ru' || lang == 'uk' || lang == 'be') { - for (var key in keys) { - if (pg == key) return keys[key]; - } - } - - return pg; - } - - function trigger$2(element, event_name) { - var event = document.createEvent('Event'); - event.initEvent(event_name, false, true); - element.dispatchEvent(event); - } - - function isPWA() { - var pwa = false; - - try { - pwa = window.matchMedia('(display-mode: standalone)').matches; - } catch (e) {} - - return pwa; - } - - function bigNumberToShort(number) { - var suffixes = ['', 'K', 'M', 'M']; // Суффиксы для различных форматов - - var absoluteNumber = Math.abs(number); // Получаем абсолютное значение числа - - var suffixIndex = Math.floor((absoluteNumber.toFixed(0).length - 1) / 3); // Определение индекса суффикса - // Проверяем, если число меньше 1000, возвращаем его без изменений - - if (absoluteNumber < 1000) { - return number.toString(); - } // Округление числа и преобразование в строку - - - var roundedNumber = (number / Math.pow(1000, suffixIndex)).toFixed(1).replace('.0', ''); - return roundedNumber + suffixes[suffixIndex]; // Возвращаем округленное число с суффиксом - } - - function gup(name, url) { - if (!url) url = location.href; - name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); - var regexS = "[\\?&]" + name + "=([^&#]*)"; - var regex = new RegExp(regexS); - var results = regex.exec(url); - return results == null ? null : results[1]; - } - - function dcma(media, id) { - return window.lampa_settings.dcma && window.lampa_settings.dcma.find(function (a) { - return a.cat == media && a.id == id; - }); - } - - function inputDisplay(value) { - var f = value.trim(); - var d = f.length - value.length; - var e = d < 0 ? value.slice(d).replace(/\s/g, ' ') : ''; - return f + e; - } - - var Utils$2 = { - secondsToTime: secondsToTime, - secondsToTimeHuman: secondsToTimeHuman, - capitalizeFirstLetter: capitalizeFirstLetter, - substr: substr, - numberWithSpaces: numberWithSpaces, - time: time$3, - bytesToSize: bytesToSize, - calcBitrate: calcBitrate, - parseTime: parseTime, - parseToDate: parseToDate, - checkHttp: checkHttp, - shortText: shortText, - protocol: protocol, - addUrlComponent: addUrlComponent, - sizeToBytes: sizeToBytes, - putScript: putScript, - putScriptAsync: putScriptAsync, - putStyle: putStyle, - clearTitle: clearTitle, - cardImgBackground: cardImgBackground, - cardImgBackgroundBlur: cardImgBackgroundBlur, - strToTime: strToTime, - stringToHslColor: stringToHslColor, - pathToNormalTitle: pathToNormalTitle, - hash: hash$2, - uid: uid, - copyTextToClipboard: copyTextToClipboard, - imgLoad: imgLoad, - isTouchDevice: isTouchDevice, - toggleFullscreen: toggleFullscreen, - canFullScreen: canFullScreen, - countSeasons: countSeasons, - countDays: countDays, - decodePG: decodePG, - trigger: trigger$2, - isPWA: isPWA, - bigNumberToShort: bigNumberToShort, - rewriteIfHTTPS: rewriteIfHTTPS, - checkEmptyUrl: checkEmptyUrl, - gup: gup, - dcma: dcma, - inputDisplay: inputDisplay - }; - - var widgetAPI, - tvKey, - pluginAPI, - loader$2, - orsay_loaded, - orsay_call = Date.now(); - - function init$G() { - $('body').append($("
    \n \n \n \n
    ")); - Utils$2.putScript(['$MANAGER_WIDGET/Common/API/Widget.js', '$MANAGER_WIDGET/Common/API/TVKeyValue.js', '$MANAGER_WIDGET/Common/API/Plugin.js', '$MANAGER_WIDGET/Common/webapi/1.0/webapis.js', '$MANAGER_WIDGET/Common/IME_XT9/ime.js', '$MANAGER_WIDGET/Common/IME_XT9/inputCommon/ime_input.js'], function () { - try { - if (typeof Common !== 'undefined' && Common.API && Common.API.TVKeyValue && Common.API.Plugin && Common.API.Widget) { - widgetAPI = new Common.API.Widget(); - tvKey = new Common.API.TVKeyValue(); - pluginAPI = new Common.API.Plugin(); - window.onShow = orsayOnshow; - setTimeout(function () { - orsayOnshow(); - }, 2000); - widgetAPI.sendReadyEvent(); - } else { - if (orsay_call + 5 * 1000 > Date.now()) setTimeout(orsayOnLoad, 50); - } - } catch (e) {} - }); - /** - * Скрывает ненужные параметры для плеера - */ - - if (Platform.is('orsay')) { - var hidePlayerParams = function hidePlayerParams() { - $('[data-name="player_normalization"],[data-name="player_scale_method"],[data-name="player_hls_method"]').toggleClass('hide', Lampa.Storage.field('player') == 'orsay'); - }; - /* Подписываемся на открытие настроек плера*/ - - - Lampa.Settings.listener.follow('open', function (e) { - if (e.name == 'player') hidePlayerParams(); - }); - /* Подписываемся на изменение плера*/ - - Lampa.Storage.listener.follow('change', function (e) { - if (e.name == 'player') hidePlayerParams(); - }); - } - } - - function orsayOnshow() { - if (orsay_loaded) return; - orsay_loaded = true; - - try { - //Включает анимацию изменения громкости на ТВ и т.д. - pluginAPI.SetBannerState(1); //Отключает перехват кнопок, этими кнопками управляет система ТВ - - pluginAPI.unregistKey(tvKey.KEY_INFO); - pluginAPI.unregistKey(tvKey.KEY_TOOLS); - pluginAPI.unregistKey(tvKey.KEY_MENU); - pluginAPI.unregistKey(tvKey.KEY_VOL_UP); - pluginAPI.unregistKey(tvKey.KEY_VOL_DOWN); - pluginAPI.unregistKey(tvKey.KEY_MUTE); // Отключаем заставку ТВ - - pluginAPI.setOffScreenSaver(); - console.log('App', 'Version widget ', Platform.version('orsay')); - } catch (e) {} - } - - function isNewWidget() { - if (typeof window.top.WidgetLoader != 'undefined') { - loader$2 = window.top.WidgetLoader; - return true; - } else { - return false; - } - } - - function getLoaderUrl() { - if (isNewWidget()) { - return loader$2.getUrl(); - } - } - - function setLoaderUrl(_url) { - if (isNewWidget()) { - return loader$2.setUrl(_url); - } - } - - function changeLoaderUrl() { - if (isNewWidget()) { - return loader$2.changeUrl(); - } - } - - function exit() { - if (widgetAPI) widgetAPI.sendReturnEvent(); - } - - var Orsay = { - init: init$G, - isNewWidget: isNewWidget, - getLoaderUrl: getLoaderUrl, - setLoaderUrl: setLoaderUrl, - changeLoaderUrl: changeLoaderUrl, - exit: exit - }; - - var timer$8; - var need_update = false; - var need_visible = false; - var canianimate$1 = typeof requestAnimationFrame !== 'undefined'; - - function init$F() { - $(window).on('resize', function () { - clearTimeout(timer$8); - timer$8 = setTimeout(function () { - toggleMobile(); - toggleOrientation(); - size$1(); - update$b(); - }, 100); - }); - var follow = ['animation', 'mask', 'card_interfice_poster', 'glass_style', 'black_style', 'glass_opacity', 'card_interfice_cover', 'advanced_animation']; - Storage.listener.follow('change', function (event) { - if (event.name == 'interface_size') { - size$1(); - update$b(); - } - - if (follow.indexOf(event.name) >= 0) toggleClasses(); - }); - toggleClasses(); - toggleMobile(); - toggleOrientation(); - size$1(); - setTimeout(blick, 5000); - if (Platform.tv() || Platform.desktop()) mouseEvents(); - } - - function toggleMobile() { - $('body').toggleClass('true--mobile', Platform.screen('mobile')); - } - - function toggleOrientation() { - $('body').removeClass('orientation--portrait orientation--landscape').addClass('orientation--' + (window.innerWidth > window.innerHeight && window.innerHeight < 768 ? 'landscape' : 'portrait')); - } - - function mouseEvents() { - var body = $('body'); - var mouse_timer_cursor; - $(window).on('mousemove', function () { - clearTimeout(mouse_timer_cursor); - mouse_timer_cursor = setTimeout(function () { - body.toggleClass('no--cursor', true); - }, 3000); - body.toggleClass('no--cursor', false); - }); - } - - function size$1() { - var sl = Storage.field('interface_size'); - var sz = { - normal: 1, - small: 0.9, - bigger: 1.05 - }; - var fs = sz[sl]; - $('body').css({ - fontSize: Math.max(window.innerWidth / 84.17 * fs, 10.6) + 'px' - }).removeClass('size--small size--normal size--bigger').addClass('size--' + sl); - } - - function blick() { - $('.icon--blink').not('.ready').each(function () { - var elem = $(this), - time = parseInt(elem.data('blink-interval') || 3) * 1000; - elem.addClass('ready'); - setInterval(function () { - elem.addClass('animate'); - setTimeout(function () { - elem.removeClass('animate'); - }, 1000); - }, time); - }); - } - - function frameUpdate(render) { - var where = render || document.body; - var target = where instanceof jQuery ? where[0] : where; - var landscape = window.innerWidth > window.innerHeight && window.innerHeight < 768; - var wrap = document.querySelector('.wrap__left'); - var head = document.querySelector('.head'); - var navi = document.querySelector('.navigation-bar'); - var menu_left = wrap ? wrap.getBoundingClientRect().left : 0; - var menu_width = wrap ? wrap.getBoundingClientRect().width : 0; - var head_height = head ? head.getBoundingClientRect().height : 0; - var navi_height = navi && !landscape ? navi.getBoundingClientRect().height : 0; - var navi_width = navi && landscape ? navi.getBoundingClientRect().width : 0; - var layer_width = Array.from(target.querySelectorAll('.layer--width')); - var layer_height = Array.from(target.querySelectorAll('.layer--height')); - var layer_wheight = Array.from(target.querySelectorAll('.layer--wheight')); - if (target.classList.contains('layer--width')) layer_width.push(target); - if (target.classList.contains('layer--height')) layer_height.push(target); - if (target.classList.contains('layer--wheight')) layer_wheight.push(target); - - for (var i = 0; i < layer_width.length; i++) { - var elem = layer_width[i], - read = parseFloat(elem.style.width), - widh = window.innerWidth - (Platform.screen('light') && menu_left == 0 ? menu_width : 0) - navi_width; - if (read !== widh) layer_width[i].style.width = widh; - } - - for (var _i = 0; _i < layer_wheight.length; _i++) { - var _elem = layer_wheight[_i], - heig = window.innerHeight - head_height - navi_height, - attr = _elem.mheight, - _read = parseFloat(_elem.style.height); - - if (attr) { - heig -= attr.getBoundingClientRect().height; - } - - if (_read !== heig) _elem.style.height = heig; - } - - for (var _i2 = 0; _i2 < layer_height.length; _i2++) { - var _elem2 = layer_height[_i2], - _heig = window.innerHeight, - _attr = _elem2.mheight, - _read2 = parseFloat(_elem2.style.height); - - if (_attr) { - _heig -= _attr.getBoundingClientRect().height; - } - - if (_read2 !== _heig) _elem2.style.height = _heig; - } - } - - function intersected(a, b) { - return a[0] <= b[2] && b[0] <= a[2] && a[1] <= b[3] && b[1] <= a[3]; - } - - function frameVisible(render) { - var active = Lampa.Activity.active(); - var where = render ? render : active && active.activity ? active.activity.render() : false; - var area = 1.5; - var hide = Storage.field('hide_outside_the_screen'); - var v_w = window.innerWidth * area; - var v_h = window.innerHeight * area; - var m_w = window.innerWidth - v_w; - var m_h = window.innerHeight - v_h; - - if (where) { - var target = where instanceof jQuery ? where[0] : where; - var elems = []; - - if (target.classList.contains('layer--visible')) { - elems.push({ - type: 'visible', - elem: target - }); - } - - if (target.classList.contains('layer--render')) { - elems.push({ - type: 'render', - elem: target - }); - } - - elems = elems.concat(Array.from(target.querySelectorAll('.layer--visible')).map(function (elem) { - return { - type: 'visible', - elem: elem - }; - }), Array.from(target.querySelectorAll('.layer--render')).map(function (elem) { - return { - type: 'render', - elem: elem - }; - })); - - for (var i = 0; i < elems.length; i++) { - var item = elems[i]; - var elem = item.elem; - - if (item.type == 'visible') { - if (!elem.call_visible) { - var bond = elem.getBoundingClientRect(); - - if (intersected([m_w, m_h, v_w, v_h], [bond.left, bond.top, bond.left + bond.width, bond.top + bond.height])) { - elem.call_visible = true; - item.visible = true; - } - } - } - - if (elem.call_visible) { - var _bond = elem.getBoundingClientRect(); - - var view = hide ? intersected([m_w, m_h, v_w, v_h], [_bond.left, _bond.top, _bond.left + _bond.width, _bond.top + _bond.height]) : true; - var visibility = view ? 'visible' : 'hidden'; - - if (elem.visibility !== visibility) { - if (!elem.visibility && visibility == 'visible') continue; - elem.visibility = visibility; - item.visibility = visibility; - } - } - } - - for (var _i3 = 0; _i3 < elems.length; _i3++) { - var _item = elems[_i3]; - var _elem3 = _item.elem; - - if (_item.type == 'visible') { - if (_item.visible) Utils$2.trigger(_elem3, 'visible'); - } - - if (_item.visibility) { - _elem3.style.visibility = _elem3.visibility; - } - } - } - } - - function toggleClasses() { - $('body').toggleClass('no--animation', !Storage.field('animation')); - $('body').toggleClass('no--mask', !Storage.field('mask')); - $('body').toggleClass('no--poster', !Storage.field('card_interfice_poster')); - $('body').toggleClass('glass--style', Storage.field('glass_style')); - $('body').toggleClass('black--style', Storage.field('black_style')); - $('body').toggleClass('card--no-cover', !Storage.field('card_interfice_cover')); - $('body').toggleClass('advanced--animation', Storage.field('advanced_animation')); - $('body').removeClass('glass--style-opacity--easy glass--style-opacity--medium glass--style-opacity--blacked'); - if (Storage.field('glass_style')) $('body').addClass('glass--style-opacity--' + Storage.field('glass_opacity')); - } - - function visible(where) { - requestFrame$1(); - need_visible = where; - if (!canianimate$1) frameVisible(where); - } - - function update$b(where) { - requestFrame$1(); - need_update = where; - if (!canianimate$1) frameUpdate(where); - } - - function requestFrame$1() { - if (canianimate$1 && need_update === false && need_visible === false) requestAnimationFrame(updateFrame); - } - - function updateFrame() { - if (need_update !== false) frameUpdate(need_update); - if (need_visible !== false) frameVisible(need_visible); - need_update = false; - need_visible = false; - } - - var Layer = { - update: update$b, - visible: visible, - init: init$F - }; - - function create$q() { - var _this = this; - - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var _self = this; - - var html = Template$1.js('scroll'); - var body = html.querySelector('.scroll__body'); - var content = html.querySelector('.scroll__content'); - var caianimate = typeof requestAnimationFrame !== 'undefined'; - var frame_time = 0; - var scroll_position = 0; - var scroll_transition = 0; - var scroll_time = 0, - scroll_step = params.step || 150; - var call_update_time = Date.now(); - var call_transition_time = Date.now(); - if (params.horizontal) html.classList.toggle('scroll--horizontal', true); - if (params.mask) html.classList.toggle('scroll--mask', true); - if (params.over) html.classList.toggle('scroll--over', true); - if (params.nopadding) html.classList.toggle('scroll--nopadding', true); - if (params.notransition) body.classList.toggle('notransition', true); - html.addEventListener('mousewheel', function (e) { - var parent = $(e.target).parents('.scroll'); - var inner = onTheRightSide(e, true); - if (!params.horizontal && $(html).is(parent[0])) inner = true; - - if (Storage.field('navigation_type') == 'mouse' && Date.now() - scroll_time > 200 && inner) { - scroll_time = Date.now(); - - if (e.wheelDelta / 120 > 0) { - if (_this.onWheel) _this.onWheel(-scroll_step);else _this.wheel(-scroll_step); - } else { - if (_this.onWheel) _this.onWheel(scroll_step);else _this.wheel(scroll_step); - } - } - }); - html.Scroll = _self; - body.addEventListener('webkitTransitionEnd', function () { - if (Date.now() - call_transition_time > 400) return; //чет на моей карте выходит 180-190, странно, ну да ладно, поставил 150 - - if (Date.now() - call_update_time > 150) scrollEnded(); - }); - - if (Platform.screen('tv')) { - html.addEventListener('scroll', function (e) { - html.scrollTop = 0; - html.scrollLeft = 0; - }); - } else { - html.addEventListener('scroll', scrollEnded); - } - - function onTheRightSide(e) { - var inleft = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - var offset = content.getBoundingClientRect().left; - var width = window.innerWidth - offset; - var position = e.clientX - offset; - return params.horizontal ? position > width / 2 : inleft ? position < width / 2 : false; - } - - function maxOffset(offset) { - var w = params.horizontal ? html.offsetWidth : html.offsetHeight; - var p = parseInt(window.getComputedStyle(content, null).getPropertyValue('padding-' + (params.horizontal ? 'left' : 'top'))); - var s = body[params.horizontal ? 'scrollWidth' : 'scrollHeight']; - offset = Math.min(0, offset); - offset = Math.max(-(Math.max(s + p * 2, w) - w), offset); - return offset; - } - - function scrollEnded() { - call_update_time = Date.now(); - if (_self.onScroll) _self.onScroll(!Platform.screen('tv') ? html[params.horizontal ? 'scrollLeft' : 'scrollTop'] : -scroll_position);else Layer.visible(html); - if (_self.onEnd && _self.isEnd()) _self.onEnd(); - } - - function scrollTo(scrl) { - if (!Platform.screen('tv')) { - var object = {}; - object[params.horizontal ? 'scrollLeft' : 'scrollTop'] = -scrl; - $(html).animate(object, 200); - } else { - if (scroll_transition == false) { - scroll_transition = scrl; - - if (caianimate && Storage.field('animation')) { - var cannow = Date.now() - frame_time > 500; - if (cannow) animate();else requestAnimationFrame(animate); - } else animate(); - } - } - - scroll_position = scrl; - } - - function animate() { - body.style['-webkit-transform'] = 'translate3d(' + Math.round(params.horizontal ? scroll_transition : 0) + 'px, ' + Math.round(params.horizontal ? 0 : scroll_transition) + 'px, 0px)'; - scroll_transition = false; - if (!Storage.field('animation') || Date.now() - call_update_time < 300) scrollEnded(); - frame_time = Date.now(); - } - - function startScroll(scrl) { - scrollTo(scrl); - call_update_time = Date.now(); - call_transition_time = Date.now(); - } - - this.addSwipeDown = function (call) { - if (window.innerWidth > 480) return; - var s = 0; - var t = 0; - html.addEventListener('touchstart', function (e) { - var point = e.touches[0] || e.changedTouches[0]; - - if (s == 0) { - s = point.clientY; - t = Date.now(); - } - }); - html.addEventListener('touchmove', function (e) { - var point = e.touches[0] || e.changedTouches[0]; - - if (s !== 0) { - if (point.clientY - s > 50 && html.scrollTop == 0 && Date.now() - t < 100) { - s = 0; - call(); - } - } - }); - html.addEventListener('touchend', function (e) { - s = 0; - }); - }; - - this.wheel = function (size) { - var direct = params.horizontal ? 'left' : 'top'; - var scrl = scroll_position, - scrl_offset = html.getBoundingClientRect()[direct], - scrl_padding = parseInt(window.getComputedStyle(content, null).getPropertyValue('padding-' + direct)); - - if (params.scroll_by_item) { - var pos = body.scroll_position; - pos = pos || 0; - var items = Array.from(body.children); - pos += size > 0 ? 1 : -1; - pos = Math.max(0, Math.min(items.length - 1, pos)); - body.scroll_position = pos; - var item = items[pos], - ofst = item.getBoundingClientRect()[direct]; - size = ofst - scrl_offset - scrl_padding; - } - - var max = params.horizontal ? 30000 : body.offsetHeight; - max -= params.horizontal ? html.offsetWidth : html.offsetHeight; - max += scrl_padding * 2; - scrl -= size; - scrl = Math.min(0, Math.max(-max, scrl)); - scrl = maxOffset(scrl); - startScroll(scrl); - }; - - this.update = function (elem, tocenter) { - var dir = params.horizontal ? 'left' : 'top', - siz = params.horizontal ? 'offsetWidth' : 'offsetHeight'; - var target = elem instanceof jQuery ? elem[0] : elem; - var ofs_elm = target.getBoundingClientRect()[dir], - ofs_box = body.getBoundingClientRect()[dir], - center = ofs_box + (tocenter ? content[siz] / 2 - target[siz] / 2 : 0), - scrl = Math.min(0, center - ofs_elm); - scrl = maxOffset(scrl); - startScroll(scrl); - }; - - this.vieport = function () { - var vieport = {}; - - if (!Platform.screen('tv')) { - vieport.position = html[params.horizontal ? 'scrollLeft' : 'scrollTop'], vieport.body = body[params.horizontal ? 'scrollWidth' : 'scrollHeight'], vieport.content = html[params.horizontal ? 'offsetWidth' : 'offsetHeight']; - } else { - vieport.position = scroll_position; - vieport.body = body[params.horizontal ? 'offsetWidth' : 'offsetHeight']; - vieport.content = html[params.horizontal ? 'offsetWidth' : 'offsetHeight']; - } - - return vieport; - }; - - this.isEnd = function (end_ratio) { - var vieport = this.vieport(); - if (vieport.body < vieport.content) return false; - return vieport.body - vieport.content * Math.max(1, end_ratio || params.end_ratio || 1) < Math.abs(vieport.position); - }; - - this.append = function (object) { - body.appendChild(object instanceof jQuery ? object[0] : object); - }; - - this.minus = function (minus) { - html.classList.add('layer--wheight'); - html.mheight = minus instanceof jQuery ? minus[0] : minus; - }; - - this.height = function (minus) { - html.classList.add('layer--height'); - html.mheight = minus instanceof jQuery ? minus[0] : minus; - }; - - this.body = function (js) { - return js ? body : $(body); - }; - - this.render = function (js) { - return js ? html : $(html); - }; - - this.clear = function () { - body.innerHTML = ''; - }; - - this.params = function () { - return params; - }; - - this.reset = function () { - body.classList.add('transition-reset'); - body.style['-webkit-transform'] = 'translate3d(0px, 0px, 0px)'; - setTimeout(function () { - body.classList.remove('transition-reset'); - }, 0); - scroll_position = 0; - }; - - this.destroy = function () { - html.remove(); - }; - } - - var sounds = {}; - - function Sound(option) { - this.option = option; - this.loaded = false; - this.audio = new Audio(); - this.audio.src = option.url; - this.audio.volume = option.volume || 1; - this.audio.load(); - var volume = option.volume || 1; - var isplay = false; - this.audio.addEventListener("playing", function (event) { - isplay = true; - }); - this.audio.addEventListener("pause", function (event) { - isplay = false; - }); - - this.play = function () { - this.stop(); - var playPromise; - - try { - this.audio.currentTime = 0; - this.audio.volume = volume * (Lampa.Storage.field('interface_sound_level') / 100); - playPromise = this.audio.play(); - } catch (e) {} - - if (playPromise !== undefined) { - playPromise.then(function () {})["catch"](function (e) { - console.log('Sound', 'play promise error:', e.message); - }); - } - - return this; - }; - - this.stop = function () { - if (!isplay) return this; - var stopPromise; - - try { - stopPromise = this.audio.pause(); - } catch (e) {} - - if (stopPromise !== undefined) { - stopPromise.then(function () {})["catch"](function (e) { - console.log('Sound', 'stop promise error:', e.message); - }); - } - - return this; - }; - - return this; - } - - function play$4(name) { - if (sounds[name] && Storage.field('interface_sound_play')) sounds[name].play(); - } - - function add$c(name, params) { - try { - sounds[name] = new Sound(params); - return sounds[name]; - } catch (e) { - return false; - } - } - - var Sound$1 = { - add: add$c, - play: play$4 - }; - - var philipse = { - play: typeof VK_PLAY !== 'undefined' ? VK_PLAY : typeof KEYCODE_MEDIA_PLAY !== 'undefined' ? KEYCODE_MEDIA_PLAY : -1, - stop: typeof VK_STOP !== 'undefined' ? VK_STOP : typeof KEYCODE_MEDIA_STOP !== 'undefined' ? KEYCODE_MEDIA_STOP : -1, - pause: typeof VK_PAUSE !== 'undefined' ? VK_PAUSE : typeof KEYCODE_MEDIA_PAUSE !== 'undefined' ? KEYCODE_MEDIA_PAUSE : -1, - play_pause: typeof VK_PLAY_PAUSE !== 'undefined' ? VK_PLAY_PAUSE : typeof KEYCODE_MEDIA_PLAY_PAUSE !== 'undefined' ? KEYCODE_MEDIA_PLAY_PAUSE : -1 - }; - var enabled$2 = false; - var listener$k = start$8(); - var time$2 = 0; - var lastdown = 0; - var timer$7; - var longpress; - var keydown = false; - var canianimate = typeof requestAnimationFrame !== 'undefined'; - var frame_time = 0; - - function toggle$b(new_status) { - enabled$2 = new_status; - listener$k.send('toggle', { - status: enabled$2 - }); - } - - function enable$1() { - toggle$b(true); - } - - function disable() { - toggle$b(false); - } - - function isEnter(keycode) { - return keycode == 13 || keycode == 29443 || keycode == 117 || keycode == 65385; - } - - function keyCode(e) { - var keycode; - - if (window.event) { - keycode = e.keyCode; - } else if (e.which) { - keycode = e.which; - } - - return keycode; - } - - function requestFrame() { - keydownTrigger(keydown); - keydown = false; - frame_time = Date.now(); - } - - function keydownTrigger(e) { - var keycode = keyCode(e); //Noty.show(keycode) - if (time$2 > Date.now() - 100) return; - time$2 = Date.now(); - listener$k.send('keydown', { - code: keycode, - enabled: enabled$2, - event: e - }); - if (e.defaultPrevented) return; - if (isEnter(keycode)) return; - if (!enabled$2) return; //отключить все - //4 - Samsung orsay - - if (keycode == 37 || keycode == 4) { - Sound$1.play('hover'); - Controller.move('left'); - } //29460 - Samsung orsay - - - if (keycode == 38 || keycode == 29460) { - Sound$1.play('hover'); - Controller.move('up'); - } //5 - Samsung orsay - - - if (keycode == 39 || keycode == 5) { - Sound$1.play('hover'); - Controller.move('right'); - } //5 - Samsung orsay - //29461 - Samsung orsay - - - if (keycode == 40 || keycode == 29461) { - Sound$1.play('hover'); - Controller.move('down'); - } //33 - LG; 427 - Samsung - - - if (keycode == 33 || keycode == 427) { - Sound$1.play('hover'); - Controller.move('toup'); - } //34 - LG; 428 - Samsung - - - if (keycode == 34 || keycode == 428) { - Sound$1.play('hover'); - Controller.move('todown'); - } //Абсолютный Enter - //10252 - Samsung tizen - - - if (keycode == 32 || keycode == 179 || keycode == 10252 || keycode == philipse.play_pause) { - Controller.trigger('playpause'); - } //Samsung media - //71 - Samsung orsay - - - if (keycode == 415 || keycode == 71 || keycode == philipse.play) { - Controller.trigger('play'); - } //Samsung stop - //70 - Samsung orsay - - - if (keycode == 413 || keycode == philipse.stop || keycode == 70) { - Controller.trigger('stop'); - } //69 - Samsung orsay - - - if (keycode == 412 || keycode == 69 || keycode == 177) { - Controller.trigger('rewindBack'); - } //72 - Samsung orsay - - - if (keycode == 418 || keycode == 417 || keycode == 72 || keycode == 176) { - Controller.trigger('rewindForward'); - } //74 - Samsung orsay - - - if (keycode == 19 || keycode == 74 || keycode == philipse.pause) { - Controller.trigger('pause'); - } - - if (keycode == 457) { - Controller.trigger('info'); - } //E-Manual - - - if (keycode == 10146) { - e.preventDefault(); - } - - if (keycode == 10133) { - Controller.toggle('settings'); - } //Кнопка назад - //8 - браузер - //27 - //461 - LG - //10009 - Samsung - //88 - Samsung orsay - - - if (keycode == 8 || keycode == 27 || keycode == 461 || keycode == 10009 || keycode == 88) { - e.preventDefault(); - if (window.appready) Activity$1.back(); - return false; - } //Exit orsay - - - if (keycode == 45) { - Orsay.exit(); - } //Кнопка pre-ch вызывает окно смены адреса в Loader - //259 - Samsung orsay - - - if (keycode == 259) { - if (Orsay.isNewWidget()) { - Orsay.changeLoaderUrl(); - } - } - - e.preventDefault(); - } - - function init$E() { - window.addEventListener("keydown", function (e) { - lastdown = keyCode(e); - - if (!timer$7) { - timer$7 = setTimeout(function () { - if (isEnter(lastdown)) { - longpress = true; - listener$k.send('longdown', {}); - Controller["long"](); - } - }, 800); - } - }); - window.addEventListener("keyup", function (e) { - clearTimeout(timer$7); - time$2 = 0; - timer$7 = null; - listener$k.send('keyup', { - code: keyCode(e), - enabled: enabled$2, - event: e - }); - - if (!longpress) { - if (isEnter(keyCode(e)) && !e.defaultPrevented) { - Sound$1.play('enter'); - Controller.enter(); - } - } else longpress = false; - }); - window.addEventListener("keydown", function (e) { - if (canianimate) { - var cannow = Date.now() - frame_time > 500; - var presed = keydown; - keydown = e; - - if (presed === false) { - if (cannow) requestFrame();else requestAnimationFrame(requestFrame); - } - } else { - keydownTrigger(e); - } - }); - } - - var Keypad = { - listener: listener$k, - init: init$E, - enable: enable$1, - disable: disable - }; - - var keydown_time = 0; - var move_time = 0; - var touch = false; - - function init$D() { - Keypad.listener.follow('keydown', function () { - keydown_time = Date.now(); - move_time = 0; - }); - $(window).on('mousemove', function (e) { - move_time = Date.now(); - }).on('touchstart', function () { - touch = true; - }); - detect$9(); - } - - function showModal$1(text, onselect) { - var controller = Controller.enabled().name; - Modal.open({ - title: '', - align: 'center', - zIndex: 300, - html: $('
    ' + text + '
    '), - buttons: [{ - name: Lang.translate('settings_param_no'), - onSelect: function onSelect() { - Modal.close(); - Controller.toggle(controller); - } - }, { - name: Lang.translate('settings_param_yes'), - onSelect: onselect - }] - }); - } - - function detect$9() { - var show_touch, show_mouse, show_remote; - $(document).on('touchstart', function (e) { - if ($('.modal').length || show_touch) return; - - if (!Storage.get('is_true_mobile', 'false') && Platform.screen('tv')) { - show_touch = true; - showModal$1(Lang.translate('input_detection_touch'), function () { - Storage.set('is_true_mobile', 'true'); - window.location.reload(); - }); - } - }).on('click', function (e) { - if ($('.modal').length || show_mouse || !canClick(e.originalEvent)) return; - - if (Storage.field('navigation_type') !== 'mouse' && Platform.screen('tv')) { - show_mouse = true; - showModal$1(Lang.translate('input_detection_mouse'), function () { - Storage.set('navigation_type', 'mouse'); - window.location.reload(); - }); - } - }); - Keypad.listener.follow('keydown', function () { - if ($('.modal').length || show_remote || document.activeElement.tagName == 'INPUT') return; - - if (Storage.get('is_true_mobile', 'false')) { - show_remote = true; - showModal$1(Lang.translate('input_detection_remote'), function () { - Storage.set('is_true_mobile', 'false'); - window.location.reload(); - }); - } - }); - } - - function canClick(e) { - //Noty.show('pointerType: ' + e.pointerType + '; type: ' + e.type + '; isTrusted: ' + e.isTrusted) - if (e && e.custom_trigger) return true; - return Date.now() - keydown_time < 500 ? false : touch || Platform.is('browser') || Platform.tv() || Platform.desktop() || Date.now() - move_time < 500; - } - - var DeviceInput = { - init: init$D, - canClick: canClick - }; - - function HeadBackward (title, use_js) { - var head = Template$1[use_js ? 'js' : 'get']('head_backward', { - title: title - }); - - if (use_js) { - head.querySelector('.head-backward__button').addEventListener('click', function () { - window.history.back(); - }); - head.querySelector('.head-backward__title').innerText = title; - } else { - head.find('.head-backward__button').on('click', function () { - window.history.back(); - }); - } - - return head; - } - - var html$j, active$6, _scroll, last$4; - - function open$6(params) { - active$6 = params; - html$j = Template$1.get('modal', { - title: params.title - }); - html$j.on('click', function (e) { - if (!$(e.target).closest($('.modal__content', html$j)).length && DeviceInput.canClick(e.originalEvent)) window.history.back(); - }); - title$1(params.title); - html$j.toggleClass('modal--medium', params.size == 'medium' ? true : false); - html$j.toggleClass('modal--large', params.size == 'large' ? true : false); - html$j.toggleClass('modal--full', params.size == 'full' ? true : false); - html$j.toggleClass('modal--overlay', params.overlay ? true : false); - html$j.toggleClass('modal--align-center', params.align == 'center' ? true : false); - if (params.zIndex) html$j.css('z-index', params.zIndex); - _scroll = new create$q({ - over: true, - mask: params.mask - }); - - _scroll.render().toggleClass('layer--height', params.size == 'full' ? true : false); - - html$j.find('.modal__body').append(_scroll.render()); - - if (Platform.screen('mobile') && params.size !== 'full') { - var close_button = $("
    \n \n \n \n
    "); - close_button.on('click', function () { - window.history.back(); - }); - html$j.find('.modal__content').prepend(close_button); - } - - bind$3(params.html); - - _scroll.onWheel = function (step) { - roll(step > 0 ? 'down' : 'up'); - }; - - if (params.size == 'full' && Platform.screen('mobile')) { - _scroll.append(HeadBackward(params.title || '')); - } - - _scroll.append(params.html); - - _scroll.addSwipeDown(function () { - html$j.addClass('animate-down'); - setTimeout(function () { - window.history.back(); - }, 200); - }); - - if (params.buttons) buttons(); - $('body').append(html$j); - max(); - toggle$a(params.select); - html$j.addClass('animate'); - } - - function max() { - _scroll.render().find('.scroll__content').css('max-height', Math.round(window.innerWidth <= 480 ? window.innerHeight * 0.6 : window.innerHeight - _scroll.render().offset().top - window.innerHeight * 0.1) + 'px'); - } - - function buttons() { - var footer = $(''); - active$6.buttons.forEach(function (button) { - var btn = $(''); - btn.text(button.name); - btn.on('click hover:enter', function () { - button.onSelect(); - }); - footer.append(btn); - }); - - _scroll.append(footer); - } - - function bind$3(where) { - where.find('.selector').on('hover:focus', function (e) { - last$4 = e.target; - - _scroll.update($(e.target)); - }).on('hover:enter', function (e) { - last$4 = e.target; - if (active$6.onSelect) active$6.onSelect($(e.target)); - }); - } - - function jump(tofoward) { - var select = _scroll.render().find('.selector.focus'); - - if (tofoward) select = select.nextAll().filter('.selector');else select = select.prevAll().filter('.selector'); - select = select.slice(0, 10); - select = select.last(); - - if (select.length) { - Controller.collectionFocus(select[0], _scroll.render()); - } - } - - function roll(direction) { - var select = _scroll.render().find('.selector'); - - if (select.length) { - Navigator.move(direction); - } else { - var step = Math.round(window.innerHeight * 0.15); - - _scroll.wheel(direction == 'down' ? step : -step); - } - } - - function toggle$a(need_select) { - Controller.add('modal', { - invisible: true, - toggle: function toggle() { - Controller.collectionSet(_scroll.render()); - Controller.collectionFocus(need_select || last$4, _scroll.render()); - Layer.visible(_scroll.render(true)); - }, - up: function up() { - roll('up'); - }, - down: function down() { - roll('down'); - }, - right: function right() { - if (Navigator.canmove('right')) Navigator.move('right');else jump(true); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else jump(false); - }, - back: function back() { - if (active$6.onBack) active$6.onBack(); - } - }); - Controller.toggle('modal'); - } - - function update$a(new_html) { - last$4 = false; - - _scroll.clear(); - - _scroll.append(new_html); - - bind$3(new_html); - max(); - toggle$a(active$6.select); - } - - function title$1(tit) { - html$j.find('.modal__title').text(tit); - html$j.toggleClass('modal--empty-title', tit ? false : true); - } - - function destroy$9() { - last$4 = false; - - _scroll.destroy(); - - html$j.remove(); - } - - function close$7() { - destroy$9(); - } - - function render$h() { - return html$j; - } - - var Modal = { - open: open$6, - close: close$7, - update: update$a, - title: title$1, - toggle: toggle$a, - render: render$h, - scroll: function scroll() { - return _scroll; - } - }; - - function init$C() { - var agent = navigator.userAgent.toLowerCase(); - - if (typeof webOS !== 'undefined' && webOS.platform.tv === true) { - Storage.set('platform', 'webos'); - webOS.deviceInfo(function (e) { - webOS.sdk_version = parseFloat(e.sdkVersion); - }); - } else if (typeof webapis !== 'undefined' && typeof tizen !== 'undefined') { - Storage.set('platform', 'tizen'); - tizen.tvinputdevice.registerKey("MediaPlayPause"); - tizen.tvinputdevice.registerKey("MediaPlay"); - tizen.tvinputdevice.registerKey("MediaStop"); - tizen.tvinputdevice.registerKey("MediaPause"); - tizen.tvinputdevice.registerKey("MediaRewind"); - tizen.tvinputdevice.registerKey("MediaFastForward"); - tizen.tvinputdevice.registerKey("ChannelUp"); - tizen.tvinputdevice.registerKey("ChannelDown"); - } else if (agent.indexOf("lampa_client") > -1) { - Storage.set('platform', 'android'); - } else if (agent.indexOf("whaletv") > -1 || agent.indexOf("philips") > -1 || agent.indexOf("nettv") > -1) { - Storage.set('platform', 'philips'); - } else if (agent.indexOf("ipad") > -1 && window.innerWidth == 1920 && window.innerHeight == 1080) { - Storage.set('platform', 'apple_tv'); - } else if (agent.indexOf("iphone") > -1 || agent.indexOf("mac os") > -1 && Utils$2.isTouchDevice() || agent.indexOf("macintosh") > -1 && Utils$2.isTouchDevice()) { - Storage.set('platform', 'apple'); - } else if (typeof nw !== 'undefined') { - Storage.set('platform', 'nw'); - } else if (agent.indexOf("electron") > -1) { - Storage.set('platform', 'electron'); - } else if (agent.indexOf("netcast") > -1) { - Storage.set('platform', 'netcast'); - } else if (agent.indexOf("version/5.1.7 safari/534.57.2") > -1) { - Storage.set('platform', 'orsay'); - } else if (agent.indexOf("windows nt") > -1 || agent.indexOf("macintosh") > -1 && !Utils$2.isTouchDevice()) { - Storage.set('platform', 'browser'); - } else if (agent.indexOf("maple") > -1) { - Storage.set('platform', 'orsay'); - Orsay.init(); - } else { - Storage.set('platform', ''); - } - - Storage.set('native', Storage.get('platform') ? true : false); - } - /** - * Какая платформа - * @returns String - */ - - - function get$d() { - return Storage.get('platform', ''); - } - /** - * Если это платформа - * @param {String} need - какая нужна? tizen, webos, android, orsay - * @returns Boolean - */ - - - function is(need) { - return get$d() == need ? true : false; - } - /** - * Если хоть одна из платформ tizen, webos, android - * @returns Boolean - */ - - - function any() { - return is('tizen') || is('webos') || is('android') || is('netcast') || is('orsay') || is('apple') || is('apple_tv') || macOS() || desktop() ? true : false; - } - /** - * Если это именно телек - * @returns Boolean - */ - - - function tv() { - return is('tizen') || is('webos') || is('orsay') || is('netcast') || is('apple_tv') ? true : false; - } - /** - * Если это NW.js или Electron - * @returns Boolean - */ - - - function desktop() { - return is('nw') || is('electron') ? true : false; - } - - function macOS() { - var agent = navigator.userAgent.toLowerCase(); - return agent.indexOf("mac os x") > -1 && !Utils$2.isTouchDevice(); - } - - function version(name) { - if (name == 'app') { - return object$2.app_version; - } else if (name == 'android') { - return AndroidJS.appVersion(); - } else if (name == 'orsay') { - return curWidget.version; - } else { - return ''; - } - } - - function screen(need) { - if (need == 'light') { - return Storage.field('light_version') && screen('tv'); - } - - var is_tv = true; - - if (!tv()) { - if (Storage.get('is_true_mobile', 'false')) is_tv = false;else if (Boolean(Storage.get('platform', '') == 'apple')) is_tv = false;else if (Boolean(navigator.userAgent.toLowerCase().match(/iphone|ipad/i))) is_tv = false;else if (Utils$2.isTouchDevice()) { - if (!Boolean(navigator.userAgent.toLowerCase().match(/(large screen)|googletv|mibox|mitv|smarttv|google tv/i))) { - var ratio = window.devicePixelRatio || 1; - var width = window.innerWidth * ratio; - var height = window.innerHeight * ratio; - is_tv = width > height && width >= 1280; - } - } - } - - if (need == 'tv') return is_tv; - if (need == 'mobile') return !is_tv; - return false; - } - - function install$2(what) { - var about = Template$1.get('about'); - if ($('.modal').length) Modal.close(); - - if (what == 'apk') { - $('> div:eq(0)', about).html(Lang.translate('install_app_apk_text')); - $('.about__contacts', about).empty(); - $('.about__rules', about).remove(); - $('.about__contacts', about).append("\n
    \n Telegram
    \n @lampa_plugins_uncensored\n
    \n "); - $('.about__contacts', about).append("\n
    \n ")); - Modal.open({ - title: '', - html: about, - size: 'medium', - onBack: function onBack() { - Modal.close(); - Controller.toggle('content'); - } - }); - } - } - - var Platform = { - init: init$C, - get: get$d, - any: any, - is: is, - tv: tv, - desktop: desktop, - version: version, - screen: screen, - install: install$2, - macOS: macOS - }; - - function create$p() { - var listener = start$8(); - var _calls = []; - - var _last; - - var last_reguest; - var need = { - timeout: 1000 * 60 - }; - - this.timeout = function (time) { - need.timeout = time; - }; - /** - * Видимый запрос - * @param {String} url адрес - * @param {Function} complite успешно - * @param {Function} error ошибка - * @param {Object} post_data данные для пост запроса - */ - - - this.get = function (url, _complite, _error, post_data) { - clear(); - go({ - url: url, - post_data: post_data, - start: function start() { - listener.send('start'); - }, - before_complite: function before_complite() { - listener.send('before_complite'); - }, - complite: function complite(data) { - if (_complite) _complite(data); - }, - after_complite: function after_complite() { - listener.send('after_complite'); - }, - before_error: function before_error() { - listener.send('before_error'); - }, - error: function error(data) { - if (_error) _error(data); - }, - after_error: function after_error() { - listener.send('after_error'); - }, - end: function end() { - listener.send('end'); - } - }); - }; - /** - * Тихий запрос, отработает в любом случае - * @param {String} url адрес - * @param {Function} complite успешно - * @param {Function} error ошибка - * @param {Object} post_data данные для пост запроса - * @param {Object} params дополнительные параметры - */ - - - this.quiet = function (url, _complite2, _error2, post_data, params) { - var add_params = {}; - - if (params) { - add_params = params; - } - - var data = { - url: url, - post_data: post_data, - complite: function complite(data) { - if (_complite2) _complite2(data); - }, - error: function error(data) { - if (_error2) _error2(data); - } - }; - Arrays.extend(data, add_params, true); - go(data); - }; - /** - * Бесшумный запрос, сработает прерывание при новом запросе - * @param {String} url адрес - * @param {Function} complite успешно - * @param {Function} error ошибка - * @param {Object} post_data данные для пост запроса - * @param {Object} params дополнительные параметры - */ - - - this.silent = function (url, complite, error, post_data, params) { - var add_params = {}; - - if (params) { - add_params = params; - } - - var reguest = { - url: url, - complite: complite, - error: error - }; - - _calls.push(reguest); - - var data = { - url: url, - post_data: post_data, - complite: function complite(data) { - if (_calls.indexOf(reguest) !== -1 && reguest.complite) reguest.complite(data); - }, - error: function error(data) { - if (_calls.indexOf(reguest) !== -1 && reguest.error) reguest.error(data); - }, - end: function end() { - listener.send('end'); - } - }; - Arrays.extend(data, add_params, true); - go(data); - }; - /** - * Отработать только последний запрос в стеке - * @param {String} url адрес - * @param {Function} complite успешно - * @param {Function} error ошибка - * @param {Object} post_data данные для пост запроса - */ - - - this.last = function (url, complite, error, post_data) { - var reguest = { - url: url, - complite: complite, - error: error - }; - _last = reguest; - go({ - url: url, - post_data: post_data, - complite: function complite(data) { - if (_last && _last.complite) _last.complite(data); - }, - error: function error(data) { - if (_last && _last.error) _last.error(data); - }, - end: function end() { - dispatchEvent({ - type: 'load:end' - }); - } - }); - }; - - this["native"] = function (url, complite, error, post_data, params) { - var add_params = {}; - - if (params) { - add_params = params; - } - - var reguest = { - url: url, - complite: complite, - error: error - }; - - _calls.push(reguest); - - var data = { - url: url, - post_data: post_data, - complite: function complite(data) { - if (_calls.indexOf(reguest) !== -1 && reguest.complite) reguest.complite(data); - }, - error: function error(data) { - if (_calls.indexOf(reguest) !== -1 && reguest.error) reguest.error(data); - }, - end: function end() { - listener.send('end'); - } - }; - Arrays.extend(data, add_params, true); - - _native(data); - }; - /** - * Очистить все запросы - */ - - - this.clear = function () { - _calls = []; - }; - /** - * Повторить запрос - * @param {Object} custom - */ - - - this.again = function (custom) { - if (custom || last_reguest) { - go(custom || last_reguest); - } - }; - /** - * Вернуть обьект последненго запроса - * @returns Object - */ - - - this.latest = function () { - return last_reguest; - }; - /** - * Декодировать ошибку в запросе - * @param {Object} jqXHR - * @param {String} exception - * @returns String - */ - - - this.errorDecode = function (jqXHR, exception) { - return errorDecode(jqXHR, exception); - }; - - function errorDecode(jqXHR, exception) { - if (!Arrays.isObject(jqXHR)) return Lang.translate('network_error'); - var msg = ''; - var txt = jqXHR.responseText || jqXHR.message || jqXHR.status || ''; - - if (jqXHR.status === 0 && exception !== 'timeout') { - msg = Lang.translate('network_noconnect'); - } else if (jqXHR.responseJSON && jqXHR.responseJSON.code) { - msg = Lang.translate('network_500').replace('500', jqXHR.responseJSON.code) + (jqXHR.responseJSON.text ? ' [' + jqXHR.responseJSON.text + ']' : ''); - } else if (jqXHR.status == 404) { - msg = Lang.translate('network_404'); - } else if (jqXHR.status == 401) { - msg = Lang.translate('network_401'); - } else if (jqXHR.status == 500) { - msg = Lang.translate('network_500'); - } else if (exception === 'parsererror') { - msg = Lang.translate('network_parsererror'); - } else if (exception === 'timeout') { - msg = Lang.translate('network_timeout'); - } else if (exception === 'abort') { - msg = Lang.translate('network_abort'); - } else if (exception === 'custom') { - msg = jqXHR.responseText; - } else { - msg = Lang.translate('network_error') + (txt ? ': ' + txt : ''); - } - - return msg; - } - /** - * Сделать запрос - * @param {Object} params - */ - - - function go(params) { - var error = function error(jqXHR, exception) { - console.log('Request', 'error of ' + params.url + ' :', errorDecode(jqXHR, exception)); - if (params.before_error) params.before_error(jqXHR, exception); - if (params.error) params.error(jqXHR, exception); - if (params.after_error) params.after_error(jqXHR, exception); - if (params.end) params.end(); - }; - - if (typeof params.url !== 'string' || !params.url) return error({ - status: 404 - }, ''); - listener.send('go'); - last_reguest = params; - if (params.start) params.start(); - - var secuses = function secuses(data) { - if (params.before_complite) params.before_complite(data); - - if (params.complite) { - try { - params.complite(data); - } catch (e) { - console.error('Request', 'complite error:', e.message + "\n\n" + e.stack); - Noty.show('Error: ' + (e.error || e).message + '

    ' + (e.error && e.error.stack ? e.error.stack : e.stack || '').split("\n").join('
    ')); - } - } - - if (params.after_complite) params.after_complite(data); - if (params.end) params.end(); - }; - - var datatype = params.dataType || 'json'; - var data = { - dataType: datatype, - url: params.url, - timeout: need.timeout, - crossDomain: true, - success: function success(data) { - if (datatype == 'json' && !data) error({ - status: 500 - });else secuses(data); - }, - error: error, - beforeSend: function beforeSend(xhr) { - var use = Storage.field('torrserver_auth'); - var srv = Storage.get(Storage.field('torrserver_use_link') == 'two' ? 'torrserver_url_two' : 'torrserver_url'); - - if (use && srv && params.url.indexOf(srv) >= 0) { - var authorization = "Basic " + Base64.encode(Storage.get('torrserver_login') + ':' + Storage.get('torrserver_password')); - console.log('Request', 'authorization:', authorization); - xhr.setRequestHeader("Authorization", authorization); - } - - if (params.beforeSend) { - xhr.setRequestHeader(params.beforeSend.name, params.beforeSend.value); - } - } - }; - - if (params.withCredentials) { - data.xhrFields = { - withCredentials: true - }; - } - - if (params.post_data) { - data.type = 'POST'; - data.data = params.post_data; - } - - if (params.type) data.type = params.type; - - if (params.headers) { - data.headers = params.headers; - } - - $.ajax(data); - need.timeout = 1000 * 60; - } - /** - * Сделать нативный Android запрос - * @param {Object} params - */ - - - function android_go(params) { - var error = function error(jqXHR, exception) { - console.log('Request', 'error of ' + params.url + ' :', errorDecode(jqXHR, exception)); - if (params.before_error) params.before_error(jqXHR, exception); - if (params.error) params.error(jqXHR, exception); - if (params.after_error) params.after_error(jqXHR, exception); - if (params.end) params.end(); - }; - - if (typeof params.url !== 'string' || !params.url) return error({ - status: 404 - }, ''); - listener.send('go'); - last_reguest = params; - if (params.start) params.start(); - - var secuses = function secuses(data) { - if (params.before_complite) params.before_complite(data); - - if (params.complite) { - try { - params.complite(data); - } catch (e) { - console.error('Request', 'complite error:', e.message + "\n\n" + e.stack); - Noty.show('Error: ' + (e.error || e).message + '

    ' + (e.error && e.error.stack ? e.error.stack : e.stack || '').split("\n").join('
    ')); - } - } - - if (params.after_complite) params.after_complite(data); - if (params.end) params.end(); - }; - - params.timeout = need.timeout; - Android.httpReq(params, { - complite: secuses, - error: error - }); - need.timeout = 1000 * 60; - } - - function _native(params) { - if (Platform.is('android')) android_go(params);else go(params); - } - } - - var components$2 = {}; - var params$2 = {}; - /** - * Добавить компонент - * @param {{component:string, icon:string, name:string}} data - */ - - function addComponent(data) { - components$2[data.component] = data; - Template$1.add('settings_' + data.component, '
    '); - } - /** - * Получить компонент - * @param {string} component - * @returns {{component:string, icon:string, name:string}} - */ - - - function getComponent(component) { - return components$2[component]; - } - /** - * Добавить параметр - * @param {{component:string, param:{name:string, type:string, values:string|object, default:string|boolean}, field:{name:string, description:string|undefined}, onRender:((item)=>void)|undefined, onChange?:((e)=>void)|undefined}} data - */ - - - function addParam(data) { - if (!params$2[data.component]) params$2[data.component] = []; - params$2[data.component].push(data); - if (data.param.type == 'select' || data.param.type == 'input') Params.select(data.param.name, data.param.values, data.param["default"]); - if (data.param.type == 'trigger') Params.trigger(data.param.name, data.param["default"]); - } - /** - * Получить параметры - * @param {string} component - * @returns {[{component:string, param:{name:string, type:string, values:string|object, default:string|boolean}, field:{name:string, description:string|undefined}, onRender:((item)=>void)|undefined, onChange?:((e)=>void)|undefined}]} - */ - - - function getParam(component) { - return params$2[component]; - } - /** - * Получить все компоненты - * @returns {{name:{component:string, icon:string, name:string}}} - */ - - - function allComponents() { - return components$2; - } - /** - * Получить все параметры - * @returns {{component:[{component:string, param:{name:string, type:string, values:string|object, default:string|boolean}, field:{name:string, description:string|undefined}, onRender:((item)=>void)|undefined, onChange?:((e)=>void)|undefined}]}} - */ - - - function allParams() { - return params$2; - } - - var SettingsApi = { - allComponents: allComponents, - allParams: allParams, - addComponent: addComponent, - addParam: addParam, - getComponent: getComponent, - getParam: getParam - }; - - var html$i; - var scroll$3; - var active$5; - - function init$B() { - html$i = Template$1.get('selectbox'); - scroll$3 = new create$q({ - mask: true, - over: true - }); - html$i.find('.selectbox__body').append(scroll$3.render()); - html$i.find('.selectbox__layer').on('click', function (e) { - if (DeviceInput.canClick(e.originalEvent)) window.history.back(); - }); - scroll$3.addSwipeDown(function () { - html$i.addClass('animate-down'); - setTimeout(function () { - window.history.back(); - }, 200); - }); - $('body').append(html$i); - } - - function bind$2() { - scroll$3.clear(); - html$i.find('.selectbox__title').text(active$5.title); - html$i.toggleClass('selectbox--fullsize', active$5.fullsize ? true : false); - active$5.items.forEach(function (element) { - if (element.hide) return; - element.title = Utils$2.capitalizeFirstLetter(element.title || ''); - - if (element.separator) { - var _item = $('
    ' + element.title + '
    '); - - return scroll$3.append(_item); - } - - var item = Template$1.get(element.template || 'selectbox_item', element); - if (!element.subtitle) item.find('.selectbox-item__subtitle').remove(); - - if (element.checkbox) { - item.addClass('selectbox-item--checkbox'); - item.append('
    '); - if (element.checked) item.addClass('selectbox-item--checked'); - } - - if (element.ghost) item.css('opacity', 0.5); - item.on('hover:focus', function (e) { - scroll$3.update($(e.target), true); - if (active$5.onFocus) active$5.onFocus(element, e.target); - }); - - if (!element.noenter) { - var goclose = function goclose() { - if (!active$5.nohide) hide$2();else { - scroll$3.render().find('.selected').removeClass('selected'); - item.addClass('selected'); - } - if (element.onSelect) element.onSelect(element, item);else if (active$5.onSelect) active$5.onSelect(element, item); - }; - - item.on('hover:enter', function () { - if (element.checkbox) { - element.checked = !element.checked; - item.toggleClass('selectbox-item--checked', element.checked); - if (element.onCheck) element.onCheck(element, item);else if (active$5.onCheck) active$5.onCheck(element, item); - } else if (active$5.onBeforeClose) { - if (active$5.onBeforeClose()) goclose(); - } else goclose(); - }).on('hover:long', function (e) { - if (active$5.onLong) active$5.onLong(element, e.target); - }); - } - - if (element.selected) item.addClass('selected'); - if (element.picked) item.addClass('picked'); - if (active$5.nomark) item.addClass('nomark'); - if (active$5.onDraw) active$5.onDraw(item, element); - scroll$3.append(item); - }); - if (active$5.onFullDraw) active$5.onFullDraw(scroll$3); - } - - function show$9(object) { - active$5 = object; - bind$2(); - $('body').toggleClass('selectbox--open', true); - html$i.find('.selectbox__body').addClass('layer--wheight').css('max-height', window.innerWidth <= 480 ? window.innerHeight * 0.6 : 'unset').data('mheight', html$i.find('.selectbox__head')); - html$i.addClass('animate'); - Activity$1.mixState('select=open'); - toggle$9(); - } - - function toggle$9() { - Controller.add('select', { - toggle: function toggle() { - var selected = scroll$3.render().find('.selected'); - Controller.collectionSet(html$i); - Controller.collectionFocus(selected.length ? selected[0] : false, html$i); - }, - up: function up() { - Navigator.move('up'); - }, - down: function down() { - Navigator.move('down'); - }, - left: close$6, - back: close$6 - }); - Controller.toggle('select'); - } - - function hide$2() { - $('body').toggleClass('selectbox--open', false); - html$i.removeClass('animate animate-down'); - } - - function close$6() { - hide$2(); - Activity$1.mixState(); - if (active$5.onBack) active$5.onBack(); - } - - function render$g() { - return html$i; - } - - var Select = { - init: init$B, - show: show$9, - hide: hide$2, - close: close$6, - render: render$g - }; - - var IndexedDB = /*#__PURE__*/function () { - function IndexedDB(database_name) { - var tables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - var version = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3; - - _classCallCheck(this, IndexedDB); - - this.listener = start$8(); - this.database_name = 'lampa_' + database_name; - this.tables = tables; - this.version = version; - this.db = null; - this.logs = true; - } - - _createClass(IndexedDB, [{ - key: "log", - value: function log(err, store_name, key) { - if (this.logs) console.log('DB', this.database_name + (store_name ? '_' + store_name : '') + (key ? ' -> [' + key + ']' : ''), err); - } - }, { - key: "openDatabase", - value: function openDatabase() { - var _this = this; - - return new Promise(function (resolve, reject) { - if (!('indexedDB' in window)) return _this.log('Not supported'), reject('Not supported'); - if (!_this.tables.length) return _this.log('No tables'), reject('No tables'); - var request = indexedDB.open(_this.database_name, _this.version); - - request.onerror = function (event) { - _this.log(request.error || 'An error occurred while opening the database'); - - reject(request.error || 'An error occurred while opening the database'); - }; - - request.onsuccess = function (event) { - _this.db = event.target.result; - resolve(); - }; - - request.onupgradeneeded = function (event) { - var db = event.target.result; - - _this.log('OnUpgradeNeeded'); - - _this.tables.forEach(function (name) { - if (!db.objectStoreNames.contains(name)) { - _this.log('Create table - ' + name); - - db.createObjectStore(name, { - keyPath: 'key' - }); - } - }); - }; - }); - } - }, { - key: "addData", - value: function addData(store_name, key, value) { - var _this2 = this; - - return new Promise(function (resolve, reject) { - if (!_this2.db) { - return _this2.log('Database not open', store_name, key), reject('Database not open'); - } - - var transaction = _this2.db.transaction([store_name], 'readwrite'); - - var objectStore = transaction.objectStore(store_name); - var addRequest = objectStore.add({ - key: key, - value: value, - time: Date.now() - }); - - addRequest.onerror = function (event) { - _this2.log(addRequest.error || 'An error occurred while adding data', store_name, key); - - reject(addRequest.error || 'An error occurred while adding data'); - }; - - addRequest.onsuccess = resolve; - }); - } - }, { - key: "getData", - value: function getData(store_name, key) { - var _this3 = this; - - var life_time = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1; - return new Promise(function (resolve, reject) { - if (!_this3.db) { - return _this3.log('Database not open', store_name, key), reject('Database not open'); - } - - var transaction = _this3.db.transaction([store_name], 'readonly'); - - var objectStore = transaction.objectStore(store_name); - var getRequest = key ? objectStore.get(key) : objectStore.getAll(); - - getRequest.onerror = function (event) { - _this3.log(getRequest.error || 'An error occurred while retrieving data', store_name, key); - - reject(getRequest.error || 'An error occurred while retrieving data'); - }; - - getRequest.onsuccess = function (event) { - var result = event.target.result; - - if (result) { - if (key) { - if (life_time == -1) resolve(result.value);else { - if (Date.now() < result.time + life_time * 1000 * 60) resolve(result.value);else resolve(null); - } - } else resolve(result.map(function (r) { - return r.value; - })); - } else { - resolve(null); - } - }; - }); - } - }, { - key: "getDataAnyCase", - value: function getDataAnyCase(store_name, key, life_time) { - var _this4 = this; - - return new Promise(function (resolve, reject) { - _this4.getData(store_name, key, life_time).then(resolve)["catch"](function () { - resolve(null); - }); - }); - } - }, { - key: "updateData", - value: function updateData(store_name, key, value) { - var _this5 = this; - - return new Promise(function (resolve, reject) { - if (!_this5.db) { - return _this5.log('Database not open', store_name, key), reject('Database not open'); - } - - var transaction = _this5.db.transaction([store_name], 'readwrite'); - - var objectStore = transaction.objectStore(store_name); - var getRequest = objectStore.get(key); - - getRequest.onerror = function (event) { - _this5.log(getRequest.error || 'An error occurred while updating data', store_name, key); - - reject(getRequest.error || 'An error occurred while updating data'); - }; - - getRequest.onsuccess = function (event) { - var result = event.target.result; - - if (result) { - result.value = value; - result.time = Date.now(); - var updateRequest = objectStore.put(result); - - updateRequest.onerror = function (event) { - _this5.log(updateRequest.error || 'An error occurred while updating data', store_name, key); - - reject(updateRequest.error || 'An error occurred while updating data'); - }; - - updateRequest.onsuccess = resolve; - } else { - _this5.log('No data found with the given key', store_name, key); - - reject('No data found with the given key'); - } - }; - }); - } - }, { - key: "rewriteData", - value: function rewriteData(store_name, key, value) { - var _this6 = this; - - return new Promise(function (resolve, reject) { - if (!_this6.db) { - return _this6.log('Database not open', store_name, key), reject('Database not open'); - } - - var transaction = _this6.db.transaction([store_name], 'readwrite'); - - var objectStore = transaction.objectStore(store_name); - var addRequest = objectStore.put({ - key: key, - value: value, - time: Date.now() - }); - - addRequest.onerror = function (event) { - _this6.log(addRequest.error || 'An error occurred while rewrite data', store_name, key); - - reject(addRequest.error || 'An error occurred while rewrite data'); - }; - - addRequest.onsuccess = resolve; - }); - } - }, { - key: "deleteData", - value: function deleteData(store_name, key) { - var _this7 = this; - - return new Promise(function (resolve, reject) { - if (!_this7.db) { - return _this7.log('Database not open', store_name, key), reject('Database not open'); - } - - var transaction = _this7.db.transaction([store_name], 'readwrite'); - - var objectStore = transaction.objectStore(store_name); - var deleteRequest = objectStore["delete"](key); - - deleteRequest.onerror = function (event) { - _this7.log(deleteRequest.error || 'An error occurred while deleting data', store_name, key); - - reject(deleteRequest.error || 'An error occurred while deleting data'); - }; - - deleteRequest.onsuccess = resolve; - }); - } - }, { - key: "clearTable", - value: function clearTable(store_name) { - var _this8 = this; - - return new Promise(function (resolve, reject) { - if (!_this8.db) { - return _this8.log('Database not open', store_name), reject('Database not open'); - } - - var transaction = _this8.db.transaction([store_name], 'readwrite'); - - var objectStore = transaction.objectStore(store_name); - var clearRequest = objectStore.clear(); - - clearRequest.onerror = function (event) { - _this8.log(clearRequest.error || 'An error occurred while clearing the table', store_name); - - reject(clearRequest.error || 'An error occurred while clearing the table'); - }; - - clearRequest.onsuccess = function () { - resolve(); - }; - }); - } - }, { - key: "clearAll", - value: function clearAll() { - var _this9 = this; - - return new Promise(function (resolve, reject) { - if (!_this9.db) { - return _this9.log('Database not open'), reject('Database not open'); - } - - var objectStoreNames = _this9.db.objectStoreNames; - var tableNames = Array.from(objectStoreNames); - tableNames.forEach(function (n) { - _this9.clearTable(n); - }); - resolve(); - }); - } - }]); - - return IndexedDB; - }(); - - var Cache = new IndexedDB('cache', ['screensavers', 'plugins', 'backgrounds', 'images', 'themes', 'other', 'timetable'], 5); - Cache.openDatabase(); - - function Component$1(name) { - var component_params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var scrl = new create$q({ - mask: true, - over: true, - step: 200 - }); - var comp = Template$1.get('settings_' + name); - var last; - /** - * Обновить скролл - */ - - function updateScroll() { - comp.find('.selector').unbind('hover:focus').on('hover:focus', function (e) { - last = e.target; - scrl.update($(e.target), true); - }).unbind('hover:hover hover:touch').on('hover:hover hover:touch', function (e) { - last = e.target; - }); - } - /** - * Билдим все события - */ - - - function buildEvents() { - if (!Platform.is('android')) { - comp.find('.is--android').remove(); - } - - if (!Platform.any()) { - comp.find('.is--player').remove(); - } - - if (!Platform.desktop() || Platform.macOS()) { - comp.find('.is--nw').remove(); - } - - if (!(Platform.is('android') || Platform.is('browser') || Platform.is('apple_tv') || Platform.desktop())) { - comp.find('.is--sound').remove(); - } - - if (!window.lampa_settings.lang_use) comp.find('[data-name="light_version"]').prev().remove(); - scrl.render().find('.scroll__content').addClass('layer--wheight').data('mheight', $('.settings__head')); - scrl.render().css('max-height', window.innerWidth <= 480 ? window.innerHeight * 0.6 : 'unset'); - var clear = comp.find('.clear-storage'); - clear.on('hover:enter', function () { - var controller = Controller.enabled().name; - var status = clear.find('.settings-param__descr'); - Select.show({ - title: Lang.translate('settings_rest_cache'), - items: [{ - title: Lang.translate('settings_rest_cache_calculate'), - calculate: true - }, { - title: Lang.translate('settings_rest_cache_only'), - subtitle: Lang.translate('settings_rest_cache_only_descr') - }, { - title: Lang.translate('settings_rest_cache_all'), - subtitle: Lang.translate('settings_rest_cache_all_descr'), - full: true - }], - onSelect: function onSelect(a) { - Controller.toggle(controller); - - if (a.calculate) { - Storage.getsize(function (size) { - status.text(Lang.translate('title_left') + ' - ' + Lampa.Utils.bytesToSize(size)); - }); - } else { - Storage.clear(a.full); - Cache.clearAll(); - } - }, - onBack: function onBack() { - Controller.toggle(controller); - } - }); - }); - Params.bind(comp.find('.selector'), comp); - Params.listener.follow('update_scroll', updateScroll); - Params.listener.follow('update_scroll_position', function () { - if (last) scrl.update($(last), true); - }); - updateScroll(); - } - /** - * Добавляем пользовательские параметры - */ - - - function addParams() { - var params = SettingsApi.getParam(name); - - if (params) { - params.forEach(function (data) { - var item; - - if (data.param.type == 'select') { - item = $("
    \n
    ").concat(data.field.name, "
    \n
    \n
    ")); - } - - if (data.param.type == 'trigger') { - item = $("
    \n
    ").concat(data.field.name, "
    \n
    \n
    ")); - } - - if (data.param.type == 'input') { - item = $("
    \n
    ").concat(data.field.name, "
    \n
    \n
    ")); - } - - if (data.param.type == 'title') { - item = $("
    ".concat(data.field.name, "
    ")); - } - - if (data.param.type == 'static') { - item = $("
    \n
    ".concat(data.field.name, "
    \n
    ")); - } - - if (data.param.type == 'button') { - item = $("
    \n
    ").concat(data.field.name, "
    \n
    ")); - } - - if (item) { - if (data.field.description) item.append("
    ".concat(data.field.description, "
    ")); - if (typeof data.onRender == 'function') data.onRender(item); - if (typeof data.onChange == 'function') item.data('onChange', data.onChange); - comp.append(item); - } - }); - } - } - /** - * Стартуем - */ - - - function start() { - addParams(); - buildEvents(); - if (typeof component_params.last_index !== 'undefined' && component_params.last_index > 0) last = comp.find('.selector').eq(component_params.last_index)[0]; - Controller.add('settings_component', { - toggle: function toggle() { - Controller.collectionSet(comp); - Controller.collectionFocus(last, comp); - }, - up: function up() { - Navigator.move('up'); - }, - down: function down() { - Navigator.move('down'); - }, - back: function back() { - scrl.destroy(); - comp.remove(); - Params.listener.remove('update_scroll', updateScroll); - if (component_params.onBack) component_params.onBack();else Controller.toggle('settings'); - } - }); - } - - start(); - /** - * Уничтожить - */ - - this.destroy = function () { - scrl.destroy(); - comp.remove(); - comp = null; - Params.listener.remove('update_scroll', updateScroll); - }; - /** - * Рендер - * @returns {object} - */ - - - this.render = function () { - scrl.append(comp); - return scrl.render(); - }; - } - - function Main$1() { - var _this = this; - - var comp; - var scrl = new create$q({ - mask: true, - over: true, - step: 200 - }); - var last; - /** - * Создать - */ - - this.create = function () { - comp = Template$1.get('settings_main'); - if (!window.lampa_settings.account_use) comp.find('[data-component="account"]').remove(); - if (!window.lampa_settings.plugins_use) comp.find('[data-component="plugins"]').remove(); - - if (!window.lampa_settings.torrents_use) { - comp.find('[data-component="parser"]').remove(); - comp.find('[data-component="server"]').remove(); - } - - scrl.render().css('max-height', window.innerWidth <= 480 ? window.innerHeight * 0.6 : 'unset'); - scrl.append(comp); - - _this.update(); - }; - /** - * Обновить события - */ - - - this.update = function () { - var components = SettingsApi.allComponents(); - - for (var name in components) { - var aded = components[name]; - - if (!comp.find('[data-component="' + name + '"]').length) { - var item = $("
    \n
    \n ").concat(aded.icon, "\n
    \n
    ").concat(aded.name, "
    \n
    ")); - comp.append(item); - } - } - - comp.find('.selector').unbind('hover:focus').on('hover:focus', function (event) { - last = event.target; - scrl.update($(event.target), true); - }).unbind('hover:hover hover:touch').on('hover:hover hover:touch', function (event) { - last = event.target; - Navigator.focused(event.target); - }).not('[data-static]').unbind('hover:enter').on('hover:enter', function (event) { - _this.render().detach(); - - _this.onCreate($(event.target).data('component')); - }); - }; - /** - * Сделать активным - */ - - - this.active = function () { - Controller.collectionSet(comp); - Controller.collectionFocus(last, comp); - scrl.height($('.settings__head')); - }; - /** - * Рендер - * @returns {object} - */ - - - this.render = function () { - return scrl.render(); - }; - } - - var html$h; - var body$3; - var listener$j = start$8(); - var last$3 = ''; - - var _main; - /** - * Запуск - */ - - - function init$A() { - html$h = Template$1.get('settings'); - body$3 = html$h.find('.settings__body'); - html$h.find('.settings__layer').on('click', function (e) { - if (DeviceInput.canClick(e.originalEvent)) window.history.back(); - }); - _main = new Main$1(); - _main.onCreate = create$o; - - _main.create(); - - Controller.add('settings', { - toggle: function toggle() { - _main.render().detach(); - - _main.update(); - - listener$j.send('open', { - name: 'main', - body: _main.render() - }); - body$3.empty().append(_main.render()); - - _main.active(); - - $('body').toggleClass('settings--open', true); - html$h.addClass('animate'); - Activity$1.mixState('settings=main'); - }, - up: function up() { - Navigator.move('up'); - }, - down: function down() { - Navigator.move('down'); - }, - left: function left() { - _main.render().detach(); - - Controller.toggle('content'); - }, - gone: function gone(to) { - if (to !== 'settings_component') { - $('body').toggleClass('settings--open', false); - html$h.removeClass('animate'); - } - }, - back: function back() { - _main.render().detach(); - - Controller.toggle('head'); - Activity$1.mixState(); - } - }); - } - /** - * Создать компонент - * @param {string} name - * @param {{last_index:integer}} params - */ - - - function create$o(name) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var comp = new Component$1(name, params); - body$3.empty().append(comp.render()); - listener$j.send('open', { - name: name, - body: comp.render(), - params: params - }); - last$3 = name; - Controller.toggle('settings_component'); - Activity$1.mixState('settings=' + name); - } - /** - * Обновить открытый компонент - */ - - - function update$9() { - var selects = body$3.find('.selector'); - var lastinx = selects.index(body$3.find('.selector.focus')); - create$o(last$3, { - last_index: lastinx - }); - } - /** - * Рендер - * @returns {object} - */ - - - function render$f() { - return html$h; - } - - var Settings = { - listener: listener$j, - init: init$A, - render: render$f, - update: update$9, - create: create$o, - main: function main() { - return _main; - } - }; - - function AVPlay$1(call_video) { - var stream_url, loaded; - console.log('Player', 'run Tizen'); - var object = $(''); - var video = object[0]; - var listener = start$8(); - var change_scale_later; - var change_speed_later; - object.width(window.innerWidth); - object.height(window.innerHeight); - /** - * Установить урл - */ - - Object.defineProperty(video, "src", { - set: function set(url) { - if (url) { - stream_url = url; - webapis.avplay.open(url); - webapis.avplay.setDisplayRect(0, 0, window.innerWidth, window.innerHeight); - webapis.avplay.setDisplayMethod('PLAYER_DISPLAY_MODE_LETTER_BOX'); - - try { - webapis.avplay.setSilentSubtitle(false); - } catch (e) {} - } - }, - get: function get() {} - }); - /** - * Позиция - */ - - Object.defineProperty(video, "currentTime", { - set: function set(t) { - try { - webapis.avplay.seekTo(t * 1000); - } catch (e) {} - }, - get: function get() { - var d = 0; - - try { - d = webapis.avplay.getCurrentTime(); - } catch (e) {} - - return d ? d / 1000 : 0; - } - }); - /** - * Длительность - */ - - Object.defineProperty(video, "duration", { - set: function set() {}, - get: function get() { - var d = 0; - - try { - d = webapis.avplay.getDuration(); - } catch (e) {} - - return d ? d / 1000 : 0; - } - }); - /** - * Пауза - */ - - Object.defineProperty(video, "paused", { - set: function set() {}, - get: function get() { - try { - return webapis.avplay.getState() == 'PAUSED'; - } catch (e) { - return false; - } - } - }); - /** - * Аудиодорожки - */ - - Object.defineProperty(video, "audioTracks", { - set: function set() {}, - get: function get() { - try { - var totalTrackInfo = webapis.avplay.getTotalTrackInfo(); - var tracks = totalTrackInfo.filter(function (track) { - return track.type === 'AUDIO'; - }).map(function (track) { - var info = JSON.parse(track.extra_info); - var item = { - extra: JSON.parse(track.extra_info), - index: parseInt(track.index), - language: info.language - }; - Object.defineProperty(item, "enabled", { - set: function set(v) { - if (v) { - try { - webapis.avplay.setSelectTrack('AUDIO', item.index); - } catch (e) { - console.log('Player', 'no change audio:', e.message); - } - } - }, - get: function get() {} - }); - return item; - }).sort(function (a, b) { - return a.index - b.index; - }); - return tracks; - } catch (e) { - return []; - } - } - }); - /** - * Субтитры - */ - - Object.defineProperty(video, "textTracks", { - set: function set() {}, - get: function get() { - try { - var totalTrackInfo = webapis.avplay.getTotalTrackInfo(); - var tracks = totalTrackInfo.filter(function (track) { - return track.type === 'TEXT'; - }).map(function (track) { - var info = JSON.parse(track.extra_info), - item = { - extra: JSON.parse(track.extra_info), - index: parseInt(track.index), - language: info.track_lang - }; - Object.defineProperty(item, "mode", { - set: function set(v) { - if (v == 'showing') { - try { - webapis.avplay.setSelectTrack('TEXT', item.index); - } catch (e) { - console.log('Player', 'no change text:', e.message); - } - } - }, - get: function get() {} - }); - return item; - }).sort(function (a, b) { - return a.index - b.index; - }); - console.log('Tizen', 'tracks', tracks); - console.log('Tizen', 'tracks index', tracks.map(function (a) { - return a.index; - })); - return tracks; - } catch (e) { - return []; - } - } - }); - /** - * Ширина видео - */ - - Object.defineProperty(video, "videoWidth", { - set: function set() {}, - get: function get() { - var info = videoInfo(); - return info.Width || 0; - } - }); - /** - * Высота видео - */ - - Object.defineProperty(video, "videoHeight", { - set: function set() {}, - get: function get() { - var info = videoInfo(); - return info.Height || 0; - } - }); - /** - * Получить информацию о видео - * @returns {object} - */ - - function videoInfo() { - try { - var info = webapis.avplay.getCurrentStreamInfo(), - json = {}; - - for (var i = 0; i < info.length; i++) { - var detail = info[i]; - - if (detail.type == 'VIDEO') { - json = JSON.parse(detail.extra_info); - } - } - - return json; - } catch (e) { - return {}; - } - } - /** - * Меняем размер видео - * @param {string} scale - default|cover - */ - - - function changeScale(scale) { - try { - if (scale == 'cover') { - webapis.avplay.setDisplayMethod('PLAYER_DISPLAY_MODE_FULL_SCREEN'); - } else { - webapis.avplay.setDisplayMethod('PLAYER_DISPLAY_MODE_LETTER_BOX'); - } - } catch (e) { - change_scale_later = scale; - } - } - - function changeSpeed(speed) { - try { - webapis.avplay.setSpeed(speed); - } catch (e) { - change_speed_later = speed; - } - } - /** - * Всегда говорим да, мы можем играть - */ - - - video.canPlayType = function () { - return true; - }; - /** - * Вешаем кастомные события - */ - - - video.addEventListener = listener.follow.bind(listener); - /** - * Вешаем события от плеера тайзен - */ - - webapis.avplay.setListener({ - onbufferingstart: function onbufferingstart() { - listener.send('progress', { - percent: 0 - }); - listener.send('waiting'); - }, - onbufferingprogress: function onbufferingprogress(percent) { - listener.send('progress', { - percent: percent - }); - }, - onbufferingcomplete: function onbufferingcomplete() { - listener.send('progress', { - percent: 0 - }); - listener.send('playing'); - }, - onstreamcompleted: function onstreamcompleted() { - webapis.avplay.stop(); - listener.send('ended'); - }, - oncurrentplaytime: function oncurrentplaytime() { - listener.send('timeupdate'); - - if (change_scale_later) { - change_scale_later = false; - changeScale(change_scale_later); - } - - if (change_speed_later) { - change_speed_later = false; - changeSpeed(change_speed_later); - } - }, - onerror: function onerror(eventType) { - listener.send('error', { - error: { - code: 'tizen', - message: eventType - } - }); - }, - onevent: function onevent(eventType, eventData) { - console.log('Player', 'event type:', eventType, 'data:', eventData); - }, - onsubtitlechange: function onsubtitlechange(duration, text, data3, data4) { - listener.send('subtitle', { - text: text - }); - }, - ondrmevent: function ondrmevent(drmEvent, drmData) {} - }); - /** - * Загрузить - */ - - video.load = function () { - if (stream_url) { - webapis.avplay.prepareAsync(function () { - loaded = true; - webapis.avplay.play(); - - try { - webapis.avplay.setSilentSubtitle(false); - } catch (e) {} - - listener.send('canplay'); - listener.send('playing'); - listener.send('loadeddata'); - }, function (e) { - listener.send('error', { - error: 'code [' + e.code + '] ' + e.message - }); - }); - } - }; - /** - * Играть - */ - - - video.play = function () { - if (loaded) webapis.avplay.play(); - }; - /** - * Пауза - */ - - - video.pause = function () { - if (loaded) webapis.avplay.pause(); - }; - /** - * Установить масштаб - */ - - - video.size = function (type) { - changeScale(type); - }; - /** - * Установить скорость - */ - - - video.speed = function (speed) { - changeSpeed(speed); - }; - /** - * Уничтожить - */ - - - video.destroy = function () { - try { - webapis.avplay.close(); - } catch (e) {} - - video.remove(); - listener.destroy(); - }; - - call_video(video); - return object; - } - - function create$n(object) { - this.state = object.state; - - this.start = function () { - this.dispath(this.state); - }; - - this.dispath = function (action_name) { - var action = object.transitions[action_name]; - - if (action) { - action.call(this); - } else { - console.log('invalid action'); - } - }; - } - - var listener$i = start$8(); - var status$3 = { - active: false, - channel: false, - select: false, - program: false - }; - var numpad = { - timer: false, - prev: '' - }; - - function init$z() { - Keypad.listener.follow('keydown', function (e) { - if (!playning()) return; - PlayerPanel.rewind(); //PG- - - if (e.code === 428 || e.code === 34 || e.code === 4 || e.code === 65) { - prevChannel(); - playDelay(); - } //PG+ - - - if (e.code === 427 || e.code === 33 || e.code === 5 || e.code === 68) { - nextChannel(); - playDelay(); - } - - var digid = 0; - if (e.code >= 48 && e.code <= 57) digid = e.code - 48;else if (e.code >= 96 && e.code <= 105) digid = e.code - 96; - - if (digid) { - clearTimeout(numpad.timer); - numpad.prev += digid; - toChannel(parseInt(numpad.prev)); - numpad.timer = setTimeout(function () { - play$3(); - numpad.prev = ''; - }, 2000); - } - }); - } - - function start$7(object) { - status$3.position_view = object.position; - status$3.position_channel = object.position; - status$3.active = object; - status$3.channel = channel$1(); - listener$i.send('channel', { - channel: status$3.channel, - dir: 0, - position: status$3.position_view - }); - if (status$3.active.onPlay) status$3.active.onPlay(status$3.channel); - listener$i.send('play', { - channel: status$3.channel, - position: status$3.position_view - }); - } - - function playning() { - return status$3.active; - } - - function channel$1(position) { - status$3.select = status$3.active.onGetChannel(position || status$3.position_view); - return status$3.select; - } - - function play$3() { - if (status$3.select !== status$3.channel) { - status$3.channel = status$3.select; - status$3.position_channel = status$3.position_view; - if (status$3.active.onPlay) status$3.active.onPlay(status$3.channel); - listener$i.send('play', { - channel: status$3.channel, - position: status$3.position_view - }); - } - } - - function playDelay() { - clearTimeout(status$3.timer); - status$3.timer = setTimeout(play$3, 2000); - } - - function reset$1() { - status$3.position_view = status$3.position_channel; - moveChannel(0); - } - - function programReady(data) { - setTimeout(function () { - if (status$3.select == data.channel) { - status$3.program = data; - status$3.position_program = data.position; - listener$i.send('draw-program', { - dir: 0 - }); - } - }, 10); - } - - function select$2() { - return status$3.select; - } - - function moveChannel(dir) { - channel$1(status$3.position_view); - listener$i.send('channel', { - channel: status$3.select, - dir: dir, - position: status$3.position_view - }); - } - - function nextChannel() { - if (status$3.position_view + 1 < status$3.active.total) { - status$3.position_view++; - moveChannel(1); - } - } - - function prevChannel() { - if (status$3.position_view - 1 >= 0) { - status$3.position_view--; - moveChannel(-1); - } - } - - function toChannel(num) { - num = Math.max(1, num); - - if (num <= status$3.active.total) { - status$3.position_view = num - 1; - moveChannel(1); - } - } - - function redrawChannel() { - moveChannel(0); - } - - function moveProgram(dir) { - if (status$3.program) { - status$3.position_program += dir; - status$3.position_program = Math.max(0, Math.min(status$3.program.total, status$3.position_program)); - listener$i.send('draw-program', { - dir: dir - }); - } - } - - function nextProgram() { - moveProgram(1); - } - - function prevProgram() { - moveProgram(-1); - } - - function drawProgram(container) { - status$3.active.onGetProgram(status$3.select, status$3.position_program, container); - } - - function playlistProgram() { - if (status$3.active.onPlaylistProgram) status$3.active.onPlaylistProgram(status$3.select, status$3.position_program); - } - - function openMenu() { - if (status$3.active.onMenu) status$3.active.onMenu(status$3.select, status$3.position_program);else if (status$3.active.onPlaylistProgram) status$3.active.onPlaylistProgram(status$3.select, status$3.position_program); - } - - function destroy$8() { - clearTimeout(status$3.timer); - clearTimeout(numpad.timer); - status$3 = { - active: false, - channel: false, - select: false, - program: false - }; - } - - var PlayerIPTV = { - listener: listener$i, - init: init$z, - start: start$7, - playning: playning, - channel: channel$1, - programReady: programReady, - reset: reset$1, - play: play$3, - select: select$2, - nextChannel: nextChannel, - prevChannel: prevChannel, - prevProgram: prevProgram, - nextProgram: nextProgram, - drawProgram: drawProgram, - playlistProgram: playlistProgram, - openMenu: openMenu, - redrawChannel: redrawChannel, - destroy: destroy$8 - }; - - function status$2(need) { - this.data = {}; - this.work = 0; - this.need = need; - this.complited = false; - - this.check = function () { - if (this.work >= this.need && !this.complited) { - this.complited = true; - this.onComplite(this.data); - } - }; - - this.append = function (name, json) { - this.work++; - this.data[name] = json; - this.check(); - }; - - this.error = function () { - this.work++; - this.check(); - }; - } - - var data$3 = []; - /** - * Запуск - */ - - function init$y() { - data$3 = Storage.cache('recomends_scan', 300, []); - setInterval(function () { - var history = Favorite.get({ - type: 'history' - }); - var added = 0; - console.log('Recomendations', 'find history:', history.length); - history.forEach(function (elem) { - if (['cub', 'tmdb'].indexOf(elem.source) >= 0) { - var id = data$3.filter(function (a) { - return a.id == elem.id; - }); - - if (!id.length) { - data$3.push({ - id: elem.id, - tv: elem.number_of_seasons || elem.seasons - }); - added++; - } - } - }); - console.log('Recomendations', 'added to scan:', added, 'ready:', data$3.length); - Storage.set('recomends_scan', data$3); - search$6(); - }, 120 * 1000); - } - - function search$6() { - var ids = data$3.filter(function (e) { - return !e.scan; - }); - - if (ids.length) { - var elem = ids[0]; - elem.scan = 1; - console.log('Recomendations', 'scan:', elem.id, elem.title || elem.name); - TMDB.get((elem.tv ? 'tv' : 'movie') + '/' + elem.id + '/recommendations', {}, function (json) { - console.log('Recomendations', 'result:', json.results && json.results.length ? json.results.length : 0); - - if (json.results && json.results.length) { - var recomend = Storage.cache('recomends_list', 100, []); - var favorite = Favorite.get({ - type: 'history' - }); - json.results.forEach(function (e) { - if (!recomend.filter(function (r) { - return r.id == e.id; - }).length && !favorite.filter(function (h) { - return h.id == e.id; - }).length) { - recomend.push(e); - } - }); - Storage.set('recomends_list', recomend); - } - }); - } else { - data$3.forEach(function (a) { - return a.scan = 0; - }); - } - - Storage.set('recomends_scan', data$3); - } - - function get$c(type) { - var all = Storage.get('recomends_list', '[]'); - var items = all.filter(function (e) { - return type == 'tv' ? e.number_of_seasons || e.first_air_date : !(e.number_of_seasons || e.first_air_date); - }).reverse(); - items.forEach(function (item) { - item.ready = false; - }); - return items; - } - - var Recomends = { - init: init$y, - get: get$c - }; - - var broken_images = 0; - - function proxy(name) { - var proxy = Storage.field(name); - - if (proxy.length > 0 && proxy.charAt(proxy.length - 1) == '/') { - proxy = proxy.substring(0, proxy.length - 1); - } - - return Utils$2.checkHttp(proxy); - } - - function api$2(url) { - var base = Utils$2.protocol() + 'api.themoviedb.org/3/' + url; - return Storage.field('proxy_tmdb') && Storage.field('tmdb_proxy_api') ? proxy('tmdb_proxy_api') + '/' + base : base; - } - - function image(url) { - var base = Utils$2.protocol() + 'image.tmdb.org/' + url; - return Storage.field('proxy_tmdb') && Storage.field('tmdb_proxy_image') ? proxy('tmdb_proxy_image') + '/' + base : base; - } - - function broken() { - broken_images++; - - if (broken_images > 50) { - broken_images = 0; - if (Storage.field('tmdb_proxy_image') && Storage.field('proxy_tmdb_auto')) Storage.set('proxy_tmdb', true); - } - } - - function key() { - return '4ef0d7355d9ffb5151e987764708ce96'; - } - - var TMDB$1 = { - api: api$2, - key: key, - image: image, - broken: broken - }; - - /** - * Карточка - * @param {object} data - * @param {{isparser:boolean, card_small:boolean, card_category:boolean, card_collection:boolean, card_wide:true}} params - */ - - function Episode(data) { - var card = data.card; - var episode = data.episode; - Arrays.extend(card, { - title: card.name, - original_title: card.original_name, - release_date: card.first_air_date - }); - card.release_year = ((card.release_date || '0000') + '').slice(0, 4); - - function remove(elem) { - if (elem) elem.remove(); - } - /** - * Загрузить шаблон - */ - - - this.build = function () { - this.card = Template$1.js('card_episode'); - this.img_poster = this.card.querySelector('.card__img') || {}; - this.img_episode = this.card.querySelector('.full-episode__img img') || {}; - this.card.querySelector('.card__title').innerText = card.title; - this.card.querySelector('.full-episode__name').innerText = episode.name || Lang.translate('noname'); - this.card.querySelector('.full-episode__num').innerText = episode.episode_number || ''; - this.card.querySelector('.full-episode__date').innerText = episode.air_date ? Utils$2.parseTime(episode.air_date).full : '----'; - - if (card.release_year == '0000') { - remove(this.card.querySelector('.card__age')); - } else { - this.card.querySelector('.card__age').innerText = card.release_year; - } - - this.card.addEventListener('visible', this.visible.bind(this)); - }; - /** - * Загрузить картинку - */ - - - this.image = function () { - var _this = this; - - this.img_poster.onload = function () {//this.card.classList.add('card--loaded') - }; - - this.img_poster.onerror = function () { - _this.img_poster.src = './img/img_broken.svg'; - }; - - this.img_episode.onload = function () { - _this.card.querySelector('.full-episode__img').classList.add('full-episode__img--loaded'); - }; - - this.img_episode.onerror = function () { - _this.img_episode.src = './img/img_broken.svg'; - }; - }; - /** - * Создать - */ - - - this.create = function () { - var _this2 = this; - - this.build(); - this.card.addEventListener('hover:focus', function () { - if (_this2.onFocus) _this2.onFocus(_this2.card, card); - }); - this.card.addEventListener('hover:hover', function () { - if (_this2.onHover) _this2.onHover(_this2.card, card); - }); - this.card.addEventListener('hover:enter', function () { - if (_this2.onEnter) _this2.onEnter(_this2.card, card); - }); - this.image(); - }; - /** - * Загружать картинку если видна карточка - */ - - - this.visible = function () { - if (card.poster_path) this.img_poster.src = Api.img(card.poster_path);else if (card.profile_path) this.img_poster.src = Api.img(card.profile_path);else if (card.poster) this.img_poster.src = card.poster;else if (card.img) this.img_poster.src = card.img;else this.img_poster.src = './img/img_broken.svg'; - if (episode.still_path) this.img_episode.src = Api.img(episode.still_path, 'w300');else if (card.backdrop_path) this.img_episode.src = Api.img(card.backdrop_path, 'w300');else this.img_episode.src = './img/img_broken.svg'; - if (this.onVisible) this.onVisible(this.card, card); - }; - /** - * Уничтожить - */ - - - this.destroy = function () { - this.img_poster.onerror = function () {}; - - this.img_poster.onload = function () {}; - - this.img_episode.onerror = function () {}; - - this.img_episode.onload = function () {}; - - this.img_poster.src = ''; - this.img_episode.src = ''; - remove(this.card); - this.card = null; - this.img_poster = null; - this.img_episode = null; - }; - /** - * Рендер - * @returns {object} - */ - - - this.render = function (js) { - return js ? this.card : $(this.card); - }; - } - - var network$a = new create$p(); - var menu_list = []; - var genres$1 = { - movie: [{ - "id": 28, - "title": "#{filter_genre_ac}" - }, { - "id": 12, - "title": "#{filter_genre_ad}" - }, { - "id": 16, - "title": "#{filter_genre_mv}" - }, { - "id": 35, - "title": "#{filter_genre_cm}" - }, { - "id": 80, - "title": "#{filter_genre_cr}" - }, { - "id": 99, - "title": "#{filter_genre_dc}" - }, { - "id": 18, - "title": "#{filter_genre_dr}" - }, { - "id": 10751, - "title": "#{filter_genre_fm}" - }, { - "id": 14, - "title": "#{filter_genre_fe}" - }, { - "id": 36, - "title": "#{filter_genre_hi}" - }, { - "id": 27, - "title": "#{filter_genre_ho}" - }, { - "id": 10402, - "title": "#{filter_genre_mu}" - }, { - "id": 9648, - "title": "#{filter_genre_de}" - }, { - "id": 10749, - "title": "#{filter_genre_md}" - }, { - "id": 878, - "title": "#{filter_genre_fa}" - }, { - "id": 10770, - "title": "#{filter_genre_tv}" - }, { - "id": 53, - "title": "#{filter_genre_tr}" - }, { - "id": 10752, - "title": "#{filter_genre_mi}" - }, { - "id": 37, - "title": "#{filter_genre_ve}" - }], - tv: [{ - "id": 10759, - "title": "#{filter_genre_aa}" - }, { - "id": 16, - "title": "#{filter_genre_mv}" - }, { - "id": 35, - "title": "#{filter_genre_cm}" - }, { - "id": 80, - "title": "#{filter_genre_cr}" - }, { - "id": 99, - "title": "#{filter_genre_dc}" - }, { - "id": 18, - "title": "#{filter_genre_dr}" - }, { - "id": 10751, - "title": "#{filter_genre_fm}" - }, { - "id": 10762, - "title": "#{filter_genre_ch}" - }, { - "id": 9648, - "title": "#{filter_genre_de}" - }, { - "id": 10763, - "title": "#{filter_genre_nw}" - }, { - "id": 10764, - "title": "#{filter_genre_rs}" - }, { - "id": 10765, - "title": "#{filter_genre_hf}" - }, { - "id": 10766, - "title": "#{filter_genre_op}" - }, { - "id": 10767, - "title": "#{filter_genre_tc}" - }, { - "id": 10768, - "title": "#{filter_genre_mp}" - }, { - "id": 37, - "title": "#{filter_genre_ve}" - }] - }; - - function url$5(u) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var ln = [Storage.field('tmdb_lang')]; - if (params.langs) ln = typeof params.langs == 'string' ? [params.langs] : ln.concat(params.langs.filter(function (n) { - return n !== ln[0]; - })); - u = add$b(u, 'api_key=' + TMDB$1.key()); - u = add$b(u, 'language=' + ln.join(',')); - if (params.genres && u.indexOf('with_genres') == -1) u = add$b(u, 'with_genres=' + params.genres); - if (params.page) u = add$b(u, 'page=' + params.page); - if (params.query) u = add$b(u, 'query=' + params.query); - if (params.keywords) u = add$b(u, 'with_keywords=' + params.keywords); - if (params.watch_region) u = add$b(u, 'watch_region=' + params.watch_region); - if (params.watch_providers) u = add$b(u, 'with_watch_providers=' + params.watch_providers); - if (params.networks) u = add$b(u, 'with_networks=' + params.networks); - if (params.sort_by) u = add$b(u, 'sort_by=' + params.sort_by); - - if (params.filter) { - for (var i in params.filter) { - u = add$b(u, i + '=' + params.filter[i]); - } - } // Добавляем проверку для запросов по жанрам - - - if (params.genres && u.indexOf('discover/') !== 0) { - u = 'discover/' + u; - } - - return TMDB$1.api(u); - } - - function add$b(u, params) { - return u + (/\?/.test(u) ? '&' : '?') + params; - } - - function img(src, size) { - var poster_size = Storage.field('poster_size'); - var baseimg = 't/p/' + poster_size + '/'; - var path = baseimg; - if (size) path = path.replace(new RegExp(poster_size, 'g'), size); - return src ? TMDB$1.image(path + src) : ''; - } - - function find(find) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var finded; - - var filtred = function filtred(items) { - for (var i = 0; i < items.length; i++) { - var item = items[i]; - - if (params.original_title == item.original_title || params.title == item.title) { - finded = item; - break; - } - } - }; - - if (find.movie && find.movie.results.length) filtred(find.movie.results); - if (find.tv && find.tv.results.length && !finded) filtred(find.tv.results); - return finded; - } - - function main$3() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - var parts_limit = 6; - var parts_data = [function (call) { - get$b('movie/now_playing', params, function (json) { - json.title = Lang.translate('title_now_watch'); - call(json); - }, call); - }, function (call) { - call({ - results: TimeTable.lately().slice(0, 20), - title: Lang.translate('title_upcoming_episodes'), - nomore: true, - cardClass: function cardClass(_elem, _params) { - return new Episode(_elem, _params); - } - }); - }, function (call) { - get$b('trending/movie/day', params, function (json) { - json.title = Lang.translate('title_trend_day'); - call(json); - }, call); - }, function (call) { - get$b('trending/movie/week', params, function (json) { - json.title = Lang.translate('title_trend_week'); - call(json); - }, call); - }, function (call) { - get$b('movie/upcoming', params, function (json) { - json.title = Lang.translate('title_upcoming'); - call(json); - }, call); - }, function (call) { - get$b('movie/popular', params, function (json) { - json.title = Lang.translate('title_popular_movie'); - call(json); - }, call); - }, function (call) { - get$b('trending/tv/week', params, function (json) { - json.title = Lang.translate('title_popular_tv'); - call(json); - }, call); - }, function (call) { - get$b('movie/top_rated', params, function (json) { - json.title = Lang.translate('title_top_movie'); - call(json); - }, call); - }, function (call) { - get$b('tv/top_rated', params, function (json) { - json.title = Lang.translate('title_top_tv'); - call(json); - }, call); - }]; - Arrays.insert(parts_data, 0, Api.partPersons(parts_data, parts_limit, 'movie')); - genres$1.movie.forEach(function (genre) { - var event = function event(call) { - get$b('discover/movie?with_genres=' + genre.id, params, function (json) { - json.title = Lang.translate(genre.title.replace(/[^a-z_]/g, '')); - call(json); - }, call); - }; - - parts_data.push(event); - }); - - function loadPart(partLoaded, partEmpty) { - Api.partNext(parts_data, parts_limit, partLoaded, partEmpty); - } - - loadPart(oncomplite, onerror); - return loadPart; - } - - function category$3() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - var fullcat = !(params.genres || params.keywords); - var show = ['movie', 'tv'].indexOf(params.url) > -1 && fullcat; - var books = show ? Favorite.continues(params.url) : []; - var recomend = show ? Arrays.shuffle(Recomends.get(params.url)).slice(0, 19) : []; - var parts_limit = 6; - var parts_data = [function (call) { - var json = { - results: books, - title: params.url == 'tv' ? Lang.translate('title_continue') : Lang.translate('title_watched') - }; - - if (params.url == 'tv') { - json.ad = 'notice', json.type = params.url; - } - - call(json); - }, function (call) { - if (params.url == 'tv' || params.url == 'anime') { - call({ - results: TimeTable.lately().slice(0, 20), - title: Lang.translate('title_upcoming_episodes'), - nomore: true, - cardClass: function cardClass(_elem, _params) { - return new Episode(_elem, _params); - } - }); - } else { - call(); - } - }, function (call) { - call({ - results: recomend, - title: Lang.translate('title_recomend_watch') - }); - }, function (call) { - if (params.url == 'movie') { - get$b('discover/' + params.url + '?with_release_type=3', params, function (json) { - json.title = Lang.translate('title_now_watch'); - call(json); - }, call); - } else call(); - }, function (call) { - get$b(params.url == 'movie' ? 'discover/movie' : 'trending/tv/day', params, function (json) { - json.title = Lang.translate('title_popular'); - - if (params.url == 'tv') { - json.ad = 'bot'; - json.type = params.url; - } - - call(json); - }, call); - }, function (call) { - get$b('discover/' + params.url + '?' + (params.url == 'movie' ? 'primary_release_year' : 'first_air_date_year') + '=' + (new Date().getFullYear() - 1), params, function (json) { - json.title = Lang.translate('title_last_year'); - call(json); - }, call); - }, function (call) { - var lte = new Date().getFullYear() - 2 + '-12-31'; - var gte = new Date().getFullYear() - 7 + '-01-01'; - var reg = params.url == 'movie' ? 'primary_release_date' : 'first_air_date'; - lte = reg + '.lte=' + lte; - gte = reg + '.gte=' + gte; - get$b('discover/' + params.url + '?' + lte + '&' + gte, params, function (json) { - json.title = Lang.translate('title_worth_rewatch'); - call(json); - }, call); - }, function (call) { - var lte = new Date().getFullYear() - 2 + '-12-31'; - var gte = new Date().getFullYear() - 7 + '-01-01'; - var reg = params.url == 'movie' ? 'primary_release_date' : 'first_air_date'; - lte = reg + '.lte=' + lte; - gte = reg + '.gte=' + gte; - get$b('discover/' + params.url + '?' + lte + '&' + gte + '&vote_average.gte=8&vote_average.lte=9', params, function (json) { - json.title = Lang.translate('title_hight_voite'); - call(json); - }, call); - }, function (call) { - if (params.genres) return call(); - - if (params.url == 'tv') { - get$b('trending/tv/week', params, function (json) { - json.title = Lang.translate('title_this_week'); - call(json); - }, call); - } else { - get$b('movie/upcoming', params, function (json) { - json.title = Lang.translate('title_upcoming'); - json.small = true; - json.wide = true; - json.results.forEach(function (card) { - card.promo = card.overview; - card.promo_title = card.title || card.name; - }); - call(json); - }, call); - } - }]; - if (fullcat) Arrays.insert(parts_data, 0, Api.partPersons(parts_data, parts_limit, params.url)); - genres$1[params.url].forEach(function (genre) { - var gen = params.genres ? [].concat(params.genres, genre.id) : [genre.id]; - if (params.genres && params.genres == genre.id) return; - - var event = function event(call) { - get$b('discover/' + params.url + '?with_genres=' + gen.join(','), params, function (json) { - json.title = Lang.translate(genre.title.replace(/[^a-z_]/g, '')); - call(json); - }, call); - }; - - parts_data.push(event); - }); - - function loadPart(partLoaded, partEmpty) { - Api.partNext(parts_data, parts_limit, partLoaded, partEmpty); - } - - loadPart(oncomplite, onerror); - return loadPart; - } - - function full$3() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - var status = new status$2(8); - status.onComplite = oncomplite; - if (Utils$2.dcma(params.method, params.id)) return onerror(); - get$b(params.method + '/' + params.id + '?append_to_response=content_ratings,release_dates,external_ids,keywords,alternative_titles', params, function (json) { - json.source = 'tmdb'; - - if (json.external_ids) { - json.imdb_id = json.external_ids.imdb_id; - } - - if (params.method == 'tv') { - var season = Utils$2.countSeasons(json); - get$b('tv/' + json.id + '/season/' + season, {}, function (ep) { - status.append('episodes', ep); - }, status.error.bind(status)); - } else status.need--; - - if (json.belongs_to_collection) { - get$b('collection/' + json.belongs_to_collection.id, {}, function (collection) { - collection.results = collection.parts.slice(0, 19); - status.append('collection', collection); - }, status.error.bind(status)); - } else status.need--; - - status.append('movie', json); - }, function () { - status.need -= 2; - status.error(); - }); - get$b(params.method + '/' + params.id + '/credits', params, function (json) { - status.append('persons', json); - }, status.error.bind(status)); - get$b(params.method + '/' + params.id + '/recommendations', params, function (json) { - status.append('recomend', json); - }, status.error.bind(status)); - get$b(params.method + '/' + params.id + '/similar', params, function (json) { - status.append('simular', json); - }, status.error.bind(status)); - videos(params, function (json) { - status.append('videos', json); - }, status.error.bind(status)); - Api.sources.cub.reactionsGet(params, function (json) { - status.append('reactions', json); - }); - - if (Lang.selected(['ru', 'uk', 'be'])) { - status.need++; - Api.sources.cub.discussGet(params, function (json) { - status.append('discuss', json); - }); - } - } - - function videos() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var lg = Storage.field('tmdb_lang'); - var status = new status$2(lg == 'en' ? 1 : 2); - - status.onComplite = function (res) { - var data = []; - if (res.one && res.one.results.length) data = data.concat(res.one.results); - if (res.two && res.two.results.length) data = data.concat(res.two.results); - oncomplite({ - results: data - }); - }; - - get$b(params.method + '/' + params.id + '/videos', { - langs: Storage.field('tmdb_lang') - }, function (json) { - status.append('one', json); - }, status.error.bind(status)); - - if (lg !== 'en') { - get$b(params.method + '/' + params.id + '/videos', { - langs: 'en' - }, function (json) { - status.append('two', json); - }, status.error.bind(status)); - } - } - - function list$4() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - var u = url$5(params.url, params); - network$a.silent(u, oncomplite, onerror); - } - - function get$b(method) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var oncomplite = arguments.length > 2 ? arguments[2] : undefined; - var onerror = arguments.length > 3 ? arguments[3] : undefined; - var u = url$5(method, params); - network$a.silent(u, function (json) { - json.url = method; - oncomplite(json); - }, onerror); - } - - function search$5() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var status = new status$2(3); - - status.onComplite = function (data) { - var items = []; - if (data.movie && data.movie.results.length) items.push(data.movie); - if (data.tv && data.tv.results.length) items.push(data.tv); - if (data.person && data.person.results.length) items.push(data.person); - oncomplite(items); - }; - - get$b('search/movie', params, function (json) { - json.title = Lang.translate('menu_movies'); - json.type = 'movie'; - status.append('movie', json); - }, status.error.bind(status)); - get$b('search/tv', params, function (json) { - json.title = Lang.translate('menu_tv'); - json.type = 'tv'; - status.append('tv', json); - }, status.error.bind(status)); - get$b('search/person', params, function (json) { - json.title = Lang.translate('title_actors'); - json.type = 'person'; - status.append('person', json); - }, status.error.bind(status)); - } - - function discovery$1() { - return { - title: 'TMDB', - search: search$5, - params: { - align_left: true, - object: { - source: 'tmdb' - } - }, - onMore: function onMore(params) { - Activity$1.push({ - url: 'search/' + params.data.type, - title: Lang.translate('search') + ' - ' + params.query, - component: 'category_full', - page: 2, - query: encodeURIComponent(params.query), - source: 'tmdb' - }); - }, - onCancel: network$a.clear.bind(network$a) - }; - } - - function person$2() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - - var sortCredits = function sortCredits(credits) { - return credits.map(function (a) { - a.year = parseInt(((a.release_date || a.first_air_date || '0000') + '').slice(0, 4)); - return a; - }).sort(function (a, b) { - return b.vote_average - a.vote_average && b.vote_count - a.vote_count; - }); //сортируем по оценке и кол-ву голосов (чтобы отсечь мусор с 1-2 оценками) - }; - - var convert = function convert(credits, person_data) { - if (params.only_credits) { - var cast = sortCredits(credits.cast); - var result = {}; - result[params.only_credits] = sortCredits(cast.filter(function (media) { - return media.media_type === params.only_credits; - })); - return result; - } else { - var department = ['directing', 'writing', 'editing', 'creator']; - credits.crew.forEach(function (a) { - a.department = Lang.translate(department.indexOf(a.department.toLowerCase()) == -1 ? 'settings_main_rest' : 'full_' + a.department.toLowerCase()); - }); - - var _cast = sortCredits(credits.cast), - crew = sortCredits(credits.crew), - tv = sortCredits(_cast.filter(function (media) { - return media.media_type === 'tv'; - })), - movie = sortCredits(_cast.filter(function (media) { - return media.media_type === 'movie'; - })), - knownFor; //Наиболее известные работы человека - //1. Группируем все работы по департаментам (Актер, Режиссер, Сценарист и т.д.) - - - knownFor = Arrays.groupBy(crew, 'department'); - if (movie.length > 0) knownFor[Lang.translate('menu_movies')] = movie; - if (tv.length > 0) knownFor[Lang.translate('menu_tv')] = tv; //2. Для каждого департамента суммируем кол-ва голосов (вроде бы сам TMDB таким образом определяет knownFor для людей) - - knownFor = Object.entries(knownFor).map(function (_ref) { - var _ref2 = _slicedToArray(_ref, 2), - depIdx = _ref2[0], - dep = _ref2[1]; - - //убираем дубликаты (человек может быть указан в одном департаменте несколько раз на разных должностях (job)) - var set = {}, - credits = dep.filter(function (credit) { - return set.hasOwnProperty(credit.original_title || credit.original_name) ? false : credit.original_title ? set[credit.original_title] = true : set[credit.original_name] = true; - }); - return { - name: depIdx, - credits: credits, - vote_count: dep.reduce(function (a, b) { - return a + b.vote_count; - }, 0) - }; //3. Сортируем департаменты по кол-ву голосов - }).sort(function (a, b) { - return b.credits.length - a.credits.length; - }); - return { - raw: credits, - cast: _cast, - crew: crew, - tv: tv, - movie: movie, - knownFor: knownFor - }; - } - }; - - var status = new status$2(params.only_credits ? 1 : 2); - - status.onComplite = function () { - var fulldata = {}; - if (status.data.person) fulldata.person = status.data.person; - if (status.data.credits) fulldata.credits = convert(status.data.credits, status.data.person || {}); - oncomplite(fulldata); - }; - - if (!params.only_credits) { - get$b('person/' + params.id, params, function (json) { - status.append('person', json); - }, status.error.bind(status)); - } - - get$b('person/' + params.id + '/combined_credits', params, function (json) { - status.append('credits', json); - }, status.error.bind(status)); - } - - function menu$2() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - if (menu_list.length) oncomplite(menu_list);else { - var u = url$5('genre/movie/list', params); - network$a.silent(u, function (j) { - j.genres.forEach(function (g) { - menu_list.push({ - title: g.name, - id: g.id - }); - }); - oncomplite(menu_list); - }); - } - } - - function menuCategory$2(params, oncomplite) { - var menu = []; - - if (params.action !== 'tv') { - menu.push({ - title: Lang.translate('title_now_watch'), - url: params.action + '/now_playing' - }); - } - - menu.push({ - title: Lang.translate('title_popular'), - url: params.action + '/popular' - }); - var date = new Date(); - var query = []; - query.push('sort_by=release_date.desc'); - query.push('year=' + date.getFullYear()); - query.push('first_air_date_year=' + date.getFullYear()); - query.push('vote_average.gte=7'); - menu.push({ - title: Lang.translate('title_new'), - url: 'discover/' + params.action + '?' + query.join('&') - }); - - if (params.action == 'tv') { - menu.push({ - title: Lang.translate('title_tv_today'), - url: params.action + '/airing_today' - }); - menu.push({ - title: Lang.translate('title_this_week'), - url: params.action + '/on_the_air' - }); - } - - menu.push({ - title: Lang.translate('title_in_top'), - url: params.action + '/top_rated' - }); - oncomplite(menu); - } - - function external_ids() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - get$b((params.type || 'tv') + '/' + params.id + '/external_ids', params, oncomplite, onerror); - } - - function external_imdb_id() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - get$b(params.type + '/' + params.id + '/external_ids', params, function (ids) { - oncomplite(ids.imdb_id || ''); - }, function () { - oncomplite(''); - }); - } - - function company$1() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - var status = new status$2(3); - - status.onComplite = function () { - function sortResultsByVoteAverage(results) { - return results.sort(function (a, b) { - return b.vote_average - a.vote_average; - }); - } - - if (status.data.company) { - var fulldata = { - company: status.data.company, - lines: [] - }; - if (status.data.movie && status.data.movie.results.length) fulldata.lines.push({ - nomore: true, - title: Lang.translate('menu_movies'), - results: sortResultsByVoteAverage(status.data.movie.results) - }); - if (status.data.tv && status.data.tv.results.length) fulldata.lines.push({ - nomore: true, - title: Lang.translate('menu_tv'), - results: sortResultsByVoteAverage(status.data.tv.results) - }); - oncomplite(fulldata); - } else onerror(); - }; - - get$b('company/' + params.id, params, function (json) { - status.append('company', json); - }, status.error.bind(status)); - get$b('discover/movie?sort_by=vote_count.desc&with_companies=' + params.id, params, function (json) { - status.append('movie', json); - }, status.error.bind(status)); - get$b('discover/tv?sort_by=vote_count.desc&with_companies=' + params.id, params, function (json) { - status.append('tv', json); - }, status.error.bind(status)); - } - - function seasons$2(tv, from, oncomplite) { - var status = new status$2(from.length); - status.onComplite = oncomplite; - from.forEach(function (season) { - get$b('tv/' + tv.id + '/season/' + season, {}, function (json) { - status.append('' + season, json); - }, status.error.bind(status)); - }); - } - - function parsePG(movie) { - var pg; - var cd = Storage.field('language'); - - if (movie.content_ratings) { - try { - var _find = movie.content_ratings.results.find(function (a) { - return a.iso_3166_1 == cd.toUpperCase(); - }); - - if (!_find) _find = movie.content_ratings.results.find(function (a) { - return a.iso_3166_1 == 'US'; - }); - if (_find) pg = Utils$2.decodePG(_find.rating); - } catch (e) {} - } - - if (movie.release_dates && !pg) { - var _find2 = movie.release_dates.results.find(function (a) { - return a.iso_3166_1 == cd.toUpperCase(); - }); - - if (!_find2) _find2 = movie.release_dates.results.find(function (a) { - return a.iso_3166_1 == 'US'; - }); - - if (_find2 && _find2.release_dates.length) { - pg = Utils$2.decodePG(_find2.release_dates[0].certification); - } - } - - if (movie.restrict) pg = movie.restrict + '+'; - return pg; - } - - function parseCountries(movie) { - var iso_countries = { - 'AD': Lang.translate('country_ad'), - 'AE': Lang.translate('country_ae'), - 'AF': Lang.translate('country_af'), - //'AG' : 'Antigua And Barbuda', - //'AI' : 'Anguilla', - 'AL': Lang.translate('country_al'), - 'AM': Lang.translate('country_am'), - //'AN' : 'Netherlands Antilles', - 'AO': Lang.translate('country_ao'), - //'AQ' : 'Antarctica', - 'AR': Lang.translate('country_ar'), - //'AS' : 'American Samoa', - 'AT': Lang.translate('country_at'), - 'AU': Lang.translate('country_au'), - 'AW': Lang.translate('country_aw'), - 'AZ': Lang.translate('country_az'), - 'BA': Lang.translate('country_ba'), - //'BB' : 'Barbados', - 'BD': Lang.translate('country_bd'), - 'BE': Lang.translate('country_be'), - //'BF' : 'Burkina Faso', - 'BG': Lang.translate('country_bg'), - 'BH': Lang.translate('country_bh'), - 'BI': Lang.translate('country_bi'), - 'BJ': Lang.translate('country_bj'), - //'BL' : 'Saint Barthelemy', - //'BM' : 'Bermuda', - //'BN' : 'Brunei Darussalam', - 'BO': Lang.translate('country_bo'), - 'BR': Lang.translate('country_br'), - 'BS': Lang.translate('country_bs'), - 'BT': Lang.translate('country_bt'), - //'BV' : 'Bouvet Island', - 'BW': Lang.translate('country_bw'), - 'BY': Lang.translate('country_by'), - //'BZ' : 'Belize', - 'CA': Lang.translate('country_ca'), - //'CC' : 'Cocos (Keeling) Islands', - //'CD' : 'Congo, Democratic Republic', - //'CF' : 'Central African Republic', - //'CG' : 'Congo', - 'CH': Lang.translate('country_ch'), - //'CI' : 'Cote D\'Ivoire', - //'CK' : 'Cook Islands', - 'CL': Lang.translate('country_cl'), - 'CM': Lang.translate('country_cm'), - 'CN': Lang.translate('country_cn'), - 'CO': Lang.translate('country_co'), - 'CR': Lang.translate('country_cr'), - 'CU': Lang.translate('country_cu'), - 'CV': Lang.translate('country_cv'), - //'CX' : 'Christmas Island', - 'CY': Lang.translate('country_cy'), - 'CZ': Lang.translate('country_cz'), - 'DE': Lang.translate('country_de'), - 'DJ': Lang.translate('country_dj'), - 'DK': Lang.translate('country_dk'), - //'DM' : 'Dominica', - 'DO': Lang.translate('country_do'), - 'DZ': Lang.translate('country_dz'), - 'EC': Lang.translate('country_ec'), - 'EE': Lang.translate('country_ee'), - 'EG': Lang.translate('country_eg'), - //'EH' : 'Western Sahara', - //'ER' : 'Eritrea', - 'ES': Lang.translate('country_es'), - 'ET': Lang.translate('country_et'), - 'FI': Lang.translate('country_fi'), - //'FJ' : 'Fiji', - //'FK' : 'Falkland Islands (Malvinas)', - //'FM' : 'Micronesia, Federated States Of', - 'FO': Lang.translate('country_fo'), - 'FR': Lang.translate('country_fr'), - 'GA': Lang.translate('country_ga'), - 'GB': Lang.translate('country_gb'), - //'GD' : 'Grenada', - 'GE': Lang.translate('country_ge'), - //'GF' : 'French Guiana', - //'GG' : 'Guernsey', - 'GH': Lang.translate('country_gh'), - //'GI' : 'Gibraltar', - 'GL': Lang.translate('country_gl'), - //'GM' : 'Gambia', - //'GN' : 'Guinea', - 'GP': Lang.translate('country_gp'), - //'GQ' : 'Equatorial Guinea', - 'GR': Lang.translate('country_gr'), - //'GS' : 'South Georgia And Sandwich Isl.', - 'GT': Lang.translate('country_gt'), - //'GU' : 'Guam', - //'GW' : 'Guinea-Bissau', - //'GY' : 'Guyana', - 'HK': Lang.translate('country_hk'), - //'HM' : 'Heard Island & Mcdonald Islands', - //'HN' : 'Honduras', - 'HR': Lang.translate('country_hr'), - 'HT': Lang.translate('country_ht'), - 'HU': Lang.translate('country_hu'), - 'ID': Lang.translate('country_id'), - 'IE': Lang.translate('country_ie'), - 'IL': Lang.translate('country_il'), - //'IM' : 'Isle Of Man', - 'IN': Lang.translate('country_in'), - //'IO' : 'British Indian Ocean Territory', - 'IQ': Lang.translate('country_iq'), - 'IR': Lang.translate('country_ir'), - 'IS': Lang.translate('country_is'), - 'IT': Lang.translate('country_it'), - //'JE' : 'Jersey', - 'JM': Lang.translate('country_jm'), - 'JO': Lang.translate('country_jo'), - 'JP': Lang.translate('country_jp'), - 'KE': Lang.translate('country_ke'), - 'KG': Lang.translate('country_kg'), - 'KH': Lang.translate('country_kh'), - //'KI' : 'Kiribati', - //'KM' : 'Comoros', - //'KN' : 'Saint Kitts And Nevis', - 'KP': Lang.translate('country_kp'), - 'KR': Lang.translate('country_kr'), - 'KW': Lang.translate('country_kw'), - //'KY' : 'Cayman Islands', - 'KZ': Lang.translate('country_kz'), - 'LA': Lang.translate('country_la'), - 'LB': Lang.translate('country_lb'), - //'LC' : 'Saint Lucia', - 'LI': Lang.translate('country_li'), - 'LK': Lang.translate('country_lk'), - 'LR': Lang.translate('country_lr'), - //'LS' : 'Lesotho', - 'LT': Lang.translate('country_lt'), - 'LU': Lang.translate('country_lu'), - 'LV': Lang.translate('country_lv'), - 'LY': Lang.translate('country_ly'), - 'MA': Lang.translate('country_ma'), - 'MC': Lang.translate('country_mc'), - 'MD': Lang.translate('country_md'), - 'ME': Lang.translate('country_me'), - //'MF' : 'Saint Martin', - //'MG' : 'Madagascar', - //'MH' : 'Marshall Islands', - 'MK': Lang.translate('country_mk'), - //'ML' : 'Mali', - 'MM': Lang.translate('country_mm'), - 'MN': Lang.translate('country_mn'), - 'MO': Lang.translate('country_mo'), - //'MP' : 'Northern Mariana Islands', - //'MQ' : 'Martinique', - //'MR' : 'Mauritania', - //'MS' : 'Montserrat', - 'MT': Lang.translate('country_mt'), - 'MU': Lang.translate('country_mu'), - 'MV': Lang.translate('country_mv'), - 'MW': Lang.translate('country_mw'), - 'MX': Lang.translate('country_mx'), - 'MY': Lang.translate('country_my'), - 'MZ': Lang.translate('country_mz'), - 'NA': Lang.translate('country_na'), - //'NC' : 'New Caledonia', - 'NE': Lang.translate('country_ne'), - //'NF' : 'Norfolk Island', - 'NG': Lang.translate('country_ng'), - 'NI': Lang.translate('country_ni'), - 'NL': Lang.translate('country_nl'), - 'NO': Lang.translate('country_no'), - 'NP': Lang.translate('country_np'), - //'NR' : 'Nauru', - //'NU' : 'Niue', - 'NZ': Lang.translate('country_nz'), - 'OM': Lang.translate('country_om'), - 'PA': Lang.translate('country_pa'), - 'PE': Lang.translate('country_pe'), - //'PF' : 'French Polynesia', - 'PG': Lang.translate('country_pg'), - 'PH': Lang.translate('country_ph'), - 'PK': Lang.translate('country_pk'), - 'PL': Lang.translate('country_pl'), - //'PM' : 'Saint Pierre And Miquelon', - //'PN' : 'Pitcairn', - 'PR': Lang.translate('country_pr'), - 'PS': Lang.translate('country_ps'), - 'PT': Lang.translate('country_pt'), - //'PW' : 'Palau', - 'PY': Lang.translate('country_py'), - 'QA': Lang.translate('country_qa'), - //'RE' : 'Reunion', - 'RO': Lang.translate('country_ro'), - 'RS': Lang.translate('country_rs'), - 'RU': Lang.translate('country_ru'), - 'RW': Lang.translate('country_rw'), - 'SA': Lang.translate('country_sa'), - //'SB' : 'Solomon Islands', - //'SC' : 'Seychelles', - 'SD': Lang.translate('country_sd'), - 'SE': Lang.translate('country_se'), - 'SG': Lang.translate('country_sg'), - //'SH' : 'Saint Helena', - 'SI': Lang.translate('country_si'), - //'SJ' : 'Svalbard And Jan Mayen', - 'SK': Lang.translate('country_sk'), - //'SL' : 'Sierra Leone', - //'SM' : 'San Marino', - 'SN': Lang.translate('country_sn'), - //'SO' : 'Somalia', - //'SR' : 'Suriname', - //'ST' : 'Sao Tome And Principe', - 'SU': Lang.translate('country_su'), - 'SV': Lang.translate('country_sv'), - 'SY': Lang.translate('country_sy'), - //'SZ' : 'Swaziland', - //'TC' : 'Turks And Caicos Islands', - //'TD' : 'Chad', - //'TF' : 'French Southern Territories', - //'TG' : 'Togo', - 'TH': Lang.translate('country_th'), - 'TJ': Lang.translate('country_tj'), - //'TK' : 'Tokelau', - //'TL' : 'Timor-Leste', - 'TM': Lang.translate('country_tm'), - 'TN': Lang.translate('country_tn'), - //'TO' : 'Tonga', - 'TR': Lang.translate('country_tr'), - //'TT' : 'Trinidad And Tobago', - //'TV' : 'Tuvalu', - 'TW': Lang.translate('country_tw'), - 'TZ': Lang.translate('country_tz'), - 'UA': Lang.translate('country_ua'), - 'UG': Lang.translate('country_ug'), - //'UM' : 'United States Outlying Islands', - 'US': Lang.translate('country_us'), - 'UY': Lang.translate('country_uy'), - 'UZ': Lang.translate('country_uz'), - //'VA' : 'Holy See (Vatican City State)', - //'VC' : 'Saint Vincent And Grenadines', - 'VE': Lang.translate('country_ve'), - //'VG' : 'Virgin Islands, British', - //'VI' : 'Virgin Islands, U.S.', - 'VN': Lang.translate('country_vn'), - //'VU' : 'Vanuatu', - //'WF' : 'Wallis And Futuna', - 'WS': Lang.translate('country_ws'), - 'YE': Lang.translate('country_ye'), - //'YT' : 'Mayotte', - 'YU': Lang.translate('country_yu'), - 'ZA': Lang.translate('country_za'), - 'ZM': Lang.translate('country_zm'), - 'ZW': Lang.translate('country_zw') - }; - return movie.production_countries ? movie.production_countries.map(function (a) { - //let cc = 'country_' + a.iso_3166_1.toLowerCase() - //return Lang.translate(cc) // FIXME! return a.name as fallback - if (iso_countries.hasOwnProperty(a.iso_3166_1)) { - return iso_countries[a.iso_3166_1]; - } else { - return a.name; - } - }) : ''; - } - - function getGenresNameFromIds(card_type, ids) { - var finded = []; - var where = genres$1[card_type]; - ids.forEach(function (a) { - var find = where.find(function (i) { - return i.id == a; - }); - if (find) finded.push(Utils$2.capitalizeFirstLetter(Lang.translate(find.title))); - }); - return finded; - } - - function clear$9() { - network$a.clear(); - } - - var TMDB = { - main: main$3, - menu: menu$2, - img: img, - full: full$3, - list: list$4, - category: category$3, - search: search$5, - clear: clear$9, - company: company$1, - person: person$2, - seasons: seasons$2, - find: find, - external_ids: external_ids, - get: get$b, - menuCategory: menuCategory$2, - discovery: discovery$1, - parsePG: parsePG, - parseCountries: parseCountries, - genres: genres$1, - external_imdb_id: external_imdb_id, - getGenresNameFromIds: getGenresNameFromIds, - videos: videos - }; - - var data$2 = []; - var object$1 = false; - var limit$2 = 300; - var started = Date.now(); - /** - * Запуск - */ - - function init$x() { - data$2 = Storage.cache('timetable', limit$2, []); - setInterval(extract$2, 1000 * 60 * (2)); - setInterval(favorites, 1000 * 60 * 10); - Favorite.listener.follow('add,added', function (e) { - if (e.card.number_of_seasons && e.where !== 'history') update$8(e.card); - }); - Favorite.listener.follow('remove', function (e) { - if (e.card.number_of_seasons && e.method == 'id') { - var find = data$2.find(function (a) { - return a.id == e.card.id; - }); - - if (find) { - Arrays.remove(data$2, find); - Storage.set('timetable', data$2); - Storage.remove('timetable', find.id); - } - } - }); - Lampa.Listener.follow('worker_storage', function (e) { - if (e.type == 'insert' && e.name == 'timetable') { - data$2 = Storage.get('timetable', '[]'); - } - }); - } - /** - * Добавить карточки к парсингу - * @param {[{id:integer,number_of_seasons:integer}]} elems - карточки - */ - - - function add$a(elems) { - if (started + 1000 * 60 * 2 > Date.now()) return; - var filtred = elems.filter(function (elem) { - return elem.number_of_seasons && typeof elem.id == 'number'; - }); - console.log('Timetable', 'add:', elems.length, 'filtred:', filtred.length); - filtred.forEach(function (elem) { - var find = data$2.find(function (a) { - return a.id == elem.id; - }); - - if (!find) { - data$2.push({ - id: elem.id, - season: elem.number_of_seasons, - episodes: [] - }); - } - }); - Storage.set('timetable', data$2); - } - /** - * Добавить из закладок - */ - - - function favorites() { - var category = ['like', 'wath', 'book', 'look', 'viewed', 'scheduled', 'continued', 'thrown']; - category.forEach(function (a) { - add$a(Favorite.get({ - type: a - })); - }); - } - - function filter(episodes) { - var filtred = []; - var fileds = ['air_date', 'season_number', 'episode_number', 'name', 'still_path']; - episodes.forEach(function (episode) { - var item = {}; - fileds.forEach(function (field) { - if (typeof episode[field] !== 'undefined') item[field] = episode[field]; - }); - filtred.push(item); - }); - return filtred; - } - /** - * Парсим карточку - */ - - - function parse$c(to_database) { - var check = Favorite.check(object$1); - var any = Favorite.checkAnyNotHistory(check); - console.log('Timetable', 'parse:', object$1.id, 'any:', any, 'season:', object$1.season); - - if (any || to_database) { - TMDB.get('tv/' + object$1.id + '/season/' + object$1.season, {}, function (ep) { - if (!ep.episodes) return save$5(); - object$1.episodes = filter(ep.episodes); - Cache.getData('timetable', object$1.id).then(function (obj) { - if (obj) obj.episodes = object$1.episodes;else obj = Arrays.clone(object$1); - Cache.rewriteData('timetable', object$1.id, obj).then(function () {})["catch"](function () {}); - })["catch"](function (e) {}); - save$5(); - }, save$5); - } else { - Arrays.remove(data$2, object$1); - Storage.remove('timetable', object$1.id); - save$5(); - } - } - /** - * Получить карточку для парсинга - */ - - - function extract$2() { - var ids = data$2.filter(function (e) { - return !e.scaned && (e.scaned_time || 0) + 60 * 60 * 12 * 1000 < Date.now(); - }); - console.log('Timetable', 'extract:', ids.length); - - if (ids.length) { - object$1 = ids[0]; - parse$c(); - } else { - data$2.forEach(function (a) { - return a.scaned = 0; - }); - } - - Storage.set('timetable', data$2); - } - /** - * Сохранить состояние - */ - - - function save$5() { - if (object$1) { - object$1.scaned = 1; - object$1.scaned_time = Date.now(); - Storage.set('timetable', data$2); - } - } - /** - * Получить эпизоды для карточки если есть - * @param {{id:integer}} elem - карточка - * @returns {array} - */ - - - function get$a(elem, callback) { - var fid = data$2.filter(function (e) { - return e.id == elem.id; - }); - var res = (fid.length ? fid[0] : {}).episodes || []; - - if (typeof callback == 'function') { - if (res.length) return callback(res); - Cache.getData('timetable', elem.id).then(function (obj) { - callback(obj ? obj.episodes || [] : []); - })["catch"](function (e) { - callback(res); - }); - } else { - return res; - } - } - /** - * Добавить карточку в парсинг самостоятельно - * @param {{id:integer,number_of_seasons:integer}} elem - карточка - */ - - - function update$8(elem) { - if (elem.number_of_seasons && typeof elem.id == 'number') { - var check = Favorite.check(elem); - var any = Favorite.checkAnyNotHistory(check); - var id = data$2.filter(function (a) { - return a.id == elem.id; - }); - var item = { - id: elem.id, - season: Utils$2.countSeasons(elem), - episodes: [] - }; - TMDB.clear(); - - if (any) { - if (!id.length) { - console.log('Timetable', 'push:', elem.id); - data$2.push(item); - Storage.set('timetable', data$2); - object$1 = item; - } else { - object$1 = id[0]; - object$1.season = Utils$2.countSeasons(elem); - } - - parse$c(); - } else { - object$1 = item; - parse$c(true); - } - } - } - /** - * Получить все данные - * @returns {[{id:integer,season:integer,episodes:[]}]} - */ - - - function all$3() { - return data$2; - } - - function lately() { - var fav = Favorite.full().card; - if (Account.working()) fav = Account.all(); - fav = fav.filter(function (f) { - return f.number_of_seasons; - }); - var now_date = new Date(); - now_date.setHours(0, 0, 0); - var now_time = now_date.getTime(); - var cards = []; - data$2.filter(function (d) { - return fav.find(function (c) { - return c.id == d.id; - }); - }).forEach(function (season) { - var episodes = season.episodes.filter(function (ep) { - return Lampa.Utils.parseToDate(ep.air_date).getTime() >= now_time; - }); - - if (episodes.length) { - cards.push({ - card: Arrays.clone(fav.find(function (c) { - return c.id == season.id; - })), - episode: episodes[0], - time: Lampa.Utils.parseToDate(episodes[0].air_date).getTime(), - season: season - }); - } - }); - cards = cards.sort(function (a, b) { - if (a.time > b.time) return 1;else if (a.time < b.time) return -1;else return 0; - }); - return cards; - } - - var TimeTable = { - init: init$x, - get: get$a, - add: add$a, - all: all$3, - update: update$8, - lately: lately - }; - - var listener$h = start$8(); - - function filename() { - var acc = Account.canSync(); - var name = 'file_view' + (acc ? '_' + acc.profile.id : ''); - - if (window.localStorage.getItem(name) === null && acc) { - Storage.set(name, Arrays.clone(Storage.cache('file_view', 10000, {}))); - } - - return name; - } - - function update$7(params) { - if (params.hash == 0) return; - var viewed = Storage.cache(filename(), 10000, {}); - var road = viewed[params.hash]; - - if (typeof road == 'undefined' || typeof road == 'number') { - road = { - duration: 0, - time: 0, - percent: 0, - profile: 0 - }; - viewed[params.hash] = road; - } - - road.percent = params.percent; - if (typeof params.time !== 'undefined') road.time = params.time; - if (typeof params.duration !== 'undefined') road.duration = params.duration; - if (typeof params.profile !== 'undefined') road.profile = params.profile; - Storage.set(filename(), viewed); - var line = $('.time-line[data-hash="' + params.hash + '"]').toggleClass('hide', params.percent ? false : true); - $('> div', line).css({ - width: params.percent + '%' - }); - $('.time-line-details[data-hash="' + params.hash + '"]').each(function () { - var f = format(road); - $(this).find('[a="t"]').text(f.time); - $(this).find('[a="p"]').text(f.percent); - $(this).find('[a="d"]').text(f.duration); - $(this).toggleClass('hide', road.duration ? false : true); - }); - listener$h.send('update', { - data: { - hash: params.hash, - road: road - } - }); - if (!params.received && Account.hasPremium()) Socket.send('timeline', { - params: params - }); - } - - function view$1(hash) { - var viewed = Storage.cache(filename(), 10000, {}), - curent = typeof viewed[hash] !== 'undefined' ? viewed[hash] : 0; - var account = Account.canSync(); - var profile = account && account.profile ? account.profile.id : 0; - var road = { - percent: 0, - time: 0, - duration: 0, - profile: 0 - }; - - if (_typeof(curent) == 'object') { - road.percent = curent.percent; - road.time = curent.time; - road.duration = curent.duration; - road.profile = curent.profile || profile; - } else { - road.percent = curent || 0; - road.profile = profile; - } - - listener$h.send('view', { - data: { - hash: hash, - road: road - } - }); - return { - hash: hash, - percent: road.percent, - time: road.time, - duration: road.duration, - profile: road.profile, - handler: function handler(percent, time, duration) { - return update$7({ - hash: hash, - percent: percent, - time: time, - duration: duration, - profile: road.profile - }); - } - }; - } - - function render$e(params) { - var line = Template$1.get('timeline', params); - line.toggleClass('hide', params.percent ? false : true); - return line; - } - - function details(params) { - var str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; - var line = Template$1.get('timeline_details', format(params)); - if (str) line.prepend(str); - line.attr('data-hash', params.hash); - line.toggleClass('hide', params.duration ? false : true); - return line; - } - - function watched(card) { - var hash = Lampa.Utils.hash(card.original_name ? [1, 1, card.original_name].join('') : card.original_title); - return view$1(hash).percent; - } - - function format(params) { - var road = { - percent: params.percent + '%', - time: Utils$2.secondsToTimeHuman(params.time), - duration: Utils$2.secondsToTimeHuman(params.duration) - }; - return road; - } - - var Timeline = { - listener: listener$h, - render: render$e, - update: update$7, - view: view$1, - details: details, - format: format, - watched: watched - }; - - function create$m(source) { - var timer, - html = $('
    '), - items = [], - active = 0, - query; - this.listener = start$8(); - - this.create = function () { - this.empty(); - }; - - this.empty = function () { - html.empty().append($('
    ' + Lang.translate(query ? 'search_nofound' : 'search_start_typing') + '
    ')); - }; - - this.loading = function () { - this.listener.send('start'); - html.empty().append($('
    ' + Lang.translate('search_searching') + '
    ')); - }; - - this.cancel = function () { - if (source.onCancel) source.onCancel(); - }; - - this.search = function (value, immediately) { - var _this = this; - - clearTimeout(timer); - - if (value.length >= 2) { - timer = setTimeout(function () { - if (query == value) return; - query = value; - - _this.loading(); - - source.search({ - query: encodeURIComponent(value) - }, function (data) { - _this.clear(); - - if (data.length > 0) { - html.empty(); - data.forEach(_this.build.bind(_this)); //Layer.visible(html) - } - - _this.listener.send('finded', { - count: data.length, - data: data - }); - }); - }, immediately ? 10 : 2500); - } else { - query = value; - this.clear(); - } - }; - - this.build = function (data) { - var _this2 = this; - - data.noimage = true; - source.params.card_view = 6; - var line = new create$h(data, source.params); - line.onDown = this.down.bind(this); - line.onUp = this.up.bind(this); - line.onBack = this.back.bind(this); - - line.onLeft = function () {}; - - line.onMore = function () { - if (source.onMore) source.onMore({ - data: data, - line: line, - query: query - }, function () { - _this2.listener.send('select'); - }); - }; - - if (source.onSelect) { - line.onSelect = function (e, element) { - source.onSelect({ - data: data, - line: line, - query: query, - element: element - }, function () { - _this2.listener.send('back'); - }); - }; - } else { - line.onEnter = function () { - _this2.listener.send('select'); - }; - } - - if (source.onRender) source.onRender(line); - if (source.onAppend) line.onAppend = source.onAppend; - line.create(); - items.push(line); - html.append(line.render()); - }; - - this.any = function () { - return items.length; - }; - - this.back = function () { - this.listener.send('back'); - }; - - this.down = function () { - active++; - active = Math.min(active, items.length - 1); - items[active].toggle(); - this.listener.send('toggle', { - element: items[active].render() - }); - }; - - this.up = function () { - active--; - if (active < 0) this.listener.send('up'); - - if (active < 0) { - active = 0; - } else { - items[active].toggle(); - this.listener.send('toggle', { - element: items[active].render() - }); - } - }; - - this.clear = function () { - this.empty(); - active = 0; - Arrays.destroy(items); - items = []; - }; - - this.toggle = function () { - var _this3 = this; - - Controller.add('search_results', { - invisible: true, - toggle: function toggle() { - Controller.collectionSet(html); - - if (items.length) { - items[active].toggle(); - - _this3.listener.send('toggle', { - element: items[active].render() - }); - } - }, - back: function back() { - _this3.listener.send('back'); - } - }); - Controller.toggle('search_results'); - }; - - this.render = function () { - return html; - }; - - this.destroy = function () { - clearTimeout(timer); - this.clear(); - this.listener.destroy(); - }; - } - - var stop_keys = ['пор', 'порн', 'порно', 'секс', 'член', 'por', 'porn', 'porno', 'sex', 'hot', 'xxx']; - - function create$l() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var scroll, last, active; - var html = $('
    '), - results = []; - this.listener = start$8(); - - this.create = function () { - scroll = new create$q({ - over: true, - mask: false, - horizontal: true - }); - var sources = params.sources || Api.availableDiscovery(); - sources.forEach(this.build.bind(this)); - - if (!params.sources) { - params.additional.forEach(this.build.bind(this)); - } - - this.enable(results[0]); - - if (results.length < 2) { - scroll.render().addClass('hide'); - html.addClass('search__results-offset'); - } - }; - - this.enable = function (result) { - if (active) active.render().detach(); - active = result; - html.empty().append(result.render()); - scroll.render().find('.search-source').removeClass('active').eq(results.indexOf(result)).addClass('active'); - Layer.visible(result.render()); - }; - - this.build = function (source) { - var _this = this; - - var tab = $('
    ' + source.title + '
    0
    '); - var result = new create$m(source); - result.create(); - result.listener.follow('start', function () { - tab.addClass('search-source--loading'); - tab.find('.search-source__count').html(' '); - }); - result.listener.follow('finded', function (e) { - tab.removeClass('search-source--loading'); - tab.find('.search-source__count').text(e.count); - if (active == result) Layer.visible(result.render()); - - _this.listener.send('finded', { - source: source, - result: result, - count: e.count, - data: e.data - }); - }); - result.listener.follow('up', function (e) { - if (results.length < 2) _this.listener.send('up');else _this.toggle(); - }); - result.listener.follow('select', this.listener.send.bind(this.listener, 'select')); - result.listener.follow('back', this.listener.send.bind(this.listener, 'back')); - result.listener.follow('toggle', function (e) { - _this.listener.send('toggle', { - source: source, - result: e.result, - element: e.element - }); - }); - tab.on('hover:enter', function () { - _this.enable(result); - }).on('hover:focus', function (e) { - last = e.target; - scroll.update($(e.target)); - }); - scroll.append(tab); - results.push(result); - this.listener.send('create', { - source: source, - result: result - }); - }; - - this.toggle = function (from_search) { - var _this2 = this; - - Controller.add('search_sources', { - toggle: function toggle() { - Controller.collectionSet(scroll.render()); - Controller.collectionFocus(last, scroll.render()); - if (from_search && results.length < 2 && active.any()) active.toggle(); - }, - update: function update() {}, - up: function up() { - _this2.listener.send('up'); - }, - down: function down() { - if (active.any()) active.toggle(); - }, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - Navigator.move('left'); - }, - back: function back() { - _this2.listener.send('back'); - } - }); - Controller.toggle('search_sources'); - }; - - this.search = function (query, immediately) { - results.forEach(function (result) { - return result.cancel(); - }); - - if (!stop_keys.find(function (k) { - return k == query.toLowerCase(); - })) { - this.listener.send('search', { - query: query, - immediately: immediately - }); - results.forEach(function (result) { - result.search(query, immediately); - }); - } - }; - - this.tabs = function () { - return scroll.render(); - }; - - this.render = function () { - return html; - }; - - this.destroy = function () { - scroll.destroy(); - results.forEach(function (result) { - return result.cancel(); - }); - this.listener.destroy(); - }; - } - - function create$k() { - var scroll, - last, - keys = []; - this.listener = start$8(); - - this.create = function () { - var _this = this; - - scroll = new create$q({ - over: true, - mask: false, - horizontal: true - }); - - scroll.onWheel = function (step) { - _this.toggle(); - - Controller.enabled().controller[step > 0 ? 'right' : 'left'](); - }; - - scroll.onScroll = function (step) {}; - - keys = Storage.get('search_history', '[]'); - keys.map(function (v) { - return v; - }).reverse().slice(0, 15).forEach(function (key) { - _this.append(key); - }); - if (!keys.length) scroll.append($('
    ' + Lang.translate('search_empty') + '
    ')); - }; - - this.append = function (value) { - var _this2 = this; - - var key = $('
    ' + value + '
    '); - key.on('hover:enter', function () { - _this2.listener.send('enter', { - value: value - }); - }).on('hover:focus', function (e) { - last = e.target; - scroll.update($(e.target), true); - }).on('hover:long', function () { - var selc = scroll.render().find('.selector'); - Arrays.remove(keys, value); - Storage.set('search_history', keys); - Storage.remove('search_history', value); - var index = selc.index(key); - if (index > 0) last = selc.eq(index - 1)[0];else if (selc[index + 1]) last = selc.eq(index + 1)[0]; - key.remove(); - if (selc.length - 1 <= 0) last = false; - Controller.collectionFocus(last, scroll.render()); - }); - scroll.append(key); - }; - - this.add = function (value) { - var inx = keys.indexOf(value); - - if (inx == -1) { - keys.push(value); - } else { - Arrays.remove(keys, value); - keys.push(value); - } - - Storage.set('search_history', keys); - }; - - this.toggle = function () { - var _this3 = this; - - Controller.add('search_history', { - toggle: function toggle() { - Controller.collectionSet(scroll.render()); - Controller.collectionFocus(last, scroll.render()); - }, - update: function update() {}, - up: function up() { - _this3.listener.send('up'); - }, - down: function down() { - _this3.listener.send('down'); - }, - right: function right() { - Navigator.move('right'); - }, - back: function back() { - _this3.listener.send('back'); - }, - left: function left() { - Navigator.move('left'); - } - }); - Controller.toggle('search_history'); - }; - - this.any = function () { - return keys.length; - }; - - this.render = function () { - return scroll.render(); - }; - - this.destroy = function () { - scroll.destroy(); - this.listener.destroy(); - keys = null; - last = null; - }; - } - - var html$g = $(''), - search$4, - history, - sources$1, - keyboard$1, - scroll$2, - input$1 = '', - params$1 = {}, - additional = [], - listener$g = start$8(); - - function open$5() { - var use_params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - params$1 = use_params; - input$1 = use_params.input || ''; - $('body').toggleClass('ambience--enable', true); - $('body').toggleClass('search--open', true); - create$j(); - toggle$8(); - Layer.update(html$g[0]); - listener$g.send('open'); - } - - function toggle$8() { - Controller.add('search', { - invisible: true, - toggle: function toggle() { - keyboard$1.toggle(); - }, - update: function update() {}, - back: destroy$7 - }); - Controller.toggle('search'); - } - - function scrollTo(element) { - scroll$2.update(element ? element : search$4.find('.search__input'), true); - } - - function create$j() { - search$4 = Template$1.get('search'); - scroll$2 = new create$q({ - step: 300 - }); - scroll$2.height(); - scroll$2.render().addClass('search'); - scroll$2.append(HeadBackward(Lang.translate('search'))); - scroll$2.append(search$4); - html$g.append(scroll$2.render()); - - scroll$2.onScroll = function (step) { - Layer.visible(scroll$2.render(true)); - }; - - if (Storage.field('keyboard_type') !== 'lampa') search$4.find('.search__input').hide(); - createKeyboard(); - createHistory(); - createSources(); - keyboard$1.value(input$1); - sources$1.search(input$1, true); - } - - function createSources() { - sources$1 = new create$l({ - sources: params$1.sources, - additional: additional - }); - listener$g.send('sources', { - sources: sources$1 - }); - sources$1.create(); - sources$1.listener.follow('back', destroy$7); - sources$1.listener.follow('up', function () { - if (history.any()) history.toggle();else keyboard$1.toggle(); - scrollTo(); - }); - sources$1.listener.follow('toggle', function (e) { - scrollTo(e.element); - }); - sources$1.listener.follow('select', function (e) { - if (input$1) history.add(input$1); - destroy$7(); - }); - search$4.find('.search__sources').append(sources$1.tabs()); - search$4.find('.search__results').append(sources$1.render()); - } - - function createHistory() { - history = new create$k(); - history.create(); - history.listener.follow('down', function () { - sources$1.toggle(true); - }); - history.listener.follow('up', function () { - keyboard$1.toggle(); - }); - history.listener.follow('enter', function (event) { - keyboard$1.value(event.value); - sources$1.search(event.value, true); - }); - history.listener.follow('back', destroy$7); - search$4.find('.search__history').append(history.render()); - } - - function createKeyboard() { - keyboard$1 = new create$2({ - layout: 'search' - }); - keyboard$1.create(); - keyboard$1.listener.follow('change', function (event) { - input$1 = event.value; - - if (input$1) { - search$4.find('.search__input').toggleClass('filled', true).html(input$1.replace(/\s/g, ' ')); - sources$1.search(input$1); - } else { - search$4.find('.search__input').toggleClass('filled', false).text(Lang.translate('search_input') + '...'); - } - }); - keyboard$1.listener.follow('down', function () { - if (history.any()) history.toggle();else sources$1.toggle(); - }); - keyboard$1.listener.follow('hover', function () { - sources$1.search(input$1); - }); - keyboard$1.listener.follow('back', destroy$7); - } - - function addSource(source) { - additional.push(source); - } - - function removeSource(source) { - Arrays.remove(additional, source); - } - - function render$d() { - return html$g; - } - - function destroy$7() { - keyboard$1.destroy(); - history.destroy(); - sources$1.destroy(); - search$4.remove(); - html$g.empty(); - $('body').toggleClass('ambience--enable', false); - $('body').toggleClass('search--open', false); - if (params$1.onBack) params$1.onBack();else Controller.toggle('content'); - params$1 = {}; - input$1 = ''; - listener$g.send('close'); - } - - function close$5() { - destroy$7(); - } - - var Search = { - listener: listener$g, - open: open$5, - render: render$d, - addSource: addSource, - removeSource: removeSource, - close: close$5 - }; - - var callback_cancel, controller_enabled, loader$1, timer$6; - - function start$6(on_cancel, text) { - callback_cancel = on_cancel; - controller_enabled = Controller.enabled().name; - loader$1 = $("
    \n
    \n
    ".concat(Lang.translate('loading'), "
    \n
    \n
    \n
    ")); - if (text) loader$1.find('.loading-layer__text').text(text); - loader$1.on('click', function (e) { - if (DeviceInput.canClick(e.originalEvent)) cancel(); - }); - clearTimeout(timer$6); - timer$6 = setTimeout(function () { - $('body').append(loader$1); - }, 500); - toggle$7(); - } - - function toggle$7() { - Controller.add('loading', { - invisible: true, - toggle: function toggle() {}, - back: cancel, - up: cancel, - down: cancel, - left: cancel, - right: cancel - }); - Controller.toggle('loading'); - } - - function cancel() { - if (callback_cancel) callback_cancel(); - } - - function stop() { - if (loader$1) loader$1.remove(); - clearTimeout(timer$6); - if (controller_enabled) Controller.toggle(controller_enabled); - } - - function setText(text) { - if (loader$1) loader$1.find('.loading-layer__text').text(text); - } - - var Loading = { - start: start$6, - stop: stop, - setText: setText - }; - - var canvas$1 = document.createElement('canvas'); - var ctx$1 = canvas$1.getContext('2d'); - var waiting = {}; - - function write(img, src) { - if (!Storage.field('cache_images')) return; - - if (src.indexOf('http') === 0) { - if (waiting[src]) return; - waiting[src] = true; - img.crossOrigin = "Anonymous"; - Cache.getData('images', src).then(function (str) { - if (!str || typeof src == 'string') { - setTimeout(function () { - canvas$1.width = img.naturalWidth || img.width; - canvas$1.height = img.naturalHeight || img.height; - - try { - ctx$1.drawImage(img, 0, 0, canvas$1.width, canvas$1.height); - canvas$1.toBlob(function (blob) { - Cache.addData('images', src, blob).then(function () { - console.log('ImagesCache', 'save to cache', src); - delete waiting[src]; - })["catch"](function () { - delete waiting[src]; - }); - }, 'image/jpeg', 1); - } catch (e) { - delete waiting[src]; - } - }, 1500 + Math.round(500 * Math.random())); - } else delete waiting[src]; - })["catch"](function (e) { - delete waiting[src]; - }); - } - } - - function read$2(img, src) { - if (Storage.field('cache_images')) { - Cache.getData('images', src).then(function (str) { - if (str) { - if (typeof str == 'string') img.src = str;else { - img.src = URL.createObjectURL(str); - } - } else img.src = src; - })["catch"](function () { - img.src = src; - }); - } else img.src = src; - } - - var ImageCache = { - write: write, - read: read$2 - }; - - /** - * Карточка - * @param {object} data - * @param {{isparser:boolean, card_small:boolean, card_category:boolean, card_collection:boolean, card_wide:true}} params - */ - - function Card(data) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - this.data = data; - this.params = params; - Arrays.extend(data, { - title: data.name, - original_title: data.original_name, - release_date: data.first_air_date - }); - data.release_year = ((data.release_date || data.birthday || '0000') + '').slice(0, 4); - - function remove(elem) { - if (elem) elem.remove(); - } - /** - * Загрузить шаблон - */ - - - this.build = function () { - this.card = Template$1.js(params.isparser ? 'card_parser' : 'card', data); - this.img = this.card.querySelector('.card__img') || {}; - this.card.card_data = data; - - if (params.isparser) { - var elem_title = this.card.querySelector('.card-parser__title'); - var elem_size = this.card.querySelector('.card-parser__size'); - var elem_details = this.card.querySelector('.card-parser__details'); - if (elem_title) elem_title.innerText = data.Title; - if (elem_size) elem_size.innerText = data.size; - var seeds = document.createElement('div'); - var grabs = document.createElement('div'); - elem_details.innerHTML = ''; - seeds.innerHTML = Lang.translate('torrent_item_seeds') + ': ' + data.Seeders + ''; - grabs.innerHTML = Lang.translate('torrent_item_grabs') + ': ' + data.Peers + ''; - elem_details.appendChild(seeds); - elem_details.appendChild(grabs); - } else { - var _elem_title = this.card.querySelector('.card__title'); - - if (_elem_title) _elem_title.innerText = data.title; - - if (data.first_air_date) { - var type_elem = document.createElement('div'); - type_elem.classList.add('card__type'); - type_elem.innerText = data.first_air_date ? 'TV' : 'MOV'; - this.card.querySelector('.card__view').appendChild(type_elem); - this.card.classList.add(data.first_air_date ? 'card--tv' : 'card--movie'); - } - - if (params.card_small) { - this.card.classList.add('card--small'); - remove(this.card.querySelector('.card__title')); - remove(this.card.querySelector('.card__age')); - } - - if (params.card_category) { - this.card.classList.add('card--category'); - } - - if (params.card_collection) { - this.card.classList.add('card--collection'); - remove(this.card.querySelector('.card__age')); - } - - if (params.card_wide) { - this.card.classList.add('card--wide'); - data.poster = data.cover; - - if (data.promo || data.promo_title) { - var promo_wrap = document.createElement('div'); - promo_wrap.classList.add('card__promo'); - - if (data.promo_title) { - var promo_title = document.createElement('div'); - promo_title.classList.add('card__promo-title'); - promo_title.innerText = data.promo_title; - promo_wrap.appendChild(promo_title); - } - - if (data.promo) { - var promo_text = document.createElement('div'); - promo_text.classList.add('card__promo-text'); - promo_text.innerText = data.promo.slice(0, 110) + (data.promo.length > 110 ? '...' : ''); - promo_wrap.appendChild(promo_text); - } - - this.card.querySelector('.card__view').appendChild(promo_wrap); - } - - if (Storage.field('light_version')) remove(this.card.querySelector('.card__title')); - remove(this.card.querySelector('.card__age')); - } - - if (data.release_year == '0000') { - remove(this.card.querySelector('.card__age')); - } else { - var year = this.card.querySelector('.card__age'); - if (year) year.innerText = data.release_year; - } - - var vote = parseFloat((data.vote_average || 0) + '').toFixed(1); - - if (vote > 0) { - var vote_elem = document.createElement('div'); - vote_elem.classList.add('card__vote'); - vote_elem.innerText = vote >= 10 ? 10 : vote; - this.card.querySelector('.card__view').appendChild(vote_elem); - } - - var qu = data.quality || data.release_quality; - - if (qu && Storage.field('card_quality')) { - var quality = document.createElement('div'); - quality.classList.add('card__quality'); - var quality_inner = document.createElement('div'); - quality_inner.innerText = qu; - quality.appendChild(quality_inner); - this.card.querySelector('.card__view').appendChild(quality); - } - } - - this.card.addEventListener('visible', this.visible.bind(this)); - this.card.addEventListener('update', this.update.bind(this)); - }; - /** - * Загрузить картинку - */ - - - this.image = function () { - var _this = this; - - if (params.isparser) return; - - this.img.onload = function () { - _this.card.classList.add('card--loaded'); - - ImageCache.write(_this.img, _this.img.src); - }; - - this.img.onerror = function () { - TMDB$1.broken(); - console.log('Img', 'noload', _this.img.src); - _this.img.src = './img/img_broken.svg'; - }; - }; - /** - * Добавить иконку - * @param {string} name - */ - - - this.addicon = function (name) { - var icon = document.createElement('div'); - icon.classList.add('card__icon'); - icon.classList.add('icon--' + name); - this.card.querySelector('.card__icons-inner').appendChild(icon); - }; - /** - * Обносить состояние карточки - */ - - - this.update = function () { - if (params.isparser) return; - this.watched_checked = false; - if (this.watched_wrap) remove(this.watched_wrap); - this.favorite(); - if (this.card.classList.contains('focus')) this.watched(); - }; - /** - * Какие серии просмотрено - */ - - - this.watched = function () { - var _this2 = this; - - if (!Storage.field('card_episodes')) return; - - if (!this.watched_checked) { - TimeTable.get(data, function (episodes) { - var viewed; - episodes.forEach(function (ep) { - var hash = Utils$2.hash([ep.season_number, ep.season_number > 10 ? ':' : '', ep.episode_number, data.original_title].join('')); - var view = Timeline.view(hash); - if (view.percent) viewed = { - ep: ep, - view: view - }; - }); - - if (viewed) { - var soon = []; - var next = episodes.slice(episodes.indexOf(viewed.ep)).filter(function (ep) { - return ep.air_date; - }).filter(function (ep) { - var date = Utils$2.parseToDate(ep.air_date).getTime(); - if (date > Date.now()) soon.push(ep); - return date < Date.now(); - }).slice(0, 5); - if (next.length == 0) next = [viewed.ep]; - if (soon.length) next.push(soon[0]); - var wrap = Template$1.js('card_watched', {}); - next.forEach(function (ep) { - var div = document.createElement('div'); - var span = document.createElement('span'); - var date = Utils$2.parseToDate(ep.air_date); - var now = Date.now(); - var days = Math.ceil((date.getTime() - now) / (24 * 60 * 60 * 1000)); - div.classList.add('card-watched__item'); - div.appendChild(span); - span.innerText = ep.episode_number + ' - ' + (days > 0 ? Lang.translate('full_episode_days_left') + ': ' + days : ep.name || Lang.translate('noname')); - if (ep == viewed.ep) div.appendChild(Timeline.render(viewed.view)[0]); - wrap.querySelector('.card-watched__body').appendChild(div); - }); - _this2.watched_wrap = wrap; - - var view = _this2.card.querySelector('.card__view'); - - view.insertBefore(wrap, view.firstChild); - } - }); - this.watched_checked = true; - } - }; - /** - * Обновить иконки на закладки - */ - - - this.favorite = function () { - var status = Favorite.check(data); - var marker = this.card.querySelector('.card__marker'); - var marks = ['look', 'viewed', 'scheduled', 'continued', 'thrown']; - this.card.querySelector('.card__icons-inner').innerHTML = ''; - if (status.book) this.addicon('book'); - if (status.like) this.addicon('like'); - if (status.wath) this.addicon('wath'); - if (status.history || Timeline.watched(data)) this.addicon('history'); - var any_marker = marks.find(function (m) { - return status[m]; - }); - - if (any_marker) { - if (!marker) { - marker = document.createElement('div'); - marker.addClass('card__marker'); - marker.append(document.createElement('span')); - this.card.querySelector('.card__view').append(marker); - } - - marker.find('span').text(Lang.translate('title_' + any_marker)); - marker.removeClass(marks.map(function (m) { - return 'card__marker--' + m; - }).join(' ')).addClass('card__marker--' + any_marker); - } else if (marker) marker.remove(); - }; - /** - * Вызвали меню - * @param {object} target - * @param {object} data - */ - - - this.onMenu = function (target, data) { - var _this3 = this; - - var enabled = Controller.enabled().name; - var status = Favorite.check(data); - var menu_plugins = []; - var menu_favorite = [{ - title: Lang.translate('title_book'), - where: 'book', - checkbox: true, - checked: status.book - }, { - title: Lang.translate('title_like'), - where: 'like', - checkbox: true, - checked: status.like - }, { - title: Lang.translate('title_wath'), - where: 'wath', - checkbox: true, - checked: status.wath - }, { - title: Lang.translate('menu_history'), - where: 'history', - checkbox: true, - checked: status.history - }, { - title: Lang.translate('settings_cub_status'), - separator: true - }]; - var marks = ['look', 'viewed', 'scheduled', 'continued', 'thrown']; - marks.forEach(function (m) { - menu_favorite.push({ - title: Lang.translate('title_' + m), - where: m, - picked: status[m], - collect: true, - noenter: !Account.hasPremium() - }); - }); - object$2.plugins.forEach(function (plugin) { - if (plugin.type == 'video' && plugin.onContextMenu && plugin.onContextLauch) { - menu_plugins.push({ - title: plugin.name, - subtitle: plugin.subtitle || plugin.description, - onSelect: function onSelect() { - if (document.body.classList.contains('search--open')) Search.close(); - - if (!data.imdb_id && data.source == 'tmdb') { - Loading.start(function () { - Loading.stop(); - Controller.toggle(enabled); - }); - TMDB.external_imdb_id({ - type: data.name ? 'tv' : 'movie', - id: data.id - }, function (imdb_id) { - Loading.stop(); - data.imdb_id = imdb_id; - plugin.onContextLauch(data); - }); - } else plugin.onContextLauch(data); - } - }); - } - }); - if (menu_plugins.length) menu_plugins.push({ - title: Lang.translate('more'), - separator: true - }); - var menu_main = menu_plugins.length ? menu_plugins.concat(menu_favorite) : menu_favorite; - if (this.onMenuShow) this.onMenuShow(menu_main, this.card, data); - Select.show({ - title: Lang.translate('title_action'), - items: menu_main, - onBack: function onBack() { - Controller.toggle(enabled); - }, - onCheck: function onCheck(a) { - if (params.object) data.source = params.object.source; - - if (a.where) { - Favorite.toggle(a.where, data); - - _this3.favorite(); - } - }, - onSelect: function onSelect(a) { - if (params.object) data.source = params.object.source; - - if (a.collect) { - Favorite.toggle(a.where, data); - - _this3.favorite(); - } - - if (_this3.onMenuSelect) _this3.onMenuSelect(a, _this3.card, data); - Controller.toggle(enabled); - }, - onDraw: function onDraw(item, elem) { - if (elem.collect) { - if (!Account.hasPremium()) { - var wrap = $('
    '); - wrap.append(Template$1.js('icon_lock')); - item.find('.selectbox-item__checkbox').remove(); - item.append(wrap); - item.on('hover:enter', function () { - Select.close(); - Account.showCubPremium(); - }); - } - } - } - }); - }; - /** - * Создать - */ - - - this.create = function () { - var _this4 = this; - - this.build(); - this.card.addEventListener('hover:focus', function () { - _this4.watched(); - - if (_this4.onFocus) _this4.onFocus(_this4.card, data); - }); - this.card.addEventListener('hover:touch', function () { - _this4.watched(); - - if (_this4.onTouch) _this4.onTouch(_this4.card, data); - }); - this.card.addEventListener('hover:hover', function () { - _this4.watched(); - - if (_this4.onHover) _this4.onHover(_this4.card, data); - }); - this.card.addEventListener('hover:enter', function () { - if (_this4.onEnter) _this4.onEnter(_this4.card, data); - }); - this.card.addEventListener('hover:long', function () { - if (_this4.onMenu) _this4.onMenu(_this4.card, data); - }); - this.image(); - }; - /** - * Загружать картинку если видна карточка - */ - - - this.visible = function () { - var src = ''; - if (params.card_wide && data.backdrop_path) src = Api.img(data.backdrop_path, 'w780');else if (params.card_collection && data.backdrop_path) src = Api.img(data.backdrop_path, 'w500');else if (data.poster_path) src = Api.img(data.poster_path);else if (data.profile_path) src = Api.img(data.profile_path);else if (data.poster) src = data.poster;else if (data.img) src = data.img;else src = './img/img_broken.svg'; - ImageCache.read(this.img, src); - this.update(); - if (this.onVisible) this.onVisible(this.card, data); - }; - /** - * Уничтожить - */ - - - this.destroy = function () { - this.img.onerror = function () {}; - - this.img.onload = function () {}; - - this.img.src = ''; - remove(this.card); - this.card = null; - this.img = null; - }; - /** - * Рендер - * @returns {object} - */ - - - this.render = function (js) { - return js ? this.card : $(this.card); - }; - } - - var WorkerClass = null; - - try { - var WorkerThreads = - typeof module !== 'undefined' && typeof module.require === 'function' && module.require('worker_threads') || - typeof __non_webpack_require__ === 'function' && __non_webpack_require__('worker_threads') || - typeof require === 'function' && require('worker_threads'); - WorkerClass = WorkerThreads.Worker; - } catch(e) {} // eslint-disable-line - - function decodeBase64$1(base64, enableUnicode) { - return Buffer.from(base64, 'base64').toString(enableUnicode ? 'utf16' : 'utf8'); - } - - function createBase64WorkerFactory$2(base64, sourcemapArg, enableUnicodeArg) { - var sourcemap = sourcemapArg === undefined ? null : sourcemapArg; - var enableUnicode = enableUnicodeArg === undefined ? false : enableUnicodeArg; - var source = decodeBase64$1(base64, enableUnicode); - var start = source.indexOf('\n', 10) + 1; - var body = source.substring(start) + (sourcemap ? '\/\/# sourceMappingURL=' + sourcemap : ''); - return function WorkerFactory(options) { - return new WorkerClass(body, Object.assign({}, options, { eval: true })); - }; - } - - function decodeBase64(base64, enableUnicode) { - var binaryString = atob(base64); - if (enableUnicode) { - var binaryView = new Uint8Array(binaryString.length); - for (var i = 0, n = binaryString.length; i < n; ++i) { - binaryView[i] = binaryString.charCodeAt(i); - } - return String.fromCharCode.apply(null, new Uint16Array(binaryView.buffer)); - } - return binaryString; - } - - function createURL(base64, sourcemapArg, enableUnicodeArg) { - var sourcemap = sourcemapArg === undefined ? null : sourcemapArg; - var enableUnicode = enableUnicodeArg === undefined ? false : enableUnicodeArg; - var source = decodeBase64(base64, enableUnicode); - var start = source.indexOf('\n', 10) + 1; - var body = source.substring(start) + (sourcemap ? '\/\/# sourceMappingURL=' + sourcemap : ''); - var blob = new Blob([body], { type: 'application/javascript' }); - return URL.createObjectURL(blob); - } - - function createBase64WorkerFactory$1(base64, sourcemapArg, enableUnicodeArg) { - var url; - return function WorkerFactory(options) { - url = url || createURL(base64, sourcemapArg, enableUnicodeArg); - return new Worker(url, options); - }; - } - - var kIsNodeJS = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'; - - function isNodeJS() { - return false; - } - - function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) { - if (isNodeJS()) { - return createBase64WorkerFactory$2(base64, sourcemapArg, enableUnicodeArg); - } - return createBase64WorkerFactory$1(base64, sourcemapArg, enableUnicodeArg); - } - - var WorkerFactory$2 = createBase64WorkerFactory('Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyogZXNsaW50LWRpc2FibGUgbm8tYml0d2lzZSAtLSB1c2VkIGZvciBjYWxjdWxhdGlvbnMgKi8KCiAgLyogZXNsaW50LWRpc2FibGUgdW5pY29ybi9wcmVmZXItcXVlcnktc2VsZWN0b3IgLS0gYWltaW5nIGF0DQogICAgYmFja3dhcmQtY29tcGF0aWJpbGl0eSAqLwoKICAvKioNCiAgKiBTdGFja0JsdXIgLSBhIGZhc3QgYWxtb3N0IEdhdXNzaWFuIEJsdXIgRm9yIENhbnZhcw0KICAqDQogICogSW4gY2FzZSB5b3UgZmluZCB0aGlzIGNsYXNzIHVzZWZ1bCAtIGVzcGVjaWFsbHkgaW4gY29tbWVyY2lhbCBwcm9qZWN0cyAtDQogICogSSBhbSBub3QgdG90YWxseSB1bmhhcHB5IGZvciBhIHNtYWxsIGRvbmF0aW9uIHRvIG15IFBheVBhbCBhY2NvdW50DQogICogbWFyaW9AcXVhc2ltb25kby5kZQ0KICAqDQogICogT3Igc3VwcG9ydCBtZSBvbiBmbGF0dHI6DQogICoge0BsaW5rIGh0dHBzOi8vZmxhdHRyLmNvbS90aGluZy83Mjc5MS9TdGFja0JsdXItYS1mYXN0LWFsbW9zdC1HYXVzc2lhbi1CbHVyLUVmZmVjdC1mb3ItQ2FudmFzSmF2YXNjcmlwdH0uDQogICoNCiAgKiBAbW9kdWxlIFN0YWNrQmx1cg0KICAqIEBhdXRob3IgTWFyaW8gS2xpbmdlbWFubg0KICAqIENvbnRhY3Q6IG1hcmlvQHF1YXNpbW9uZG8uY29tDQogICogV2Vic2l0ZToge0BsaW5rIGh0dHA6Ly93d3cucXVhc2ltb25kby5jb20vU3RhY2tCbHVyRm9yQ2FudmFzL1N0YWNrQmx1ckRlbW8uaHRtbH0NCiAgKiBUd2l0dGVyOiBAcXVhc2ltb25kbw0KICAqDQogICogQGNvcHlyaWdodCAoYykgMjAxMCBNYXJpbyBLbGluZ2VtYW5uDQogICoNCiAgKiBQZXJtaXNzaW9uIGlzIGhlcmVieSBncmFudGVkLCBmcmVlIG9mIGNoYXJnZSwgdG8gYW55IHBlcnNvbg0KICAqIG9idGFpbmluZyBhIGNvcHkgb2YgdGhpcyBzb2Z0d2FyZSBhbmQgYXNzb2NpYXRlZCBkb2N1bWVudGF0aW9uDQogICogZmlsZXMgKHRoZSAiU29mdHdhcmUiKSwgdG8gZGVhbCBpbiB0aGUgU29mdHdhcmUgd2l0aG91dA0KICAqIHJlc3RyaWN0aW9uLCBpbmNsdWRpbmcgd2l0aG91dCBsaW1pdGF0aW9uIHRoZSByaWdodHMgdG8gdXNlLA0KICAqIGNvcHksIG1vZGlmeSwgbWVyZ2UsIHB1Ymxpc2gsIGRpc3RyaWJ1dGUsIHN1YmxpY2Vuc2UsIGFuZC9vciBzZWxsDQogICogY29waWVzIG9mIHRoZSBTb2Z0d2FyZSwgYW5kIHRvIHBlcm1pdCBwZXJzb25zIHRvIHdob20gdGhlDQogICogU29mdHdhcmUgaXMgZnVybmlzaGVkIHRvIGRvIHNvLCBzdWJqZWN0IHRvIHRoZSBmb2xsb3dpbmcNCiAgKiBjb25kaXRpb25zOg0KICAqDQogICogVGhlIGFib3ZlIGNvcHlyaWdodCBub3RpY2UgYW5kIHRoaXMgcGVybWlzc2lvbiBub3RpY2Ugc2hhbGwgYmUNCiAgKiBpbmNsdWRlZCBpbiBhbGwgY29waWVzIG9yIHN1YnN0YW50aWFsIHBvcnRpb25zIG9mIHRoZSBTb2Z0d2FyZS4NCiAgKg0KICAqIFRIRSBTT0ZUV0FSRSBJUyBQUk9WSURFRCAiQVMgSVMiLCBXSVRIT1VUIFdBUlJBTlRZIE9GIEFOWSBLSU5ELA0KICAqIEVYUFJFU1MgT1IgSU1QTElFRCwgSU5DTFVESU5HIEJVVCBOT1QgTElNSVRFRCBUTyBUSEUgV0FSUkFOVElFUw0KICAqIE9GIE1FUkNIQU5UQUJJTElUWSwgRklUTkVTUyBGT1IgQSBQQVJUSUNVTEFSIFBVUlBPU0UgQU5EDQogICogTk9OSU5GUklOR0VNRU5ULiBJTiBOTyBFVkVOVCBTSEFMTCBUSEUgQVVUSE9SUyBPUiBDT1BZUklHSFQNCiAgKiBIT0xERVJTIEJFIExJQUJMRSBGT1IgQU5ZIENMQUlNLCBEQU1BR0VTIE9SIE9USEVSIExJQUJJTElUWSwNCiAgKiBXSEVUSEVSIElOIEFOIEFDVElPTiBPRiBDT05UUkFDVCwgVE9SVCBPUiBPVEhFUldJU0UsIEFSSVNJTkcNCiAgKiBGUk9NLCBPVVQgT0YgT1IgSU4gQ09OTkVDVElPTiBXSVRIIFRIRSBTT0ZUV0FSRSBPUiBUSEUgVVNFIE9SDQogICogT1RIRVIgREVBTElOR1MgSU4gVEhFIFNPRlRXQVJFLg0KICAqLwogIHZhciBCbHVyU3RhY2sgPSBmdW5jdGlvbiBCbHVyU3RhY2soKSB7CiAgICB0aGlzLnIgPSAwOwogICAgdGhpcy5nID0gMDsKICAgIHRoaXMuYiA9IDA7CiAgICB0aGlzLmEgPSAwOwogICAgdGhpcy5uZXh0ID0gbnVsbDsKICB9OwoKICB2YXIgbXVsVGFibGUgPSBbNTEyLCA1MTIsIDQ1NiwgNTEyLCAzMjgsIDQ1NiwgMzM1LCA1MTIsIDQwNSwgMzI4LCAyNzEsIDQ1NiwgMzg4LCAzMzUsIDI5MiwgNTEyLCA0NTQsIDQwNSwgMzY0LCAzMjgsIDI5OCwgMjcxLCA0OTYsIDQ1NiwgNDIwLCAzODgsIDM2MCwgMzM1LCAzMTIsIDI5MiwgMjczLCA1MTIsIDQ4MiwgNDU0LCA0MjgsIDQwNSwgMzgzLCAzNjQsIDM0NSwgMzI4LCAzMTIsIDI5OCwgMjg0LCAyNzEsIDI1OSwgNDk2LCA0NzUsIDQ1NiwgNDM3LCA0MjAsIDQwNCwgMzg4LCAzNzQsIDM2MCwgMzQ3LCAzMzUsIDMyMywgMzEyLCAzMDIsIDI5MiwgMjgyLCAyNzMsIDI2NSwgNTEyLCA0OTcsIDQ4MiwgNDY4LCA0NTQsIDQ0MSwgNDI4LCA0MTcsIDQwNSwgMzk0LCAzODMsIDM3MywgMzY0LCAzNTQsIDM0NSwgMzM3LCAzMjgsIDMyMCwgMzEyLCAzMDUsIDI5OCwgMjkxLCAyODQsIDI3OCwgMjcxLCAyNjUsIDI1OSwgNTA3LCA0OTYsIDQ4NSwgNDc1LCA0NjUsIDQ1NiwgNDQ2LCA0MzcsIDQyOCwgNDIwLCA0MTIsIDQwNCwgMzk2LCAzODgsIDM4MSwgMzc0LCAzNjcsIDM2MCwgMzU0LCAzNDcsIDM0MSwgMzM1LCAzMjksIDMyMywgMzE4LCAzMTIsIDMwNywgMzAyLCAyOTcsIDI5MiwgMjg3LCAyODIsIDI3OCwgMjczLCAyNjksIDI2NSwgMjYxLCA1MTIsIDUwNSwgNDk3LCA0ODksIDQ4MiwgNDc1LCA0NjgsIDQ2MSwgNDU0LCA0NDcsIDQ0MSwgNDM1LCA0MjgsIDQyMiwgNDE3LCA0MTEsIDQwNSwgMzk5LCAzOTQsIDM4OSwgMzgzLCAzNzgsIDM3MywgMzY4LCAzNjQsIDM1OSwgMzU0LCAzNTAsIDM0NSwgMzQxLCAzMzcsIDMzMiwgMzI4LCAzMjQsIDMyMCwgMzE2LCAzMTIsIDMwOSwgMzA1LCAzMDEsIDI5OCwgMjk0LCAyOTEsIDI4NywgMjg0LCAyODEsIDI3OCwgMjc0LCAyNzEsIDI2OCwgMjY1LCAyNjIsIDI1OSwgMjU3LCA1MDcsIDUwMSwgNDk2LCA0OTEsIDQ4NSwgNDgwLCA0NzUsIDQ3MCwgNDY1LCA0NjAsIDQ1NiwgNDUxLCA0NDYsIDQ0MiwgNDM3LCA0MzMsIDQyOCwgNDI0LCA0MjAsIDQxNiwgNDEyLCA0MDgsIDQwNCwgNDAwLCAzOTYsIDM5MiwgMzg4LCAzODUsIDM4MSwgMzc3LCAzNzQsIDM3MCwgMzY3LCAzNjMsIDM2MCwgMzU3LCAzNTQsIDM1MCwgMzQ3LCAzNDQsIDM0MSwgMzM4LCAzMzUsIDMzMiwgMzI5LCAzMjYsIDMyMywgMzIwLCAzMTgsIDMxNSwgMzEyLCAzMTAsIDMwNywgMzA0LCAzMDIsIDI5OSwgMjk3LCAyOTQsIDI5MiwgMjg5LCAyODcsIDI4NSwgMjgyLCAyODAsIDI3OCwgMjc1LCAyNzMsIDI3MSwgMjY5LCAyNjcsIDI2NSwgMjYzLCAyNjEsIDI1OV07CiAgdmFyIHNoZ1RhYmxlID0gWzksIDExLCAxMiwgMTMsIDEzLCAxNCwgMTQsIDE1LCAxNSwgMTUsIDE1LCAxNiwgMTYsIDE2LCAxNiwgMTcsIDE3LCAxNywgMTcsIDE3LCAxNywgMTcsIDE4LCAxOCwgMTgsIDE4LCAxOCwgMTgsIDE4LCAxOCwgMTgsIDE5LCAxOSwgMTksIDE5LCAxOSwgMTksIDE5LCAxOSwgMTksIDE5LCAxOSwgMTksIDE5LCAxOSwgMjAsIDIwLCAyMCwgMjAsIDIwLCAyMCwgMjAsIDIwLCAyMCwgMjAsIDIwLCAyMCwgMjAsIDIwLCAyMCwgMjAsIDIwLCAyMCwgMjEsIDIxLCAyMSwgMjEsIDIxLCAyMSwgMjEsIDIxLCAyMSwgMjEsIDIxLCAyMSwgMjEsIDIxLCAyMSwgMjEsIDIxLCAyMSwgMjEsIDIxLCAyMSwgMjEsIDIxLCAyMSwgMjEsIDIxLCAyMSwgMjIsIDIyLCAyMiwgMjIsIDIyLCAyMiwgMjIsIDIyLCAyMiwgMjIsIDIyLCAyMiwgMjIsIDIyLCAyMiwgMjIsIDIyLCAyMiwgMjIsIDIyLCAyMiwgMjIsIDIyLCAyMiwgMjIsIDIyLCAyMiwgMjIsIDIyLCAyMiwgMjIsIDIyLCAyMiwgMjIsIDIyLCAyMiwgMjIsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDIzLCAyMywgMjMsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNCwgMjQsIDI0LCAyNF07CiAgLyoqDQogICAqIEBwYXJhbSB7SW1hZ2VEYXRhfSBpbWFnZURhdGENCiAgICogQHBhcmFtIHtJbnRlZ2VyfSB0b3BYDQogICAqIEBwYXJhbSB7SW50ZWdlcn0gdG9wWQ0KICAgKiBAcGFyYW0ge0ludGVnZXJ9IHdpZHRoDQogICAqIEBwYXJhbSB7SW50ZWdlcn0gaGVpZ2h0DQogICAqIEBwYXJhbSB7RmxvYXR9IHJhZGl1cw0KICAgKiBAcmV0dXJucyB7SW1hZ2VEYXRhfQ0KICAgKi8KCgogIGZ1bmN0aW9uIHByb2Nlc3NJbWFnZURhdGFSR0IoaW1hZ2VEYXRhLCB0b3BYLCB0b3BZLCB3aWR0aCwgaGVpZ2h0LCByYWRpdXMpIHsKICAgIHZhciBwaXhlbHMgPSBpbWFnZURhdGEgPyBpbWFnZURhdGEuZGF0YSA6IFtdOwogICAgdmFyIGRpdiA9IDIgKiByYWRpdXMgKyAxOyAvLyBjb25zdCB3NCA9IHdpZHRoIDw8IDI7CgogICAgdmFyIHdpZHRoTWludXMxID0gd2lkdGggLSAxOwogICAgdmFyIGhlaWdodE1pbnVzMSA9IGhlaWdodCAtIDE7CiAgICB2YXIgcmFkaXVzUGx1czEgPSByYWRpdXMgKyAxOwogICAgdmFyIHN1bUZhY3RvciA9IHJhZGl1c1BsdXMxICogKHJhZGl1c1BsdXMxICsgMSkgLyAyOwogICAgdmFyIHN0YWNrU3RhcnQgPSBuZXcgQmx1clN0YWNrKCk7CiAgICB2YXIgc3RhY2sgPSBzdGFja1N0YXJ0OwogICAgdmFyIHN0YWNrRW5kOwoKICAgIGZvciAodmFyIGkgPSAxOyBpIDwgZGl2OyBpKyspIHsKICAgICAgc3RhY2sgPSBzdGFjay5uZXh0ID0gbmV3IEJsdXJTdGFjaygpOwoKICAgICAgaWYgKGkgPT09IHJhZGl1c1BsdXMxKSB7CiAgICAgICAgc3RhY2tFbmQgPSBzdGFjazsKICAgICAgfQogICAgfQoKICAgIHN0YWNrLm5leHQgPSBzdGFja1N0YXJ0OwogICAgdmFyIHN0YWNrSW4gPSBudWxsOwogICAgdmFyIHN0YWNrT3V0ID0gbnVsbDsKICAgIHZhciBtdWxTdW0gPSBtdWxUYWJsZVtyYWRpdXNdOwogICAgdmFyIHNoZ1N1bSA9IHNoZ1RhYmxlW3JhZGl1c107CiAgICB2YXIgcCwgcmJzOwogICAgdmFyIHl3ID0gMCwKICAgICAgICB5aSA9IDA7CgogICAgZm9yICh2YXIgeSA9IDA7IHkgPCBoZWlnaHQ7IHkrKykgewogICAgICB2YXIgcHIgPSBwaXhlbHNbeWldLAogICAgICAgICAgcGcgPSBwaXhlbHNbeWkgKyAxXSwKICAgICAgICAgIHBiID0gcGl4ZWxzW3lpICsgMl0sCiAgICAgICAgICByT3V0U3VtID0gcmFkaXVzUGx1czEgKiBwciwKICAgICAgICAgIGdPdXRTdW0gPSByYWRpdXNQbHVzMSAqIHBnLAogICAgICAgICAgYk91dFN1bSA9IHJhZGl1c1BsdXMxICogcGIsCiAgICAgICAgICByU3VtID0gc3VtRmFjdG9yICogcHIsCiAgICAgICAgICBnU3VtID0gc3VtRmFjdG9yICogcGcsCiAgICAgICAgICBiU3VtID0gc3VtRmFjdG9yICogcGI7CiAgICAgIHN0YWNrID0gc3RhY2tTdGFydDsKCiAgICAgIGZvciAodmFyIF9pNSA9IDA7IF9pNSA8IHJhZGl1c1BsdXMxOyBfaTUrKykgewogICAgICAgIHN0YWNrLnIgPSBwcjsKICAgICAgICBzdGFjay5nID0gcGc7CiAgICAgICAgc3RhY2suYiA9IHBiOwogICAgICAgIHN0YWNrID0gc3RhY2submV4dDsKICAgICAgfQoKICAgICAgdmFyIHJJblN1bSA9IDAsCiAgICAgICAgICBnSW5TdW0gPSAwLAogICAgICAgICAgYkluU3VtID0gMDsKCiAgICAgIGZvciAodmFyIF9pNiA9IDE7IF9pNiA8IHJhZGl1c1BsdXMxOyBfaTYrKykgewogICAgICAgIHAgPSB5aSArICgod2lkdGhNaW51czEgPCBfaTYgPyB3aWR0aE1pbnVzMSA6IF9pNikgPDwgMik7CiAgICAgICAgclN1bSArPSAoc3RhY2suciA9IHByID0gcGl4ZWxzW3BdKSAqIChyYnMgPSByYWRpdXNQbHVzMSAtIF9pNik7CiAgICAgICAgZ1N1bSArPSAoc3RhY2suZyA9IHBnID0gcGl4ZWxzW3AgKyAxXSkgKiByYnM7CiAgICAgICAgYlN1bSArPSAoc3RhY2suYiA9IHBiID0gcGl4ZWxzW3AgKyAyXSkgKiByYnM7CiAgICAgICAgckluU3VtICs9IHByOwogICAgICAgIGdJblN1bSArPSBwZzsKICAgICAgICBiSW5TdW0gKz0gcGI7CiAgICAgICAgc3RhY2sgPSBzdGFjay5uZXh0OwogICAgICB9CgogICAgICBzdGFja0luID0gc3RhY2tTdGFydDsKICAgICAgc3RhY2tPdXQgPSBzdGFja0VuZDsKCiAgICAgIGZvciAodmFyIHggPSAwOyB4IDwgd2lkdGg7IHgrKykgewogICAgICAgIHBpeGVsc1t5aV0gPSByU3VtICogbXVsU3VtID4+IHNoZ1N1bTsKICAgICAgICBwaXhlbHNbeWkgKyAxXSA9IGdTdW0gKiBtdWxTdW0gPj4gc2hnU3VtOwogICAgICAgIHBpeGVsc1t5aSArIDJdID0gYlN1bSAqIG11bFN1bSA+PiBzaGdTdW07CiAgICAgICAgclN1bSAtPSByT3V0U3VtOwogICAgICAgIGdTdW0gLT0gZ091dFN1bTsKICAgICAgICBiU3VtIC09IGJPdXRTdW07CiAgICAgICAgck91dFN1bSAtPSBzdGFja0luLnI7CiAgICAgICAgZ091dFN1bSAtPSBzdGFja0luLmc7CiAgICAgICAgYk91dFN1bSAtPSBzdGFja0luLmI7CiAgICAgICAgcCA9IHl3ICsgKChwID0geCArIHJhZGl1cyArIDEpIDwgd2lkdGhNaW51czEgPyBwIDogd2lkdGhNaW51czEpIDw8IDI7CiAgICAgICAgckluU3VtICs9IHN0YWNrSW4uciA9IHBpeGVsc1twXTsKICAgICAgICBnSW5TdW0gKz0gc3RhY2tJbi5nID0gcGl4ZWxzW3AgKyAxXTsKICAgICAgICBiSW5TdW0gKz0gc3RhY2tJbi5iID0gcGl4ZWxzW3AgKyAyXTsKICAgICAgICByU3VtICs9IHJJblN1bTsKICAgICAgICBnU3VtICs9IGdJblN1bTsKICAgICAgICBiU3VtICs9IGJJblN1bTsKICAgICAgICBzdGFja0luID0gc3RhY2tJbi5uZXh0OwogICAgICAgIHJPdXRTdW0gKz0gcHIgPSBzdGFja091dC5yOwogICAgICAgIGdPdXRTdW0gKz0gcGcgPSBzdGFja091dC5nOwogICAgICAgIGJPdXRTdW0gKz0gcGIgPSBzdGFja091dC5iOwogICAgICAgIHJJblN1bSAtPSBwcjsKICAgICAgICBnSW5TdW0gLT0gcGc7CiAgICAgICAgYkluU3VtIC09IHBiOwogICAgICAgIHN0YWNrT3V0ID0gc3RhY2tPdXQubmV4dDsKICAgICAgICB5aSArPSA0OwogICAgICB9CgogICAgICB5dyArPSB3aWR0aDsKICAgIH0KCiAgICBmb3IgKHZhciBfeDIgPSAwOyBfeDIgPCB3aWR0aDsgX3gyKyspIHsKICAgICAgeWkgPSBfeDIgPDwgMjsKCiAgICAgIHZhciBfcHIyID0gcGl4ZWxzW3lpXSwKICAgICAgICAgIF9wZzIgPSBwaXhlbHNbeWkgKyAxXSwKICAgICAgICAgIF9wYjIgPSBwaXhlbHNbeWkgKyAyXSwKICAgICAgICAgIF9yT3V0U3VtMiA9IHJhZGl1c1BsdXMxICogX3ByMiwKICAgICAgICAgIF9nT3V0U3VtMiA9IHJhZGl1c1BsdXMxICogX3BnMiwKICAgICAgICAgIF9iT3V0U3VtMiA9IHJhZGl1c1BsdXMxICogX3BiMiwKICAgICAgICAgIF9yU3VtMiA9IHN1bUZhY3RvciAqIF9wcjIsCiAgICAgICAgICBfZ1N1bTIgPSBzdW1GYWN0b3IgKiBfcGcyLAogICAgICAgICAgX2JTdW0yID0gc3VtRmFjdG9yICogX3BiMjsKCiAgICAgIHN0YWNrID0gc3RhY2tTdGFydDsKCiAgICAgIGZvciAodmFyIF9pNyA9IDA7IF9pNyA8IHJhZGl1c1BsdXMxOyBfaTcrKykgewogICAgICAgIHN0YWNrLnIgPSBfcHIyOwogICAgICAgIHN0YWNrLmcgPSBfcGcyOwogICAgICAgIHN0YWNrLmIgPSBfcGIyOwogICAgICAgIHN0YWNrID0gc3RhY2submV4dDsKICAgICAgfQoKICAgICAgdmFyIF9ySW5TdW0yID0gMCwKICAgICAgICAgIF9nSW5TdW0yID0gMCwKICAgICAgICAgIF9iSW5TdW0yID0gMDsKCiAgICAgIGZvciAodmFyIF9pOCA9IDEsIHlwID0gd2lkdGg7IF9pOCA8PSByYWRpdXM7IF9pOCsrKSB7CiAgICAgICAgeWkgPSB5cCArIF94MiA8PCAyOwogICAgICAgIF9yU3VtMiArPSAoc3RhY2suciA9IF9wcjIgPSBwaXhlbHNbeWldKSAqIChyYnMgPSByYWRpdXNQbHVzMSAtIF9pOCk7CiAgICAgICAgX2dTdW0yICs9IChzdGFjay5nID0gX3BnMiA9IHBpeGVsc1t5aSArIDFdKSAqIHJiczsKICAgICAgICBfYlN1bTIgKz0gKHN0YWNrLmIgPSBfcGIyID0gcGl4ZWxzW3lpICsgMl0pICogcmJzOwogICAgICAgIF9ySW5TdW0yICs9IF9wcjI7CiAgICAgICAgX2dJblN1bTIgKz0gX3BnMjsKICAgICAgICBfYkluU3VtMiArPSBfcGIyOwogICAgICAgIHN0YWNrID0gc3RhY2submV4dDsKCiAgICAgICAgaWYgKF9pOCA8IGhlaWdodE1pbnVzMSkgewogICAgICAgICAgeXAgKz0gd2lkdGg7CiAgICAgICAgfQogICAgICB9CgogICAgICB5aSA9IF94MjsKICAgICAgc3RhY2tJbiA9IHN0YWNrU3RhcnQ7CiAgICAgIHN0YWNrT3V0ID0gc3RhY2tFbmQ7CgogICAgICBmb3IgKHZhciBfeTIgPSAwOyBfeTIgPCBoZWlnaHQ7IF95MisrKSB7CiAgICAgICAgcCA9IHlpIDw8IDI7CiAgICAgICAgcGl4ZWxzW3BdID0gX3JTdW0yICogbXVsU3VtID4+IHNoZ1N1bTsKICAgICAgICBwaXhlbHNbcCArIDFdID0gX2dTdW0yICogbXVsU3VtID4+IHNoZ1N1bTsKICAgICAgICBwaXhlbHNbcCArIDJdID0gX2JTdW0yICogbXVsU3VtID4+IHNoZ1N1bTsKICAgICAgICBfclN1bTIgLT0gX3JPdXRTdW0yOwogICAgICAgIF9nU3VtMiAtPSBfZ091dFN1bTI7CiAgICAgICAgX2JTdW0yIC09IF9iT3V0U3VtMjsKICAgICAgICBfck91dFN1bTIgLT0gc3RhY2tJbi5yOwogICAgICAgIF9nT3V0U3VtMiAtPSBzdGFja0luLmc7CiAgICAgICAgX2JPdXRTdW0yIC09IHN0YWNrSW4uYjsKICAgICAgICBwID0gX3gyICsgKChwID0gX3kyICsgcmFkaXVzUGx1czEpIDwgaGVpZ2h0TWludXMxID8gcCA6IGhlaWdodE1pbnVzMSkgKiB3aWR0aCA8PCAyOwogICAgICAgIF9yU3VtMiArPSBfckluU3VtMiArPSBzdGFja0luLnIgPSBwaXhlbHNbcF07CiAgICAgICAgX2dTdW0yICs9IF9nSW5TdW0yICs9IHN0YWNrSW4uZyA9IHBpeGVsc1twICsgMV07CiAgICAgICAgX2JTdW0yICs9IF9iSW5TdW0yICs9IHN0YWNrSW4uYiA9IHBpeGVsc1twICsgMl07CiAgICAgICAgc3RhY2tJbiA9IHN0YWNrSW4ubmV4dDsKICAgICAgICBfck91dFN1bTIgKz0gX3ByMiA9IHN0YWNrT3V0LnI7CiAgICAgICAgX2dPdXRTdW0yICs9IF9wZzIgPSBzdGFja091dC5nOwogICAgICAgIF9iT3V0U3VtMiArPSBfcGIyID0gc3RhY2tPdXQuYjsKICAgICAgICBfckluU3VtMiAtPSBfcHIyOwogICAgICAgIF9nSW5TdW0yIC09IF9wZzI7CiAgICAgICAgX2JJblN1bTIgLT0gX3BiMjsKICAgICAgICBzdGFja091dCA9IHN0YWNrT3V0Lm5leHQ7CiAgICAgICAgeWkgKz0gd2lkdGg7CiAgICAgIH0KICAgIH0KCiAgICByZXR1cm4gaW1hZ2VEYXRhOwogIH0KCiAgb25tZXNzYWdlID0gZnVuY3Rpb24gb25tZXNzYWdlKGUpIHsKICAgIHZhciBkYXRhID0gZS5kYXRhOwogICAgdmFyIGltYWdlRGF0YTsKCiAgICB0cnkgewogICAgICBpbWFnZURhdGEgPSBwcm9jZXNzSW1hZ2VEYXRhUkdCKGRhdGEuaW1hZ2VEYXRhLCBkYXRhLnRvcFgsIGRhdGEudG9wWSwgZGF0YS53aWR0aCwgZGF0YS5oZWlnaHQsIGRhdGEucmFkaXVzKTsKICAgICAgcG9zdE1lc3NhZ2UoaW1hZ2VEYXRhKTsKICAgIH0gY2F0Y2ggKGUpIHt9CiAgfTsKCn0pKCk7Cgo=', null, false); - /* eslint-enable */ - - var WorkerFactory$1 = createBase64WorkerFactory('Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIGZ1bmN0aW9uIHBhcnNlKHN0cmluZywgZW1wdHkpIHsKICAgICAgdmFyIGpzb24gPSBlbXB0eSB8fCB7fTsKCiAgICAgIGlmIChzdHJpbmcpIHsKICAgICAgICB0cnkgewogICAgICAgICAganNvbiA9IEpTT04ucGFyc2Uoc3RyaW5nKTsKICAgICAgICB9IGNhdGNoIChlKSB7fQogICAgICB9CgogICAgICByZXR1cm4ganNvbjsKICAgIH0KCiAgICBmdW5jdGlvbiBzdHJpbmdpZnkoZGF0YSkgewogICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoZGF0YSk7CiAgICB9CgogICAgb25tZXNzYWdlID0gZnVuY3Rpb24gb25tZXNzYWdlKGUpIHsKICAgICAgdmFyIG1zZyA9IGUuZGF0YTsKCiAgICAgIGlmIChtc2cudHlwZSA9PSAnc3RyaW5naWZ5JykgewogICAgICAgIHBvc3RNZXNzYWdlKHN0cmluZ2lmeShtc2cuZGF0YSkpOwogICAgICB9IGVsc2UgaWYgKG1zZy50eXBlID09ICdwYXJzZScpIHsKICAgICAgICBwb3N0TWVzc2FnZShwYXJzZShtc2cuZGF0YSwgbXNnLmVtcHR5KSk7CiAgICAgIH0KICAgIH07Cgp9KSgpOwoK', null, false); - /* eslint-enable */ - - var WorkerFactory = createBase64WorkerFactory('Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIG9ubWVzc2FnZSA9IGZ1bmN0aW9uIG9ubWVzc2FnZShlKSB7CiAgICAgIHZhciBtc2cgPSBlLmRhdGE7CgogICAgICBpZiAobXNnLnR5cGUgPT0gJ2FjY291bnRfYm9va21hcmtzX3BhcnNlJykgewogICAgICAgIHZhciBib29rbWFya3MgPSBtc2cuZGF0YS5tYXAoZnVuY3Rpb24gKGVsZW0pIHsKICAgICAgICAgIGlmICh0eXBlb2YgZWxlbS5kYXRhID09ICdzdHJpbmcnKSB7CiAgICAgICAgICAgIGVsZW0uZGF0YSA9IEpTT04ucGFyc2UoZWxlbS5kYXRhKTsKICAgICAgICAgICAgZGVsZXRlIGVsZW0uZGF0YS5yZWxlYXNlX3F1YWxpdHk7CiAgICAgICAgICAgIGRlbGV0ZSBlbGVtLmRhdGEucXVhbGl0eTsKICAgICAgICAgIH0KCiAgICAgICAgICByZXR1cm4gZWxlbTsKICAgICAgICB9KS5yZXZlcnNlKCk7CiAgICAgICAgcG9zdE1lc3NhZ2UoYm9va21hcmtzKTsKICAgICAgfQogICAgfTsKCn0pKCk7Cgo=', null, false); - /* eslint-enable */ - - var agent = navigator.userAgent.toLowerCase(); - - function WebWorker(worker) { - var callback = false; - - worker.onmessage = function (data) { - if (callback) { - callback(data); - callback = false; - } - }; - - this.call = function (data, call) { - callback = call; - worker.postMessage(data); - }; - } - - function createWorker(extend, nosuport) { - var worker; - if (agent.indexOf("netcast") > -1 || agent.indexOf("maple") > -1) return nosuport || { - call: function call() {} - }; - - try { - worker = new WebWorker(new extend()); - } catch (e) { - worker = nosuport || { - call: function call() {} - }; - } - - return worker; - } - - var blurWorker = createWorker(WorkerFactory$2, { - call: function call(msg, _call) { - var imageData = Blur.imageDataRGB(msg.imageData, msg.topX, msg.topY, msg.width, msg.height, msg.radius); - - _call({ - data: imageData - }); - } - }); - var jsonWorker = createWorker(WorkerFactory$1, { - call: function call(msg, _call2) { - _call2({ - data: msg.type == 'parse' ? Arrays.decodeJson(msg.data, msg.empty) : JSON.stringify(msg.data) - }); - } - }); - var utilsWorker = createWorker(WorkerFactory, { - call: function call(msg, _call3) { - if (msg.type == 'account_bookmarks_parse') { - var bookmarks = msg.data.map(function (elem) { - if (typeof elem.data == 'string') { - elem.data = JSON.parse(elem.data); - delete elem.data.release_quality; - delete elem.data.quality; - } - - return elem; - }).reverse(); - - _call3({ - data: bookmarks - }); - } - } - }); - var AppWorker = { - blur: blurWorker.call, - json: jsonWorker.call, - utils: utilsWorker.call - }; - - /* eslint-disable no-bitwise -- used for calculations */ - - /* eslint-disable unicorn/prefer-query-selector -- aiming at - backward-compatibility */ - - /** - * StackBlur - a fast almost Gaussian Blur For Canvas - * - * In case you find this class useful - especially in commercial projects - - * I am not totally unhappy for a small donation to my PayPal account - * mario@quasimondo.de - * - * Or support me on flattr: - * {@link https://flattr.com/thing/72791/StackBlur-a-fast-almost-Gaussian-Blur-Effect-for-CanvasJavascript}. - * - * @module StackBlur - * @author Mario Klingemann - * Contact: mario@quasimondo.com - * Website: {@link http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html} - * Twitter: @quasimondo - * - * @copyright (c) 2010 Mario Klingemann - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - - var mulTable = [512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292, 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271, 268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292, 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259]; - var shgTable = [9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24]; - /** - * @param {string|HTMLImageElement} img - * @param {string|HTMLCanvasElement} canvas - * @param {Float} radius - * @param {boolean} blurAlphaChannel - * @param {boolean} useOffset - * @param {boolean} skipStyles - * @returns {undefined} - */ - - function processImage(img, canvas, radius, blurAlphaChannel, useOffset, skipStyles) { - if (typeof img === 'string') { - img = document.getElementById(img); - } - - if (!img || !('naturalWidth' in img)) { - return; - } - - var dimensionType = useOffset ? 'offset' : 'natural'; - var w = img[dimensionType + 'Width']; - var h = img[dimensionType + 'Height']; - - if (typeof canvas === 'string') { - canvas = document.getElementById(canvas); - } - - if (!canvas || !('getContext' in canvas)) { - return; - } - - if (!skipStyles) { - canvas.style.width = w + 'px'; - canvas.style.height = h + 'px'; - } - - canvas.width = w; - canvas.height = h; - var context = canvas.getContext('2d'); - context.clearRect(0, 0, w, h); - context.drawImage(img, 0, 0, img.naturalWidth, img.naturalHeight, 0, 0, w, h); - - if (isNaN(radius) || radius < 1) { - return; - } - - if (blurAlphaChannel) { - processCanvasRGBA(canvas, 0, 0, w, h, radius); - } else { - processCanvasRGB(canvas, 0, 0, w, h, radius); - } - } - /** - * @param {string|HTMLCanvasElement} canvas - * @param {Integer} topX - * @param {Integer} topY - * @param {Integer} width - * @param {Integer} height - * @throws {Error|TypeError} - * @returns {ImageData} See {@link https://html.spec.whatwg.org/multipage/canvas.html#imagedata} - */ - - - function getImageDataFromCanvas(canvas, topX, topY, width, height) { - if (typeof canvas === 'string') { - canvas = document.getElementById(canvas); - } - - if (!canvas || _typeof(canvas) !== 'object' || !('getContext' in canvas)) ; - - var context = canvas.getContext('2d'); - - try { - return context.getImageData(topX, topY, width, height); - } catch (e) {//throw new Error('unable to access image data: ' + e); - } - } - /** - * @param {HTMLCanvasElement} canvas - * @param {Integer} topX - * @param {Integer} topY - * @param {Integer} width - * @param {Integer} height - * @param {Float} radius - * @returns {undefined} - */ - - - function processCanvasRGBA(canvas, topX, topY, width, height, radius) { - if (isNaN(radius) || radius < 1) { - return; - } - - radius |= 0; - var imageData = getImageDataFromCanvas(canvas, topX, topY, width, height); - - if (imageData) { - imageData = processImageDataRGBA(imageData, topX, topY, width, height, radius); - - try { - canvas.getContext('2d').putImageData(imageData, topX, topY); - } catch (e) {} - } - } - /** - * @param {ImageData} imageData - * @param {Integer} topX - * @param {Integer} topY - * @param {Integer} width - * @param {Integer} height - * @param {Float} radius - * @returns {ImageData} - */ - - - function processImageDataRGBA(imageData, topX, topY, width, height, radius) { - var pixels = imageData ? imageData.data : []; - var div = 2 * radius + 1; // const w4 = width << 2; - - var widthMinus1 = width - 1; - var heightMinus1 = height - 1; - var radiusPlus1 = radius + 1; - var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2; - var stackStart = new BlurStack(); - var stack = stackStart; - var stackEnd; - - for (var i = 1; i < div; i++) { - stack = stack.next = new BlurStack(); - - if (i === radiusPlus1) { - stackEnd = stack; - } - } - - stack.next = stackStart; - var stackIn = null, - stackOut = null, - yw = 0, - yi = 0; - var mulSum = mulTable[radius]; - var shgSum = shgTable[radius]; - - for (var y = 0; y < height; y++) { - stack = stackStart; - var pr = pixels[yi], - pg = pixels[yi + 1], - pb = pixels[yi + 2], - pa = pixels[yi + 3]; - - for (var _i = 0; _i < radiusPlus1; _i++) { - stack.r = pr; - stack.g = pg; - stack.b = pb; - stack.a = pa; - stack = stack.next; - } - - var rInSum = 0, - gInSum = 0, - bInSum = 0, - aInSum = 0, - rOutSum = radiusPlus1 * pr, - gOutSum = radiusPlus1 * pg, - bOutSum = radiusPlus1 * pb, - aOutSum = radiusPlus1 * pa, - rSum = sumFactor * pr, - gSum = sumFactor * pg, - bSum = sumFactor * pb, - aSum = sumFactor * pa; - - for (var _i2 = 1; _i2 < radiusPlus1; _i2++) { - var p = yi + ((widthMinus1 < _i2 ? widthMinus1 : _i2) << 2); - var r = pixels[p], - g = pixels[p + 1], - b = pixels[p + 2], - a = pixels[p + 3]; - var rbs = radiusPlus1 - _i2; - rSum += (stack.r = r) * rbs; - gSum += (stack.g = g) * rbs; - bSum += (stack.b = b) * rbs; - aSum += (stack.a = a) * rbs; - rInSum += r; - gInSum += g; - bInSum += b; - aInSum += a; - stack = stack.next; - } - - stackIn = stackStart; - stackOut = stackEnd; - - for (var x = 0; x < width; x++) { - var paInitial = aSum * mulSum >> shgSum; - pixels[yi + 3] = paInitial; - - if (paInitial !== 0) { - var _a2 = 255 / paInitial; - - pixels[yi] = (rSum * mulSum >> shgSum) * _a2; - pixels[yi + 1] = (gSum * mulSum >> shgSum) * _a2; - pixels[yi + 2] = (bSum * mulSum >> shgSum) * _a2; - } else { - pixels[yi] = pixels[yi + 1] = pixels[yi + 2] = 0; - } - - rSum -= rOutSum; - gSum -= gOutSum; - bSum -= bOutSum; - aSum -= aOutSum; - rOutSum -= stackIn.r; - gOutSum -= stackIn.g; - bOutSum -= stackIn.b; - aOutSum -= stackIn.a; - - var _p = x + radius + 1; - - _p = yw + (_p < widthMinus1 ? _p : widthMinus1) << 2; - rInSum += stackIn.r = pixels[_p]; - gInSum += stackIn.g = pixels[_p + 1]; - bInSum += stackIn.b = pixels[_p + 2]; - aInSum += stackIn.a = pixels[_p + 3]; - rSum += rInSum; - gSum += gInSum; - bSum += bInSum; - aSum += aInSum; - stackIn = stackIn.next; - var _stackOut = stackOut, - _r = _stackOut.r, - _g = _stackOut.g, - _b = _stackOut.b, - _a = _stackOut.a; - rOutSum += _r; - gOutSum += _g; - bOutSum += _b; - aOutSum += _a; - rInSum -= _r; - gInSum -= _g; - bInSum -= _b; - aInSum -= _a; - stackOut = stackOut.next; - yi += 4; - } - - yw += width; - } - - for (var _x = 0; _x < width; _x++) { - yi = _x << 2; - - var _pr = pixels[yi], - _pg = pixels[yi + 1], - _pb = pixels[yi + 2], - _pa = pixels[yi + 3], - _rOutSum = radiusPlus1 * _pr, - _gOutSum = radiusPlus1 * _pg, - _bOutSum = radiusPlus1 * _pb, - _aOutSum = radiusPlus1 * _pa, - _rSum = sumFactor * _pr, - _gSum = sumFactor * _pg, - _bSum = sumFactor * _pb, - _aSum = sumFactor * _pa; - - stack = stackStart; - - for (var _i3 = 0; _i3 < radiusPlus1; _i3++) { - stack.r = _pr; - stack.g = _pg; - stack.b = _pb; - stack.a = _pa; - stack = stack.next; - } - - var yp = width; - var _gInSum = 0, - _bInSum = 0, - _aInSum = 0, - _rInSum = 0; - - for (var _i4 = 1; _i4 <= radius; _i4++) { - yi = yp + _x << 2; - - var _rbs = radiusPlus1 - _i4; - - _rSum += (stack.r = _pr = pixels[yi]) * _rbs; - _gSum += (stack.g = _pg = pixels[yi + 1]) * _rbs; - _bSum += (stack.b = _pb = pixels[yi + 2]) * _rbs; - _aSum += (stack.a = _pa = pixels[yi + 3]) * _rbs; - _rInSum += _pr; - _gInSum += _pg; - _bInSum += _pb; - _aInSum += _pa; - stack = stack.next; - - if (_i4 < heightMinus1) { - yp += width; - } - } - - yi = _x; - stackIn = stackStart; - stackOut = stackEnd; - - for (var _y = 0; _y < height; _y++) { - var _p2 = yi << 2; - - pixels[_p2 + 3] = _pa = _aSum * mulSum >> shgSum; - - if (_pa > 0) { - _pa = 255 / _pa; - pixels[_p2] = (_rSum * mulSum >> shgSum) * _pa; - pixels[_p2 + 1] = (_gSum * mulSum >> shgSum) * _pa; - pixels[_p2 + 2] = (_bSum * mulSum >> shgSum) * _pa; - } else { - pixels[_p2] = pixels[_p2 + 1] = pixels[_p2 + 2] = 0; - } - - _rSum -= _rOutSum; - _gSum -= _gOutSum; - _bSum -= _bOutSum; - _aSum -= _aOutSum; - _rOutSum -= stackIn.r; - _gOutSum -= stackIn.g; - _bOutSum -= stackIn.b; - _aOutSum -= stackIn.a; - _p2 = _x + ((_p2 = _y + radiusPlus1) < heightMinus1 ? _p2 : heightMinus1) * width << 2; - _rSum += _rInSum += stackIn.r = pixels[_p2]; - _gSum += _gInSum += stackIn.g = pixels[_p2 + 1]; - _bSum += _bInSum += stackIn.b = pixels[_p2 + 2]; - _aSum += _aInSum += stackIn.a = pixels[_p2 + 3]; - stackIn = stackIn.next; - _rOutSum += _pr = stackOut.r; - _gOutSum += _pg = stackOut.g; - _bOutSum += _pb = stackOut.b; - _aOutSum += _pa = stackOut.a; - _rInSum -= _pr; - _gInSum -= _pg; - _bInSum -= _pb; - _aInSum -= _pa; - stackOut = stackOut.next; - yi += width; - } - } - - return imageData; - } - /** - * @param {HTMLCanvasElement} canvas - * @param {Integer} topX - * @param {Integer} topY - * @param {Integer} width - * @param {Integer} height - * @param {Float} radius - * @returns {undefined} - */ - - - function processCanvasRGB(canvas, topX, topY, width, height, radius, callback) { - if (isNaN(radius) || radius < 1) { - return; - } - - radius |= 0; - var imageData = getImageDataFromCanvas(canvas, topX, topY, width, height); - AppWorker.blur({ - imageData: imageData, - topX: topX, - topY: topY, - width: width, - height: height, - radius: radius - }, function (imageBlurData) { - try { - canvas.getContext('2d').putImageData(imageBlurData.data, topX, topY); - } catch (e) {} - - callback(); - }); - /* - imageData = processImageDataRGB( - imageData, topX, topY, width, height, radius - ); - try{ - canvas.getContext('2d').putImageData(imageData, topX, topY); - } - catch(e){} - */ - } - /** - * @param {ImageData} imageData - * @param {Integer} topX - * @param {Integer} topY - * @param {Integer} width - * @param {Integer} height - * @param {Float} radius - * @returns {ImageData} - */ - - - function processImageDataRGB(imageData, topX, topY, width, height, radius) { - var pixels = imageData ? imageData.data : []; - var div = 2 * radius + 1; // const w4 = width << 2; - - var widthMinus1 = width - 1; - var heightMinus1 = height - 1; - var radiusPlus1 = radius + 1; - var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2; - var stackStart = new BlurStack(); - var stack = stackStart; - var stackEnd; - - for (var i = 1; i < div; i++) { - stack = stack.next = new BlurStack(); - - if (i === radiusPlus1) { - stackEnd = stack; - } - } - - stack.next = stackStart; - var stackIn = null; - var stackOut = null; - var mulSum = mulTable[radius]; - var shgSum = shgTable[radius]; - var p, rbs; - var yw = 0, - yi = 0; - - for (var y = 0; y < height; y++) { - var pr = pixels[yi], - pg = pixels[yi + 1], - pb = pixels[yi + 2], - rOutSum = radiusPlus1 * pr, - gOutSum = radiusPlus1 * pg, - bOutSum = radiusPlus1 * pb, - rSum = sumFactor * pr, - gSum = sumFactor * pg, - bSum = sumFactor * pb; - stack = stackStart; - - for (var _i5 = 0; _i5 < radiusPlus1; _i5++) { - stack.r = pr; - stack.g = pg; - stack.b = pb; - stack = stack.next; - } - - var rInSum = 0, - gInSum = 0, - bInSum = 0; - - for (var _i6 = 1; _i6 < radiusPlus1; _i6++) { - p = yi + ((widthMinus1 < _i6 ? widthMinus1 : _i6) << 2); - rSum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - _i6); - gSum += (stack.g = pg = pixels[p + 1]) * rbs; - bSum += (stack.b = pb = pixels[p + 2]) * rbs; - rInSum += pr; - gInSum += pg; - bInSum += pb; - stack = stack.next; - } - - stackIn = stackStart; - stackOut = stackEnd; - - for (var x = 0; x < width; x++) { - pixels[yi] = rSum * mulSum >> shgSum; - pixels[yi + 1] = gSum * mulSum >> shgSum; - pixels[yi + 2] = bSum * mulSum >> shgSum; - rSum -= rOutSum; - gSum -= gOutSum; - bSum -= bOutSum; - rOutSum -= stackIn.r; - gOutSum -= stackIn.g; - bOutSum -= stackIn.b; - p = yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1) << 2; - rInSum += stackIn.r = pixels[p]; - gInSum += stackIn.g = pixels[p + 1]; - bInSum += stackIn.b = pixels[p + 2]; - rSum += rInSum; - gSum += gInSum; - bSum += bInSum; - stackIn = stackIn.next; - rOutSum += pr = stackOut.r; - gOutSum += pg = stackOut.g; - bOutSum += pb = stackOut.b; - rInSum -= pr; - gInSum -= pg; - bInSum -= pb; - stackOut = stackOut.next; - yi += 4; - } - - yw += width; - } - - for (var _x2 = 0; _x2 < width; _x2++) { - yi = _x2 << 2; - - var _pr2 = pixels[yi], - _pg2 = pixels[yi + 1], - _pb2 = pixels[yi + 2], - _rOutSum2 = radiusPlus1 * _pr2, - _gOutSum2 = radiusPlus1 * _pg2, - _bOutSum2 = radiusPlus1 * _pb2, - _rSum2 = sumFactor * _pr2, - _gSum2 = sumFactor * _pg2, - _bSum2 = sumFactor * _pb2; - - stack = stackStart; - - for (var _i7 = 0; _i7 < radiusPlus1; _i7++) { - stack.r = _pr2; - stack.g = _pg2; - stack.b = _pb2; - stack = stack.next; - } - - var _rInSum2 = 0, - _gInSum2 = 0, - _bInSum2 = 0; - - for (var _i8 = 1, yp = width; _i8 <= radius; _i8++) { - yi = yp + _x2 << 2; - _rSum2 += (stack.r = _pr2 = pixels[yi]) * (rbs = radiusPlus1 - _i8); - _gSum2 += (stack.g = _pg2 = pixels[yi + 1]) * rbs; - _bSum2 += (stack.b = _pb2 = pixels[yi + 2]) * rbs; - _rInSum2 += _pr2; - _gInSum2 += _pg2; - _bInSum2 += _pb2; - stack = stack.next; - - if (_i8 < heightMinus1) { - yp += width; - } - } - - yi = _x2; - stackIn = stackStart; - stackOut = stackEnd; - - for (var _y2 = 0; _y2 < height; _y2++) { - p = yi << 2; - pixels[p] = _rSum2 * mulSum >> shgSum; - pixels[p + 1] = _gSum2 * mulSum >> shgSum; - pixels[p + 2] = _bSum2 * mulSum >> shgSum; - _rSum2 -= _rOutSum2; - _gSum2 -= _gOutSum2; - _bSum2 -= _bOutSum2; - _rOutSum2 -= stackIn.r; - _gOutSum2 -= stackIn.g; - _bOutSum2 -= stackIn.b; - p = _x2 + ((p = _y2 + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width << 2; - _rSum2 += _rInSum2 += stackIn.r = pixels[p]; - _gSum2 += _gInSum2 += stackIn.g = pixels[p + 1]; - _bSum2 += _bInSum2 += stackIn.b = pixels[p + 2]; - stackIn = stackIn.next; - _rOutSum2 += _pr2 = stackOut.r; - _gOutSum2 += _pg2 = stackOut.g; - _bOutSum2 += _pb2 = stackOut.b; - _rInSum2 -= _pr2; - _gInSum2 -= _pg2; - _bInSum2 -= _pb2; - stackOut = stackOut.next; - yi += width; - } - } - - return imageData; - } - /** - * - */ - - - var BlurStack = - /** - * Set properties. - */ - function BlurStack() { - _classCallCheck(this, BlurStack); - - this.r = 0; - this.g = 0; - this.b = 0; - this.a = 0; - this.next = null; - }; - var Blur = { - /** - * @function module:StackBlur.image - * @see module:StackBlur~processImage - */ - image: processImage, - - /** - * @function module:StackBlur.canvasRGBA - * @see module:StackBlur~processCanvasRGBA - */ - canvasRGBA: processCanvasRGBA, - - /** - * @function module:StackBlur.canvasRGB - * @see module:StackBlur~processCanvasRGB - */ - canvasRGB: processCanvasRGB, - - /** - * @function module:StackBlur.imageDataRGBA - * @see module:StackBlur~processImageDataRGBA - */ - imageDataRGBA: processImageDataRGBA, - - /** - * @function module:StackBlur.imageDataRGB - * @see module:StackBlur~processImageDataRGB - */ - imageDataRGB: processImageDataRGB - }; - - var canvas = document.createElement('canvas'), - ctx = canvas.getContext('2d'); - canvas.width = 30; - canvas.height = 17; - var canvas_poster = document.createElement('canvas'), - ctx_poster = canvas_poster.getContext('2d'); - - function extract$1(img_data) { - var data = img_data.data, - colors = []; - - for (var i = 0, n = data.length; i < n; i += 4) { - colors.push([data[i], data[i + 1], data[i + 2]]); - } - - return colors; - } - - function palette(palette) { - var colors = { - bright: [0, 0, 0], - average: [127, 127, 127], - dark: [255, 255, 255] - }; - var ar = 0, - ag = 0, - ab = 0, - at = palette.length; - var bg = 0, - dk = 765; - - for (var i = 0; i < palette.length; i++) { - var p = palette[i], - a = p[0] + p[1] + p[2]; - ar += p[0]; - ag += p[1]; - ab += p[2]; - - if (a > bg) { - bg = a; - colors.bright = p; - } - - if (a < dk) { - dk = a; - colors.dark = p; - } - } - - colors.average = [Math.round(ar / at), Math.round(ag / at), Math.round(ab / at)]; - return colors; - } - - function rgba(c) { - var o = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; - return 'rgba(' + c.join(',') + ',' + o + ')'; - } - - function tone(c) { - var o = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; - var s = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 30; - var l = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 80; - var hls = rgbToHsl(c[0], c[1], c[2]); - var rgb = hslToRgb$1(hls[0], Math.min(s, hls[1]), l); - return rgba(rgb, o); - } - /** - * Converts an RGB color value to HSL. - * - * @param {number} r The red color value - * @param {number} g The green color value - * @param {number} b The blue color value - * @return {Array} The HSL representation - */ - - - function rgbToHsl(r, g, b) { - var rabs, gabs, babs, rr, gg, bb, h, s, v, diff, diffc, percentRoundFn; - rabs = r / 255; - gabs = g / 255; - babs = b / 255; - v = Math.max(rabs, gabs, babs), diff = v - Math.min(rabs, gabs, babs); - - diffc = function diffc(c) { - return (v - c) / 6 / diff + 1 / 2; - }; - - percentRoundFn = function percentRoundFn(num) { - return Math.round(num * 100) / 100; - }; - - if (diff == 0) { - h = s = 0; - } else { - s = diff / v; - rr = diffc(rabs); - gg = diffc(gabs); - bb = diffc(babs); - - if (rabs === v) { - h = bb - gg; - } else if (gabs === v) { - h = 1 / 3 + rr - bb; - } else if (babs === v) { - h = 2 / 3 + gg - rr; - } - - if (h < 0) { - h += 1; - } else if (h > 1) { - h -= 1; - } - } - - return [Math.round(h * 360), percentRoundFn(s * 100), percentRoundFn(v * 100)]; - } - /** - * Converts an HSL color value to RGB. - * - * @param {number} h The hue - * @param {number} s The saturation - * @param {number} l The lightness - * @return {Array} The RGB representation - */ - - - function hslToRgb$1(h, s, l) { - s /= 100; - l /= 100; - var C = (1 - Math.abs(2 * l - 1)) * s; - var hue = h / 60; - var X = C * (1 - Math.abs(hue % 2 - 1)); - var r = 0, - g = 0, - b = 0; - - if (hue >= 0 && hue < 1) { - r = C; - g = X; - } else if (hue >= 1 && hue < 2) { - r = X; - g = C; - } else if (hue >= 2 && hue < 3) { - g = C; - b = X; - } else if (hue >= 3 && hue < 4) { - g = X; - b = C; - } else if (hue >= 4 && hue < 5) { - r = X; - b = C; - } else { - r = C; - b = X; - } - - var m = l - C / 2; - r += m; - g += m; - b += m; - r *= 255.0; - g *= 255.0; - b *= 255.0; - return [Math.round(r), Math.round(g), Math.round(b)]; - } - - function reset(width, height) { - canvas.width = width; - canvas.height = height; - } - - function get$9(img) { - reset(30, 17); - var ratio = Math.max(canvas.width / img.width, canvas.height / img.height); - var nw = img.width * ratio, - nh = img.height * ratio; - ctx.drawImage(img, -(nw - canvas.width) / 2, -(nh - canvas.height) / 2, nw, nh); - return extract$1(ctx.getImageData(0, 0, canvas.width, canvas.height)); - } - - function blur$1(img, callback) { - reset(200, 130); - var ratio = Math.max(canvas.width / img.width, canvas.height / img.height); - var nw = img.width * ratio, - nh = img.height * ratio; - ctx.drawImage(img, -(nw - canvas.width) / 2, -(nh - canvas.height) / 2, nw, nh); - Blur.canvasRGB(canvas, 0, 0, canvas.width, canvas.height, 80, function () { - var nimg = new Image(); - - try { - nimg.src = canvas.toDataURL(); - } catch (e) {} - - setTimeout(function () { - callback(nimg); - }, 100); - }); - } - - function getImg(callback) { - var im = new Image(); - - try { - im.src = canvas_poster.toDataURL(); - } catch (e) {} - - setTimeout(function () { - callback(im); - }, 100); - } - - function blurPoster(img, w, h, callback) { - canvas_poster.width = w; - canvas_poster.height = h; - var ratio = Math.max(canvas_poster.width / img.width, canvas_poster.height / img.height); - var nw = img.width * ratio, - nh = img.height * ratio; - setTimeout(function () { - ctx_poster.drawImage(img, -(nw - canvas_poster.width) / 2, -(nh - canvas_poster.height) / 2, nw, nh); - Blur.canvasRGB(canvas_poster, 0, 0, canvas_poster.width, canvas_poster.height, 50, function () { - var gradient = ctx_poster.createLinearGradient(0, 0, 0, canvas_poster.height); - gradient.addColorStop(0.5, 'rgba(0, 0, 0, 1)'); - gradient.addColorStop(0.6, 'rgba(0, 0, 0, 0)'); - gradient.addColorStop(1, 'rgba(0, 0, 0, 1)'); - ctx_poster.globalCompositeOperation = 'destination-out'; - ctx_poster.fillStyle = gradient; - ctx_poster.fillRect(0, 0, canvas_poster.width, canvas_poster.height); - ctx_poster.globalCompositeOperation = 'source-over'; - getImg(function (blured) { - canvas_poster.width = w; - canvas_poster.height = h; - ctx_poster.drawImage(img, -(nw - canvas_poster.width) / 2, -(nh - canvas_poster.height) / 2, nw, nh); - var gradient = ctx_poster.createLinearGradient(0, 0, 0, canvas_poster.height); - gradient.addColorStop(0, 'rgba(0, 0, 0, 1)'); - gradient.addColorStop(0.5, 'rgba(0, 0, 0, 1)'); - gradient.addColorStop(0.6, 'rgba(0, 0, 0, 0)'); - gradient.addColorStop(1, 'rgba(0, 0, 0, 0)'); - ctx_poster.globalCompositeOperation = 'destination-in'; - ctx_poster.fillStyle = gradient; - ctx_poster.fillRect(0, 0, canvas_poster.width, canvas_poster.height); - ctx_poster.globalCompositeOperation = 'source-over'; - ctx_poster.drawImage(blured, 0, 0); - getImg(callback); - }); - }); - }, 100); - } - - function rgbToHex(r, g, b) { - return "#" + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1); - } - - var Color = { - get: get$9, - extract: extract$1, - palette: palette, - rgba: rgba, - blur: blur$1, - tone: tone, - rgbToHsl: rgbToHsl, - rgbToHex: rgbToHex, - hslToRgb: hslToRgb$1, - blurPoster: blurPoster - }; - - var html$f = $("\n
    \n \n \n
    "); - var background = { - one: { - canvas: $('.background__one', html$f), - ctx: $('.background__one', html$f)[0].getContext('2d') - }, - two: { - canvas: $('.background__two', html$f), - ctx: $('.background__two', html$f)[0].getContext('2d') - } - }; - var theme_elem = $('head meta[name="theme-color"]'); - var view = 'one'; - var src = ''; - var loaded$1 = {}; - var bokeh = { - c: [], - h: [], - d: true - }; - var timer$5; - var timer_resize; - var timer_change; - var immed_time = Date.now(); - /** - * Запуск - */ - - function init$w() { - Storage.listener.follow('change', function (event) { - if (event.name == 'background' || event.name == 'background_type') resize(); - }); - var u = Platform.any() ? 'https://yumata.github.io/lampa/' : './'; - - if (Platform.is('orsay')) { - u = './'; - } - - for (var i = 1; i <= 6; i++) { - var im = new Image(); - im.src = u + 'img/bokeh-h/' + i + '.png'; - bokeh.h.push(im); - } - - for (var _i = 1; _i <= 6; _i++) { - var _im = new Image(); - - _im.src = u + 'img/bokeh/' + _i + '.png'; - bokeh.c.push(_im); - } - - $(window).on('resize', resize); - } - /** - * Получить активный фон - * @returns {{canvas:object, ctx: class}} - */ - - - function bg() { - clearTimeout(timer_change); - timer_change = setTimeout(function () { - html$f.find('canvas').eq(view == 'one' ? 1 : 0).removeClass('visible'); - }, 400); - view = view == 'one' ? 'two' : 'one'; - return background[view]; - } - /** - * Рисовать - * @param {object} data - * @param {object} item - фон - * @param {boolean} noimage - */ - - - function draw(data, item, noimage) { - if (!Storage.get('background', 'true') || noimage) { - background.one.canvas.removeClass('visible'); - background.two.canvas.removeClass('visible'); - return; - } - - item.canvas[0].width = window.innerWidth; - item.canvas[0].height = window.innerHeight; - var palette = data.palette; - var type = Storage.field('background_type'); - blur(data, item, function () { - if (type == 'complex' && bokeh.d) { - var bright = Color.rgbToHsl(palette.average[0], palette.average[1], palette.average[2]); - item.ctx.globalAlpha = bright[2] > 30 ? bright[2] / 100 * 0.6 : 0.4; - item.ctx.globalCompositeOperation = bright[2] > 30 ? 'color-dodge' : 'screen'; - - for (var i = 0; i < 10; i++) { - var bp = Math.round(Math.random() * (bokeh.c.length - 1)); - var im = bright[2] > 30 ? bokeh.h[bp] : bokeh.c[bp]; - var xp = window.innerWidth * Math.random(), - yp = window.innerHeight / 2 * Math.random() + window.innerHeight / 2, - sz = Math.max(window.innerHeight / 8, window.innerHeight / 5 * Math.random()) * 0.01, - nw = im.width * sz, - nh = im.height * sz; - - try { - item.ctx.drawImage(im, xp - nw / 2, yp - nw / 2, nw, nh); - } catch (e) {} - } - } - - item.ctx.globalAlpha = type == 'poster' ? 0.7 : 0.6; - item.ctx.globalCompositeOperation = 'multiply'; - var angle = 90 * Math.PI / 180, - x2 = item.canvas[0].width * Math.cos(angle), - y2 = item.canvas[0].height * Math.sin(angle); - var gradient = item.ctx.createLinearGradient(0, 0, x2, y2); - gradient.addColorStop(0, 'rgba(0,0,0,1)'); - gradient.addColorStop(1, 'rgba(0,0,0,0)'); - item.ctx.fillStyle = gradient; - item.ctx.fillRect(0, 0, item.canvas[0].width, item.canvas[0].height); - - if (Platform.screen('mobile')) { - item.ctx.globalAlpha = 1; - item.ctx.globalCompositeOperation = 'destination-out'; - gradient = item.ctx.createLinearGradient(0, 0, x2, y2); - gradient.addColorStop(0.05, 'rgba(29,31,32,1)'); - gradient.addColorStop(0.18, 'rgba(' + palette.bright.join(',') + ',0)'); - item.ctx.fillStyle = gradient; - item.ctx.fillRect(0, 0, item.canvas[0].width, item.canvas[0].height); - } - - item.canvas.addClass('visible'); - if (!Player.opened()) theme('reset'); - }); - } - /** - * Размыть картинку - * @param {object} data - * @param {object} item - фон - * @param {function} complite - */ - - - function blur(data, item, complite) { - function blured(img) { - var ratio = Math.max(item.canvas[0].width / img.width, item.canvas[0].height / img.height); - var nw = img.width * ratio, - nh = img.height * ratio; - item.ctx.globalAlpha = data.img.width > 1000 ? bokeh.d ? 0.7 : 0.2 : 1; - item.ctx.drawImage(img, -(nw - item.canvas[0].width) / 2, -(nh - item.canvas[0].height) / 2, nw, nh); - complite(); - } - - if (data.img.width > 1000) blured(data.img);else Color.blur(data.img, blured); - } - /** - * Обновить если изменился размер окна - */ - - - function resize() { - clearTimeout(timer_resize); - html$f.find('canvas').removeClass('visible'); - timer_resize = setTimeout(function () { - background.one.canvas.width(window.innerWidth); - background.one.canvas.height(window.innerHeight); - background.two.canvas.width(window.innerWidth); - background.two.canvas.height(window.innerHeight); - if (loaded$1[src]) draw(loaded$1[src], background[view]); - }, 200); - } - /** - * Максимум картинок в памяти - */ - - - function limit$1() { - var a = Arrays.getKeys(loaded$1); - - if (a.length > 30) { - var u = a.slice(0, 1); - delete loaded$1[u]; - } - } - /** - * Загрузить картинку в память - */ - - - function load$2() { - if (loaded$1[src]) { - draw(loaded$1[src], bg()); - } else if (src) { - limit$1(); - var cache_src = src; - var colors; - var img = new Image(); - img.crossOrigin = "Anonymous"; - - img.onload = function () { - try { - colors = Color.get(img); - } catch (e) { - colors = [[200, 200, 200], [100, 100, 100], [10, 10, 10]]; - } - - loaded$1[cache_src] = { - img: img, - palette: Color.palette(colors) - }; - draw(loaded$1[cache_src], bg()); - ImageCache.write(img, img.src); - }; - - img.onerror = function () { - draw(false, false, true); - }; - - ImageCache.read(img, src); - } - } - /** - * Изменить картинку - * @param {string} url - */ - - - function change() { - var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - if (url == src || Storage.field('light_version')) return; - bokeh.d = true; - if (url) src = url; - clearTimeout(timer$5); - timer$5 = setTimeout(function () { - if (url) load$2();else draw(false, false, true); - }, 1000); - } - /** - * Изменить немедленно без ожидания - * @param {string} url - */ - - - function immediately() { - var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - if (Storage.field('light_version') || immed_time + 1000 > Date.now()) return; - if (url) src = url; - clearTimeout(timer$5); - bokeh.d = false; - immed_time = Date.now(); - if (url) load$2();else draw(false, false, true); - } - - function theme(color) { - if (color == 'black') color = '#000000';else if (color == 'reset') color = '#1d1f20'; - theme_elem.attr('content', color); - } - /** - * Рендер - * @returns {object} - */ - - - function render$c() { - return html$f; - } - - var Background = { - render: render$c, - change: change, - update: resize, - init: init$w, - immediately: immediately, - theme: theme - }; - - function create$i() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var card = Template$1.js('more'); - card.querySelector('.card-more__title').innerText = Lang.translate('more'); - - if (params.card_small) { - card.classList.add('card-more--small'); - } - - this.create = function () { - var _this = this; - - card.addEventListener('hover:focus', function (e) { - _this.onFocus(e.target); - }); - card.addEventListener('hover:enter', function (e) { - _this.onEnter(e.target); - }); - }; - - this.render = function (js) { - return js ? card : $(card); - }; - - this.destroy = function () { - card.remove(); - card = null; - }; - } - - function create$h(data) { - var _this = this; - - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var content = Template$1.js('items_line', { - title: data.title - }); - var body = content.querySelector('.items-line__body'); - var scroll = new create$q({ - horizontal: true, - step: params.card_wide ? 600 : 300 - }); - var items = []; - var active = 0; - var tv = Platform.screen('tv'); - var view = (tv ? Lampa.Storage.field('interface_size') == 'small' ? 7 : 6 : 12) + (params.align_left ? 4 : 0); - var more; - var last; - - var onmore = function onmore() { - if (_this.onEnter) _this.onEnter(); - - if (_this.onMore) { - _this.onMore(data); - } else { - Activity$1.push({ - url: data.url, - title: data.title || Lang.translate('title_category'), - component: 'category_full', - page: 1, - genres: params.genres, - filter: data.filter, - source: data.source || params.object.source - }); - } - }; - - this.event = function (type) { - Lampa.Listener.send('line', { - line: this, - type: type, - params: params, - data: data, - scroll: scroll, - body: body, - items: items, - active: active - }); - }; - - this.create = function () { - var _this2 = this; - - this.event('create'); - scroll.body(true).classList.add('items-cards'); - content.querySelector('.items-line__title').innerHTML = data.title; - content.classList.add('items-line--type-' + (params.type || 'none')); - content.addEventListener('visible', this.visible.bind(this)); - data.results.slice(0, view).forEach(this.append.bind(this)); - body.appendChild(scroll.render(true)); - - scroll.onWheel = function (step) { - if (!Controller.own(_this2)) _this2.toggle(); - Controller.enabled().controller[step > 0 ? 'right' : 'left'](); - }; - - scroll.onScroll = this.attach.bind(this); - }; - /* - События - - this.onAppend = function(){} - this.onFocus = function(){} - this.onEnter = function(){} - this.onSelect = function(){} - this.onMore = function(){} - this.onFocusMore = function(){} - this.onLeft = function(){} - this.onBack = function(){} - this.onDown = function(){} - this.onUp = function(){} - */ - - - this.visible = function () { - data.results.slice(0, view).forEach(this.append.bind(this)); - - if ((data.results.length >= 20 || data.more) && !params.nomore) { - var button = document.createElement('div'); - button.classList.add('items-line__more'); - button.classList.add('selector'); - button.innerText = Lang.translate('more'); - button.addEventListener('hover:enter', onmore); - content.querySelector('.items-line__head').appendChild(button); - } - - this.event('visible'); - Layer.visible(scroll.render(true)); - }; - - this.append = function (element) { - var _this3 = this; - - if (element.ready) return; - element.ready = true; - var card = params.cardClass ? params.cardClass(element, params) : new Card(element, params); - card.create(); - - card.onFocus = function (target, card_data) { - last = target; - var prev_active = active; - active = items.indexOf(card); - if (active > 0 || prev_active > active) scroll.update(items[active].render(true), params.align_left ? false : true); - if (!data.noimage) Background.change(Utils$2.cardImgBackground(card_data)); - if (_this3.onFocus) _this3.onFocus(card_data); - }; - - card.onEnter = function (target, card_data) { - last = target; - if (_this3.onEnter) _this3.onEnter(target, card_data); - if (_this3.onSelect) return _this3.onSelect(target, card_data); - if (!card_data.source) card_data.source = params.object.source; - - if (typeof card_data.gender !== 'undefined') { - Activity$1.push({ - url: card_data.url, - title: Lang.translate('title_person'), - component: 'actor', - id: card_data.id, - source: card_data.source || params.object.source - }); - } else { - Activity$1.push({ - url: card_data.url, - component: 'full', - id: card_data.id, - method: card_data.name ? 'tv' : 'movie', - card: card_data, - source: card_data.source || params.object.source - }); - } - }; - - card.onHover = function (target, card_data) { - if (_this3.onHover) _this3.onHover(card_data); - }; - - card.onVisible = function () { - if (Controller.own(_this3)) Controller.collectionAppend(card.render(true)); - }; - - if (this.onMenu) card.onMenu = this.onMenu; - - if (params.card_events) { - for (var i in params.card_events) { - card[i] = params.card_events[i]; - } - } - - scroll.append(card.render(true)); - items.push(card); - if (this.onAppend) this.onAppend(card); - this.event('append'); - return card.render(true); - }; - - this.more = function () { - var _this4 = this; - - more = new create$i(params); - more.create(); - - more.onFocus = function (target) { - last = target; - active = items.indexOf(more); - scroll.update(more.render(true), params.align_left ? false : true); - if (_this4.onFocusMore) _this4.onFocusMore(); - }; - - more.onEnter = onmore.bind(this); - scroll.append(more.render(true)); - items.push(more); - return more.render(true); - }; - - this.attach = function () { - var size = tv ? (Math.round(active / view) + 1) * view + 1 : data.results.length; - data.results.slice(0, size).filter(function (e) { - return !e.ready; - }).forEach(this.append.bind(this)); - - if (!more && !params.nomore && data.results.length == data.results.filter(function (e) { - return e.ready; - }).length && data.results.length >= 20) { - var more_item = this.more(); - if (Controller.own(this)) Controller.collectionAppend(more_item); - } - - Layer.visible(scroll.render(true)); - }; - - this.toggle = function () { - var _this5 = this; - - Controller.add('items_line', { - link: this, - toggle: function toggle() { - Controller.collectionSet(scroll.render(true)); - Controller.collectionFocus(items.length ? last : false, scroll.render(true)); - if (_this5.onToggle) _this5.onToggle(_this5); - - _this5.event('toggle'); - }, - update: function update() {}, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else if (_this5.onLeft) _this5.onLeft();else Controller.toggle('menu'); - }, - down: this.onDown, - up: this.onUp, - gone: function gone() {}, - back: this.onBack - }); - Controller.toggle('items_line'); - }; - - this.render = function (js) { - return js ? content : $(content); - }; - - this.destroy = function () { - Arrays.destroy(items); - scroll.destroy(); - content.remove(); - items = null; - this.event('destroy'); - }; - } - - var html$e; - var scroll$1; - var active$4 = 0; - var items$1 = []; - var listener$f = start$8(); - - function init$v() { - html$e = Template$1.js('player_footer'); - scroll$1 = new create$q({ - nopadding: true, - over: true - }); - - scroll$1.onWheel = function (step) { - if (step > 0) down();else if (active$4 > 0) up(); - }; - - html$e.find('.player-footer__body').append(scroll$1.render(true)); - Controller.add('player_footer', { - toggle: function toggle() { - items$1[active$4].toggle(); - open$4(); - }, - up: close$4, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - Navigator.move('left'); - }, - back: close$4 - }); - } - - function open$4() { - html$e.addClass('open'); - listener$f.send('open'); - } - - function close$4() { - html$e.removeClass('open'); - listener$f.send('close'); - } - - function appendElement(element) { - var classElement = new function () { - var div = document.createElement('div'); - div.append(element); - - this.toggle = function () { - var _this = this; - - Controller.add('player_footer_element', { - toggle: function toggle() { - Controller.collectionSet(div); - Controller.collectionFocus(false, div); - - _this.onToggle(); - }, - up: this.onUp, - down: this.onDown, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - Navigator.move('left'); - }, - back: this.onBack - }); - Controller.toggle('player_footer_element'); - }; - - this.render = function () { - return div; - }; - - this.destroy = function () { - div.remove(); - }; - }(); - appendClass(classElement); - } - - function up() { - active$4--; - - if (active$4 < 0) { - active$4 = 0; - close$4(); - } else { - items$1[active$4].toggle(); - scroll$1.update(items$1[active$4].render(true)); - } - } - - function down() { - active$4++; - active$4 = Math.min(active$4, items$1.length - 1); - scroll$1.update(items$1[active$4].render(true)); - items$1[active$4].toggle(); - } - - function appendClass(classElement) { - classElement.onUp = up; - classElement.onDown = down; - - classElement.onToggle = function () { - scroll$1.render(true).style.height = items$1[active$4].render(true).offsetHeight; - }; - - classElement.onEnter = function () { - close$4(); - Lampa.Player.close(); - }; - - classElement.onBack = close$4; - - classElement.onLeft = function () {}; - - classElement.onMenu = function () {}; - - scroll$1.append(classElement.render(true)); - items$1.push(classElement); - } - - function appendCard(card) { - var card_html = Template$1.js('player_footer_card'); - card_html.find('.player-footer-card__title').text(card.name || card.title); - card_html.find('.player-footer-card__tags').text(card.genres && Arrays.isArray(card.genres) ? card.genres.map(function (a) { - return Utils$2.capitalizeFirstLetter(a.name); - }).join(', ') : '---'); - var text = card_html.find('.player-footer-card__text'); - if (card.overview) text.text(card.overview);else { - card_html.addClass('notext'); - - for (var i = 0; i < 3; i++) { - text.append(document.createElement('div')); - } - } - Utils$2.imgLoad(card_html.find('img'), card.poster_path ? Api.img(card.poster_path, 'w200') : './img/img_broken.svg'); - appendElement(card_html); - } - - function appendContinue(element) { - element.results.forEach(function (e) { - e.ready = false; - }); - var item = new create$h(element, { - url: element.url, - object: {}, - card_wide: element.wide, - card_small: element.small, - card_broad: element.broad, - card_collection: element.collection, - card_category: element.category, - card_events: element.card_events, - cardClass: element.cardClass, - nomore: element.nomore, - type: element.line_type || 'cards' - }); - appendClass(item); - item.create(); - } - - function available() { - return items$1.length; - } - - function destroy$6() { - Arrays.destroy(items$1); - active$4 = 0; - scroll$1.reset(); - items$1 = []; - } - - function render$b() { - return html$e; - } - - var Footer = { - init: init$v, - listener: listener$f, - appendCard: appendCard, - appendContinue: appendContinue, - render: render$b, - destroy: destroy$6, - available: available - }; - - var html$d; - var listener$e = start$8(); - var state; - var elems$1; - var panel_visible = false; - var timeline_last = { - position: 0, - peding: 0 - }; - var condition = {}; - var timer$4 = {}; - var tracks = []; - var subs = []; - var qualitys = false; - var translates = {}; - var last_settings_action; - var last_panel_focus; - - function init$u() { - html$d = Template$1.get('player_panel'); - elems$1 = { - peding: $('.player-panel__peding', html$d), - position: $('.player-panel__position', html$d), - time: $('.player-panel__time', html$d), - timenow: $('.player-panel__timenow', html$d), - timeend: $('.player-panel__timeend', html$d), - title: $('.player-panel__filename', html$d), - tracks: $('.player-panel__tracks', html$d), - subs: $('.player-panel__subs', html$d), - timeline: $('.player-panel__timeline', html$d), - quality: $('.player-panel__quality', html$d), - episode: $('.player-panel__next-episode-name', html$d), - rewind_touch: $('.player-panel__time-touch-zone', html$d), - iptv_channel: $('.player-panel-iptv__channel', html$d), - iptv_arrow_up: $('.player-panel-iptv__arrow-up', html$d), - iptv_arrow_down: $('.player-panel-iptv__arrow-down', html$d), - iptv_position: $('.player-panel-iptv__position', html$d) - }; - /** - * Отсеживаем состояние, - * когда надо показать панель, а когда нет - */ - - state = new create$n({ - state: 'start', - transitions: { - start: function start() { - clearTimeout(timer$4.hide); - clearTimeout(timer$4.rewind); - this.dispath('canplay'); - }, - canplay: function canplay() { - if (condition.canplay) this.dispath('visible');else _visible(true); - }, - visible: function visible() { - if (condition.visible) _visible(true);else this.dispath('rewind'); - }, - rewind: function rewind() { - var _this = this; - - clearTimeout(timer$4.rewind); - - if (condition.rewind) { - _visible(true); - - timer$4.rewind = setTimeout(function () { - condition.rewind = false; - - _this.dispath('mousemove'); - }, 1000); - } else { - this.dispath('mousemove'); - } - }, - mousemove: function mousemove() { - if (condition.mousemove) { - _visible(true); - } - - this.dispath('hide'); - }, - hide: function hide() { - clearTimeout(timer$4.hide); - timer$4.hide = setTimeout(function () { - if (PlayerIPTV.playning()) { - PlayerIPTV.reset(); - Controller.toggle('player'); - } else if (!PlayerVideo.video().paused) _visible(false); - }, PlayerIPTV.playning() ? 5000 : 3000); - } - } - }); - html$d.find('.selector').on('hover:focus', function (e) { - }); - html$d.find('.player-panel__playpause').on('hover:enter', function (e) { - listener$e.send('playpause', {}); - }); - html$d.find('.player-panel__next').on('hover:enter', function (e) { - listener$e.send('next', {}); - }); - html$d.find('.player-panel__prev').on('hover:enter', function (e) { - listener$e.send('prev', {}); - }); - html$d.find('.player-panel__rprev').on('hover:enter', function (e) { - listener$e.send('rprev', {}); - }); - html$d.find('.player-panel__rnext').on('hover:enter', function (e) { - listener$e.send('rnext', {}); - }); - html$d.find('.player-panel__playlist').on('hover:enter', function (e) { - listener$e.send('playlist', {}); - }); - html$d.find('.player-panel__tstart').on('hover:enter', function (e) { - listener$e.send('to_start', {}); - }); - html$d.find('.player-panel__tend').on('hover:enter', function (e) { - listener$e.send('to_end', {}); - }); - html$d.find('.player-panel__fullscreen').on('hover:enter', function (e) { - listener$e.send('fullscreen', {}); - }); - html$d.find('.player-panel__settings').on('hover:enter', settings); - html$d.find('.player-panel__pip,.player-panel__volume').toggleClass('hide', !Boolean(Platform.is('nw') || Platform.is('browser') || Platform.is('apple') && !Utils$2.isPWA())); - html$d.find('.player-panel__pip').on('hover:enter', function () { - listener$e.send('pip', {}); - }); - elems$1.timeline.attr('data-controller', 'player_rewind'); - elems$1.rewind_touch.toggleClass('hide', !Platform.screen('mobile')); - elems$1.timeline.on('mousemove', function (e) { - if (!Platform.screen('mobile')) listener$e.send('mouse_rewind', { - method: 'move', - time: elems$1.time, - percent: percent(e) - }); - }).on('mouseout', function () { - if (!Platform.screen('mobile')) elems$1.time.addClass('hide'); - }).on('click', function (e) { - if (DeviceInput.canClick(e.originalEvent) && !Platform.screen('mobile')) listener$e.send('mouse_rewind', { - method: 'click', - time: elems$1.time, - percent: percent(e) - }); - }); - - if (!html$d.find('.player-panel__volume').hasClass('hide')) { - html$d.find('.player-panel__volume-range').val(Storage.get('player_volume', '1')).on('input', function () { - listener$e.send('change_volume', { - volume: $(this).val() - }); - PlayerVideo.changeVolume($(this).val()); - }); - } - - var touch; - - var touchEnd = function touchEnd(e) { - window.removeEventListener('touchend', touchEnd); - PlayerVideo.video().rewind = false; - listener$e.send('mouse_rewind', { - method: 'click', - time: elems$1.time, - percent: touch.to / 100 - }); - touch = false; - }; - - elems$1.rewind_touch.on('touchstart', function (e) { - var point = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]; - touch = { - now: percent({ - clientX: elems$1.position.width() - }) * 100, - from: percent(point) * 100 - }; - touch.move = touch.from; - touch.to = touch.from; - window.addEventListener('touchend', touchEnd); - }).on('touchmove', function (e) { - var point = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]; - - if (touch) { - touch.move = percent(point) * 100; - touch.to = Math.max(0, Math.min(100, touch.now + (touch.move - touch.from))); - elems$1.position.width(touch.to + '%'); - PlayerVideo.video().rewind = true; - rewind$1(); - } - }); - html$d.find('.player-panel__line:eq(1) .selector').attr('data-controller', 'player_panel'); - html$d.find('.player-panel__left .selector,.player-panel__center .selector,.player-panel__right .selector').on('hover:focus', function () { - last_panel_focus = $(this)[0]; - }); - /** - * Выбор качества - */ - - elems$1.quality.text('auto').on('hover:enter', function () { - if (qualitys) { - var qs = []; - var nw = elems$1.quality.text(); - - if (Arrays.isArray(qualitys)) { - qs = qualitys; - } else { - for (var i in qualitys) { - qs.push({ - title: i, - url: qualitys[i], - selected: nw == i - }); - } - } - - if (!qs.length) return; - var enabled = Controller.enabled(); - Select.show({ - title: Lang.translate('player_quality'), - items: qs, - onSelect: function onSelect(a) { - elems$1.quality.text(a.title); - qs.forEach(function (q) { - return q.selected = false; - }); - a.enabled = true; - a.selected = true; - if (!Arrays.isArray(qualitys) || a.change_quality) listener$e.send('quality', { - name: a.title, - url: a.url - }); - Controller.toggle(enabled.name); - }, - onBack: function onBack() { - Controller.toggle(enabled.name); - } - }); - } - }); - /** - * Выбор аудиодорожки - */ - - elems$1.tracks.on('hover:enter', function (e) { - if (tracks.length) { - tracks.forEach(function (element, p) { - var name = []; - var from = translates.tracks && Arrays.isArray(translates.tracks) && translates.tracks[p] ? translates.tracks[p] : element; - name.push(p + 1); - name.push(normalName(from.language || from.name || Lang.translate('player_unknown'))); - if (from.label) name.push(normalName(from.label)); - - if (from.extra) { - if (from.extra.channels) name.push(from.extra.channels + ' Ch'); - if (from.extra.fourCC) name.push(from.extra.fourCC); - } - - element.title = name.join(' / '); - }); - var enabled = Controller.enabled(); - Select.show({ - title: Lang.translate('player_tracks'), - items: tracks, - onSelect: function onSelect(a) { - tracks.forEach(function (element) { - element.enabled = false; - element.selected = false; - }); - a.enabled = true; - a.selected = true; - Controller.toggle(enabled.name); - }, - onBack: function onBack() { - Controller.toggle(enabled.name); - } - }); - } - }); - /** - * Выбор субтитров - */ - - elems$1.subs.on('hover:enter', function (e) { - if (subs.length) { - if (subs[0].index !== -1) { - var any_select = subs.find(function (s) { - return s.selected; - }); - Arrays.insert(subs, 0, { - title: Lang.translate('player_disabled'), - selected: any_select ? false : true, - index: -1 - }); - } - - subs.forEach(function (element, p) { - if (element.index !== -1) { - var track_num = element.extra && element.extra.track_num ? parseInt(element.extra.track_num) : element.index; - var from = translates.subs && Arrays.isArray(translates.subs) && translates.subs[track_num] ? translates.subs[track_num] : element; - element.title = p + ' / ' + normalName(from.language && from.label ? from.language + ' / ' + from.label : from.language || from.label || Lang.translate('player_unknown')); - } - }); - var enabled = Controller.enabled(); - Select.show({ - title: Lang.translate('player_subs'), - items: subs, - onSelect: function onSelect(a) { - subs.forEach(function (element) { - element.mode = 'disabled'; - element.selected = false; - }); - a.mode = 'showing'; - a.selected = true; - listener$e.send('subsview', { - status: a.index > -1 - }); - Controller.toggle(enabled.name); - }, - onBack: function onBack() { - Controller.toggle(enabled.name); - } - }); - } - }); - PlayerIPTV.listener.follow('channel', channel); - PlayerIPTV.listener.follow('draw-program', program); - Footer.listener.follow('open', function () { - html$d.addClass('panel--footer-open'); - }); - Footer.listener.follow('close', function () { - html$d.removeClass('panel--footer-open'); - Controller.toggle('player_panel'); - }); - } - - function hideRewind() { - html$d.addClass('panel--norewind'); - } - - function showParams() { - var enabled = Controller.enabled().name; - var items = []; - items.push({ - title: Lang.translate('player_tracks'), - trigger: elems$1.tracks, - ghost: elems$1.tracks.hasClass('hide'), - noenter: elems$1.tracks.hasClass('hide') - }); - items.push({ - title: Lang.translate('player_subs'), - trigger: elems$1.subs, - ghost: elems$1.subs.hasClass('hide'), - noenter: elems$1.subs.hasClass('hide') - }); - items.push({ - title: Lang.translate('player_quality'), - trigger: elems$1.quality, - ghost: !qualitys, - noenter: !qualitys - }); - items.push({ - title: Lang.translate('settings_main_rest'), - trigger: html$d.find('.player-panel__settings') - }); - Select.show({ - title: Lang.translate('title_settings'), - items: items, - onSelect: function onSelect(a) { - Controller.toggle(enabled); - a.trigger.trigger('hover:enter'); - }, - onBack: function onBack() { - Controller.toggle(enabled); - } - }); - } - - function program(data) { - if (elems$1.iptv_channel_active) { - var prog = elems$1.iptv_channel_active.find('.player-panel-iptv-item__prog'); - PlayerIPTV.drawProgram(prog); - playAnimation(prog, data.dir > 0 ? 'endless-left' : 'endless-right'); - } - } - - function playAnimation(elem, anim) { - elem.css('animation', 'none'); - elem[0].offsetHeight; - elem.css('animation', (anim || 'pulse') + ' 0.2s ease'); - } - - function channel(data) { - var select = PlayerIPTV.select(); - elems$1.iptv_channel.removeClass('up down'); - var active = elems$1.iptv_channel.find('.active'); - elems$1.iptv_channel.find('> div:not(.active)').remove(); - var new_item = $("\n
    \n
    \n \n
    \n
    \n
    ".concat(select.group, "
    \n
    ").concat(select.name, "
    \n
    \n
    ").concat(Lang.translate('loading'), "...
    \n
    \n
    \n
    \n ")); - - if (select.icons) { - select.icons.forEach(function (ic) { - new_item.find('.player-panel-iptv-item__name').append($('
    ' + ic + '
    ')); - }); - } - - var ico = new_item.find('.player-panel-iptv-item__ico'); - var img = ico[0]; - - img.onload = function () { - ico.addClass('loaded'); - }; - - img.onerror = function () { - ico.remove(); - $('.player-panel-iptv-item__left', new_item).append("\n \n \n \n \n \n \n "); - }; - - if (select.logo) img.src = select.logo;else img.onerror(); - new_item.css({ - '-webkit-transform': 'translate3d(0,' + (data.dir > 0 ? '100%' : '-100%') + ',0)' - }); - elems$1.iptv_channel.append(new_item); - elems$1.iptv_channel_active = new_item; - playAnimation(elems$1.iptv_position); - playAnimation(data.dir > 0 ? elems$1.iptv_arrow_down : elems$1.iptv_arrow_up); - setTimeout(function () { - new_item.css({ - '-webkit-transform': 'translate3d(0,0,0)', - opacity: 1 - }); - if (active.length) active.removeClass('active').css({ - '-webkit-transform': 'translate3d(0,' + (data.dir > 0 ? '-100%' : '100%') + ',0)', - opacity: 0 - }); - elems$1.iptv_position.text((data.position + 1).pad(3)); - }, 10); - } - - function settings() { - var speed = Storage.get('player_speed', 'default'); - var items = [{ - title: Lang.translate('player_video_size'), - subtitle: Lang.translate('player_size_' + Storage.get('player_size', 'default') + '_title'), - method: 'size' - }, { - title: Lang.translate('player_video_speed'), - subtitle: speed == 'default' ? Lang.translate('player_speed_default_title') : speed, - method: 'speed' - }, { - title: Lang.translate('player_share_title'), - subtitle: Lang.translate('player_share_descr'), - method: 'share' - }]; - - if (Storage.field('player_normalization')) { - items.push({ - title: Lang.translate('player_normalization'), - separator: true - }); - items.push({ - title: Lang.translate('player_normalization_power_title'), - subtitle: Lang.translate('player_normalization_step_' + Storage.get('player_normalization_power', 'hight')), - method: 'normalization_power' - }); - items.push({ - title: Lang.translate('player_normalization_smooth_title'), - subtitle: Lang.translate('player_normalization_step_' + Storage.get('player_normalization_smooth', 'medium')), - method: 'normalization_smooth' - }); - } - - if (last_settings_action) { - items.find(function (a) { - return a.method == last_settings_action; - }).selected = true; - } - - Select.show({ - title: Lang.translate('title_settings'), - items: items, - nomark: true, - onSelect: function onSelect(a) { - last_settings_action = a.method; - if (a.method == 'size') selectSize(); - if (a.method == 'speed') selectSpeed(); - if (a.method == 'normalization_power') selectNormalizationStep('power', 'hight'); - if (a.method == 'normalization_smooth') selectNormalizationStep('smooth', 'medium'); - - if (a.method == 'share') { - Controller.toggle(Platform.screen('mobile') ? 'player' : 'player_panel'); - listener$e.send('share', {}); - } - }, - onBack: function onBack() { - Controller.toggle(Platform.screen('mobile') ? 'player' : 'player_panel'); - } - }); - } - - function selectNormalizationStep(type, def) { - var select = Storage.get('player_normalization_' + type, def); - var items = [{ - title: Lang.translate('player_normalization_step_none'), - value: 'none', - selected: select == 'none' - }, { - title: Lang.translate('player_normalization_step_low'), - value: 'low', - selected: select == 'low' - }, { - title: Lang.translate('player_normalization_step_medium'), - value: 'medium', - selected: select == 'medium' - }, { - title: Lang.translate('player_normalization_step_hight'), - value: 'hight', - selected: select == 'hight' - }]; - Select.show({ - title: Lang.translate('player_normalization_' + type + '_title'), - items: items, - nohide: true, - onBack: settings, - onSelect: function onSelect(a) { - Storage.set('player_normalization_' + type, a.value); - settings(); - } - }); - } - /** - * Выбор масштаба видео - */ - - - function selectSize() { - var select = Storage.get('player_size', 'default'); - var items = [{ - title: Lang.translate('player_size_default_title'), - subtitle: Lang.translate('player_size_default_descr'), - value: 'default', - selected: select == 'default' - }, { - title: Lang.translate('player_size_cover_title'), - subtitle: Lang.translate('player_size_cover_descr'), - value: 'cover', - selected: select == 'cover' - }]; - - if (Platform.is('orsay') && Storage.field('player') == 'orsay') { - items.splice(1, 1); - } - - if (!(Platform.is('tizen') && Storage.field('player') == 'tizen')) { - items = items.concat([{ - title: Lang.translate('player_size_fill_title'), - subtitle: Lang.translate('player_size_fill_descr'), - value: 'fill', - selected: select == 'fill' - }, { - title: Lang.translate('player_size_s115_title'), - subtitle: Lang.translate('player_size_s115_descr'), - value: 's115', - selected: select == 's115' - }, { - title: Lang.translate('player_size_s130_title'), - subtitle: Lang.translate('player_size_s130_descr'), - value: 's130', - selected: select == 's130' - }, { - title: Lang.translate('player_size_v115_title'), - subtitle: Lang.translate('player_size_v115_descr'), - value: 'v115', - selected: select == 'v115' - }, { - title: Lang.translate('player_size_v130_title'), - subtitle: Lang.translate('player_size_v130_descr'), - value: 'v130', - selected: select == 'v130' - }]); - } else { - if (select == 's130' || select == 'fill') { - items[0].selected = true; - } - } - - Select.show({ - title: Lang.translate('player_video_size'), - items: items, - nohide: true, - onSelect: function onSelect(a) { - listener$e.send('size', { - size: a.value - }); - }, - onBack: settings - }); - } - - function selectSpeed() { - var select = Storage.get('player_speed', 'default'); - var items = [{ - title: '0.25', - value: '0.25' - }, { - title: '0.50', - value: '0.50' - }, { - title: '0.75', - value: '0.75' - }, { - title: Lang.translate('player_speed_default_title'), - value: 'default' - }, { - title: '1.25', - value: '1.25' - }, { - title: '1.50', - value: '1.50' - }, { - title: '1.75', - value: '1.75' - }, { - title: '2', - value: '2' - }]; - - if (Platform.is('tizen') && Storage.field('player') == 'tizen' || Platform.is('orsay') && Storage.field('player') == 'orsay') { - items = [{ - title: Lang.translate('player_speed_default_title'), - value: 'default', - selected: select == 'default' - }, { - title: '2', - subtitle: Platform.is('orsay') && Storage.field('player') == 'orsay' ? Lang.translate('player_speed_two_descr') : '', - value: '2' - }]; - } - - var any; - items.forEach(function (e) { - if (e.value == select) { - any = true; - e.selected = true; - } - }); - - if (!any) { - Storage.set('player_speed', 'default'); - if (items.length == 3) items[0].selected = true;else items[3].selected = true; - } - - Select.show({ - title: Lang.translate('player_video_speed'), - items: items, - nohide: true, - onSelect: function onSelect(a) { - Storage.set('player_speed', a.value); - listener$e.send('speed', { - speed: a.value - }); - settings(); - }, - onBack: settings - }); - } - - function isTV() { - return $('body > .player').hasClass('tv'); - } - - function normalName(name) { - return name.replace(/^[0-9]+(\.)?([\t ]+)?/, '').replace(/\s#[0-9]+/, ''); - } - /** - * Добавить контроллеры - */ - - - function addController() { - Controller.add('player_tv', { - invisible: true, - toggle: function toggle() { - Controller.clear(); - condition.visible = false; - state.start(); - }, - up: function up() { - PlayerIPTV.prevChannel(); - state.start(); - }, - down: function down() { - PlayerIPTV.nextChannel(); - state.start(); - }, - left: function left() { - condition.visible = true; - PlayerIPTV.openMenu(); - state.start(); - }, - right: function right() { - condition.visible = true; - showParams(); - state.start(); - }, - enter: function enter() { - PlayerIPTV.play(); - state.start(); - }, - back: function back() { - PlayerIPTV.reset(); - Controller.toggle('player'); - hide$1(); - } - }); - Controller.add('player_rewind', { - toggle: function toggle() { - Controller.collectionSet(render$a()); - Controller.collectionFocus(false, render$a()); - }, - up: function up() { - Controller.toggle('player'); - }, - down: function down() { - toggleButtons(); - }, - right: function right() { - listener$e.send('rnext', {}); - }, - left: function left() { - listener$e.send('rprev', {}); - }, - gone: function gone() { - html$d.find('.selector').removeClass('focus'); - }, - back: function back() { - Controller.toggle('player'); - hide$1(); - } - }); - Controller.add('player_panel', { - toggle: function toggle() { - if (PlayerIPTV.playning()) Controller.toggle('player_tv');else { - Controller.collectionSet(render$a()); - Controller.collectionFocus(last_panel_focus ? last_panel_focus : $(isTV() ? '.player-panel__next' : '.player-panel__playpause', html$d)[0], render$a()); - } - }, - up: function up() { - isTV() || html$d.hasClass('panel--norewind') ? Controller.toggle('player') : toggleRewind(); - }, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - Navigator.move('left'); - }, - down: function down() { - Footer.available() ? Controller.toggle('player_footer') : listener$e.send('playlist', {}); - }, - gone: function gone() { - html$d.find('.selector').removeClass('focus'); - }, - back: function back() { - Controller.toggle('player'); - hide$1(); - } - }); - } - /** - * Рассчитать проценты - * @param {object} e - * @returns {number} - */ - - - function percent(e) { - var offset = elems$1.timeline.offset(); - var width = elems$1.timeline.width(); - return (e.clientX - offset.left) / width; - } - /** - * Обновляем состояние панели - * @param {string} need - что нужно обновить - * @param {string|number} value - значение - */ - - - function update$6(need, value) { - if (need == 'position') { - timeline_last.position = value; - if (panel_visible) elems$1.position.css({ - width: value - }); - } - - if (need == 'peding') { - timeline_last.peding = value; - if (panel_visible) elems$1.peding.css({ - width: value - }); - } - - if (need == 'timeend') { - elems$1.timeend.text(value); - } - - if (need == 'timenow') { - elems$1.timenow.text(value); - } - - if (need == 'play') { - html$d.toggleClass('panel--paused', false); - } - - if (need == 'pause') { - html$d.toggleClass('panel--paused', true); - } - } - /** - * Показать или скрыть панель - * @param {boolean} status - */ - - - function _visible(status) { - listener$e.send('visible', { - status: status - }); - html$d.toggleClass('panel--visible', status); - panel_visible = status; - elems$1.position.css({ - width: timeline_last.position - }); - elems$1.peding.css({ - width: timeline_last.peding - }); - } - /** - * Можем играть, далее отслеживаем статус - */ - - - function canplay() { - condition.canplay = true; - state.start(); - } - /** - * Перемотка - */ - - - function rewind$1() { - condition.rewind = true; - state.start(); - } - /** - * Переключить на контроллер перемотки - */ - - - function toggleRewind() { - Controller.toggle(isTV() || html$d.hasClass('panel--norewind') ? 'player_panel' : 'player_rewind'); - } - /** - * Переключить на контроллер кнопки - */ - - - function toggleButtons() { - if (!Platform.screen('mobile')) Controller.toggle('player_panel'); - } - /** - * Контроллер - */ - - - function toggle$6() { - condition.visible = true; - state.start(); - if (PlayerIPTV.playning()) Controller.toggle('player_tv');else if (!Platform.screen('mobile')) toggleRewind(); - } - /** - * Показать панель - */ - - - function show$8() { - state.start(); - html$d.find('.player-panel__fullscreen').toggleClass('hide', Platform.tv() || Platform.is('android') || !Utils$2.canFullScreen()); - addController(); - } - /** - * Если двигали мышку - */ - - - function mousemove() { - condition.mousemove = true; - state.start(); - } - /** - * Скрыть панель - */ - - - function hide$1() { - condition.visible = false; - - _visible(false); - } - - function visibleStatus() { - return html$d.hasClass('panel--visible'); - } - /** - * Установить субтитры - * @param {[{index:integer, language:string, label:string}]} su - */ - - - function setSubs(su) { - subs = su; - elems$1.subs.toggleClass('hide', false); - } - /** - * Установить дорожки - * @param {[{index:integer, language:string, label:string}]} tr - */ - - - function setTracks(tr) { - tracks = tr; - elems$1.tracks.toggleClass('hide', false); - } - /** - * Установить качество - * @param {[{title:string, url:string}]} levels - * @param {string} current - */ - - - function setLevels(levels, current) { - if (qualitys && Object.keys(qualitys).length) return; - qualitys = levels; - elems$1.quality.text(current); - } - /** - * Показать текущие качество - * @param {[{title:string, url:string}]} qs - * @param {string} url - */ - - - function quality(qs, url) { - if (qs) { - elems$1.quality.toggleClass('hide', false); - qualitys = qs; - - for (var i in qs) { - if (qs[i] == url) { - elems$1.quality.text(i); - break; - } - } - } - } - /** - * Показать название следующего эпизода - * @param {{position:integer, playlist:[{title:string, url:string}]}} e - */ - - - function showNextEpisodeName(e) { - if (e.playlist[e.position + 1]) { - elems$1.episode.text(e.playlist[e.position + 1].title).toggleClass('hide', false); - } else elems$1.episode.toggleClass('hide', true); - } - /** - * Установить перевод для дорожек и сабов - * @param {{subs:[],tracks:[]}} data - */ - - - function setTranslate(data) { - if (_typeof(data) == 'object') translates = data; - } - - function updateTranslate(where, data) { - if (!translates[where]) translates[where] = data; - } - /** - * Уничтожить - */ - - - function destroy$5() { - condition = {}; - tracks = []; - subs = []; - qualitys = false; - translates = {}; - timeline_last.position = 0; - timeline_last.peding = 0; - last_panel_focus = false; - panel_visible = false; - elems$1.peding.css({ - width: 0 - }); - elems$1.position.css({ - width: 0 - }); - elems$1.time.text('00:00'); - elems$1.timenow.text('00:00'); - elems$1.timeend.text('00:00'); - elems$1.quality.text('auto'); - elems$1.subs.toggleClass('hide', true); - elems$1.tracks.toggleClass('hide', true); - elems$1.episode.toggleClass('hide', true); - html$d.toggleClass('panel--paused', false); - html$d.toggleClass('panel--norewind', false); - } - /** - * Получить html - * @returns {object} - */ - - - function render$a() { - return html$d; - } - - var PlayerPanel = { - init: init$u, - listener: listener$e, - render: render$a, - toggle: toggle$6, - show: show$8, - destroy: destroy$5, - hide: hide$1, - canplay: canplay, - update: update$6, - rewind: rewind$1, - setTracks: setTracks, - setSubs: setSubs, - setLevels: setLevels, - mousemove: mousemove, - quality: quality, - showNextEpisodeName: showNextEpisodeName, - setTranslate: setTranslate, - updateTranslate: updateTranslate, - visible: _visible, - visibleStatus: visibleStatus, - showParams: showParams, - hideRewind: hideRewind - }; - - var subparams; - - var listener$d = function listener(e) { - if (e.code == 405) getWebosmediaId(setSubtitleColor); - if (e.code == 406) getWebosmediaId(setSubtitleBackgroundColor); - if (e.code == 403) getWebosmediaId(setSubtitleFontSize); - if (e.code == 404) getWebosmediaId(setSubtitlePosition); - if (e.code == 55) getWebosmediaId(setSubtitleBackgroundOpacity); - if (e.code == 57) getWebosmediaId(setSubtitleCharacterOpacity); - }; - - Keypad.listener.follow('keydown', listener$d); - - function luna$1(params, call, fail) { - if (call) params.onSuccess = call; - - params.onFailure = function (result) { - console.log('WebOS', params.method + " [fail][" + result.errorCode + "] " + result.errorText); - if (fail) fail(); - }; - - webOS.service.request("luna://com.webos.media", params); - } - - function initStorage() { - if (!subparams) { - subparams = Storage.get('webos_subs_params', '{}'); - Arrays.extend(subparams, { - color: 2, - font_size: 1, - bg_color: 'black', - position: -1, - bg_opacity: 0, - char_opacity: 255 - }); - } - } - - function subCallParams(mediaId, method, func_params) { - var parameters = { - mediaId: mediaId - }; - Arrays.extend(parameters, func_params); - luna$1({ - parameters: parameters, - method: method - }); - Storage.set('webos_subs_params', subparams); - } - - function getWebosmediaId(func) { - var video = document.querySelector('video'); - - if (video && video.mediaId) { - initStorage(); - setTimeout(function () { - subCallParams(video.mediaId, func.name, func()); - }, 300); - } - } - - function setSubtitleColor() { - subparams.color++; - if (subparams.color == 6) subparams.color = 0; - return { - color: subparams.color - }; - } - - function setSubtitleBackgroundColor() { - var bgcolors = ['black', 'white', 'yellow', 'red', 'green', 'blue']; - var ixcolors = bgcolors.indexOf(subparams.bg_color); - ixcolors++; - if (ixcolors == -1) ixcolors = 0; - subparams.bg_color = bgcolors[ixcolors]; - return { - bgColor: subparams.bg_color - }; - } - - function setSubtitleFontSize() { - subparams.font_size++; - if (subparams.font_size == 5) subparams.font_size = 0; - return { - fontSize: subparams.font_size - }; - } - - function setSubtitlePosition() { - subparams.position++; - if (subparams.position == 5) subparams.position = -3; - return { - position: subparams.position - }; - } - - function setSubtitleBackgroundOpacity() { - subparams.bg_opacity += 15; - if (subparams.bg_opacity > 255) subparams.bg_opacity = 0; - return { - bgOpacity: subparams.bg_opacity - }; - } - - function setSubtitleCharacterOpacity() { - subparams.char_opacity += 15; - if (subparams.char_opacity > 255) subparams.char_opacity = 45; - return { - charOpacity: subparams.char_opacity - }; - } - - function initialize() { - var video = document.querySelector('video'); - - if (video && video.mediaId) { - initStorage(); - var methods = ['setSubtitleColor', 'setSubtitleBackgroundColor', 'setSubtitleFontSize', 'setSubtitlePosition', 'setSubtitleBackgroundOpacity', 'setSubtitleCharacterOpacity']; - var parameters = { - mediaId: video.mediaId, - color: subparams.color, - bgColor: subparams.bg_color, - position: subparams.position, - fontSize: subparams.font_size, - bgOpacity: subparams.bg_opacity, - charOpacity: subparams.char_opacity - }; - Arrays.extend(parameters, subparams); - methods.forEach(function (method) { - luna$1({ - parameters: parameters, - method: method - }); - }); - } - } - - var WebosSubs = { - initialize: initialize - }; - - /** - * Для запросов в луну - * @param {object} params - * @param {function} call - * @param {function} fail - */ - - function luna(params, call, fail) { - if (call) params.onSuccess = call; - - params.onFailure = function (result) { - console.log('WebOS', params.method + " [fail][" + result.errorCode + "] " + result.errorText); - if (fail) fail(); - }; - - webOS.service.request("luna://com.webos.media", params); - } - - function create$g(_video) { - var video = _video; - var media_id; - var subtitle_visible = false; - var timer; - var timer_repet; - var count = 0; - var count_message = 0; - var data = { - subs: [], - tracks: [] - }; - this.subscribed = false; - this.repeted = false; - /** - * Начинаем поиск видео - */ - - this.start = function () { - timer = setInterval(this.search.bind(this), 300); - }; - /** - * Включить/выключить сабы - * @param {boolean} status - */ - - - this.toggleSubtitles = function (status) { - subtitle_visible = status; - luna({ - method: 'setSubtitleEnable', - parameters: { - 'mediaId': media_id, - 'enable': status - } - }); - if (status) WebosSubs.initialize(); - }; - /** - * Получили сабы, выводим в панель - * @param {object} info - */ - - - this.subtitles = function (info) { - var _this = this; - - if (info.numSubtitleTracks) { - var all = []; - - var add = function add(sub, index) { - sub.index = index; - sub.language = sub.language == '(null)' ? '' : sub.language; - Object.defineProperty(sub, 'mode', { - set: function set(v) { - if (v == 'showing') { - _this.toggleSubtitles(sub.index == -1 ? false : true); - - console.log('WebOS', 'change subtitles for id: ', media_id, ' index:', sub.index); - - if (sub.index !== -1) { - setTimeout(function () { - luna({ - method: 'selectTrack', - parameters: { - 'type': 'text', - 'mediaId': media_id, - 'index': sub.index - } - }); - }, 500); - } - } - }, - get: function get() {} - }); - all.push(sub); - }; - - add({ - title: Lang.translate('player_disabled'), - selected: true - }, -1); - - for (var i = 0; i < info.subtitleTrackInfo.length; i++) { - add(info.subtitleTrackInfo[i], i); - } - - data.subs = all; - PlayerVideo.listener.send('webos_subs', { - subs: data.subs - }); - PlayerPanel.setSubs(data.subs); - } - }; - /** - * Получили дорожки, выводим в панель - * @param {object} info - */ - - - this.tracks = function (info) { - if (info.numAudioTracks) { - var all = []; - - var add = function add(track, index) { - track.index = index; - track.selected = index == -1; - track.extra = { - channels: track.channels, - fourCC: track.codec - }; - Object.defineProperty(track, 'enabled', { - set: function set(v) { - if (v) { - console.log('WebOS', 'change audio for id:', media_id, ' index:', track.index); - luna({ - method: 'selectTrack', - parameters: { - 'type': 'audio', - 'mediaId': media_id, - 'index': track.index - } - }); - - if (video.audioTracks) { - for (var i = 0; i < video.audioTracks.length; i++) { - video.audioTracks[i].enabled = false; - } - - if (video.audioTracks[track.index]) { - video.audioTracks[track.index].enabled = true; - console.log('WebOS', 'change audio two method:', track.index); - } - } - } - }, - get: function get() {} - }); - all.push(track); - }; - - for (var i = 0; i < info.audioTrackInfo.length; i++) { - add(info.audioTrackInfo[i], i); - } - - data.tracks = all; - PlayerVideo.listener.send('webos_tracks', { - tracks: data.tracks - }); - PlayerPanel.setTracks(data.tracks, true); - } - }; - /** - * Подписываемся на видео и ждем события - */ - - - this.subscribe = function () { - var _this2 = this; - - this.subscribed = true; - luna({ - method: 'subscribe', - parameters: { - 'mediaId': media_id, - 'subscribe': true - } - }, function (result) { - if (result.sourceInfo && !_this2.sourceInfo) { - _this2.sourceInfo = true; - var info = result.sourceInfo.programInfo[0]; - - _this2.subtitles(info); - - _this2.tracks(info); - - _this2.unsubscribe(); - - _this2.call(); - } - - if (result.bufferRange) { - count_message++; - - if (count_message == 30) { - _this2.unsubscribe(); - - _this2.call(); - } - } - }, function () { - _this2.call(); - }); - }; - /** - * Отписка от видео - */ - - - this.unsubscribe = function () { - luna({ - method: 'unload', - parameters: { - 'mediaId': media_id - } - }); - }; - /** - * Сканируем наличия видео - */ - - - this.search = function () { - var _this3 = this; - - count++; - - if (count > 3) { - clearInterval(timer); - clearInterval(timer_repet); - } - - var rootSubscribe = function rootSubscribe() { - console.log('WebOS', 'Run root', 'version:', webOS.sdk_version); - - _this3.toggleSubtitles(false); - - if (_this3.subscribed) clearInterval(timer_repet); - if (!_this3.subscribed) _this3.subscribe();else { - if (data.tracks.length) { - PlayerVideo.listener.send('webos_tracks', { - tracks: data.tracks - }); - PlayerPanel.setTracks(data.tracks, true); - } - - if (data.subs.length) { - PlayerVideo.listener.send('webos_subs', { - subs: data.subs - }); - PlayerPanel.setSubs(data.subs); - } - } - clearInterval(timer); - }; - - console.log('WebOS', 'try get id:', video.mediaId); - - if (video.mediaId) { - media_id = video.mediaId; - console.log('WebOS', 'video id:', media_id); - rootSubscribe(); - } - }; - /** - * Вызываем и завершаем работу - */ - - - this.call = function () { - if (this.callback) this.callback(); - this.callback = false; - }; - - this.speed = function (v) { - luna({ - method: 'setPlayRate', - parameters: { - 'mediaId': media_id, - 'playRate': v, - 'audioOutput': true - } - }); - }; - /** - * Создаем новое видео - * @param {object} new_video - */ - - - this.repet = function (new_video) { - video = new_video; - console.log('WebOS', 'repeat to new video', new_video ? true : false); - media_id = ''; - clearInterval(timer); - count = 0; - this.repeted = true; - timer_repet = setInterval(this.search.bind(this), 300); - }; - /** - * После перемотки включаем состояние сабов - */ - - - this.rewinded = function () { - this.toggleSubtitles(subtitle_visible); - }; - /** - * Уничтожить - */ - - - this.destroy = function () { - clearInterval(timer); - clearInterval(timer_repet); - if (media_id) this.unsubscribe(); - data = null; - this.subscribed = false; - this.callback = false; - }; - } - - var FORMAT_NAME$7 = "vtt"; - var helper$5 = { - toMilliseconds: function toMilliseconds(s) { - var match = /^\s*(\d{1,2}:)?(\d{1,2}):(\d{1,2})([.,](\d{1,3}))?\s*$/.exec(s); - var hh = match[1] ? parseInt(match[1].replace(":", "")) : 0; - var mm = parseInt(match[2]); - var ss = parseInt(match[3]); - var ff = match[5] ? parseInt(match[5]) : 0; - var ms = hh * 3600 * 1000 + mm * 60 * 1000 + ss * 1000 + ff; - return ms; - }, - toTimeString: function toTimeString(ms) { - var hh = Math.floor(ms / 1000 / 3600); - var mm = Math.floor(ms / 1000 / 60 % 60); - var ss = Math.floor(ms / 1000 % 60); - var ff = Math.floor(ms % 1000); - var time = (hh < 10 ? "0" : "") + hh + ":" + (mm < 10 ? "0" : "") + mm + ":" + (ss < 10 ? "0" : "") + ss + "." + (ff < 100 ? "0" : "") + (ff < 10 ? "0" : "") + ff; - return time; - } - }; - /****************************************************************************************** - * Parses captions in WebVTT format (Web Video Text Tracks Format) - ******************************************************************************************/ - - function parse$b(content, options) { - var index = 1; - var captions = []; - var eol = options.eol || "\r\n"; - var parts = content.split(/\r?\n\s+\r?\n/); - - for (var i = 0; i < parts.length; i++) { - //WebVTT data - var regex = /^([^\r\n]+\r?\n)?((\d{1,2}:)?\d{1,2}:\d{1,2}([.,]\d{1,3})?)\s*\-\-\>\s*((\d{1,2}:)?\d{1,2}:\d{1,2}([.,]\d{1,3})?)\r?\n([\s\S]*)(\r?\n)*$/gi; - var match = regex.exec(parts[i]); - - if (match) { - var caption = {}; - caption.type = "caption"; - caption.index = index++; - - if (match[1]) { - caption.cue = match[1].replace(/[\r\n]*/gi, ""); - } - - caption.start = helper$5.toMilliseconds(match[2]); - caption.end = helper$5.toMilliseconds(match[5]); - caption.duration = caption.end - caption.start; - var lines = match[8].split(/\r?\n/); - caption.content = lines.join(eol); - caption.text = caption.content.replace(/\<[^\>]+\>/g, "") //bold or italic - .replace(/\{[^\}]+\}/g, ""); //{b}bold{/b} or {i}italic{/i} - - captions.push(caption); - continue; - } //WebVTT meta - - - var meta = /^([A-Z]+)(\r?\n([\s\S]*))?$/.exec(parts[i]); - - if (!meta) { - //Try inline meta - meta = /^([A-Z]+)\s+([^\r\n]*)?$/.exec(parts[i]); - } - - if (meta) { - var caption = {}; - caption.type = "meta"; - caption.name = meta[1]; - - if (meta[3]) { - caption.data = meta[3]; - } - - captions.push(caption); - continue; - } - - if (options.verbose) { - console.log("WARN: Unknown part", parts[i]); - } - } - - return captions; - } - /****************************************************************************************** - * Builds captions in WebVTT format (Web Video Text Tracks Format) - ******************************************************************************************/ - - function build$9(captions, options) { - var eol = options.eol || "\r\n"; - var content = "WEBVTT" + eol + eol; - - for (var i = 0; i < captions.length; i++) { - var caption = captions[i]; - - if (caption.type == "meta") { - if (caption.name == "WEBVTT") continue; - content += caption.name + eol; - content += caption.data ? caption.data + eol : ""; - content += eol; - continue; - } - - if (typeof caption.type === "undefined" || caption.type == "caption") { - content += (i + 1).toString() + eol; - content += helper$5.toTimeString(caption.start) + " --> " + helper$5.toTimeString(caption.end) + eol; - content += caption.text + eol; - content += eol; - continue; - } - - if (options.verbose) { - console.log("SKIP:", caption); - } - } - - return content; - } - /****************************************************************************************** - * Detects a subtitle format from the content. - ******************************************************************************************/ - - function detect$8(content) { - if (typeof content !== "string") { - throw new Error("Expected string content!"); - } - - if (/^[\s\r\n]*WEBVTT\r?\n/g.test(content)) { - /* - WEBVTT - ... - */ - return "vtt"; - } - } - /****************************************************************************************** - * Export - ******************************************************************************************/ - - var vttFormatter = { - name: FORMAT_NAME$7, - helper: helper$5, - detect: detect$8, - parse: parse$b, - build: build$9 - }; - - var FORMAT_NAME$6 = "lrc"; - var helper$4 = { - toMilliseconds: function toMilliseconds(s) { - var match = /^\s*(\d+):(\d{1,2})([.,](\d{1,3}))?\s*$/.exec(s); - var mm = parseInt(match[1]); - var ss = parseInt(match[2]); - var ff = match[4] ? parseInt(match[4]) : 0; - var ms = mm * 60 * 1000 + ss * 1000 + ff * 10; - return ms; - }, - toTimeString: function toTimeString(ms) { - var mm = Math.floor(ms / 1000 / 60); - var ss = Math.floor(ms / 1000 % 60); - var ff = Math.floor(ms % 1000); - var time = (mm < 10 ? "0" : "") + mm + ":" + (ss < 10 ? "0" : "") + ss + "." + (ff < 100 ? "0" : "") + (ff < 10 ? "0" : Math.floor(ff / 10)); - return time; - } - }; - /****************************************************************************************** - * Parses captions in LRC format: https://en.wikipedia.org/wiki/LRC_%28file_format%29 - ******************************************************************************************/ - - function parse$a(content, options) { - var prev = null; - var captions = []; - options.eol || "\r\n"; - var parts = content.split(/\r?\n/); - - for (var i = 0; i < parts.length; i++) { - if (!parts[i] || parts[i].trim().length == 0) { - continue; - } //LRC content - - - var regex = /^\[(\d{1,2}:\d{1,2}([.,]\d{1,3})?)\](.*)(\r?\n)*$/gi; - var match = regex.exec(parts[i]); - - if (match) { - var caption = {}; - caption.type = "caption"; - caption.start = helper$4.toMilliseconds(match[1]); - caption.end = caption.start + 2000; - caption.duration = caption.end - caption.start; - caption.content = match[3]; - caption.text = caption.content; - captions.push(caption); //Update previous - - if (prev) { - prev.end = caption.start; - prev.duration = prev.end - prev.start; - } - - prev = caption; - continue; - } //LRC meta - - - var meta = /^\[([\w\d]+):([^\]]*)\](\r?\n)*$/gi.exec(parts[i]); - - if (meta) { - var caption = {}; - caption.type = "meta"; - caption.tag = meta[1]; - - if (meta[2]) { - caption.data = meta[2]; - } - - captions.push(caption); - continue; - } - - if (options.verbose) { - console.log("WARN: Unknown part", parts[i]); - } - } - - return captions; - } - /****************************************************************************************** - * Builds captions in LRC format: https://en.wikipedia.org/wiki/LRC_%28file_format%29 - ******************************************************************************************/ - - function build$8(captions, options) { - var content = ""; - var lyrics = false; - var eol = options.eol || "\r\n"; - - for (var i = 0; i < captions.length; i++) { - var caption = captions[i]; - - if (caption.type == "meta") { - if (caption.tag && caption.data) { - content += "[" + caption.tag + ":" + caption.data.replace(/[\r\n]+/g, " ") + "]" + eol; - } - - continue; - } - - if (typeof caption.type === "undefined" || caption.type == "caption") { - if (!lyrics) { - content += eol; //New line when lyrics start - - lyrics = true; - } - - content += "[" + helper$4.toTimeString(caption.start) + "]" + caption.text + eol; - continue; - } - - if (options.verbose) { - console.log("SKIP:", caption); - } - } - - return content; - } - /****************************************************************************************** - * Detects a subtitle format from the content. - ******************************************************************************************/ - - function detect$7(content) { - if (typeof content === "string") { - if (/\r?\n\[(\d+:\d{1,2}([.,]\d{1,3})?)\](.*)\r?\n/.test(content)) { - /* - [04:48.28]Sister, perfume? - */ - //return "lrc"; - return true; - } - } - } - /****************************************************************************************** - * Export - ******************************************************************************************/ - - var lrcFormatter = { - name: FORMAT_NAME$6, - helper: helper$4, - detect: detect$7, - parse: parse$a, - build: build$8 - }; - - var FORMAT_NAME$5 = "smi"; - var helper$3 = { - htmlEncode: function htmlEncode(text) { - return text.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/\/g, '>') //.replace(/\s/g, ' ') - .replace(/\r?\n/g, '
    '); - }, - htmlDecode: function htmlDecode(html, eol) { - return html.replace(/\/gi, eol || '\r\n').replace(/ /g, ' ').replace(/"/g, '"').replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&'); - } - }; - /****************************************************************************************** - * Parses captions in SAMI format (.smi) - ******************************************************************************************/ - - function parse$9(content, options) { - var captions = []; - var eol = options.eol || "\r\n"; - var title = /\]*\>([\s\S]*)\<\/TITLE\>/gi.exec(content); - - if (title) { - var caption = {}; - caption.type = "meta"; - caption.name = "title"; - caption.data = title[1].replace(/^[\s\r\n]*/g, "").replace(/[\s\r\n]*$/g, ""); - captions.push(caption); - } - - var style = /\]*\>([\s\S]*)\<\/STYLE\>/gi.exec(content); - - if (style) { - var caption = {}; - caption.type = "meta"; - caption.name = "style"; - caption.data = style[1]; - captions.push(caption); - } - - var sami = content.replace(/^[\s\S]*\]*\>/gi, "") //Remove content before body - .replace(/\<\/BODY[^\>]*\>[\s\S]*$/gi, ""); //Remove content after body - - var prev = null; - var parts = sami.split(/\ - - var match = /^\]+Start\s*=\s*["']?(\d+)["']?[^\>]*\>([\s\S]*)/gi.exec(part); - - if (match) { - var caption = {}; - caption.type = "caption"; - caption.start = parseInt(match[1]); - caption.end = caption.start + 2000; - caption.duration = caption.end - caption.start; - caption.content = match[2].replace(/^\<\/SYNC[^\>]*>/gi, ""); - var blank = true; - var p = /^\]+Class\s*=\s*["']?([\w\d\-_]+)["']?[^\>]*\>([\s\S]*)/gi.exec(caption.content); - - if (!p) { - p = /^\]*)\>([\s\S]*)/gi.exec(caption.content); - } - - if (p) { - var html = p[2].replace(/\ tag - - html = html.replace(/\[\s\r\n]+/gi, eol).replace(/\/gi, eol).replace(/\<[^\>]+\>/g, ""); //Remove all tags - - html = html.replace(/^[\s\r\n]+/g, "").replace(/[\s\r\n]+$/g, ""); //Trim new lines and spaces - - blank = html.replace(/ /gi, " ").replace(/[\s\r\n]+/g, "").length == 0; - caption.text = helper$3.htmlDecode(html, eol); - } - - if (!options.preserveSpaces && blank) { - if (options.verbose) { - console.log("INFO: Skipping white space caption at " + caption.start); - } - } else { - captions.push(caption); - } //Update previous - - - if (prev) { - prev.end = caption.start; - prev.duration = prev.end - prev.start; - } - - prev = caption; - continue; - } - - if (options.verbose) { - console.log("WARN: Unknown part", parts[i]); - } - } - - return captions; - } - /****************************************************************************************** - * Builds captions in SAMI format (.smi) - ******************************************************************************************/ - - function build$7(captions, options) { - var eol = options.eol || "\r\n"; - var content = ""; - content += '' + eol; - content += '' + eol; - content += '' + (options.title || "") + '' + eol; - content += '' + eol; - content += '' + eol; - content += '' + eol; - - for (var i = 0; i < captions.length; i++) { - var caption = captions[i]; - - if (caption.type == "meta") { - continue; - } - - if (typeof caption.type === "undefined" || caption.type == "caption") { - //Start of caption - content += '' + eol; - content += '

    ' + helper$3.htmlEncode(caption.text || "") + (options.closeTags ? '

    ' : "") + eol; - - if (options.closeTags) { - content += '
    ' + eol; - } //Blank line indicates the end of caption - - - content += '' + eol; - content += '

    ' + ' ' + (options.closeTags ? '

    ' : "") + eol; - - if (options.closeTags) { - content += '
    ' + eol; - } - - continue; - } - - if (options.verbose) { - console.log("SKIP:", caption); - } - } - - content += '' + eol; - content += '
    ' + eol; - return content; - } - /****************************************************************************************** - * Detects a subtitle format from the content. - ******************************************************************************************/ - - function detect$6(content) { - if (typeof content === "string") { - if (/\]*\>[\s\S]*\]*\>/g.test(content)) { - /* - - - - - */ - return "smi"; - } - } - } - /****************************************************************************************** - * Export - ******************************************************************************************/ - - var smiFormatter = { - name: FORMAT_NAME$5, - helper: helper$3, - detect: detect$6, - parse: parse$9, - build: build$7 - }; - - var FORMAT_NAME$4 = "ssa"; - var helper$2 = { - toMilliseconds: function toMilliseconds(s) { - var match = /^\s*(\d+:)?(\d{1,2}):(\d{1,2})([.,](\d{1,3}))?\s*$/.exec(s); - var hh = match[1] ? parseInt(match[1].replace(":", "")) : 0; - var mm = parseInt(match[2]); - var ss = parseInt(match[3]); - var ff = match[5] ? parseInt(match[5]) : 0; - var ms = hh * 3600 * 1000 + mm * 60 * 1000 + ss * 1000 + ff * 10; - return ms; - }, - toTimeString: function toTimeString(ms) { - var hh = Math.floor(ms / 1000 / 3600); - var mm = Math.floor(ms / 1000 / 60 % 60); - var ss = Math.floor(ms / 1000 % 60); - var ff = Math.floor(ms % 1000 / 10); //2 digits - - var time = hh + ":" + (mm < 10 ? "0" : "") + mm + ":" + (ss < 10 ? "0" : "") + ss + "." + (ff < 10 ? "0" : "") + ff; - return time; - } - }; - /****************************************************************************************** - * Parses captions in SubStation Alpha format (.ssa) - ******************************************************************************************/ - - function parse$8(content, options) { - var meta; - var columns = null; - var captions = []; - var eol = options.eol || "\r\n"; - var parts = content.split(/\r?\n\s*\r?\n/); - - for (var i = 0; i < parts.length; i++) { - var regex = /^\s*\[([^\]]+)\]\r?\n([\s\S]*)(\r?\n)*$/gi; - var match = regex.exec(parts[i]); - - if (match) { - var tag = match[1]; - var lines = match[2].split(/\r?\n/); - - for (var l = 0; l < lines.length; l++) { - var line = lines[l]; - - if (/^\s*;/.test(line)) { - continue; //Skip comment - } - - var m = /^\s*([^:]+):\s*(.*)(\r?\n)?$/.exec(line); - - if (m) { - if (tag == "Script Info") { - if (!meta) { - meta = {}; - meta.type = "meta"; - meta.data = {}; - captions.push(meta); - } - - var name = m[1].trim(); - var value = m[2].trim(); - meta.data[name] = value; - continue; - } - - if (tag == "V4 Styles" || tag == "V4+ Styles") { - var name = m[1].trim(); - var value = m[2].trim(); - - if (name == "Format") { - columns = value.split(/\s*,\s*/g); - continue; - } - - if (name == "Style") { - var values = value.split(/\s*,\s*/g); - var caption = {}; - caption.type = "style"; - caption.data = {}; - - for (var c = 0; c < columns.length && c < values.length; c++) { - caption.data[columns[c]] = values[c]; - } - - captions.push(caption); - continue; - } - } - - if (tag == "Events") { - var name = m[1].trim(); - var value = m[2].trim(); - - if (name == "Format") { - columns = value.split(/\s*,\s*/g); - continue; - } - - if (name == "Dialogue") { - //Work-around for missing text (when the text contains ',' char) - var getPosition = function getPosition(s, search, index) { - return s.split(search, index).join(search).length; - }; - - var values = value.split(/\s*,\s*/g); - var caption = {}; - caption.type = "caption"; - caption.data = {}; - - for (var c = 0; c < columns.length && c < values.length; c++) { - caption.data[columns[c]] = values[c]; - } - - caption.start = helper$2.toMilliseconds(caption.data["Start"]); - caption.end = helper$2.toMilliseconds(caption.data["End"]); - caption.duration = caption.end - caption.start; - caption.content = caption.data["Text"]; - var indexOfText = getPosition(value, ',', columns.length - 1) + 1; - caption.content = value.substr(indexOfText); - caption.data["Text"] = caption.content; - caption.text = caption.content.replace(/\\N/g, eol) //"\N" for new line - .replace(/\{[^\}]+\}/g, ""); //{\pos(400,570)} - - captions.push(caption); - continue; - } - } - } - } - } - - if (options.verbose) { - console.log("WARN: Unknown part", parts[i]); - } - } - - return captions; - } - /****************************************************************************************** - * Builds captions in SubStation Alpha format (.ssa) - ******************************************************************************************/ - - function build$6(captions, options) { - var eol = options.eol || "\r\n"; - var ass = options.format == "ass"; - var content = ""; - content += "[Script Info]" + eol; - content += "; Script generated by subsrt " + eol; - content += "ScriptType: v4.00" + (ass ? "+" : "") + eol; - content += "Collisions: Normal" + eol; - content += eol; - - if (ass) { - content += "[V4+ Styles]" + eol; - content += "Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding" + eol; - content += "Style: DefaultVCD, Arial,28,&H00B4FCFC,&H00B4FCFC,&H00000008,&H80000008,-1,0,0,0,100,100,0.00,0.00,1,1.00,2.00,2,30,30,30,0" + eol; - } else { - content += "[V4 Styles]" + eol; - content += "Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding" + eol; - content += "Style: DefaultVCD, Arial,28,11861244,11861244,11861244,-2147483640,-1,0,1,1,2,2,30,30,30,0,0" + eol; - } - - content += eol; - content += "[Events]" + eol; - content += "Format: " + (ass ? "Layer" : "Marked") + ", Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text" + eol; - - for (var i = 0; i < captions.length; i++) { - var caption = captions[i]; - - if (caption.type == "meta") { - continue; - } - - if (typeof caption.type === "undefined" || caption.type == "caption") { - content += "Dialogue: " + (ass ? "0" : "Marked=0") + "," + helper$2.toTimeString(caption.start) + "," + helper$2.toTimeString(caption.end) + ",DefaultVCD, NTP,0000,0000,0000,," + caption.text.replace(/\r?\n/g, "\\N") + eol; - continue; - } - - if (options.verbose) { - console.log("SKIP:", caption); - } - } - - return content; - } - /****************************************************************************************** - * Detects a subtitle format from the content. - ******************************************************************************************/ - - function detect$5(content) { - if (typeof content !== "string") { - throw new Error("Expected string content!"); - } - - if (/^[\s\r\n]*\[Script Info\]\r?\n/g.test(content) && /[\s\r\n]*\[Events\]\r?\n/g.test(content)) { - /* - [Script Info] - ... - [Events] - */ - //Advanced (V4+) styles for ASS format - return content.indexOf("[V4+ Styles]") > 0 ? "ass" : "ssa"; - } - } - /****************************************************************************************** - * Export - ******************************************************************************************/ - - var ssaFormatter = { - name: FORMAT_NAME$4, - helper: helper$2, - detect: detect$5, - parse: parse$8, - build: build$6 - }; - - var assFormatter = { - name: "ass", - helper: ssaFormatter.helper, - detect: ssaFormatter.detect, - parse: ssaFormatter.parse, - build: ssaFormatter.build - }; - - var FORMAT_NAME$3 = "sub"; - var DEFAULT_FPS = 25; - /****************************************************************************************** - * Parses captions in MicroDVD format: https://en.wikipedia.org/wiki/MicroDVD - ******************************************************************************************/ - - function parse$7(content, options) { - var fps = options.fps > 0 ? options.fps : DEFAULT_FPS; - var captions = []; - var eol = options.eol || "\r\n"; - var parts = content.split(/\r?\n/g); - - for (var i = 0; i < parts.length; i++) { - var regex = /^\{(\d+)\}\{(\d+)\}(.*)$/gi; - var match = regex.exec(parts[i]); - - if (match) { - var caption = {}; - caption.type = "caption"; - caption.index = i + 1; - caption.frame = { - start: parseInt(match[1]), - end: parseInt(match[2]) - }; - caption.frame.count = caption.frame.end - caption.frame.start; - caption.start = Math.round(caption.frame.start / fps); - caption.end = Math.round(caption.frame.end / fps); - caption.duration = caption.end - caption.start; - var lines = match[3].split(/\|/g); - caption.content = lines.join(eol); - caption.text = caption.content.replace(/\{[^\}]+\}/g, ""); //{0}{25}{c:$0000ff}{y:b,u}{f:DeJaVuSans}{s:12}Hello! - - captions.push(caption); - continue; - } - - if (options.verbose) { - console.log("WARN: Unknown part", parts[i]); - } - } - - return captions; - } - /****************************************************************************************** - * Builds captions in MicroDVD format: https://en.wikipedia.org/wiki/MicroDVD - ******************************************************************************************/ - - function build$5(captions, options) { - var fps = options.fps > 0 ? options.fps : DEFAULT_FPS; - var sub = ""; - var eol = options.eol || "\r\n"; - - for (var i = 0; i < captions.length; i++) { - var caption = captions[i]; - - if (typeof caption.type === "undefined" || caption.type == "caption") { - var startFrame = _typeof(caption.frame) == "object" && caption.frame.start >= 0 ? caption.frame.start : caption.start * fps; - var endFrame = _typeof(caption.frame) == "object" && caption.frame.end >= 0 ? caption.frame.end : caption.end * fps; - var text = caption.text.replace(/\r?\n/, "|"); - sub += "{" + startFrame + "}" + "{" + endFrame + "}" + text + eol; - continue; - } - - if (options.verbose) { - console.log("SKIP:", caption); - } - } - - return sub; - } - /****************************************************************************************** - * Detects a subtitle format from the content. - ******************************************************************************************/ - - function detect$4(content) { - if (typeof content === "string") { - if (/^\{\d+\}\{\d+\}(.*)/.test(content)) { - /* - {7207}{7262}Sister, perfume? - */ - return FORMAT_NAME$3; - } - } - } - /****************************************************************************************** - * Export - ******************************************************************************************/ - - var subFormatter = { - name: FORMAT_NAME$3, - detect: detect$4, - parse: parse$7, - build: build$5 - }; - - var FORMAT_NAME$2 = "srt"; - var helper$1 = { - toMilliseconds: function toMilliseconds(s) { - var match = /^\s*(\d{1,2}):(\d{1,2}):(\d{1,2})([.,](\d{1,3}))?\s*$/.exec(s); - var hh = parseInt(match[1]); - var mm = parseInt(match[2]); - var ss = parseInt(match[3]); - var ff = match[5] ? parseInt(match[5]) : 0; - var ms = hh * 3600 * 1000 + mm * 60 * 1000 + ss * 1000 + ff; - return ms; - }, - toTimeString: function toTimeString(ms) { - var hh = Math.floor(ms / 1000 / 3600); - var mm = Math.floor(ms / 1000 / 60 % 60); - var ss = Math.floor(ms / 1000 % 60); - var ff = Math.floor(ms % 1000); - var time = (hh < 10 ? "0" : "") + hh + ":" + (mm < 10 ? "0" : "") + mm + ":" + (ss < 10 ? "0" : "") + ss + "," + (ff < 100 ? "0" : "") + (ff < 10 ? "0" : "") + ff; - return time; - } - }; - /****************************************************************************************** - * Parses captions in SubRip format (.srt) - ******************************************************************************************/ - - function parse$6(content, options) { - var captions = []; - var eol = options.eol || "\r\n"; - var parts = content.split(/\r?\n\s+\r?\n/g); - - for (var i = 0; i < parts.length; i++) { - var regex = /^(\d+)\r?\n(\d{1,2}:\d{1,2}:\d{1,2}([.,]\d{1,3})?)\s*\-\-\>\s*(\d{1,2}:\d{1,2}:\d{1,2}([.,]\d{1,3})?)\r?\n([\s\S]*)(\r?\n)*$/gi; - var match = regex.exec(parts[i]); - - if (match) { - var caption = {}; - caption.type = "caption"; - caption.index = parseInt(match[1]); - caption.start = helper$1.toMilliseconds(match[2]); - caption.end = helper$1.toMilliseconds(match[4]); - caption.duration = caption.end - caption.start; - var lines = match[6].split(/\r?\n/); - caption.content = lines.join(eol); - caption.text = caption.content.replace(/\<[^\>]+\>/g, "") //bold or italic - .replace(/\{[^\}]+\}/g, "") //{b}bold{/b} or {i}italic{/i} - .replace(/\>\>\s*[^:]*:\s*/g, ""); //>> SPEAKER NAME: - - captions.push(caption); - continue; - } - - if (options.verbose) { - console.log("WARN: Unknown part", parts[i]); - } - } - - return captions; - } - /****************************************************************************************** - * Builds captions in SubRip format (.srt) - ******************************************************************************************/ - - function build$4(captions, options) { - var srt = ""; - var eol = options.eol || "\r\n"; - - for (var i = 0; i < captions.length; i++) { - var caption = captions[i]; - - if (typeof caption.type === "undefined" || caption.type == "caption") { - srt += (i + 1).toString() + eol; - srt += helper$1.toTimeString(caption.start) + " --> " + helper$1.toTimeString(caption.end) + eol; - srt += caption.text + eol; - srt += eol; - continue; - } - - if (options.verbose) { - console.log("SKIP:", caption); - } - } - - return srt; - } - /****************************************************************************************** - * Detects a subtitle format from the content. - ******************************************************************************************/ - - function detect$3(content) { - if (typeof content === "string") { - if (/\d+\r?\n\d{1,2}:\d{1,2}:\d{1,2}([.,]\d{1,3})?\s*\-\-\>\s*\d{1,2}:\d{1,2}:\d{1,2}([.,]\d{1,3})?/g.test(content)) { - /* - 3 - 00:04:48,280 --> 00:04:50,510 - Sister, perfume? - */ - return FORMAT_NAME$2; - } - } - } - /****************************************************************************************** - * Export - ******************************************************************************************/ - - var srtFormatter = { - name: FORMAT_NAME$2, - helper: helper$1, - detect: detect$3, - parse: parse$6, - build: build$4 - }; - - var FORMAT_NAME$1 = "sbv"; - var helper = { - toMilliseconds: function toMilliseconds(s) { - var match = /^\s*(\d{1,2}):(\d{1,2}):(\d{1,2})([.,](\d{1,3}))?\s*$/.exec(s); - var hh = parseInt(match[1]); - var mm = parseInt(match[2]); - var ss = parseInt(match[3]); - var ff = match[5] ? parseInt(match[5]) : 0; - var ms = hh * 3600 * 1000 + mm * 60 * 1000 + ss * 1000 + ff; - return ms; - }, - toTimeString: function toTimeString(ms) { - var hh = Math.floor(ms / 1000 / 3600); - var mm = Math.floor(ms / 1000 / 60 % 60); - var ss = Math.floor(ms / 1000 % 60); - var ff = Math.floor(ms % 1000); - var time = (hh < 10 ? "0" : "") + hh + ":" + (mm < 10 ? "0" : "") + mm + ":" + (ss < 10 ? "0" : "") + ss + "." + (ff < 100 ? "0" : "") + (ff < 10 ? "0" : "") + ff; - return time; - } - }; - /****************************************************************************************** - * Parses captions in SubViewer format (.sbv) - ******************************************************************************************/ - - function parse$5(content, options) { - var captions = []; - var eol = options.eol || "\r\n"; - var parts = content.split(/\r?\n\s+\r?\n/); - - for (var i = 0; i < parts.length; i++) { - var regex = /^(\d{1,2}:\d{1,2}:\d{1,2}([.,]\d{1,3})?)\s*[,;]\s*(\d{1,2}:\d{1,2}:\d{1,2}([.,]\d{1,3})?)\r?\n([\s\S]*)(\r?\n)*$/gi; - var match = regex.exec(parts[i]); - - if (match) { - var caption = {}; - caption.type = "caption"; - caption.start = helper.toMilliseconds(match[1]); - caption.end = helper.toMilliseconds(match[3]); - caption.duration = caption.end - caption.start; - var lines = match[5].split(/\[br\]|\r?\n/gi); - caption.content = lines.join(eol); - caption.text = caption.content.replace(/\>\>\s*[^:]+:\s*/g, ""); //>> SPEAKER NAME: - - captions.push(caption); - continue; - } - - if (options.verbose) { - console.log("WARN: Unknown part", parts[i]); - } - } - - return captions; - } - /****************************************************************************************** - * Builds captions in SubViewer format (.sbv) - ******************************************************************************************/ - - function build$3(captions, options) { - var content = ""; - var eol = options.eol || "\r\n"; - - for (var i = 0; i < captions.length; i++) { - var caption = captions[i]; - - if (typeof caption.type === "undefined" || caption.type == "caption") { - content += helper.toTimeString(caption.start) + "," + helper.toTimeString(caption.end) + eol; - content += caption.text + eol; - content += eol; - continue; - } - - if (options.verbose) { - console.log("SKIP:", caption); - } - } - - return content; - } - /****************************************************************************************** - * Detects a subtitle format from the content. - ******************************************************************************************/ - - function detect$2(content) { - if (typeof content !== "string") { - throw new Error("Expected string content!"); - } - - if (/\d{1,2}:\d{1,2}:\d{1,2}([.,]\d{1,3})?\s*[,;]\s*\d{1,2}:\d{1,2}:\d{1,2}([.,]\d{1,3})?/g.test(content)) { - /* - 00:04:48.280,00:04:50.510 - Sister, perfume? - */ - return "sbv"; - } - } - /****************************************************************************************** - * Export - ******************************************************************************************/ - - var sbvFormatter = { - name: FORMAT_NAME$1, - helper: helper, - detect: detect$2, - parse: parse$5, - build: build$3 - }; - - var FORMAT_NAME = "json"; - /****************************************************************************************** - * Parses captions in JSON format - ******************************************************************************************/ - - function parse$4(content, options) { - return JSON.parse(content); - } - /****************************************************************************************** - * Builds captions in JSON format - ******************************************************************************************/ - - function build$2(captions, options) { - return JSON.stringify(captions, " ", 2); - } - /****************************************************************************************** - * Detects a subtitle format from the content. - ******************************************************************************************/ - - - function detect$1(content) { - if (typeof content === "string") { - if (/^\[[\s\r\n]*\{[\s\S]*\}[\s\r\n]*\]$/g.test(content)) { - /* - [ - { ... } - ] - */ - return "json"; - } - } - } - /****************************************************************************************** - * Export - ******************************************************************************************/ - - var jsonFormatter = { - name: FORMAT_NAME, - detect: detect$1, - parse: parse$4, - build: build$2 - }; - - var supportedFormats = { - vtt: vttFormatter, - lrc: lrcFormatter, - smi: smiFormatter, - ssa: ssaFormatter, - ass: assFormatter, - sub: subFormatter, - srt: srtFormatter, - sbv: sbvFormatter, - json: jsonFormatter - }; - - function clone(obj) { - return JSON.parse(JSON.stringify(obj)); - } - /****************************************************************************************** - * Gets a list of supported subtitle supportedFormats. - ******************************************************************************************/ - - - function list$3() { - return Object.keys(supportedFormats); - } - /****************************************************************************************** - * Detects a subtitle supportedFormats from the content. - ******************************************************************************************/ - - - function detect(content) { - var formats = Object.keys(supportedFormats); - - for (var i = 0; i < formats.length; i++) { - var formatName = formats[i]; - var handler = supportedFormats[formatName]; - - if (handler === undefined) { - continue; - } - - if (typeof handler.detect != "function") { - continue; - } //Function 'detect' can return true or supportedFormats name - - - var d = handler.detect(content); - - if (d === true) { - //Logical true - return formatName; - } - - if (formatName === d) { - //Format name - return d; - } - } - } - /****************************************************************************************** - * Parses a subtitle content. - ******************************************************************************************/ - - - function parse$3(content, options) { - options = options || {}; - var format = options.format || detect(content); - - if (!format || format.trim().length == 0) { - throw new Error("Cannot determine subtitle supportedFormats!"); - } - - var handler = supportedFormats[format]; - - if (handler === undefined) { - throw new Error("Unsupported subtitle supportedFormats: " + format); - } - - var func = handler.parse; - - if (typeof func != "function") { - throw new Error("Subtitle supportedFormats does not support 'parse' op: " + format); - } - - return func(content, options); - } - /****************************************************************************************** - * Builds a subtitle content - ******************************************************************************************/ - - - function build$1(captions, options) { - options = options || {}; - var format = options.format || "srt"; - - if (!format || format.trim().length == 0) { - throw new Error("Cannot determine subtitle supportedFormats!"); - } - - var handler = supportedFormats[format]; - - if (typeof handler == "undefined") { - throw new Error("Unsupported subtitle supportedFormats: " + format); - } - - var func = handler.build; - - if (typeof func != "function") { - throw new Error("Subtitle supportedFormats does not support 'build' op: " + format); - } - - return func(captions, options); - } - /****************************************************************************************** - * Converts subtitle supportedFormats - ******************************************************************************************/ - - - function convert(content, options) { - if (typeof options == "string") { - options = { - to: options - }; - } - - options = options || {}; - var opt = clone(options); - delete opt.format; - - if (opt.from) { - opt.format = opt.from; - } - - var captions = parse$3(content, opt); - - if (opt.resync) { - captions = resync(captions, opt.resync); - } - - opt.format = opt.to || options.format; - return build$1(captions, opt); - } - /****************************************************************************************** - * Shifts the time of the captions. - ******************************************************************************************/ - - - function resync(captions, options) { - options = options || {}; - var func, ratio, frame, offset; - - if (typeof options == "function") { - func = options; //User's function to handle time shift - } else if (typeof options == "number") { - offset = options; //Time shift (+/- offset) - - func = function func(a) { - return [a[0] + offset, a[1] + offset]; - }; - } else if (_typeof(options) == "object") { - offset = (options.offset || 0) * (options.frame ? options.fps || 25 : 1); - ratio = options.ratio || 1.0; - frame = options.frame; - - func = function func(a) { - return [Math.round(a[0] * ratio + offset), Math.round(a[1] * ratio + offset)]; - }; - } else { - throw new Error("Argument 'options' not defined!"); - } - - var resynced = []; - - for (var i = 0; i < captions.length; i++) { - var caption = clone(captions[i]); - - if (typeof caption.type === "undefined" || caption.type == "caption") { - if (frame) { - var shift = func([caption.frame.start, caption.frame.end]); - - if (shift && shift.length == 2) { - caption.frame.start = shift[0]; - caption.frame.end = shift[1]; - caption.frame.count = caption.frame.end - caption.frame.start; - } - } else { - var shift = func([caption.start, caption.end]); - - if (shift && shift.length == 2) { - caption.start = shift[0]; - caption.end = shift[1]; - caption.duration = caption.end - caption.start; - } - } - } - - resynced.push(caption); - } - - return resynced; - } - - var subsrt = { - list: list$3, - detect: detect, - parse: parse$3, - build: build$1, - convert: convert, - resync: resync - }; - - /** - * Поучить время - * @param {string} val - * @returns {number} - */ - - function time$1(val) { - var regex = /(\d+):(\d{2}):(\d{2})[.,](\d{3})/; - var parts = regex.exec(val); - if (parts === null) return 0; - - for (var i = 1; i < 5; i++) { - parts[i] = parseInt(parts[i], 10); - if (isNaN(parts[i])) parts[i] = 0; - } //hours + minutes + seconds + ms - - - return parts[1] * 3600000 + parts[2] * 60000 + parts[3] * 1000 + parts[4]; - } - /** - * Парсить - * @param {string} data - * @param {boolean} ms - * @returns - */ - - - function parse$2(data, ms) { - var type = subsrt.detect(data); - if (type === 'vtt') return parseVTT(data, ms); - if (type !== undefined && type !== 'srt') return parseVTT(convertToVTT(data), ms);else return parseSRT(data, ms); - } - /** - * Парсить SRT - * @param {string} data - * @param {boolean} ms - * @returns {[{id:string, startTime:number, endTime:number, text:string}]} - */ - - - function parseSRT(data, ms) { - var useMs = ms ? true : false; - data = data.replace(/\r\n/g, '\n'); - data = data.replace(/\r/g, '\n'); - var regex = /(\d+)\n(\d{2}:\d{2}:\d{2},\d{3}) --> (\d{2}:\d{2}:\d{2},\d{3})/g; - data = data.split(regex); - data.shift(); - var items = []; - - for (var i = 0; i < data.length; i += 4) { - items.push({ - id: data[i].trim(), - startTime: useMs ? time$1(data[i + 1].trim()) : data[i + 1].trim(), - endTime: useMs ? time$1(data[i + 2].trim()) : data[i + 2].trim(), - text: data[i + 3].trim() - }); - } - - return items; - } - - function convertToVTT(data) { - return subsrt.convert(data, { - format: 'vtt', - fps: 25 - }); - } - /** - * Парсить VTT - * @param {string} data - * @param {boolean} ms - * @returns {[{id:string, startTime:number, endTime:number, text:string}]} - */ - - - function parseVTT(data, ms) { - var useMs = ms ? true : false; - data = data.replace(/\r\n/g, '\n'); - data = data.replace(/\r/g, '\n'); - data = data.replace(/(\d{2}):(\d{2})\.(\d{3})[ \t]+-->[ \t]+(\d{2}):(\d{2})\.(\d{3})/g, '00:$1:$2.$3 --> 00:$4:$5.$6'); - var regex = /(\n\n.+\n)?[ \t]*(\d{2}:\d{2}:\d{2}\.\d{3})[ \t]+-->[ \t]+(\d{2}:\d{2}:\d{2}\.\d{3})/g; - data = data.split(regex); - data.shift(); - var items = []; - - for (var i = 0; i < data.length; i += 4) { - items.push({ - id: (data[i] || '').trim(), - startTime: useMs ? time$1(data[i + 1].trim()) : data[i + 1].trim(), - endTime: useMs ? time$1(data[i + 2].trim()) : data[i + 2].trim(), - text: data[i + 3].trim() - }); - } - - return items; - } - /** - * Класс - */ - - - function CustomSubs() { - var parsed; - var network = new create$p(); - this.listener = start$8(); - /** - * Загрузить - * @param {string} url - */ - - this.load = function (url) { - network.silent(url, function (data) { - if (data) { - parsed = parse$2(data, true); - } - }, false, false, { - dataType: 'text' - }); - }; - /** - * Показать текст - * @param {number} time_sec - */ - - - this.update = function (time_sec) { - var time_ms = time_sec * 1000; - - if (parsed) { - var text = ''; - - for (var i = 0; i < parsed.length; i++) { - var sub = parsed[i]; - - if (time_ms > sub.startTime && time_ms < sub.endTime) { - text = sub.text.replace("\n", '
    '); - break; - } - } - - this.listener.send('subtitle', { - text: text.trim() - }); - } - }; - /** - * Уничтожить - */ - - - this.destroy = function () { - network.clear(); - network = null; - this.listener = null; - }; - } - - var context; - - function smooth(a, b, s, c) { - return a + (b - a) * (s * 0.02); - } - - function toDb(_float) { - var db = 20 * (Math.log(_float) / Math.log(10)); - db = Math.max(-48, Math.min(db, 0)); - return db; - } - - function Source(video) { - var source = context.createMediaElementSource(video); - var analyser = context.createAnalyser(); - var volume = context.createGain(); - var destroy = false; - var display = true; - var draw_html = $('
    '); - var draw_canvas = draw_html.find('canvas')[0]; - var draw_context = draw_canvas.getContext("2d"); - draw_canvas.width = 5; - draw_canvas.height = Math.round(window.innerHeight * 0.26); //размер буффера - - try { - analyser.fftSize = 2048 * 4; - } catch (e) { - try { - analyser.fftSize = 2048 * 2; - } catch (e) { - analyser.fftSize = 2048; - } - } //данные от анализа - - - analyser.time_array = new Uint8Array(analyser.fftSize); //нижний порог - - analyser.min_db = 0; //подключаем анализ - - source.connect(analyser); //подключаем регулятор звука - - analyser.connect(volume); //подключаем к выходу - - volume.connect(context.destination); - $('body').append(draw_html); - - function update() { - if (!destroy) requestAnimationFrame(update); - analyser.getByteTimeDomainData(analyser.time_array); - var total = 0, - rms = 0, - i = 0; - - var _float2, mdb; - - var min = -48; - - while (i < analyser.fftSize) { - _float2 = analyser.time_array[i++] / 0x80 - 1; - total += _float2 * _float2; - rms = Math.max(rms, _float2); - mdb = toDb(_float2); - if (!isNaN(mdb)) min = Math.max(min, mdb); - } - - rms = Math.sqrt(total / analyser.fftSize); - var db = toDb(rms); - var sm = Storage.get('player_normalization_smooth', 'medium'); - var pw = Storage.get('player_normalization_power', 'hight'); - if (min === -48) min = db; - if (min === -48) min = -40; - analyser.min_db = smooth(analyser.min_db, min, sm == 'hight' ? 45 : sm == 'medium' ? 25 : 10); - var low = (-48 - analyser.min_db) * (pw == 'hight' ? 1 : pw == 'medium' ? 0.75 : 0.5); - volume.gain.value = pw == 'none' ? 1 : Math.max(0.0, Math.min(2, db / low)); - - if (display) { - draw_context.clearRect(0, 0, draw_canvas.width, draw_canvas.height); - var down = Math.min(1, Math.max(0, 1 - volume.gain.value)); - var up = Math.min(1, Math.max(0, volume.gain.value - 1)); - var half = draw_canvas.height / 2; - draw_context.fillStyle = 'rgba(251,91,91,1)'; - draw_context.fillRect(0, half, draw_canvas.width, half * down); - draw_context.fillStyle = 'rgba(91,213,251,1)'; - draw_context.fillRect(0, half - half * up, draw_canvas.width, half * up); - } - } - - update(); - - this.visible = function (status) { - display = status; - draw_html.toggleClass('normalization--visible', status); - }; - - this.destroy = function () { - volume.disconnect(); - analyser.disconnect(); - source.disconnect(); - destroy = true; - draw_html.remove(); - }; - } - - function Normalization() { - - if (!context) { - var classContext = window.AudioContext || window.webkitAudioContext; - context = new classContext(); - } - - var source; - - this.attach = function (video) { - if (!source) source = new Source(video); - }; - - this.visible = function (status) { - if (source) source.visible(status); - }; - - this.destroy = function () { - if (source) source.destroy(); - source = null; - }; - } - - function AVPlay(call_video) { - var avplay, plugin, stream_url, loaded, current_time; - var object = $(''); - var video = object[0]; - var listener = start$8(); - var change_scale_later; - var change_speed_later; - var canGetVideoResolution = false; - /** - * Установить урл - */ - - Object.defineProperty(video, "src", { - set: function set(url) { - if (url) { - if (url.toLowerCase().indexOf(".m3u8") != -1 && url.toUpperCase().indexOf("|COMPONENT=HLS") == -1) { - url += "|COMPONENT=HLS"; - } else if (url.toLowerCase().indexOf(".mpd") != -1 && url.toUpperCase().indexOf("|COMPONENT=HAS") == -1) { - url += "|COMPONENT=HAS"; - } - - stream_url = url; - console.log(stream_url); - avplay.init(); - plugin = avplay.setPlayerPluginObject(); - avplay.onEvent = eventHandler; - } - }, - get: function get() {} - }); - /** - * Позиция - */ - - Object.defineProperty(video, "currentTime", { - set: function set(t) { - try { - seekTo(t); - } catch (e) { - listener.send('error', { - error: 'code [' + e.code + '] ' + e.message - }); - } - }, - get: function get() { - return current_time ? current_time / 1000 : 0; - } - }); - /** - * - */ - - function seekTo(time) { - var time_s; - var time_ms = Math.ceil(time) * 1000; - var duration_ms = avplay.getDuration(); - - if (time_ms >= 0 && current_time - time_ms >= 0) { - time_s = Math.ceil((current_time - time_ms) / 1000); - plugin.Execute("JumpBackward", time_s); - } else if (time_ms >= 0 && duration_ms - current_time + time_ms >= 0) { - time_s = Math.ceil((time_ms - current_time) / 1000); - plugin.Execute("JumpForward", time_s); - } - } - /** - * Длительность - */ - - - Object.defineProperty(video, "duration", { - set: function set() {}, - get: function get() { - var d = 0; - - try { - d = avplay.getDuration(); - } catch (e) {} - - return d ? d / 1000 : 0; - } - }); - /** - * Пауза - */ - - Object.defineProperty(video, "paused", { - set: function set() {}, - get: function get() { - try { - return avplay.status == '5'; - } catch (e) { - return false; - } - } - }); - /** - * Аудиодорожки - */ - - Object.defineProperty(video, "audioTracks", { - set: function set() {}, - get: function get() { - try { - var amount = avplay.getTotalNumOfStreamID(1); - var tracks = Array.apply(null, { - length: amount - }).map(Number.call, Number).map(function (i) { - var item = { - extra: JSON.parse(avplay.getStreamExtraData(1, i)), - index: parseInt(i), - language: languageNumToStr(avplay.getStreamLanguageInfo(1, i)) - }; - Object.defineProperty(item, "enabled", { - set: function set(v) { - if (v) { - try { - avplay.setStreamID(1, item.index); - } catch (e) { - console.log('Player', 'no change audio:', e.message); - } - } - }, - get: function get() {} - }); - return item; - }).sort(function (a, b) { - return a.index - b.index; - }); - return tracks; - } catch (e) { - return []; - } - } - }); - /** - * Субтитры - */ - - Object.defineProperty(video, "textTracks", { - set: function set() {}, - get: function get() { - try { - var amount = avplay.getTotalNumOfStreamID(4); - var tracks = Array.apply(null, { - length: amount - }).map(Number.call, Number).map(function (i) { - var item = { - extra: JSON.parse(avplay.getStreamExtraData(4, i)), - index: parseInt(i), - language: languageNumToStr(avplay.getStreamLanguageInfo(4, i)) - }; - Object.defineProperty(item, "mode", { - set: function set(v) { - if (v == 'showing') { - try { - avplay.setStreamID(4, item.index); - } catch (e) { - console.log('Player', 'no change text:', e.message); - } - } - }, - get: function get() {} - }); - return item; - }).sort(function (a, b) { - return a.index - b.index; - }); - return tracks; - } catch (e) { - return []; - } - } - }); - /** - * Получаем текст языка субтитров или аудио - */ - - function languageNumToStr(num) { - var str; //Словарь кодов озвучек - - var lang = { - 6384738: "Albanian", - 7565673: "Albanian", - 6647399: "English", - 6388325: "Azerbaijan", - 6386285: "Armenian", - 6448492: "Belarusian", - 6452588: "Bulgarian", - 6514793: "Chinese", - 6776178: "German", - 6911073: "Italian", - 7565409: "Spanish", - 7037306: "Kazakh", - 7040882: "Korean", - 7368562: "Portuguese", - 7501171: "Russian", - 7564399: "Slovak", - 7564406: "Slovenian", - 7565936: "Serbian", - 7632242: "Turkish", - 7699042: "Uzbek", - 7695218: "Ukrainian", - 8026747: "Ukrainian", - 6713957: "French", - 7567205: "Swedish", - 6975598: "Japanese" - }; - - if (lang[num] != undefined) { - str = lang[num]; - } else { - var nHex = num.toString(16); - var sHex1 = "0x" + nHex.substring(0, 2); - var sHex2 = "0x" + nHex.substring(2, 2); - var sHex3 = "0x" + nHex.substring(4, 2); - var str1 = String.fromCharCode(sHex1); - var str2 = String.fromCharCode(sHex2); - var str3 = String.fromCharCode(sHex3); - str = str1 + str2 + str3; - - if (str === "\0\0\0") { - str = "Неизвестный"; - } - } - - return str; - } - /** - * Ширина видео - */ - - - Object.defineProperty(video, "videoWidth", { - set: function set() {}, - get: function get() { - if (canGetVideoResolution) { - return avplay.getVideoResolution().split('|')[0]; - } else { - return 0; - } - } - }); - /** - * Высота видео - */ - - Object.defineProperty(video, "videoHeight", { - set: function set() {}, - get: function get() { - if (canGetVideoResolution) { - return avplay.getVideoResolution().split('|')[1]; - } else { - return 0; - } - } - }); - /** - * Меняем размер видео - * @param {string} scale - default|fill - */ - - function changeScale(scale) { - try { - var xV = curWidget.width, - yV = curWidget.height, - aX = 0, - aY = 0, - aW = curWidget.width, - aH = curWidget.height, - cX = 0, - cY = 0, - pH = 100, - pW = 100, - cW = video.videoWidth, - cH = video.videoHeight; - - if (cH == 0 || cW == 0) { - throw false; - } - - switch (scale) { - //original - case 'default': - if (cW / cH < 1.79) { - aW = yV * cW / cH; - aX = (xV - aW) / 2; - } else { - aH = xV * cH / cW; - aY = (yV - aH) / 2; - } - - ; - break; - //full - - case 'fill': - break; - - default: - //zoom - var type = scale[0]; - var zoom = parseInt(scale.replace(/\D+/g, "")); - - if (type == 's') { - pH = zoom; - pW = zoom; - } else if (type == 'v') { - pH = zoom; - pW = 100; - } - - if (zoom >= 80 && zoom <= 140) { - if (pW <= 100) { - aW = xV / 100 * pW; - aX = (xV - aW) / 2; - } else { - cX = cW * (pW / 200 - 0.5); - cW = cW * (2 - pW / 100); - } - - if (pH <= 100) { - aH = yV / 100 * pH; - aY = (yV - aH) / 2; - } else { - cY = cH * (pH / 200 - 0.5); - cH = cH * (2 - pH / 100); - } - } else { - changeScale('default'); - return; - } - - break; - } - - ; - avplay.setDisplayArea({ - left: aX, - top: aY, - width: aW, - height: aH - }); - - if (scale != 'fill') { - avplay.setCropArea(function () { - console.log('Player', 'change scale ' + scale); - }, function (e) { - listener.send('error', { - error: 'code [' + e.code + '] ' + e.message - }); - }, { - left: cX, - top: cY, - width: cW, - height: cH - }); - } else { - avplay.setCropArea(function () { - console.log('Player', 'change scale ' + scale); - }, function (e) { - listener.send('error', { - error: 'code [' + e.code + '] ' + e.message - }); - }, { - left: 0, - top: 0, - width: 0, - height: 0 - }); - } - } catch (e) { - change_scale_later = scale; - } - } - - function changeSpeed(speed) { - try { - avplay.setSpeed(speed); - } catch (e) { - change_speed_later = speed; - } - } - /** - * Всегда говорим да, мы можем играть - */ - - - video.canPlayType = function () { - return true; - }; - /** - * Вешаем кастомные события - */ - - - video.addEventListener = listener.follow.bind(listener); - /** - * Вешаем события от плеера orsay - */ - - var eventHandler = function eventHandler(type, data) { - switch (type) { - // 1 CONNECTION_FAILED; - case 1: - listener.send('error', { - error: '[orsay native player: CONNECTION_FAILED]' - }); - break; - // 2 AUTHENTICATION_FAILED - - case 2: - listener.send('error', { - error: '[orsay native player: AUTHENTICATION_FAILED]' - }); - break; - // 3 STREAM_NOT_FOUND - - case 3: - listener.send('error', { - error: '[orsay native player: STREAM_NOT_FOUND]' - }); - break; - // 4 NETWORK_DISCONNECTED - - case 4: - listener.send('error', { - error: '[orsay native player: NETWORK_DISCONNECTED]' - }); - break; - // 5 NETWORK_SLOW - - case 5: - listener.send('error', { - error: '[orsay native player: NETWORK_SLOW]' - }); - break; - // 6 RENDER_ERROR (a) - - case 6: - switch (data) { - case "0": - listener.send('error', { - error: '[orsay native player: UNKNOWN_ERROR]' - }); - break; - - case "1": - listener.send('error', { - error: '[orsay native player: UNSUPPORTED_CONTAINER]' - }); - break; - - case "2": - listener.send('error', { - error: '[orsay native player: UNSUPPORTED_VIDEO_CODEC]' - }); - break; - - case "3": - listener.send('error', { - error: '[orsay native player: UNSUPPORTED_AUDIO_CODEC]' - }); - break; - - case "4": - listener.send('error', { - error: '[orsay native player: UNSUPPORTED_VIDEO_RESOLUTION]' - }); - break; - - case "5": - listener.send('error', { - error: '[orsay native player: UNSUPPORTED_VIDEO_FRAMERATE]' - }); - break; - - case "6": - listener.send('error', { - error: '[orsay native player: CURRUPTED_STREAM]' - }); - break; - - case "100": - listener.send('error', { - error: '[orsay native player: CUSTOM_ERROR]' - }); - break; - } - - // 7 RENDERING_START - - case 7: - console.log('Player', 'RENDERING_START'); - break; - // 8 RENDERING_COMPLETE - - case 8: - console.log('Player', 'RENDERING_COMPLETE'); - avplay.stop(); - listener.send('ended'); - break; - // 9 STREAM_INFO_READY - - case 9: - canGetVideoResolution = true; - $('body').toggleClass('orsay-player--show', true); - console.log('Player', 'STREAM_INFO_READY'); - avplay.startSubtitle({ - path: "/dtv/temp/", - streamID: 999, - sync: 999, - callback: function callback() {} - }); - listener.send('loadeddata'); - break; - // 10 DECODING_COMPLETE - - case 10: - console.log('Player', 'DECODING_COMPLETE'); - break; - - case 11: - console.log('Player', 'buffering start'); - listener.send('waiting'); - break; - // 12 BUFFERING_COMPLETE - - case 12: - console.log('Player', 'BUFFERING_COMPLETE'); - listener.send('playing'); - break; - // 13 BUFFERING_PROGRESS - - case 13: - listener.send('progress', { - percent: data - }); - break; - // 14 CURRENT_PLAYBACK_TIME - - case 14: - current_time = data; - listener.send('timeupdate'); - - if (change_scale_later) { - changeScale(change_scale_later); - change_scale_later = false; - } - - if (change_speed_later) { - changeSpeed(change_speed_later); - change_speed_later = false; - } - - break; - // 15 AD_START - - case 15: - console.log('Player', 'AD_START'); - break; - // 16 AD_END - - case 16: - console.log('Player', 'AD_END'); - break; - // 17 RESOLUTION_CHANGED - - case 17: - console.log('Player', 'RESOLUTION_CHANGED ' + data); - break; - // 18 BITRATE_CHANGED - - case 18: - console.log('Player', 'BITRATE_CHANGED ' + data); - break; - // 19 SUBTITLE - - case 19: - listener.send('subtitle', { - text: data - }); - break; - } - }; - /** - * Загрузить - */ - - - video.load = function () { - if (stream_url) { - if (avplay.open(stream_url)) { - loaded = true; - listener.send('canplay'); - } - } - }; - /** - * Играть - */ - - - video.play = function () { - if (loaded) { - if (avplay.status == '5') { - avplay.resume(); - } else { - avplay.play(function () { - console.log('Player', 'play'); - }, function (e) { - listener.send('error', { - error: 'code [' + e.code + '] ' + e.message - }); - }); - } - } - }; - /** - * Пауза - */ - - - video.pause = function () { - if (loaded) avplay.pause(); - }; - /** - * Установить масштаб - */ - - - video.size = function (type) { - changeScale(type); - }; - /** - * Установить скорость - */ - - - video.speed = function (speed) { - changeSpeed(speed); - }; - /** - * Уничтожить - */ - - - video.destroy = function () { - try { - console.log('Player', 'destroy'); - avplay.destroy(); - } catch (e) {} - - $('body').toggleClass('orsay-player--show', false); - video.remove(); - listener.destroy(); - }; - - webapis.avplay.getAVPlay(function (av) { - avplay = av; - }, function (e) { - listener.send('error', { - error: 'code [' + e.code + '] ' + e.message - }); - }); - call_video(video); - return object; - } - - function YouTube$1(call_video) { - var stream_url, loaded; - var needclick = true; //Platform.screen('mobile') || navigator.userAgent.toLowerCase().indexOf("android") >= 0 - - var object = $('
    ' + Lang.translate('player_youtube_no_played') + '
    '); - var video = object[0]; - var listener = start$8(); - var volume = 100; - var youtube; - var timeupdate; - var timetapplay; - var screen_size = 2; - - function videoSize() { - var size = { - width: 0, - height: 0 - }; - - if (youtube) { - var str = ''; - - try { - str = youtube.getPlaybackQuality(); - } catch (e) {} - - if (str == 'highres' || str == 'hd2160') { - size.width = 3840; - size.height = 2160; - } else if (str == 'hd1440') { - size.width = 2560; - size.height = 1440; - } else if (str == 'hd1080') { - size.width = 1920; - size.height = 1080; - } else if (str == 'hd720') { - size.width = 1280; - size.height = 720; - } else { - size.width = 854; - size.height = 480; - } - } - - return size; - } - /** - * Установить урл - */ - - - Object.defineProperty(video, "src", { - set: function set(url) { - if (url) { - stream_url = url; - } - }, - get: function get() {} - }); - /** - * Позиция - */ - - Object.defineProperty(video, "currentTime", { - set: function set(t) { - try { - youtube.seekTo(t); - } catch (e) {} - }, - get: function get() { - try { - return youtube.getCurrentTime(); - } catch (e) { - return 0; - } - } - }); - /** - * Длительность - */ - - Object.defineProperty(video, "duration", { - set: function set() {}, - get: function get() { - try { - return youtube.getDuration(); - } catch (e) { - return 0; - } - } - }); - /** - * Пауза - */ - - Object.defineProperty(video, "paused", { - set: function set() {}, - get: function get() { - if (needclick) return true; - - try { - return youtube.getPlayerState() == YT.PlayerState.PAUSED; - } catch (e) { - return true; - } - } - }); - /** - * Аудиодорожки - */ - - Object.defineProperty(video, "audioTracks", { - set: function set() {}, - get: function get() { - return []; - } - }); - /** - * Субтитры - */ - - Object.defineProperty(video, "textTracks", { - set: function set() {}, - get: function get() { - return []; - } - }); - /** - * Ширина видео - */ - - Object.defineProperty(video, "videoWidth", { - set: function set() {}, - get: function get() { - return videoSize().width; - } - }); - /** - * Высота видео - */ - - Object.defineProperty(video, "videoHeight", { - set: function set() {}, - get: function get() { - return videoSize().height; - } - }); - Object.defineProperty(video, "volume", { - set: function set(num) { - volume = num * 100; - if (youtube) youtube.setVolume(volume); - }, - get: function get() {} - }); - /** - * Всегда говорим да, мы можем играть - */ - - video.canPlayType = function () { - return true; - }; - - video.resize = function () { - object.find('.player-video__youtube-player').width(window.innerWidth * screen_size); - object.find('.player-video__youtube-player').height((window.innerHeight + 600) * screen_size); - object.find('.player-video__youtube-player').addClass('minimize'); //.css({transform: 'scale(0.5)'}) - }; - /** - * Вешаем кастомные события - */ - - - video.addEventListener = listener.follow.bind(listener); - /** - * Загрузить - */ - - video.load = function () { - if (stream_url && !youtube) { - video.resize(); - var id = stream_url.split('?v=').pop(); - - if (needclick) { - object.append('
    ' + Lang.translate('loading') + '...' + '
    '); - timetapplay = setTimeout(function () { - object.find('.player-video__youtube-needclick div').text(Lang.translate('player_youtube_start_play')); - PlayerPanel.update('pause'); - }, 10000); - } - - console.log('YouTube', 'create'); - youtube = new YT.Player('youtube-player', { - height: (window.innerHeight + 600) * screen_size, - width: window.innerWidth * screen_size, - playerVars: { - 'controls': 1, - 'showinfo': 0, - 'autohide': 1, - 'modestbranding': 1, - 'autoplay': 1, - 'disablekb': 1, - 'fs': 0, - 'enablejsapi': 1, - 'playsinline': 1, - 'rel': 0, - 'suggestedQuality': 'hd1080', - 'setPlaybackQuality': 'hd1080' - }, - videoId: id, - events: { - onReady: function onReady(event) { - loaded = true; - youtube.setVolume(volume); - listener.send('canplay'); - listener.send('loadeddata'); - timeupdate = setInterval(function () { - if (youtube.getPlayerState() !== YT.PlayerState.PAUSED) listener.send('timeupdate'); - }, 100); - if (needclick) listener.send('playing'); - }, - onStateChange: function onStateChange(state) { - object.removeClass('ended'); - if (needclick) object.find('.player-video__youtube-needclick div').text(Lang.translate('loading') + '...'); - - if (state.data == YT.PlayerState.PLAYING) { - listener.send('playing'); - clearTimeout(timetapplay); - - if (needclick) { - needclick = false; - setTimeout(function () { - object.find('.player-video__youtube-needclick').remove(); - }, 500); - } - } - - if (state.data == YT.PlayerState.ENDED) { - object.addClass('ended'); - listener.send('ended'); - } - - if (state.data == YT.PlayerState.BUFFERING) { - listener.send('waiting'); - state.target.setPlaybackQuality('hd1080'); - } - }, - onPlaybackQualityChange: function onPlaybackQualityChange(state) { - console.log('YouTube', 'quality', youtube.getPlaybackQuality()); - }, - onError: function onError(e) { - object.find('.player-video__youtube-noplayed').removeClass('hide'); - object.addClass('ended'); - if (needclick) object.find('.player-video__youtube-needclick').remove(); - clearTimeout(timetapplay); - } - } - }); - } - }; - /** - * Играть - */ - - - video.play = function () { - try { - youtube.playVideo(); - } catch (e) {} - }; - /** - * Пауза - */ - - - video.pause = function () { - try { - youtube.pauseVideo(); - } catch (e) {} - }; - /** - * Установить масштаб - */ - - - video.size = function (type) {}; - /** - * Установить скорость - */ - - - video.speed = function (speed) {}; - /** - * Уничтожить - */ - - - video.destroy = function () { - if (loaded) { - clearInterval(timeupdate); - - try { - youtube.destroy(); - } catch (e) {} - } - - object.remove(); - clearTimeout(timetapplay); - listener.destroy(); - }; - - call_video(video); - return object; - } - - var loaded_data = { - ad: [], - time: 0, - position: 0 - }; - - var VideoBlock = /*#__PURE__*/function () { - function VideoBlock(number) { - var _this = this; - - _classCallCheck(this, VideoBlock); - - this.network = new create$p(); - this.listener = start$8(); - this.paused = false; - this.number = number || 1; - var domain = object$2.cub_domain; - - if (loaded_data.time < Date.now() + 1000 * 60 * 60 * 5) { - this.network.silent(Utils$2.protocol() + domain + '/api/ad/all', function (data) { - loaded_data.time = Date.now(); - var need_shuffle = !loaded_data.ad.length; - data.forEach(function (elem) { - var ad = loaded_data.ad.find(function (a) { - return a.url == elem.url; - }); - - if (!ad) { - ad = elem; - loaded_data.ad.push(elem); - } - - ad.volume = elem.volume; - ad.duration = elem.duration; - }); - if (need_shuffle) Arrays.shuffle(loaded_data.ad); - - _this.start(); - }, function () { - _this.listener.send('empty'); - }); - } - } - - _createClass(VideoBlock, [{ - key: "start", - value: function start() { - var ad = loaded_data.ad[loaded_data.position]; - - if (!ad) { - loaded_data.position = 0; - Arrays.shuffle(loaded_data.ad); - ad = loaded_data.ad[0]; - } - - loaded_data.position++; - - if (ad) { - this.time = Date.now(); - this.create(ad); - this.load(ad); - } - } - }, { - key: "load", - value: function load(data) { - this.video.src = data.url; - this.video.load(); - } - }, { - key: "create", - value: function create(data) { - var _this2 = this; - - this.block = Template$1.js('ad_video_block'); - this.last_controller = Controller.enabled().name; - this.block.find('.ad-video-block__text').text(Lang.translate('ad') + ' - ' + Lang.translate('ad_disable')); - this.block.find('.ad-video-block__info').text(data.info || ''); - this.video = this.block.find('.ad-video-block__video'); - var detention = 0; - var duration = data.duration; - var passed = 0; - var skip = this.block.find('.ad-video-block__skip'); - var progressbar = this.block.find('.ad-video-block__progress-fill'); - var pause = this.block.find('.player-video__paused'); - var skip_sec = data.skip ? data.skip / 1000 : 10; - skip.find('span').text(skip_sec); - if (duration <= 1000 * skip_sec) skip.classList.add('hide'); - this.video.addEventListener('loadeddata', function () { - _this2.video.play(); - - detention = Math.min(1000 * 2, Date.now() - _this2.time); - - _this2.video.classList.add('loaded'); - }); - this.video.addEventListener('timeupdate', function () { - _this2.listener.send('timeupdate'); - }); - this.video.addEventListener('ended', function () { - _this2.destroy(); - }); - - function enter() { - var left = Math.max(0, Math.round(skip_sec - passed / 1000)); - if (left == 0) return this.destroy(); - - if (this.video.paused) { - this.video.play(); - pause.classList.add('hide'); - this.paused = false; - } else { - this.video.pause(); - pause.classList.remove('hide'); - this.paused = true; - } - } - - this.block.on('click', enter.bind(this)); - this.video.volume = (Boolean(Platform.is('nw') || Platform.is('browser') || Platform.is('apple') && !Utils$2.isPWA()) ? parseFloat(Storage.get('player_volume', '1')) : 1) * data.volume; - this.video.muted = false; - document.body.append(this.block); - this.timer = setInterval(function () { - if (_this2.paused) return; - passed += 100; - var progress = Math.min(100, passed / (duration + detention) * 100); - var left = Math.max(0, Math.round(skip_sec - passed / 1000)); - progressbar.style.width = progress + '%'; - skip.find('span').text(Lang.translate(left == 0 ? 'ad_skip' : left)); - if (progress == 100) _this2.destroy(); - }, 100); - Controller.add('ad_video_block', { - toggle: function toggle() { - Controller.clear(); - }, - enter: enter.bind(this), - back: function back() {} - }); - Controller.toggle('ad_video_block'); - this.listener.send('launch'); - - if (data.stat) { - $.ajax({ - dataType: 'text', - url: data.stat - }); - } - } - }, { - key: "destroy", - value: function destroy() { - clearInterval(this.timer); - this.video.pause(); - this.video.src = ''; - this.block.remove(); - Controller.toggle(this.last_controller); - this.listener.send('ended'); - } - }]); - - return VideoBlock; - }(); - - var Item = /*#__PURE__*/function () { - function Item(data, params) { - _classCallCheck(this, Item); - - this.data = data; - this.params = params; - } - - _createClass(Item, [{ - key: "create", - value: function create() { - this.html = Template$1.js(this.template, {}); - this.html.addEventListener('visible', this.visible.bind(this)); - } - }, { - key: "update", - value: function update() { - var url = (this.data.url || this.data.link) + ''; - var loc = url.slice(0, 6) == 'https:' || window.location.protocol == 'https:'; - var hts = url.slice(0, 6) == 'https:' || url.slice(0, 5) == 'http:'; - if (window.location.protocol == 'https:' && hts) url = url.replace(/(http:\/\/|https:\/\/)/g, 'https://'); - this.html.querySelector('.extensions__item-name').innerText = this.data.name || Lang.translate('extensions_no_name'); - this.html.querySelector('.extensions__item-author').innerText = this.data.author || (this.params.type == 'plugins' ? '@cub' : '@bylampa'); - this.html.querySelector('.extensions__item-descr').innerText = (this.data.descr || url).replace(/\n|\t|\r/g, ' '); - var proto = this.html.querySelector('.extensions__item-proto'); - - if (proto && hts) { - proto.toggleClass('hide', !Boolean(this.params.type == 'plugins' || this.params.type == 'installs')); - proto.addClass('protocol-' + (loc ? 'https' : 'http')); - } - - var status = this.html.querySelector('.extensions__item-disabled'); - status.innerText = Lang.translate('player_disabled'); - if (this.data.status || !this.params.autocheck) status.classList.add('hide');else status.classList.remove('hide'); - } - }, { - key: "cub", - value: function cub() { - var cub = document.createElement('div'); - cub.classList.add('extensions__cub'); - cub.innerText = 'CUB'; - this.html.appendChild(cub); - } - }, { - key: "premium", - value: function premium() { - var author = this.html.querySelector('.extensions__item-author'); - var premium = document.createElement('span'); - premium.classList.add('extensions__item-premium'); - premium.innerText = 'CUB Premium'; - var where = author || this.html; - where.appendChild(premium); - } - }, { - key: "visible", - value: function visible() { - this.update(); - } - }, { - key: "render", - value: function render() { - return this.html; - } - }, { - key: "destroy", - value: function destroy() { - this.html.remove(); - } - }]); - - return Item; - }(); - - function showReload(cancel) { - Modal.open({ - title: '', - align: 'center', - zIndex: 300, - html: $('
    ' + Lang.translate('plugins_need_reload') + '
    '), - buttons: [{ - name: Lang.translate('settings_param_no'), - onSelect: function onSelect() { - Modal.close(); - cancel(); - } - }, { - name: Lang.translate('settings_param_yes'), - onSelect: function onSelect() { - window.location.reload(); - } - }] - }); - } - - function showInfo(plug, back) { - var modal = Template$1.get('extensions_info'); - var footer = $('.extensions-info__footer', modal); - if (plug.image) modal.prepend($('')); - $('.extensions-info__descr', modal).text(plug.descr); - $('.extensions-info__instruction', modal).html((plug.instruction || Lang.translate('extensions_no_info')).replace(/\n/g, '
    ').replace(/\s\s/g, '  ')); - - function addLabel(name, value) { - var label = $("
    \n
    ".concat(name, "
    \n
    ").concat(value, "
    \n
    ")); - footer.append(label); - } - - if (plug.link) addLabel(Lang.translate('settings_parser_jackett_link'), plug.link); - if (plug.author) addLabel(Lang.translate('title_author'), plug.author); - if (plug.time) addLabel(Lang.translate('settings_added'), Utils$2.parseTime(plug.time).full); - Modal.open({ - title: plug.name || Lang.translate('extensions_info'), - html: modal, - size: 'large', - onBack: function onBack() { - Modal.close(); - back(); - } - }); - } - - var Utils$1 = { - showReload: showReload, - showInfo: showInfo - }; - - var Extension = /*#__PURE__*/function (_Item) { - _inherits(Extension, _Item); - - var _super = _createSuper(Extension); - - function Extension(data, params) { - var _this; - - _classCallCheck(this, Extension); - - _this = _super.call(this, data, params); - _this.network = new create$p(); - _this.template = 'extensions_item'; - return _this; - } - - _createClass(Extension, [{ - key: "visible", - value: function visible() { - _get(_getPrototypeOf(Extension.prototype), "visible", this).call(this); - - if (this.params.cub) this.cub(); - if (this.data.premium) this.premium(); - if (this.params.autocheck) this.check(); - if (Plugins.loaded().indexOf(this.data.url || this.data.link) >= 0) this.html.querySelector('.extensions__item-included').classList.remove('hide'); - this.html.addEventListener('hover:enter', this.menu.bind(this)); - } - }, { - key: "menu", - value: function menu() { - var _this2 = this; - - if (this.removed) return; - var menu = []; - var controller = Controller.enabled().name; - - var back = function back() { - Controller.toggle(controller); - }; - - if (this.params.type == 'plugins' || this.params.type == 'installs') { - menu.push({ - title: Lang.translate('extensions_' + (this.data.status ? 'disable' : 'enable')), - toggle: true - }); - } - - menu.push({ - title: Lang.translate('extensions_check'), - status: true - }); - - if (this.params.cub || this.params.noedit) { - if (this.params.type == 'extensions') { - menu.push({ - title: Lang.translate('extensions_install'), - install: true - }); - } - - menu.push({ - title: Lang.translate('extensions_info'), - instruction: true - }); - } else { - menu.push({ - title: Lang.translate('extensions_edit'), - separator: true - }); - menu.push({ - title: Lang.translate('extensions_change_name'), - change: 'name' - }); - menu.push({ - title: Lang.translate('extensions_change_link'), - change: 'url' - }); - menu.push({ - title: Lang.translate('extensions_remove'), - remove: true - }); - } - - Select.show({ - title: Lang.translate('title_action'), - items: menu, - onBack: back, - onSelect: function onSelect(a) { - if (a.toggle) { - _this2.data.status = _this2.data.status == 1 ? 0 : 1; - if (_this2.params.cub) Account.pluginsStatus(_this2.data, _this2.data.status);else Plugins.save(_this2.data); - - _this2.update(); - - if (_this2.data.status == 1) { - back(); - Plugins.push(_this2.data); - } else { - Utils$1.showReload(back); - } - } else if (a.change) { - Input.edit({ - title: a.change == 'name' ? Lang.translate('extensions_set_name') : Lang.translate('extensions_set_url'), - value: _this2.data[a.change] || '', - free: true, - nosave: true - }, function (new_value) { - if (new_value) { - _this2.data[a.change] = new_value; - Plugins.save(_this2.data); - - _this2.update(); - - if (a.change == 'url') { - _this2.check(); - - Plugins.push(_this2.data); - } - } - - back(); - }); - } else if (a.status) { - back(); - - _this2.check(); - } else if (a.install) { - var ready = Plugins.get().find(function (b) { - return b.url == _this2.data.link; - }); - - if (ready) { - Noty.show(Lang.translate('extensions_ready')); - back(); - } else { - back(); - Plugins.add({ - url: _this2.data.link, - status: 1, - name: _this2.data.name, - author: _this2.data.author - }); - - _this2.html.querySelector('.extensions__item-included').classList.remove('hide'); - } - } else if (a.instruction) { - Utils$1.showInfo(_this2.data, back); - } else if (a.remove) { - Plugins.remove(_this2.data); - _this2.html.style.opacity = 0.5; - _this2.removed = true; - Utils$1.showReload(back); - } - } - }); - } - }, { - key: "check", - value: function check() { - var check = this.html.querySelector('.extensions__item-check'); - var code = this.html.querySelector('.extensions__item-code'); - var stat = this.html.querySelector('.extensions__item-status'); - check.classList.remove('hide'); - code.classList.add('hide'); - stat.classList.add('hide'); - - var display = function display(type, num, text) { - code.innerText = num; - code.classList.remove('hide'); - code.classList.remove('success'); - code.classList.remove('error'); - code.classList.add(type); - stat.innerText = text; - stat.classList.remove('hide'); - check.classList.add('hide'); - }; - - var url = Utils$2.rewriteIfHTTPS(this.data.url || this.data.link); - this.network.timeout(5000); - this.network["native"](url, function (str) { - if (/Lampa\./.test(str)) { - display('success', 200, Lang.translate('extensions_worked')); - } else { - display('error', 500, Lang.translate('extensions_no_plugin')); - } - }, function (a, e) { - display('error', 404, Lang.translate('title_error')); - }, false, { - dataType: 'text' - }); - } - }]); - - return Extension; - }(Item); - - var Recomend = /*#__PURE__*/function (_Extension) { - _inherits(Recomend, _Extension); - - var _super = _createSuper(Recomend); - - function Recomend(data, params) { - var _this; - - _classCallCheck(this, Recomend); - - _this = _super.call(this, data, params); - _this.template = 'extensions_recomend'; - return _this; - } - - _createClass(Recomend, [{ - key: "visible", - value: function visible() { - var _this2 = this; - - _get(_getPrototypeOf(Recomend.prototype), "visible", this).call(this); - - this.img = this.html.querySelector('.extensions__item-image'); - - this.img.onload = function () { - _this2.img.classList.add('loaded'); - }; - - this.img.src = Utils$2.rewriteIfHTTPS(this.data.image); - } - }, { - key: "destroy", - value: function destroy() { - _get(_getPrototypeOf(Recomend.prototype), "destroy", this).call(this); - - if (this.img) { - this.img.onload = false; - this.img.onerror = false; - } - } - }]); - - return Recomend; - }(Extension); - - var Theme$1 = /*#__PURE__*/function () { - function Theme() { - _classCallCheck(this, Theme); - } - - _createClass(Theme, [{ - key: "init", - value: function init() { - if (this.get()) this.set(this.get()); - } - }, { - key: "toggle", - value: function toggle(url) { - if (url) { - Storage.set('cub_theme', url); - this.set(url); - } else { - Storage.set('cub_theme', ''); - $('#cub-theme').remove(); - } - } - }, { - key: "get", - value: function get() { - return Storage.get('cub_theme', ''); - } - }, { - key: "set", - value: function set(url) { - $('#cub-theme').remove(); - var href = Utils$2.rewriteIfHTTPS(Utils$2.addUrlComponent(url, 'token=' + encodeURIComponent(Storage.get('account', '{}').token))); - var css = $(''); - $('body').append(css); - } - }]); - - return Theme; - }(); - - var Theme$2 = new Theme$1(); - - var Theme = /*#__PURE__*/function (_Item) { - _inherits(Theme, _Item); - - var _super = _createSuper(Theme); - - function Theme(data, params) { - var _this; - - _classCallCheck(this, Theme); - - _this = _super.call(this, data, params); - _this.template = 'extensions_theme'; - _this.link = Utils$2.rewriteIfHTTPS(Utils$2.protocol() + object$2.cub_domain + '/extensions/' + _this.data.id); - return _this; - } - - _createClass(Theme, [{ - key: "update", - value: function update() { - this.html.querySelector('.extensions__item-name').innerText = this.data.name || Lang.translate('extensions_no_name'); - if (this.active()) this.html.classList.add('active');else this.html.classList.remove('active'); - } - }, { - key: "active", - value: function active() { - return Storage.get('cub_theme', '') == this.link; - } - }, { - key: "visible", - value: function visible() { - var _this2 = this; - - _get(_getPrototypeOf(Theme.prototype), "visible", this).call(this); - - if (this.data.premium) this.premium(); - this.img = this.html.querySelector('.extensions__item-image'); - - this.img.onload = function () { - _this2.img.classList.add('loaded'); - }; - - this.img.src = Utils$2.rewriteIfHTTPS(this.data.image); - this.html.addEventListener('hover:enter', this.menu.bind(this)); - } - }, { - key: "menu", - value: function menu() { - var _this3 = this; - - var menu = []; - var controller = Controller.enabled().name; - menu.push({ - title: Lang.translate('extensions_' + (this.active() ? 'disable' : 'enable')), - toggle: true - }); - Select.show({ - title: Lang.translate('title_action'), - items: menu, - onBack: function onBack() { - Controller.toggle(controller); - }, - onSelect: function onSelect(a) { - Controller.toggle(controller); - - if (a.toggle) { - if (!_this3.active() && _this3.data.premium && !Account.hasPremium()) return Lampa.Account.showCubPremium(); - Theme$2.toggle(_this3.active() ? '' : _this3.link); - - _this3.update(); - } - } - }); - } - }, { - key: "destroy", - value: function destroy() { - _get(_getPrototypeOf(Theme.prototype), "destroy", this).call(this); - - if (this.img) { - this.img.onload = false; - this.img.onerror = false; - } - } - }]); - - return Theme; - }(Item); - - var Nature = /*#__PURE__*/function () { - function Nature() { - _classCallCheck(this, Nature); - - this.slide = 'one'; - this.direct = ['lt', 'rt', 'br', 'lb', 'ct']; - } - - _createClass(Nature, [{ - key: "create", - value: function create() { - this.html = Template$1.get('screensaver'); - this.timer = setInterval(this.next.bind(this), 30000); - this.time = Utils$2.time(this.html); - this.time.tik(); - this.next(); - } - }, { - key: "next", - value: function next() { - var _this = this; - - var image = 'https://source.unsplash.com/1600x900/?nature&order_by=relevant&v=' + Math.random(); - var to_img = $('.screensaver__slides-' + (this.slide == 'one' ? 'two' : 'one'), this.html)[0]; - - to_img.onload = function () { - $(to_img).removeClass(_this.direct.join(' ') + ' animate').addClass(_this.direct[Math.floor(Math.random() * _this.direct.length)]); - setTimeout(function () { - $('.screensaver__slides-' + _this.slide, _this.html).removeClass('visible'); - _this.slide = _this.slide == 'one' ? 'two' : 'one'; - $(to_img).addClass('visible').addClass('animate'); - }, 100); - }; - - to_img.onerror = this.next.bind(this); - to_img.src = image; - } - }, { - key: "render", - value: function render() { - return this.html; - } - }, { - key: "destroy", - value: function destroy() { - clearInterval(this.timer); - clearInterval(this.time.timer); - this.html.remove(); - } - }]); - - return Nature; - }(); - - var Chrome = /*#__PURE__*/function () { - function Chrome() { - _classCallCheck(this, Chrome); - } - - _createClass(Chrome, [{ - key: "create", - value: function create() { - this.html = $('
    '); - } - }, { - key: "render", - value: function render() { - return this.html; - } - }, { - key: "destroy", - value: function destroy() { - this.html.remove(); - } - }]); - - return Chrome; - }(); - - var Cub = /*#__PURE__*/function () { - function Cub(params) { - _classCallCheck(this, Cub); - - this.params = params; - this["default"] = Utils$2.protocol() + object$2.cub_domain + '/img/background/default.mp4'; - } - - _createClass(Cub, [{ - key: "create", - value: function create() { - this.html = Template$1.get('screensaver'); - var source = this.params && this.params.url ? this.params.url : Storage.get('cub_screensaver', ''); - if (!source) source = this["default"]; - this.url = Utils$2.addUrlComponent(source, 'token=' + encodeURIComponent(Storage.get('account', '{}').token)); - this.preload = $('
    '); - this.html.prepend(this.preload); - this.html.find('.screensaver__slides').remove(); - this.time = Utils$2.time(this.html); - this.time.tik(); - if (Platform.is('webos')) this.video(this.url);else this.cache(this.url); - } - }, { - key: "load", - value: function load(video, er) { - var _this = this; - - video.load(); - var playPromise; - - try { - playPromise = video.play(); - } catch (e) {} - - var startPlay = function startPlay() { - console.log('Screesaver', 'playing'); - - _this.preload.remove(); - }; - - if (playPromise !== undefined) { - playPromise.then(function () { - return startPlay(); - })["catch"](function (e) { - console.log('Screesaver', 'play promise error:', e.message); - if (er) er(); - }); - } else startPlay(); - } - }, { - key: "video", - value: function video(src) { - var _this2 = this; - - var video = $(''); - this.html.prepend(video); - video[0].src = src; - this.load(video[0], function () { - console.log('Screesaver', 'get play url'); - video[0].src = _this2.url; - - _this2.load(video[0]); - }); - } - }, { - key: "cache", - value: function cache(url) { - var _this4 = this; - - var getblob = function getblob(result) { - return new Promise(function (resolve, reject) { - console.log('Screesaver', 'db find:', result ? 'true' : 'false'); - if (result) resolve(result);else { - console.log('Screesaver', 'start download video'); - var xhr = new XMLHttpRequest(); - xhr.open('GET', url, true); - xhr.responseType = 'blob'; - - xhr.onload = function (e) { - var _this3 = this; - - if (this.status == 200) { - Cache.addData('screensavers', url, this.response).then(function () { - console.log('Screesaver', 'push blob to db'); - resolve(_this3.response); - })["catch"](resolve.bind(this.response)); - } else reject(); - }; - - xhr.onerror = reject; - xhr.send(); - } - }); - }; - - Cache.getData('screensavers', url).then(getblob).then(function (blob) { - console.log('Screesaver', 'set video blob'); - _this4.create_url_blob = URL.createObjectURL(new Blob([blob], { - type: "video/mp4" - })); - - _this4.video(_this4.create_url_blob); - })["catch"](function (e) { - console.log('Screesaver', 'error:', typeof e == 'string' ? e : e.message); - - _this4.video(url); - }); - } - }, { - key: "render", - value: function render() { - return this.html; - } - }, { - key: "destroy", - value: function destroy() { - this.html.remove(); - - this.video = function () {}; - - if (this.create_url_blob) URL.revokeObjectURL(this.create_url_blob); - } - }]); - - return Cub; - }(); - - var Aerial = /*#__PURE__*/function () { - function Aerial(params) { - _classCallCheck(this, Aerial); - - this.params = params; - this.net = new create$p(); - this.visible = false; - this.items = []; - this.opacity = 0; - this.transition_time = 4000; - this.transition_timeout; - } - - _createClass(Aerial, [{ - key: "create", - value: function create() { - var _this = this; - - this.html = Template$1.get('screensaver'); - this.preload = $('
    '); - this.video = $('')[0]; - this.overlay = $('
    '); - this.video.addEventListener('timeupdate', function () { - if (_this.video.duration) { - var visible = _this.video.currentTime > 0 && _this.video.currentTime < _this.video.duration - 5; - var points = _this.object.pointsOfInterest; - - if (visible !== _this.visible) { - _this.visible = visible; - - _this.info.toggleClass('visible', visible); - - if (_this.visible) _this.fadeVideoOut(_this.transition_time);else _this.fadeVideoIn(_this.transition_time); - } - - if (_this.video.currentTime == _this.video.duration && !_this.wait_load) { - _this.wait_load = true; - - _this.select(); - - _this.play(); - } - - if (points) { - for (var time in points) { - var text = points[time]; - - if (parseInt(time) <= _this.video.currentTime && _this.tagline.text_ready !== text) { - _this.tagline.text_ready = text; - - _this.tagline.text(text); - } - } - } - } - }); - this.info = $("
    \n
    \n
    \n
    "); - this.title = this.info.find('.screensaver__title-name'); - this.tagline = this.info.find('.screensaver__title-tagline'); - this.html.prepend(this.preload); - this.html.prepend(this.overlay); - this.html.prepend(this.video); - this.html.find('.screensaver__slides').remove(); - this.html.find('.screensaver__gradient').after(this.info); - this.time = Utils$2.time(this.html); - this.time.tik(); - this.cache(function () { - _this.select(); - - _this.play(); - }); - } - }, { - key: "select", - value: function select() { - this.object = this.items[Math.floor(Math.random() * this.items.length)]; - this.title.text(this.object.name.replace(/\s\d$/, '')); - this.tagline.text(Utils$2.capitalizeFirstLetter(this.object.type)); - } - }, { - key: "fadeVideoIn", - value: function fadeVideoIn(time) { - if (time > 0) { - this.transition_timeout = setTimeout(this.fadeVideoIn.bind(this), 16, time - 16); - } - - this.opacity = 1 - time / this.transition_time; - this.overlay[0].style.opacity = this.opacity; - } - }, { - key: "fadeVideoOut", - value: function fadeVideoOut(time) { - if (time > 0) { - this.transition_timeout = setTimeout(this.fadeVideoOut.bind(this), 16, time - 16); - } - - this.opacity = time / this.transition_time; - this.overlay[0].style.opacity = this.opacity; - } - }, { - key: "play", - value: function play() { - var _this2 = this; - - this.video.src = this.object.src.H2641080p.replace('https:', 'http:'); - this.video.load(); - var playPromise; - - try { - playPromise = this.video.play(); - } catch (e) {} - - var startPlay = function startPlay() { - console.log('Screesaver', 'playing'); - - _this2.preload.remove(); - - _this2.wait_load = false; - }; - - if (playPromise !== undefined) { - playPromise.then(function () { - return startPlay(); - })["catch"](function (e) { - console.log('Player', 'play promise error:', e.message); - }); - } else startPlay(); - } - }, { - key: "cache", - value: function cache(call) { - var _this3 = this; - - this.items = Storage.get('screensaver_aerial_items', '[]'); - if (this.items.length) call();else { - this.net.silent('https://raw.githubusercontent.com/OrangeJedi/Aerial/master/videos.json', function (json) { - _this3.items = json.filter(function (a) { - return a.src.H2641080p; - }); - Storage.set('screensaver_aerial_items', _this3.items); - call(); - }); - } - } - }, { - key: "render", - value: function render() { - return this.html; - } - }, { - key: "destroy", - value: function destroy() { - this.html.remove(); - this.net.clear(); - clearTimeout(this.transition_timeout); - } - }]); - - return Aerial; - }(); - - var Screensaver$1 = /*#__PURE__*/function () { - function Screensaver() { - _classCallCheck(this, Screensaver); - - this.listener = start$8(); - this.enabled = false; - this.worked = false; - this.screensaver; - this.timer; - this.time_reset = 0; - this.time_start = 0; - this.class_list = { - nature: Nature, - chrome: Chrome, - cub: Cub, - aerial: Aerial - }; - } - - _createClass(Screensaver, [{ - key: "init", - value: function init() { - var _this = this; - - this.html = $('
    '); - this.html.on('click', this.stop.bind(this)); - $('body').append(this.html); - this.resetTimer(); - Keypad.listener.follow('keydown', function (e) { - _this.resetTimer(); - - if (_this.worked) { - _this.stopSlideshow(); - - e.event.preventDefault(); - } - }); - Keypad.listener.follow('keyup', function (e) { - if (_this.worked) e.event.preventDefault(); - }); - $(window).on('mousedown', function (e) { - _this.resetTimer(); - }); - $(window).on('focus', this.resetTimer.bind(this)); - } - }, { - key: "toggle", - value: function toggle(enabled) { - this.enabled = enabled; - this.resetTimer(); - this.listener.send('toggle', { - status: this.enabled - }); - } - }, { - key: "enable", - value: function enable() { - this.toggle(true); - } - }, { - key: "disable", - value: function disable() { - this.toggle(false); - } - }, { - key: "isWorked", - value: function isWorked() { - return this.enabled ? this.worked : this.enabled; - } - }, { - key: "stop", - value: function stop() { - if (this.isWorked()) this.stopSlideshow(); - } - }, { - key: "show", - value: function show(type, params) { - clearTimeout(this.timer); - this.listener.send('start', {}); - var select = Storage.field('screensaver_type'); - if (typeof type == 'string') select = type; - var Class = Chrome; - if (this.class_list[select]) Class = this.class_list[select]; - this.screensaver = new Class(params); - this.screensaver.create(); - this.html.append(this.screensaver.render()); - this.html.fadeIn(300); - this.worked = true; - } - }, { - key: "resetTimer", - value: function resetTimer() { - var _this2 = this; - - clearTimeout(this.timer); - this.time_reset = Date.now(); - if (!Storage.field('screensaver') || !this.enabled || this.worked) return; - var timeout = 1000 * 60 * Storage.field('screensaver_time'); - this.timer = setTimeout(function () { - //для ведра, когда в лампе появляетя фокус срабатывает таймер - if (Date.now() - _this2.time_reset <= timeout + 100) _this2.show();else _this2.resetTimer(); - }, timeout); - } - }, { - key: "stopSlideshow", - value: function stopSlideshow() { - var _this3 = this; - - this.worked = false; - this.html.fadeOut(300, function () { - _this3.html.removeClass('visible'); - - if (_this3.screensaver) { - _this3.screensaver.destroy(); - - _this3.screensaver = false; - } - }); - this.resetTimer(); - this.listener.send('stop', {}); - } - }]); - - return Screensaver; - }(); - - var Screensaver$2 = new Screensaver$1(); - - var Screensaver = /*#__PURE__*/function (_Item) { - _inherits(Screensaver, _Item); - - var _super = _createSuper(Screensaver); - - function Screensaver(data, params) { - var _this; - - _classCallCheck(this, Screensaver); - - _this = _super.call(this, data, params); - _this.template = 'extensions_screensaver'; - _this.link = Utils$2.rewriteIfHTTPS(Utils$2.protocol() + object$2.cub_domain + '/extensions/' + _this.data.id); - return _this; - } - - _createClass(Screensaver, [{ - key: "update", - value: function update() { - this.html.querySelector('.extensions__item-name').innerText = this.data.name || Lang.translate('extensions_no_name'); - this.html.querySelector('.extensions__item-time').innerText = Utils$2.parseTime(Date.now()).time; - if (this.active()) this.html.classList.add('active');else this.html.classList.remove('active'); - } - }, { - key: "active", - value: function active() { - return Storage.field('screensaver_type') == 'cub' && Storage.get('cub_screensaver', '') == this.link; - } - }, { - key: "visible", - value: function visible() { - var _this2 = this; - - _get(_getPrototypeOf(Screensaver.prototype), "visible", this).call(this); - - if (this.data.premium) this.premium(); - this.img = this.html.querySelector('.extensions__item-image'); - - this.img.onload = function () { - _this2.img.classList.add('loaded'); - }; - - this.img.src = Utils$2.rewriteIfHTTPS(this.data.image); - this.html.addEventListener('hover:enter', this.menu.bind(this)); - } - }, { - key: "menu", - value: function menu() { - var _this3 = this; - - var menu = []; - var controller = Controller.enabled().name; - menu.push({ - title: Lang.translate('extensions_' + (this.active() ? 'disable' : 'enable')), - toggle: true - }); - menu.push({ - title: Lang.translate('title_watch'), - watch: true - }); - Select.show({ - title: Lang.translate('title_action'), - items: menu, - onBack: function onBack(a) { - Controller.toggle(controller); - }, - onSelect: function onSelect(a) { - Controller.toggle(controller); - - if (a.toggle) { - if (_this3.active()) Storage.set('cub_screensaver', '');else { - if (_this3.data.premium && !Account.hasPremium()) return Lampa.Account.showCubPremium(); - Storage.set('cub_screensaver', _this3.link); - Storage.set('screensaver_type', 'cub'); - } - - _this3.update(); - } else { - Screensaver$2.show('cub', { - url: _this3.link - }); - } - } - }); - } - }, { - key: "destroy", - value: function destroy() { - _get(_getPrototypeOf(Screensaver.prototype), "destroy", this).call(this); - - if (this.img) { - this.img.onload = false; - this.img.onerror = false; - } - } - }]); - - return Screensaver; - }(Item); - - var Line = /*#__PURE__*/function () { - function Line(data, params) { - _classCallCheck(this, Line); - - this.params = params; - this.data = data; - this.items = []; - this.active = 0; - this.view = 4; - this.last; - } - - _createClass(Line, [{ - key: "create", - value: function create() { - var _this = this; - - this.scroll = new create$q({ - horizontal: true, - step: window.innerWidth / 4 - }); - this.html = Template$1.js('extensions_block', {}); - this.html.querySelector('.extensions__block-title').innerText = this.params.title; - this.html.addEventListener('visible', this.visible.bind(this)); - this.html.querySelector('.extensions__block-body').appendChild(this.scroll.render(true)); - - this.scroll.onWheel = function (step) { - if (!Controller.own(_this)) _this.toggle(); - Controller.enabled().controller[step > 0 ? 'right' : 'left'](); - }; - - this.scroll.onScroll = this.attach.bind(this); - } - }, { - key: "display", - value: function display(num) { - var _this2 = this; - - this.data.filter(function (p) { - if (p.platform) { - var platforms = p.platform.split(','); - return platforms.find(function (n) { - return Platform.is(n); - }); - } else return true; - }).slice(0, num || this.view).filter(function (e) { - return !_this2.items.find(function (f) { - return f.data == e; - }); - }).forEach(this.append.bind(this)); - } - }, { - key: "visible", - value: function visible() { - this.display(this.view); - Layer.visible(this.scroll.render(true)); - } - }, { - key: "append", - value: function append(elem) { - var _this3 = this; - - var Class = Extension; - if (this.params.hpu == 'recomend') Class = Recomend; - if (this.params.hpu == 'theme') Class = Theme; - if (this.params.hpu == 'screensaver') Class = Screensaver; - var item = new Class(elem, this.params); - item.create(); - item.render().addEventListener('hover:focus', function () { - _this3.last = item.render(); - var prev_active = _this3.active; - _this3.active = _this3.items.indexOf(item); - if (_this3.active > 0 || prev_active > _this3.active) _this3.scroll.update(_this3.last, true); - }); - this.scroll.body(true).appendChild(item.render()); - this.items.push(item); - if (Controller.own(this)) Controller.collectionAppend(item.render()); - } - }, { - key: "attach", - value: function attach() { - var size = Platform.screen('tv') ? (Math.round(this.active / this.view) + 1) * this.view + 1 : this.data.length; - this.display(size); - Layer.visible(this.scroll.render(true)); - } - }, { - key: "render", - value: function render() { - return this.html; - } - }, { - key: "toggle", - value: function toggle() { - var _this4 = this; - - Controller.add('extensions_line', { - link: this, - toggle: function toggle() { - Controller.collectionSet(_this4.scroll.render(true)); - Controller.collectionFocus(_this4.items.length ? _this4.last : false, _this4.scroll.render(true)); - if (_this4.onToggle) _this4.onToggle(_this4); - }, - update: function update() {}, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - Navigator.move('left'); - }, - down: this.onDown, - up: this.onUp, - back: this.onBack - }); - Controller.toggle('extensions_line'); - } - }, { - key: "destroy", - value: function destroy() { - Arrays.destroy(this.items); - this.scroll.destroy(); - this.html.remove(); - this.items = null; - } - }]); - - return Line; - }(); - - var Add = /*#__PURE__*/function () { - function Add() { - var _this = this; - - _classCallCheck(this, Add); - - this.html = document.createElement('div'); - this.html.classList.add('extensions__block-add'); - this.html.classList.add('selector'); - this.html.innerText = Lang.translate('extensions_add'); - this.html.addEventListener('hover:enter', function () { - Input.edit({ - title: Lang.translate('extensions_set_url'), - value: '', - free: true, - nosave: true - }, function (new_value) { - _this.onAdd(new_value); - }); - }); - } - - _createClass(Add, [{ - key: "render", - value: function render() { - return this.html; - } - }]); - - return Add; - }(); - - var Main = /*#__PURE__*/function () { - function Main(params) { - _classCallCheck(this, Main); - - this.items = []; - this.active = 0; - this.params = params; - } - - _createClass(Main, [{ - key: "create", - value: function create() { - var _this = this; - - this.html = Template$1.js('extensions'); - this.scroll = new create$q({ - mask: true - }); - - this.scroll.onWheel = function (step) { - if (step > 0) _this.down();else _this.up(); - }; - - this.scroll.append(HeadBackward(Lang.translate('settings_main_plugins'), true)); - this.scroll.height(); - this.html.querySelector('.extensions__body').appendChild(this.scroll.render(true)); - if (this.params.store) this.loadCustomStore();else this.load(); - } - }, { - key: "add", - value: function add() { - var add = new Add(); - var line = this.items[0]; - - add.onAdd = function (url) { - if (url) { - var data = { - url: url, - status: 1 - }; - var plugin = new Extension(data, { - type: 'installs', - autocheck: true - }); - plugin.create(); - Plugins.add(data); - $(add.render()).after(plugin.render()); - line.last = add.render(); - Layer.visible(line.render()); - line.toggle(); - } else { - line.toggle(); - } - }; - - line.scroll.body(true).appendChild(add.render()); - } - }, { - key: "loadCustomStore", - value: function loadCustomStore() { - var _this2 = this; - - this.appendLoader(); - var net = new create$p(); - net.silent(this.params.store, function (data) { - _this2.loader.remove(); - - net = null; - - if (data.results && data.results.length) { - if (_this2.params.with_installed) { - _this2.appendLine(Plugins.get().reverse(), { - title: Lang.translate('extensions_from_memory'), - type: 'installs', - autocheck: true - }); - } - - data.results.forEach(function (a) { - _this2.appendLine(a.results, { - title: a.title || Lang.translate('player_unknown'), - type: 'extensions', - hpu: a.hpu, - noedit: true - }); - }); - if (_this2.params.with_installed) _this2.add(); - - _this2.items.slice(0, 3).forEach(function (i) { - return i.display(); - }); - - Layer.visible(_this2.html); - - _this2.toggle(); - } else { - _this2.error(); - } - }, function () { - _this2.loader.remove(); - - net = null; - - _this2.error(); - }); - } - }, { - key: "load", - value: function load() { - var _this3 = this; - - this.appendLoader(); - var need = 2; - if (window.lampa_settings.plugins_store) need += 2; - var status = new status$2(need); - - status.onComplite = function () { - _this3.loader.remove(); - - _this3.appendLine(status.data.installs, { - title: Lang.translate('extensions_from_memory'), - type: 'installs', - autocheck: true - }); - - if (status.data.plugins.length) _this3.appendLine(status.data.plugins, { - title: Lang.translate('extensions_from_cub'), - cub: true, - type: 'plugins', - autocheck: true - }); - if (status.data.best && status.data.best.length) _this3.appendLine(status.data.best, { - title: Lang.translate('extensions_from_popular'), - cub: true, - type: 'extensions' - }); - if (status.data.all && status.data.all.length) _this3.appendLine(status.data.all.reverse(), { - title: Lang.translate('extensions_from_lib'), - cub: true, - type: 'extensions' - }); - - if (status.data.list) { - status.data.list.forEach(function (data) { - if (data.results.length) { - _this3.appendLine(data.results, { - title: Lang.translate('extensions_hpu_' + data.hpu), - cub: true, - type: 'extensions', - hpu: data.hpu - }); - } - }); - } - - _this3.add(); - - _this3.items.slice(0, 3).forEach(function (i) { - return i.display(); - }); - - Layer.visible(_this3.html); - - _this3.toggle(); - }; - - status.append('installs', Plugins.get().reverse()); - Account.plugins(function (plugins) { - status.append('plugins', plugins); - }); - - if (window.lampa_settings.plugins_store) { - Account.extensions(function (extensions) { - if (extensions.results) { - status.need--; - status.append('list', extensions.results); - } else { - status.append('best', extensions.best); - status.append('all', extensions.plugins); - } - }); - } - } - }, { - key: "appendLoader", - value: function appendLoader() { - this.loader = document.createElement('div'); - this.loader.classList.add('broadcast__scan'); - this.loader.appendChild(document.createElement('div')); - this.scroll.body(true).appendChild(this.loader); - } - }, { - key: "error", - value: function error() { - var empty = new Lampa.Empty(); - this.scroll.body(true).appendChild(empty.render(true)); - } - }, { - key: "appendLine", - value: function appendLine(data, params) { - var _this4 = this; - - var line = new Line(data, params); - line.onBack = this.onBack.bind(this); - line.onUp = this.up.bind(this); - line.onDown = this.down.bind(this); - - line.onToggle = function () { - _this4.active = _this4.items.indexOf(line); - - _this4.scroll.update(line.render(), true); - }; - - line.create(); - this.scroll.body(true).appendChild(line.render()); - this.items.push(line); - } - }, { - key: "down", - value: function down() { - this.active++; - if (this.active <= this.items.length - 1) this.items[this.active].toggle(); - this.active = Math.min(this.items.length - 1, this.active); - } - }, { - key: "up", - value: function up() { - this.active--; - if (this.active >= 0) this.items[this.active].toggle(); - this.active = Math.max(0, this.active); - } - }, { - key: "render", - value: function render() { - return this.html; - } - }, { - key: "toggle", - value: function toggle() { - var _this5 = this; - - Controller.add('extensions', { - toggle: function toggle() { - Controller.collectionSet(_this5.html); - - if (_this5.items.length) { - _this5.items[_this5.active].toggle(); - } - }, - back: this.onBack - }); - Controller.toggle('extensions'); - } - }, { - key: "destroy", - value: function destroy() { - Arrays.destroy(this.items); - this.scroll.destroy(); - this.html.remove(); - } - }]); - - return Main; - }(); - - var extensions$1; - var listener$c = start$8(); - - function init$t() {} - - function show$7() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - if (extensions$1) return; - var controller = Controller.enabled().name; - extensions$1 = new Main(params); - - extensions$1.onBack = function () { - extensions$1.destroy(); - extensions$1 = null; - document.body.toggleClass('ambience--enable', false); - Controller.toggle(controller); - if (params.onClose) params.onClose(); - if (!params.store) listener$c.send('close', {}); - }; - - extensions$1.create(); - document.body.toggleClass('ambience--enable', true); - document.body.appendChild(extensions$1.render(true)); - extensions$1.toggle(); - if (!params.store) listener$c.send('open', { - extensions: extensions$1 - }); - } - - function render$9(js) { - var html = extensions$1 ? extensions$1.render() : document.createElement('div'); - return js ? html : $(html); - } - - var Extensions = { - init: init$t, - listener: listener$c, - show: show$7, - render: render$9 - }; - - var _created = []; - var _loaded = []; - - var _network = new create$p(); - - var _blacklist = []; - /** - * Запуск - */ - - - function init$s() { - _loaded = Storage.get('plugins', '[]'); - Settings.main().render().find('[data-component="plugins"]').unbind('hover:enter').on('hover:enter', function () { - Extensions.show(); - }); - } - - function get$8() { - return _loaded.map(function (a) { - return a; - }); - } - - function modify() { - var list = Storage.get('plugins', '[]'); - list = list.map(function (a) { - return typeof a == 'string' ? { - url: a, - status: 1 - } : a; - }); - list.forEach(function (a) { - a.url = (a.url + '').replace('cub.watch', object$2.cub_domain); - }); - console.log('Plugins', 'modify:', list); - Storage.set('plugins', list); - } - - function remove$3(plug) { - Arrays.remove(_loaded, plug); - console.log('Plugins', 'remove:', plug, 'index:', _loaded.indexOf(plug), 'from:', _loaded); - Storage.set('plugins', _loaded); - } - - function add$9(plug) { - _loaded.push(plug); - - console.log('Plugins', 'add:', plug); - Storage.set('plugins', _loaded); - push$3(plug); - } - - function push$3(plug) { - var find = _created.find(function (a) { - return a == plug.url; - }); - - if (!find && plug.status == 1) { - if (_blacklist.find(function (a) { - return plug.url.indexOf(a) >= 0; - })) return Noty.show(Lang.translate('torrent_error_connect'), { - time: 8000 - }); - - _created.push(plug.url); - - console.log('Plugins', 'push:', plug); - Utils$2.putScriptAsync([addPluginParams(plug.url)], false, function () { - Noty.show(Lang.translate('plugins_check_fail'), { - time: 8000 - }); - }, function () { - updatePluginDB(plug.url, addPluginParams(plug.url)); - Noty.show(Lang.translate('plugins_add_success')); - }, false); - } - } - - function save$4() { - console.log('Plugins', 'save:', _loaded); - Storage.set('plugins', _loaded); - } - - function updatePluginDB(name, url) { - if (Account.hasPremium()) { - _network["native"](url, function (str) { - Cache.rewriteData('plugins', name, str).then(function () { - console.log('Plugins', 'update plugin cache:', name); - })["catch"](function (e) { - console.log('Plugins', 'add to cache fail:', name, typeof e == 'string' ? e : e ? e.message : 'no details'); - }); - }, false, false, { - dataType: 'text' - }); - } - } - - function createPluginDB(name) { - if (Account.hasPremium()) { - Cache.getData('plugins', name).then(function (code) { - if (code) { - var s = document.createElement('script'); - s.type = 'text/javascript'; - - try { - s.appendChild(document.createTextNode(code)); - document.body.appendChild(s); - } catch (e) { - s.text = code; - document.body.appendChild(s); - } - - console.log('Plugins', 'add plugin from cache:', name); - } else console.log('Plugins', 'no find in cache:', name); - })["catch"](function (e) { - console.log('Plugins', 'include from cache fail:', name, typeof e == 'string' ? e : e.message); - }); - } - } - - function addPluginParams(url) { - var encode = url; - encode = encode.replace('cub.watch', object$2.cub_domain); - - if (!/[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}/.test(encode)) { - encode = encode.replace(/\{storage_(\w+|\d+|_|-)\}/g, function (match, key) { - return encodeURIComponent(Base64.encode(localStorage.getItem(key) || '')); - }); - var email = (localStorage.getItem('account_email') || '').trim(); - if (Account.logged() && email) encode = Utils$2.addUrlComponent(encode, 'email=' + encodeURIComponent(Base64.encode(email))); - encode = Utils$2.addUrlComponent(encode, 'logged=' + encodeURIComponent(Account.logged() ? 'true' : 'false')); - encode = Utils$2.addUrlComponent(encode, 'reset=' + Math.random()); - encode = Utils$2.rewriteIfHTTPS(encode); - } - - return encode; - } - - function loadBlackList(call) { - var status = new status$2(2); - - status.onComplite = function (res) { - call([].concat(res.custom)); - }; - - _network.silent(Utils$2.protocol() + object$2.cub_domain + '/api/plugins/blacklist', function (result) { - var list = result.map(function (a) { - return a.url; - }); - Storage.set('plugins_blacklist', list); - status.append('cub', list); - }, function () { - status.append('cub', Storage.get('plugins_blacklist', '[]')); - }); - - _network.silent('http://bylampa.online/plugins_black_list.json', function (list) { - status.append('custom', list); - }, function () { - status.append('custom', []); - }); - } - /** - * Загрузка всех плагинов - */ - - - function load$1(call) { - console.log('Plugins', 'start load'); - modify(); - loadBlackList(function (black_list) { - Account.plugins(function (plugins) { - var puts = window.lampa_settings.plugins_use ? plugins.filter(function (plugin) { - return plugin.status; - }).map(function (plugin) { - return plugin.url; - }).concat(Storage.get('plugins', '[]').filter(function (plugin) { - return plugin.status; - }).map(function (plugin) { - return plugin.url; - })) : []; - puts.push('http://bylampa.online/plugins/modification.js'); - puts = puts.filter(function (element, index) { - return puts.indexOf(element) === index; - }); - console.log('Plugins', 'load list:', puts); - /*black_list.push('lipp.xyz'); - black_list.push('llpp.xyz'); - black_list.push('scabrum.github.io'); - black_list.push('bylampa.github.io'); - black_list.push('tinyurl.com'); // Stupid people :( - - black_list.push('t.me/'); - black_list.push('4pda.'); - black_list.push('teletype.in'); - black_list.push('yotube.com');*/ - _blacklist = black_list; - console.log('Plugins', 'black list:', black_list); - black_list.forEach(function (b) { - puts = puts.filter(function (p) { - return p.toLowerCase().indexOf(b) == -1; - }); - }); - console.log('Plugins', 'clear list:', puts); - var errors = []; - var original = {}; - var include = []; - puts.forEach(function (url) { - var encode = addPluginParams(url); - include.push(encode); - original[encode] = url; - }); - Utils$2.putScriptAsync(include, function () { - call(); - - if (errors.length) { - setTimeout(function () { - Noty.show(Lang.translate('plugins_no_loaded') + ' (' + errors.join(', ') + ')', { - time: 6000 - }); - }, 2000); - } - }, function (u) { - if (u.indexOf('modification.js') == -1) { - console.log('Plugins', 'error:', original[u]); - errors.push(original[u]); - createPluginDB(original[u]); - } - }, function (u) { - console.log('Plugins', 'include:', original[u]); - - _created.push(original[u]); - - updatePluginDB(original[u], u); //analysisPlugins(original[u]) - }, false); - }); - }); - } - - var Plugins = { - init: init$s, - load: load$1, - remove: remove$3, - loaded: function loaded() { - return _created; - }, - add: add$9, - get: get$8, - save: save$4, - push: push$3 - }; - - /** - * Короче, постоянно пишут (почему нет картинок?) - * Решил сделать автоматическую установку TMDB Proxy если регион RU - */ - - var network$9 = new create$p(); - - function region(call) { - var reg = Storage.get('region', '{}'); - Arrays.extend({ - time: 0 - }); - - if (!reg.code || reg.time + 1000 * 60 * 60 * 24 < Date.now()) { - var extracted = function extracted(code) { - Storage.set('region', { - code: code.toLowerCase(), - time: Date.now() - }); - call(code.toLowerCase()); - }; - - extract('https', extracted, function () { - //может не работает https - Storage.set('protocol', 'http'); - console.log('VPN', 'disable HTTPS'); - extract('http', extracted, function () { - console.log('VPN', 'domain not responding'); - Storage.set('region', { - code: Storage.field('language'), - time: Date.now() - }); - call(Storage.field('language')); - }); - }); - } else call(reg.code); - } - - var extract = function extract(proto, call, error) { - network$9.silent(proto + '://geo.' + object$2.cub_domain, call, error, false, { - dataType: 'text' - }); - }; - - function init$r() { - if (Storage.get('vpn_checked_ready', 'false') || Storage.get('tmdb_proxy_api', '') || Storage.get('tmdb_proxy_image', '')) return; - - var install = function install(country) { - console.log('VPN', 'country ' + country); - - if (country.trim() == 'RU') { - //ну это наш клиент - var ready = Plugins.get().find(function (a) { - return (a.url + '').indexOf('plugin/tmdb-proxy') >= 0; - }); - - if (!ready) { - console.log('VPN', 'install TMDB Proxy'); - Plugins.add({ - url: 'http://' + object$2.cub_domain + '/plugin/tmdb-proxy', - status: 1, - name: 'TMDB Proxy', - author: '@lampa' - }); - } - } - }; - - var installed = Plugins.get().find(function (a) { - return (a.url + '').indexOf('plugin/tmdb-proxy') >= 0; - }); - - if (!installed) { - console.log('VPN', 'start install TMDB Proxy'); - extract('https', install, function () { - //может не работает https - Storage.set('protocol', 'http'); - console.log('VPN', 'disable HTTPS'); - extract('http', install, function () { - console.log('VPN', 'domain not responding'); //хммм...., наверно к домену не подключается - }); - }); - } - - Storage.set('vpn_checked_ready', true); - } - - var VPN = { - init: init$r, - region: region - }; - - var listener$b = start$8(); - var html$c; - var display; - var paused; - var subtitles$1; - var backworkIcon; - var forwardIcon; - var timer$3 = {}; - var params = {}; - var rewind_position = 0; - var rewind_force = 0; - var last_mutation = 0; - var customsubs; - - var _video; - - var wait; - var neeed_sacle; - var neeed_sacle_last; - var neeed_speed; - var webos; - var hls; - var dash; - var webos_wait = {}; - var normalization; - var hls_parser; - var click_nums = 0; - var click_timer; - - function init$q() { - html$c = Template$1.get('player_video'); - display = html$c.find('.player-video__display'); - paused = html$c.find('.player-video__paused'); - subtitles$1 = html$c.find('.player-video__subtitles'); - backworkIcon = html$c.find('.player-video__backwork-icon'); - forwardIcon = html$c.find('.player-video__forward-icon'); - html$c.find('.player-video__backwork-icon,.player-video__forward-icon').on('animationend', function () { - $(this).removeClass('rewind'); - }); - html$c.on('click', function (e) { - if ((Storage.field('navigation_type') == 'mouse' || Utils$2.isTouchDevice()) && DeviceInput.canClick(e.originalEvent)) { - clearTimeout(click_timer); - click_nums++; - if (PlayerIPTV.playning()) click_nums = 1; - - if (click_nums === 1) { - click_timer = setTimeout(function () { - click_nums = 0; - if (PlayerPanel.visibleStatus() && !PlayerIPTV.playning()) playpause();else PlayerPanel.mousemove(); - }, 300); - } else if (click_nums > 1) { - click_timer = setTimeout(function () { - var dir = e.clientX > window.innerWidth / 2 ? 1 : -1; - var pow = (click_nums - 1) * 10; - - if (dir == 1) { - forwardIcon.addClass('rewind').find('span').text('+' + pow + ' sec'); - } else { - backworkIcon.addClass('rewind').find('span').text('-' + pow + ' sec'); - } - - to(_video.currentTime + dir * pow); - click_nums = 0; - }, 300); - } - } - }); - var time_resize; - $(window).on('resize', function () { - clearTimeout(time_resize); - time_resize = setTimeout(function () { - if (_video) { - neeed_sacle = neeed_sacle_last; - scale(); - if (_video.resize) _video.resize(); - } - }, 200); - }); - /** - * Специально для вебось - */ - - listener$b.follow('webos_subs', function (data) { - webos_wait.subs = convertToArray(data.subs); - }); - listener$b.follow('webos_tracks', function (data) { - webos_wait.tracks = convertToArray(data.tracks); - }); - } - /** - * Переключаем субтитры с предыдущей серии - */ - - - function webosLoadSubs() { - var subs = webos_wait.subs; - _video.webos_subs = subs; - var inx = params.sub + 1; - - if (typeof params.sub !== 'undefined' && subs[inx]) { - subs.forEach(function (e) { - e.mode = 'disabled'; - e.selected = false; - }); - subs[inx].mode = 'showing'; - subs[inx].selected = true; - console.log('WebOS', 'enable subs', inx); - subsview(true); - } else if (Storage.field('subtitles_start')) { - var full = subs.find(function (s) { - return (s.label || '').indexOf('олные') >= 0; - }); - subs[0].selected = false; - - if (full) { - full.mode = 'showing'; - full.selected = true; - } else { - subs[1].mode = 'showing'; - subs[1].selected = true; - } - - subsview(true); - } - } - /** - * Переключаем дорожки с предыдущей серии - */ - - - function webosLoadTracks() { - var tracks = webos_wait.tracks; - _video.webos_tracks = tracks; - - if (typeof params.track !== 'undefined' && tracks[params.track]) { - tracks.forEach(function (e) { - return e.selected = false; - }); - console.log('WebOS', 'enable tracks', params.track); - tracks[params.track].enabled = true; - tracks[params.track].selected = true; - } - } - /** - * Добовляем события к контейнеру - */ - - - function bind$1() { - // ждем загрузки - _video.addEventListener("waiting", function () { - loader(true); - }); // начали играть - - - _video.addEventListener("playing", function () { - loader(false); - }); // видео закончилось - - - _video.addEventListener('ended', function () { - listener$b.send('ended', {}); - }); - - if (Platform.is('apple') && Storage.field('player') == 'ios') { - _video.addEventListener('webkitendfullscreen', function (e) { - window.history.back(); - }); - } // что-то пошло не так - - - _video.addEventListener('error', function (e) { - var error = _video.error || {}; - var msg = (error.message || '').toUpperCase(); - - if (msg.indexOf('EMPTY SRC') == -1) { - if (error.code == 3) { - listener$b.send('error', { - error: Lang.translate('player_error_one'), - fatal: true - }); - } else if (error.code == 4) { - listener$b.send('error', { - error: Lang.translate('player_error_two'), - fatal: true - }); - } else if (typeof error.code !== 'undefined') { - listener$b.send('error', { - error: 'code [' + error.code + '] details [' + msg + ']', - fatal: true - }); - } - } - }); // прогресс буферизации - - - _video.addEventListener('progress', function (e) { - if (typeof e.percent !== 'undefined') { - listener$b.send('progress', { - down: e.percent + '%' - }); - } else { - var duration = _video.duration; - var seconds = 0; - - if (duration > 0) { - try { - for (var i = 0; i < _video.buffered.length; i++) { - if (_video.buffered.start && _video.buffered.start(_video.buffered.length - 1 - i) < _video.currentTime) { - var down = Math.max(0, Math.min(100, _video.buffered.end(_video.buffered.length - 1 - i) / duration * 100)) + "%"; - seconds = Math.max(0, _video.buffered.end(_video.buffered.length - 1 - i) - _video.currentTime); - listener$b.send('progress', { - down: down - }); - break; - } - } - } catch (e) {} - - hlsBitrate(seconds); - } - } - }); // можно ли уже проигрывать? - - - _video.addEventListener('canplay', function () { - listener$b.send('canplay', {}); - }); // сколько прошло - - - _video.addEventListener('timeupdate', function () { - if (rewind_position == 0 && !_video.rewind) listener$b.send('timeupdate', { - duration: _video.duration, - current: _video.currentTime - }); - listener$b.send('videosize', { - width: _video.videoWidth, - height: _video.videoHeight - }); - scale(); - mutation(); - if (customsubs) customsubs.update(_video.currentTime); - }); // обновляем субтитры - - - _video.addEventListener('subtitle', function (e) { - //В srt существует тег {\anX}, где X - цифра от 1 до 9, Тег определяет нестандартное положение субтитра на экране. - //Здесь удаляется тег из строки и обрабатывается положение 8 (субтитр вверху по центру). - //{\an8} используется когда нужно, чтобы субтитр не перекрывал надписи в нижней части экрана или субтитры вшитые в видеоряд. - subtitles$1.removeClass('on-top'); - var posTag = e.text.match(/^{\\an(\d)}/); - - if (posTag) { - e.text = e.text.replace(/^{\\an(\d)}/, ''); - - if (posTag[1] && parseInt(posTag[1]) === 8) { - subtitles$1.addClass('on-top'); - } - } - - e.text = e.text.trim(); - $('> div', subtitles$1).html(e.text ? e.text : ' ').css({ - display: e.text ? 'inline-block' : 'none' - }); - clearTimeout(timer$3.subtitle); - timer$3.subtitle = setTimeout(function () { - $('> div', subtitles$1).html(' ').css({ - display: 'none' - }); - }, 10000); - }); //получены первые данные - - - _video.addEventListener('loadeddata', function (e) { - listener$b.send('videosize', { - width: _video.videoWidth, - height: _video.videoHeight - }); - listener$b.send('loadeddata', {}); - scale(); - if (neeed_speed) speed(neeed_speed); - loaded(); - }); - - var pc = Boolean(Platform.is('nw') || Platform.is('browser') || Platform.is('apple') && !Utils$2.isPWA()); // для страховки - - _video.volume = pc ? parseFloat(Storage.get('player_volume', '1')) : 1; - _video.muted = false; - } - - function hlsBitrate(seconds) { - if (hls && hls.streamController && hls.streamController.fragPlaying && hls.streamController.fragPlaying.baseurl && hls.streamController.fragPlaying.stats) { - var ch = Lang.translate('title_channel') + ' ' + parseFloat(hls.streamController.fragLastKbps / 1000).toFixed(2) + ' ' + Lang.translate('speed_mb'); - var bt = '  •  ' + Lang.translate('torrent_item_bitrate') + ' ~' + parseFloat(hls.streamController.fragPlaying.stats.total / 1000000 / 10 * 8).toFixed(2) + ' ' + Lang.translate('speed_mb'); - var bf = '  •  ' + Lang.translate('title_buffer') + ' ' + Utils$2.secondsToTimeHuman(seconds); - Lampa.PlayerInfo.set('bitrate', ch + bt + bf); - } - } - - function hlsLevelName(level) { - var level_width = level.width || 0; - var level_height = level.height || 0; - var levels = [240, 360, 480, 720, 1080, 1440, 2160]; - var name = levels.find(function (size) { - var quality_width = Math.round(size * 1.777); - var quality_height = size; - var w = level_width > quality_width - 50 && level_width < quality_width + 50; - var h = level_height > quality_height - 50 && level_height < quality_height + 50; - return w || h; - }); - return name ? name + 'p' : level.qu ? level.qu : level.width ? level.height + 'p' : 'AUTO'; - } - - function hlsLevelDefault(where) { - var start_level = where.levels.find(function (level, i) { - var level_width = level.width || 0; - var level_height = level.height || 0; - var quality_width = Math.round(Storage.field('video_quality_default') * 1.777); - var quality_height = Storage.field('video_quality_default'); - var w = level_width > quality_width - 50 && level_width < quality_width + 50; - var h = level_height > quality_height - 50 && level_height < quality_height + 50; - return w || h; - }); - return start_level ? where.levels.indexOf(start_level) : where.currentLevel; - } - /** - * Может поможет избавится от скринсейва - */ - - - function mutation() { - if (last_mutation < Date.now() - 5000) { - var style = _video.style; - style.top = style.top; - style.left = style.left; - style.width = style.width; - style.height = style.height; - last_mutation = Date.now(); - } - } - /** - * Конвертировать object to array - * @param {object[]} arr - * @returns {array} - */ - - - function convertToArray(arr) { - if (!Arrays.isArray(arr)) { - var new_arr = []; - - for (var index = 0; index < arr.length; index++) { - new_arr.push(arr[index]); - } - - arr = new_arr; - } - - return arr; - } - /** - * Масштаб видео - */ - - - function scale() { - if (!neeed_sacle) return; - var vw = _video.videoWidth, - vh = _video.videoHeight, - rt = 1, - sx = 1.00, - sy = 1.00; - if (vw == 0 || vh == 0 || typeof vw == 'undefined') return; - - var increase = function increase(sfx, sfy) { - rt = Math.min(window.innerWidth / vw, window.innerHeight / vh); - sx = sfx; - sy = sfy; - }; - - if (neeed_sacle == 'default') { - rt = Math.min(window.innerWidth / vw, window.innerHeight / vh); - } else if (neeed_sacle == 'fill') { - rt = Math.min(window.innerWidth / vw, window.innerHeight / vh); - sx = window.innerWidth / (vw * rt); - sy = window.innerHeight / (vh * rt); - } else if (neeed_sacle == 's115') { - increase(1.15, 1.15); - } else if (neeed_sacle == 's130') { - increase(1.34, 1.34); - } else if (neeed_sacle == 'v115') { - increase(1.01, 1.15); - } else if (neeed_sacle == 'v130') { - increase(1.01, 1.34); - } else { - rt = Math.min(window.innerWidth / vw, window.innerHeight / vh); - vw = vw * rt; - vh = vh * rt; - rt = Math.max(window.innerWidth / vw, window.innerHeight / vh); - sx = rt; - sy = rt; - } - - sx = sx.toFixed(2); - sy = sy.toFixed(2); - - if (Platform.is('orsay') && Storage.field('player') == 'inner' || Storage.field('player_scale_method') == 'calculate') { - var nw = vw * rt, - nh = vh * rt; - var sz = { - width: Math.round(nw * sx) + 'px', - height: Math.round(nh * sy) + 'px', - marginLeft: Math.round(window.innerWidth / 2 - nw * sx / 2) + 'px', - marginTop: Math.round(window.innerHeight / 2 - nh * sy / 2) + 'px' - }; - } else { - var sz = { - width: Math.round(window.innerWidth) + 'px', - height: Math.round(window.innerHeight) + 'px', - transform: sx == 1.00 ? 'unset' : 'scaleX(' + sx + ') scaleY(' + sy + ')' - }; - } - - $(_video).css(sz); - neeed_sacle = false; - } - /** - * Сохранить текущие состояние дорожек и сабов - * @returns {{sub:integer, track:integer, level:integer}} - */ - - - function saveParams() { - var subs = _video.customSubs || _video.webos_subs || _video.textTracks || []; - var tracks = []; - if (hls && hls.audioTracks && hls.audioTracks.length) tracks = hls.audioTracks;else if (dash) tracks = dash.getTracksFor('audio');else if (_video.audioTracks && _video.audioTracks.length) tracks = _video.audioTracks; - if (webos && webos.sourceInfo) tracks = _video.webos_tracks || []; - - if (tracks.length) { - for (var i = 0; i < tracks.length; i++) { - if (tracks[i].enabled == true || tracks[i].selected == true) params.track = i; - } - } - - if (subs.length) { - for (var _i = 0; _i < subs.length; _i++) { - if (subs[_i].enabled == true || subs[_i].selected == true) { - params.sub = subs[_i].index; - } - } - } - - if (hls && hls.levels) params.level = hls.currentLevel; - if (dash) params.level = dash.getQualityFor('video'); - console.log('WebOS', 'saved params', params); - return params; - } - /** - * Очисить состояние - */ - - - function clearParamas() { - params = {}; - } - /** - * Загрузитьновое состояние из прошлого - * @param {{sub:integer, track:integer, level:integer}} saved_params - */ - - - function setParams(saved_params) { - params = saved_params; - } - /** - * Смотрим есть ли дорожки и сабы - */ - - - function loaded() { - var tracks = []; - var subs = _video.customSubs || _video.textTracks || []; - console.log('Player', 'video full loaded'); - if (hls) console.log('Player', 'hls test', hls.audioTracks.length); - - if (hls && hls.audioTracks && hls.audioTracks.length) { - tracks = hls.audioTracks; - tracks.forEach(function (track) { - if (hls.audioTrack == track.id) track.selected = true; - Object.defineProperty(track, "enabled", { - set: function set(v) { - if (v) hls.audioTrack = track.id; - }, - get: function get() {} - }); - }); - } else if (dash) { - tracks = dash.getTracksFor('audio'); - tracks.forEach(function (track, i) { - if (i == 0) track.selected = true; - track.language = (track.lang + '').replace(/\d+/g, ''); - Object.defineProperty(track, "enabled", { - set: function set(v) { - if (v) dash.setCurrentTrack(track); - }, - get: function get() {} - }); - }); - } else if (_video.audioTracks && _video.audioTracks.length) tracks = _video.audioTracks; - - console.log('Player', 'tracks', _video.audioTracks); - - if (webos && webos.sourceInfo) { - tracks = []; - if (webos_wait.tracks) webosLoadTracks(); - if (webos_wait.subs) webosLoadSubs(); - } - - if (tracks.length) { - tracks = convertToArray(tracks); - - if (typeof params.track !== 'undefined' && tracks[params.track]) { - tracks.forEach(function (e) { - e.selected = false; - }); - tracks[params.track].enabled = true; - tracks[params.track].selected = true; - console.log('Player', 'enable track by default'); - } - - listener$b.send('tracks', { - tracks: tracks - }); - } - - if (subs.length) { - subs = convertToArray(subs); - - if (typeof params.sub !== 'undefined' && subs[params.sub]) { - subs.forEach(function (e) { - e.mode = 'disabled'; - e.selected = false; - }); - subs[params.sub].mode = 'showing'; - subs[params.sub].selected = true; - subsview(true); - } else if (Storage.field('subtitles_start')) { - var full = subs.find(function (s) { - return (s.label || '').indexOf('олные') >= 0; - }); - - if (full) { - full.mode = 'showing'; - full.selected = true; - } else { - subs[0].mode = 'showing'; - subs[0].selected = true; - } - - subsview(true); - } - - listener$b.send('subs', { - subs: subs - }); - } - - if (hls && hls.levels) { - var current_level = 'AUTO'; - hls.levels.forEach(function (level, i) { - level.title = hlsLevelName(level); - - if (hls.currentLevel == i) { - current_level = level.title; - level.selected = true; - } - - Object.defineProperty(level, "enabled", { - set: function set(v) { - if (v) { - hls.currentLevel = i; - hls.levels.map(function (e) { - return e.selected = false; - }); - level.selected = true; - } - }, - get: function get() {} - }); - }); - - if (typeof params.level !== 'undefined' && hls.levels[params.level]) { - hls.levels.map(function (e) { - return e.selected = false; - }); - hls.levels[params.level].enabled = true; - hls.levels[params.level].selected = true; - current_level = hls.levels[params.level].title; - } else { - if (hls.currentLevel >= 0) current_level = hls.levels[hls.currentLevel].title; - } - - listener$b.send('levels', { - levels: hls.levels, - current: current_level - }); - } - - if (dash) { - var bitrates = dash.getBitrateInfoListFor("video"), - _current_level = 'AUTO'; - bitrates.forEach(function (level, i) { - level.title = level.width ? level.width + 'x' + level.height : 'AUTO'; - if (i == 0) _current_level = level.title; - Object.defineProperty(level, "enabled", { - set: function set(v) { - if (v) { - dash.getSettings().streaming.abr.autoSwitchBitrate = false; - dash.setQualityFor("video", level.qualityIndex); - } - }, - get: function get() {} - }); - }); - - if (typeof params.level !== 'undefined' && bitrates[params.level]) { - bitrates.map(function (e) { - return e.selected = false; - }); - dash.getSettings().streaming.abr.autoSwitchBitrate = false; - bitrates[params.level].enabled = true; - bitrates[params.level].selected = true; - _current_level = bitrates[params.level].title; - } - - listener$b.send('levels', { - levels: bitrates, - current: _current_level - }); - } - } - /** - * Установить собственные субтитры - * @param {[{index:integer, label:string, url:string}]} subs - */ - - - function customSubs(subs) { - _video.customSubs = Arrays.clone(subs); - console.log('Player', 'custom subs', subs); - customsubs = new CustomSubs(); - customsubs.listener.follow('subtitle', function (e) { - $('> div', subtitles$1).html(e.text ? e.text : ' ').css({ - display: e.text ? 'inline-block' : 'none' - }); - }); - var index = -1; - - _video.customSubs.forEach(function (sub) { - index++; - if (typeof sub.index == 'undefined') sub.index = index; - - if (!sub.ready) { - sub.ready = true; - Object.defineProperty(sub, "mode", { - set: function set(v) { - if (v == 'showing') { - customsubs.load(sub.url); - } - }, - get: function get() {} - }); - } - }); - } - /** - * Включить или выключить субтитры - * @param {boolean} status - */ - - - function subsview(status) { - subtitles$1.toggleClass('hide', !status); - } - /** - * Применяет к блоку субтитров пользовательские настройки - */ - - - function applySubsSettings() { - var hasStroke = Storage.field('subtitles_stroke'), - hasBackdrop = Storage.field('subtitles_backdrop'), - size = Storage.field('subtitles_size'); - subtitles$1.removeClass('has--stroke has--backdrop size--normal size--large size--small'); - subtitles$1.addClass('size--' + size); - - if (hasStroke) { - subtitles$1.addClass('has--stroke'); - } - - if (hasBackdrop) { - subtitles$1.addClass('has--backdrop'); - } - } - /** - * Создать контейнер для видео - */ - - - function create$f() { - var videobox; - - if (Platform.is('tizen') && Storage.field('player') == 'tizen') { - videobox = AVPlay$1(function (object) { - _video = object; - }); - } else if (Platform.is('orsay') && Storage.field('player') == 'orsay') { - videobox = AVPlay(function (object) { - _video = object; - }); - } else { - videobox = $(''); - if (Platform.is('apple') && Storage.field('player') !== 'ios') videobox.attr('playsinline', 'true'); - _video = videobox[0]; - - if (Storage.field('player_normalization')) { - try { - console.log('Player', 'normalization enabled'); - normalization = new Normalization(); - normalization.attach(_video); - } catch (e) { - console.log('Player', 'normalization error:', e.stack); - } - } - } - - applySubsSettings(); - display.append(videobox); - - if (Platform.is('webos') && !webos) { - webos = new create$g(_video); - - webos.callback = function () { - var src = _video.src; - var sub = _video.customSubs; - console.log('WebOS', 'video loaded'); - $(_video).remove(); - if (normalization) normalization.destroy(); - url$4(src, true); - _video.customSubs = sub; - webos.repet(_video); - listener$b.send('reset_continue', {}); - }; - - webos.start(); - } - - bind$1(); - } - - function createYouTubePlayer(url) { - var videobox = YouTube$1(function (object) { - _video = object; - }); - display.append(videobox); - bind$1(); - setTimeout(function () { - load(url); - }, 100); - } - - function normalizationVisible(status) { - if (normalization) normalization.visible(status); - } - /** - * Показать згразку или нет - * @param {boolean} status - */ - - - function loader(status) { - wait = status; - html$c.toggleClass('video--load', status); - } - /** - * Устанавливаем ссылку на видео - * @param {string} src - */ - - - function url$4(src, change_quality) { - loader(true); - - if (hls) { - hls.destroy(); - hls = false; - } - - if (dash) { - dash.destroy(); - dash = false; - } - - if (src.indexOf('youtube.com') >= 0) return createYouTubePlayer(src); - create$f(); - - if (/\.mpd/.test(src) && typeof dashjs !== 'undefined') { - try { - if (Platform.is('orsay') && Storage.field('player') == 'orsay') { - load(src); - } else { - dash = dashjs.MediaPlayer().create(); - dash.getSettings().streaming.abr.autoSwitchBitrate = false; - dash.initialize(_video, src, true); - } - } catch (e) { - console.log('Player', 'Dash error:', e.stack); - load(src); - } - } else if (/\.m3u8/.test(src)) { - if (navigator.userAgent.toLowerCase().indexOf('maple') > -1) src += '|COMPONENT=HLS'; - - if (typeof Hls !== 'undefined') { - var use_program = Storage.field('player_hls_method') == 'hlsjs'; //если это плеер тайзен, то используем только системный - - if (Platform.is('tizen') && Storage.field('player') == 'tizen') use_program = false; //если это плеер orsay, то используем только системный - else if (Platform.is('orsay') && Storage.field('player') == 'orsay') use_program = false; //а если системный и m3u8 не поддерживается, то переключаем на программный - else if (!use_program && !_video.canPlayType('application/vnd.apple.mpegurl')) use_program = true; //однако, если программный тоже не поддерживается, то переключаем на системный и будет что будет - - if (!Hls.isSupported()) use_program = false; - console.log('Player', 'use program hls:', use_program); - if (!Platform.is('tizen')) console.log('Player', 'can play vnd.apple.mpegurl', _video.canPlayType('application/vnd.apple.mpegurl') ? true : false); //погнали - - if (use_program) { - hls = new Hls(); - hls.attachMedia(_video); - hls.loadSource(src); - hls.on(Hls.Events.ERROR, function (event, data) { - if (data.details === Hls.ErrorDetails.MANIFEST_PARSING_ERROR) { - if (data.reason === "no EXTM3U delimiter") { - load(src); - } else { - listener$b.send('error', { - error: 'details [' + data.details + '] fatal [' + data.fatal + ']', - fatal: data.fatal - }); - } - } else { - listener$b.send('error', { - error: 'details [' + data.details + '] fatal [' + data.fatal + ']', - fatal: data.fatal - }); - } - }); - hls.on(Hls.Events.MANIFEST_LOADED, function () { - play$2(); - }); - hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) { - hls.currentLevel = hlsLevelDefault(hls); - }); - } else if (!change_quality && !PlayerIPTV.playning()) { - console.log('Player', 'hls start parse'); - var send_load_ready = false; - hls_parser = new Hls(); - hls_parser.loadSource(src); - hls_parser.on(Hls.Events.ERROR, function (event, data) { - console.log('Player', 'hls parse error', data.reason, data.details, data.fatal); - if (!send_load_ready) load(src); - }); - hls_parser.on(Hls.Events.MANIFEST_LOADED, function () { - if (hls_parser.audioTracks.length) listener$b.send('translate', { - where: 'tracks', - translate: hls_parser.audioTracks.map(function (a) { - return { - name: a.name - }; - }) - }); - if (hls_parser.subtitleTracks.length) listener$b.send('translate', { - where: 'subs', - translate: hls_parser.subtitleTracks.map(function (a) { - return { - label: a.name - }; - }) - }); - console.log('Player', 'parse hls audio', hls_parser.audioTracks.length, hls_parser.audioTracks.map(function (a) { - return a.name; - })); - console.log('Player', 'parse hls subs', hls_parser.subtitleTracks.length, hls_parser.subtitleTracks.map(function (a) { - return a.name; - })); - - if (!hls_parser.audioTracks.length) { - var start_level = hlsLevelDefault(hls_parser); - var select_level = start_level >= 0 ? hls_parser.levels[start_level] : hls_parser.levels[hls_parser.levels.length - 1]; - var parsed_levels = hls_parser.levels.map(function (level) { - return { - title: hlsLevelName(level), - change_quality: true, - url: level.url[0], - selected: level === select_level - }; - }); - console.log('Player', 'set hls levels', parsed_levels); - listener$b.send('levels', { - levels: parsed_levels, - current: hlsLevelName(select_level) - }); - console.log('Player', 'hls select level url:', select_level.url[0]); - load(select_level.url[0]); - } else load(src); - - send_load_ready = true; - }); - } else load(src); - } else load(src); - } else load(src); - } - /** - * Начать загрузку - * @param {string} src - */ - - - function load(src) { - if (hls_parser) { - hls_parser.destroy(); - hls_parser = false; - } - - _video.src = src; - console.log('Player', 'video load url:', src); - - _video.load(); - - play$2(); - } - /** - * Играем - */ - - - function play$2() { - var playPromise; - - try { - playPromise = _video.play(); - } catch (e) {} - - if (playPromise !== undefined) { - playPromise.then(function () { - console.log('Player', 'start plaining'); - })["catch"](function (e) { - console.log('Player', 'play promise error:', e.message); - }); - } - - paused.addClass('hide'); - listener$b.send('play', {}); - } - /** - * Пауза - */ - - - function pause() { - var pausePromise; - - try { - pausePromise = _video.pause(); - } catch (e) {} - - if (pausePromise !== undefined) { - pausePromise.then(function () { - console.log('Player', 'pause'); - })["catch"](function (e) { - console.log('Player', 'pause promise error:', e.message); - }); - } - - paused.removeClass('hide'); - listener$b.send('pause', {}); - } - /** - * Играем или пауза - */ - - - function playpause() { - if (wait || rewind_position) return; - - if (_video.paused) { - play$2(); - listener$b.send('play', {}); - } else { - pause(); - listener$b.send('pause', {}); - } - } - /** - * Завершаем перемотку - * @param {boolean} immediately - завершить немедленно - */ - - - function rewindEnd(immediately) { - clearTimeout(timer$3.rewind_call); - timer$3.rewind_call = setTimeout(function () { - _video.currentTime = rewind_position; - rewind_position = 0; - rewind_force = 0; - play$2(); - if (webos) webos.rewinded(); - }, immediately ? 0 : 1000); - } - /** - * Подготовка к перемотке - * @param {number} position_time - новое время - * @param {boolean} immediately - завершить немедленно - */ - - - function rewindStart(position_time, immediately) { - if (!_video.duration) return; - rewind_position = Math.max(0, Math.min(position_time, _video.duration)); - pause(); - if (rewind_position == 0) _video.currentTime = 0;else if (rewind_position == _video.duration) _video.currentTime = _video.duration; - timer$3.rewind = Date.now(); - listener$b.send('timeupdate', { - duration: _video.duration, - current: rewind_position - }); - listener$b.send('rewind', {}); - rewindEnd(immediately); - } - /** - * Начать перематывать - * @param {boolean} forward - направление, true - вперед - * @param {number} custom_step - свое значение в секундах - */ - - - function rewind(forward, custom_step) { - if (_video.duration) { - var step = Storage.field('player_rewind'); - - if (rewind_position == 0) { - rewind_force = Math.max(5, custom_step || step); - rewind_position = _video.currentTime; - } - - rewind_force *= 1.03; - - if (forward) { - rewind_position += rewind_force; - } else { - rewind_position -= rewind_force; - } - - rewindStart(rewind_position); - } - } - /** - * Размер видео, масштаб - * @param {string} type - */ - - - function size(type) { - neeed_sacle = type; - neeed_sacle_last = type; - scale(); - if (_video.size) _video.size(type); - } - - function speed(value) { - neeed_speed = value; - var fv = value == 'default' ? 1 : parseFloat(value); - if (_video.speed) _video.speed(fv);else if (webos) webos.speed(fv);else _video.playbackRate = fv; - } - /** - * Перемотка на позицию - * @param {number} type - */ - - - function to(seconds) { - pause(); - - try { - if (seconds == -1) _video.currentTime = Math.max(0, _video.duration - 3);else _video.currentTime = seconds; - } catch (e) {} - - play$2(); - } - - function enterToPIP() { - if (!document.pictureInPictureElement && document.pictureInPictureEnabled && _video.requestPictureInPicture) { - _video.requestPictureInPicture(); - } - } - - function exitFromPIP() { - if (document.pictureInPictureElement) { - document.exitPictureInPicture(); - } - } - - function togglePictureInPicture() { - if (document.pictureInPictureElement) exitFromPIP();else enterToPIP(); - } - - function changeVolume(volume) { - _video.volume = volume; - Storage.set('player_volume', volume); - } - /** - * Уничтожить - * @param {boolean} type - сохранить с параметрами - */ - - - function destroy$4(savemeta) { - subsview(false); - neeed_sacle = false; - - paused.addClass('hide'); - if (webos) webos.destroy(); - $('> div', subtitles$1).empty(); - webos = null; - webos_wait = {}; - clearTimeout(click_timer); - var hls_destoyed = false; - var dash_destoyed = false; - - if (hls) { - hls.destroy(); - hls = false; - hls_destoyed = true; - } - - if (hls_parser) { - hls_parser.destroy(); - hls_parser = false; - } - - if (dash) { - dash.destroy(); - dash = false; - dash_destoyed = true; - } - - if (!savemeta) { - if (customsubs) { - customsubs.destroy(); - customsubs = false; - } - } - - exitFromPIP(); - - if (_video && !(hls_destoyed || dash_destoyed)) { - if (_video.destroy) _video.destroy();else { - _video.src = ""; - - _video.load(); - } - } - - if (normalization) { - normalization.destroy(); - normalization = false; - } - - display.empty(); - loader(false); - } - - function render$8() { - return html$c; - } - - var PlayerVideo = { - init: init$q, - listener: listener$b, - url: url$4, - render: render$8, - destroy: destroy$4, - playpause: playpause, - rewind: rewind, - play: play$2, - pause: pause, - size: size, - speed: speed, - subsview: subsview, - customSubs: customSubs, - to: to, - video: function video() { - return _video; - }, - saveParams: saveParams, - clearParamas: clearParamas, - setParams: setParams, - normalizationVisible: normalizationVisible, - togglePictureInPicture: togglePictureInPicture, - changeVolume: changeVolume - }; - - function parse$1(data) { - var result = { - hash_string: '', - season: null, - episode: null, - serial: !!data.movie.number_of_seasons - }; - var regexps = [[/\bs(\d+)\.?ep?(\d+)\b/i, 'season', 'episode'], [/\b(\d{1,2})[x\-](\d+)\b/i, 'season', 'episode'], [/\bs(\d{2})(\d{2,3})\b/i, 'season', 'episode'], [/season (\d+) episode (\d+)/i, 'season', 'episode'], [/сезон (\d+) серия (\d+)/i, 'season', 'episode'], [/(\d+) season (\d+) episode/i, 'season', 'episode'], [/(\d+) сезон (\d+) серия/i, 'season', 'episode'], [/episode (\d+)/i, 'episode'], [/серия (\d+)/i, 'episode'], [/(\d+) episode/i, 'episode'], [/(\d+) серия/i, 'episode'], [/season (\d+)/i, 'season'], [/сезон (\d+)/i, 'season'], [/(\d+) season/i, 'season'], [/(\d+) сезон/i, 'season'], [/\bs(\d+)\b/i, 'season'], [/\bep?\.?(\d+)\b/i, 'episode'], [/\b(\d{1,3}) of (\d+)/i, 'episode'], [/\b(\d{1,3}) из (\d+)/i, 'episode'], [/ - (\d{1,3})\b/i, 'episode'], [/\[(\d{1,3})\]/i, 'episode'], [/(\d+) сер/i, 'episode']]; - var folder_regexps = [[/season (\d+)/i, 'season'], [/сезон (\d+)/i, 'season'], [/(\d+) season/i, 'season'], [/(\d+) сезон/i, 'season'], [/\bs(\d+)\b/i, 'season']]; - var parts = data.path.replace(/_/g, ' ').split('/'); - var fname = parts.pop(); - var folder = parts.pop(); - regexps.forEach(function (regexp) { - var match = fname.match(regexp[0]); - - if (match) { - var arr = regexp.slice(1); - arr.forEach(function (a, i) { - var v = match[i + 1]; - if (v && result[a] == null) result[a] = parseInt(v); - }); - } - }); - - if (folder && result.season == null) { - folder_regexps.forEach(function (regexp) { - var match = folder.match(regexp[0]); - - if (match) { - var arr = regexp.slice(1); - arr.forEach(function (a, i) { - var v = match[i + 1]; - if (v && result[a] == null) result[a] = parseInt(v); - }); - } - }); - } - - if (result.season == null) result.season = data.movie.number_of_seasons ? 1 : 0; - - if (result.episode == null) { - var match = data.filename.replace(/_/g, ' ').trim().match(/^(\d{1,3})\b/i); - result.episode = match ? parseInt(match[1]) : 0; - } - - if (!data.is_file) { - if (data.movie.number_of_seasons) { - result.hash_string = [result.season, result.season > 10 ? ':' : '', result.episode, data.movie.original_title].join(''); - } else if (data.movie.original_title && !result.serial) { - result.hash_string = data.movie.original_title; - } else { - result.hash_string = data.path; - } - } else { - result.hash_string = data.path; - } - - return result; - } - - var EpisodeParser = { - parse: parse$1 - }; - - var network$8 = new create$p(); - - function url$3() { - var u = ip(); - return u ? Utils$2.checkEmptyUrl(u) : u; - } - - function ip() { - var one = Storage.get('torrserver_url'); - var two = Storage.get('torrserver_url_two'); - return Storage.field('torrserver_use_link') == 'two' ? two || one : one || two; - } - - function my(success, fail) { - var data = JSON.stringify({ - action: 'list' - }); - clear$8(); - network$8.silent(url$3() + '/torrents', function (result) { - if (result.length) success(result);else fail(); - }, fail, data); - } - - function cache$1(hash, success, fail) { - var data = JSON.stringify({ - action: 'get', - hash: hash - }); - network$8.silent(url$3() + '/cache', success, fail, data); - } - - function add$8(object, success, fail) { - var data = JSON.stringify({ - action: 'add', - link: object.link, - title: '[LAMPA] ' + (object.title + '').replace('??', '?'), - poster: object.poster, - data: object.data ? JSON.stringify(object.data) : '', - save_to_db: true - }); - clear$8(); - network$8.silent(url$3() + '/torrents', success, fail, data); - } - - function hash$1(object, success, fail) { - var data = JSON.stringify({ - action: 'add', - link: object.link, - title: '[LAMPA] ' + (object.title + '').replace('??', '?'), - poster: object.poster, - data: object.data ? JSON.stringify(object.data) : '', - save_to_db: Storage.get('torrserver_savedb', 'false') - }); - clear$8(); - network$8.silent(url$3() + '/torrents', success, function (a, c) { - fail(network$8.errorDecode(a, c)); - }, data); - } - - function files$1(hash, success, fail) { - var data = JSON.stringify({ - action: 'get', - hash: hash - }); - clear$8(); - network$8.timeout(2000); - network$8.silent(url$3() + '/torrents', function (json) { - if (json.file_stats) { - success(json); - } - }, fail, data); - } - - function connected(success, fail) { - clear$8(); - network$8.timeout(5000); - network$8.silent(url$3() + '/settings', function (json) { - if (typeof json.CacheSize == 'undefined') { - fail(Lang.translate('torrent_error_nomatrix')); - } else { - success(json); - } - }, function (a, c) { - fail(network$8.errorDecode(a, c)); - }, JSON.stringify({ - action: 'get' - })); - } - - function stream(path, hash, id) { - return url$3() + '/stream/' + encodeURIComponent(path.split('\\').pop().split('/').pop()) + '?link=' + hash + '&index=' + id + '&' + (Storage.field('torrserver_preload') ? 'preload' : 'play'); - } - - function drop(hash, success, fail) { - var data = JSON.stringify({ - action: 'drop', - hash: hash - }); - clear$8(); - network$8.silent(url$3() + '/torrents', success, fail, data, { - dataType: 'text' - }); - } - - function remove$2(hash, success, fail) { - var data = JSON.stringify({ - action: 'rem', - hash: hash - }); - clear$8(); - network$8.silent(url$3() + '/torrents', success, fail, data, { - dataType: 'text' - }); - } - - function parse(data) { - var result = EpisodeParser.parse(data); - result.hash = Utils$2.hash(result.hash_string); - return result; - } - - function clearFileName(files) { - var combo = []; - files.forEach(function (element) { - var spl = element.path.split('/'); - var nam = spl[spl.length - 1].split('.'); - if (nam.length > 1) nam.pop(); - nam = nam.join('.'); - element.path_human = Utils$2.pathToNormalTitle(nam, false).trim(); - - if (spl.length > 1) { - spl.pop(); - element.folder_name = Utils$2.pathToNormalTitle(spl.pop(), false).trim(); - } - }); - - if (files.length > 1) { - files.forEach(function (element) { - var spl = element.path_human.split(' '); - - for (var i = spl.length - 1; i >= 0; i--) { - var com = spl.join(' '); - if (combo.indexOf(com) == -1) combo.push(com); - spl.pop(); - } - }); - combo.sort(function (a, b) { - return a.length > b.length ? -1 : a.length < b.length ? 1 : 0; - }); - - var _loop = function _loop(i) { - var com = combo[i]; - var len = files.filter(function (f) { - return f.path_human.slice(0, com.length) == com; - }).length; - if (len < files.length) Arrays.remove(combo, com); - }; - - for (var i = combo.length - 1; i >= 0; i--) { - _loop(i); - } - - files.forEach(function (element) { - for (var _i = 0; _i < combo.length; _i++) { - var com = combo[_i]; - var inx = element.path_human.indexOf(com); - - if (inx >= 0 && com !== element.path_human) { - element.path_human = element.path_human.slice(com.length).trim(); - break; - } - } - }); - } - - return files; - } - - function clear$8() { - network$8.clear(); - } - - function error$1() { - var temp = Template$1.get('torrent_error', { - ip: ip() - }); - var list = temp.find('.torrent-checklist__list > li'); - var info = temp.find('.torrent-checklist__info > div'); - var next = temp.find('.torrent-checklist__next-step'); - var prog = temp.find('.torrent-checklist__progress-bar > div'); - var comp = temp.find('.torrent-checklist__progress-steps'); - var btn = temp.find('.selector'); - var position = -2; - - function makeStep() { - position++; - list.slice(0, position + 1).addClass('wait'); - var total = list.length; - comp.text(Lang.translate('torrent_error_made') + ' ' + Math.max(0, position) + ' ' + Lang.translate('torrent_error_from') + ' ' + total); - - if (position > list.length) { - Modal.close(); - Controller.toggle('content'); - } else if (position >= 0) { - info.addClass('hide'); - info.eq(position).removeClass('hide'); - var next_step = list.eq(position + 1); - prog.css('width', Math.round(position / total * 100) + '%'); - list.slice(0, position).addClass('check'); - btn.text(position < total ? Lang.translate('torrent_error_next') : Lang.translate('torrent_error_complite')); - next.text(next_step.length ? '- ' + next_step.text() : ''); - } - } - - makeStep(); - btn.on('hover:enter', function () { - makeStep(); - }); - Modal.title(Lang.translate('torrent_error_connect')); - Modal.update(temp); - Controller.add('modal', { - invisible: true, - toggle: function toggle() { - Controller.collectionSet(temp); - Controller.collectionFocus(false, temp); - }, - back: function back() { - Modal.close(); - Controller.toggle('content'); - } - }); - Controller.toggle('modal'); - } - - var Torserver = { - ip: ip, - my: my, - add: add$8, - url: url$3, - hash: hash$1, - files: files$1, - clear: clear$8, - drop: drop, - stream: stream, - remove: remove$2, - connected: connected, - parse: parse, - error: error$1, - cache: cache$1, - clearFileName: clearFileName - }; - - var html$b; - var listener$a = start$8(); - var network$7 = new create$p(); - var elems; - var error, stat_timer; - - function init$p() { - html$b = Template$1.get('player_info'); - html$b.find('.player-info__body').prepend(HeadBackward('Плеер')); - elems = { - name: $('.player-info__name,.head-backward__title', html$b), - size: $('.value--size span', html$b), - stat: $('.value--stat span', html$b), - speed: $('.value--speed span', html$b), - error: $('.player-info__error', html$b), - pieces: $('.value--pieces', html$b) - }; - Utils$2.time(html$b); - } - /** - * Установить значение - * @param {string} need - * @param {string|{width,height}} value - */ - - - function set$3(need, value) { - if (need == 'name') elems.name.html(value);else if (need == 'size' && value.width && value.height) elems.size.text(value.width + 'x' + value.height);else if (need == 'error') { - clearTimeout(error); - elems.error.removeClass('hide').text(value); - error = setTimeout(function () { - elems.error.addClass('hide'); - }, 10000); - } else if (need == 'stat') stat$1(value);else if (need == 'bitrate') elems.stat.html(value); - } - - function pieces(cache) { - elems.pieces.empty(); - - if (cache.Readers.length) { - var reader = cache.Readers[0].Reader; - var end = cache.Readers[0].End; - var start = reader; - var total = end - reader; - var dots = 5; - var loaded = 0; - - while (cache.Pieces[start] && cache.Pieces[start].Completed && start < end) { - start++; - loaded++; - } - - var percent = loaded / total * 100; - - for (var i = 0; i < dots; i++) { - var color = ''; - var filled = Math.round(dots * (loaded / total)) >= i; - - if (i == 0) { - if (percent > 80) color = 'green';else if (percent >= 40) color = 'yellow';else color = 'red'; - } else if (filled) color = 'active'; - - elems.pieces.append(''); - } - } - } - /** - * Показываем статистику по торренту - * @param {string} url - */ - - - function stat$1(url) { - var wait = 0; - elems.stat.text('- / - • - ' + Lang.translate('connected_seeds')); - elems.speed.text('--'); - - var update = function update() { - // если панель скрыта, то зачем каждую секунду чекать? хватит и 5 сек - // проверено, если ставить на паузу, разадача удаляется, но если чекать постоянно, то все норм - if (!html$b.hasClass('info--visible')) { - wait++; - if (wait <= 5) return;else wait = 0; - } - - network$7.timeout(2000); - network$7.silent(url.replace('preload', 'stat').replace('play', 'stat'), function (data) { - elems.stat.text((data.active_peers || 0) + ' / ' + (data.total_peers || 0) + ' • ' + (data.connected_seeders || 0) + ' ' + Lang.translate('connected_seeds')); - elems.speed.text(Utils$2.bytesToSize(data.download_speed ? data.download_speed * 8 : 0, true)); - var hash = url.match(/link=(.*?)\&/); - - if (hash) { - Torserver.cache(hash[1], function (cache) { - pieces(cache); - listener$a.send('stat', { - data: data, - cache: cache - }); - }, function () { - listener$a.send('stat', { - data: data - }); - }); - } else { - listener$a.send('stat', { - data: data - }); - } - }); - }; - - stat_timer = setInterval(update, 2000); - update(); - } - /** - * Показать скрыть инфо - * @param {boolean} status - */ - - - function toggle$5(status) { - html$b.toggleClass('info--visible', status); - } - - function loading$1() { - elems.size.text(Lang.translate('loading') + '...'); - } - /** - * Уничтожить - */ - - - function destroy$3() { - elems.size.text(Lang.translate('loading') + '...'); - elems.stat.text(''); - elems.speed.text(''); - elems.error.addClass('hide'); - elems.pieces.empty(); - clearTimeout(error); - clearInterval(stat_timer); - network$7.clear(); - } - - function render$7() { - return html$b; - } - - var PlayerInfo = { - init: init$p, - listener: listener$a, - render: render$7, - set: set$3, - toggle: toggle$5, - loading: loading$1, - destroy: destroy$3 - }; - - var listener$9 = start$8(); - var current = ''; - var playlist$1 = []; - var _position = 0; - /** - * Показать плейлист - */ - - function show$6() { - active$3(); - var enabled = Controller.enabled(); - Select.show({ - title: Lang.translate('player_playlist'), - items: playlist$1, - onSelect: function onSelect(a) { - Controller.toggle(enabled.name); - listener$9.send('select', { - playlist: playlist$1, - item: a, - position: _position - }); - }, - onBack: function onBack() { - Controller.toggle(enabled.name); - } - }); - } - /** - * Установить активным - */ - - - function active$3() { - playlist$1.forEach(function (element) { - element.selected = element.url == current; - if (element.selected) _position = playlist$1.indexOf(element); - }); - } - /** - * Назад - */ - - - function prev() { - active$3(); - - if (_position > 0) { - listener$9.send('select', { - playlist: playlist$1, - position: _position - 1, - item: playlist$1[_position - 1] - }); - } - } - /** - * Далее - */ - - - function next$1() { - active$3(); - - if (_position < playlist$1.length - 1) { - listener$9.send('select', { - playlist: playlist$1, - position: _position + 1, - item: playlist$1[_position + 1] - }); - } - } - /** - * Установить плейлист - * @param {[{title:string, url:string}]} p - */ - - - function set$2(p) { - playlist$1 = p; - playlist$1.forEach(function (l, i) { - if (l.url == current) _position = i; - }); - listener$9.send('set', { - playlist: playlist$1, - position: _position - }); - } - /** - * Получить список - * @returns {[{title:string, url:string}]} - */ - - - function get$7() { - return playlist$1; - } - /** - * Установить текуший урл - * @param {string} u - */ - - - function url$2(u) { - current = u; - } - - var PlayerPlaylist = { - listener: listener$9, - active: active$3, - show: show$6, - url: url$2, - get: get$7, - set: set$2, - prev: prev, - next: next$1, - position: function position() { - return _position; - } - }; - - var timer$2; - var listener$8; - /** - * Открыть окно - * @param {{type:string, object:{}}} params - */ - - function open$3(params) { - var enabled = Controller.enabled().name; - var text = params.type == 'card' ? Lang.translate('broadcast_open') : params.type == 'play' ? Lang.translate('broadcast_play') : ''; - var temp = Template$1.get('broadcast', { - text: text - }); - var list = temp.find('.broadcast__devices'); - var last = ''; - if (!text) temp.find('.about').remove(); - Socket.send('devices', {}); - timer$2 = setInterval(function () { - Socket.send('devices', {}); - }, 3000); - - listener$8 = function listener(e) { - if (e.method == 'devices') { - var devices = e.data.filter(function (d) { - return !(d.name == 'CUB' || d.device_id == Socket.uid()); - }); - var select; - list.empty(); - devices.forEach(function (device) { - var item = $('
    ' + device.name + '
    '); - item.on('hover:enter', function () { - close$3(); - Controller.toggle(enabled); - - if (params.type == 'card') { - Socket.send('open', { - params: params.object, - uid: device.uid - }); - } - - if (params.type == 'play') { - Socket.send('other', { - params: { - submethod: 'play', - object: params.object - }, - uid: device.uid - }); - } - }).on('hover:focus', function () { - last = device.uid; - }); - list.append(item); - if (last == device.uid) select = item[0]; - }); - Modal.toggle(select); - } - }; - - Modal.open({ - title: '', - html: temp, - size: 'small', - mask: true, - onBack: function onBack() { - close$3(); - Controller.toggle(enabled); - } - }); - listener$8({ - method: 'devices', - data: Socket.devices() - }); - Socket.listener.follow('message', listener$8); - } - /** - * Закрыть окно - */ - - - function close$3() { - Socket.listener.remove('message', listener$8); - clearInterval(timer$2); - Modal.close(); - listener$8 = null; - } - - var Broadcast = { - open: open$3 - }; - - var already_requested = false; - var last_time_requested = 0; - - function init$o() { - Params.trigger('parental_control', false); - Params.select('parental_control_time', { - 'always': '#{settings_parental_control_param_time_always}', - 'once': '#{settings_parental_control_param_time_once}', - '10': '#{settings_parental_control_param_time_10}', - '20': '#{settings_parental_control_param_time_20}', - '30': '#{settings_parental_control_param_time_30}', - '60': '#{settings_parental_control_param_time_60}', - '120': '#{settings_parental_control_param_time_120}' - }, 'once'); - Template$1.add('settings_parental_control', "
    \n
    \n
    #{title_parental_control}
    \n
    \n
    \n
    \n
    \n
    #{settings_parental_control_change_pin}
    \n
    \n
    \n
    #{settings_parental_control_demand_title}
    \n
    \n
    #{settings_parental_control_demand_descr}
    \n
    \n
    \n
    "); - Settings.listener.follow('open', function (e) { - if (e.name == 'parental_control') { - var toggle = e.body.find('.parental-control-toggle'); - var change = e.body.find('.parental-control-change'); - var other = e.body.find('.parental-control-other'); - var active; - - var updateStatus = function updateStatus() { - toggle.find('.settings-param__value').text(Lang.translate(Storage.field('parental_control') ? 'settings_parental_control_enabled' : 'settings_parental_control_disabled')); - other.toggleClass('hide', !Boolean(Storage.field('parental_control'))); - }; - - toggle.on('hover:enter', function () { - active = Controller.enabled().name; - - if (Storage.field('parental_control')) { - request(function () { - Storage.set('parental_control', false); - updateStatus(); - Controller.toggle(active); - }, function () { - Controller.toggle(active); - }); - } else if (!Storage.value('parental_control_pin')) { - set$1(function (code) { - if (code) { - Storage.set('parental_control_pin', code); - Storage.set('parental_control', true); - updateStatus(); - } - }); - } else { - Storage.set('parental_control', true); - updateStatus(); - } - }); - change.on('hover:enter', function () { - active = Controller.enabled().name; - - if (Storage.value('parental_control_pin')) { - request(function () { - set$1(function (code) { - if (code) { - Storage.set('parental_control_pin', code); - } - - Controller.toggle(active); - }); - }, function () { - Controller.toggle(active); - }); - } - }); - updateStatus(); - } - }); - } - - function set$1(call) { - var active = Controller.enabled().name; - pin(Lang.translate('parental_control_input_new_code'), function (code_one) { - if (code_one) { - pin(Lang.translate('parental_control_confirm_new_code'), function (code_two) { - if (code_one == code_two) { - Controller.toggle(active); - call(code_two); - } else { - Controller.toggle(active); - Noty.show(Lang.translate('parental_control_no_match_code')); - call(); - } - }); - } else { - Controller.toggle(active); - call(); - } - }); - } - - function pin(title, call) { - Input.edit({ - free: true, - title: title, - nosave: true, - value: '', - layout: 'nums', - keyboard: 'lampa' - }, call); - } - - function request(call, error) { - if (Storage.field('parental_control')) { - pin(Lang.translate('parental_control_input_code'), function (code) { - if (code == Storage.value('parental_control_pin')) { - call(); - } else if (code) { - Noty.show(Lang.translate('parental_control_input_error')); - if (error) error(); - } else if (error) error(); - }); - } else { - call(); - } - } - /** - * Запросить PIN-код - * @param {function} call - если pin верный - * @param {function} error - если нет - */ - - - function query(call, error) { - if (Storage.field('parental_control')) { - var type = Storage.field('parental_control_time'); - - if (type !== 'always') { - if (type == 'once') { - if (already_requested) return call(); - } else { - if (last_time_requested + 1000 * 60 * parseInt(type) > Date.now()) return call(); - } - } - - request(function () { - already_requested = true; - last_time_requested = Date.now(); - call(); - }, error); - } else { - call(); - } - } - /** - * Запрос на установку PIN-кода, перед этим нужно проверить через enabled() - * @param {function} call - callback - */ - - - function install$1(call) { - set$1(function (code) { - if (code) { - Storage.set('parental_control_pin', code); - Storage.set('parental_control', true); - } - - call(Boolean(code)); - }); - } - /** - * Проверить, установлен ли контроль - * @returns bollean - */ - - - function enabled$1() { - return Storage.field('parental_control'); - } - - var ParentalControl = { - init: init$o, - query: query, - enabled: enabled$1, - install: install$1 - }; - - var status$1 = false; - - function init$n() { - $.ajax({ - url: "./personal.lampa", - dataType: 'text', - success: function success() { - status$1 = true; - } - }); - } - - function confirm() { - return status$1; - } - - var Personal = { - init: init$n, - confirm: confirm - }; - - var Vast = /*#__PURE__*/function () { - function Vast(number) { - var _this = this; - - _classCallCheck(this, Vast); - - this.network = new create$p(); - this.listener = start$8(); - this.paused = false; - setTimeout(function () { - _this.create(); - }, 100); - } - - _createClass(Vast, [{ - key: "create", - value: function create() { - this.block = Template$1.js('ad_video_block'); - this.last_controller = Controller.enabled().name; - this.block.find('video').remove(); - this.block.find('.ad-video-block__text').text(Lang.translate('ad') + ' - ' + Lang.translate('ad_disable')); - this.block.find('.ad-video-block__info').text(''); - this.block.find('.ad-video-block__vast-line').removeClass('hide'); - var skip = this.block.find('.ad-video-block__skip'); - var progressbar = this.block.find('.ad-video-block__progress-fill'); - var adDisplayContainer; - var adsLoader; - var adsManager; - var videoContent = this.block.find('video'); - var adContainer = this.block.find('.ad-video-block__vast'); - var adInterval; - var isLinearAd = false; - var adDuration = 0; - var adReadySkip; - - function initializeIMA() { - // Создаем контейнер для объявлений - adDisplayContainer = new google.ima.AdDisplayContainer(adContainer, videoContent); - adsLoader = new google.ima.AdsLoader(adDisplayContainer); // Регистрируем слушатель для получения рекламных ошибок - - adsLoader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, onAdsManagerLoaded.bind(this), false); - adsLoader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, onAdError.bind(this), false); // Загружаем рекламу - - var adsRequest = new google.ima.AdsRequest(); - adsRequest.adTagUrl = 'https://yandex.ru/ads/adfox/277740/getCode?p1=dekrt&p2=gdol'; // Ссылка на VAST - // Указываем, что реклама должна воспроизводиться перед контентом - - adsRequest.linearAdSlotWidth = window.innerWidth; - adsRequest.linearAdSlotHeight = window.innerHeight; - adsLoader.requestAds(adsRequest); - } - - function onAdsManagerLoaded(adsManagerLoadedEvent) { - var _this2 = this; - - // Инициализируем AdsManager, который контролирует рекламу - adsManager = adsManagerLoadedEvent.getAdsManager(videoContent); - adsManager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, onAdError.bind(this)); - adsManager.addEventListener(google.ima.AdEvent.Type.STARTED, onAdStarted.bind(this)); - adsManager.addEventListener(google.ima.AdEvent.Type.COMPLETE, function () { - adsManager.destroy(); - - _this2.destroy(); - }, false); - - try { - adDisplayContainer.initialize(); - adsManager.init(window.innerWidth, window.innerHeight, google.ima.ViewMode.NORMAL); - adsManager.start(); - } catch (adError) { - console.log('Ad', 'error', 'AdsManager could not be started'); - adsManager.destroy(); - adsLoader.destroy(); - this.destroy(); - } - } - - function onAdStarted(event) { - var ad = event.getAd(); - - if (ad.isLinear()) { - isLinearAd = true; // Отображаем полную продолжительность рекламы - - adDuration = adsManager.getRemainingTime(); // Обновляем прогресс рекламы каждую секунду - - adInterval = setInterval(updateAdProgress, 100); // Показываем кнопку "Пропустить" через 5 секунд, если это разрешено рекламой - - if (ad.getSkipTimeOffset() !== -1) { - setTimeout(function () { - adReadySkip = true; - }, ad.getSkipTimeOffset() * 1000); // Отображаем кнопку через заданное время - } - } else { - isLinearAd = false; - } - } - - function updateAdProgress() { - if (isLinearAd && adsManager) { - var remainingTime = adsManager.getRemainingTime(); - var progress = Math.min(100, (1 - remainingTime / adDuration) * 100); - progressbar.style.width = progress + '%'; - skip.find('span').text(Lang.translate(adReadySkip ? 'ad_skip' : Math.round(remainingTime))); - - if (remainingTime <= 0) { - clearInterval(adInterval); - } - } - } - - function enter() { - if (adReadySkip) { - adsManager.destroy(); - adsLoader.destroy(); - this.destroy(); - } - } - - function onAdError(adErrorEvent) { - console.log('Ad', 'error', adErrorEvent.getError().data.errorMessage); - if (adsManager) adsManager.destroy(); - adsLoader.destroy(); - this.destroy(); - } - - this.block.on('click', enter.bind(this)); - document.body.append(this.block); - Controller.add('ad_video_block', { - toggle: function toggle() { - Controller.clear(); - }, - enter: enter.bind(this), - back: function back() {} - }); - Controller.toggle('ad_video_block'); - this.listener.send('launch'); - initializeIMA.apply(this); - } - }, { - key: "destroy", - value: function destroy() { - this.block.remove(); - Controller.toggle(this.last_controller); - this.listener.send('ended'); - } - }]); - - return Vast; - }(); - - var next = 0; - var imasdk; - - function init$m() { - if (Platform.is('android')) { - Utils$2.putScriptAsync(['https://imasdk.googleapis.com/js/sdkloader/ima3.js'], false, false, function () { - imasdk = true; - }); - } - } - - function random(min, max) { - return Math.floor(Math.random() * (max - min + 1) + min); - } - - function video(num, started, ended) { - var Blok = imasdk ? Vast : VideoBlock; - var item = new Blok(num); - item.listener.follow('launch', started); - item.listener.follow('ended', ended); - item.listener.follow('empty', ended); - } - - function launch(call) { - var enabled = Controller.enabled().name; - next = Date.now() + 1000 * 60 * random(30, 80); - var html = $("\n
    \n
    \n
    ".concat(Lang.translate('ad'), "
    \n
    \n
    \n ")); - $('body').append(html); - setTimeout(function () { - html.find('.ad-preroll__bg').addClass('animate'); - setTimeout(function () { - html.find('.ad-preroll__text').addClass('animate'); - }, 500); - }, 100); - setTimeout(function () { - html.find('.ad-preroll__over').addClass('animate'); - setTimeout(function () { - Controller.toggle(enabled); - video(1, function () { - html.remove(); - }, function () { - html.remove(); - call(); - }); - }, 300); - }, 3500); - Controller.add('ad_preroll', { - toggle: function toggle() { - Controller.clear(); - }, - enter: function enter() {}, - back: function back() {} - }); - Controller.toggle('ad_preroll'); - } - - function show$5(data, call) { - if (window.god_enabled) return launch(call); - - if (!Account.hasPremium() && next < Date.now() && !(data.torrent_hash || data.youtube || data.iptv || data.continue_play) && !Personal.confirm()) { - VPN.region(function (code) { - if (code == 'ru') launch(call);else call(); - }); - } else call(); - } - - var Preroll = { - init: init$m, - show: show$5 - }; - - var html$a; - var listener$7 = start$8(); - new create$p(); - var callback$2; - var work = false; - var launch_player; - var timer_ask; - var timer_save; - var wait_for_loading_url = false; - var preloader = { - wait: false - }; - var viewing = { - time: 0, - difference: 0, - current: 0 - }; - /** - * Подписываемся на события - */ - - function init$l() { - PlayerPanel.init(); - PlayerVideo.init(); - PlayerInfo.init(); - Footer.init(); - PlayerIPTV.init(); - html$a = Template$1.get('player'); - html$a.append(PlayerVideo.render()); - html$a.append(PlayerPanel.render()); - html$a.append(PlayerInfo.render()); - html$a.append(Footer.render()); - html$a.on('mousemove', function () { - if (Storage.field('navigation_type') == 'mouse' && !Utils$2.isTouchDevice()) PlayerPanel.mousemove(); - }); - if (!window.localStorage.getItem('player_torrent')) Storage.set('player_torrent', Storage.field('player')); - /** Следим за обновлением времени */ - - PlayerVideo.listener.follow('timeupdate', function (e) { - PlayerPanel.update('time', Utils$2.secondsToTime(e.current | 0, true)); - PlayerPanel.update('timenow', Utils$2.secondsToTime(e.current || 0)); - PlayerPanel.update('timeend', Utils$2.secondsToTime(e.duration || 0)); - PlayerPanel.update('position', e.current / e.duration * 100 + '%'); - Screensaver$2.resetTimer(); - - if (work && work.timeline && !work.timeline.waiting_for_user && e.duration) { - if (Storage.field('player_timecode') !== 'again' && !work.timeline.continued) { - var exact = parseFloat(work.timeline.time + ''); - exact = isNaN(exact) ? 0 : parseFloat(exact.toFixed(3)); - var prend = e.duration - 15, - posit = exact > 0 && exact < e.duration ? exact : Math.round(e.duration * work.timeline.percent / 100); - if (posit > 10) PlayerVideo.to(posit > prend ? prend : posit); - work.timeline.continued = true; - } else { - work.timeline.percent = Math.round(e.current / e.duration * 100); - work.timeline.time = e.current; - work.timeline.duration = e.duration; - } - } - - viewing.difference = e.current - viewing.current; - viewing.current = e.current; - if (viewing.difference > 0 && viewing.difference < 3) viewing.time += viewing.difference; - }); - /** Буферизация видео */ - - PlayerVideo.listener.follow('progress', function (e) { - PlayerPanel.update('peding', e.down); - }); - /** Может ли плеер начать играть */ - - PlayerVideo.listener.follow('canplay', function (e) { - PlayerPanel.canplay(); - }); - /** Плей видео */ - - PlayerVideo.listener.follow('play', function (e) { - PlayerPanel.update('play'); - PlayerPanel.rewind(); - }); - /** Пауза видео */ - - PlayerVideo.listener.follow('pause', function (e) { - PlayerPanel.update('pause'); - }); - /** Перемотка видео */ - - PlayerVideo.listener.follow('rewind', function (e) { - PlayerPanel.rewind(); - }); - /** Видео было завершено */ - - PlayerVideo.listener.follow('ended', function (e) { - if (Storage.field('playlist_next') && !$('body').hasClass('selectbox--open')) PlayerPlaylist.next(); - }); - /** Дорожки полученые из видео */ - - PlayerVideo.listener.follow('tracks', function (e) { - PlayerPanel.setTracks(e.tracks); - }); - /** Субтитры полученые из видео */ - - PlayerVideo.listener.follow('subs', function (e) { - PlayerPanel.setSubs(e.subs); - }); - /** Качество видео в m3u8 */ - - PlayerVideo.listener.follow('levels', function (e) { - PlayerPanel.setLevels(e.levels, e.current); - }); - /** Размер видео */ - - PlayerVideo.listener.follow('videosize', function (e) { - PlayerInfo.set('size', e); - }); - /** Ошибка при попытки возпроизвести */ - - PlayerVideo.listener.follow('error', function (e) { - if (work) { - PlayerInfo.set('error', e.error); - - if (e.fatal && work.url_reserve) { - PlayerVideo.destroy(true); - PlayerVideo.url(work.url_reserve, true); - delete work.url_reserve; - } - } - }); - PlayerVideo.listener.follow('translate', function (e) { - PlayerPanel.updateTranslate(e.where, e.translate); - }); - PlayerVideo.listener.follow('loadeddata', function () { - if (PlayerVideo.video().duration < 60 * 3 && work.need_check_live_stream) { - PlayerPanel.hideRewind(); - } - }); - /** Сбросить (продолжить) */ - - PlayerVideo.listener.follow('reset_continue', function (e) { - if (work && work.timeline && !work.timeline.continued_bloc) work.timeline.continued = false; - }); - /** Перемотка мышкой */ - - PlayerPanel.listener.follow('mouse_rewind', function (e) { - var vid = PlayerVideo.video(); - - if (vid && vid.duration) { - if (!Platform.screen('mobile')) e.time.removeClass('hide').text(Utils$2.secondsToTime(vid.duration * e.percent)).css('left', e.percent * 100 + '%'); - - if (e.method == 'click') { - PlayerVideo.to(vid.duration * e.percent); - } - } - }); - /** Плей/Пауза */ - - PlayerPanel.listener.follow('playpause', function (e) { - PlayerVideo.playpause(); - if (Platform.screen('mobile')) PlayerPanel.rewind(); - }); - /** Нажали на плейлист */ - - PlayerPanel.listener.follow('playlist', function (e) { - PlayerPlaylist.show(); - }); - /** Изменить размер видео */ - - PlayerPanel.listener.follow('size', function (e) { - PlayerVideo.size(e.size); - Storage.set('player_size', e.size); - }); - /** Изменить скорость видео */ - - PlayerPanel.listener.follow('speed', function (e) { - PlayerVideo.speed(e.speed); - Storage.set('player_speed', e.speed); - }); - /** Предыдущая серия */ - - PlayerPanel.listener.follow('prev', function (e) { - PlayerPlaylist.prev(); - }); - /** Следуюшия серия */ - - PlayerPanel.listener.follow('next', function (e) { - PlayerPlaylist.next(); - }); - /** Перемотать назад */ - - PlayerPanel.listener.follow('rprev', function (e) { - PlayerVideo.rewind(false); - }); - /** Перемотать далее */ - - PlayerPanel.listener.follow('rnext', function (e) { - PlayerVideo.rewind(true); - }); - /** Показать/скрыть субтитры */ - - PlayerPanel.listener.follow('subsview', function (e) { - PlayerVideo.subsview(e.status); - }); - /** Состояние панели, скрыта или нет */ - - PlayerPanel.listener.follow('visible', function (e) { - PlayerInfo.toggle(e.status); - PlayerVideo.normalizationVisible(e.status); - html$a.toggleClass('player--panel-visible', e.status); - }); - /** К началу видео */ - - PlayerPanel.listener.follow('to_start', function (e) { - PlayerVideo.to(0); - }); - /** К концу видео */ - - PlayerPanel.listener.follow('to_end', function (e) { - PlayerVideo.to(-1); - }); - /** На весь экран */ - - PlayerPanel.listener.follow('fullscreen', function () { - Utils$2.toggleFullscreen(); - }); - /** Картинка в картинке */ - - PlayerPanel.listener.follow('pip', function (e) { - PlayerVideo.togglePictureInPicture(); - }); - /** Переключили качемтво видео */ - - PlayerPanel.listener.follow('quality', function (e) { - PlayerVideo.destroy(true); - PlayerVideo.url(e.url, true); - - if (work && work.timeline) { - work.timeline.continued = false; - work.timeline.continued_bloc = false; - } - }); - /** Нажали на кнопку (отправить) */ - - PlayerPanel.listener.follow('share', function (e) { - Broadcast.open({ - type: 'play', - object: { - player: work, - playlist: PlayerPlaylist.get() - } - }); - }); - /** Событие на переключение серии */ - - PlayerPlaylist.listener.follow('select', function (e) { - var type = _typeof(e.item.url); - - var call = function call() { - var params = PlayerVideo.saveParams(); - destroy$2(); - e.item.continue_play = true; - play$1(e.item); - PlayerVideo.setParams(params); - if (e.item.callback) e.item.callback(); - if (Torserver.ip() && e.item.url.indexOf(Torserver.ip()) > -1) PlayerInfo.set('stat', e.item.url); - PlayerPlaylist.active(); - PlayerPanel.showNextEpisodeName({ - playlist: PlayerPlaylist.get(), - position: PlayerPlaylist.position() - }); - }; - - if (type == 'string') call();else if (type == 'function' && !wait_for_loading_url) { - PlayerInfo.loading(); - wait_for_loading_url = true; - e.item.url(call); - } - }); - /** Установить название следующей серии */ - - PlayerPlaylist.listener.follow('set', PlayerPanel.showNextEpisodeName); - /** Прослушиваем на сколько загрузилось, затем запускаем видео */ - - PlayerInfo.listener.follow('stat', function (e) { - if (preloader.wait) { - var pb = e.data.preloaded_bytes || 0, - ps = e.data.preload_size || 0; - var progress = Math.min(100, pb * 100 / ps); - PlayerPanel.update('timenow', Math.round(progress) + '%'); - PlayerPanel.update('timeend', 100 + '%'); - PlayerPanel.update('peding', progress + '%'); - - if (progress >= 90 || isNaN(progress)) { - PlayerPanel.update('peding', '0%'); - preloader.wait = false; - preloader.call(); - } - } - }); - PlayerIPTV.listener.follow('play', function (data) { - locked(data.channel, function () { - PlayerVideo.destroy(); - console.log('Player', 'url:', data.channel.url); - PlayerVideo.url(data.channel.url); - PlayerInfo.set('name', ''); - Controller.toggle('player_tv'); - }); - }); - } - /** - * Главный контроллер - */ - - - function toggle$4() { - Controller.add('player', { - invisible: true, - toggle: function toggle() { - PlayerPanel.hide(); - }, - up: function up() { - PlayerPanel.toggle(); - }, - down: function down() { - PlayerPanel.toggle(); - }, - right: function right() { - if (PlayerIPTV.playning()) PlayerPanel.toggle();else PlayerVideo.rewind(true); - }, - left: function left() { - if (PlayerIPTV.playning()) PlayerPanel.toggle();else PlayerVideo.rewind(false); - }, - enter: function enter() { - if (PlayerIPTV.playning()) PlayerPanel.toggle();else PlayerVideo.playpause(); - }, - playpause: function playpause() { - if (!PlayerIPTV.playning()) PlayerVideo.playpause(); - }, - play: function play() { - if (!PlayerIPTV.playning()) PlayerVideo.play(); - }, - pause: function pause() { - if (!PlayerIPTV.playning()) PlayerVideo.pause(); - }, - rewindForward: function rewindForward() { - if (!PlayerIPTV.playning()) PlayerVideo.rewind(true); - }, - rewindBack: function rewindBack() { - if (!PlayerIPTV.playning()) PlayerVideo.rewind(false); - }, - stop: backward$1, - back: backward$1 - }); - Controller.toggle('player'); - } - /** - * Вызвать событие назад - */ - - - function backward$1() { - destroy$2(); - if (callback$2) callback$2();else Controller.toggle('content'); - callback$2 = false; - } - /** - * Уничтожить плеер - */ - - - function destroy$2() { - saveTimeView(); - if (work.viewed) work.viewed(viewing.time); - clearTimeout(timer_ask); - clearInterval(timer_save); - work = false; - preloader.wait = false; - preloader.call = null; - wait_for_loading_url = false; - viewing.time = 0; - viewing.difference = 0; - viewing.current = 0; - html$a.removeClass('player--ios'); - html$a.removeClass('iptv'); - html$a.removeClass('player--panel-visible'); - PlayerIPTV.destroy(); - PlayerVideo.destroy(); - PlayerVideo.clearParamas(); - PlayerPanel.destroy(); - PlayerInfo.destroy(); - Footer.destroy(); - html$a.detach(); - Background.theme('reset'); - listener$7.send('destroy', {}); - } - /** - * Запустить webos плеер - * @param {Object} params - */ - - - function runWebOS(params) { - webOS.service.request("luna://com.webos.applicationManager", { - method: "launch", - parameters: { - "id": params.need, - "params": { - "payload": [{ - "fullPath": params.url, - "artist": "", - "subtitle": "", - "dlnaInfo": { - "flagVal": 4096, - "cleartextSize": "-1", - "contentLength": "-1", - "opVal": 1, - "protocolInfo": "http-get:*:video/x-matroska:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000", - "duration": 0 - }, - "mediaType": "VIDEO", - "thumbnail": "", - "deviceType": "DMR", - "album": "", - "fileName": params.name, - "lastPlayPosition": params.position - }] - } - }, - onSuccess: function onSuccess() { - console.log('Player', 'The app is launched'); - }, - onFailure: function onFailure(inError) { - console.log('Player', "Failed to launch the app (" + params.need + "): ", "[" + inError.errorCode + "]: " + inError.errorText); - - if (params.need == 'com.webos.app.photovideo') { - params.need = 'com.webos.app.smartshare'; - runWebOS(params); - } else if (params.need == 'com.webos.app.smartshare') { - params.need = 'com.webos.app.mediadiscovery'; - runWebOS(params); - } - } - }); - } - /** - * Показать предзагрузку торрента - * @param {Object} data - * @param {Function} call - */ - - - function preload$1(data, call) { - data.url = data.url.replace('&preload', '&play'); - return call(); - } - /** - * Спросить продолжать ли просмотр - */ - - - function ask() { - if (work && work.timeline && work.timeline.percent) { - work.timeline.waiting_for_user = false; - - if (Storage.field('player_timecode') == 'ask') { - work.timeline.waiting_for_user = true; - Select.show({ - title: Lang.translate('title_action'), - items: [{ - title: Lang.translate('player_start_from') + ' ' + Utils$2.secondsToTime(work.timeline.time) + '?', - yes: true - }, { - title: Lang.translate('settings_param_no') - }], - onBack: function onBack() { - work.timeline.continued = true; - work.timeline.continued_bloc = true; - toggle$4(); - clearTimeout(timer_ask); - }, - onSelect: function onSelect(a) { - work.timeline.waiting_for_user = false; - - if (!a.yes) { - work.timeline.continued = true; - work.timeline.continued_bloc = true; - } - - toggle$4(); - clearTimeout(timer_ask); - } - }); - clearTimeout(timer_ask); - timer_ask = setTimeout(function () { - work.timeline.continued = true; - work.timeline.continued_bloc = true; - Select.hide(); - toggle$4(); - }, 8000); - } - } - } - /** - * Сохранить отметку просмотра - */ - - - function saveTimeView() { - if (work.timeline && work.timeline.handler) work.timeline.handler(work.timeline.percent, work.timeline.time, work.timeline.duration); - } - /** - * Сохранять отметку просмотра каждые 2 минуты - */ - - - function saveTimeLoop() { - if (work.timeline) { - timer_save = setInterval(saveTimeView, 1000 * 60 * 2); - } - } - - function locked(data, call) { - var name = Controller.enabled().name; - - if (data.locked) { - ParentalControl.query(call, function () { - Controller.toggle(name); - }); - } else call(); - } - - function start$5(data, need, inner) { - var player_need = 'player' + (need ? '_' + need : ''); - if (launch_player == 'lampa' || launch_player == 'inner' || data.url.indexOf('youtube.com') >= 0) inner();else if (Platform.is('apple')) { - data.url = data.url.replace('&preload', '&play').replace(/\s/g, '%20'); - if (Storage.field(player_need) == 'vlc') window.open('vlc://' + data.url);else if (Storage.field(player_need) == 'nplayer') window.open('nplayer-' + data.url);else if (Storage.field(player_need) == 'infuse') window.open('infuse://x-callback-url/play?url=' + encodeURIComponent(data.url));else if (Storage.field(player_need) == 'svplayer') window.open('svplayer://x-callback-url/stream?url=' + encodeURIComponent(data.url));else if (Storage.field(player_need) == 'ios') { - html$a.addClass('player--ios'); - inner(); - } else inner(); - } else if (Platform.macOS()) { - data.url = data.url.replace('&preload', '&play'); - if (Storage.field(player_need) == 'mpv') window.location.assign('mpv://' + encodeURI(data.url));else if (Storage.field(player_need) == 'iina') window.location.assign('iina://weblink?url=' + encodeURIComponent(data.url));else if (Storage.field(player_need) == 'nplayer') window.location.assign('nplayer-' + encodeURI(data.url));else if (Storage.field(player_need) == 'infuse') window.location.assign('infuse://x-callback-url/play?url=' + encodeURIComponent(data.url));else inner(); - } else if (Platform.is('apple_tv')) { - data.url = data.url.replace('&preload', '&play'); - if (Storage.field(player_need) == 'vlc') window.location.assign('vlc-x-callback://x-callback-url/stream?url=' + encodeURIComponent(data.url));else if (Storage.field(player_need) == 'infuse') window.location.assign('infuse://x-callback-url/play?url=' + encodeURIComponent(data.url));else if (Storage.field(player_need) == 'svplayer') window.location.assign('svplayer://x-callback-url/stream?url=' + encodeURIComponent(data.url));else if (Storage.field(player_need) == 'tvos') window.location.assign('lampa://video?player=tvos&src=' + encodeURIComponent(data.url) + '&playlist=' + encodeURIComponent(JSON.stringify(data.playlist)));else inner(); - } else if (Platform.is('webos') && (Storage.field(player_need) == 'webos' || launch_player == 'webos')) { - data.url = data.url.replace('&preload', '&play'); - Preroll.show(data, function () { - runWebOS({ - need: 'com.webos.app.photovideo', - url: data.url, - name: data.path || data.title, - position: data.timeline ? data.timeline.time || -1 : -1 - }); - }); - } else if (Platform.is('android') && (Storage.field(player_need) == 'android' || launch_player == 'android' || data.torrent_hash)) { - data.url = data.url.replace('&preload', '&play'); - - if (data.playlist && Array.isArray(data.playlist)) { - data.playlist = data.playlist.filter(function (p) { - return typeof p.url == 'string'; - }); - data.playlist.forEach(function (a) { - a.url = a.url.replace('&preload', '&play'); - }); - } - - Preroll.show(data, function () { - Android.openPlayer(data.url, data); - }); - } else if (Platform.desktop() && Storage.field(player_need) == 'other') { - var path = Storage.field('player_nw_path'); - - var file = require('fs'); - - data.url = data.url.replace('&preload', '&play').replace(/\s/g, '%20'); - - if (file.existsSync(path)) { - Preroll.show(data, function () { - var spawn = require('child_process').spawn; - - spawn(path, [data.url]); - }); - } else { - Noty.show(Lang.translate('player_not_found') + ': ' + path); - } - } else inner(); - } - - function addContinueWatch() { - var continues_next = Storage.get('player_continue_watch', '[]'); - var continues_watch = Favorite.continues('tv'); - continues_watch = continues_watch.filter(function (a) { - var status = Favorite.check(a); - return !(status.thrown || status.viewed); - }); - var continues_all = Arrays.removeDuplicates([].concat(continues_next, continues_watch), 'id'); - if (continues_all.length) Footer.appendContinue({ - results: continues_all, - title: Lang.translate('title_continue'), - small: true, - collection: true, - nomore: true, - line_type: 'player-cards' - }); - } - /** - * Запустить плеер - * @param {Object} data - */ - - - function play$1(data) { - console.log('Player', 'url:', data.url); - - if (data.quality) { - if (Arrays.getKeys(data.quality).length == 1) delete data.quality;else { - for (var q in data.quality) { - if (parseInt(q) == Storage.field('video_quality_default')) { - data.url = data.quality[q]; - break; - } - } - } - } - - var lauch = function lauch() { - work = data; - Preroll.show(data, function () { - Background.theme('black'); - preload$1(data, function () { - html$a.toggleClass('tv', data.tv ? true : false); - html$a.toggleClass('youtube', Boolean(data.url.indexOf('youtube.com') >= 0)); - listener$7.send('start', data); - if (work.timeline) work.timeline.continued = false; - PlayerPlaylist.url(data.url); - PlayerPanel.quality(data.quality, data.url); - if (data.translate) PlayerPanel.setTranslate(data.translate); - PlayerVideo.url(data.url); - PlayerVideo.size(Storage.get('player_size', 'default')); - PlayerVideo.speed(Storage.get('player_speed', 'default')); - if (data.subtitles) PlayerVideo.customSubs(data.subtitles); - PlayerInfo.set('name', data.title); - if (data.card) Footer.appendCard(card);else { - Lampa.Activity.active().movie && Footer.appendCard(Lampa.Activity.active().movie); - } - addContinueWatch(); - if (!preloader.call) $('body').append(html$a); - toggle$4(); - PlayerPanel.show(true); - ask(); - saveTimeLoop(); - listener$7.send('ready', data); - }); - }); - }; - - start$5(data, data.torrent_hash ? 'torrent' : '', lauch); - launch_player = ''; - } - - function iptv(data) { - locked(data, function () { - console.log('Player', 'play iptv'); - data.iptv = true; //пометка для ведра, что это iptv - - var lauch = function lauch() { - Background.theme('black'); - listener$7.send('start', data); - html$a.toggleClass('iptv', true); - PlayerIPTV.start(data); - PlayerVideo.size(Storage.get('player_size', 'default')); - PlayerVideo.speed(Storage.get('player_speed', 'default')); - $('body').append(html$a); - toggle$4(); - PlayerPanel.show(true); - listener$7.send('ready', data); - }; - - start$5(data, 'iptv', lauch); - }); - } - /** - * Статистика для торрсервера - * @param {String} url - */ - - - function stat(url) { - if (work || preloader.wait) PlayerInfo.set('stat', url); - } - /** - * Установить плейлист - * @param {Array} playlist - */ - - - function playlist(playlist) { - if (work || preloader.wait) PlayerPlaylist.set(playlist); - } - /** - * Установить субтитры - * @param {Array} subs - */ - - - function subtitles(subs) { - if (work || preloader.wait) { - PlayerVideo.customSubs(subs); - } - } - /** - * Запустить другой плеер - * @param {String} need - тип плеера - */ - - - function runas(need) { - launch_player = need; - } - /** - * Обратный вызов - * @param {Function} back - */ - - - function onBack(back) { - callback$2 = back; - } - /** - * Рендер плеера - * @returns Html - */ - - - function render$6() { - return html$a; - } - /** - * Возвращает статус, открыт ли плеер - * @returns boolean - */ - - - function opened$1() { - return $('body').find('.player').length ? true : false; - } - - var Player = { - init: init$l, - listener: listener$7, - play: play$1, - playlist: playlist, - render: render$6, - stat: stat, - subtitles: subtitles, - runas: runas, - callback: onBack, - opened: opened$1, - iptv: iptv, - programReady: PlayerIPTV.programReady, - close: backward$1 - }; - - var socket; - var ping; - - var _uid = Utils$2.uid(); - - var _devices = []; - var listener$6 = start$8(); - var expects = []; - var timeping = 5000; - var timeout; - - function connect$1() { - if (!window.lampa_settings.socket_use) return; - clearInterval(ping); - clearTimeout(timeout); - timeout = setTimeout(function () { - console.log('Socket', 'timeout close'); - if (socket) socket.close(); - }, 10000); - - try { - socket = new WebSocket(window.lampa_settings.socket_url); - } catch (e) { - console.log('Socket', 'not work'); - } - - if (!socket) return; - socket.addEventListener('open', function (event) { - console.log('Socket', 'open'); - timeping = 5000; - clearTimeout(timeout); - send('start', {}); - listener$6.send('open', {}); - }); - socket.addEventListener('close', function (event) { - console.log('Socket', 'close', event.code); - clearTimeout(timeout); - listener$6.send('close', {}); - console.log('Socket', 'try connect after', Math.round(timeping) / 1000, 'sec.'); - setTimeout(connect$1, Math.round(timeping)); - timeping *= 2; - }); - socket.addEventListener('error', function (event) { - console.log('Socket', 'error:', 'maybe there is no connection to the server'); - socket.close(); - }, false); - socket.addEventListener('message', function (event) { - var result = JSON.parse(event.data); - - if (window.lampa_settings.socket_methods) { - if (result.method == 'devices') { - _devices = result.data; - } else if (result.method == 'open') { - Controller.toContent(); - Activity$1.push(result.data); - } else if (result.method == 'timeline') { - result.data.received = true; //чтоб снова не остправлять и не зациклить - - var account = Account.canSync(); - - if (account && account.profile && account.profile.id == result.data.profile) { - Timeline.update(result.data); - } - } else if (result.method == 'bookmarks') { - Account.update(); - } else if (result.method == 'logoff') { - Account.logoff(result.data); - } else if (result.method == 'other' && result.data.submethod == 'play') { - Controller.toContent(); - Player.play(result.data.object.player); - Player.playlist(result.data.object.playlist); - } - } - - listener$6.send('message', result); - }); - setInterval(function () { - if (expects.length > 50) expects = expects.slice(-50); - - if (socket && socket.readyState == 1 && expects.length) { - var msg = expects.shift(); - console.log('Socket', 'sent with a delay:', msg.method); - send(msg.method, msg); - } - }, 1000); - } - - function send(method, data) { - var name_devise = Platform.get() ? Platform.get() : navigator.userAgent.toLowerCase().indexOf('mobile') > -1 ? 'mobile' : navigator.userAgent.toLowerCase().indexOf('x11') > -1 ? 'chrome' : 'other'; - data.device_id = _uid; - data.name = Utils$2.capitalizeFirstLetter(name_devise) + ' - ' + Storage.field('device_name'); - data.method = method; - data.version = 1; - data.account = Storage.get('account', '{}'); - data.premium = Account.hasPremium(); - if (socket && socket.readyState == 1) socket.send(JSON.stringify(data));else expects.push(data); - } - - var Socket = { - listener: listener$6, - init: connect$1, - send: send, - uid: function uid() { - return _uid; - }, - devices: function devices() { - return _devices; - } - }; - - var NoticeClass = /*#__PURE__*/function () { - function NoticeClass() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - _classCallCheck(this, NoticeClass); - - this.params = params; - this.name = 'Noname'; - } - - _createClass(NoticeClass, [{ - key: "active", - value: function active() { - return true; - } - }, { - key: "push", - value: function push(element, resolve, reject) { - resolve(); - } - }, { - key: "empty", - value: function empty() { - return Lang.translate('notice_none_system'); - } - }, { - key: "viewed", - value: function viewed() {} - }, { - key: "items", - value: function items() { - return []; - } - }, { - key: "count", - value: function count() { - return 0; - } - }]); - - return NoticeClass; - }(); - - var NoticeAll = /*#__PURE__*/function (_NoticeClass) { - _inherits(NoticeAll, _NoticeClass); - - var _super = _createSuper(NoticeAll); - - function NoticeAll() { - var _this; - - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - _classCallCheck(this, NoticeAll); - - _this = _super.call(this, params); - _this.name = Lang.translate('settings_param_jackett_interview_all'); - return _this; - } - - _createClass(NoticeAll, [{ - key: "active", - value: function active() { - return false; - } - }, { - key: "count", - value: function count() { - return Notice$1.count(); - } - }, { - key: "viewed", - value: function viewed() { - for (var name in Notice$1.classes) { - if (Notice$1.classes[name] !== this) { - Notice$1.classes[name].viewed(); - } - } - } - }, { - key: "items", - value: function items() { - var _this2 = this; - - var items = []; - - var _loop = function _loop(name) { - if (Notice$1.classes[name] !== _this2) { - items = items.concat(Notice$1.classes[name].items().map(function (item) { - var new_item = Arrays.clone(item); - new_item.display = name; - return new_item; - })); - } - }; - - for (var name in Notice$1.classes) { - _loop(name); - } - - items.sort(function (a, b) { - return a.time > b.time ? -1 : a.time < b.time ? 1 : 0; - }); - return items; - } - }]); - - return NoticeAll; - }(NoticeClass); - - var NoticeLampa = /*#__PURE__*/function (_NoticeClass) { - _inherits(NoticeLampa, _NoticeClass); - - var _super = _createSuper(NoticeLampa); - - function NoticeLampa() { - var _this; - - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - _classCallCheck(this, NoticeLampa); - - _this = _super.call(this, params); - _this.name = params.name || 'Lampa'; - _this.time = 0; - _this.view = 0; - _this.db_name = params.db_name || 'notice'; - _this.notices = []; - - _this.connect(); - - return _this; - } - - _createClass(NoticeLampa, [{ - key: "connect", - value: function connect() { - this.db = new IndexedDB(this.db_name, ['all', 'readed'], 2); - this.db.openDatabase().then(this.update.bind(this)); - } - }, { - key: "update", - value: function update() { - var _this2 = this; - - this.db.getData('readed', 'time').then(function (time) { - _this2.time = time || 0; - return _this2.db.getData('all'); - }).then(function (result) { - result.sort(function (a, b) { - return a.time > b.time ? -1 : a.time < b.time ? 1 : 0; - }); - _this2.notices = result; - _this2.view = result.filter(function (n) { - return n.time > _this2.time; - }).length; - Notice$1.drawCount(); - })["catch"](function (e) {}); - } - }, { - key: "count", - value: function count() { - return this.view; - } - }, { - key: "push", - value: function push(element, resolve, reject) { - if (!(element.id && element.from)) { - if (reject) reject('No (id) or (from)'); - return; - } - - if (!this.notices.find(function (n) { - return n.id == element.id; - })) { - this.db.addData('all', element.id, element).then(this.update.bind(this)).then(function (e) { - if (resolve) resolve(e); - })["catch"](function (e) { - if (reject) reject(e); - }); - } else if (reject) reject('Already added'); - } - }, { - key: "viewed", - value: function viewed() { - this.db.rewriteData('readed', 'time', Date.now()); - this.view = 0; - this.time = Date.now(); - Notice$1.drawCount(); - } - }, { - key: "items", - value: function items() { - return this.notices; - } - }]); - - return NoticeLampa; - }(NoticeClass); - - var NoticeCub = /*#__PURE__*/function (_NoticeClass) { - _inherits(NoticeCub, _NoticeClass); - - var _super = _createSuper(NoticeCub); - - function NoticeCub() { - var _this; - - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - _classCallCheck(this, NoticeCub); - - _this = _super.call(this, params); - _this.name = 'CUB'; - _this.time = Storage.get('cub_notice_time', '0'); - _this.notices = []; - setInterval(_this.update.bind(_assertThisInitialized(_this)), 1000 * 60 * 5); - - _this.update(); - - return _this; - } - - _createClass(NoticeCub, [{ - key: "update", - value: function update() { - var _this2 = this; - - Account.notice(function (result) { - _this2.notices = result.map(function (item) { - var data = JSON.parse(item.data); - var text = Lang.translate('notice_new_quality'); - var labels = []; - - if (data.card.seasons) { - var k = []; - - for (var i in data.card.seasons) { - k.push(i); - } - - var s = k.pop(); - labels.push('S - ' + s + ''); - labels.push('E - ' + data.card.seasons[s] + ''); - if (data.voice) labels.push(data.voice); - text = Lang.translate('notice_new_episode'); - } else { - labels.push(Lang.translate('notice_quality') + ' - ' + data.card.quality + ''); - } - - return { - time: item.time || Utils.parseToDate(item.date).getTime(), - title: !Lang.selected(['ru', 'uk', 'be']) ? data.card.original_title || data.card.original_name : data.card.title || data.card.name, - text: text, - poster: data.card.poster ? data.card.poster : data.card.img ? data.card.img : data.card.poster_path, - card: data.card, - labels: labels - }; - }); - - _this2.notices.sort(function (a, b) { - return a.time > b.time ? -1 : a.time < b.time ? 1 : 0; - }); - - Notice$1.drawCount(); - }); - } - }, { - key: "viewed", - value: function viewed() { - Storage.set('cub_notice_time', Date.now()); - this.time = Date.now(); - Notice$1.drawCount(); - } - }, { - key: "empty", - value: function empty() { - return Lang.translate(Account.logged() ? 'notice_none_account' : 'notice_none'); - } - }, { - key: "count", - value: function count() { - var _this3 = this; - - return this.notices.filter(function (n) { - return n.time > _this3.time; - }).length; - } - }, { - key: "items", - value: function items() { - return this.notices; - } - }]); - - return NoticeCub; - }(NoticeClass); - - function translate$1(str) { - if (Arrays.isObject(str)) { - var code = Lampa.Storage.get('language', 'ru'); - if (str[code]) return str[code];else if (str.ru) return str.ru;else return str[Arrays.getKeys(str)[0]]; - } - - return str; - } - - var Notice = /*#__PURE__*/function () { - function Notice() { - _classCallCheck(this, Notice); - - this.listener = start$8(); - this.display = 'all'; - this.classes = {}; - } - - _createClass(Notice, [{ - key: "init", - value: function init() { - this.classes.all = new NoticeAll(); - this.classes.lampa = new NoticeLampa(); - this.classes.cub = new NoticeCub(); - } - }, { - key: "open", - value: function open() { - var _this = this; - - if (Lampa.Controller.enabled().name == 'modal') Modal.close(); - var html = $('
    '); - var tabs = []; - var viever = this.classes[this.display]; - var items = viever.items(); - var navigation = $(''); - - for (var name in this.classes) { - var count = this.classes[name].count(); - var tab = { - name: name, - count: count - }; - tabs.push(tab); - } - - tabs.forEach(function (tab, i) { - var button = $(''); - if (tab.count) button.append('' + tab.count + ''); - button.on('hover:enter', function () { - _this.display = tab.name; - - _this.open(); - }); - if (tab.name == _this.display) button.addClass('active'); - if (i > 0) navigation.append(''); - navigation.append(button); - }); - html.append(navigation); - items.forEach(function (element) { - var item = Template$1.get('notice_card', {}); - var icon = element.poster || element.icon || element.img; - var author_data = {}; - var author_html; - item.addClass('image--' + (element.poster ? 'poster' : element.icon ? 'icon' : element.img ? 'img' : 'none')); - item.find('.notice__title').html(translate$1(element.title)); - item.find('.notice__descr').html(translate$1(element.text)); - item.find('.notice__time').html(Utils$2.parseTime(element.time)["short"]); - if (element.labels) item.find('.notice__descr').append($('')); - - if (element.author) { - author_data = translate$1(element.author); - author_html = $("
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    "); - author_html.find('.notice__author-name').html(author_data.name); - author_html.find('.notice__author-text').html(author_data.text); - item.find('.notice__body').append(author_html); - } - - item.on('hover:enter', function () { - if (element.card) { - _this.close(); - - Activity$1.push({ - url: '', - component: 'full', - id: element.card.id, - method: element.card.number_of_seasons || element.card.seasons ? 'tv' : 'movie', - card: element.card, - source: Lang.selected(['ru', 'uk', 'be']) ? 'cub' : '' - }); - } else _this.listener.send('select', { - display: element.display || _this.display, - element: element - }); - }).on('visible', function () { - if (icon) { - icon = translate$1(icon); - if (icon.indexOf('http') == -1) icon = TMDB$1.image('t/p/w300/' + icon); - var img_icon = item.find('.notice__left img')[0] || {}; - var img_author = item.find('.notice__author img')[0] || {}; - - img_icon.onload = function () { - item.addClass('image--loaded'); - }; - - img_icon.onerror = function () { - img_icon.src = './img/img_broken.svg'; - }; - - img_author.onload = function () { - item.addClass('image-author--loaded'); - }; - - img_author.onerror = function () { - img_author.src = './img/img_broken.svg'; - }; - - img_icon.src = icon; - if (element.author) img_author.src = author_data.img.indexOf('http') >= 0 ? author_data.img : TMDB$1.image('t/p/w200/' + author_data.img); - } - }); - html.append(item); - }); - - if (!items.length) { - var empty = $('
    '); - empty.append(viever.empty()); - html.append(empty); - } - - viever.viewed(); - this.listener.send('viewed', { - display: this.display - }); - Modal.open({ - title: Lang.translate('title_notice'), - select: html.find('.navigation-tabs .active')[0], - size: 'medium', - html: html, - onBack: this.close.bind(this) - }); - } - }, { - key: "count", - value: function count() { - var all = 0; - - for (var name in this.classes) { - if (this.classes[name].active()) all += this.classes[name].count(); - } - - return all; - } - }, { - key: "close", - value: function close() { - Modal.close(); - Controller.toggle('head'); - } - }, { - key: "drawCount", - value: function drawCount() { - var status = Boolean(this.count()); - var icon = $('.head .notice--icon'); - icon.toggleClass('active', status); - clearInterval(this.blick_timer); - - if (status) { - this.blick_timer = setInterval(function () { - icon.addClass('animate'); - setTimeout(function () { - icon.removeClass('animate'); - }, 1000); - }, 1000 * 15); - } - } - }, { - key: "addClass", - value: function addClass(class_name, noticeClass) { - this.classes[class_name] = noticeClass; - } - }, { - key: "pushNotice", - value: function pushNotice(class_name, data, resolve, reject) { - if (this.classes[class_name] && this.classes[class_name].push) { - this.classes[class_name].push(data, resolve, reject); - } else if (reject) reject('No find class'); - } - }]); - - return Notice; - }(); - - var Notice$1 = new Notice(); - - var html$9 = $('
    '), - text = html$9.find('.processing__text'); - var processing = []; - - function init$k() { - update$5(); - } - - function update$5() { - if (processing.length) { - text.text(processing.length > 1 ? processing.length : '1 / ' + Math.round(processing[0].percent) + '%'); - var complite = processing.find(function (a) { - return a.percent >= 100; - }); - if (complite) Lampa.Arrays.remove(processing, complite); - requestAnimationFrame(update$5); - } else html$9.addClass('hide'); - } - - function push$2(id, percent) { - var find = processing.find(function (a) { - return a.id == id; - }); - - if (!find) { - processing.push({ - id: id, - percent: percent, - start: Date.now() - }); - html$9.removeClass('hide'); - update$5(); - } else find.percent = percent; - } - - function render$5(js) { - return js ? html$9[0] : html$9; - } - - var Processing = { - init: init$k, - push: push$2, - render: render$5 - }; - - var html$8; - var last$2; - var activi = false; - - function init$j() { - html$8 = Template$1.get('head'); - html$8.find('.head__actions').prepend(Processing.render()); - Utils$2.time(html$8); - html$8.find('.selector').data('controller', 'head').on('hover:focus', function (event) { - last$2 = event.target; - }); - html$8.find('.open--settings').on('hover:enter', function () { - Controller.toggle('settings'); - }); - html$8.find('.open--notice').on('hover:enter', Notice$1.open.bind(Notice$1)); - html$8.find('.open--search').on('hover:enter', Search.open.bind(Search)); - html$8.find('.head__logo-icon,.head__menu-icon').on('click', function (e) { - if (DeviceInput.canClick(e.originalEvent)) Controller.toggle('menu'); - }); - Storage.listener.follow('change', function (e) { - if (e.name == 'account') { - html$8.find('.open--profile').toggleClass('hide', e.value.token && window.lampa_settings.account_use ? false : true); - } - - if (e.name == 'account_user') { - html$8.find('.open--premium').toggleClass('hide', Account.hasPremium() || window.lampa_settings.white_use ? true : !Lang.selected(['ru', 'uk', 'be'])); - } - }); - html$8.find('.full-screen').on('hover:enter', function () { - Utils$2.toggleFullscreen(); - }).toggleClass('hide', Platform.tv() || Platform.is('android') || !Utils$2.canFullScreen()); - - if (!Lang.selected(['ru', 'uk', 'be'])) { - html$8.find('.open--feed').remove(); - } else { - html$8.find('.open--feed').on('hover:enter', function () { - Activity$1.push({ - url: '', - title: Lang.translate('menu_feed'), - component: 'feed', - page: 1 - }); - }); - } - - html$8.find('.open--premium').toggleClass('hide', Account.hasPremium() || window.lampa_settings.white_use ? true : !Lang.selected(['ru', 'uk', 'be'])).on('hover:enter', function () { - Modal.open({ - title: '', - size: 'full', - mask: true, - html: Template$1.get('cub_premium_modal'), - onBack: function onBack() { - Modal.close(); - Controller.toggle('head'); - } - }); - }); - Controller.add('head', { - toggle: function toggle() { - Controller.collectionSet(html$8, false, true); - Controller.collectionFocus(last$2, html$8, true); - }, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - down: function down() { - Controller.toggle('content'); - }, - back: function back() { - Activity$1.backward(); - } - }); - var timer; - var broadcast = html$8.find('.open--broadcast').hide(); - broadcast.on('hover:enter', function () { - Broadcast.open({ - type: 'card', - object: Activity$1.extractObject(activi) - }); - }); - Lampa.Listener.follow('activity', function (e) { - if (e.type == 'start') activi = e.object; - clearTimeout(timer); - timer = setTimeout(function () { - if (activi) { - if (activi.component !== 'full') { - broadcast.hide(); - activi = false; - } - } - }, 1000); - - if (e.type == 'start' && e.component == 'full') { - broadcast.show(); - activi = e.object; - } - }); - } - - function title(title) { - html$8.find('.head__title').text(title || ''); - } - - function render$4() { - return html$8; - } - - var Head = { - render: render$4, - title: title, - init: init$j - }; - - var body$2; - var network$6 = new create$p(); - var listener$5 = start$8(); - var start_time = Date.now(); - var user_data; - var notice_load = { - time: 0, - data: [] - }; - var bookmarks = []; - - function api$1() { - return Utils$2.protocol() + object$2.cub_domain + '/api/'; - } - /** - * Запуск - */ - - - function init$i() { - if (!window.lampa_settings.account_use) return; - Settings.listener.follow('open', function (e) { - body$2 = null; - - if (e.name == 'account') { - body$2 = e.body; - renderPanel(); - check$1(); - } - }); - Storage.listener.follow('change', function (e) { - if (e.name == 'account_use') timelines(true); - - if (e.name == 'account') { - timelines(true); - updateProfileIcon(); - } - }); - Socket.listener.follow('open', checkValidAccount); - Socket.listener.follow('open', function () { - if (Date.now() - start_time > 1000 * 60 * 5) timelines(false, true); - }); - Favorite.listener.follow('add,added', function (e) { - save$3('add', e.where, e.card); - }); - Favorite.listener.follow('remove', function (e) { - if (e.method == 'id') save$3('remove', e.where, e.card); - }); - Head.render().find('.head__body .open--profile').on('hover:enter', function () { - showProfiles('head'); - }); - network$6.silent(Utils$2.protocol() + 'tmdb.' + object$2.cub_domain + '/blocked', function (dcma) { - window.lampa_settings.dcma = dcma; - }); - setInterval(checkValidAccount, 1000 * 60 * 10); - updateBookmarks(Storage.get('account_bookmarks', '[]')); - notice_load.data = Storage.get('account_notice', '[]'); - checkProfile(function () { - update$4(); - timelines(); - getUser(); - updateProfileIcon(); - persons(); - }); - } - - function checkProfile(call) { - var account = Storage.get('account', '{}'); - - if (account.token && window.lampa_settings.account_use) { - if (account.profile.id) call();else { - network$6.silent(api$1() + 'profiles/all', function (result) { - var main = result.profiles.find(function (p) { - return p.main; - }); - - if (main) { - account.profile = main; - Storage.set('account', account); - } - - call(); - }, function () { - setTimeout(checkProfile.bind(checkProfile, call), 1000 * 60); - }, false, { - headers: { - token: account.token - } - }); - } - } else { - Storage.set('account_user', ''); - } - } - - function checkValidAccount() { - var account = Storage.get('account', '{}'); - - if (account.token) { - Socket.send('check_token', {}); - } - } - - function updateProfileIcon() { - var account = Storage.get('account', '{}'); - var button = Head.render().find('.head__body .open--profile').toggleClass('hide', !Boolean(account.token)); - - if (account.token) { - var img = button.find('img')[0]; - - img.onerror = function () { - img.src = './img/img_load.svg'; - }; - - img.src = Utils$2.protocol() + object$2.cub_domain + '/img/profiles/' + (account.profile.icon || 'l_1') + '.png'; - } - } - - function persons(secuses, error) { - var account = Storage.get('account', '{}'); - - if (account.token && window.lampa_settings.account_use) { - network$6.silent(api$1() + 'person/list', function (data) { - Storage.set('person_subscribes_id', data.results.map(function (a) { - return a.person_id; - })); - if (secuses) secuses(data.results); - }, error ? error : false, false, { - headers: { - token: account.token - } - }); - } else error(); - } - - function getUser() { - var account = Storage.get('account', '{}'); - - if (account.token && window.lampa_settings.account_use) { - network$6.silent(api$1() + 'users/get', function (result) { - user_data = result.user; - Storage.set('account_user', JSON.stringify(result.user)); - }, false, false, { - headers: { - token: account.token - } - }); - } - } - - function checkPremium() { - return 1; - } - - function timelines(full, visual) { - var account = Storage.get('account', '{}'); - - if (account.token && Storage.field('account_use') && window.lampa_settings.account_use && window.lampa_settings.account_sync) { - var url = api$1() + 'timeline/all'; - var _all = full; - if (Storage.get('timeline_full_update_time', '0') + 1000 * 60 * 60 * 24 < Date.now()) _all = true; - if (_all) url = url + '?full=true'; - network$6.silent(url, function (result) { - if (visual) { - for (var i in result.timelines) { - var time = result.timelines[i]; - time.received = true; - Timeline.update(time); - } - } else { - var name = 'file_view_' + account.profile.id; - - if (window.localStorage.getItem(name) === null) { - Storage.set(name, Arrays.clone(Storage.cache('file_view', 10000, {}))); - } - - var viewed = Storage.cache(name, 10000, {}); - - for (var _i in result.timelines) { - var _time = result.timelines[_i]; - viewed[_i] = _time; - Arrays.extend(viewed[_i], { - duration: 0, - time: 0, - percent: 0 - }); - delete viewed[_i].hash; - } - - Storage.set(name, viewed); - } - - Storage.set('timeline_full_update_time', Date.now()); - }, function () { - setTimeout(timelines.bind(timelines, full), 1000 * 60); - }, false, { - headers: { - token: account.token, - profile: account.profile.id - } - }); - } - } - - function save$3(method, type, card) { - var account = Storage.get('account', '{}'); - - if (account.token && Storage.field('account_use') && window.lampa_settings.account_use && window.lampa_settings.account_sync) { - var list = bookmarks; - var find = list.find(function (elem) { - return elem.card_id == card.id && elem.type == type; - }); - network$6.clear(); - network$6.silent(api$1() + 'bookmarks/' + method, update$4, false, { - type: type, - data: JSON.stringify(card), - card_id: card.id, - id: find ? find.id : 0 - }, { - headers: { - token: account.token, - profile: account.profile.id - } - }); - - if (method == 'remove') { - if (find) { - Arrays.remove(list, find); - } - } else { - Arrays.insert(list, 0, { - id: 0, - card_id: card.id, - type: type, - data: JSON.parse(JSON.stringify(card)), - profile: account.profile.id - }); - } - - Socket.send('bookmarks', {}); - } - } - - function clear$7(where) { - var account = Storage.get('account', '{}'); - - if (account.token && window.lampa_settings.account_use && window.lampa_settings.account_sync) { - network$6.silent(api$1() + 'bookmarks/clear', function (result) { - if (result.secuses) update$4(); - }, false, { - type: 'group', - group: where - }, { - headers: { - token: account.token, - profile: account.profile.id - } - }); - } - } - - function update$4(call) { - var account = Storage.get('account', '{}'); - - if (account.token && window.lampa_settings.account_use && window.lampa_settings.account_sync) { - network$6.silent(api$1() + 'bookmarks/all?full=1', function (result) { - if (result.secuses) { - updateBookmarks(result.bookmarks, function () { - if (call && typeof call == 'function') call(); - }); - } - }, function () { - if (call && typeof call == 'function') call(); - }, false, { - headers: { - token: account.token, - profile: account.profile.id - } - }); - } else { - updateBookmarks([]); - } - } - - function plugins(call) { - var account = Storage.get('account', '{}'); - - if (account.token && window.lampa_settings.account_use) { - network$6.timeout(3000); - network$6.silent(api$1() + 'plugins/all', function (result) { - if (result.secuses) { - Storage.set('account_plugins', result.plugins); - call(result.plugins); - } else { - call(Storage.get('account_plugins', '[]')); - } - }, function () { - call(Storage.get('account_plugins', '[]')); - }, false, { - headers: { - token: account.token, - profile: account.profile.id - } - }); - } else { - call([]); - } - } - - function extensions(call) { - var account = Storage.get('account', '{}'); - var headers = {}; - - if (account.token && window.lampa_settings.account_use) { - headers = { - headers: { - token: account.token, - profile: account.profile.id - } - }; - } - - network$6.timeout(5000); - network$6.silent(api$1() + 'extensions/list', function (result) { - if (result.secuses) { - if (window.lampa_settings.white_use) { - var forbidden = [9, 10, 12, 180, 5, 149, 13, 158, 179]; - result.results.forEach(function (elem) { - elem.results = elem.results.filter(function (plug) { - return forbidden.indexOf(plug.id) == -1; - }); - }); - } - - Storage.set('account_extensions', result); - call(result); - } else { - call(Storage.get('account_extensions', '{}')); - } - }, function () { - call(Storage.get('account_extensions', '{}')); - }, false, headers); - } - - function pluginsStatus(plugin, status) { - var account = Storage.get('account', '{}'); - - if (account.token && window.lampa_settings.account_use) { - network$6.silent(api$1() + (plugin.author ? 'extensions' : 'plugins') + '/status', false, false, { - id: plugin.id, - status: status - }, { - headers: { - token: account.token, - profile: account.profile.id - } - }); - } - } - /** - * Статус - */ - - - function renderStatus$1(name) { - var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; - - if (body$2) { - body$2.find('.settings--account-status .settings-param__value').text(name); - body$2.find('.settings--account-status .settings-param__descr').text(value); - } - } - - function addDevice() { - var displayModal = function displayModal() { - var html = Template$1.get('account_add_device'); - html.find('.simple-button').on('hover:enter', function () { - Modal.close(); - Input.edit({ - free: true, - title: Lang.translate('account_code_enter'), - nosave: true, - value: '', - layout: 'nums' - }, function (new_value) { - var code = parseInt(new_value); - - if (new_value && new_value.length == 6 && !isNaN(code)) { - var login = function login(error) { - network$6.silent(api$1() + 'device/add', function (result) { - Loading.stop(); - Storage.set('account', result, true); - Storage.set('account_email', result.email, true); - window.location.reload(); - }, error, { - code: code - }); - }; - - Loading.start(function () { - network$6.clear(); - Loading.stop(); - }); - network$6.clear(); - login(function () { - localStorage.setItem('protocol', window.location.protocol == 'https:' ? 'https' : 'http'); - login(function () { - Loading.stop(); - Noty.show(Lang.translate('account_code_error')); - }); - }); - } else { - displayModal(); - Noty.show(Lang.translate('account_code_wrong')); - } - }); - }); - Modal.open({ - title: '', - html: html, - size: 'small', - onBack: function onBack() { - Modal.close(); - Controller.toggle('settings_component'); - } - }); - }; - - displayModal(); - } - - function renderPanel() { - if (body$2) { - var account = Storage.get('account', '{}'); - var signed = account.token ? true : false; - - if (!window.lampa_settings.account_sync) { - body$2.find('[data-name="account_use"]').remove(); - body$2.find('.settings--account-status').nextAll().remove(); - } - - body$2.find('.settings--account-signin').toggleClass('hide', signed); - body$2.find('.settings--account-user').toggleClass('hide', !signed); - body$2.find('.settings--account-premium').toggleClass('selectbox-item--checked', Boolean(checkPremium())); - body$2.find('.settings-param__label').toggleClass('hide', !Boolean(checkPremium())); - - if (!checkPremium()) { - body$2.find('.selectbox-item').on('hover:enter', showCubPremium); - } - - body$2.find('.settings--account-device-add').on('hover:enter', addDevice); - - if (account.token) { - body$2.find('.settings--account-user-info .settings-param__value').text(account.email); - body$2.find('.settings--account-user-profile .settings-param__value').text(account.profile.name); - body$2.find('.settings--account-user-out').on('hover:enter', function () { - Storage.set('account', ''); - Storage.set('account_user', ''); - Storage.set('account_email', ''); - Settings.update(); - update$4(); - }); - body$2.find('.settings--account-user-sync').on('hover:enter', function () { - account = Storage.get('account', '{}'); - Select.show({ - title: Lang.translate('settings_cub_sync'), - items: [{ - title: Lang.translate('confirm'), - subtitle: Lang.translate('account_sync_to_profile') + ' (' + account.profile.name + ')', - confirm: true - }, { - title: Lang.translate('cancel') - }], - onSelect: function onSelect(a) { - if (a.confirm) { - var file; - - try { - file = new File([localStorage.getItem('favorite') || '{}'], "bookmarks.json", { - type: "text/plain" - }); - } catch (e) {} - - if (!file) { - try { - file = new Blob([localStorage.getItem('favorite') || '{}'], { - type: 'text/plain' - }); - file.lastModifiedDate = new Date(); - } catch (e) { - Noty.show(Lang.translate('account_export_fail')); - } - } - - if (file) { - var formData = new FormData($('
    ')[0]); - formData.append("file", file, "bookmarks.json"); - var loader = $('
    '); - body$2.find('.settings--account-user-sync').append(loader); - $.ajax({ - url: api$1() + 'bookmarks/sync', - type: 'POST', - data: formData, - async: true, - cache: false, - contentType: false, - enctype: 'multipart/form-data', - processData: false, - headers: { - token: account.token, - profile: account.profile.id - }, - success: function success(j) { - if (j.secuses) { - Noty.show(Lang.translate('account_sync_secuses')); - update$4(); - loader.remove(); - } - }, - error: function error() { - Noty.show(Lang.translate('account_export_fail')); - loader.remove(); - } - }); - } - } - - Controller.toggle('settings_component'); - }, - onBack: function onBack() { - Controller.toggle('settings_component'); - } - }); - }); - body$2.find('.settings--account-user-backup').on('hover:enter', backup); - profile(); - } else check$1(); - } - } - - function profile() { - var account = Storage.get('account', '{}'); - body$2.find('.settings--account-user-profile .settings-param__value').text(account.profile.name); - body$2.find('.settings--account-user-profile').on('hover:enter', function () { - showProfiles('settings_component'); - }); - } - - function showProfiles(controller) { - var account = Storage.get('account', '{}'); - Loading.start(function () { - network$6.clear(); - Loading.stop(); - }); - network$6.clear(); - network$6.silent(api$1() + 'profiles/all', function (result) { - Loading.stop(); - - if (result.secuses) { - var items = Arrays.clone(result.profiles); - items.reverse(); - Select.show({ - title: Lang.translate('account_profiles'), - items: items.map(function (elem, index) { - elem.title = elem.name; - elem.template = 'selectbox_icon'; - elem.icon = ''; - elem.index = index; - elem.selected = account.profile.id == elem.id; - return elem; - }), - onSelect: function onSelect(a) { - account.profile = result.profiles[a.index]; - Storage.set('account', account); - if (body$2) body$2.find('.settings--account-user-profile .settings-param__value').text(a.name); - notice_load.time = 0; - Controller.toggle(controller); - update$4(); - }, - onBack: function onBack() { - Controller.toggle(controller); - } - }); - } else { - Noty.show(result.text); - } - }, function () { - Loading.stop(); - Noty.show(Lang.translate('account_profiles_empty')); - }, false, { - headers: { - token: account.token - } - }); - } - - function check$1() { - var account = Storage.get('account', '{}'); - - if (account.token) { - renderStatus$1(Lang.translate('account_authorized'), Lang.translate('account_logged_in') + ' ' + account.email); - } else { - renderStatus$1(Lang.translate('account_login_failed'), Lang.translate('account_login_wait')); - } - } - - function working() { - return Storage.get('account', '{}').token && Storage.field('account_use') && window.lampa_settings.account_use && window.lampa_settings.account_sync; - } - - function canSync(logged_check) { - return (logged_check ? logged() && window.lampa_settings.account_sync : working()) ? Storage.get('account', '{}') : false; - } - - function logged() { - return Storage.get('account', '{}').token ? window.lampa_settings.account_use : false; - } - - function get$6(params) { - return bookmarks.filter(function (elem) { - return elem.type == params.type; - }).map(function (elem) { - return elem.data; - }); - } - - function all$2() { - return bookmarks.map(function (elem) { - return elem.data; - }); - } - - function addDiscuss(params, call) { - var account = Storage.get('account', '{}'); - - if (account.token) { - network$6.silent(api$1() + 'discuss/add', function (data) { - data.result.icon = account.profile.icon; - call(data.result); - }, function (j, e) { - Noty.show(j.responseJSON.text, { - time: 5000 - }); - }, { - id: [params.method, params.id].join('_'), - comment: params.comment, - lang: Storage.field('language') - }, { - headers: { - token: account.token, - profile: account.profile.id - } - }); - } - } - - function voiteDiscuss(params, call) { - var account = Storage.get('account', '{}'); - - if (account.token) { - network$6.silent(api$1() + 'discuss/voite', call, function (j, e) { - Noty.show(j.responseJSON.text); - }, params, { - headers: { - token: account.token, - profile: account.profile.id - } - }); - } - } - - function updateBookmarks(rows, call) { - AppWorker.utils({ - type: 'account_bookmarks_parse', - data: rows - }, function (e) { - Storage.set('account_bookmarks', rows); - bookmarks = e.data; - if (call) call(); - listener$5.send('update_bookmarks', { - rows: rows, - bookmarks: e.data - }); - }); - } - - function notice(call) { - var account = Storage.get('account', '{}'); - - if (account.token && window.lampa_settings.account_use && window.lampa_settings.account_sync) { - if (notice_load.time + 1000 * 60 * 10 < Date.now()) { - network$6.timeout(1000); - network$6.silent(api$1() + 'notice/all', function (result) { - if (result.secuses) { - notice_load.time = Date.now(); - notice_load.data = result.notice; - Storage.set('account_notice', result.notice.map(function (n) { - return n; - })); - call(result.notice); - } else call(notice_load.data); - }, function () { - call(notice_load.data); - }, false, { - headers: { - token: account.token, - profile: account.profile.id - } - }); - } else call(notice_load.data); - } else call([]); - } - - function torrentViewed(data) { - network$6.timeout(5000); - network$6.silent(api$1() + 'torrent/viewing', false, false, data); - } - - function torrentPopular(data, secuses, error) { - network$6.timeout(5000); - network$6.silent(api$1() + 'torrent/popular', secuses, error, data); - } - - function backup() { - var account = Storage.get('account', '{}'); - - if (account.token) { - Select.show({ - title: Lang.translate('settings_cub_backup'), - nomark: true, - items: [{ - title: Lang.translate('settings_cub_backup_export'), - subtitle: Lang.translate('settings_cub_backup_export_descr'), - "export": true, - selected: true - }, { - title: Lang.translate('settings_cub_backup_import'), - subtitle: Lang.translate('settings_cub_backup_import_descr'), - "import": true - }, { - title: Lang.translate('cancel') - }], - onSelect: function onSelect(a) { - if (a["export"]) { - Select.show({ - title: Lang.translate('sure'), - nomark: true, - items: [{ - title: Lang.translate('confirm'), - "export": true, - selected: true - }, { - title: Lang.translate('cancel') - }], - onSelect: function onSelect(a) { - if (a["export"]) { - var file; - - try { - file = new File([JSON.stringify(localStorage)], "backup.json", { - type: "text/plain" - }); - } catch (e) {} - - if (!file) { - try { - file = new Blob([JSON.stringify(localStorage)], { - type: 'text/plain' - }); - file.lastModifiedDate = new Date(); - } catch (e) { - Noty.show(Lang.translate('account_export_fail')); - } - } - - if (file) { - var formData = new FormData($('
    ')[0]); - formData.append("file", file, "backup.json"); - var loader = $('
    '); - body$2.find('.settings--account-user-backup').append(loader); - $.ajax({ - url: api$1() + 'users/backup/export', - type: 'POST', - data: formData, - async: true, - cache: false, - contentType: false, - enctype: 'multipart/form-data', - processData: false, - headers: { - token: account.token - }, - success: function success(j) { - if (j.secuses) { - if (j.limited) showLimitedAccount();else Noty.show(Lang.translate('account_export_secuses')); - } else Noty.show(Lang.translate('account_export_fail')); - - loader.remove(); - }, - error: function error(e) { - Noty.show(Lang.translate('account_export_fail_' + (e.responseJSON.code || 500))); - loader.remove(); - } - }); - } - } - - Controller.toggle('settings_component'); - }, - onBack: function onBack() { - Controller.toggle('settings_component'); - } - }); - } else if (a["import"]) { - network$6.silent(api$1() + 'users/backup/import', function (data) { - if (data.data) { - var keys = Arrays.getKeys(data.data); - - for (var i in data.data) { - localStorage.setItem(i, data.data[i]); - } - - Noty.show(Lang.translate('account_import_secuses') + ' - ' + Lang.translate('account_imported') + ' (' + keys.length + ') - ' + Lang.translate('account_reload_after')); - setTimeout(function () { - window.location.reload(); - }, 5000); - } else Noty.show(Lang.translate('nodata')); - }, function () { - Noty.show(Lang.translate('account_import_fail')); - }, false, { - headers: { - token: account.token - } - }); - Controller.toggle('settings_component'); - } else { - Controller.toggle('settings_component'); - } - }, - onBack: function onBack() { - Controller.toggle('settings_component'); - } - }); - } - } - - function subscribes(params, secuses, error) { - var account = canSync(true); - - if (account) { - network$6.silent(api$1() + 'notifications/all', function (result) { - secuses({ - results: result.notifications.map(function (r) { - return Arrays.decodeJson(r.card, {}); - }) - }); - }, error, false, { - headers: { - token: account.token, - profile: account.profile.id - } - }); - } else error(); - } - - function showModal(template_name) { - var enabled = Controller.enabled().name; - Modal.open({ - title: '', - html: Template$1.get(template_name), - onBack: function onBack() { - Modal.close(); - Controller.toggle(enabled); - } - }); - } - - function showNoAccount() { - showModal('account'); - } - - function showLimitedAccount() { - showModal('account_limited'); - } - - function showCubPremium() { - var enabled = Controller.enabled().name; - Modal.open({ - title: '', - html: Template$1.get('cub_premium'), - onBack: function onBack() { - Modal.close(); - Controller.toggle(enabled); - } - }); - Modal.render().addClass('modal--cub-premium').find('.modal__content').before(''); - } - - function subscribeToTranslation() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var call = arguments.length > 1 ? arguments[1] : undefined; - var error = arguments.length > 2 ? arguments[2] : undefined; - var account = canSync(true); - - if (account && params.voice) { - network$6.timeout(5000); - network$6.silent(api$1() + 'notifications/add', function (result) { - if (result.limited) showLimitedAccount();else if (call) call(); - }, function () { - if (error) error(); - }, { - voice: params.voice, - data: JSON.stringify(params.card), - episode: params.episode, - season: params.season - }, { - headers: { - token: account.token - } - }); - } else if (error) error(); - } - - function logoff(data) { - var account = Storage.get('account', '{}'); - - if (account.token && account.email == data.email) { - Storage.set('account', ''); - Storage.set('account_use', false); - Storage.set('account_user', ''); - Storage.set('account_email', ''); - Storage.set('account_notice', ''); - Storage.set('account_bookmarks', ''); - $('.head .open--profile').addClass('hide'); - window.location.reload(); - } - } - - var Account = { - listener: listener$5, - init: init$i, - working: working, - canSync: canSync, - get: get$6, - all: all$2, - plugins: plugins, - notice: notice, - pluginsStatus: pluginsStatus, - showProfiles: showProfiles, - torrentViewed: torrentViewed, - torrentPopular: torrentPopular, - clear: clear$7, - update: update$4, - network: network$6, - backup: backup, - extensions: extensions, - subscribeToTranslation: subscribeToTranslation, - subscribes: subscribes, - showNoAccount: showNoAccount, - showCubPremium: showCubPremium, - showLimitedAccount: showLimitedAccount, - logged: logged, - removeStorage: function removeStorage() {}, - //устарело - logoff: logoff, - persons: persons, - addDiscuss: addDiscuss, - voiteDiscuss: voiteDiscuss - }; - Object.defineProperty(Account, 'hasPremium', { - value: function value() { - return checkPremium(); - }, - writable: false - }); - - var data$1 = {}; - var listener$4 = start$8(); - var category$2 = ['like', 'wath', 'book', 'history', 'look', 'viewed', 'scheduled', 'continued', 'thrown']; - var marks = ['look', 'viewed', 'scheduled', 'continued', 'thrown']; - - function save$2() { - Storage.set('favorite', data$1); - } - /** - * Добавить - * @param {String} where - * @param {Object} card - */ - - - function add$7(where, card, limit) { - read$1(); - var find = data$1[where].find(function (id) { - return id == card.id; - }); - - if (!find) { - Arrays.insert(data$1[where], 0, card.id); - listener$4.send('add', { - where: where, - card: card - }); - if (!search$3(card.id)) data$1.card.push(card); - - if (limit) { - var excess = data$1[where].slice(limit); - - for (var i = excess.length - 1; i >= 0; i--) { - remove$1(where, { - id: excess[i] - }); - } - } - - save$2(); - } else { - Arrays.remove(data$1[where], card.id); - Arrays.insert(data$1[where], 0, card.id); - save$2(); - listener$4.send('added', { - where: where, - card: card - }); - } - } - /** - * Удалить - * @param {String} where - * @param {Object} card - */ - - - function remove$1(where, card) { - read$1(); - Arrays.remove(data$1[where], card.id); - listener$4.send('remove', { - where: where, - card: card, - method: 'id' - }); - - for (var i = data$1.card.length - 1; i >= 0; i--) { - var element = data$1.card[i]; - - if (!check(element).any) { - Arrays.remove(data$1.card, element); - listener$4.send('remove', { - where: where, - card: element, - method: 'card' - }); - } - } - - save$2(); - } - /** - * Найти - * @param {Int} id - * @returns Object - */ - - - function search$3(id) { - var found; - - for (var index = 0; index < data$1.card.length; index++) { - var element = data$1.card[index]; - - if (element.id == id) { - found = element; - break; - } - } - - return found; - } - /** - * Переключить - * @param {String} where - * @param {Object} card - */ - - - function toggle$3(where, card) { - read$1(); - var find = cloud(card); - - if (marks.find(function (a) { - return a == where; - })) { - var added = marks.find(function (a) { - return find[a]; - }); - if (added && added !== where) remove$1(added, card); - } - - if (find[where]) remove$1(where, card);else add$7(where, card); - return find[where] ? false : true; - } - /** - * Проверить - * @param {Object} card - * @returns Object - */ - - - function check(card) { - var result = { - any: false - }; - category$2.forEach(function (a) { - result[a] = data$1[a].find(function (id) { - return id == card.id; - }); - if (result[a]) result.any = true; - }); - return result; - } - /** - * Проверить есть ли карточка где либо кроме истории - * @param {Object} status - * @returns {Boolean} - */ - - - function checkAnyNotHistory(status) { - var any = false; - category$2.filter(function (a) { - return a !== 'history'; - }).forEach(function (a) { - if (status[a]) any = true; - }); - return any; - } - /** - * Облако, закладки из cub - * @param {Object} card - * @returns {Object} - */ - - - function cloud(card) { - if (Account.working()) { - var result = { - any: true - }; - category$2.forEach(function (a) { - result[a] = Boolean(Account.get({ - type: a - }).find(function (elem) { - return elem.id == card.id; - })); - if (result[a]) result.any = true; - }); - return result; - } else return check(card); - } - /** - * Получить списаок по типу - * @param {String} params.type - тип - * @returns Object - */ - - - function get$5(params) { - if (Account.working()) { - return Account.get(params); - } else { - read$1(); - var result = []; - var ids = data$1[params.type]; - ids.forEach(function (id) { - for (var i = 0; i < data$1.card.length; i++) { - var card = data$1.card[i]; - if (card.id == id) result.push(card); - } - }); - return result; - } - } - /** - * Очистить - * @param {String} where - * @param {Object} card - */ - - - function clear$6(where, card) { - read$1(); - - if (Account.working()) { - Account.clear(where); - } else { - if (card) remove$1(where, card);else { - for (var i = data$1[where].length - 1; i >= 0; i--) { - var _card = search$3(data$1[where][i]); - - if (_card) remove$1(where, _card); - } - } - } - } - /** - * Считать последние данные - */ - - - function read$1() { - data$1 = Storage.get('favorite', '{}'); - var empty = { - card: [] - }; - category$2.forEach(function (a) { - empty[a] = []; - }); - Arrays.extend(data$1, empty); - } - /** - * Получить весь список что есть - */ - - - function full$2() { - var empty = { - card: [] - }; - category$2.forEach(function (a) { - empty[a] = []; - }); - Arrays.extend(data$1, empty); - return data$1; - } - - function all$1() { - var result = {}; - category$2.forEach(function (a) { - result[a] = get$5({ - type: a - }); - }); - return result; - } - - function continues(type) { - return Arrays.clone(get$5({ - type: 'history' - }).filter(function (e) { - return type == 'tv' ? e.number_of_seasons || e.first_air_date : !(e.number_of_seasons || e.first_air_date); - }).slice(0, 19)).map(function (e) { - e.check_new_episode = true; - return e; - }); - } - /** - * Запуск - */ - - - function init$h() { - read$1(); - } - - var Favorite = { - listener: listener$4, - check: cloud, - add: add$7, - remove: remove$1, - toggle: toggle$3, - get: get$5, - init: init$h, - clear: clear$6, - continues: continues, - full: full$2, - checkAnyNotHistory: checkAnyNotHistory, - all: all$1 - }; - - function Progress(need) { - var works = []; - var result = []; - var loaded = 0; - - this.append = function (call) { - if (Arrays.isArray(call)) works = works.concat(call);else if (typeof call == 'function') works.push(call); - }; - - this.start = function (complite) { - works.forEach(function (fun, i) { - fun(function (data) { - result[i] = data; - loaded++; - if (loaded == works.length) complite(result); - }); - }); - }; - } - - var baseurl = Utils$2.protocol() + 'tmdb.' + object$2.cub_domain + '/'; - var network$5 = new create$p(); - - function url$1(u) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - if (params.genres && u.indexOf('genre') == -1) u = add$6(u, 'genre=' + params.genres); - if (params.page) u = add$6(u, 'page=' + params.page); - if (params.query) u = add$6(u, 'query=' + params.query); - - if (params.filter) { - for (var i in params.filter) { - u = add$6(u, i + '=' + params.filter[i]); - } - } - - return baseurl + u; - } - - function add$6(u, params) { - return u + (/\?/.test(u) ? '&' : '?') + params; - } - - function get$4(method) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var oncomplite = arguments.length > 2 ? arguments[2] : undefined; - var onerror = arguments.length > 3 ? arguments[3] : undefined; - var u = url$1(method, params); - network$5.silent(u, function (json) { - json.url = method; - oncomplite(json); - }, onerror); - } - - function list$2() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - var u = url$1(params.url, params); - network$5.silent(u, oncomplite, onerror); - } - - function main$2() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - var parts_limit = 6; - var parts_data = [function (call) { - get$4('?sort=now_playing', params, function (json) { - json.title = Lang.translate('title_now_watch'); - call(json); - }, call); - }, function (call) { - call({ - results: TimeTable.lately().slice(0, 20), - title: Lang.translate('title_upcoming_episodes'), - nomore: true, - cardClass: function cardClass(_elem, _params) { - return new Episode(_elem, _params); - } - }); - }, function (call) { - get$4('?sort=latest', params, function (json) { - json.title = Lang.translate('title_latest'); - call(json); - }, call); - }, function (call) { - get$4('?cat=' + params.url + '&sort=latest&uhd=true', params, function (json) { - json.title = Lang.translate('title_in_high_quality'); - json.small = true; - json.wide = true; - json.results.forEach(function (card) { - card.promo = card.overview; - card.promo_title = card.title || card.name; - }); - call(json); - }, call); - }, function (call) { - get$4('movie/now', params, function (json) { - json.title = Lang.translate('menu_movies'); - call(json); - }, call); - }, function (call) { - trailers('added', call); - }, function (call) { - get$4('tv/now', params, function (json) { - json.title = Lang.translate('menu_tv'); - call(json); - }, call); - }, function (call) { - get$4('tv/popular', params, function (json) { - json.title = Lang.translate('title_popular_tv'); - call(json); - }, call); - }]; - Arrays.insert(parts_data, 0, Api.partPersons(parts_data, parts_limit, 'movie')); - TMDB.genres.movie.forEach(function (genre) { - var event = function event(call) { - get$4('?sort=now&genre=' + genre.id, params, function (json) { - json.title = Lang.translate(genre.title.replace(/[^a-z_]/g, '')); - call(json); - }, call); - }; - - parts_data.push(event); - }); - network$5.silent(Utils$2.protocol() + object$2.cub_domain + '/api/collections/roll', function (data) { - var rolls = data.results.filter(function (a) { - return a.type; - }); - var total = parts_data.length - (parts_limit + 3); - var offset = Math.round(total / rolls.length); - rolls.forEach(function (collection, index) { - Arrays.insert(parts_data, index + parts_limit + 3 + offset * index, function (call_inner) { - get$4('collections/' + collection.hpu, {}, function (json) { - json.title = collection.title; - json.collection = true; - json.line_type = 'collection'; - call_inner(json); - }, call_inner); - }); - }); - }); - - function loadPart(partLoaded, partEmpty) { - Api.partNext(parts_data, parts_limit, partLoaded, partEmpty); - } - - loadPart(oncomplite, onerror); - return loadPart; - } - - function category$1() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - var fullcat = !(params.genres || params.keywords); - var show = ['movie', 'tv'].indexOf(params.url) > -1 && !params.genres; - var books = show ? Favorite.continues(params.url) : []; - var recomend = show ? Arrays.shuffle(Recomends.get(params.url)).slice(0, 19) : []; - var airdate = params.url == 'anime' ? '&airdate=' + new Date().getFullYear() : ''; - var parts_limit = 6; - var parts_data = [function (call) { - var json = { - results: books, - title: params.url == 'tv' ? Lang.translate('title_continue') : Lang.translate('title_watched') - }; - - if (params.url == 'tv') { - json.ad = 'notice', json.type = params.url; - } - - call(json); - }, function (call) { - if (params.url == 'tv' || params.url == 'anime') { - call({ - results: TimeTable.lately().slice(0, 20), - title: Lang.translate('title_upcoming_episodes'), - nomore: true, - cardClass: function cardClass(_elem, _params) { - return new Episode(_elem, _params); - } - }); - } else { - call(); - } - }, function (call) { - call({ - results: recomend, - title: Lang.translate('title_recomend_watch') - }); - }, function (call) { - get$4('?cat=' + params.url + '&sort=now_playing' + airdate, params, function (json) { - json.title = Lang.translate('title_now_watch'); - - if (params.url == 'tv') { - json.ad = 'bot'; - json.type = params.url; - } - - call(json); - }, call); - }, function (call) { - if (params.url == 'anime') { - get$4('?cat=' + params.url + '&sort=top', params, function (json) { - json.title = Lang.translate('title_in_top'); - json.small = true; - json.wide = true; - json.results.forEach(function (card) { - card.promo = card.overview; - card.promo_title = card.title || card.name; - }); - call(json); - }, call); - } else { - get$4('?cat=' + params.url + '&sort=latest&uhd=true' + airdate, params, function (json) { - json.title = Lang.translate('title_in_high_quality'); - json.small = true; - json.wide = true; - json.results.forEach(function (card) { - card.promo = card.overview; - card.promo_title = card.title || card.name; - }); - call(json); - }, call); - } - }, function (call) { - if (params.url == 'tv' || params.url == 'anime') { - get$4('?cat=' + params.url + '&sort=airing' + airdate, params, function (json) { - json.title = Lang.translate('title_ongoing'); - call(json); - }, call); - } else call(); - }, function (call) { - get$4('?cat=' + params.url + '&sort=top' + airdate, params, function (json) { - json.title = Lang.translate('title_popular'); - call(json); - }, call); - }, function (call) { - get$4('?cat=' + params.url + '&sort=now', params, function (json) { - json.title = Lang.translate('title_new_this_year'); - call(json); - }, call); - }, function (call) { - if (params.url == 'movie' && fullcat) trailers('added', call);else call(); - }, function (call) { - get$4('?cat=' + params.url + '&sort=top&airdate=' + (new Date().getFullYear() - 1), params, function (json) { - json.title = Lang.translate('title_last_year'); - call(json); - }, call); - }, function (call) { - get$4('?cat=' + params.url + '&sort=top&airdate=' + (new Date().getFullYear() - 7) + '-' + (new Date().getFullYear() - 2) + '&vote=6-8', params, function (json) { - json.title = Lang.translate('title_worth_rewatch'); - call(json); - }, call); - }, function (call) { - get$4('?cat=' + params.url + '&sort=top&airdate=' + (new Date().getFullYear() - 7) + '-' + (new Date().getFullYear() - 2) + '&vote=8-10', params, function (json) { - json.title = Lang.translate('title_hight_voite'); - call(json); - }, call); - }]; - if (fullcat) Arrays.insert(parts_data, 0, Api.partPersons(parts_data, parts_limit + 3, params.url)); - - if (TMDB.genres[params.url]) { - TMDB.genres[params.url].forEach(function (genre) { - var gen = params.genres ? [].concat(params.genres, genre.id) : [genre.id]; - if (params.genres && params.genres == genre.id) return; - - var event = function event(call) { - get$4('?cat=' + params.url + '&sort=top&genre=' + gen.join(','), params, function (json) { - json.title = Lang.translate(genre.title.replace(/[^a-z_]/g, '')); - call(json); - }, call); - }; - - parts_data.push(event); - }); - - if (fullcat) { - network$5.silent(Utils$2.protocol() + object$2.cub_domain + '/api/collections/roll', function (data) { - var rolls = data.results.filter(function (a) { - return a.type == params.url; - }); - var total = parts_data.length - (parts_limit + 5); - var offset = Math.round(total / rolls.length); - rolls.forEach(function (collection, index) { - Arrays.insert(parts_data, index + parts_limit + 5 + offset * index, function (call_inner) { - get$4('collections/' + collection.hpu, {}, function (json) { - json.title = collection.title; - json.collection = true; - json.line_type = 'collection'; - call_inner(json); - }, call_inner); - }); - }); - }); - } - } else if (params.url == 'anime') { - TMDB.genres.tv.filter(function (a) { - return !(a.id == 99 || a.id == 10766); - }).forEach(function (genre) { - var event = function event(call) { - get$4('?cat=' + params.url + '&sort=top&genre=' + genre.id, params, function (json) { - json.title = Lang.translate(genre.title.replace(/[^a-z_]/g, '')); - call(json); - }, call); - }; - - parts_data.push(event); - }); - } - - function loadPart(partLoaded, partEmpty) { - Api.partNext(parts_data, parts_limit, partLoaded, partEmpty); - } - - loadPart(oncomplite, onerror); - return loadPart; - } - - function full$1(params, oncomplite, onerror) { - var status = new status$2(8); - status.onComplite = oncomplite; - if (Utils$2.dcma(params.method, params.id)) return onerror(); - TMDB.get(params.method + '/' + params.id + '?api_key=' + TMDB$1.key() + '&append_to_response=content_ratings,release_dates,keywords,alternative_titles&language=' + Storage.field('tmdb_lang'), params, function (json) { - json.source = 'tmdb'; - - if (params.method == 'tv') { - var season = Utils$2.countSeasons(json); - TMDB.get('tv/' + json.id + '/season/' + season, {}, function (ep) { - status.append('episodes', ep); - }, status.error.bind(status)); - } else status.need--; - - if (json.belongs_to_collection) { - TMDB.get('collection/' + json.belongs_to_collection.id, {}, function (collection) { - collection.results = collection.parts.slice(0, 19); - status.append('collection', collection); - }, status.error.bind(status)); - } else status.need--; - - status.append('movie', json); - }, function () { - status.need -= 2; - status.error(); - }); - TMDB.get(params.method + '/' + params.id + '/credits', params, function (json) { - status.append('persons', json); - }, status.error.bind(status)); - TMDB.get(params.method + '/' + params.id + '/recommendations', params, function (json) { - status.append('recomend', json); - }, status.error.bind(status)); - TMDB.get(params.method + '/' + params.id + '/similar', params, function (json) { - status.append('simular', json); - }, status.error.bind(status)); - TMDB.videos(params, function (json) { - status.append('videos', json); - }, status.error.bind(status)); - reactionsGet(params, function (json) { - status.append('reactions', json); - }); - - if (Lang.selected(['ru', 'uk', 'be'])) { - status.need++; - discussGet(params, function (json) { - status.append('discuss', json); - }, status.error.bind(status)); - } - } - - function trailers(type, oncomplite) { - network$5.silent(Utils$2.protocol() + object$2.cub_domain + '/api/trailers/short/trailers/' + type, function (result) { - result.wide = true; - result.small = true; - result.results.forEach(function (card) { - card.promo = card.overview; - card.promo_title = card.title || card.name; - }); - result.title = Lang.translate('title_trailers') + ' - ' + Lang.translate('title_new'); - oncomplite(result); - }, function () { - oncomplite({ - results: [] - }); - }); - } - - function reactionsGet(params, oncomplite) { - network$5.silent(Utils$2.protocol() + object$2.cub_domain + '/api/reactions/get/' + params.method + '_' + params.id, oncomplite, function () { - oncomplite({ - result: [] - }); - }); - } - - function discussGet(params, oncomplite, onerror) { - network$5.silent(Utils$2.protocol() + object$2.cub_domain + '/api/discuss/get/' + params.method + '_' + params.id + '/' + (params.page || 1) + '/' + Storage.field('language'), oncomplite, onerror); - } - - function reactionsAdd(params, oncomplite, onerror) { - network$5.silent(Utils$2.protocol() + object$2.cub_domain + '/api/reactions/add/' + params.method + '_' + params.id + '/' + params.type, oncomplite, onerror); - } - - function menuCategory$1(params, oncomplite) { - var menu = []; - menu.push({ - title: Lang.translate('title_now_watch'), - url: '?cat=' + params.action + '&sort=now_playing' - }); - - if (params.action == 'tv') { - menu.push({ - title: Lang.translate('title_new_episodes'), - url: '?cat=' + params.action + '&sort=update' - }); - } - - menu.push({ - title: Lang.translate('title_popular'), - url: '?cat=' + params.action + '&sort=top' - }); - menu.push({ - title: Lang.translate('title_latest'), - url: '?cat=' + params.action + '&sort=latest' - }); - menu.push({ - title: Lang.translate('title_new_this_year'), - url: '?cat=' + params.action + '&sort=now' - }); - menu.push({ - title: Lang.translate('title_hight_voite'), - url: '?cat=' + params.action + '&sort=latest&vote=7' - }); - oncomplite(menu); - } - - function search$2() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var status = new status$2(3); - - status.onComplite = function (data) { - var items = []; - if (data.movie && data.movie.results.length) items.push(data.movie); - if (data.tv && data.tv.results.length) items.push(data.tv); - if (data.anime && data.anime.results.length) items.push(data.anime); - oncomplite(items); - }; - - get$4('search/movie', params, function (json) { - json.title = Lang.translate('menu_movies'); - json.type = 'movie'; - status.append('movie', json); - }, status.error.bind(status)); - get$4('search/tv', params, function (json) { - json.title = Lang.translate('menu_tv'); - json.type = 'tv'; - status.append('tv', json); - }, status.error.bind(status)); - get$4('search/anime', params, function (json) { - json.title = Lang.translate('menu_anime'); - json.type = 'anime'; - status.append('anime', json); - }, status.error.bind(status)); - } - - function discovery() { - return { - title: 'CUB', - search: search$2, - params: { - align_left: true, - object: { - source: 'cub' - } - }, - onMore: function onMore(params) { - Activity$1.push({ - url: 'search/' + params.data.type, - title: Lang.translate('search') + ' - ' + params.query, - component: 'category_full', - page: 2, - query: encodeURIComponent(params.query), - source: 'cub' - }); - }, - onCancel: network$5.clear.bind(network$5) - }; - } - - function person$1(params, oncomplite, onerror) { - TMDB.person(params, oncomplite, onerror); - } - - function menu$1(params, oncomplite) { - TMDB.menu(params, oncomplite); - } - - function seasons$1(tv, from, oncomplite) { - TMDB.seasons(tv, from, oncomplite); - } - - function clear$5() { - network$5.clear(); - } - - var CUB = { - main: main$2, - menu: menu$1, - full: full$1, - list: list$2, - category: category$1, - clear: clear$5, - person: person$1, - seasons: seasons$1, - menuCategory: menuCategory$1, - discovery: discovery, - reactionsGet: reactionsGet, - reactionsAdd: reactionsAdd, - discussGet: discussGet - }; - - /** - * Источники - */ - - var sources = { - tmdb: TMDB, - cub: CUB - }; - /** - * Чтоб не переписали их - */ - - Object.defineProperty(sources, 'tmdb', { - get: function get() { - return TMDB; - } - }); - Object.defineProperty(sources, 'cub', { - get: function get() { - return CUB; - } - }); - var network$4 = new create$p(); - /** - * Получить источник - * @param {{source:string}} params - * @returns {class} - */ - - function source(params) { - return params.source && sources[params.source] ? sources[params.source] : sources.tmdb; - } - - function availableDiscovery() { - var list = []; - var active = Storage.get('source', 'tmdb'); - - for (var key in sources) { - console.log('Api', 'discovery check:', key, sources[key].discovery ? true : false, _typeof(sources[key].discovery)); - - if (sources[key].discovery) { - if (key === active) list.splice(0, 0, sources[key].discovery());else list.push(sources[key].discovery()); - } - } - - return list; - } - /** - * Главная страница - * @param {{source:string}} params - * @param {function} oncomplite - * @param {function} onerror - */ - - - function main$1() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - return source(params).main(params, oncomplite, onerror); - } - /** - * Категория - * @param {{url:string, source:string}} params - * @param {function} oncomplite - * @param {function} onerror - */ - - - function category() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - return source(params).category(params, oncomplite, onerror); - } - /** - * Просмотр карточки - * @param {{id:string, source:string, method:string, card:{}}} params - * @param {function} oncomplite - * @param {function} onerror - */ - - - function full() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - source(params).full(params, oncomplite, onerror); - } - /** - * Главный поиск - * @param {{query:string}} params - * @param {function} oncomplite - */ - - - function search$1() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - TMDB.search(params, function (json) { - var result = { - movie: json.find(function (a) { - return a.type == 'movie'; - }), - tv: json.find(function (a) { - return a.type == 'tv'; - }) - }; - oncomplite(result); - }, function () { - oncomplite({}); - }); - } - /** - * Что-то старое, надо проверить - * @param {object} params - * @param {function} oncomplite - */ - - - function menuCategory() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - source(params).menuCategory(params, oncomplite); - } - /** - * Информация об актёре - * @param {{id:integer, source:string}} params - * @param {function} oncomplite - * @param {function} onerror - */ - - - function person() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - source(params).person(params, oncomplite, onerror); - } - /** - * Жанры - * @param {object} params - * @param {function} oncomplite - * @param {function} onerror - */ - - - function genres() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - TMDB.genres(params, oncomplite, onerror); - } - /** - * Компания - * @param {{id:integer}} params - * @param {function} oncomplite - * @param {function} onerror - */ - - - function company() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - TMDB.company(params, oncomplite, onerror); - } - /** - * Полная категори - * @param {{page:integer, url:string, source:string}} params - * @param {function} oncomplite - * @param {function} onerror - */ - - - function list$1() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - source(params).list(params, oncomplite, onerror); - } - /** - * Получить список категорий для каталога в меню - * @param {{source:string}} params - * @param {function} oncomplite - */ - - - function menu() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - source(params).menu(params, oncomplite); - } - /** - * Сезоны - * @param {{id:integer, source:string}} tv - * @param {[1,2,3]} from - список сезонов 1,3,4... - * @param {function} oncomplite - */ - - - function seasons(tv, from, oncomplite) { - source(tv).seasons(tv, from, oncomplite); - } - /** - * Коллекции - * @param {object} params - * @param {function} oncomplite - * @param {function} onerror - */ - - - function collections(params, oncomplite, onerror) { - source(params).collections(params, oncomplite, onerror); - } - /** - * Закладки - * @param {{page:integer, type:string}} params - * @param {function} oncomplite - * @param {function} onerror - */ - - - function favorite() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - var data = {}; - data.results = Favorite.get(params); - data.total_pages = Math.ceil(data.results.length / 20); - data.page = Math.min(params.page, data.total_pages); - var offset = data.page - 1; - data.results = data.results.slice(20 * offset, 20 * offset + 20); - if (data.results.length) oncomplite(data);else onerror(); - } - /** - * Релизы - * @param {function} oncomplite - * @param {function} onerror - */ - - - function relise(params, oncomplite, onerror) { - network$4.silent(Utils$2.protocol() + 'tmdb.' + object$2.cub_domain + '?sort=releases&results=20&page=' + params.page, oncomplite, onerror); - } - - function partPersons(parts, parts_limit, type) { - return function (call) { - if (['movie', 'tv'].indexOf(type) == -1) return call(); - TMDB.get('/trending/person/day', {}, function (json) { - call(); - json.results.sort(function (a, b) { - return a.popularity - b.popularity; - }); - var filtred = json.results.filter(function (p) { - return p.known_for_department && p.known_for; - }); - var persons = filtred.filter(function (p) { - return (p.known_for_department || '').toLowerCase() == 'acting' && p.known_for.length && p.popularity > 30; - }).slice(0, 5); - var total = parts.length - parts_limit; - var offset = Math.round(total / persons.length); - persons.forEach(function (person_data, index) { - Arrays.insert(parts, index + parts_limit + offset * index, function (call_inner) { - person({ - only_credits: type, - id: person_data.id - }, function (result) { - if (!result.credits) return call_inner(); - var items = (result.credits[type] || []).filter(function (m) { - return m.backdrop_path && m.popularity > 30 && m.vote_count > 20; - }); - if (type == 'tv') items = items.filter(function (m) { - return !(m.genre_ids.indexOf(10767) >= 0 || m.genre_ids.indexOf(10763) >= 0); - }); - items.sort(function (a, b) { - var da = a.release_date || a.first_air_date; - var db = b.release_date || b.first_air_date; - if (db > da) return 1;else if (db < da) return -1;else return 0; - }); - var src = person_data.profile_path ? TMDB.img(person_data.profile_path, 'w90_and_h90_face') : person_data.img || './img/actor.svg'; - var icon = "
    \n
    \n \n
    \n \n
    \n
    ").concat(person_data.name, "
    \n
    \n
    "); - call_inner({ - results: items.length > 5 ? items.slice(0, 20) : [], - nomore: true, - title: icon - }); - }); - }); - }); - }, call); - }; - } - - function partNext(parts, parts_limit, partLoaded, partEmpty) { - var pieces = parts.filter(function (p) { - return typeof p == 'function'; - }).slice(0, 0 + parts_limit); - - if (pieces.length) { - var progress = new Progress(); - progress.append(pieces); - progress.start(function (result) { - var data = result.filter(function (r) { - return r && r.results && r.results.length; - }); - - for (var i = 0; i < pieces.length; i++) { - parts[parts.indexOf(pieces[i])] = false; - } - - if (data.length) { - if (data.length < 3) { - partNext(parts, parts_limit, function (more_data) { - data = data.concat(more_data); - partLoaded(data); - }, function () { - partLoaded(data); - }); - } else partLoaded(data); - } else partNext(parts, parts_limit, partLoaded, partEmpty); - }); - } else partEmpty(); - } - /** - * Очистить - */ - - - function clear$4() { - for (var i in sources) { - sources[i].clear(); - } - - network$4.clear(); - } - - var Api = { - main: main$1, - img: TMDB.img, - full: full, - list: list$1, - genres: genres, - category: category, - search: search$1, - clear: clear$4, - company: company, - person: person, - favorite: favorite, - seasons: seasons, - screensavers: TMDB.screensavers, - relise: relise, - menu: menu, - collections: collections, - menuCategory: menuCategory, - sources: sources, - availableDiscovery: availableDiscovery, - partPersons: partPersons, - partNext: partNext - }; - - function component$k(object) { - var comp = new Lampa.InteractionMain(object); - - comp.onLinesBuild = function (data) { - object$2.plugins.forEach(function (plugin) { - if (plugin.onMain) { - var result = plugin.onMain(data); - if (result.results.length) comp.append(result); - } - }); - }; - - comp.create = function () { - this.activity.loader(true); - var next = Api.main(object, this.build.bind(this), this.empty.bind(this)); - if (typeof next == 'function') this.next = next; - return this.render(); - }; - - return comp; - } - - var player; - var html$7; - var timer$1; - - function create$e(id) { - html$7 = $('
    '); - $('body').append(html$7); - player = new YT.Player('youtube-player', { - height: window.innerHeight, - width: window.innerWidth, - playerVars: { - 'controls': 0, - 'showinfo': 0, - 'autohide': 1, - 'modestbranding': 1, - 'autoplay': 1, - 'suggestedQuality': 'hd1080', - 'setPlaybackQuality': 'hd1080' - }, - videoId: id, - events: { - onReady: function onReady(event) { - event.target.setPlaybackQuality('hd1080'); - event.target.playVideo(); - update$3(); - }, - onStateChange: function onStateChange(state) { - if (state.data == 0) { - Controller.toggle('content'); - } - - if (state.data == YT.PlayerState.BUFFERING) { - state.target.setPlaybackQuality('hd1080'); - } - }, - onPlaybackQualityChange: function onPlaybackQualityChange(state) { - console.log('YouTube', 'quality', state.target.getPlaybackQuality()); - } - } - }); - } - - function update$3() { - timer$1 = setTimeout(function () { - var progress = player.getCurrentTime() / player.getDuration() * 100; - $('#youtube-player__progress').css('width', progress + '%'); - Screensaver$2.resetTimer(); - update$3(); - }, 400); - } - - function play(id) { - if (typeof YT == 'undefined') return; - create$e(id); - Controller.add('youtube', { - invisible: true, - toggle: function toggle() {}, - right: function right() { - player.seekTo(player.getCurrentTime() + 10, true); - }, - left: function left() { - player.seekTo(player.getCurrentTime() - 10, true); - }, - enter: function enter() {}, - gone: function gone() { - destroy$1(); - }, - back: function back() { - Controller.toggle('content'); - } - }); - Controller.toggle('youtube'); - } - - function destroy$1() { - clearTimeout(timer$1); - player.destroy(); - html$7.remove(); - html$7 = null; - } - - var YouTube = { - play: play - }; - - function Event() { - var ids = {}; - var evokes = {}; - - function callback(data) { - if (data.method == 'callback' && ids[data.callback_name] == data.callback_id) { - evokes[data.callback_id](data); - - evokes[data.callback_id] = function () {}; - } - } - - this.call = function (method, params, call) { - if (!ids[method]) ids[method] = Utils$2.uid(10); - params.callback_id = ids[method]; - params.callback_name = method; - evokes[params.callback_id] = call; - Socket.send('callback', params); - }; - - this.cancel = function (method) { - if (ids[method]) { - evokes[ids[method]] = function () {}; - } - }; - - this.destroy = function () { - Socket.listener.remove('message', callback); - - for (var i in evokes) { - evokes[i] = function () {}; - } - }; - - Socket.listener.follow('message', callback); - } - - function create$d(data) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var html; - var last; - var tbtn; - var self = this; - - var follow = function follow(e) { - if (e.name == 'parser_use') { - var status = Storage.field('parser_use'); - if (window.lampa_settings.torrents_use) tbtn.toggleClass('selector', status).toggleClass('hide', !status); - self.groupButtons(); - } - }; - - var buttons_scroll = new create$q({ - horizontal: true, - nopadding: false - }); - var load_images = { - poster: {} - }; - var event = new Event(); - var new_html = Storage.field('card_interfice_type') == 'new'; - Arrays.extend(data.movie, { - title: data.movie.name, - original_title: data.movie.original_name, - runtime: 0, - img: data.movie.poster_path ? Api.img(data.movie.poster_path, Storage.field('poster_size')).replace(/\/w200/, '/w500') : './img/img_broken.svg' - }); - - this.create = function () { - var _this = this; - - var genres = (data.movie.genres || ['---']).slice(0, 3).map(function (a) { - return Utils$2.capitalizeFirstLetter(a.name); - }).join(', '); - var countries = Api.sources.tmdb.parseCountries(data.movie); - var seasons = Utils$2.countSeasons(data.movie); - html = Template$1.get('full_start' + (new_html ? '_new' : ''), { - title: data.movie.title, - original_title: data.movie.original_title, - descr: Utils$2.substr(data.movie.overview || Lang.translate('full_notext'), 420), - time: Utils$2.secondsToTime(data.movie.runtime * 60, true), - genres: Utils$2.substr(genres, 30), - rating: parseFloat((data.movie.vote_average || 0) + '').toFixed(1), - seasons: seasons, - countries: countries.join(', '), - episodes: data.movie.number_of_episodes, - tagline: data.movie.tagline - }); - if (!window.lampa_settings.torrents_use) html.find('.view--torrent').addClass('hide'); - if (new_html && data.movie.name) html.find('.full-start-new__poster').addClass('card--tv').append('
    TV
    '); - var relise = (data.movie.release_date || data.movie.first_air_date || '') + ''; - var year = relise ? relise.slice(0, 4) : ''; - var quality = !data.movie.first_air_date ? data.movie.release_quality || data.movie.quality : false; - var head = []; - var info = []; - - if (year) { - html.find('.tag--year').removeClass('hide').find('> div').text(year); - head.push('' + year + ''); - } - - if (countries.length) { - head.push(countries.slice(0, 5).join(' | ')); - } - - if (!data.movie.tagline) { - html.find('.full--tagline').remove(); - } - - if (data.movie.runtime > 0) { - info.push('' + Utils$2.secondsToTime(data.movie.runtime * 60, true) + ''); - } - - if (quality) { - html.find('.tag--quality').removeClass('hide').find('> div').text(quality); - info.push('' + Lang.translate('player_quality') + ': ' + quality.toUpperCase() + ''); - } - - if (seasons) { - info.push('' + Lang.translate('title_seasons') + ': ' + seasons + ''); - } - - if (data.movie.number_of_episodes) { - info.push('' + Lang.translate('title_episodes') + ': ' + data.movie.number_of_episodes + ''); - } - - if (data.movie.genres) { - genres = data.movie.genres.slice(0, 5).map(function (a) { - return Utils$2.capitalizeFirstLetter(a.name); - }).join(' | '); - info.push('' + genres + ''); - } - - if (data.movie.number_of_seasons) { - html.find('.is--serial').removeClass('hide'); - } - - if (data.movie.vote_average == 0) { - html.find('.rate--tmdb').addClass('hide'); - } - - if (data.movie.imdb_rating && parseFloat(data.movie.imdb_rating) > 0) { - html.find('.rate--imdb').removeClass('hide').find('> div').eq(0).text(parseFloat(data.movie.imdb_rating) >= 10 ? 10 : data.movie.imdb_rating); - } - - if (data.movie.kp_rating && parseFloat(data.movie.kp_rating) > 0) { - html.find('.rate--kp').removeClass('hide').find('> div').eq(0).text(parseFloat(data.movie.kp_rating) >= 10 ? 10 : data.movie.kp_rating); - } - - if (!(data.movie.source == 'tmdb' || data.movie.source == 'cub')) html.find('.source--name').text(data.movie.source.toUpperCase());else if (data.movie.number_of_seasons) { - html.find('.button--subscribe').removeClass('hide'); - this.subscribed(); - } - - if (!new_html) { - $('.full-start__buttons-scroll', html).append(buttons_scroll.render()); - buttons_scroll.append($('.full-start__buttons', html)); - } - - if (!data.movie.runtime) $('.tag--time', html).remove(); - - if (data.movie.next_episode_to_air) { - var air = Utils$2.parseToDate(data.movie.next_episode_to_air.air_date); - var now = Date.now(); - var day = Math.ceil((air.getTime() - now) / (24 * 60 * 60 * 1000)); - var txt = Lang.translate('full_next_episode') + ': ' + Utils$2.parseTime(data.movie.next_episode_to_air.air_date)["short"] + ' / ' + Lang.translate('full_episode_days_left') + ': ' + day; - - if (day > 0) { - $('.tag--episode', html).removeClass('hide').find('div').text(txt); - info.push('' + txt + ''); - } - } - - if (data.movie.status) { - html.find('.full-start__status').removeClass('hide').text(Lang.translate('tv_status_' + data.movie.status.toLowerCase().replace(/ /g, '_'))); - } - - tbtn = html.find('.view--torrent'); - tbtn.on('hover:enter', function () { - var year = ((data.movie.first_air_date || data.movie.release_date || '0000') + '').slice(0, 4); - var combinations = { - 'df': data.movie.original_title, - 'df_year': data.movie.original_title + ' ' + year, - 'df_lg': data.movie.original_title + ' ' + data.movie.title, - 'df_lg_year': data.movie.original_title + ' ' + data.movie.title + ' ' + year, - 'lg': data.movie.title, - 'lg_year': data.movie.title + ' ' + year, - 'lg_df': data.movie.title + ' ' + data.movie.original_title, - 'lg_df_year': data.movie.title + ' ' + data.movie.original_title + ' ' + year - }; - Activity$1.push({ - url: '', - title: Lang.translate('title_torrents'), - component: 'torrents', - search: combinations[Storage.field('parse_lang')], - search_one: data.movie.title, - search_two: data.movie.original_title, - movie: data.movie, - page: 1 - }); - }); - html.find('.info__icon').not('[data-type="subscribe"]').on('hover:enter', function (e) { - var type = $(e.target).data('type'); - params.object.card = data.movie; - params.object.card.source = params.object.source; - Favorite.toggle(type, params.object.card); - - _this.favorite(); - }); - - if (!new_html) { - buttons_scroll.render().find('.selector').on('hover:focus', function () { - last = $(this)[0]; - buttons_scroll.update($(this), false); - }); - } else { - $('.full-start-new__buttons', html).find('.selector').on('hover:focus', function () { - last = $(this)[0]; - }); - } - - html.find('.full-start-new__head').toggleClass('hide', !head.length).html(head.join(', ')); - html.find('.full-start-new__details').html(info.join('')); - Storage.listener.follow('change', follow); - follow({ - name: 'parser_use' - }); - this.trailers(); - this.favorite(); - this.loadPoster(); - this.translations(); - this.bookmarks(); - this.reactions(); - var pg = Api.sources.tmdb.parsePG(data.movie); - if (pg) html.find('.full-start__pg').removeClass('hide').text(pg); - if (window.lampa_settings.read_only) html.find('.button--play').remove(); - }; - - this.setBtnInPriority = function (btn) { - var cont = html.find('.full-start-new__buttons'); - var clon = btn.clone(); - cont.find('.button--priority').remove(); - clon.addClass('button--priority').removeClass('view--torrent').on('hover:enter', function () { - btn.trigger('hover:enter'); - }).on('hover:long', function () { - clon.remove(); - Storage.set('full_btn_priority', ''); - last = html.find('.button--play')[0]; - Controller.toggle('full_start'); - }); - cont.prepend(clon); - }; - - this.vote = function (type, add) { - var mine = Storage.get('mine_reactions', {}); - var id = (data.movie.name ? 'tv' : 'movie') + '_' + data.movie.id; - if (!mine[id]) mine[id] = []; - var ready = mine[id].indexOf(type) >= 0; - - if (add) { - if (!ready) mine[id].push(type); - Storage.set('mine_reactions', mine); - } - - return ready; - }; - - this.reactions = function () { - var _this2 = this; - - if (!Storage.field('card_interfice_reactions')) return html.find('.full-start-new__reactions, .button--reaction').remove(); - - var drawReactions = function drawReactions() { - if (data.reactions && data.reactions.result && data.reactions.result.length) { - var reactions = data.reactions.result; - var reactions_body = html.find('.full-start-new__reactions')[0]; - reactions.sort(function (a, b) { - return a.counter > b.counter ? -1 : a.counter < b.counter ? 1 : 0; - }); - reactions_body.empty(); - reactions.forEach(function (r) { - var reaction = document.createElement('div'), - icon = document.createElement('img'), - count = document.createElement('div'), - wrap = document.createElement('div'); - reaction.addClass('reaction'); - icon.addClass('reaction__icon'); - count.addClass('reaction__count'); - reaction.addClass('reaction--' + r.type); - count.text(Utils$2.bigNumberToShort(r.counter)); - icon.src = Utils$2.protocol() + object$2.cub_domain + '/img/reactions/' + r.type + '.svg'; - reaction.append(icon); - reaction.append(count); - wrap.append(reaction); - if (_this2.vote(r.type)) reaction.addClass('reaction--voted'); - reactions_body.append(wrap); - }); - } - }; - - var items = [{ - type: 'fire' - }, { - type: 'nice' - }, { - type: 'think' - }, { - type: 'bore' - }, { - type: 'shit' - }]; - items.forEach(function (a) { - a.template = 'selectbox_icon', a.icon = ''; - a.ghost = _this2.vote(a.type); - a.noenter = a.ghost; - a.title = Lang.translate('reactions_' + a.type); - }); - html.find('.button--reaction').on('hover:enter', function () { - Select.show({ - title: Lang.translate('title_reactions'), - items: items, - onSelect: function onSelect(a) { - Controller.toggle('full_start'); - Api.sources.cub.reactionsAdd({ - method: data.movie.name ? 'tv' : 'movie', - id: data.movie.id, - type: a.type - }, function () { - _this2.vote(a.type, true); - - var find = data.reactions.result.find(function (r) { - return r.type == a.type; - }); - if (find) find.counter++;else { - data.reactions.result.push({ - type: a.type, - counter: 1 - }); - } - a.ghost = true; - a.noenter = true; - drawReactions(); - }, function (e) { - Lampa.Noty.show(Lang.translate('reactions_ready')); - }); - }, - onBack: function onBack() { - Controller.toggle('full_start'); - } - }); - }); - drawReactions(); - }; - - this.bookmarks = function () { - var _this3 = this; - - html.find('.button--book').on('hover:enter', function () { - var status = Favorite.check(params.object.card); - var items = [{ - title: Lang.translate('title_book'), - type: 'book', - checkbox: true, - checked: status.book - }, { - title: Lang.translate('title_like'), - type: 'like', - checkbox: true, - checked: status.like - }, { - title: Lang.translate('title_wath'), - type: 'wath', - checkbox: true, - checked: status.wath - }, { - title: Lang.translate('menu_history'), - type: 'history', - checkbox: true, - checked: status.history - }, { - title: Lang.translate('settings_cub_status'), - separator: true - }]; - var marks = ['look', 'viewed', 'scheduled', 'continued', 'thrown']; - - var label = function label(a) { - params.object.card = data.movie; - params.object.card.source = params.object.source; - Favorite.toggle(a.type, params.object.card); - if (a.collect) Controller.toggle('full_start'); - - _this3.favorite(); - }; - - marks.forEach(function (m) { - items.push({ - title: Lang.translate('title_' + m), - type: m, - picked: status[m], - collect: true, - noenter: !Account.hasPremium() - }); - }); - Select.show({ - title: Lang.translate('settings_input_links'), - items: items, - onCheck: label, - onSelect: label, - onBack: function onBack() { - Controller.toggle('full_start'); - }, - onDraw: function onDraw(item, elem) { - if (elem.collect) { - if (!Account.hasPremium()) { - var wrap = $('
    '); - wrap.append(Template$1.js('icon_lock')); - item.append(wrap); - item.on('hover:enter', function () { - Select.close(); - Account.showCubPremium(); - }); - } - } - } - }); - }); - }; - - this.groupButtons = function () { - var _this4 = this; - - var play = html.find('.button--play'); - var btns = html.find('.buttons--container > .full-start__button').not('.hide'); - var priority = Storage.get('full_btn_priority', '') + ''; - - if (priority) { - var priority_button; - btns.each(function () { - var hash = Utils$2.hash($(this).clone().removeClass('focus').prop('outerHTML')); - if (hash == priority) priority_button = $(this); - }); - if (priority_button) this.setBtnInPriority(priority_button); - } - - play.unbind().on('hover:enter', function (e) { - priority = Storage.get('full_btn_priority', '') + ''; - btns = html.find('.buttons--container > .full-start__button').not('.hide').filter(function () { - return priority !== Utils$2.hash($(this).clone().removeClass('focus').prop('outerHTML')); - }); - - if (btns.length == 1) { - btns.trigger('hover:enter'); - } else { - var items = []; - btns.each(function () { - var icon = $(this).find('svg').prop('outerHTML'); - items.push({ - title: $(this).text(), - subtitle: $(this).data('subtitle'), - template: typeof icon == 'undefined' || icon == 'undefined' ? 'selectbox_item' : 'selectbox_icon', - icon: icon, - btn: $(this) - }); - }); - Select.show({ - title: Lang.translate('settings_rest_source'), - items: items, - onSelect: function onSelect(a) { - a.btn.trigger('hover:enter'); - }, - onLong: function onLong(a) { - Storage.set('full_btn_priority', Utils$2.hash(a.btn.clone().removeClass('focus').prop('outerHTML'))); - - _this4.setBtnInPriority(a.btn); - }, - onBack: function onBack() { - Controller.toggle('full_start'); - } - }); - } - }).on('hover:focus', function () { - last = $(this)[0]; - }); - play.toggleClass('hide', !Boolean(btns.length)); - }; - - this.trailers = function () { - var _this5 = this; - - if (data.videos && data.videos.results.length) { - html.find('.view--trailer').on('hover:enter', function () { - var items = []; - data.videos.results.forEach(function (element) { - var date = Utils$2.parseTime(element.published_at).full; - items.push({ - title: Utils$2.shortText(element.name, 50), - subtitle: (element.official ? Lang.translate('full_trailer_official') : Lang.translate('full_trailer_no_official')) + ' - ' + date, - id: element.key, - player: element.player, - code: element.iso_639_1, - time: new Date(element.published_at).getTime(), - url: element.url || 'https://www.youtube.com/watch?v=' + element.key, - youtube: typeof element.youtube !== 'undefined' ? element.youtube : true, - icon: '', - template: 'selectbox_icon' - }); - }); - items.sort(function (a, b) { - return a.time > b.time ? -1 : a.time < b.time ? 1 : 0; - }); - var my_lang = items.filter(function (n) { - return n.code == Storage.field('tmdb_lang'); - }); - var en_lang = items.filter(function (n) { - return n.code == 'en' && my_lang.indexOf(n) == -1; - }); - var al_lang = []; - - if (my_lang.length) { - al_lang = al_lang.concat(my_lang); - } - - if (al_lang.length && en_lang.length) { - al_lang.push({ - title: Lang.translate('more'), - separator: true - }); - } - - al_lang = al_lang.concat(en_lang); - Select.show({ - title: Lang.translate('title_trailers'), - items: al_lang, - onSelect: function onSelect(a) { - _this5.toggle(); - - if (Platform.is('android') && Storage.field('player_launch_trailers') == 'youtube' && a.youtube) { - Android.openYoutube(a.id); - } else { - var playlist = al_lang.filter(function (v) { - return !v.separator; - }); - Player.play(a); - Player.playlist(playlist); - } - }, - onBack: function onBack() { - Controller.toggle('full_start'); - } - }); - }); - } else { - html.find('.view--trailer').remove(); - } - }; - - this.subscribed = function () { - event.call('subscribed', { - card_id: data.movie.id - }, function (result) { - if (result.result) { - html.find('.button--subscribe').data('voice', result.result).addClass('active').find('path').attr('fill', 'currentColor'); - } - }); - }; - - this.translations = function () { - var _this6 = this; - - var button = html.find('.button--subscribe'); - button.on('hover:enter', function () { - Loading.start(function () { - event.cancel('translations'); - Loading.stop(); - }); - event.call('translations', { - card_id: data.movie.id, - imdb_id: data.movie.imdb_id, - season: Utils$2.countSeasons(data.movie) - }, function (result) { - Loading.stop(); - - if (!result.result) { - result.result = { - voice: {}, - subscribe: '' - }; - } - - var items = []; - var subscribed = result.result.subscribe || button.data('voice'); - - if (subscribed) { - items.push({ - title: Lang.translate('title_unsubscribe'), - subtitle: subscribed, - unsubscribe: true - }); - } - - for (var voice in result.result.voice) { - items.push({ - title: voice, - voice: voice, - ghost: voice !== result.result.subscribe, - episode: result.result.voice[voice] - }); - } - - if (items.length) { - Select.show({ - title: Lang.translate('title_subscribe'), - items: items, - onSelect: function onSelect(a) { - _this6.toggle(); - - if (a.unsubscribe) { - event.call('unsubscribe', { - card_id: data.movie.id - }, function (result) { - if (result.result) { - button.removeClass('active').data('voice', '').find('path').attr('fill', 'transparent'); - } - }); - } else if (Account.logged()) { - Account.subscribeToTranslation({ - card: data.movie, - season: Utils$2.countSeasons(data.movie), - episode: a.episode, - voice: a.voice - }, function () { - Noty.show(Lang.translate('subscribe_success')); - button.addClass('active').data('voice', a.voice).find('path').attr('fill', 'currentColor'); - }, function () { - Noty.show(Lang.translate('subscribe_error')); - }); - } else { - Account.showNoAccount(); - } - }, - onBack: function onBack() { - Controller.toggle('full_start'); - } - }); - } else Noty.show(Lang.translate('subscribe_noinfo')); - }); - }); - }; - - this.loadPoster = function () { - var _this7 = this; - - var im = html.find('.full--poster'); - - if (window.innerWidth <= 480) { - load_images.poster = new Image(); - load_images.poster.crossOrigin = "Anonymous"; - } else load_images.poster = im[0] || {}; - - load_images.poster.onerror = function (e) { - load_images.poster.src = './img/img_broken.svg'; - }; - - load_images.poster.onload = function (e) { - im.parent().addClass('loaded'); - }; - - var poster; - - if (window.innerWidth <= 480) { - if (data.movie.backdrop_path) poster = Api.img(data.movie.backdrop_path, 'w1280');else if (data.movie.background_image) poster = data.movie.background_image; - - load_images.poster.onload = function (e) { - Color.blurPoster(load_images.poster, im.width(), im.height(), function (nim) { - im[0].src = nim.src; - im.parent().addClass('loaded'); - setTimeout(function () { - im[0].style.transition = 'none'; - }, 500); - - var sc = _this7.mscroll.render(true); - - var an = 0; - var ts = 0; - var dl = window.innerHeight * 0.1; - - var smoothParallax = function smoothParallax() { - im[0].style.transform = 'translate3d(0, ' + ts * 0.35 + 'px, 0)'; - im[0].style.opacity = ts >= dl ? Math.max(0, 1 - (ts - dl) / (window.innerHeight * 0.2)) : 1; - an--; - if (an > 0) smoothParallax(); - }; - - sc.addEventListener('scroll', function (e) { - ts = sc.scrollTop; - - if (an == 0) { - an = 100; - requestAnimationFrame(smoothParallax); - } - }); - }); - }; - } - - if (poster) html.find('.full-start__poster').addClass('background--poster'); - load_images.poster.src = poster || data.movie.img; - }; // this.loadPoster = function(){ - // let im = html.find('.full--poster') - // load_images.poster = im[0] || {} - // load_images.poster.onerror = function(e){ - // load_images.poster.src = './img/img_broken.svg' - // } - // load_images.poster.onload = function(e){ - // im.parent().addClass('loaded') - // im.after('') - // } - // let poster - // if(window.innerWidth <= 400){ - // if(data.movie.backdrop_path) poster = Api.img(data.movie.backdrop_path,'w1280') - // else if(data.movie.background_image) poster = data.movie.background_image - // } - // if(poster) html.find('.full-start__poster').addClass('background--poster') - // load_images.poster.src = poster || data.movie.img - // } - - - this.favorite = function () { - var status = Favorite.check(params.object.card); - var any = Favorite.checkAnyNotHistory(status); - $('.button--book path', html).attr('fill', any ? 'currentColor' : 'transparent'); - }; - - this.toggleBackground = function () { - Background.immediately(Utils$2.cardImgBackgroundBlur(data.movie)); - }; - - this.toggle = function () { - var _this8 = this; - - Controller.add('full_start', { - update: function update() {}, - toggle: function toggle() { - _this8.groupButtons(); - - var btns = html.find('.full-start__buttons > *').filter(function () { - return $(this).is(':visible'); - }); - Controller.collectionSet(_this8.render()); - Controller.collectionFocus(last || (btns.length ? btns.eq(0)[0] : false), _this8.render()); - if (_this8.onToggle) _this8.onToggle(_this8); - }, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - down: function down() { - if (Navigator.canmove('down')) Navigator.move('down');else _this8.onDown(); - }, - up: function up() { - if (Navigator.canmove('up')) Navigator.move('up'); - - _this8.onUp(); - }, - gone: function gone() {}, - back: this.onBack - }); - Controller.toggle('full_start'); - }; - - this.render = function () { - return html; - }; - - this.destroy = function () { - last = null; - buttons_scroll.destroy(); - event.destroy(); - - load_images.poster.onerror = function () {}; - - html.remove(); - Storage.listener.remove('change', follow); - }; - } - - function tag(name, items, call) { - var elem = $("
    \n
    ".concat(name, "
    \n
    ").concat(items.length, "
    \n
    ")); - elem.on('hover:enter', function () { - var select = items.map(function (a) { - return { - title: Utils$2.capitalizeFirstLetter(a.name), - elem: a - }; - }); - Select.show({ - title: name, - items: select, - onSelect: function onSelect(a) { - Controller.toggle('full_descr'); - call(a.elem); - }, - onBack: function onBack() { - Controller.toggle('full_descr'); - } - }); - }); - return elem; - } - - function create$c(data) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var html, body, last; - - this.create = function () { - html = Template$1.get('items_line', { - title: Lang.translate('full_detail') - }); - var media = data.movie.number_of_seasons ? 'tv' : 'movie'; - var countries = Api.sources.tmdb.parseCountries(data.movie); - var date = (data.movie.release_date || data.movie.first_air_date || '') + ''; - body = Template$1.get('full_descr', { - text: (data.movie.overview || Lang.translate('full_notext')) + '

    ', - relise: date.length > 3 ? Utils$2.parseTime(date).full : date.length > 0 ? date : Lang.translate('player_unknown'), - budget: '$ ' + Utils$2.numberWithSpaces(data.movie.budget || 0), - countries: countries.join(', ') - }); - var tags = body.find('.full-descr__tags'); - - if (data.movie.genres.length) { - tags.append(tag(Lang.translate('full_genre'), data.movie.genres, function (genre) { - Activity$1.push({ - url: genre.url || media, - title: Utils$2.capitalizeFirstLetter(genre.name), - component: params.object.source == 'cub' ? 'category' : 'category_full', - genres: genre.id, - source: params.object.source, - page: 1 - }); - })); - } - - if (data.movie.production_companies.length) { - tags.append(tag(Lang.translate('full_production'), data.movie.production_companies, function (company) { - Activity$1.push({ - url: company.url || media, - component: 'company', - title: Lang.translate('title_company'), - id: company.id, - source: params.object.source, - page: 1 - }); - })); - } - - var key_tags = data.movie.keywords ? data.movie.keywords.results || data.movie.keywords.keywords : []; - - if (key_tags.length) { - tags.append(tag(Lang.translate('full_keywords'), key_tags, function (key) { - Activity$1.push({ - url: 'discover/' + media, - title: Utils$2.capitalizeFirstLetter(key.name), - keywords: key.id, - component: 'category_full', - source: 'tmdb', - page: 1 - }); - })); - } - - if (!data.movie.budget) $('.full--budget', body).remove(); - if (!countries.length) $('.full--countries', body).remove(); - body.find('.selector').on('hover:focus', function (e) { - last = e.target; //this.onScroll(e.target) - }); - html.find('.items-line__body').append(body); - }; - - this.toggle = function () { - var _this = this; - - Controller.add('full_descr', { - toggle: function toggle() { - Controller.collectionSet(_this.render()); - Controller.collectionFocus(last, _this.render()); - if (_this.onToggle) _this.onToggle(_this); //if(last && !$(last).hasClass('full-descr__text')) this.onScroll(last) - }, - update: function update() {}, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - down: function down() { - if (Navigator.canmove('down')) Navigator.move('down');else _this.onDown(); - }, - up: function up() { - if (Navigator.canmove('up')) Navigator.move('up');else _this.onUp(); - }, - gone: function gone() {}, - back: this.onBack - }); - Controller.toggle('full_descr'); - }; - - this.render = function () { - return html; - }; - - this.destroy = function () { - body.remove(); - html.remove(); - html = null; - body = null; - }; - } - - function create$b(persons, params) { - var html, scroll, last; - var active = 0; - var view = 6; - var tv = Platform.screen('tv'); - - this.create = function () { - var _this = this; - - if (persons.length > 50) persons = persons.slice(0, 50); - html = Template$1.get('items_line', { - title: params.title || Lang.translate('title_actors') - }); - scroll = new create$q({ - horizontal: true, - scroll_by_item: true - }); - scroll.body().addClass('full-persons'); - persons.slice(0, view).forEach(this.append.bind(this)); - html.find('.items-line__body').append(scroll.render()); - - scroll.onWheel = function (step) { - _this.toggle(); - - Controller.enabled().controller[step > 0 ? 'right' : 'left'](); - }; - - scroll.onScroll = function (step) { - persons.slice(active, tv ? active + view : persons.length).filter(function (e) { - return !e.ready; - }).forEach(function (line_data) { - Controller.collectionAppend(_this.append(line_data)); - }); - Layer.visible(scroll.render(true)); - }; - }; - - this.append = function (element) { - element.ready = true; - var person = Template$1.get('full_person', { - name: element.name, - role: element.character || element.job - }); - person.on('visible', function () { - var img = person.find('img')[0]; - - img.onerror = function (e) { - img.src = './img/actor.svg'; - }; - - img.onload = function () { - person.addClass('full-person--loaded'); - }; - - img.src = element.profile_path ? Api.img(element.profile_path, 'w276_and_h350_face') : element.img || './img/actor.svg'; - }); - person.on('hover:focus', function (e) { - last = e.target; - active = persons.indexOf(element); - scroll.update($(e.target), true); - }).on('hover:enter', function () { - Activity$1.push({ - url: element.url, - title: Lang.translate('title_persons'), - component: 'actor', - id: element.id, - source: params.object.source - }); - }); - scroll.append(person); - return person; - }; - - this.toggle = function () { - var _this2 = this; - - Controller.add('full_descr', { - link: this, - toggle: function toggle() { - Controller.collectionSet(_this2.render()); - Controller.collectionFocus(last, _this2.render()); - if (_this2.onToggle) _this2.onToggle(_this2); - }, - update: function update() {}, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - down: this.onDown, - up: this.onUp, - gone: function gone() {}, - back: this.onBack - }); - Controller.toggle('full_descr'); - }; - - this.render = function () { - return html; - }; - - this.destroy = function () { - scroll.destroy(); - html.remove(); - html = null; - }; - } - - function create$a() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - Arrays.extend(params, { - title: Lang.translate('empty_title_two'), - descr: Lang.translate('empty_text_two') - }); - var html = Template$1.get('empty', params); - - this.start = function () { - Controller.add('content', { - toggle: function toggle() { - var selects = html.find('.selector').filter(function () { - return !$(this).hasClass('empty__img'); - }); - html.find('.empty__img').toggleClass('selector', selects.length > 0 ? false : true); - Controller.collectionSet(html); - Controller.collectionFocus(selects.length > 0 ? selects.eq(0)[0] : false, html); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - up: function up() { - if (Navigator.canmove('up')) Navigator.move('up');else Controller.toggle('head'); - }, - down: function down() { - Navigator.move('down'); - }, - right: function right() { - Navigator.move('right'); - }, - back: function back() { - Activity$1.backward(); - } - }); - Controller.toggle('content'); - }; - - this.append = function (add) { - html.append(add); - }; - - this.render = function (add) { - if (typeof add == 'boolean') return html[0]; - if (add) html.append(add); - return html; - }; - } - - var Review = /*#__PURE__*/function () { - function Review(element) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - _classCallCheck(this, Review); - - Arrays.extend(params, { - type: 'line' - }); - this.element = element; - this.params = params; - } - - _createClass(Review, [{ - key: "create", - value: function create() { - var _this = this; - - var text = (this.element.text || this.element.comment) + ''; - text = Utils$2.capitalizeFirstLetter(this.params.type == 'line' && text.length > 120 ? text.slice(0, 120) + '...' : text); - this.html = Template$1.get('full_review', _objectSpread2(_objectSpread2({}, this.element), {}, { - text: text - })); - this.html.addClass('type--' + this.params.type); - if (this.element.liked < 0) this.html.addClass('bad--comment'); - - if (this.element.email) { - var who = $("
    \n
    \n \n
    \n
    ".concat(Utils$2.capitalizeFirstLetter(this.element.email), "
    \n
    ")); - var like = $("
    \n \n \n
    ")); - this.html.find('.full-review__footer').html(who).append(like); - this.html.on('visible', function () { - var img = who.find('img')[0]; - Utils$2.imgLoad(img, Utils$2.protocol() + object$2.cub_domain + '/img/profiles/' + _this.element.icon + '.png', function () { - who.addClass('loaded'); - }, function () { - img.src = './img/actor.svg'; - }); - }); - } - } - }, { - key: "updateLike", - value: function updateLike(add) { - this.element.liked = (this.element.liked || 0) + add; - this.html.find('.full-review__like-counter').text(this.element.liked); - } - }, { - key: "render", - value: function render() { - return this.html; - } - }, { - key: "destroy", - value: function destroy() { - this.html.remove(); - } - }]); - - return Review; - }(); - - function create$9(data) { - var html, scroll, last; - var active = 0; - var view = 6; - var tv = Platform.screen('tv'); - - this.create = function () { - var _this = this; - - html = Template$1.get('items_line', { - title: Lang.translate('title_comments') - }); - scroll = new create$q({ - horizontal: true - }); - scroll.render().find('.scroll__body').addClass('full-reviews'); - html.find('.items-line__body').append(scroll.render()); - data.comments.slice(0, view).forEach(this.append.bind(this)); - - scroll.onWheel = function (step) { - _this.toggle(); - - Controller.enabled().controller[step > 0 ? 'right' : 'left'](); - }; - - scroll.onScroll = function (step) { - data.comments.slice(active, tv ? active + view : data.comments.length).filter(function (e) { - return !e.ready; - }).forEach(function (line_data) { - Controller.collectionAppend(_this.append(line_data)); - }); - Layer.visible(scroll.render(true)); - }; - }; - - this.append = function (element) { - element.ready = true; - var review = new Review(element); - review.create(); - review.render().on('hover:focus', function (e) { - last = e.target; - active = data.comments.indexOf(element); - scroll.update($(e.target), true); - }); - scroll.append(review.render()); - return review.render(); - }; - - this.toggle = function () { - var _this2 = this; - - Controller.add('full_reviews', { - link: this, - toggle: function toggle() { - Controller.collectionSet(_this2.render()); - Controller.collectionFocus(last, _this2.render()); - if (_this2.onToggle) _this2.onToggle(_this2); - }, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - down: this.onDown, - up: this.onUp, - gone: function gone() {}, - back: this.onBack - }); - Controller.toggle('full_reviews'); - }; - - this.render = function () { - return html; - }; - } - - function Discuss(data) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var html, scroll, last, all_ready, rules_html; - var active = 0; - var view = 6; - var tv = Platform.screen('tv'); - - this.create = function () { - var _this = this; - - html = Template$1.get('items_line', { - title: Lang.translate('title_comments') - }); - scroll = new create$q({ - horizontal: true - }); - scroll.render().find('.scroll__body').addClass('full-reviews'); - html.find('.items-line__body').append(scroll.render()); - this.add(); - data.discuss.result.slice(0, view).forEach(this.append.bind(this)); - - scroll.onWheel = function (step) { - _this.toggle(); - - Controller.enabled().controller[step > 0 ? 'right' : 'left'](); - }; - - scroll.onScroll = function (step) { - data.discuss.result.slice(active, tv ? active + view : data.discuss.result.length).filter(function (e) { - return !e.ready; - }).forEach(function (line_data) { - Controller.collectionAppend(_this.append(line_data)); - }); - - if ((tv || active + view >= data.discuss.result.length) && !all_ready && data.discuss.total_pages > 1) { - all_ready = true; - - _this.all(); - } - - Layer.visible(scroll.render(true)); - }; - }; - - this.rules = function () { - rules_html = Template$1.get('discuss_rules'); - $('body').append(rules_html); - }; - - this.filter = function (text) { - var err = 0; - - function containsLongWords(str) { - var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 15; - var any = false; - str.split(/\s/).map(function (a) { - if (a.length >= length) any = true; - }); - return any; - } - - function containsFiveWords(str) { - var words = str.split(/\s/); - var count = 0; - words.map(function (a) { - if (a.length >= 5) count++; - }); - return count; - } - - if (/\d{4,}/g.test(text)) err = 1;else if (!/[а-яА-ЯёЁ]{5,}/.test(text)) err = 2;else if (!/[.,:;!?]/.test(text)) err = 3;else if (/[*%$#_+=|^&]/.test(text)) err = 4;else if (containsFiveWords(text) < 5) err = 5;else if (containsLongWords(text)) err = 6;else if (text.length > 300) err = 7; - return err; - }; - - this.add = function () { - var _this2 = this; - - var add_button = $('
    '); - var add_value = ''; - add_button.on('hover:enter', function () { - if (Account.logged()) { - if (!Account.hasPremium()) return Account.showCubPremium(); - - _this2.rules(); - - var keyboard = Input.edit({ - title: '', - value: add_value, - nosave: true - }, function (new_value) { - rules_html.remove(); - add_value = new_value; - - if (new_value) { - Account.addDiscuss(_objectSpread2(_objectSpread2({}, params.object), {}, { - comment: new_value - }), function (comment) { - add_button.after(_this2.append(comment)); - Layer.visible(scroll.render(true)); - }); - } - - _this2.toggle(); - }); - var keypad = $('.simple-keyboard'); - var helper = $('
    '); - - if (keypad.hasClass('simple-keyboard--with-textarea')) { - keypad.append(helper); - keyboard.listener.follow('change', function (event) { - var code = _this2.filter(event.value.trim()); - - helper.toggleClass('hide', !Boolean(code)).text(Lang.translate('discuss_rules_rule_' + code)); - }); - } - } else { - Lampa.Account.showNoAccount(); - } - }).on('hover:focus hover:touch', function (e) { - last = e.target; - scroll.update($(e.target), true); - }); - scroll.append(add_button); - }; - - this.all = function () { - var _this3 = this; - - var all_button = $('
    ' + Lang.translate('more') + '
    ' + (data.discuss.total - data.discuss.result.length) + '
    '); - all_button.on('hover:enter', function () { - var page = 2; - var discuss = []; - var wait = false; - var position = 0; - var container = $('
    '); - - var draw = function draw() { - Modal.scroll().reset(); - container.empty(); - discuss.forEach(function (element) { - var review = new Review(element, { - type: 'vertical' - }); - review.create(); - review.render().on('hover:focus hover:touch', function (e) { - position = discuss.indexOf(element); - }).on('hover:enter', function () { - _this3.see(review, Modal.toggle); - }); - container.append(review.render()); - }); - if (data.discuss.total_pages !== page) container.append($('
    ')); - Modal.update(container); - Modal.toggle(); - }; - - var load = function load() { - CUB.discussGet(_objectSpread2(_objectSpread2({}, params.object), {}, { - page: page - }), function (anser) { - wait = false; - discuss = discuss.slice(position, discuss.length).concat(anser.result); - position = 0; - draw(); - }, function () { - page--; - wait = false; - }); - }; - - Modal.open({ - title: Lang.translate('title_comments'), - html: container, - size: 'medium', - onBack: function onBack() { - Modal.close(); - - draw = function draw() {}; - - load = function load() {}; - - _this3.toggle(); - } - }); - - Modal.scroll().onEnd = function () { - if (!wait && page < data.discuss.total_pages) { - wait = true; - page++; - load(); - } - }; - - Modal.scroll().params().end_ratio = 1.5; - setTimeout(load, 200); //задержка для анимации окна - }); - scroll.append(all_button); - }; - - this.see = function (review, onBack) { - var items = []; - var voited = Storage.cache('discuss_voited', 100, []); - - if (voited.indexOf(review.element.id) == -1 && Account.logged()) { - items = [{ - separator: true, - title: Lang.translate('title_action') - }, { - title: '+1 ' + Lang.translate('title_like'), - like: 1 - }, { - title: Lang.translate('reactions_shit'), - like: -1 - }]; - } - - Select.show({ - title: Utils$2.capitalizeFirstLetter(review.element.email), - items: items, - onFullDraw: function onFullDraw(select_scroll) { - select_scroll.body().prepend($('
    ' + Utils$2.capitalizeFirstLetter(review.element.comment) + '
    ')); - }, - onSelect: function onSelect(item) { - onBack(); - Account.voiteDiscuss({ - id: review.element.id, - like: item.like - }, function () { - voited.push(review.element.id); - Storage.set('discuss_voited', voited); - review.updateLike(item.like); - Noty.show(Lang.translate('discuss_voited')); - }); - }, - onBack: onBack - }); - }; - - this.append = function (element) { - var _this4 = this; - - element.ready = true; - var review = new Review(element); - review.create(); - review.render().on('hover:focus', function (e) { - last = e.target; - active = data.discuss.result.indexOf(element); - scroll.update($(e.target), true); - }).on('hover:touch', function (e) { - active = data.discuss.result.indexOf(element); - last = e.target; - }).on('hover:enter', function () { - _this4.see(review, _this4.toggle.bind(_this4)); - }); - scroll.append(review.render()); - return review.render(); - }; - - this.toggle = function () { - var _this5 = this; - - Controller.add('full_reviews', { - link: this, - toggle: function toggle() { - Controller.collectionSet(_this5.render()); - Controller.collectionFocus(last, _this5.render()); - if (_this5.onToggle) _this5.onToggle(_this5); - }, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - down: this.onDown, - up: this.onUp, - gone: function gone() {}, - back: this.onBack - }); - Controller.toggle('full_reviews'); - }; - - this.render = function () { - return html; - }; - } - - function create$8(data) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var html, scroll, last; - var view = 6; - var tv = Platform.screen('tv'); - var active = 0; - - this.create = function () { - var _this = this; - - html = Template$1.get('items_line', { - title: params.season.name || Lang.translate('full_series_release') - }); - scroll = new create$q({ - horizontal: true - }); - scroll.render().find('.scroll__body').addClass('full-episodes'); - - scroll.onWheel = function (step) { - if (!Controller.own(_this)) _this.toggle(); - Controller.enabled().controller[step > 0 ? 'right' : 'left'](); - }; - - scroll.onScroll = function (step) { - data.slice(active, tv ? active + view : data.length).filter(function (e) { - return !e.ready; - }).forEach(function (elem) { - Controller.collectionAppend(_this.append(elem)); - }); - Layer.visible(scroll.render(true)); - }; - - html.find('.items-line__body').append(scroll.render()); - data.reverse(); - data.forEach(function (episode, num) { - return episode.episode_number = episode.episode_number || num + 1; - }); - var wath_all = Template$1.get('full_episode', { - name: Lang.translate('more') - }); - wath_all.addClass('full-episode--wath-all'); - wath_all.on('hover:enter', function () { - Activity$1.push({ - url: '', - title: Lang.translate('title_episodes'), - component: 'episodes', - movie: params.movie, - page: 1 - }); - }); - scroll.append(wath_all); - data.slice(0, view).forEach(this.append.bind(this)); - }; - - this.append = function (element) { - element.ready = true; - element.date = element.air_date ? Utils$2.parseTime(element.air_date).full : '----'; - element.num = element.episode_number; - var episode = Template$1.get('full_episode', element); - var hash = Utils$2.hash([element.season_number, element.season_number > 10 ? ':' : '', element.episode_number, params.title].join('')); - var view = Timeline.view(hash); - episode.append('
    ' + Template$1.get('icon_viewed', {}, true) + '
    '); - episode.toggleClass('full-episode--viewed', Boolean(view.percent)); - - if (element.plus) { - episode.addClass('full-episode--next'); - } - - episode.on('visible', function () { - var img = episode.find('img')[0]; - - img.onerror = function (e) { - img.src = './img/img_broken.svg'; - }; - - img.onload = function () { - episode.addClass('full-episode--loaded'); - }; - - if (element.still_path) img.src = Api.img(element.still_path, 'w300');else if (element.img) img.src = element.img;else img.src = './img/img_broken.svg'; - }); - episode.on('hover:focus', function (e) { - last = e.target; - active = data.indexOf(element); - scroll.update($(e.target), true); - }).on('hover:enter', function () { - if (element.overview) { - Modal.open({ - title: element.name, - html: $('
    ' + element.overview + '
    '), - onBack: function onBack() { - Modal.close(); - Controller.toggle('content'); - }, - onSelect: function onSelect() { - Modal.close(); - Controller.toggle('content'); - } - }); - } - }).on('hover:long', function () { - if (Boolean(view.percent)) { - view.time = 0; - view.percent = 0; - } else { - view.time = view.duration * 0.95; - view.percent = 95; - } - - Timeline.update(view); - episode.toggleClass('full-episode--viewed', Boolean(view.percent)); - }); - scroll.append(episode); - return episode; - }; - - this.toggle = function () { - var _this2 = this; - - Controller.add('full_episodes', { - link: this, - toggle: function toggle() { - Controller.collectionSet(_this2.render()); - Controller.collectionFocus(last, _this2.render()); - if (_this2.onToggle) _this2.onToggle(_this2); - }, - update: function update() {}, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - down: this.onDown, - up: this.onUp, - gone: function gone() {}, - back: this.onBack - }); - Controller.toggle('full_episodes'); - }; - - this.render = function () { - return html; - }; - } - - var components$1 = { - start: create$d, - descr: create$c, - persons: create$b, - recomend: create$h, - simular: create$h, - discuss: Discuss, - comments: create$9, - episodes: create$8 - }; - - function component$j(object) { - var network = new create$p(); - var scroll = new create$q({ - mask: true, - over: true, - step: 400, - scroll_by_item: false - }); - var items = []; - var create = []; - var active = 0; - var tv = Platform.screen('tv'); - var html = $('
    '); - var background_image; - var loaded_data; - - this.create = function () { - var _this = this; - - this.activity.loader(true); - - if (object.source == 'tmdb' && Storage.field('source') == 'cub') { - object.source = 'cub'; - } - - scroll.minus(); - - scroll.onWheel = function (step) { - if (step > 0) _this.down();else if (active > 0) _this.up(); - }; - - scroll.onScroll = this.visible.bind(this); - html.append(scroll.render()); - Api.full(object, function (data) { - if (data.movie && data.movie.blocked) { - _this.empty(); - } else if (data.movie) { - loaded_data = data; - if (Activity$1.active().activity == _this.activity) Activity$1.active().card = data.movie; //для плагинов которые используют Activity.active().card - - Lampa.Listener.send('full', { - type: 'start', - object: object, - data: data - }); - - _this.build('start', data); - - _this.build('descr', data); - - if (data.episodes && data.episodes.episodes) { - var today = new Date(); - var date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate(); - var time = Utils$2.parseToDate(date).getTime(); - var plus = false; - var cameout = data.episodes.episodes.filter(function (a) { - return a.air_date; - }).filter(function (e) { - var air = Utils$2.parseToDate(e.air_date).getTime(); - if (air <= time) return true;else if (!plus) { - plus = true; - e.plus = true; - return true; - } - return false; - }); - - _this.build('episodes', cameout, { - title: data.movie.original_title || data.movie.original_name, - season: data.episodes, - movie: data.movie - }); - } - - if (data.persons && data.persons.crew && data.persons.crew.length) { - var directors = data.persons.crew.filter(function (member) { - return member.job === 'Director'; - }); - - if (directors.length) { - _this.build('persons', directors, { - title: Lang.translate('title_producer') - }); - } - } - - if (data.persons && data.persons.cast && data.persons.cast.length) _this.build('persons', data.persons.cast); - if (data.discuss) _this.build('discuss', data);else if (data.comments && data.comments.length) _this.build('comments', data); - - if (data.collection && data.collection.results.length) { - data.collection.title = Lang.translate('title_collection'); - data.collection.noimage = true; - - _this.build('recomend', data.collection); - } - - if (data.recomend && data.recomend.results.length) { - data.recomend.title = Lang.translate('title_recomendations'); - data.recomend.noimage = true; - - _this.build('recomend', data.recomend); - } - - if (data.simular && data.simular.results.length) { - data.simular.title = Lang.translate('title_similar'); - data.simular.noimage = true; - - _this.build('simular', data.simular); - } - - TimeTable.update(data.movie); - - _this.visible(); - - Lampa.Listener.send('full', { - type: 'complite', - object: object, - data: data - }); - - _this.loadBackground(data); - - _this.activity.toggle(); - - _this.activity.loader(false); - - Layer.update(html); - } else { - _this.empty(); - } - }, this.empty.bind(this)); - return this.render(); - }; - - this.empty = function () { - var button; - - if (object.source == 'tmdb') { - button = $(''); - button.find('.selector').on('hover:enter', function () { - Storage.set('source', 'cub'); - Activity$1.replace({ - source: 'cub' - }); - }); - } - - var empty = new create$a(); - scroll.append(empty.render(button)); - this.start = empty.start; - this.activity.loader(false); - this.activity.toggle(); - }; - - this.build = function (name, data, params) { - var _this2 = this; - - create.push({ - created: false, - create: function create() { - var item = new components$1[name](data, _objectSpread2({ - object: object, - nomore: true - }, params)); - item.mscroll = scroll; - item.onDown = _this2.down.bind(_this2); - item.onUp = _this2.up.bind(_this2); - item.onBack = _this2.back.bind(_this2); - - item.onToggle = function () { - active = items.indexOf(item); - }; - - item.onScroll = function (e, center) { - scroll.update(e, center); - }; - - item.create(); - items.push(item); - Lampa.Listener.send('full', { - type: 'build', - name: name, - body: item.render() - }); - scroll.append(item.render()); - return item.render(); - } - }); - }; - - this.visible = function (position) { - create.slice(0, tv ? active + 3 : create.length).filter(function (e) { - return !e.created; - }).forEach(function (e) { - e.created = true; - e.create(); - }); //фиг знает, с задержкой все четко заработало - - setTimeout(function () { - Layer.visible(scroll.render(true)); - }, 100); - this.toggleBackgroundOpacity(position); - }; - - this.down = function () { - active++; - active = Math.min(active, items.length - 1); - - if (items[active]) { - items[active].toggle(); - scroll.update(items[active].render()); - } - }; - - this.up = function () { - active--; - - if (active < 0) { - active = 0; - Controller.toggle('head'); - } else { - items[active].toggle(); - scroll.update(items[active].render()); - } - }; - - this.toggleBackgroundOpacity = function (position) { - if (background_image) { - html.find('.full-start__background').toggleClass('dim', position > 0); - } - }; - - this.back = function () { - Activity$1.backward(); - }; - - this.loadBackground = function (data) { - var background = data.movie.backdrop_path ? Api.img(data.movie.backdrop_path, 'w1280') : data.movie.background_image ? data.movie.background_image : ''; - - if (window.innerWidth > 790 && background && !Storage.field('light_version') && Storage.field('background_type') !== 'poster') { - background_image = html.find('.full-start__background')[0] || {}; - - background_image.onload = function (e) { - html.find('.full-start__background').addClass('loaded'); - }; - - background_image.src = background; - } else html.find('.full-start__background').remove(); - }; - - this.start = function () { - if (items.length && Activity$1.active().activity == this.activity) { - if (loaded_data) Activity$1.active().card = loaded_data.movie; //на всякий пожарный :D - - items[0].toggleBackground(); - } - - Controller.add('content', { - update: function update() {}, - toggle: function toggle() { - if (items.length) { - items[active].toggle(); - } else { - Controller.collectionSet(scroll.render()); - Controller.collectionFocus(false, scroll.render()); - } - }, - left: function left() { - Controller.toggle('menu'); - }, - up: function up() { - Controller.toggle('head'); - }, - back: function back() { - Activity$1.backward(); - } - }); - Controller.toggle('content'); - }; - - this.pause = function () {}; - - this.stop = function () {}; - - this.render = function () { - return html; - }; - - this.destroy = function () { - network.clear(); - Arrays.destroy(items); - scroll.destroy(); - html.remove(); - items = null; - network = null; - - if (background_image) { - background_image.onload = function () {}; - - background_image.src = ''; - } - }; - } - - function component$i(object) { - var network = new create$p(); - var scroll = new create$q({ - mask: true, - over: true, - step: 250, - end_ratio: 2 - }); - var items = []; - var html = document.createElement('div'); - var body = document.createElement('div'); - var total_pages = 0; - var last; - var waitload; - var active = 0; - - this.create = function () {}; - - this.empty = function () { - var button; - - if (object.source == 'tmdb') { - button = $(''); - button.find('.selector').on('hover:enter', function () { - Storage.set('source', 'cub'); - Activity$1.replace({ - source: 'cub' - }); - }); - } - - var empty = new create$a(); - if (button) empty.append(button); - html.appendChild(empty.render(true)); - this.start = empty.start; - this.activity.loader(false); - this.activity.toggle(); - }; - - this.next = function () { - var _this = this; - - if (waitload) return; - - if (object.page < total_pages) { - waitload = true; - object.page++; - this.nextPageReuest(object, function (result) { - _this.append(result, true); - - waitload = false; - - _this.limit(); - }, function () { - waitload = false; - }); - } - }; - - this.nextPageReuest = function (object, resolve, reject) { - Api.list(object, resolve.bind(this), reject.bind(this)); - }; - - this.append = function (data, append) { - var _this2 = this; - - data.results.forEach(function (element) { - var card = new Card(element, { - object: object, - card_category: typeof card_category == 'undefined' ? true : data.category, - card_wide: data.wide, - card_small: data.small, - card_broad: data.broad, - card_collection: data.collection, - card_events: data.card_events - }); - card.create(); - - card.onFocus = function (target, card_data) { - last = target; - active = items.indexOf(card); - scroll.update(card.render(true)); - Background.change(Utils$2.cardImgBackground(card_data)); - }; - - card.onTouch = function (target, card_data) { - last = target; - active = items.indexOf(card); - }; - - card.onEnter = function (target, card_data) { - last = target; - - if (typeof card_data.gender !== 'undefined') { - Activity$1.push({ - url: element.url, - title: Lang.translate('title_person'), - component: 'actor', - id: element.id, - source: element.source || object.source - }); - } else { - Activity$1.push({ - url: card_data.url, - component: 'full', - id: element.id, - method: card_data.name ? 'tv' : 'movie', - card: element, - source: element.source || object.source - }); - } - }; - - body.appendChild(card.render(true)); - items.push(card); - if (_this2.cardRender) _this2.cardRender(object, element, card); - if (append) Controller.collectionAppend(card.render(true)); - }); - }; - - this.limit = function () { - var limit_view = 12; - var lilit_collection = 36; - var colection = items.slice(Math.max(0, active - limit_view), active + limit_view); - items.forEach(function (item) { - if (colection.indexOf(item) == -1) { - item.render(true).classList.remove('layer--render'); - } else { - item.render(true).classList.add('layer--render'); - } - }); - Navigator.setCollection(items.slice(Math.max(0, active - lilit_collection), active + lilit_collection).map(function (c) { - return c.render(true); - })); - Navigator.focused(last); - Layer.visible(scroll.render(true)); - }; - - this.build = function (data) { - var _this3 = this; - - if (data.results.length) { - total_pages = data.total_pages; - body.classList.add('category-full'); - scroll.minus(); - scroll.onEnd = this.next.bind(this); - scroll.onScroll = this.limit.bind(this); - - scroll.onWheel = function (step) { - if (!Controller.own(_this3)) _this3.start(); - if (step > 0) Navigator.move('down');else Navigator.move('up'); - }; - - this.append(data); - scroll.append(body); - html.appendChild(scroll.render(true)); - this.limit(); - this.activity.loader(false); - this.activity.toggle(); - } else { - this.empty(); - } - }; - - this.start = function () { - var _this4 = this; - - Controller.add('content', { - link: this, - toggle: function toggle() { - if (_this4.activity.canRefresh()) return false; - Controller.collectionSet(scroll.render(true)); - Controller.collectionFocus(last || false, scroll.render(true)); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - right: function right() { - if (_this4.onRight) { - if (Navigator.canmove('right')) Navigator.move('right');else _this4.onRight(); - } else Navigator.move('right'); - }, - up: function up() { - if (Navigator.canmove('up')) Navigator.move('up');else Controller.toggle('head'); - }, - down: function down() { - if (Navigator.canmove('down')) Navigator.move('down'); - }, - back: function back() { - Activity$1.backward(); - } - }); - Controller.toggle('content'); - }; - - this.refresh = function () { - this.activity.needRefresh(); - }; - - this.pause = function () {}; - - this.stop = function () {}; - - this.render = function (js) { - return js ? html : $(html); - }; - - this.destroy = function () { - network.clear(); - Arrays.destroy(items); - scroll.destroy(); - html.remove(); - body.remove(); - items = []; - }; - } - - function component$h(object) { - var comp = new component$i(object); - - comp.create = function () { - Api.list(object, this.build.bind(this), this.empty.bind(this)); - }; - - return comp; - } - - function component$g(object) { - var comp = new Lampa.InteractionMain(object); - - comp.create = function () { - this.activity.loader(true); - var next = Api.category(object, this.build.bind(this), this.empty.bind(this)); - if (typeof next == 'function') this.next = next; - return this.render(); - }; - - return comp; - } - - function create$7(data) { - var html; - var last; - var subscribed = Storage.get('person_subscribes_id', '[]').find(function (a) { - return a == data.id; - }); - var network = new create$p(); - - this.create = function () { - var _this = this; - - html = Template$1.get('person_start', { - name: data.name, - birthday: data.birthday ? Utils$2.parseTime(data.birthday).full : Lang.translate('player_unknown'), - img: data.profile_path ? Api.img(data.profile_path) : data.img || 'img/img_broken.svg', - place: data.place_of_birth || Lang.translate('player_unknown') - }); - this.substatus(); - html.find('.button--info').on('hover:enter', function () { - if (data.biography) { - Modal.open({ - title: data.name, - size: 'large', - html: $('
    ' + data.biography + '
    '), - onBack: function onBack() { - Modal.close(); - Controller.toggle('content'); - }, - onSelect: function onSelect() { - Modal.close(); - Controller.toggle('content'); - } - }); - } else { - Noty.show(Lang.translate('empty_title_two')); - } - }).on('hover:focus', function (e) { - last = e.target; - }); - html.find('.button--subscribe').on('hover:enter', function () { - var subscribes = Storage.get('person_subscribes_id', '[]'); - subscribed = subscribes.find(function (a) { - return a == data.id; - }); - if (!subscribed && !Account.hasPremium()) return Account.showCubPremium(); - var account = Account.logged() ? Storage.get('account', '{}') : false; - if (!account) return Account.showNoAccount(); - network.silent(Utils$2.protocol() + object$2.cub_domain + '/api/person/' + (subscribed ? 'unsubscribe' : 'subscribe'), function (result) { - if (subscribed) Arrays.remove(subscribes, data.id);else if (subscribes.indexOf(data.id) == -1) subscribes.push(data.id); - Storage.set('person_subscribes_id', subscribes); - subscribed = subscribes.find(function (a) { - return a == data.id; - }); - - _this.substatus(); - }, function (err) { - if (err.responseJSON && err.responseJSON.code == 555) Account.showCubPremium();else Noty.show(Lang.translate('subscribe_error')); - }, { - person: JSON.stringify(data) - }, { - headers: { - token: account.token - } - }); - }).on('hover:focus', function (e) { - last = e.target; - }); - }; - - this.substatus = function () { - html.find('.button--subscribe path:eq(1)').attr('fill', subscribed ? 'currentColor' : 'transparent'); - html.find('.button--subscribe span').text(Lang.translate(subscribed ? 'title_unsubscribe' : 'title_subscribe')); - }; - - this.toggle = function () { - var _this2 = this; - - Controller.add('full_start', { - toggle: function toggle() { - Controller.collectionSet(_this2.render()); - Controller.collectionFocus(last, _this2.render()); - }, - update: function update() {}, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - down: this.onDown, - up: this.onUp, - gone: function gone() {}, - back: this.onBack - }); - Controller.toggle('full_start'); - }; - - this.render = function () { - return html; - }; - - this.destroy = function () { - last = null; - html.remove(); - }; - } - - var components = { - start: create$7, - line: create$h - }; - - function component$f(object) { - var network = new create$p(); - var scroll = new create$q({ - mask: true, - over: true, - scroll_by_item: true - }); - var items = []; - var active = 0; - var poster; - - this.create = function () { - var _this = this; - - this.activity.loader(true); - scroll.minus(); - Api.person(object, function (data) { - _this.activity.loader(false); - - if (data.person) { - poster = data.person.profile_path; - - _this.build('start', data.person); - - if (data.credits && data.credits.knownFor && data.credits.knownFor.length > 0) { - for (var i = 0; i < data.credits.knownFor.length; i++) { - var departament = data.credits.knownFor[i]; - var credits = departament.credits.map(function (a) { - a.time_sort = new Date(a.first_air_date || a.release_date || '').getTime(); - return a; - }); - credits.sort(function (a, b) { - return b.time_sort - a.time_sort; - }); - - _this.build('line', { - title: departament.name, - noimage: true, - results: credits - }); - } - } - - Layer.update(scroll.render(true)); - Layer.visible(scroll.render(true)); - - _this.activity.toggle(); - } else { - _this.empty(); - } - }, this.empty.bind(this)); - return this.render(); - }; - - this.empty = function () { - var empty = new create$a(); - scroll.append(empty.render()); - this.start = empty.start; - this.activity.loader(false); - this.activity.toggle(); - }; - - this.build = function (name, data) { - var item = new components[name](data, { - object: object, - nomore: true - }); - item.onDown = this.down; - item.onUp = this.up; - item.onBack = this.back; - - item.onToggle = function () { - active = items.indexOf(item); - }; - - items.push(item); - item.create(); - scroll.append(item.render()); - }; - - this.down = function () { - active++; - active = Math.min(active, items.length - 1); - scroll.update(items[active].render()); - items[active].toggle(); - }; - - this.up = function () { - active--; - - if (active < 0) { - active = 0; - Controller.toggle('head'); - } else { - items[active].toggle(); - scroll.update(items[active].render()); - } - }; - - this.back = function () { - Activity$1.backward(); - }; - - this.start = function () { - if (Activity$1.active().activity == this.activity && poster) Background.immediately(poster ? Api.img(poster, 'w200') : ''); - Controller.add('content', { - toggle: function toggle() { - if (items.length) { - items[active].toggle(); - } else { - Controller.collectionSet(scroll.render()); - Controller.collectionFocus(false, scroll.render()); - } - }, - update: function update() {}, - left: function left() { - Controller.toggle('menu'); - }, - up: function up() { - Controller.toggle('head'); - }, - back: function back() { - Activity$1.backward(); - } - }); - Controller.toggle('content'); - }; - - this.pause = function () {}; - - this.stop = function () {}; - - this.render = function () { - return scroll.render(); - }; - - this.destroy = function () { - network.clear(); - Arrays.destroy(items); - scroll.destroy(); - items = []; - }; - } - - function component$e(object) { - var comp = new component$i(object); - - var update = function update(e) { - if (e.name == 'account') comp.activity.needRefresh(); - }; - - Storage.listener.follow('change', update); - - comp.create = function () { - this.activity.loader(true); - Api.favorite(object, this.build.bind(this), this.empty.bind(this)); - }; - - comp.nextPageReuest = function (object, resolve, reject) { - Api.favorite(object, resolve.bind(this), reject.bind(this)); - }; - - if (object.type == 'history') { - comp.cardRender = function (object, data, card) { - card.onMenuShow = function (menu_list) { - menu_list.push({ - title: Lang.translate('menu_history'), - separator: true - }); - menu_list.push({ - title: Lang.translate('fav_clear_title'), - subtitle: Lang.translate('fav_clear_descr'), - all: true - }); - menu_list.push({ - title: Lang.translate('fav_clear_label_title'), - subtitle: Lang.translate('fav_clear_label_descr'), - label: true - }); - menu_list.push({ - title: Lang.translate('fav_clear_time_title'), - subtitle: Lang.translate('fav_clear_time_descr'), - timecode: true - }); - }; - - card.onMenuSelect = function (action) { - if (action.all) { - Favorite.clear('history'); - Lampa.Activity.replace({}); - } else if (action.label) { - Storage.set('online_view', []); - Storage.set('torrents_view', []); - Noty.show(Lang.translate('fav_label_cleared')); - } else if (action.timecode) { - Storage.set('file_view', {}); - Noty.show(Lang.translate('fav_time_cleared')); - } - }; - }; - } - - return comp; - } - - function create$6() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var search = Template$1.get('search_box'); - var input = ''; - - function destroy() { - $('body').toggleClass('ambience--enable', false); - keyboard.destroy(); - search.remove(); - search = null; - } - - function back() { - destroy(); - params.onBack(); - } - - function enter() { - destroy(); - params.onSearch(input); - } - - function change(text) { - input = text; - - if (input) { - search.find('.search-box__input').toggleClass('filled', true).html(input.replace(/\s/g, ' ')); - } else { - search.find('.search-box__input').toggleClass('filled', false).text(Lang.translate('search_input') + '...'); - } - } - - if (Storage.field('keyboard_type') !== 'lampa') search.find('.search-box__input').hide(); - $('body').append(search); - $('body').toggleClass('ambience--enable', true); - var keyboard = new create$2({ - layout: 'clarify' - }); - keyboard.create(); - keyboard.listener.follow('change', function (event) { - change(event.value); - }); - keyboard.listener.follow('back', back); - keyboard.listener.follow('enter', enter); - keyboard.value(params.input); - change(params.input); - keyboard.toggle(); - } - - function create$5() { - var _this2 = this; - - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var line = Template$1.get('filter').addClass('torrent-filter'); - var empty = $(''); - var data = { - sort: [], - filter: [] - }; - var similars = []; - var buttons_scroll = new create$q({ - horizontal: true, - nopadding: true - }); - if (typeof params.search == 'string') line.find('.filter--search div').text(Utils$2.shortText(params.search, 20)).removeClass('hide'); - - function selectSearch() { - var _this = this; - - var search = []; - var year = ((params.movie ? params.movie.first_air_date || params.movie.release_date : '0000') + '').slice(0, 4); - var earlier = Storage.get('user_clarifys', '{}')[params.movie.id]; - search.push({ - title: Lang.translate('filter_set_name'), - query: '' - }); - - if (earlier) { - search.push({ - title: Lang.translate('search'), - separator: true - }); - earlier.map(function (a) { - return a; - }).reverse().forEach(function (ear) { - search.push({ - title: ear, - query: ear - }); - }); - } - - if (params.movie.names && params.movie.names.length) { - search.push({ - title: Lang.translate('filter_alt_names'), - separator: true - }); - params.movie.names.forEach(function (n) { - search.push({ - title: n, - query: n - }); - }); - } - - if (params.movie.alternative_titles && params.movie.alternative_titles.titles && params.movie.alternative_titles.titles.length) { - params.movie.alternative_titles.titles.forEach(function (a) { - if (['us', Storage.field('language')].indexOf(a.iso_3166_1.toLowerCase()) >= 0) { - if (!search.find(function (s) { - return s.title == a.title; - })) { - search.push({ - title: a.title, - query: a.title - }); - } - } - }); - } - - search.push({ - title: Lang.translate('filter_combinations'), - separator: true - }); - - if (similars.length) { - similars.forEach(function (sim) { - search.push({ - title: sim, - query: sim - }); - }); - } else { - var combinations = []; - - if (params.search_one) { - combinations.push(params.search_one); - combinations.push(params.search_one + ' ' + year); - - if (params.search_two) { - combinations.push(params.search_one + ' ' + params.search_two); - combinations.push(params.search_one + ' ' + params.search_two + ' ' + year); - } - } - - if (params.search_two) { - combinations.push(params.search_two); - combinations.push(params.search_two + ' ' + year); - - if (params.search_one) { - combinations.push(params.search_two + ' ' + params.search_one); - combinations.push(params.search_two + ' ' + params.search_one + ' ' + year); - } - } - - combinations.forEach(function (word) { - search.push({ - title: word, - query: word - }); - }); - } - - var selected; - search.forEach(function (elem) { - elem.selected = elem.query == params.search && !selected; - if (elem.selected) selected = true; - }); - Select.show({ - title: Lang.translate('filter_clarify'), - items: search, - onBack: this.onBack, - onSelect: function onSelect(a) { - if (!a.query) { - new create$6({ - input: params.search, - onSearch: function onSearch(new_query) { - var earliers = Storage.get('user_clarifys', '{}'); - if (!earliers[params.movie.id]) earliers[params.movie.id] = []; - - if (earliers[params.movie.id].indexOf(new_query) == -1) { - earliers[params.movie.id].push(new_query); - Storage.set('user_clarifys', earliers); - } - - _this.onSearch(new_query); - }, - onBack: _this.onBack - }); - } else { - _this.onSearch(a.query); - } - } - }); - } - - empty.on('hover:enter', selectSearch.bind(this)); - line.find('.filter--search').on('hover:enter', selectSearch.bind(this)); - line.find('.filter--sort').on('hover:enter', function () { - _this2.show(Lang.translate('filter_sorted'), 'sort'); - }); - line.find('.filter--filter').on('hover:enter', function () { - _this2.show(Lang.translate('filter_filtred'), 'filter'); - }); - buttons_scroll.append(line); - - this.addButtonBack = function () { - if (params.movie && params.movie.id) { - line.prepend(Template$1.get('explorer_button_back')); - line.find('.filter--back').on('hover:enter', function () { - if (Activity$1.all().length > 1) { - Activity$1.back(); - } else { - Activity$1.push({ - url: params.movie.url, - component: 'full', - id: params.movie.id, - method: params.movie.name ? 'tv' : 'movie', - card: params.movie, - source: params.movie.source - }); - } - }); - } - }; - - this.show = function (title, type) { - var _this3 = this; - - var where = data[type]; - Select.show({ - title: title, - items: where, - onBack: this.onBack, - onSelect: function onSelect(a) { - if (!a.noselect) _this3.selected(where, a); - - if (a.items) { - Select.show({ - title: a.title, - items: a.items, - onBack: function onBack() { - _this3.show(title, type); - }, - onSelect: function onSelect(b) { - if (!b) _this3.selected(a.items, b); - - _this3.onSelect(type, a, b); - - _this3.show(title, type); - }, - onCheck: function onCheck(b) { - _this3.onCheck(type, a, b); - } - }); - } else { - _this3.onSelect(type, a); - } - } - }); - }; - - this.selected = function (items, a) { - items.forEach(function (element) { - element.selected = false; - }); - a.selected = true; - }; - - this.render = function () { - return buttons_scroll.render(); - }; - - this.append = function (add) { - html.find('.files__body').append(add); - }; - - this.empty = function () { - return empty; - }; - - this.toggle = function () { - line.find('.filter--sort').toggleClass('selector', data.sort.length ? true : false).toggleClass('hide', data.sort.length ? false : true); - line.find('.filter--filter').toggleClass('selector', data.filter.length ? true : false).toggleClass('hide', data.filter.length ? false : true); - }; - - this.set = function (type, items) { - data[type] = items; - this.toggle(); - }; - - this.get = function (type) { - return data[type]; - }; - - this.similar = function (sim) { - similars = sim; - return empty; - }; - - this.sort = function (items, by) { - items.sort(function (c, b) { - if (c[by] < b[by]) return 1; - if (c[by] > b[by]) return -1; - return 0; - }); - }; - - this.chosen = function (type, select) { - line.find('.filter--' + type + ' > div').html(Utils$2.shortText(select.join(', '), 25)).toggleClass('hide', select.length ? false : true); - }; - - this.destroy = function () { - empty.remove(); - line.remove(); - buttons_scroll.destroy(); - empty = null; - line = null; - data = null; - }; - } - - var html$6 = $("
    \n
    \n
    \n \n \n \n \n \n \n
    \n
    \n
    \n
    "); - var body$1 = html$6.find('.helper__text'), - time; - var memorys = {}; - var remember = 1000 * 60 * 60 * 14; - - function show$4(name, text, elem) { - if (!Storage.field('helper')) return; - var help = memorys[name]; - - if (!help) { - help = { - time: 0, - count: 0 - }; - if (_typeof(memorys) !== 'object') memorys = {}; //хз, вылазит ошибка, что в переменную true нельзя записать значение, откуда там true хз - - memorys[name] = help; - } - - if (help.time + remember < Date.now() && help.count < 3) { - help.time = Date.now(); - help.count++; - Storage.set('helper', memorys); - clearTimeout(time); - time = setTimeout(function () { - html$6.removeClass('helper--visible'); - }, 10000); - body$1.html(text); - html$6.addClass('helper--visible'); - - if (elem) { - var blink = $(''); - elem.append(blink); - setTimeout(function () { - blink.remove(); - }, 3000); - } - } - } - - function init$g() { - memorys = Storage.cache('helper', 300, {}); - Settings.listener.follow('open', function (e) { - if (e.name == 'more') { - e.body.find('.helper--start-again').on('hover:enter', function () { - memorys = {}; - Storage.set('helper', memorys); - Noty.show(Lang.translate('helper_cleared')); - }); - } - }); - $('body').append(html$6); - } - - var Helper = { - show: show$4, - init: init$g - }; - - var SERVER = {}; - var timers = {}; - var callback$1; - var callback_back; - var formats = ['asf', 'wmv', 'divx', 'avi', 'mp4', 'm4v', 'mov', '3gp', '3g2', 'mkv', 'trp', 'tp', 'mts', 'mpg', 'mpeg', 'dat', 'vob', 'rm', 'rmvb', 'm2ts', 'ts']; - var formats_individual = ['vob', 'm2ts']; - - function start$4(element, movie) { - SERVER.object = element; - if (movie) SERVER.movie = movie; - - if (Platform.is('android') && !Storage.field('internal_torrclient')) { - Android.openTorrent(SERVER); - if (movie && movie.id) Favorite.add('history', movie, 100); - if (callback$1) callback$1(); - } else if (Torserver.url()) { - loading(); - connect(); - } else install(); - } - - function open$2(hash, movie) { - SERVER.hash = hash; - if (movie) SERVER.movie = movie; - - if (Platform.is('android') && !Storage.field('internal_torrclient')) { - Android.playHash(SERVER); - if (callback$1) callback$1(); - } else if (Torserver.url()) { - loading(); - files(); - } else install(); - } - - function loading() { - Modal.open({ - title: '', - html: Template$1.get('modal_loading'), - size: 'large', - mask: true, - onBack: function onBack() { - Modal.close(); - close$2(); - } - }); - } - - function connect() { - Torserver.connected(function () { - hash(); - }, function (echo) { - Torserver.error(); - }); - } - - function hash() { - Torserver.hash({ - title: SERVER.object.title, - link: SERVER.object.MagnetUri || SERVER.object.Link, - poster: SERVER.object.poster, - data: { - lampa: true, - movie: SERVER.movie - } - }, function (json) { - SERVER.hash = json.hash; - files(); - }, function (echo) { - //Torserver.error() - var jac = Storage.field('parser_torrent_type') == 'jackett'; - var tpl = Template$1.get('torrent_nohash', { - title: Lang.translate('title_error'), - text: Lang.translate('torrent_parser_no_hash'), - url: SERVER.object.MagnetUri || SERVER.object.Link, - echo: echo - }); - if (jac) tpl.find('.is--torlook').remove();else tpl.find('.is--jackett').remove(); - Modal.update(tpl); - }); - } - - function files() { - var repeat = 0; - timers.files = setInterval(function () { - repeat++; - Torserver.files(SERVER.hash, function (json) { - if (json.file_stats) { - clearInterval(timers.files); - show$3(json.file_stats); - } - }); - - if (repeat >= 45) { - Modal.update(Template$1.get('error', { - title: Lang.translate('title_error'), - text: Lang.translate('torrent_parser_timeout') - })); - Torserver.clear(); - Torserver.drop(SERVER.hash); - } - }, 2000); - } - - function install() { - Modal.open({ - title: '', - html: Template$1.get('torrent_install', {}), - size: 'large', - onBack: function onBack() { - Modal.close(); - Controller.toggle('content'); - } - }); - } - - function show$3(files) { - files.sort(function (a, b) { - var an = a.path.replace(/\d+/g, function (m) { - return m.length > 3 ? m : ('000' + m).substr(-4); - }); - var bn = b.path.replace(/\d+/g, function (m) { - return m.length > 3 ? m : ('000' + m).substr(-4); - }); - return an.localeCompare(bn); - }); - var active = Activity$1.active(), - movie = active.movie || SERVER.movie || {}; - var plays = Torserver.clearFileName(files.filter(function (a) { - var exe = a.path.split('.').pop().toLowerCase(); - return formats.indexOf(exe) >= 0; - })); - var seasons = []; - plays.forEach(function (element) { - var info = Torserver.parse({ - movie: movie, - files: plays, - filename: element.path_human, - path: element.path - }); - - if (info.serial && info.season && seasons.indexOf(info.season) == -1) { - seasons.push(info.season); - } - }); - - if (seasons.length) { - Api.seasons(movie, seasons, function (data) { - list(plays, { - movie: movie, - seasons: data, - files: files - }); - }); - } else { - list(plays, { - movie: movie, - files: files - }); - } - } - - function parseSubs(path, files) { - var name = path.split('/').pop().split('.').slice(0, -1).join('.'); - var index = -1; - var supportedFormats = subsrt.list(); - var subtitles = files.filter(function (a) { - var _short = a.path.split('/').pop(); - - var issub = supportedFormats.indexOf(a.path.split('.').pop().toLowerCase()) >= 0; - return _short.indexOf(name) >= 0 && issub; - }).map(function (a) { - index++; - var segments = a.path.split('/'); - segments.pop(); // drop filename - - var label = segments.slice(1).join(' - '); // drop initial folder and concat the rest - - return { - label: label, - url: Torserver.stream(a.path, SERVER.hash, a.id), - index: index - }; - }); - return subtitles.length ? subtitles : false; - } - - function preload(data, run) { - var need_preload = Torserver.ip() && data.url.indexOf(Torserver.ip()) > -1 && data.url.indexOf('&preload') > -1; - - if (need_preload) { - var checkout; - var network = new create$p(); - var first = true; - Loading.start(function () { - clearInterval(checkout); - network.clear(); - Loading.stop(); - }); - - var update = function update() { - network.timeout(2000); - network.silent(first ? data.url : data.url.replace('preload', 'stat'), function (res) { - var pb = res.preloaded_bytes || 0, - ps = res.preload_size || 0, - sp = res.download_speed ? Utils$2.bytesToSize(res.download_speed * 8, true) : '0.0'; - var progress = Math.min(100, pb * 100 / ps); - - if (progress >= 95 || isNaN(progress)) { - Loading.stop(); - clearInterval(checkout); - run(); - } else { - Loading.setText(Math.round(progress) + '%' + ' - ' + sp); - } - }); - first = false; - }; - - checkout = setInterval(update, 1000); - update(); - } else run(); - } - - function list(items, params) { - var html = $('
    '); - var playlist = []; - var scroll_to_element; - Lampa.Listener.send('torrent_file', { - type: 'list_open', - items: items - }); - var folder = ''; - items.forEach(function (element) { - var exe = element.path.split('.').pop().toLowerCase(); - var info = Torserver.parse({ - movie: params.movie, - files: items, - filename: element.path_human, - path: element.path, - is_file: formats_individual.indexOf(exe) >= 0 - }); - var view = Timeline.view(info.hash); - var item; - - var viewed = function viewed(viewing) { - Account.torrentViewed({ - object: SERVER.object, - viewing: viewing, - card: SERVER.movie - }); - }; - - Arrays.extend(element, { - season: info.season, - episode: info.episode, - title: element.path_human, - first_title: params.movie.name || params.movie.title, - size: Utils$2.bytesToSize(element.length), - url: Torserver.stream(element.path, SERVER.hash, element.id), - torrent_hash: SERVER.hash, - ffprobe: SERVER.object && SERVER.object.ffprobe ? SERVER.object.ffprobe : false, - timeline: view, - air_date: '--', - img: './img/img_broken.svg', - exe: exe, - viewed: viewed - }); - - if (params.seasons) { - var episodes = params.seasons[info.season]; - element.title = (info.episode ? info.episode + ' / ' : '') + element.path_human; - element.fname = element.title; - - if (episodes) { - var episode = episodes.episodes.filter(function (a) { - return a.episode_number == info.episode; - })[0]; - - if (episode) { - element.title = info.episode + ' / ' + episode.name; - element.air_date = Utils$2.parseTime(episode.air_date).full; - element.fname = episode.name; - if (episode.still_path) element.img = Api.img(episode.still_path);else if (episode.img) element.img = episode.img; - } - } - - if (info.episode) { - item = Template$1.get('torrent_file_serial', element); - item.find('.torrent-serial__content').append(Timeline.render(view)); - } else { - item = Template$1.get('torrent_file', element); - item.append(Timeline.render(view)); - } - } else if (items.length == 1 && params.movie && !params.movie.name) { - element.fname = params.movie.title || element.title; - if (params.movie.backdrop_path) element.img = Api.img(params.movie.backdrop_path); - item = Template$1.get('torrent_file_serial', element); - item.find('.torrent-serial__line').empty().text(params.movie.tagline || ''); - item.find('.torrent-serial__episode').remove(); - item.find('.torrent-serial__content').append(Timeline.render(view)); - } else { - item = Template$1.get('torrent_file', element); - item.append(Timeline.render(view)); - if (params.movie.title) element.title = params.movie.title; - } - - item[0].visibility = 'hidden'; - if (view.percent > 0) scroll_to_element = item; - element.subtitles = parseSubs(element.path, params.files); - element.title = (element.fname || element.title).replace(/<[^>]*>?/gm, ''); - playlist.push(element); - item.on('hover:enter', function () { - //если это андроид, но не андроид, то нефиг смотреть - if (navigator.userAgent.toLowerCase().indexOf('android') >= 0 && !Platform.is('android')) return Platform.install('apk'); - if (params.movie.id) Favorite.add('history', params.movie, 100); - - if (Platform.is('android') && playlist.length > 1) { - var trim_playlist = []; - playlist.forEach(function (elem) { - trim_playlist.push({ - title: elem.title, - url: elem.url, - timeline: elem.timeline - }); - }); - element.playlist = trim_playlist; - } - - preload(element, function () { - Player.play(element); - Player.callback(function () { - Controller.toggle('modal'); - }); - Player.playlist(playlist); - Player.stat(element.url); - - if (callback$1) { - callback$1(); - callback$1 = false; - } - - Lampa.Listener.send('torrent_file', { - type: 'onenter', - element: element, - item: item, - items: items - }); - }); - }).on('hover:long', function () { - var enabled = Controller.enabled().name; - var menu = [{ - title: Lang.translate('time_reset'), - timeclear: true - }]; - - if (Platform.is('webos')) { - menu.push({ - title: Lang.translate('player_lauch') + ' - WebOS', - player: 'webos' - }); - } - - if (Platform.is('android')) { - menu.push({ - title: Lang.translate('player_lauch') + ' - Android', - player: 'android' - }); - } - - menu.push({ - title: Lang.translate('player_lauch') + ' - Lampa', - player: 'lampa' - }); - - if (!Platform.tv()) { - menu.push({ - title: Lang.translate('copy_link'), - link: true - }); - } - - Lampa.Listener.send('torrent_file', { - type: 'onlong', - element: element, - item: item, - menu: menu, - items: items - }); - Select.show({ - title: Lang.translate('title_action'), - items: menu, - onBack: function onBack() { - Controller.toggle(enabled); - }, - onSelect: function onSelect(a) { - if (a.timeclear) { - view.percent = 0; - view.time = 0; - view.duration = 0; - element.timeline = view; - Timeline.update(view); - } - - if (a.link) { - Utils$2.copyTextToClipboard(element.url.replace('&preload', '&play'), function () { - Noty.show(Lang.translate('copy_secuses')); - }, function () { - Noty.show(Lang.translate('copy_error')); - }); - } - - Controller.toggle(enabled); - - if (a.player) { - Player.runas(a.player); - item.trigger('hover:enter'); - } - } - }); - }).on('hover:focus', function () { - Lampa.Listener.send('torrent_file', { - type: 'onfocus', - element: element, - item: item, - items: items - }); - Helper.show('torrents_view', Lang.translate('helper_torrents_view'), item); - }).on('visible', function () { - var img = item.find('img'); - - img[0].onload = function () { - img.addClass('loaded'); - }; - - img[0].src = img.attr('data-src'); - }); - - if (element.folder_name && element.folder_name !== folder) { - html.append($('
    ' + element.folder_name + '
    ')); - folder = element.folder_name; - } - - html.append(item); - Lampa.Listener.send('torrent_file', { - type: 'render', - element: element, - item: item, - items: items - }); - }); - if (items.length == 0) html = Template$1.get('error', { - title: Lang.translate('empty_title'), - text: Lang.translate('torrent_parser_nofiles') - });else Modal.title(Lang.translate('title_files')); - Modal.update(html); - if (scroll_to_element) Controller.collectionFocus(scroll_to_element, Modal.scroll().render()); - } - - function opened(call) { - callback$1 = call; - } - - function back$4(call) { - callback_back = call; - } - - function close$2() { - Torserver.drop(SERVER.hash); - Torserver.clear(); - clearInterval(timers.files); - - if (callback_back) { - callback_back(); - } else { - Controller.toggle('content'); - } - - callback_back = false; - SERVER = {}; - Lampa.Listener.send('torrent_file', { - type: 'list_close' - }); - } - - var Torrent = { - start: start$4, - open: open$2, - opened: opened, - back: back$4 - }; - - var url; - var network$3 = new create$p(); - - function init$f() { - var source = { - title: Lang.translate('title_parser'), - search: function search(params, oncomplite) { - get$3({ - search: decodeURIComponent(params.query), - other: true, - from_search: true - }, function (json) { - json.title = Lang.translate('title_parser'); - json.results = json.Results.slice(0, 20); - json.Results = null; - json.results.forEach(function (element) { - element.Title = Utils$2.shortText(element.Title, 110); - }); - oncomplite(json.results.length ? [json] : []); - }, function () { - oncomplite([]); - }); - }, - onCancel: function onCancel() { - network$3.clear(); - }, - params: { - align_left: true, - isparser: true, - card_events: { - onMenu: function onMenu() {} - } - }, - onMore: function onMore(params, close) { - close(); - Activity$1.push({ - url: '', - title: Lang.translate('title_torrents'), - component: 'torrents', - search: params.query, - from_search: true, - noinfo: true, - movie: { - title: params.query, - original_title: '', - img: './img/img_broken.svg', - genres: [] - }, - page: 1 - }); - }, - onSelect: function onSelect(params, close) { - if (params.element.reguest && !params.element.MagnetUri) { - marnet(params.element, function () { - Modal.close(); - Torrent.start(params.element, { - title: params.element.Title - }); - Torrent.back(params.line.toggle.bind(params.line)); - }, function (text) { - Modal.update(Template.get('error', { - title: Lang.translate('title_error'), - text: text - })); - }); - Modal.open({ - title: '', - html: Template.get('modal_pending', { - text: Lang.translate('torrent_get_magnet') - }), - onBack: function onBack() { - Modal.close(); - params.line.toggle(); - } - }); - } else { - Torrent.start(params.element, { - title: params.element.Title - }); - Torrent.back(params.line.toggle.bind(params.line)); - } - } - }; - Storage.listener.follow('change', function (e) { - if (e.name == 'parse_in_search') { - Search.removeSource(source); - if (Storage.field('parse_in_search')) Search.addSource(source); - } - }); - - if (Storage.field('parse_in_search')) { - Search.addSource(source); - } - } - - function get$3() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - - function complite(data) { - popular(params.movie, data, {}, oncomplite); - } - - function error(e) { - var data = { - Results: [] - }; - popular(params.movie, data, { - nolimit: true - }, function () { - if (data.Results.length) oncomplite(data);else onerror(e); - }); - } - - if (Storage.field('parser_torrent_type') == 'jackett') { - if (Storage.field('jackett_url')) { - url = Utils$2.checkEmptyUrl(Storage.field('jackett_url')); - var ignore = false; //params.from_search && !url.match(/\d+\.\d+\.\d+/g) - - if (ignore) error('');else { - jackett(params, complite, error); - } - } else { - error(Lang.translate('torrent_parser_set_link') + ': Jackett'); - } - } else if (Storage.field('parser_torrent_type') == 'prowlarr') { - if (Storage.field('prowlarr_url')) { - url = Utils$2.checkEmptyUrl(Storage.field('prowlarr_url')); - prowlarr(params, complite, error); - } else { - error(Lang.translate('torrent_parser_set_link') + ': Prowlarr'); - } - } else if (Storage.field('parser_torrent_type') == 'torrserver') { - if (Storage.field(Storage.field('torrserver_use_link') == 'two' ? 'torrserver_url_two' : 'torrserver_url')) { - url = Utils$2.checkEmptyUrl(Storage.field(Storage.field('torrserver_use_link') == 'two' ? 'torrserver_url_two' : 'torrserver_url')); - torrserver(params, complite, error); - } else { - error(Lang.translate('torrent_parser_set_link') + ': TorrServer'); - } - } else { - if (Storage.get('native')) { - torlook(params, complite, error); - } else if (Storage.field('torlook_parse_type') == 'site' && Storage.field('parser_website_url')) { - url = Utils$2.checkEmptyUrl(Storage.field('parser_website_url')); - torlook(params, complite, error); - } else if (Storage.field('torlook_parse_type') == 'native') { - torlook(params, complite, error); - } else error(Lang.translate('torrent_parser_set_link') + ': TorLook'); - } - } - - function popular(card, data, params, call) { - Account.torrentPopular({ - card: card - }, function (result) { - var torrents = result.result.torrents.filter(function (t) { - return t.viewing_request > (params.nolimit ? 0 : 3); - }); - torrents.sort(function (a, b) { - return b.viewing_average - a.viewing_average; - }); - torrents.forEach(function (t) { - delete t.viewed; - }); - data.Results = data.Results.concat(params.nolimit ? torrents : torrents.slice(0, 3)); - call(data); - }, function () { - call(data); - }); - } - - function viewed(hash) { - var view = Storage.cache('torrents_view', 5000, []); - return view.indexOf(hash) > -1; - } - - function torlook() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - torlookApi(params, oncomplite, onerror); - } - - function torlookApi() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - network$3.timeout(1000 * Storage.field('parse_timeout')); - var s = 'https://torlook.site/api.php?key=4JuCSML44FoEsmqK&s='; - var q = (params.search + '').replace(/( )/g, "+").toLowerCase(); - var u = s + encodeURIComponent(q); - network$3["native"](u, function (json) { - if (json.error) onerror(Lang.translate('torrent_parser_request_error'));else { - var data = { - Results: [] - }; - - if (json.data) { - json.data.forEach(function (elem) { - var item = {}; - item.Title = elem.title; - item.Tracker = elem.tracker; - item.Size = parseInt(elem.size); - item.size = Utils$2.bytesToSize(item.Size); - item.PublishDate = parseInt(elem.date) * 1000; - item.Seeders = parseInt(elem.seeders); - item.Peers = parseInt(elem.leechers); - item.PublisTime = parseInt(elem.date) * 1000; - item.hash = Utils$2.hash(elem.title); - item.MagnetUri = elem.magnet; - item.viewed = viewed(item.hash); - if (elem.magnet) data.Results.push(item); - }); - } - - oncomplite(data); - } - }, function (a, c) { - onerror(Lang.translate('torrent_parser_no_responce')); - }); - } - - function jackett() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - network$3.timeout(1000 * Storage.field('parse_timeout')); - var u = url + '/api/v2.0/indexers/' + (Storage.field('jackett_interview') == 'healthy' ? 'status:healthy' : 'all') + '/results?apikey=' + Storage.field('jackett_key') + '&Query=' + encodeURIComponent(params.search); - - if (!params.from_search) { - var genres = params.movie.genres.map(function (a) { - return a.name; - }); - - if (!params.clarification) { - u = Utils$2.addUrlComponent(u, 'title=' + encodeURIComponent(params.movie.title)); - u = Utils$2.addUrlComponent(u, 'title_original=' + encodeURIComponent(params.movie.original_title)); - } - - u = Utils$2.addUrlComponent(u, 'year=' + encodeURIComponent(((params.movie.release_date || params.movie.first_air_date || '0000') + '').slice(0, 4))); - u = Utils$2.addUrlComponent(u, 'is_serial=' + (params.movie.first_air_date || params.movie.last_air_date ? '2' : params.other ? '0' : '1')); - u = Utils$2.addUrlComponent(u, 'genres=' + encodeURIComponent(genres.join(','))); - u = Utils$2.addUrlComponent(u, 'Category[]=' + (params.movie.number_of_seasons > 0 ? 5000 : 2000) + (params.movie.original_language == 'ja' ? ',5070' : '')); - } - - network$3["native"](u, function (json) { - if (json.Results) { - json.Results.forEach(function (element) { - element.PublisTime = Utils$2.strToTime(element.PublishDate); - element.hash = Utils$2.hash(element.Title); - element.viewed = viewed(element.hash); - element.size = Utils$2.bytesToSize(element.Size); - }); - oncomplite(json); - } else onerror(Lang.translate('torrent_parser_no_responce') + ' (' + url + ')'); - }, function (a, c) { - onerror(Lang.translate('torrent_parser_no_responce') + ' (' + url + ')'); - }); - } // доки https://wiki.servarr.com/en/prowlarr/search#search-feed - - - function prowlarr() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - var u = new URL('/api/v1/search', url); - network$3.timeout(1000 * Storage.field('parse_timeout')); - u.searchParams.set('apikey', Storage.field('prowlarr_key')); - u.searchParams.set('query', params.search); - - if (!params.from_search) { - var isSerial = !!(params.movie.first_air_date || params.movie.last_air_date); - u.searchParams.set('categories', (params.movie.number_of_seasons > 0 ? 5000 : 2000) + (params.movie.original_language == 'ja' ? ',5070' : '')); - u.searchParams.set('type', isSerial ? 'tvsearch' : 'search'); - } - - network$3["native"](u.href, function (json) { - if (Array.isArray(json)) { - oncomplite({ - Results: json.filter(function (e) { - return e.protocol === 'torrent'; - }).map(function (e) { - var hash = Utils$2.hash(e.title); - return { - Title: e.title, - Tracker: e.indexer, - size: Utils$2.bytesToSize(e.size), - PublishDate: Utils$2.strToTime(e.publishDate), - Seeders: parseInt(e.seeders), - Peers: parseInt(e.leechers), - MagnetUri: e.downloadUrl, - viewed: viewed(hash), - hash: hash - }; - }) - }); - } else { - onerror(Lang.translate('torrent_parser_no_responce') + ' (' + url + ')'); - } - }, function () { - onerror(Lang.translate('torrent_parser_no_responce') + ' (' + url + ')'); - }); - } - - function torrserver() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var oncomplite = arguments.length > 1 ? arguments[1] : undefined; - var onerror = arguments.length > 2 ? arguments[2] : undefined; - network$3.timeout(1000 * Storage.field('parse_timeout')); - var u = new URL('/search/', url); - u.searchParams.set('query', params.search); - network$3["native"](u.href, function (json) { - oncomplite({ - Results: json.map(function (e) { - var hash = Utils$2.hash(e.Title); - return { - Title: e.Title, - Tracker: e.Tracker, - size: e.Size, - PublishDate: Utils$2.strToTime(e.CreateDate), - Seeders: parseInt(e.Seed), - Peers: parseInt(e.Peer), - MagnetUri: e.Magnet, - viewed: viewed(hash), - CategoryDesc: e.Categories, - bitrate: '-', - hash: hash - }; - }) - }); - }, function (a, c) { - onerror(Lang.translate('torrent_parser_no_responce') + ' (' + url + ')'); - }); - } - - function marnet(element, oncomplite, onerror) { - network$3.timeout(1000 * 15); - var s = Utils$2.checkHttp(Storage.field('torlook_site')) + '/'; - var u = Storage.get('native') || Storage.field('torlook_parse_type') == 'native' ? s + element.reguest : url.replace('{q}', encodeURIComponent(s + element.reguest)); - network$3["native"](u, function (html) { - var math = html.match(/magnet:(.*?)'/); - - if (math && math[1]) { - element.MagnetUri = 'magnet:' + math[1]; - oncomplite(); - } else { - onerror(Lang.translate('torrent_parser_magnet_error')); - } - }, function (a, c) { - onerror(network$3.errorDecode(a, c)); - }, false, { - dataType: 'text' - }); - } - - function clear$3() { - network$3.clear(); - } - - var Parser = { - init: init$f, - get: get$3, - torlook: torlook, - jackett: jackett, - marnet: marnet, - clear: clear$3 - }; - - function Explorer() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var html = Template$1.get('explorer', {}); - - if (params.movie.id) { - html.find('.selector').on('hover:enter', function () { - if (Activity$1.all().length > 1) { - Activity$1.back(); - } else { - Activity$1.push({ - url: params.movie.url, - component: 'full', - id: params.movie.id, - method: params.movie.name ? 'tv' : 'movie', - card: params.movie, - source: params.movie.source - }); - } - }); - } else { - html.find('.selector').removeClass('selector'); - } - - var year = ((params.movie.release_date || params.movie.first_air_date || '0000') + '').slice(0, 4); - var pg = Api.sources.tmdb.parsePG(params.movie); - var countries = Api.sources.tmdb.parseCountries(params.movie); - var img = html.find('.explorer-card__head-img > img')[0]; - var rate = parseFloat((params.movie.vote_average || 0) + ''); - var genres = (params.movie.genres || [{ - name: '' - }]).slice(0, 3).map(function (a) { - return Utils$2.capitalizeFirstLetter(a.name); - }); - html.find('.explorer-card__head-create').text(year + (countries.length ? ' - ' + countries[0] : '')).toggleClass('hide', Boolean(year == '0000')); - html.find('.explorer-card__head-rate').toggleClass('hide', !Boolean(rate > 0)).find('span').text(rate.toFixed(1)); - html.find('.explorer-card__title').text(params.movie.title || params.movie.name); - html.find('.explorer-card__descr').text(params.movie.overview || ''); - html.find('.explorer-card__genres').text(genres.join(', ')); - if (pg) html.find('.explorer-card__head-body').append('
    ' + pg + '
    '); - if (params.noinfo) html.addClass('explorer--fullsize'); - - img.onerror = function (e) { - img.src = './img/img_broken.svg'; - }; - - img.src = params.movie.poster_path ? Api.img(params.movie.poster_path, 'w300') : params.movie.img; - - this.appendFiles = function (element) { - html.find('.explorer__files-body').append(element); - }; - - this.appendHead = function (element) { - html.find('.explorer__files-head').append(element); - }; - - this.render = function () { - return html; - }; - - this.clearFiles = function () { - html.find('.explorer__files-body').empty(); - }; - - this.clearHead = function () { - html.find('.explorer__files-head').empty(); - }; - - this.destroy = function () { - html.remove(); - - img.onerror = function () {}; - - img.src = ''; - }; - } - - function component$d(object) { - var network = new create$p(); - var scroll = new create$q({ - mask: true, - over: true - }); - var files = new Explorer(object); - var filter; - var results = []; - var filtred = []; - var total_pages = 1; - var last; - var initialized; - var filter_items = { - quality: [Lang.translate('torrent_parser_any_one'), '4k', '1080p', '720p'], - hdr: [Lang.translate('torrent_parser_no_choice'), Lang.translate('torrent_parser_yes'), Lang.translate('torrent_parser_no')], - dv: [Lang.translate('torrent_parser_no_choice'), 'Dolby Vision', 'Dolby Vision TV', Lang.translate('torrent_parser_no')], - sub: [Lang.translate('torrent_parser_no_choice'), Lang.translate('torrent_parser_yes'), Lang.translate('torrent_parser_no')], - voice: [], - tracker: [Lang.translate('torrent_parser_any_two')], - year: [Lang.translate('torrent_parser_any_two')], - lang: [Lang.translate('torrent_parser_any_two')] - }; - var filter_translate = { - quality: Lang.translate('torrent_parser_quality'), - hdr: 'HDR', - dv: 'Dolby Vision', - sub: Lang.translate('torrent_parser_subs'), - voice: Lang.translate('torrent_parser_voice'), - tracker: Lang.translate('torrent_parser_tracker'), - year: Lang.translate('torrent_parser_year'), - season: Lang.translate('torrent_parser_season'), - lang: Lang.translate('title_language_short') - }; - var filter_multiple = ['quality', 'voice', 'tracker', 'season', 'lang']; - var sort_translate = { - Seeders: Lang.translate('torrent_parser_sort_by_seeders'), - Size: Lang.translate('torrent_parser_sort_by_size'), - Title: Lang.translate('torrent_parser_sort_by_name'), - Tracker: Lang.translate('torrent_parser_sort_by_tracker'), - PublisTime: Lang.translate('torrent_parser_sort_by_date'), - viewed: Lang.translate('torrent_parser_sort_by_viewed') - }; - var i = 20, - y = new Date().getFullYear(); - - while (i--) { - filter_items.year.push(y - (19 - i) + ''); - } - - var viewed = Storage.cache('torrents_view', 5000, []); - var finded_seasons = []; - var finded_seasons_full = []; - var voices = ["Laci", "Kerob", "LE-Production", "Parovoz Production", "Paradox", "Omskbird", "LostFilm", "Причудики", "BaibaKo", "NewStudio", "AlexFilm", "FocusStudio", "Gears Media", "Jaskier", "ViruseProject", "Кубик в Кубе", "IdeaFilm", "Sunshine Studio", "Ozz.tv", "Hamster Studio", "Сербин", "To4ka", "Кравец", "Victory-Films", "SNK-TV", "GladiolusTV", "Jetvis Studio", "ApofysTeam", "ColdFilm", "Agatha Studdio", "KinoView", "Jimmy J.", "Shadow Dub Project", "Amedia", "Red Media", "Selena International", "Гоблин", "Universal Russia", "Kiitos", "Paramount Comedy", "Кураж-Бамбей", "Студия Пиратского Дубляжа", "Чадов", "Карповский", "RecentFilms", "Первый канал", "Alternative Production", "NEON Studio", "Колобок", "Дольский", "Синема УС", "Гаврилов", "Живов", "SDI Media", "Алексеев", "GreenРай Studio", "Михалев", "Есарев", "Визгунов", "Либергал", "Кузнецов", "Санаев", "ДТВ", "Дохалов", "Sunshine Studio", "Горчаков", "LevshaFilm", "CasStudio", "Володарский", "ColdFilm", "Шварко", "Карцев", "ETV+", "ВГТРК", "Gravi-TV", "1001cinema", "Zone Vision Studio", "Хихикающий доктор", "Murzilka", "turok1990", "FOX", "STEPonee", "Elrom", "Колобок", "HighHopes", "SoftBox", "GreenРай Studio", "NovaFilm", "Четыре в квадрате", "Greb&Creative", "MUZOBOZ", "ZM-Show", "RecentFilms", "Kerems13", "Hamster Studio", "New Dream Media", "Игмар", "Котов", "DeadLine Studio", "Jetvis Studio", "РенТВ", "Андрей Питерский", "Fox Life", "Рыбин", "Trdlo.studio", "Studio Victory Аsia", "Ozeon", "НТВ", "CP Digital", "AniLibria", "STEPonee", "Levelin", "FanStudio", "Cmert", "Интерфильм", "SunshineStudio", "Kulzvuk Studio", "Кашкин", "Вартан Дохалов", "Немахов", "Sedorelli", "СТС", "Яроцкий", "ICG", "ТВЦ", "Штейн", "AzOnFilm", "SorzTeam", "Гаевский", "Мудров", "Воробьев Сергей", "Студия Райдо", "DeeAFilm Studio", "zamez", "ViruseProject", "Иванов", "STEPonee", "РенТВ", "СВ-Дубль", "BadBajo", "Комедия ТВ", "Мастер Тэйп", "5-й канал СПб", "SDI Media", "Гланц", "Ох! Студия", "СВ-Кадр", "2x2", "Котова", "Позитив", "RusFilm", "Назаров", "XDUB Dorama", "Реальный перевод", "Kansai", "Sound-Group", "Николай Дроздов", "ZEE TV", "Ozz.tv", "MTV", "Сыендук", "GoldTeam", "Белов", "Dream Records", "Яковлев", "Vano", "SilverSnow", "Lord32x", "Filiza Studio", "Sony Sci-Fi", "Flux-Team", "NewStation", "XDUB Dorama", "Hamster Studio", "Dream Records", "DexterTV", "ColdFilm", "Good People", "RusFilm", "Levelin", "AniDUB", "SHIZA Project", "AniLibria.TV", "StudioBand", "AniMedia", "Kansai", "Onibaku", "JWA Project", "MC Entertainment", "Oni", "Jade", "Ancord", "ANIvoice", "Nika Lenina", "Bars MacAdams", "JAM", "Anika", "Berial", "Kobayashi", "Cuba77", "RiZZ_fisher", "OSLIKt", "Lupin", "Ryc99", "Nazel & Freya", "Trina_D", "JeFerSon", "Vulpes Vulpes", "Hamster", "KinoGolos", "Fox Crime", "Денис Шадинский", "AniFilm", "Rain Death", "LostFilm", "New Records", "Ancord", "Первый ТВЧ", "RG.Paravozik", "Profix Media", "Tycoon", "RealFake", "HDrezka", "Jimmy J.", "AlexFilm", "Discovery", "Viasat History", "AniMedia", "JAM", "HiWayGrope", "Ancord", "СВ-Дубль", "Tycoon", "SHIZA Project", "GREEN TEA", "STEPonee", "AlphaProject", "AnimeReactor", "Animegroup", "Shachiburi", "Persona99", "3df voice", "CactusTeam", "AniMaunt", "AniMedia", "AnimeReactor", "ShinkaDan", "Jaskier", "ShowJet", "RAIM", "RusFilm", "Victory-Films", "АрхиТеатр", "Project Web Mania", "ko136", "КураСгречей", "AMS", "СВ-Студия", "Храм Дорам ТВ", "TurkStar", "Медведев", "Рябов", "BukeDub", "FilmGate", "FilmsClub", "Sony Turbo", "ТВЦ", "AXN Sci-Fi", "NovaFilm", "DIVA Universal", "Курдов", "Неоклассика", "fiendover", "SomeWax", "Логинофф", "Cartoon Network", "Sony Turbo", "Loginoff", "CrezaStudio", "Воротилин", "LakeFilms", "Andy", "CP Digital", "XDUB Dorama + Колобок", "SDI Media", "KosharaSerials", "Екатеринбург Арт", "Julia Prosenuk", "АРК-ТВ Studio", "Т.О Друзей", "Anifilm", "Animedub", "AlphaProject", "Paramount Channel", "Кириллица", "AniPLague", "Видеосервис", "JoyStudio", "HighHopes", "TVShows", "AniFilm", "GostFilm", "West Video", "Формат AB", "Film Prestige", "West Video", "Екатеринбург Арт", "SovetRomantica", "РуФилмс", "AveBrasil", "Greb&Creative", "BTI Studios", "Пифагор", "Eurochannel", "NewStudio", "Кармен Видео", "Кошкин", "Кравец", "Rainbow World", "Воротилин", "Варус-Видео", "ClubFATE", "HiWay Grope", "Banyan Studio", "Mallorn Studio", "Asian Miracle Group", "Эй Би Видео", "AniStar", "Korean Craze", "LakeFilms", "Невафильм", "Hallmark", "Netflix", "Mallorn Studio", "Sony Channel", "East Dream", "Bonsai Studio", "Lucky Production", "Octopus", "TUMBLER Studio", "CrazyCatStudio", "Amber", "Train Studio", "Анастасия Гайдаржи", "Мадлен Дюваль", "Fox Life", "Sound Film", "Cowabunga Studio", "Фильмэкспорт", "VO-Production", "Sound Film", "Nickelodeon", "MixFilm", "GreenРай Studio", "Sound-Group", "Back Board Cinema", "Кирилл Сагач", "Bonsai Studio", "Stevie", "OnisFilms", "MaxMeister", "Syfy Universal", "TUMBLER Studio", "NewStation", "Neo-Sound", "Муравский", "IdeaFilm", "Рутилов", "Тимофеев", "Лагута", "Дьяконов", "Zone Vision Studio", "Onibaku", "AniMaunt", "Voice Project", "AniStar", "Пифагор", "VoicePower", "StudioFilms", "Elysium", "AniStar", "BeniAffet", "Selena International", "Paul Bunyan", "CoralMedia", "Кондор", "Игмар", "ViP Premiere", "FireDub", "AveTurk", "Sony Sci-Fi", "Янкелевич", "Киреев", "Багичев", "2x2", "Лексикон", "Нота", "Arisu", "Superbit", "AveDorama", "VideoBIZ", "Киномания", "DDV", "Alternative Production", "WestFilm", "Анастасия Гайдаржи + Андрей Юрченко", "Киномания", "Agatha Studdio", "GreenРай Studio", "VSI Moscow", "Horizon Studio", "Flarrow Films", "Amazing Dubbing", "Asian Miracle Group", "Видеопродакшн", "VGM Studio", "FocusX", "CBS Drama", "NovaFilm", "Novamedia", "East Dream", "Дасевич", "Анатолий Гусев", "Twister", "Морозов", "NewComers", "kubik&ko", "DeMon", "Анатолий Ашмарин", "Inter Video", "Пронин", "AMC", "Велес", "Volume-6 Studio", "Хоррор Мэйкер", "Ghostface", "Sephiroth", "Акира", "Деваль Видео", "RussianGuy27", "neko64", "Shaman", "Franek Monk", "Ворон", "Andre1288", "Selena International", "GalVid", "Другое кино", "Студия NLS", "Sam2007", "HaseRiLLoPaW", "Севастьянов", "D.I.M.", "Марченко", "Журавлев", "Н-Кино", "Lazer Video", "SesDizi", "Red Media", "Рудой", "Товбин", "Сергей Дидок", "Хуан Рохас", "binjak", "Карусель", "Lizard Cinema", "Варус-Видео", "Акцент", "RG.Paravozik", "Max Nabokov", "Barin101", "Васька Куролесов", "Фортуна-Фильм", "Amalgama", "AnyFilm", "Студия Райдо", "Козлов", "Zoomvision Studio", "Пифагор", "Urasiko", "VIP Serial HD", "НСТ", "Кинолюкс", "Project Web Mania", "Завгородний", "AB-Video", "Twister", "Universal Channel", "Wakanim", "SnowRecords", "С.Р.И", "Старый Бильбо", "Ozz.tv", "Mystery Film", "РенТВ", "Латышев", "Ващенко", "Лайко", "Сонотек", "Psychotronic", "DIVA Universal", "Gremlin Creative Studio", "Нева-1", "Максим Жолобов", "Good People", "Мобильное телевидение", "Lazer Video", "IVI", "DoubleRec", "Milvus", "RedDiamond Studio", "Astana TV", "Никитин", "КТК", "D2Lab", "НСТ", "DoubleRec", "Black Street Records", "Останкино", "TatamiFilm", "Видеобаза", "Crunchyroll", "Novamedia", "RedRussian1337", "КонтентикOFF", "Creative Sound", "HelloMickey Production", "Пирамида", "CLS Media", "Сонькин", "Мастер Тэйп", "Garsu Pasaulis", "DDV", "IdeaFilm", "Gold Cinema", "Че!", "Нарышкин", "Intra Communications", "OnisFilms", "XDUB Dorama", "Кипарис", "Королёв", "visanti-vasaer", "Готлиб", "Paramount Channel", "СТС", "диктор CDV", "Pazl Voice", "Прямостанов", "Zerzia", "НТВ", "MGM", "Дьяков", "Вольга", "АРК-ТВ Studio", "Дубровин", "МИР", "Netflix", "Jetix", "Кипарис", "RUSCICO", "Seoul Bay", "Филонов", "Махонько", "Строев", "Саня Белый", "Говинда Рага", "Ошурков", "Horror Maker", "Хлопушка", "Хрусталев", "Антонов Николай", "Золотухин", "АрхиАзия", "Попов", "Ultradox", "Мост-Видео", "Альтера Парс", "Огородников", "Твин", "Хабар", "AimaksaLTV", "ТНТ", "FDV", "3df voice", "The Kitchen Russia", "Ульпаней Эльром", "Видеоимпульс", "GoodTime Media", "Alezan", "True Dubbing Studio", "FDV", "Карусель", "Интер", "Contentica", "Мельница", "RealFake", "ИДДК", "Инфо-фильм", "Мьюзик-трейд", "Кирдин | Stalk", "ДиоНиК", "Стасюк", "TV1000", "Hallmark", "Тоникс Медиа", "Бессонов", "Gears Media", "Бахурани", "NewDub", "Cinema Prestige", "Набиев", "New Dream Media", "ТВ3", "Малиновский Сергей", "Superbit", "Кенс Матвей", "LE-Production", "Voiz", "Светла", "Cinema Prestige", "JAM", "LDV", "Videogram", "Индия ТВ", "RedDiamond Studio", "Герусов", "Элегия фильм", "Nastia", "Семыкина Юлия", "Электричка", "Штамп Дмитрий", "Пятница", "Oneinchnales", "Gravi-TV", "D2Lab", "Кинопремьера", "Бусов Глеб", "LE-Production", "1001cinema", "Amazing Dubbing", "Emslie", "1+1", "100 ТВ", "1001 cinema", "2+2", "2х2", "3df voice", "4u2ges", "5 канал", "A. Lazarchuk", "AAA-Sound", "AB-Video", "AdiSound", "ALEKS KV", "AlexFilm", "AlphaProject", "Alternative Production", "Amalgam", "AMC", "Amedia", "AMS", "Andy", "AniLibria", "AniMedia", "Animegroup", "Animereactor", "AnimeSpace Team", "Anistar", "AniUA", "AniWayt", "Anything-group", "AOS", "Arasi project", "ARRU Workshop", "AuraFilm", "AvePremier", "AveTurk", "AXN Sci-Fi", "Azazel", "AzOnFilm", "BadBajo", "BadCatStudio", "BBC Saint-Petersburg", "BD CEE", "Black Street Records", "Bonsai Studio", "Boльгa", "Brain Production", "BraveSound", "BTI Studios", "Bubble Dubbing Company", "Byako Records", "Cactus Team", "Cartoon Network", "CBS Drama", "CDV", "Cinema Prestige", "CinemaSET GROUP", "CinemaTone", "ColdFilm", "Contentica", "CP Digital", "CPIG", "Crunchyroll", "Cuba77", "D1", "D2lab", "datynet", "DDV", "DeadLine", "DeadSno", "DeMon", "den904", "Description", "DexterTV", "Dice", "Discovery", "DniproFilm", "DoubleRec", "DreamRecords", "DVD Classic", "East Dream", "Eladiel", "Elegia", "ELEKTRI4KA", "Elrom", "ELYSIUM", "Epic Team", "eraserhead", "erogg", "Eurochannel", "Extrabit", "F-TRAIN", "Family Fan Edition", "FDV", "FiliZa Studio", "Film Prestige", "FilmGate", "FilmsClub", "FireDub", "Flarrow Films", "Flux-Team", "FocusStudio", "FOX", "Fox Crime", "Fox Russia", "FoxLife", "Foxlight", "Franek Monk", "Gala Voices", "Garsu Pasaulis", "Gears Media", "Gemini", "General Film", "GetSmart", "Gezell Studio", "Gits", "GladiolusTV", "GoldTeam", "Good People", "Goodtime Media", "GoodVideo", "GostFilm", "Gramalant", "Gravi-TV", "GREEN TEA", "GreenРай Studio", "Gremlin Creative Studio", "Hallmark", "HamsterStudio", "HiWay Grope", "Horizon Studio", "hungry_inri", "ICG", "ICTV", "IdeaFilm", "IgVin & Solncekleshka", "ImageArt", "INTERFILM", "Ivnet Cinema", "IНТЕР", "Jakob Bellmann", "JAM", "Janetta", "Jaskier", "JeFerSon", "jept", "JetiX", "Jetvis", "JimmyJ", "KANSAI", "KIHO", "kiitos", "KinoGolos", "Kinomania", "KosharaSerials", "Kолобок", "L0cDoG", "LakeFilms", "LDV", "LE-Production", "LeDoyen", "LevshaFilm", "LeXiKC", "Liga HQ", "Line", "Lisitz", "Lizard Cinema Trade", "Lord32x", "lord666", "LostFilm", "Lucky Production", "Macross", "madrid", "Mallorn Studio", "Marclail", "Max Nabokov", "MC Entertainment", "MCA", "McElroy", "Mega-Anime", "Melodic Voice Studio", "metalrus", "MGM", "MifSnaiper", "Mikail", "Milirina", "MiraiDub", "MOYGOLOS", "MrRose", "MTV", "Murzilka", "MUZOBOZ", "National Geographic", "NemFilm", "Neoclassica", "NEON Studio", "New Dream Media", "NewComers", "NewStation", "NewStudio", "Nice-Media", "Nickelodeon", "No-Future", "NovaFilm", "Novamedia", "Octopus", "Oghra-Brown", "OMSKBIRD", "Onibaku", "OnisFilms", "OpenDub", "OSLIKt", "Ozz TV", "PaDet", "Paramount Comedy", "Paramount Pictures", "Parovoz Production", "PashaUp", "Paul Bunyan", "Pazl Voice", "PCB Translate", "Persona99", "PiratVoice", "Postmodern", "Profix Media", "Project Web Mania", "Prolix", "QTV", "R5", "Radamant", "RainDeath", "RATTLEBOX", "RealFake", "Reanimedia", "Rebel Voice", "RecentFilms", "Red Media", "RedDiamond Studio", "RedDog", "RedRussian1337", "Renegade Team", "RG Paravozik", "RinGo", "RoxMarty", "Rumble", "RUSCICO", "RusFilm", "RussianGuy27", "Saint Sound", "SakuraNight", "Satkur", "Sawyer888", "Sci-Fi Russia", "SDI Media", "Selena", "seqw0", "SesDizi", "SGEV", "Shachiburi", "SHIZA", "ShowJet", "Sky Voices", "SkyeFilmTV", "SmallFilm", "SmallFilm", "SNK-TV", "SnowRecords", "SOFTBOX", "SOLDLUCK2", "Solod", "SomeWax", "Sony Channel", "Sony Turbo", "Sound Film", "SpaceDust", "ssvss", "st.Elrom", "STEPonee", "SunshineStudio", "Superbit", "Suzaku", "sweet couple", "TatamiFilm", "TB5", "TF-AniGroup", "The Kitchen Russia", "The Mike Rec.", "Timecraft", "To4kaTV", "Tori", "Total DVD", "TrainStudio", "Troy", "True Dubbing Studio", "TUMBLER Studio", "turok1990", "TV 1000", "TVShows", "Twister", "Twix", "Tycoon", "Ultradox", "Universal Russia", "VashMax2", "VendettA", "VHS", "VicTeam", "VictoryFilms", "Video-BIZ", "Videogram", "ViruseProject", "visanti-vasaer", "VIZ Media", "VO-production", "Voice Project Studio", "VoicePower", "VSI Moscow", "VulpesVulpes", "Wakanim", "Wayland team", "WestFilm", "WiaDUB", "WVoice", "XL Media", "XvidClub Studio", "zamez", "ZEE TV", "Zendos", "ZM-SHOW", "Zone Studio", "Zone Vision", "Агапов", "Акопян", "Алексеев", "Артемьев", "Багичев", "Бессонов", "Васильев", "Васильцев", "Гаврилов", "Герусов", "Готлиб", "Григорьев", "Дасевич", "Дольский", "Карповский", "Кашкин", "Киреев", "Клюквин", "Костюкевич", "Матвеев", "Михалев", "Мишин", "Мудров", "Пронин", "Савченко", "Смирнов", "Тимофеев", "Толстобров", "Чуев", "Шуваев", "Яковлев", "ААА-sound", "АБыГДе", "Акалит", "Акира", "Альянс", "Амальгама", "АМС", "АнВад", "Анубис", "Anubis", "Арк-ТВ", "АРК-ТВ Studio", "Б. Федоров", "Бибиков", "Бигыч", "Бойков", "Абдулов", "Белов", "Вихров", "Воронцов", "Горчаков", "Данилов", "Дохалов", "Котов", "Кошкин", "Назаров", "Попов", "Рукин", "Рутилов", "Варус Видео", "Васька Куролесов", "Ващенко С.", "Векшин", "Велес", "Весельчак", "Видеоимпульс", "Витя «говорун»", "Войсовер", "Вольга", "Ворон", "Воротилин", "Г. Либергал", "Г. Румянцев", "Гей Кино Гид", "ГКГ", "Глуховский", "Гризли", "Гундос", "Деньщиков", "Есарев", "Нурмухаметов", "Пучков", "Стасюк", "Шадинский", "Штамп", "sf@irat", "Держиморда", "Домашний", "ДТВ", "Дьяконов", "Е. Гаевский", "Е. Гранкин", "Е. Лурье", "Е. Рудой", "Е. Хрусталёв", "ЕА Синема", "Екатеринбург Арт", "Живаго", "Жучков", "З Ранку До Ночі", "Завгородний", "Зебуро", "Зереницын", "И. Еремеев", "И. Клушин", "И. Сафронов", "И. Степанов", "ИГМ", "Игмар", "ИДДК", "Имидж-Арт", "Инис", "Ирэн", "Ист-Вест", "К. Поздняков", "К. Филонов", "К9", "Карапетян", "Кармен Видео", "Карусель", "Квадрат Малевича", "Килька", "Кипарис", "Королев", "Котова", "Кравец", "Кубик в Кубе", "Кураж-Бамбей", "Л. Володарский", "Лазер Видео", "ЛанселаП", "Лапшин", "Лексикон", "Ленфильм", "Леша Прапорщик", "Лизард", "Люсьена", "Заугаров", "Иванов", "Иванова и П. Пашут", "Латышев", "Ошурков", "Чадов", "Яроцкий", "Максим Логинофф", "Малиновский", "Марченко", "Мастер Тэйп", "Махонько", "Машинский", "Медиа-Комплекс", "Мельница", "Мика Бондарик", "Миняев", "Мительман", "Мост Видео", "Мосфильм", "Муравский", "Мьюзик-трейд", "Н-Кино", "Н. Антонов", "Н. Дроздов", "Н. Золотухин", "Н.Севастьянов seva1988", "Набиев", "Наталья Гурзо", "НЕВА 1", "Невафильм", "НеЗупиняйПродакшн", "Неоклассика", "Несмертельное оружие", "НЛО-TV", "Новий", "Новый диск", "Новый Дубляж", "Новый Канал", "Нота", "НСТ", "НТВ", "НТН", "Оверлорд", "Огородников", "Омикрон", "Гланц", "Карцев", "Морозов", "Прямостанов", "Санаев", "Парадиз", "Пепелац", "Первый канал ОРТ", "Переводман", "Перец", "Петербургский дубляж", "Петербуржец", "Пирамида", "Пифагор", "Позитив-Мультимедиа", "Прайд Продакшн", "Премьер Видео", "Премьер Мультимедиа", "Причудики", "Р. Янкелевич", "Райдо", "Ракурс", "РенТВ", "Россия", "РТР", "Русский дубляж", "Русский Репортаж", "РуФилмс", "Рыжий пес", "С. Визгунов", "С. Дьяков", "С. Казаков", "С. Кузнецов", "С. Кузьмичёв", "С. Лебедев", "С. Макашов", "С. Рябов", "С. Щегольков", "С.Р.И.", "Сolumbia Service", "Самарский", "СВ Студия", "СВ-Дубль", "Светла", "Селена Интернешнл", "Синема Трейд", "Синема УС", "Синта Рурони", "Синхрон", "Советский", "Сокуров", "Солодухин", "Сонотек", "Сонькин", "Союз Видео", "Союзмультфильм", "СПД - Сладкая парочка", "Строев", "СТС", "Студии Суверенного Лепрозория", "Студия «Стартрек»", "KOleso", "Студия Горького", "Студия Колобок", "Студия Пиратского Дубляжа", "Студия Райдо", "Студия Трёх", "Гуртом", "Супербит", "Сыендук", "Так Треба Продакшн", "ТВ XXI век", "ТВ СПб", "ТВ-3", "ТВ6", "ТВИН", "ТВЦ", "ТВЧ 1", "ТНТ", "ТО Друзей", "Толмачев", "Точка Zрения", "Трамвай-фильм", "ТРК", "Уолт Дисней Компани", "Хихидок", "Хлопушка", "Цікава Ідея", "Четыре в квадрате", "Швецов", "Штамп", "Штейн", "Ю. Живов", "Ю. Немахов", "Ю. Сербин", "Ю. Товбин", "Я. Беллманн", "Red Head Sound", "UKR"]; - var filter_langs = [{ - title: '#{filter_lang_ru}', - code: 'ru' - }, { - title: '#{filter_lang_uk}', - code: 'uk' - }, { - title: '#{filter_lang_en}', - code: 'en' - }, { - title: '#{filter_lang_be}', - code: 'be' - }, { - title: '#{filter_lang_zh}', - code: 'zh|cn' - }, { - title: '#{filter_lang_ja}', - code: 'ja' - }, { - title: '#{filter_lang_ko}', - code: 'ko' - }, { - title: '#{filter_lang_af}', - code: 'af' - }, { - title: '#{filter_lang_sq}', - code: 'sq' - }, { - title: '#{filter_lang_ar}', - code: 'ar' - }, { - title: '#{filter_lang_az}', - code: 'az' - }, { - title: '#{filter_lang_hy}', - code: 'hy' - }, { - title: '#{filter_lang_ba}', - code: 'ba' - }, { - title: '#{filter_lang_bg}', - code: 'bg' - }, { - title: '#{filter_lang_bn}', - code: 'bn' - }, { - title: '#{filter_lang_bs}', - code: 'bs' - }, { - title: '#{filter_lang_ca}', - code: 'ca' - }, { - title: '#{filter_lang_ce}', - code: 'ce' - }, { - title: '#{filter_lang_cs}', - code: 'cs' - }, { - title: '#{filter_lang_da}', - code: 'da' - }, { - title: '#{filter_lang_ka}', - code: 'ka' - }, { - title: '#{filter_lang_de}', - code: 'de' - }, { - title: '#{filter_lang_el}', - code: 'el' - }, { - title: '#{filter_lang_es}', - code: 'es' - }, { - title: '#{filter_lang_et}', - code: 'et' - }, { - title: '#{filter_lang_fa}', - code: 'fa' - }, { - title: '#{filter_lang_fi}', - code: 'fi' - }, { - title: '#{filter_lang_fr}', - code: 'fr' - }, { - title: '#{filter_lang_ga}', - code: 'ga' - }, { - title: '#{filter_lang_gl}', - code: 'gl' - }, { - title: '#{filter_lang_gn}', - code: 'gn' - }, { - title: '#{filter_lang_he}', - code: 'he' - }, { - title: '#{filter_lang_hi}', - code: 'hi' - }, { - title: '#{filter_lang_hr}', - code: 'hr' - }, { - title: '#{filter_lang_hu}', - code: 'hu' - }, { - title: '#{filter_lang_id}', - code: 'id' - }, { - title: '#{filter_lang_is}', - code: 'is' - }, { - title: '#{filter_lang_it}', - code: 'it' - }, { - title: '#{filter_lang_kk}', - code: 'kk' - }, { - title: '#{filter_lang_ks}', - code: 'ks' - }, { - title: '#{filter_lang_ku}', - code: 'ku' - }, { - title: '#{filter_lang_ky}', - code: 'ky' - }, { - title: '#{filter_lang_lt}', - code: 'lt' - }, { - title: '#{filter_lang_lv}', - code: 'lv' - }, { - title: '#{filter_lang_mi}', - code: 'mi' - }, { - title: '#{filter_lang_mk}', - code: 'mk' - }, { - title: '#{filter_lang_mn}', - code: 'mn' - }, { - title: '#{filter_lang_mo}', - code: 'mo' - }, { - title: '#{filter_lang_mt}', - code: 'mt' - }, { - title: '#{filter_lang_no}', - code: 'no|nb|nn' - }, { - title: '#{filter_lang_ne}', - code: 'ne' - }, { - title: '#{filter_lang_nl}', - code: 'nl' - }, { - title: '#{filter_lang_pa}', - code: 'pa' - }, { - title: '#{filter_lang_pl}', - code: 'pl' - }, { - title: '#{filter_lang_ps}', - code: 'ps' - }, { - title: '#{filter_lang_pt}', - code: 'pt' - }, { - title: '#{filter_lang_ro}', - code: 'ro' - }, { - title: '#{filter_lang_si}', - code: 'si' - }, { - title: '#{filter_lang_sk}', - code: 'sk' - }, { - title: '#{filter_lang_sl}', - code: 'sl' - }, { - title: '#{filter_lang_sm}', - code: 'sm' - }, { - title: '#{filter_lang_so}', - code: 'so' - }, { - title: '#{filter_lang_sr}', - code: 'sr' - }, { - title: '#{filter_lang_sv}', - code: 'sv' - }, { - title: '#{filter_lang_sw}', - code: 'sw' - }, { - title: '#{filter_lang_ta}', - code: 'ta' - }, { - title: '#{filter_lang_tg}', - code: 'tg' - }, { - title: '#{filter_lang_th}', - code: 'th' - }, { - title: '#{filter_lang_tk}', - code: 'tk' - }, { - title: '#{filter_lang_tr}', - code: 'tr' - }, { - title: '#{filter_lang_tt}', - code: 'tt' - }, { - title: '#{filter_lang_ur}', - code: 'ur' - }, { - title: '#{filter_lang_uz}', - code: 'uz' - }, { - title: '#{filter_lang_vi}', - code: 'vi' - }, { - title: '#{filter_lang_yi}', - code: 'yi' - }]; - filter_items.lang = filter_items.lang.concat(filter_langs.map(function (a) { - return Lang.translate(a.title); - })); - scroll.minus(files.render().find('.explorer__files-head')); - scroll.body().addClass('torrent-list'); - - this.create = function () { - return this.render(); - }; - - this.initialize = function () { - var _this = this; - - this.activity.loader(true); - - if (object.movie.original_language == 'ja' && object.movie.genres.find(function (g) { - return g.id == 16; - }) && Storage.field('language') !== 'en') { - network.silent(TMDB$1.api((object.movie.name ? 'tv' : 'movie') + '/' + object.movie.id + '?api_key=' + TMDB$1.key() + '&language=en'), function (result) { - object.search_two = result.name || result.title; - - _this.parse(); - }, this.parse.bind(this)); - } else { - this.parse(); - } - - scroll.onEnd = this.next.bind(this); - return this.render(); - }; - - this.parse = function () { - var _this2 = this; - - filter = new create$5(object); - Parser.get(object, function (data) { - results = data; - - _this2.build(); - - Layer.update(scroll.render(true)); - - _this2.activity.loader(false); - - _this2.activity.toggle(); - }, function (text) { - _this2.empty(Lang.translate('torrent_error_connect') + ': ' + text); - }); - - filter.onSearch = function (value) { - Activity$1.replace({ - search: value, - clarification: true - }); - }; - - filter.onBack = function () { - _this2.start(); - }; - - filter.render().find('.selector').on('hover:focus', function (e) { - }); - filter.addButtonBack(); - files.appendHead(filter.render()); - }; - - this.empty = function (descr) { - var empty = new create$a({ - descr: descr - }); - files.render().find('.explorer__files-head').addClass('hide'); - files.appendFiles(empty.render(filter.empty())); - empty.render().find('.simple-button').on('hover:enter', function () { - filter.render().find('.filter--search').trigger('hover:enter'); - }); - this.start = empty.start; - this.activity.loader(false); - this.activity.toggle(); - }; - - this.listEmpty = function () { - var em = Template$1.get('empty_filter'); - var bn = $('
    ' + Lang.translate('filter_clarify') + '
    '); - bn.on('hover:enter', function () { - filter.render().find('.filter--filter').trigger('hover:enter'); - }); - em.find('.empty-filter__title').remove(); - em.find('.empty-filter__buttons').removeClass('hide').append(bn); - scroll.append(em); - }; - - this.buildSorted = function () { - var need = Storage.get('torrents_sort', 'Seeders'); - var select = [{ - title: Lang.translate('torrent_parser_sort_by_seeders'), - sort: 'Seeders' - }, { - title: Lang.translate('torrent_parser_sort_by_size'), - sort: 'Size' - }, { - title: Lang.translate('torrent_parser_sort_by_name'), - sort: 'Title' - }, { - title: Lang.translate('torrent_parser_sort_by_tracker'), - sort: 'Tracker' - }, { - title: Lang.translate('torrent_parser_sort_by_date'), - sort: 'PublisTime' - }, { - title: Lang.translate('torrent_parser_sort_by_viewed'), - sort: 'viewed' - }]; - select.forEach(function (element) { - if (element.sort == need) element.selected = true; - }); - filter.sort(results.Results, need); - this.sortWithPopular(); - filter.set('sort', select); - this.selectedSort(); - }; - - this.sortWithPopular = function () { - var popular = []; - var other = []; - results.Results.forEach(function (a) { - if (a.viewing_request) popular.push(a);else other.push(a); - }); - popular.sort(function (a, b) { - return b.viewing_average - a.viewing_average; - }); - results.Results = popular.concat(other); - }; - - this.cardID = function () { - return object.movie.id + ':' + (object.movie.number_of_seasons ? 'tv' : 'movie'); - }; - - this.getFilterData = function () { - var all = Storage.cache('torrents_filter_data', 500, {}); - var cid = this.cardID(); - return all[cid] || Storage.get('torrents_filter', '{}'); - }; - - this.setFilterData = function (filter) { - var all = Storage.cache('torrents_filter_data', 500, {}); - var cid = this.cardID(); - all[cid] = filter; - Storage.set('torrents_filter_data', all); - Storage.set('torrents_filter', filter); - }; - - this.buildFilterd = function () { - var need = this.getFilterData(); - var select = []; - - var add = function add(type, title) { - var items = filter_items[type]; - var subitems = []; - var multiple = filter_multiple.indexOf(type) >= 0; - var value = need[type]; - if (multiple) value = Arrays.toArray(value); - items.forEach(function (name, i) { - subitems.push({ - title: name, - //selected: multiple ? i == 0 : value == i, - checked: multiple && value.indexOf(name) >= 0, - checkbox: multiple && i > 0, - noselect: true, - index: i - }); - }); - select.push({ - title: title, - subtitle: multiple ? value.length ? value.join(', ') : items[0] : typeof value == 'undefined' ? items[0] : items[value], - items: subitems, - noselect: true, - stype: type - }); - }; - - filter_items.voice = [Lang.translate('torrent_parser_any_two'), Lang.translate('torrent_parser_voice_dubbing'), Lang.translate('torrent_parser_voice_polyphonic'), Lang.translate('torrent_parser_voice_two'), Lang.translate('torrent_parser_voice_amateur')]; - filter_items.tracker = [Lang.translate('torrent_parser_any_two')]; - filter_items.season = [Lang.translate('torrent_parser_any_two')]; - results.Results.forEach(function (element) { - var title = element.Title.toLowerCase(), - tracker = element.Tracker; - - for (var _i = 0; _i < voices.length; _i++) { - var voice = voices[_i].toLowerCase(); - - if (title.indexOf(voice) >= 0) { - if (filter_items.voice.indexOf(voices[_i]) == -1) filter_items.voice.push(voices[_i]); - } - - if (element.info && element.info.voices) { - if (element.info.voices.map(function (v) { - return v.toLowerCase(); - }).indexOf(voice) >= 0) { - if (filter_items.voice.indexOf(voices[_i]) == -1) filter_items.voice.push(voices[_i]); - } - } - } - - tracker.split(',').forEach(function (t) { - if (filter_items.tracker.indexOf(t.trim()) === -1) filter_items.tracker.push(t.trim()); - }); - var season = title.match(/.?s\[(\d+)-\].?|.?s(\d+).?|.?\((\d+) сезон.?|.?season (\d+),.?/); - - if (season) { - season = season.filter(function (c) { - return c; - }); - - if (season.length > 1) { - var orig = season[1]; - var number = parseInt(orig) + ''; - - if (number && finded_seasons.indexOf(number) == -1) { - finded_seasons.push(number); - finded_seasons_full.push(orig); - } - } - } - }); - finded_seasons_full.sort(function (a, b) { - var ac = parseInt(a); - var bc = parseInt(b); - if (ac > bc) return 1;else if (ac < bc) return -1;else return 0; - }); - finded_seasons.sort(function (a, b) { - var ac = parseInt(a); - var bc = parseInt(b); - if (ac > bc) return 1;else if (ac < bc) return -1;else return 0; - }); - if (finded_seasons.length) filter_items.season = filter_items.season.concat(finded_seasons); //надо очистить от отсутствующих ключей - - need.voice = Arrays.removeNoIncludes(Arrays.toArray(need.voice), filter_items.voice); - need.tracker = Arrays.removeNoIncludes(Arrays.toArray(need.tracker), filter_items.tracker); - need.season = Arrays.removeNoIncludes(Arrays.toArray(need.season), filter_items.season); - this.setFilterData(need); - select.push({ - title: Lang.translate('torrent_parser_reset'), - reset: true - }); - add('quality', Lang.translate('torrent_parser_quality')); - add('hdr', 'HDR'); - add('dv', 'Dolby Vision'); - add('sub', Lang.translate('torrent_parser_subs')); - add('voice', Lang.translate('torrent_parser_voice')); - add('lang', Lang.translate('title_language_short')); - add('season', Lang.translate('torrent_parser_season')); - add('tracker', Lang.translate('torrent_parser_tracker')); - add('year', Lang.translate('torrent_parser_year')); - filter.set('filter', select); - this.selectedFilter(); - }; - - this.selectedFilter = function () { - var need = this.getFilterData(), - select = []; - - for (var _i2 in need) { - if (need[_i2]) { - if (Arrays.isArray(need[_i2])) { - if (need[_i2].length) select.push(filter_translate[_i2] + ':' + need[_i2].join(', ')); - } else { - select.push(filter_translate[_i2] + ': ' + filter_items[_i2][need[_i2]]); - } - } - } - - filter.chosen('filter', select); - }; - - this.selectedSort = function () { - var select = Storage.get('torrents_sort', 'Seeders'); - filter.chosen('sort', [sort_translate[select]]); - }; - - this.build = function () { - var _this3 = this; - - this.buildSorted(); - this.buildFilterd(); - this.filtred(); - - filter.onSelect = function (type, a, b) { - if (type == 'sort') { - Storage.set('torrents_sort', a.sort); - filter.sort(results.Results, a.sort); - - _this3.sortWithPopular(); - } else { - if (a.reset) { - _this3.setFilterData({}); - - _this3.buildFilterd(); - } else { - a.items.forEach(function (n) { - return n.checked = false; - }); - - var filter_data = _this3.getFilterData(); - - filter_data[a.stype] = filter_multiple.indexOf(a.stype) >= 0 ? [] : b.index; - a.subtitle = b.title; - - _this3.setFilterData(filter_data); - } - } - - _this3.applyFilter(); - - _this3.start(); - }; - - filter.onCheck = function (type, a, b) { - var data = _this3.getFilterData(), - need = Arrays.toArray(data[a.stype]); - - if (b.checked && need.indexOf(b.title)) need.push(b.title);else if (!b.checked) Arrays.remove(need, b.title); - data[a.stype] = need; - - _this3.setFilterData(data); - - a.subtitle = need.length ? need.join(', ') : a.items[0].title; - - _this3.applyFilter(); - }; - - if (results.Results.length) this.showResults();else { - this.empty(Lang.translate('torrent_parser_empty')); - } - }; - - this.applyFilter = function () { - this.filtred(); - this.selectedFilter(); - this.selectedSort(); - this.reset(); - this.showResults(); - last = scroll.render().find('.torrent-item:eq(0)')[0]; - if (last) scroll.update(last);else scroll.reset(); - }; - - this.filtred = function () { - var filter_data = this.getFilterData(); - var filter_any = false; - - for (var _i3 in filter_data) { - var filr = filter_data[_i3]; - - if (filr) { - if (Arrays.isArray(filr)) { - if (filr.length) filter_any = true; - } else filter_any = true; - } - } - - filtred = results.Results.filter(function (element) { - if (filter_any) { - var passed = false, - nopass = false, - title = element.Title.toLowerCase(), - tracker = element.Tracker; - var qua = Arrays.toArray(filter_data.quality), - hdr = filter_data.hdr, - dv = filter_data.dv, - sub = filter_data.sub, - voi = Arrays.toArray(filter_data.voice), - tra = Arrays.toArray(filter_data.tracker), - ses = Arrays.toArray(filter_data.season), - lng = Arrays.toArray(filter_data.lang), - yer = filter_data.year; - - var test = function test(search, test_index) { - var regex = new RegExp(search); - return test_index ? title.indexOf(search) >= 0 : regex.test(title); - }; - - var check = function check(search, invert) { - if (test(search)) { - if (invert) nopass = true;else passed = true; - } else { - if (invert) passed = true;else nopass = true; - } - }; - - var includes = function includes(type, arr) { - if (!arr.length) return; - var any = false; - arr.forEach(function (a) { - if (type == 'quality') { - if (a == '4k' && test('(4k|uhd)[ |\\]|,|$]|2160[pр]|ultrahd')) any = true; - if (a == '1080p' && test('fullhd|1080[pр]')) any = true; - if (a == '720p' && test('720[pр]')) any = true; - } - - if (type == 'voice') { - var p = filter_items.voice.indexOf(a); - var n = element.info && element.info.voices ? element.info.voices.map(function (v) { - return v.toLowerCase(); - }) : []; - - if (p == 1) { - if (test('дублирован|дубляж| apple| dub| d[,| |$]|[,|\\s]дб[,|\\s|$]')) any = true; - } else if (p == 2) { - if (test('многоголос| p[,| |$]|[,|\\s](лм|пм)[,|\\s|$]')) any = true; - } else if (p == 3) { - if (test('двухголос|двуголос| l2[,| |$]|[,|\\s](лд|пд)[,|\\s|$]')) any = true; - } else if (p == 4) { - if (test('любитель|авторский| l1[,| |$]|[,|\\s](ло|ап)[,|\\s|$]')) any = true; - } else if (test(a.toLowerCase(), true)) any = true;else if (n.length && n.indexOf(a.toLowerCase()) >= 0) any = true; - } - - if (type == 'lang') { - var _p = filter_items.lang.indexOf(a); - - var c = filter_langs[_p - 1]; - - if (element.languages) { - if (element.languages.find(function (l) { - return l.toLowerCase().slice(0, 2) == c.code; - })) any = true; - } else if (title.indexOf(c.code) >= 0) any = true; - } - - if (type == 'tracker') { - if (tracker.split(',').find(function (t) { - return t.trim().toLowerCase() == a.toLowerCase(); - })) any = true; - } - - if (type == 'season') { - var pad = function pad(n) { - return n < 10 && n != '01' ? '0' + n : n; - }; - - var _i4 = finded_seasons.indexOf(a); - - var f = finded_seasons_full[_i4]; - var SES1 = title.match(/\[s(\d+)-(\d+)\]/); - var SES2 = title.match(/season (\d+)-(\d+)/); - var SES3 = title.match(/season (\d+) - (\d+).?/); - var SES4 = title.match(/сезон: (\d+)-(\d+) \/.?/); - if (Array.isArray(SES1) && (f >= SES1[1] && f <= SES1[2] || pad(f) >= SES1[1] && pad(f) <= SES1[2] || f >= pad(SES1[1]) && f <= pad(SES1[2]))) any = true; - if (Array.isArray(SES2) && (f >= SES2[1] && f <= SES2[2] || pad(f) >= SES2[1] && pad(f) <= SES2[2] || f >= pad(SES2[1]) && f <= pad(SES2[2]))) any = true; - if (Array.isArray(SES3) && (f >= SES3[1] && f <= SES3[2] || pad(f) >= SES3[1] && pad(f) <= SES3[2] || f >= pad(SES3[1]) && f <= pad(SES3[2]))) any = true; - if (Array.isArray(SES4) && (f >= SES4[1] && f <= SES4[2] || pad(f) >= SES4[1] && pad(f) <= SES4[2] || f >= pad(SES4[1]) && f <= pad(SES4[2]))) any = true; - if (test('.?\\[0' + f + 'x0.?|.?\\[s' + f + '-.?|.?-' + f + '\\].?|.?\\[s0' + f + '\\].?|.?\\[s' + f + '\\].?|.?s' + f + 'e.?|.?s' + f + '-.?|.?сезон: ' + f + ' .?|.?сезон:' + f + '.?|сезон ' + f + ',.?|\\[' + f + ' сезон.?|.?\\(' + f + ' сезон.?|.?season ' + f + '.?')) any = true; - } - }); - if (any) passed = true;else nopass = true; - }; - - includes('quality', qua); - includes('voice', voi); - includes('tracker', tra); - includes('season', ses); - includes('lang', lng); - if (hdr) check('[\\[| ]hdr[10| |\\]|,|$]', hdr !== 1); - - if (dv == 0) { - check(filter_items.dv[dv], dv !== 1); - } else if (dv == 1) { - check('dolby vision'); - } else if (dv == 2) { - check('dolby vision tv'); - } else if (dv == 3) { - check('dolby vision', dv !== 0); - } - - if (sub) check(' sub|[,|\\s]ст[,|\\s|$]', sub !== 1); - - if (yer) { - check(filter_items.year[yer]); - } - - return nopass ? false : passed; - } else return true; - }); - }; - - this.showResults = function () { - total_pages = Math.ceil(filtred.length / 20); - - if (filtred.length) { - this.append(filtred.slice(0, 20)); - } else { - this.listEmpty(); - } - - files.appendFiles(scroll.render()); - }; - - this.reset = function () { - last = false; - scroll.clear(); - }; - - this.next = function () { - if (object.page < 15 && object.page < total_pages) { - object.page++; - var offset = (object.page - 1) * 20; - this.append(filtred.slice(offset, offset + 20), true); - } - }; - - this.loadMagnet = function (element, call) { - var _this4 = this; - - Parser.marnet(element, function () { - Modal.close(); - element.poster = object.movie.img; - - _this4.start(); - - if (call) call();else Torrent.start(element, object.movie); - }, function (text) { - Modal.update(Template$1.get('error', { - title: Lang.translate('title_error'), - text: text - })); - }); - Modal.open({ - title: '', - html: Template$1.get('modal_pending', { - text: Lang.translate('torrent_get_magnet') - }), - onBack: function onBack() { - Modal.close(); - network.clear(); - Controller.toggle('content'); - } - }); - }; - - this.mark = function (element, item, add) { - if (add) { - if (viewed.indexOf(element.hash) == -1) { - viewed.push(element.hash); - item.append('
    ' + Template$1.get('icon_viewed', {}, true) + '
    '); - } - } else { - element.viewed = true; - Arrays.remove(viewed, element.hash); - item.find('.torrent-item__viewed').remove(); - } - - element.viewed = add; - Storage.set('torrents_view', viewed); - if (!add) Storage.remove('torrents_view', element.hash); - }; - - this.addToBase = function (element) { - Torserver.add({ - poster: object.movie.img, - title: object.movie.title + ' / ' + object.movie.original_title, - link: element.MagnetUri || element.Link, - data: { - lampa: true, - movie: object.movie - } - }, function () { - Noty.show(object.movie.title + ' - ' + Lang.translate('torrent_parser_added_to_mytorrents')); - }); - }; - - this.append = function (items, append) { - var _this5 = this; - - items.forEach(function (element) { - var date = Utils$2.parseTime(element.PublishDate); - var bitrate = object.movie.runtime ? Utils$2.calcBitrate(element.Size, object.movie.runtime) : 0; - Arrays.extend(element, { - title: element.Title, - date: date.full, - tracker: element.Tracker, - bitrate: bitrate, - size: !isNaN(parseInt(element.Size)) ? Utils$2.bytesToSize(element.Size) : element.size, - seeds: element.Seeders, - grabs: element.Peers - }); - var item = Template$1.get('torrent', element); - - if (element.ffprobe) { - var ffprobe_elem = item.find('.torrent-item__ffprobe'); - var ffprobe_tags = []; - var video = element.ffprobe.find(function (a) { - return a.codec_type == 'video'; - }); - var audio = element.ffprobe.filter(function (a) { - return a.codec_type == 'audio' && a.tags; - }); - var subs = element.ffprobe.filter(function (a) { - return a.codec_type == 'subtitle' && a.tags; - }); - var voice = element.info && element.info.voices ? element.info.voices : []; - if (video) ffprobe_tags.push({ - media: 'video', - value: video.width + 'x' + video.height - }); - var is_71 = element.ffprobe.find(function (a) { - return a.codec_type == 'audio' && a.channels == 8; - }); - var is_51 = element.ffprobe.find(function (a) { - return a.codec_type == 'audio' && a.channels == 6; - }); - if (is_71) ffprobe_tags.push({ - media: 'channels', - value: '7.1' - }); - if (is_51) ffprobe_tags.push({ - media: 'channels', - value: '5.1' - }); - audio.forEach(function (a) { - var line = []; - var lang = (a.tags.language || '').toUpperCase(); - var name = a.tags.title || a.tags.handler_name; - if (lang) line.push(lang); - - if (name && lang !== 'ENG') { - var translate = voice.find(function (v) { - return name.toLowerCase().indexOf(v.toLowerCase()) >= 0; - }); - name = translate ? translate : name; - if (name.toLowerCase().indexOf('dub') >= 0 || name.toLowerCase() == 'd') name = Lang.translate('torrent_parser_voice_dubbing'); - line.push(Utils$2.shortText(Utils$2.capitalizeFirstLetter(name), 20)); - } - - if (line.length) ffprobe_tags.push({ - media: 'audio', - value: line.join(' - ') - }); - }); - var find_subtitles = []; - subs.forEach(function (a) { - var lang = (a.tags.language || '').toUpperCase(); - if (lang) find_subtitles.push(lang); - }); - find_subtitles = find_subtitles.filter(function (el, pos) { - return find_subtitles.indexOf(el) == pos; - }); - find_subtitles.slice(0, 4).forEach(function (a) { - ffprobe_tags.push({ - media: 'subtitle', - value: a - }); - }); - if (find_subtitles.length > 4) ffprobe_tags.push({ - media: 'subtitle', - value: '+' + (find_subtitles.length - 4) - }); - ffprobe_tags = ffprobe_tags.filter(function (el, pos) { - return ffprobe_tags.map(function (a) { - return a.value + a.media; - }).indexOf(el.value + el.media) == pos; - }); - ffprobe_tags.forEach(function (tag) { - ffprobe_elem.append('
    ' + tag.value + '
    '); - }); - if (ffprobe_tags.length) ffprobe_elem.removeClass('hide'); - } - - if (!bitrate) item.find('.bitrate').remove(); - if (element.viewed) item.append('
    ' + Template$1.get('icon_viewed', {}, true) + '
    '); - if (!element.size || parseInt(element.size) == 0) item.find('.torrent-item__size').remove(); - item.on('hover:focus', function (e) { - last = e.target; - scroll.update($(e.target), true); - Helper.show('torrents', Lang.translate('helper_torrents'), item); - }).on('hover:hover hover:touch', function (e) { - last = e.target; - Navigator.focused(last); - }).on('hover:enter', function (e) { - last = e.target; - Torrent.opened(function () { - _this5.mark(element, item, true); - }); - - if (element.reguest && !element.MagnetUri) { - _this5.loadMagnet(element); - } else { - element.poster = object.movie.img; - - _this5.start(); - - Torrent.start(element, object.movie); - } - - Lampa.Listener.send('torrent', { - type: 'onenter', - element: element, - item: item - }); - }).on('hover:long', function () { - var enabled = Controller.enabled().name; - var menu = [{ - title: Lang.translate('torrent_parser_add_to_mytorrents'), - tomy: true - }, { - title: Lang.translate('torrent_parser_label_title'), - subtitle: Lang.translate('torrent_parser_label_descr'), - mark: true - }, { - title: Lang.translate('torrent_parser_label_cancel_title'), - subtitle: Lang.translate('torrent_parser_label_cancel_descr'), - unmark: true - }]; - Lampa.Listener.send('torrent', { - type: 'onlong', - element: element, - item: item, - menu: menu - }); - Select.show({ - title: Lang.translate('title_action'), - items: menu, - onBack: function onBack() { - Controller.toggle(enabled); - }, - onSelect: function onSelect(a) { - if (a.tomy) { - if (element.reguest && !element.MagnetUri) { - _this5.loadMagnet(element, function () { - _this5.addToBase(element); - }); - } else _this5.addToBase(element); - } else if (a.mark) { - _this5.mark(element, item, true); - } else if (a.unmark) { - _this5.mark(element, item, false); - } - - Controller.toggle(enabled); - } - }); - }); - Lampa.Listener.send('torrent', { - type: 'render', - element: element, - item: item - }); - scroll.append(item); - if (append) Controller.collectionAppend(item); - }); - }; - - this.back = function () { - Activity$1.backward(); - }; - - this.start = function () { - if (Lampa.Activity.active().activity !== this.activity) return; - - if (!initialized) { - initialized = true; - this.initialize(); - } - - Background.immediately(Utils$2.cardImgBackgroundBlur(object.movie)); - Controller.add('content', { - toggle: function toggle() { - Controller.collectionSet(scroll.render(), files.render(true)); - Controller.collectionFocus(last || false, scroll.render(true)); - }, - update: function update() {}, - up: function up() { - if (Navigator.canmove('up')) { - Navigator.move('up'); - } else Controller.toggle('head'); - }, - down: function down() { - Navigator.move('down'); - }, - right: function right() { - if (Navigator.canmove('right')) Navigator.move('right');else filter.render().find('.filter--filter').trigger('hover:enter'); - }, - left: function left() { - var poster = files.render().find('.explorer-card__head-img'); - if (poster.hasClass('focus')) Controller.toggle('menu');else if (Navigator.canmove('left')) Navigator.move('left');else Navigator.focus(poster[0]); - }, - back: this.back - }); - Controller.toggle('content'); - }; - - this.pause = function () {}; - - this.stop = function () {}; - - this.render = function () { - return files.render(); - }; - - this.destroy = function () { - network.clear(); - Parser.clear(); - files.destroy(); - scroll.destroy(); - results = null; - network = null; - }; - } - - function component$c(object) { - var network = new create$p(); - var scroll = new create$q({ - mask: true, - over: true, - step: 250, - end_ratio: 2 - }); - var items = []; - var html = $('
    '); - var body = $('
    '); - var total_pages = 0; - var last; - var torrents = []; - - this.create = function () { - var _this = this; - - this.activity.loader(true); - Torserver.my(this.build.bind(this), function () { - var empty = new create$a(); - html.append(empty.render()); - _this.start = empty.start; - - _this.activity.loader(false); - - _this.activity.toggle(); - }); - return this.render(); - }; - - this.next = function () { - if (object.page < 15 && object.page < total_pages) { - object.page++; - var offset = object.page - 1; - this.append(torrents.slice(20 * offset, 20 * offset + 20), true); - } - }; - - this.append = function (data, append) { - var _this2 = this; - - data.forEach(function (element) { - element.title = element.title.replace('[LAMPA] ', ''); - var item_data = Arrays.decodeJson(element.data, {}); - var card = new Card(element, { - card_category: true - }); - card.create(); - - card.onFocus = function (target, card_data) { - last = target; - scroll.update(card.render(), true); - Background.change(item_data.movie ? Utils$2.cardImgBackground(item_data.movie) : element.poster); - if (scroll.isEnd()) _this2.next(); - }; - - card.onEnter = function (target, card_data) { - last = target; - - _this2.start(); - - Torrent.open(card_data.hash, item_data.lampa && item_data.movie ? item_data.movie : false); - }; - - card.onMenu = function (target, card_data) { - var enabled = Controller.enabled().name; - var menu = []; - - if (item_data.movie) { - menu.push({ - title: Lang.translate('title_card') - }); - } - - menu.push({ - title: Lang.translate('torrent_remove_title'), - subtitle: Lang.translate('torrent_remove_descr'), - remove: true - }); - Select.show({ - title: Lang.translate('title_action'), - items: menu, - onBack: function onBack() { - Controller.toggle(enabled); - }, - onSelect: function onSelect(a) { - if (a.remove) { - Torserver.remove(card_data.hash); - Arrays.remove(items, card); - card.destroy(); - last = false; - Controller.toggle(enabled); - } else { - Activity$1.push({ - url: item_data.movie.url, - component: 'full', - id: item_data.movie.id, - method: item_data.movie.name ? 'tv' : 'movie', - card: item_data.movie, - source: item_data.movie.source || 'cub' - }); - } - } - }); - }; - - card.visible(); - body.append(card.render()); - if (append) Controller.collectionAppend(card.render()); - items.push(card); - }); - }; - - this.build = function (data) { - torrents = data; - total_pages = Math.ceil(torrents.length / 20); - scroll.minus(); - this.append(torrents.slice(0, 20)); - scroll.append(body); - html.append(scroll.render()); - this.activity.loader(false); - this.activity.toggle(); - }; - - this.start = function () { - Controller.add('content', { - toggle: function toggle() { - Controller.collectionSet(scroll.render()); - Controller.collectionFocus(last || false, scroll.render()); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - right: function right() { - Navigator.move('right'); - }, - up: function up() { - if (Navigator.canmove('up')) Navigator.move('up');else Controller.toggle('head'); - }, - down: function down() { - if (Navigator.canmove('down')) Navigator.move('down'); - }, - back: function back() { - Activity$1.backward(); - } - }); - Controller.toggle('content'); - }; - - this.pause = function () {}; - - this.stop = function () {}; - - this.render = function () { - return html; - }; - - this.destroy = function () { - network.clear(); - Arrays.destroy(items); - scroll.destroy(); - html.remove(); - body.remove(); - network = null; - items = null; - html = null; - body = null; - }; - } - - function component$b(object) { - var comp = new component$i(object); - - comp.create = function () { - this.activity.loader(true); - Api.relise(object, this.build.bind(this), this.empty.bind(this)); - }; - - comp.nextPageReuest = function (object, resolve, reject) { - Api.relise(object, resolve.bind(this), reject.bind(this)); - }; - - return comp; - } - - function component$a(object) { - var network = new create$p(); - var scroll = new create$q({ - mask: true, - over: true, - step: 250, - end_ratio: 2 - }); - var items = []; - var html = $('
    '); - var body = $('
    '); - var last; - var collections = []; - var waitload; - - this.create = function () { - var _this = this; - - this.activity.loader(true); - Api.collections(object, this.build.bind(this), function () { - var empty = new create$a(); - html.append(empty.render()); - _this.start = empty.start; - - _this.activity.loader(false); - - _this.activity.toggle(); - }); - return this.render(); - }; - - this.next = function () { - var _this2 = this; - - if (waitload) return; - - if (object.page < 30) { - waitload = true; - object.page++; - Api.collections(object, function (result) { - _this2.append(result.results, true); - - if (result.results.length) waitload = false; - }, function () {}); - } - }; - - this.append = function (data, append) { - var _this3 = this; - - data.forEach(function (element) { - var card = new Card(element, { - card_collection: true, - object: object - }); - card.create(); - - card.onFocus = function (target, card_data) { - last = target; - scroll.update(card.render(), true); - Background.change(Utils$2.cardImgBackground(card_data)); - if (scroll.isEnd()) _this3.next(); - }; - - card.onEnter = function (target, card_data) { - Activity$1.push({ - url: card_data.url, - id: card_data.id, - title: Lang.translate('title_collections') + ' - ' + card_data.title, - component: 'collections_view', - source: object.source, - page: 1 - }); - }; - - card.onMenu = function (target, card_data) {}; - - card.visible(); - body.append(card.render()); - if (append) Controller.collectionAppend(card.render()); - items.push(card); - }); - }; - - this.build = function (data) { - collections = data.results; - scroll.minus(); - this.append(collections.slice(0, 20)); - scroll.append(body); - html.append(scroll.render()); - this.activity.loader(false); - this.activity.toggle(); - }; - - this.start = function () { - Controller.add('content', { - toggle: function toggle() { - Controller.collectionSet(scroll.render()); - Controller.collectionFocus(last || false, scroll.render()); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - right: function right() { - Navigator.move('right'); - }, - up: function up() { - if (Navigator.canmove('up')) Navigator.move('up');else Controller.toggle('head'); - }, - down: function down() { - if (Navigator.canmove('down')) Navigator.move('down'); - }, - back: function back() { - Activity$1.backward(); - } - }); - Controller.toggle('content'); - }; - - this.pause = function () {}; - - this.stop = function () {}; - - this.render = function () { - return html; - }; - - this.destroy = function () { - network.clear(); - Arrays.destroy(items); - scroll.destroy(); - html.remove(); - body.remove(); - network = null; - items = null; - html = null; - body = null; - }; - } - - function component$9(object) { - var comp = new component$i(object); - - comp.create = function () { - Api.collections(object, this.build.bind(this), this.empty.bind(this)); - }; - - return comp; - } - - function component$8(object) { - var html = $('
    '); - var empty = new create$a(); - - this.create = function () { - var card = object.movie || object.card; - var foot = $(''); - var button_reset = $('
    ' + Lang.translate('title_reset') + '
    '); - var button_movie = $('
    ' + Lang.translate('back_to_card') + '
    '); - button_reset.on('hover:enter', function () { - Activity$1.replace(); - }); - foot.append(button_reset); - - if (card) { - button_movie.on('hover:enter', function () { - Activity$1.replace({ - component: 'full', - card: card, - id: card.id, - method: card.number_of_seasons ? 'tv' : 'movie', - source: card.source || 'cub' - }); - }); - foot.append(button_movie); - } - - empty.append(foot); - html.append(empty.render()); - this.start = empty.start; - this.activity.loader(false); - this.activity.toggle(); - }; - - this.start = function () { - Controller.add('content', { - toggle: function toggle() { - Controller.collectionSet(empty.render()); - Controller.collectionFocus(false, empty.render()); - }, - left: function left() { - Controller.toggle('menu'); - }, - up: function up() { - Controller.toggle('head'); - }, - back: function back() { - Activity$1.backward(); - } - }); - Controller.toggle('content'); - }; - - this.pause = function () {}; - - this.stop = function () {}; - - this.render = function () { - return html; - }; - - this.destroy = function () { - html.remove(); - }; - } - - function component$7(object) { - var _this = this; - - var scroll = new create$q({ - mask: true, - over: true, - step: 300 - }); - var html = $('
    '); - var body = $('
    '); - var cards = Favorite.full().card; - var table = TimeTable.all(); - var last; - - this.create = function () { - if (Account.working()) cards = Account.all(); - - if (table.length) { - var date_max = 0; - var date_now = new Date(); - var date_end = new Date(); - var date_one = 24 * 60 * 60 * 1000; - table.forEach(function (elem) { - elem.episodes.forEach(function (ep) { - var air = Utils$2.parseToDate(ep.air_date); - var tim = air.getTime(); - - if (date_max < tim) { - date_max = tim; - date_end = air; - } - }); - }); - var date_dif = Math.max(30, Math.min(30, Math.round(Math.abs((date_now - date_end) / date_one)))); - - if (date_dif > 0) { - for (var i = 0; i < date_dif; i++) { - this.append(date_now); - date_now.setDate(date_now.getDate() + 1); - } - - scroll.minus(); - scroll.append(body); - html.append(scroll.render()); - } else this.empty(); - } else this.empty(); - - this.activity.loader(false); - this.activity.toggle(); - return this.render(); - }; - - this.empty = function () { - var empty = new create$a({ - descr: Lang.translate('timetable_empty') - }); - html.append(empty.render()); - _this.start = empty.start; - - _this.activity.loader(false); - - _this.activity.toggle(); - }; - - this.append = function (date) { - var item = $("\n
    \n
    \n
    \n
    \n
    \n
    \n "); - var air_date = date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) + '-' + ('0' + date.getDate()).slice(-2); - var air_epis = []; - var day_week = Utils$2.parseTime(date.getTime()); - var weeks = [Lang.translate('week_7'), Lang.translate('week_1'), Lang.translate('week_2'), Lang.translate('week_3'), Lang.translate('week_4'), Lang.translate('week_5'), Lang.translate('week_6')]; - table.forEach(function (elem) { - elem.episodes.forEach(function (ep) { - var card = cards.find(function (card) { - return card.id == elem.id; - }); - - if (ep.air_date == air_date && card) { - air_epis.push({ - episode: ep, - card: cards.find(function (card) { - return card.id == elem.id; - }) - }); - } - }); - }); - - if (air_epis.length) { - air_epis.slice(0, 3).forEach(function (elem) { - item.find('.timetable__body').append('
    ' + elem.card.name + '
    '); - }); - - if (air_epis.length > 3) { - item.find('.timetable__body').append('
    +' + (air_epis.length - 3) + '
    '); - } - - if (air_epis.length == 1) { - var preview = $('
    ' + (air_epis[0].episode.name || Lang.translate('noname')) + '
    '); - Utils$2.imgLoad(preview.find('img'), TMDB$1.image('t/p/w200/' + air_epis[0].episode.still_path), false, function () { - preview.find('img').remove(); - }); - item.find('.timetable__body').prepend(preview); - } - - item.addClass('timetable__item--any'); - } - - item.find('.timetable__date').text(day_week["short"] + ' - ' + weeks[date.getDay()] + '.'); - item.on('hover:focus', function () { - last = $(this)[0]; - scroll.update($(this)); - }).on('hover:hover', function () { - last = $(this)[0]; - Navigator.focused(last); - }).on('hover:enter', function () { - last = $(this)[0]; - var modal = $('
    '); - air_epis.forEach(function (elem) { - var noty = Template$1.get('notice_card', { - time: Utils$2.parseTime(air_date).full, - title: elem.card.name, - descr: Lang.translate('full_season') + ' - ' + elem.episode.season_number + '
    ' + Lang.translate('full_episode') + ' - ' + elem.episode.episode_number + '' - }); - Utils$2.imgLoad(noty.find('img'), elem.card.poster ? elem.card.poster : elem.card.img ? elem.card.img : TMDB$1.image('t/p/w200/' + elem.card.poster_path), function () { - noty.addClass('image--loaded'); - }); - noty.on('hover:enter', function () { - Modal.close(); - Activity$1.push({ - url: '', - component: 'full', - id: elem.card.id, - method: 'tv', - card: elem.card, - source: elem.card.source - }); - }); - modal.append(noty); - }); - Modal.open({ - title: Lang.translate('menu_tv'), - size: 'medium', - html: modal, - onBack: function onBack() { - Modal.close(); - Controller.toggle('content'); - } - }); - }); - body.append(item); - }; - - this.back = function () { - Activity$1.backward(); - }; - - this.start = function () { - Controller.add('content', { - link: this, - toggle: function toggle() { - Controller.collectionSet(scroll.render()); - Controller.collectionFocus(last || false, scroll.render()); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - right: function right() { - Navigator.move('right'); - }, - up: function up() { - if (Navigator.canmove('up')) Navigator.move('up');else Controller.toggle('head'); - }, - down: function down() { - if (Navigator.canmove('down')) Navigator.move('down'); - }, - back: this.back - }); - Controller.toggle('content'); - }; - - this.pause = function () {}; - - this.stop = function () {}; - - this.render = function () { - return html; - }; - - this.destroy = function () { - scroll.destroy(); - html.remove(); - }; - } - - function component$6(object) { - var comp = new component$i(object); - - comp.create = function () { - this.activity.loader(true); - Account.subscribes(object, this.build.bind(this), this.empty.bind(this)); - return this.render(); - }; - - return comp; - } - - function Company(data) { - var html; - - this.create = function () { - html = Template$1.get('company', { - name: data.name, - img: data.logo_path ? Api.img(data.logo_path) : data.img || 'img/img_broken.svg', - place: (data.headquarters ? data.headquarters + (data.origin_country ? ', ' : '') : '') + (data.origin_country ? data.origin_country : '') - }); - if (!data.logo_path) html.addClass('icon--broken'); - }; - - this.toggle = function () { - var _this = this; - - Controller.add('company', { - invisible: true, - toggle: function toggle() { - Controller.collectionSet(_this.render()); - Controller.collectionFocus(false, _this.render()); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - down: this.onDown, - up: this.onUp, - back: this.onBack - }); - Controller.toggle('company'); - }; - - this.render = function (js) { - return js ? html[0] : html; - }; - - this.destroy = function () { - html.remove(); - }; - } - - function component$5(object) { - var comp = new Lampa.InteractionMain(object); - - comp.create = function () { - var _this = this; - - this.activity.loader(true); - Api.company(object, function (data) { - var company = new Company(data.company); - company.create(); - - _this.push(company); - - _this.build(data.lines); - }, this.empty.bind(this)); - return this.render(); - }; - - return comp; - } - - function Feed(object) { - var network = new create$p(); - var scroll = new create$q({ - mask: true, - over: true, - step: 250, - end_ratio: 2 - }); - var html = document.createElement('div'); - var feed = []; - var last; - - this.create = function () { - var _this = this; - - this.activity.loader(true); - network.silent(Utils$2.protocol() + object$2.cub_domain + '/api/feed/all', this.build.bind(this), function () { - var empty = new create$a(); - html.append(empty.render(true)); - _this.start = empty.start; - - _this.activity.loader(false); - - _this.activity.toggle(); - }); - return this.render(); - }; - - this.next = function () { - if (object.page < 15) { - object.page++; - var offset = object.page - 1; - this.append(feed.slice(20 * offset, 20 * offset + 20), true); - } - }; - - this.loadImg = function (box, src) { - var img = box.find('img'); - - img.onload = function () { - box.addClass('loaded'); - }; - - img.onerror = function () { - img.src = './img/img_broken.svg'; - }; - - img.src = src; - }; - - this.append = function (data, append) { - var _this2 = this; - - data.forEach(function (element) { - var item = Template$1.js(element.type == 'episode' || element.type == 'trailer' ? 'feed_episode' : 'feed_item'); - item.addClass('feed-item--' + element.type); - var type = { - top: Lampa.Lang.translate('title_in_top'), - now_playing: Lampa.Lang.translate('title_now_watch'), - uhd: Lampa.Lang.translate('title_in_high_quality'), - popular: Lampa.Lang.translate('title_popular'), - trailer: Lampa.Lang.translate('title_trailers'), - episode: Lampa.Lang.translate('card_new_episode'), - now: Lampa.Lang.translate('title_new') - }; - var sity = element.data.countries || []; - var year = ((element.data.release_date || element.data.first_air_date) + '').slice(0, 4); - var info = []; - var tags = []; - info.push(year + (sity.length ? ' - ' + sity.slice(0, 2).join(', ') : '')); - - if (element.data.imdb_rating && parseFloat(element.data.imdb_rating) > 0) { - info.push('IMDB ' + element.data.imdb_rating); - } - - if (element.data.kp_rating && parseFloat(element.data.kp_rating) > 0) { - info.push('KP ' + element.data.kp_rating); - } - - if (element.type == 'episode') { - tags = element.hash.split(';').map(function (a) { - return Lang.translate(a.slice(0, 1) == 's' ? 'torrent_serial_season' : 'torrent_serial_episode') + ' - ' + a.slice(1); - }); - } else if (element.data.genres) tags.push(element.data.genres.join(', '));else if (element.data.genre_ids) { - tags.push(Api.sources.tmdb.getGenresNameFromIds(element.card_type, element.data.genre_ids).join(', ')); - } - - item.find('.feed-item__label').addClass('feed-item__label--' + element.type).text(type[element.type]); - item.find('.feed-item__title').text(element.data.title || element.data.name); - item.find('.feed-item__info').text(info.join(' / ')); - item.find('.feed-item__descr').text(element.data.overview || ''); - item.find('.feed-item__tags').text(tags.join(' / ')); - - _this2.loadImg(item.find('.feed-item__poster-box'), element.data.poster_path ? Api.img(element.data.poster_path, 'w500') : './img/img_broken.svg'); - - var image = item.find('.feed-item__image-box'); - - if (image) { - _this2.loadImg(image, Api.img(element.type == 'episode' ? element.data.episode.still_path : element.data.backdrop_path, 'w780')); - } - - scroll.append(item); - var btn_watch = document.createElement('div'); - btn_watch.addClass('simple-button selector'); - btn_watch.text(Lang.translate('title_watch')); - btn_watch.on('hover:focus', function () { - last = btn_watch; - scroll.update(item); - Background.change(Api.img(element.data.poster_path, 'w500')); - }); - btn_watch.on('hover:enter', function () { - Activity$1.push({ - url: '', - component: 'full', - id: element.card_id, - method: element.card_type, - card: element.data, - source: element.data.source || 'tmdb' - }); - }); - item.find('.feed-item__buttons').append(btn_watch); - if (append) Controller.collectionAppend(btn_watch); - }); - }; - - this.build = function (data) { - feed = data.result; - html.addClass('feed'); - var head = Template$1.js('feed_head'); - head.find('.feed-head__title').text(Lang.translate('lampa_movie_title')); - head.find('.feed-head__info').html(Lang.translate('lampa_movie_descr')); - head.on('hover:focus', scroll.update.bind(scroll, head)); - scroll.minus(); - - scroll.onWheel = function (step) { - Navigator.move(step > 0 ? 'down' : 'up'); - }; - - scroll.onEnd = this.next.bind(this); - scroll.append(head); - this.append(feed.slice(0, 20)); - html.append(scroll.render(true)); - this.activity.loader(false); - this.activity.toggle(); - }; - - this.start = function () { - Controller.add('content', { - toggle: function toggle() { - Controller.collectionSet(scroll.render(true)); - Controller.collectionFocus(last || false, scroll.render(true)); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - right: function right() { - Navigator.move('right'); - }, - up: function up() { - if (Navigator.canmove('up')) Navigator.move('up');else Controller.toggle('head'); - }, - down: function down() { - if (Navigator.canmove('down')) Navigator.move('down'); - }, - back: function back() { - Activity$1.backward(); - } - }); - Controller.toggle('content'); - }; - - this.pause = function () {}; - - this.stop = function () {}; - - this.render = function () { - return html; - }; - - this.destroy = function () { - network.clear(); - scroll.destroy(); - html.remove(); - }; - } - - function component$4(object) { - var all = Favorite.all(); - var comp = new Lampa.InteractionMain(object); - var viev_all = false; - - comp.create = function () { - this.activity.loader(true); - Account.notice(function (notice) { - var invoice = notice.filter(function (a) { - return a.method == 'tv-voice'; - }); - var category = ['look', 'scheduled', 'book', 'like', 'wath', 'viewed', 'continued', 'thrown']; - var lines = []; - var voice = []; - category.forEach(function (a) { - if (all[a].length) { - var items = Arrays.clone(all[a].slice(0, 20)); - items.forEach(function (a) { - return a.ready = false; - }); - lines.push({ - title: Lang.translate('title_' + a), - results: items, - type: a - }); - all[a].forEach(function (card) { - var noti = invoice.find(function (a) { - return a.card_id == card.id; - }); - - if (noti) { - // сам не помню, баг будет если не клонировать - var card_clone = Arrays.clone(card); - card_clone.ready = false; - var hash = Utils$2.hash([noti.season, noti.season > 10 ? ':' : '', noti.episode, card_clone.original_title].join('')); - var view = Timeline.view(hash); - - if (!view.percent && !voice.find(function (a) { - return a.id == card_clone.id; - })) { - voice.push(card_clone); - } - } - }); - } - }); - - if (voice.length) { - Storage.set('player_continue_watch', Arrays.clone(voice.slice(0, 20))); - Arrays.insert(lines, 0, { - title: Lang.translate('card_new_episode'), - results: voice.slice(0, 20) - }); - } - - if (lines.length) { - Arrays.insert(lines, 0, { - title: '', - results: [] - }); - comp.build(lines); - Layer.visible(); - } else comp.empty(); - }); - return this.render(); - }; - - comp.onAppend = function (line, elem) { - if (elem.results.length == 0) { - line.render(true).removeClass('items-line--type-cards').find('.items-line__head').addClass('hide'); - var body = line.render(true).find('.scroll__body'); - var category = ['book', 'like', 'wath', 'look', 'viewed', 'scheduled', 'continued', 'thrown']; - category.forEach(function (a) { - var register = Template$1.js('register'); - register.addClass('selector'); - register.find('.register__name').text(Lang.translate('title_' + a)); - register.find('.register__counter').text(all[a].length); - register.on('hover:enter', function () { - Activity$1.push({ - url: '', - title: Lang.translate('title_' + a), - component: 'favorite', - type: a, - page: 1 - }); - }); - register.on('hover:focus', function () { - line.render(true).find('.scroll').Scroll.update(register, true); - }); - body.append(register); - }); - } else { - line.render(true).on('visible', function () { - var more = line.render(true).find('.items-line__more'); - - if (more) { - more.text(Lang.translate('settings_param_card_view_all')); - more.on('hover:enter', function () { - viev_all = true; - }); - } - }); - } - }; - - comp.onMore = function (line) { - setTimeout(function () { - Activity$1.push({ - url: '', - title: Lang.translate('title_' + line.type), - component: 'favorite', - type: line.type, - page: viev_all ? 1 : 2 - }); - viev_all = false; - }, 50); - }; - - return comp; - } - - function component$3(object) { - var explorer = new Explorer(object); - var filter = new create$5(object); - var scroll = new create$q({ - mask: true, - over: true - }); - var last; - var choice = { - season: object.movie.number_of_seasons - }; - - this.create = function () { - this.filter(); - this.selected(); - explorer.appendFiles(scroll.render()); - explorer.appendHead(filter.render()); - scroll.body().addClass('torrent-list'); - explorer.render().find('.filter--search, .filter--sort').remove(); - scroll.minus(explorer.render().find('.explorer__files-head')); - this.load(); - this.activity.toggle(); - return this.render(); - }; - - this.filter = function () { - var _this = this; - - filter.addButtonBack(); - - filter.onSelect = function (type, a, b) { - choice.season = b.season; //и так сойде ;] - - _this.selected(); - - _this.load(); - }; - - filter.onBack = function () { - _this.start(); - }; - }; - - this.selected = function () { - var select = []; - var seasons = []; - - for (var i in choice) { - if (i == 'season') select.push(Lang.translate('torrent_serial_season') + ': ' + choice[i]); - } - - for (var _i = 0; _i < object.movie.number_of_seasons; _i++) { - seasons.push({ - title: _i + 1, - season: _i + 1 - }); - } - - filter.set('filter', [{ - title: Lang.translate('torrent_serial_season'), - subtitle: choice.season, - noselect: true, - items: seasons - }]); - filter.chosen('filter', select); - }; - - this.load = function () { - var _this2 = this; - - this.activity.loader(true); - var season = choice.season; - Api.clear(); - Api.seasons(object.movie, [season], function (v) { - last = false; - scroll.clear(); - scroll.reset(); - - if (v[season] && v[season].episodes && v[season].episodes.length) { - _this2.season(v[season]); - - _this2.draw(v[season].episodes); - } else { - _this2.empty(); - } - - _this2.activity.loader(false); - }); - }; - - this.season = function (season) { - var head = []; - if (season.vote_average) head.push(Lang.translate('title_rating') + ': ' + parseFloat(season.vote_average + '').toFixed(1)); - if (season.air_date) head.push(Lang.translate('full_date_of_release') + ': ' + Utils$2.parseTime(season.air_date).full); - head.push(Lang.translate('title_episodes') + ': ' + season.episodes.length); - season.head = head.join('  ●  '); - var tpl = Template$1.get('season_info', season); - tpl.on('hover:focus', function (e) { - scroll.update($(e.target), true); - }); - if (!season.overview) tpl.find('.season-info__overview').remove(); - scroll.append(tpl); - }; - - this.empty = function () { - var em = Template$1.get('empty_filter'); - var bn = $('
    ' + Lang.translate('filter_clarify') + '
    '); - bn.on('hover:enter', function () { - filter.render().find('.filter--filter').trigger('hover:enter'); - }); - em.find('.empty-filter__title').remove(); - em.find('.empty-filter__buttons').removeClass('hide').append(bn); - scroll.append(em); - Controller.enable('content'); - }; - - this.draw = function (episodes) { - episodes.forEach(function (episode, index) { - var number = episode.episode_number || index + 1; - var hash = Utils$2.hash([choice.season, choice.season > 10 ? ':' : '', number, object.movie.original_title].join('')); - var info = []; - var out_air = new Date((episode.air_date + '').replace(/-/g, '/')); - var out_now = Date.now(); - var out_day = episode.air_date ? Math.round((out_air.getTime() - out_now) / (24 * 60 * 60 * 1000)) : 1; - var out_txt = Lang.translate('full_episode_days_left') + ': ' + (episode.air_date ? out_day : '- -'); - episode.timeline = Timeline.view(hash); - episode.time = Utils$2.secondsToTime(episode.runtime * 60, true); - episode.title = episode.name || Lang.translate('torrent_serial_episode') + ' ' + number; - episode.quality = out_day > 0 ? out_txt : ''; - if (episode.vote_average) info.push(Template$1.get('season_episode_rate', { - rate: parseFloat(episode.vote_average + '').toFixed(1) - }, true)); - if (episode.air_date) info.push(Utils$2.parseTime(episode.air_date).full); - episode.info = info.length ? info.map(function (i) { - return '' + i + ''; - }).join('') : ''; - var html = Template$1.get('season_episode', episode); - var loader = html.find('.season-episode__loader'); - var image = html.find('.season-episode__img'); - - var viewed = function viewed() { - html.find('.season-episode__viewed').remove(); - if (Boolean(episode.timeline.percent)) html.find('.season-episode__img').append('
    ' + Template$1.get('icon_viewed', {}, true) + '
    '); - }; - - html.find('.season-episode__timeline').append(Timeline.render(episode.timeline)); - if (out_day > 0) html.css('opacity', '0.5');else { - viewed(); - if (Boolean(episode.timeline.percent)) last = html[0]; - html.on('hover:enter', function () { - if (Boolean(episode.timeline.percent)) { - episode.timeline.time = 0; - episode.timeline.percent = 0; - } else { - episode.timeline.time = episode.timeline.duration * 0.95; - episode.timeline.percent = 95; - } - - Timeline.update(episode.timeline); - viewed(); - }); - } - html.on('hover:enter', function () {}).on('hover:focus', function (e) { - last = e.target; - scroll.update($(e.target), true); - }).on('visible', function () { - var img = html.find('img')[0]; - - img.onerror = function () { - img.src = './img/img_broken.svg'; - }; - - img.onload = function () { - image.addClass('season-episode__img--loaded'); - loader.remove(); - image.append('
    ' + ('0' + number).slice(-2) + '
    '); - }; - - if (episode.still_path) img.src = TMDB$1.image('t/p/w300' + episode.still_path);else if (episode.img) img.src = episode.img;else { - loader.remove(); - image.append('
    ' + ('0' + number).slice(-2) + '
    '); - } - }).on('hover:hover hover:touch', function (e) { - last = e.target; - Navigator.focused(last); - }); - scroll.append(html); - }); - if (last) scroll.update($(last), true); - Layer.visible(scroll.render(true)); - Controller.enable('content'); - }; - - this.start = function () { - if (Activity$1.active().activity !== this.activity) return; - Background.immediately(Utils$2.cardImgBackgroundBlur(object.movie)); - Controller.add('content', { - toggle: function toggle() { - Controller.collectionSet(scroll.render(), explorer.render()); - Controller.collectionFocus(last || false, scroll.render()); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - right: function right() { - filter.show(Lang.translate('title_filter'), 'filter'); - }, - up: function up() { - if (Navigator.canmove('up')) Navigator.move('up');else Controller.toggle('head'); - }, - down: function down() { - if (Navigator.canmove('down')) Navigator.move('down'); - }, - back: function back() { - Activity$1.backward(); - } - }); - Controller.toggle('content'); - }; - - this.pause = function () {}; - - this.stop = function () {}; - - this.render = function () { - return explorer.render(); - }; - - this.destroy = function () {}; - } - - function component$2(object) { - var network = new create$p(); - var scroll = new create$q({ - mask: true, - over: true, - step: 250, - end_ratio: 2 - }); - var items = []; - var html = document.createElement('div'); - var body = document.createElement('div'); - var last; - var active = 0; - - var follow = function follow(event) { - if (event.name == 'person_subscribes_id') { - items.forEach(function (card) { - if (event.value.indexOf(card.data.id) == -1) { - card.render(true).style.opacity = 0.5; - - card.onEnter = function () {}; - } - }); - } - }; - - this.create = function () { - this.activity.loader(true); - Storage.listener.follow('change', follow); - Account.persons(this.build.bind(this), this.empty.bind(this)); - }; - - this.empty = function () { - var empty = new create$a(); - html.appendChild(empty.render(true)); - this.start = empty.start; - this.activity.loader(false); - this.activity.toggle(); - }; - - this.append = function (data, append) { - data.forEach(function (element) { - var card = new Card(element.person, { - card_category: true - }); - card.create(); - - card.onFocus = function (target, card_data) { - last = target; - active = items.indexOf(card); - scroll.update(card.render(true)); - Background.change(Utils$2.cardImgBackgroundBlur(card_data)); - }; - - card.onTouch = function (target, card_data) { - last = target; - active = items.indexOf(card); - }; - - card.onEnter = function (target, card_data) { - last = target; - Activity$1.push({ - url: element.person.url, - title: Lang.translate('title_person'), - component: 'actor', - id: element.person_id, - source: object.source - }); - }; - - card.onMenu = function () {}; - - body.appendChild(card.render(true)); - items.push(card); - if (append) Controller.collectionAppend(card.render(true)); - }); - }; - - this.limit = function () { - var limit_view = 12; - var lilit_collection = 36; - var colection = items.slice(Math.max(0, active - limit_view), active + limit_view); - items.forEach(function (item) { - if (colection.indexOf(item) == -1) { - item.render(true).classList.remove('layer--render'); - } else { - item.render(true).classList.add('layer--render'); - } - }); - Navigator.setCollection(items.slice(Math.max(0, active - lilit_collection), active + lilit_collection).map(function (c) { - return c.render(true); - })); - Navigator.focused(last); - Layer.visible(scroll.render(true)); - }; - - this.build = function (data) { - var _this = this; - - if (data.length) { - body.classList.add('category-full'); - scroll.minus(); - scroll.onScroll = this.limit.bind(this); - - scroll.onWheel = function (step) { - if (!Controller.own(_this)) _this.start(); - if (step > 0) Navigator.move('down');else Navigator.move('up'); - }; - - this.append(data); - scroll.append(body); - html.appendChild(scroll.render(true)); - this.limit(); - this.activity.loader(false); - this.activity.toggle(); - } else { - this.empty(); - } - }; - - this.start = function () { - var _this2 = this; - - Controller.add('content', { - link: this, - toggle: function toggle() { - if (_this2.activity.canRefresh()) return false; - Controller.collectionSet(scroll.render(true)); - Controller.collectionFocus(last || false, scroll.render(true)); - }, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - right: function right() { - if (_this2.onRight) { - if (Navigator.canmove('right')) Navigator.move('right');else _this2.onRight(); - } else Navigator.move('right'); - }, - up: function up() { - if (Navigator.canmove('up')) Navigator.move('up');else Controller.toggle('head'); - }, - down: function down() { - if (Navigator.canmove('down')) Navigator.move('down'); - }, - back: function back() { - Activity$1.backward(); - } - }); - Controller.toggle('content'); - }; - - this.refresh = function () { - this.activity.needRefresh(); - }; - - this.pause = function () {}; - - this.stop = function () {}; - - this.render = function (js) { - return js ? html : $(html); - }; - - this.destroy = function () { - network.clear(); - Arrays.destroy(items); - scroll.destroy(); - Storage.listener.remove('change', follow); - html.remove(); - body.remove(); - items = []; - }; - } - - var component$1 = { - main: component$k, - full: component$j, - category: component$g, - category_full: component$h, - actor: component$f, - favorite: component$e, - torrents: component$d, - mytorrents: component$c, - relise: component$b, - collections: component$a, - collections_view: component$9, - nocomponent: component$8, - timetable: component$7, - subscribes: component$6, - company: component$5, - feed: Feed, - bookmarks: component$4, - episodes: component$3, - myperson: component$2 - }; - /** - * Создать компонент - * @param {{component:string}} object - * @returns - */ - - function create$4(object) { - if (component$1[object.component]) { - try { - return new component$1[object.component](object); - } catch (e) { - console.log('Component', 'create error', e.stack); - return new component$1.nocomponent(object); - } - } else { - return new component$1.nocomponent(object); - } - } - /** - * Добавить - * @param {string} name - * @param {class} comp - */ - - - function add$5(name, comp) { - component$1[name] = comp; - } - /** - * Получить компонент - * @param {string} name - * @returns {class} - */ - - - function get$2(name) { - return component$1[name]; - } - - var Component = { - create: create$4, - add: add$5, - get: get$2 - }; - - var listener$3 = start$8(); - var activites = []; - var callback = false; - var fullout = false; - var content; - var slides; - var maxsave; - var base; - - function Activity(component, object) { - var slide = Template$1.js('activity'); - var body = slide.querySelector('.activity__body'); - this.stoped = false; - this.started = false; - /** - * Добовляет активити в список активитис - */ - - this.append = function () { - slides.appendChild(slide); - }; - /** - * Создает новую активность - */ - - - this.create = function () { - try { - component.create(body); - - var _render = component.render(true); - - body.appendChild(_render instanceof jQuery ? _render[0] : _render); - } catch (e) { - console.log('Activity', 'create error:', e.stack); - } - }; - /** - * Показывает загрузку - * @param {boolean} status - */ - - - this.loader = function (status) { - if (status) slide.classList.add('activity--load');else slide.classList.remove('activity--load'); - }; - /** - * Создает повторно - */ - - - this.restart = function () { - this.append(); - this.stoped = false; - component.start(); - }; - /** - * Стартуем активную активность - */ - - - this.start = function () { - this.started = true; - Controller.add('content', { - invisible: true, - update: function update() {}, - toggle: function toggle() {}, - left: function left() { - Controller.toggle('menu'); - }, - up: function up() { - Controller.toggle('head'); - }, - back: function back() { - backward(); - } - }); - Controller.toggle('content'); //Layer.update(slide) - - if (this.stoped) this.restart();else component.start(); - }; - /** - * Пауза - */ - - - this.pause = function () { - this.started = false; - component.pause(); - }; - /** - * Включаем активность если она активна - */ - - - this.toggle = function () { - if (this.started) this.start(); - }; - - this.refresh = function () { - if (component.refresh) component.refresh(); - }; - - this.canRefresh = function () { - var status = this.started && this.need_refresh && inActivity() ? true : false; - - if (status) { - this.need_refresh = false; - replace(object); - } - - return status; - }; - - this.needRefresh = function () { - var _this = this; - - if (body.parentElement) body.parentElement.removeChild(body); - this.need_refresh = true; - var wait = Template$1.js('activity_wait_refresh'); - wait.addEventListener('click', function (e) { - if (DeviceInput.canClick(e.originalEvent)) _this.canRefresh(); - }); - slide.appendChild(wait); - }; - /** - * Стоп - */ - - - this.stop = function () { - this.started = false; - if (this.stoped) return; - this.stoped = true; - component.stop(); - if (slide.parentElement) slide.parentElement.removeChild(slide); - }; - /** - * Рендер - */ - - - this.render = function (js) { - return js ? slide : $(slide); - }; - /** - * Получить класс компонента - */ - - - this.component = function () { - return component; - }; - /** - * Уничтожаем активность - */ - - - this.destroy = function () { - component.destroy(); //после create работает долгий запрос и затем вызывается build, однако уже было вызвано destroy и возникают ошибки, поэтому заодно чистим функцию build и empty - - for (var f in component) { - if (typeof component[f] == 'function') { - component[f] = function () {}; - } - } - - slide.remove(); - }; - - this.append(); - } - - function parseStart() { - if (window.start_deep_link) return; - var id = Utils$2.gup('card'); - - if (id) { - window.start_deep_link = { - id: id, - component: "full", - method: Utils$2.gup('media') || 'movie', - source: Utils$2.gup('source') || 'cub', - card: { - id: id, - source: Utils$2.gup('source') || 'cub' - } - }; - } else { - try { - var params = new URLSearchParams(window.location.search); - - if (params.has('component')) { - window.start_deep_link = {}; - params.forEach(function (v, n) { - window.start_deep_link[n] = v; - }); - } - } catch (e) { - console.log('Activity', 'url params start error:', e.message); - } - } - } - /** - * Запуск - */ - - - function init$e() { - content = Template$1.js('activitys'); - slides = content.querySelector('.activitys__slides'); - maxsave = Storage.get('pages_save_total', 5); - base = document.querySelector('head base'); - parseStart(); - empty(); - var wait = true; - var swip_status = 0; - var swip_timer; - setTimeout(function () { - wait = false; - }, 1500); - window.addEventListener('popstate', function () { - if (fullout || wait) return; - Screensaver$2.stop(); - if (swip_status == 0) empty(); //это чтоб не выходило с приложения, однако на айфонах это вызвает зависание на 2-3 сек - - listener$3.send('popstate', { - count: activites.length - }); - if (callback) callback();else { - backward(); - } - }); - Storage.listener.follow('change', function (event) { - if (event.name == 'pages_save_total') maxsave = Storage.get('pages_save_total', 5); - - if (event.name == 'light_version') { - activites.forEach(function (activity) { - if (activity.activity) activity.activity.refresh(); - }); - } - }); //исключительно для огрызков пришлось мутить работу свайпа назад - - if (Platform.is('apple')) { - var body = document.querySelector('body'); - body.addEventListener('touchstart', function (e) { - var point = e.touches[0] || e.changedTouches[0]; - - if (point.clientX < window.innerWidth * 0.15 && point.clientX < window.innerHeight - 120) { - swip_status = 1; - clearTimeout(swip_timer); - swip_timer = setTimeout(function () { - swip_status = 0; - }, 2000); - } else { - swip_status = 0; - } - }); - } - } - /** - * Лимит активностей, уничтожать если больше maxsave - */ - - - function limit() { - var curent = active$2(); - if (curent && curent.activity) curent.activity.pause(); - var tree_stop = activites.slice(-2); - if (tree_stop.length > 1 && tree_stop[0].activity) tree_stop[0].activity.stop(); - var tree_destroy = activites.slice(-maxsave); - - if (tree_destroy.length > maxsave - 1) { - var first = tree_destroy[0]; - - if (first.activity) { - first.activity.destroy(); - first.activity = null; - } - } - } - /** - * Обновить адрес в строке из активности - */ - - - function pushState(object, replace, mix) { - var path = window.location.protocol == 'file:' ? '' : base ? '/' : ''; - if (!window.lampa_settings.push_state) return window.history.pushState(null, null, path); - var data = Arrays.clone(object); - delete data.activity; - var comp = []; - - for (var n in data) { - if (typeof data[n] == 'string' || typeof data[n] == 'number') comp.push(n + '=' + encodeURIComponent(data[n])); - } - - var card = object.card || object.movie; - var meth = object.method || (card ? card.name ? 'tv' : 'movie' : ''); - var sour = object.source || (card ? card.source : 'tmdb'); - var durl = card ? '?card=' + card.id + (meth ? '&media=' + meth : '') + (sour ? '&source=' + sour : '') : '?' + comp.join('&'); - if (mix) durl += '&' + mix; - if (replace) window.history.replaceState(null, null, path + durl);else window.history.pushState(null, null, path + durl); - } - /** - * Обновить адрес в строке из активности с добавлением дополнительных параметров - */ - - - function mixState(mix) { - var curent = active$2(); - if (curent && curent.activity) pushState(curent, true, mix); - } - /** - * Добавить новую активность - * @param {{component:string}} object - */ - - - function push$1(object) { - limit(); - create$3(object); - activites.push(object); - start$3(object); - pushState(object); - } - /** - * Создать новую активность - * @param {{component:string}} object - */ - - - function create$3(object) { - var comp = Component.create(object); - object.activity = new Activity(comp, object); - comp.activity = object.activity; - Lampa.Listener.send('activity', { - component: object.component, - type: 'init', - object: object - }); - object.activity.create(); - Lampa.Listener.send('activity', { - component: object.component, - type: 'create', - object: object - }); - } - /** - * Вызов обратно пользователем - */ - - - function back$3() { - window.history.back(); - } - /** - * Получить активную активность - * @returns {object} - */ - - - function active$2() { - return activites[activites.length - 1]; - } - - function inActivity() { - return $('body').hasClass('settings--open') || $('body').hasClass('menu--open') ? false : true; - } - /** - * Создать пустую историю - */ - - - function empty() { - var curent = active$2(); - if (curent && curent.activity) pushState(curent, false, 'r=' + Math.random()); - } - /** - * Получить все активности - * @returns {[{component:string, activity:class}]} - */ - - - function all() { - return activites; - } - /** - * Получить рендеры всех активностей - * @returns {array} - */ - - - function renderLayers(js) { - var result = []; - all().forEach(function (item) { - if (item.activity) result.push(item.activity.render(js)); - }); - return result; - } - /** - * Обработать событие назад - */ - - - function backward() { - callback = false; - listener$3.send('backward', { - count: activites.length - }); - if (activites.length == 1) return; - Array.from(slides.children).forEach(function (slide) { - return slide.classList.remove('activity--active'); - }); - var curent = activites.pop(); - - if (curent) { - setTimeout(function () { - curent.activity.destroy(); - Lampa.Listener.send('activity', { - component: curent.component, - type: 'destroy', - object: curent - }); - }, 200); - } - - var previous_tree = activites.slice(-maxsave); - - if (previous_tree.length > maxsave - 1) { - create$3(previous_tree[0]); - } - - previous_tree = activites.slice(-1)[0]; - - if (previous_tree) { - if (previous_tree.activity) { - start$3(previous_tree); - Lampa.Listener.send('activity', { - component: previous_tree.component, - type: 'archive', - object: previous_tree - }); - pushState(previous_tree, true); - } else { - create$3(previous_tree); - start$3(previous_tree); - pushState(previous_tree); - } - } - } - /** - * Сохранить активность в память - * @param {{component:string, activity:class}} object - */ - - - function save$1(object) { - var saved = {}; - - for (var i in object) { - if (i !== 'activity') saved[i] = object[i]; - } - - Storage.set('activity', saved); - } - /** - * Получить данные активности - * @param {{component:string, activity:class}} object - * @returns {{component:string}} - */ - - - function extractObject(object) { - var saved = {}; - - for (var i in object) { - if (i !== 'activity') saved[i] = object[i]; - } - - return saved; - } - /** - * Активируем следующию активность - * @param {{component:string, activity:class}} object - */ - - - function start$3(object) { - object.activity.start(); - save$1(object); - Array.from(slides.children).forEach(function (slide) { - return slide.classList.remove('activity--active'); - }); - object.activity.render(true).classList.add('activity--active'); - Head.title(object.title); - Lampa.Listener.send('activity', { - component: object.component, - type: 'start', - object: object - }); - } - /** - * С какой активности начать запуск лампы - */ - - - function last$1() { - var active = Storage.get('activity', 'false'); - var start_from = Storage.field("start_page"); - - if (window.start_deep_link) { - push$1(window.start_deep_link); - } else if (active && start_from === "last") { - if (active.page) active.page = 1; - push$1(active); - } else { - var _start_from$split = start_from.split('@'), - _start_from$split2 = _slicedToArray(_start_from$split, 2), - action = _start_from$split2[0], - type = _start_from$split2[1]; - - if (action == 'favorite') { - push$1({ - url: '', - title: Lang.translate(type == 'bookmarks' ? 'settings_input_links' : 'title_history'), - component: type == 'bookmarks' ? 'bookmarks' : 'favorite', - type: type, - page: 1 - }); - } else if (action == 'mytorrents') { - push$1({ - url: '', - title: Lang.translate('title_mytorrents'), - component: 'mytorrents', - page: 1 - }); - } else { - push$1({ - url: '', - title: Lang.translate('title_main') + ' - ' + Storage.field('source').toUpperCase(), - component: 'main', - source: Storage.field('source'), - page: 1 - }); - } - } - } - /** - * Рендер - * @returns {object} - */ - - - function render$3() { - return content; - } - /** - * Подключить обратный вызов при изменени истории - * @param {*} call - */ - - - function call(call) { - callback = call; - } - /** - * Выход из лампы - */ - - - function out() { - fullout = true; - back$3(); - - for (var i = 0; i < window.history.length; i++) { - back$3(); - } - - setTimeout(function () { - fullout = false; - empty(); - }, 100); - } - /** - * Заменить активную активность - * @param {object} replace - */ - - - function replace() { - var replace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var clear = arguments.length > 1 ? arguments[1] : undefined; - var object = extractObject(active$2()); - - for (var i in replace) { - object[i] = replace[i]; - } - - active$2().activity.destroy(); - activites.pop(); - push$1(clear ? replace : object); - } - - var Activity$1 = { - init: init$e, - listener: listener$3, - push: push$1, - back: back$3, - render: render$3, - backward: backward, - call: call, - last: last$1, - out: out, - replace: replace, - active: active$2, - all: all, - extractObject: extractObject, - renderLayers: renderLayers, - inActivity: inActivity, - pushState: pushState, - mixState: mixState - }; - - var listener$2 = start$8(); - var active$1; - var active_name = ''; - var controlls = {}; - var select_active; - - function observe$1() { - if (typeof MutationObserver == 'undefined') return; - var observer = new MutationObserver(function (mutations) { - for (var i = 0; i < mutations.length; i++) { - var mutation = mutations[i]; - - if (mutation.type == 'childList' && !mutation.removedNodes.length) { - var selectors = Array.from(mutation.target.querySelectorAll('.selector')); - selectors.forEach(function (elem) { - if (!elem.classList.contains('hg-button')) bindEvents(elem); - }); - } - } - }); - observer.observe(document, { - childList: true, - subtree: true - }); - } - /** - * Добавить контроллер - * @param {String} name - * @param {Object} calls - */ - - - function add$4(name, calls) { - controlls[name] = calls; - } - /** - * Запустить функцию - * @param {String} name - * @param {Object} params - */ - - - function run(name, params) { - if (active$1) { - if (active$1[name]) { - if (typeof active$1[name] == 'function') active$1[name](params);else if (typeof active$1[name] == 'string') { - run(active$1[name], params); - } - } - } - } - /** - * Двигать - * @param {String} direction - */ - - - function move(direction) { - run(direction); - } - /** - * Вызов enter - */ - - - function enter() { - if (active$1 && active$1.enter) run('enter');else if (select_active) Utils$2.trigger(select_active, 'hover:enter'); - } - /** - * Вызов long - */ - - - function _long() { - if (active$1 && active$1["long"]) run('long');else if (select_active) Utils$2.trigger(select_active, 'hover:long'); - } - /** - * Завершить - */ - - - function finish() { - run('finish'); - } - /** - * Нажали назад - */ - - - function back$2() { - run('back'); - } - /** - * Переключить контроллер - * @param {String} name - */ - - - function toggle$2(name) { - if (active$1 && active$1.gone) active$1.gone(name); - - if (controlls[name]) { - active$1 = controlls[name]; - active_name = name; - Activity$1.call(function () { - run('back'); - }); - if (active$1.toggle) active$1.toggle(); - if (active$1.update) active$1.update();else { - Layer.update(); - } - listener$2.send('toggle', { - name: name - }); - } - } - - function bindEvents(elem) { - if (elem.classList.contains('selector') && !elem.bind_events) { - elem.bind_events = true; - var long_position = 0; - var long_timer; - - var longStart = function longStart() { - clearTimeout(long_timer); - var offset = elem.getBoundingClientRect(); - long_timer = setTimeout(function () { - var time = elem.long_time || 0; - offset = elem.getBoundingClientRect(); - - if (time + 100 < Date.now()) { - var mutation = Math.abs(long_position - (offset.top + offset.left)); - if (mutation < 30) Utils$2.trigger(elem, 'hover:long'); - } - - elem.long_time = Date.now(); - }, 800); - long_position = offset.top + offset.left; - }; - - var longClear = function longClear() { - clearTimeout(long_timer); - }; - - var touchStart = function touchStart() { - longStart(); - Utils$2.trigger(elem, 'hover:touch'); - }; - - var rightClick = function rightClick(e) { - Utils$2.trigger(elem, 'hover:long'); - }; - - elem.trigger_click = function (e) { - if (Storage.field('navigation_type') == 'mouse' || Platform.screen('mobile')) { - if (DeviceInput.canClick(e)) { - Utils$2.trigger(elem, 'hover:enter'); - } - } - }; - - elem.trigger_mouseenter = function () { - clearAllFocus(); - elem.classList.add('focus'); - Utils$2.trigger(elem, 'hover:hover'); - }; - - elem.trigger_mouseleave = function () { - elem.classList.remove('focus'); - }; - - if (Storage.field('navigation_type') == 'mouse' || Platform.screen('mobile')) { - elem.addEventListener('click', elem.trigger_click); - } - - if (!Utils$2.isTouchDevice() && Storage.field('navigation_type') == 'mouse') { - elem.addEventListener('mouseenter', elem.trigger_mouseenter); - elem.addEventListener('mouseleave', elem.trigger_mouseleave); - elem.addEventListener('mouseout', longClear); - elem.addEventListener('mouseup', longClear); - elem.addEventListener('mousedown', longStart); - elem.addEventListener('contextmenu', rightClick); - } - - if (Utils$2.isTouchDevice()) { - elem.addEventListener('touchstart', touchStart); - elem.addEventListener('touchend', longClear); - elem.addEventListener('touchmove', longClear); - } - } - } - - function enable(name) { - if (active_name == name) toggle$2(name); - } - - function clearSelects() { - select_active = false; - removeClass(['focus']); - } - - function clearAllFocus() { - var collection = Array.from(document.body.querySelectorAll('.selector')); - collection.forEach(function (item) { - return item.classList.remove('focus'); - }); - } - /** - * Вызвать событие - * @param {String} name - * @param {Object} params - */ - - - function trigger$1(name, params) { - run(name, params); - } - /** - * Очистить классы - * @param {Array} classes - */ - - - function removeClass(classes) { - if (Navigator._collection) { - Navigator._collection.forEach(function (element) { - classes.forEach(function (class_name) { - element.classList.remove(class_name); - }); - }); - } - } - /** - * Фокус на элементе - * @param {Object} target - */ - - - function focus(target) { - Utils$2.trigger(target, 'hover:focus'); - - if (Platform.screen('tv')) { - removeClass(['focus']); - target.classList.add('focus'); - } - - select_active = target; - } - - function collectionSet(html) { - var append = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - var visible_only = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - html = html instanceof jQuery ? html[0] : html; - append = append instanceof jQuery ? append[0] : append; - var colection = Array.from(html.querySelectorAll('.selector')); - if (visible_only) colection = colection.filter(function (e) { - return e.offsetParent !== null; - }); - - if (append) { - colection = colection.concat(Array.from(append.querySelectorAll('.selector'))); - } - - if (colection.length || active$1.invisible) { - clearSelects(); - Navigator.setCollection(colection); - } - } - - function collectionAppend(append) { - append = append instanceof jQuery ? append.toArray() : append; - if (!append.length) append = Array.from([append]); - Navigator.multiAdd(append); - } - - function collectionFocus(target, html) { - var visible_only = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - html = html instanceof jQuery ? html[0] : html; - target = target instanceof jQuery ? target[0] : target; - if (target && target.offsetParent === null) target = false; - - if (target) { - Navigator.focus(target); - } else { - var colection = Array.from(html.querySelectorAll('.selector')).filter(function (elem) { - return !elem.classList.contains('hide'); - }); - if (visible_only) colection = colection.filter(function (e) { - return e.offsetParent !== null; - }); - if (colection.length) Navigator.focus(colection[0]); - } - } - - function own(link) { - return active$1 && active$1.link == link; - } - - function enabled() { - return { - name: active_name, - controller: active$1 - }; - } - - function toContent() { - var trys = 0; - Screensaver$2.stopSlideshow(); - - var go = function go() { - var contrl = enabled(); - var any = parseInt([$('body').hasClass('settings--open') ? 1 : 0, $('body').hasClass('selectbox--open') ? 1 : 0, $('.modal,.youtube-player,.player,.search-box,.search').length ? 1 : 0].join('')); - trys++; - - if (any) { - if (contrl.controller.back) contrl.controller.back(); - if (trys < 10) go(); - } - }; - - go(); - } - - function clear$2() { - clearSelects(); - Navigator.setCollection([]); - } - - var Controller = { - listener: listener$2, - observe: observe$1, - add: add$4, - move: move, - enter: enter, - finish: finish, - toggle: toggle$2, - trigger: trigger$1, - back: back$2, - focus: focus, - collectionSet: collectionSet, - collectionFocus: collectionFocus, - collectionAppend: collectionAppend, - enable: enable, - enabled: enabled, - "long": _long, - toContent: toContent, - updateSelects: function updateSelects() {}, - own: own, - clear: clear$2 - }; - - var http = window.location.protocol == 'https:' ? 'https://' : 'http://'; - var layers = { - search: { - 'sim': ['{MIC} {ABC} 1 2 3 4 5 6 7 8 9 0 {BKSP}', '{LANG} - + _ : ( ) [ ] . / {SPACE}'], - 'en': ['{MIC} q w e r t y u i o p {BKSP}', '{LANG} a s d f g h j k l', '{SIM} z x c v b n m . {SPACE}'], - 'uk': ['{MIC} й ц у к е н г ш щ з х ї {BKSP}', '{LANG} ф і в а п р о л д ж є', '{SIM} я ч с м и т ь б ю . {SPACE}'], - 'he': ['{MIC} ק ר א ט ו ן ם פ {BKSP}', '{LANG} ש ד ג כ ע י ח ל ך ף', '{SIM} ז ס ב ה נ מ צ ת ץ . {SPACE}'], - 'default': ['{MIC} й ц у к е н г ш щ з х ъ {BKSP}', '{LANG} ё ф ы в а п р о л д ж э', '{SIM} я ч с м и т ь б ю . {SPACE}'] - }, - clarify: { - 'en': ['1 2 3 4 5 6 7 8 9 0 - {BKSP}', 'q w e r t y u i o p', 'a s d f g h j k l', 'z x c v b n m .', '{MIC} {LANG} {SPACE} {SEARCH}'], - 'uk': ['1 2 3 4 5 6 7 8 9 0 - {BKSP}', 'й ц у к е н г ш щ з х ї', 'ф і в а п р о л д ж є', 'я ч с м и т ь б ю .', '{MIC} {LANG} {SPACE} {SEARCH}'], - 'he': ['1 2 3 4 5 6 7 8 9 0 - {BKSP}', 'ק ר א ט ו ן ם פ', 'ש ד ג כ ע י ח ל ך ף', 'ז ס ב ה נ מ צ ת ץ .', '{MIC} {LANG} {SPACE} {SEARCH}'], - 'default': ['1 2 3 4 5 6 7 8 9 0 - {BKSP}', 'й ц у к е н г ш щ з х ъ', 'ф ы в а п р о л д ж э', 'я ч с м и т ь б ю .', '{MIC} {LANG} {SPACE} {SEARCH}'] - }, - "default": { - 'en': ['{SIM} 1 2 3 4 5 6 7 8 9 0 - + = {BKSP}', '{LANG} q w e r t y u i o p', 'a s d f g h j k l / {ENTER}', '{SHIFT} z x c v b n m , . : ' + http, '{SPACE}'], - 'uk': ['{SIM} 1 2 3 4 5 6 7 8 9 0 - + = {BKSP}', '{LANG} й ц у к е н г ш щ з х ї', 'ф і в а п р о л д ж є {ENTER}', '{SHIFT} я ч с м и т ь б ю . : ' + http, '{SPACE}'], - 'he': ['{SIM} ק ר א ט ו ן ם פ {BKSP}', '{LANG} ש ד ג כ ע י ח ל ך ף', 'ז ס ב ה נ מ צ ת ץ . /', '{SHIFT} ! @ # $ % ^ & * ( ) {SPACE}'], - 'sim': ['{ABC} 1 2 3 4 5 6 7 8 9 0 - + = {BKSP}', '{LANG} ! @ # $ % ^ & * ( ) [ ]', '- _ = + \\ | [ ] { }', '; : \' " , . < > / ?', '{SPACE}'], - 'default': ['{SIM} 1 2 3 4 5 6 7 8 9 0 - + = {BKSP}', '{LANG} й ц у к е н г ш щ з х ъ', 'ф ы в а п р о л д ж э {ENTER}', '{SHIFT} я ч с м и т ь б ю , . : ' + http, '{SPACE}'] - }, - nums: { - 'default': ['0 1 2 3 4 {BKSP}', '5 6 7 8 9 {ENTER}'] - } - }; - - function add$3(name, layout) { - layers[name] = layout; - } - - function addLang(name, code, layout) { - layers[name][code] = layout; - } - - function get$1(name) { - return layers[name]; - } - - var Layers = { - add: add$3, - addLang: addLang, - get: get$1 - }; - - function create$2() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var _keyClass = window.SimpleKeyboard["default"], - _keyBord; - - var last; - var ime; - var recognition; - var simple = Storage.field('keyboard_type') !== 'lampa'; - var input; - var last_value; - var height = window.innerHeight; - var mobile = Platform.screen('mobile'); - - if (params.keyboard) { - simple = params.keyboard !== 'lampa'; - } - - this.listener = start$8(); - - this.create = function () { - var _this = this; - - if (simple) { - input = $(''); - - if (mobile) { - input = $(''); - input.on('input', function () { - input[0].style.height = 'auto'; - input[0].style.height = input[0].scrollHeight + 'px'; - }); - } - - var time_blur = 0; - var time_focus = 0; - var stated, ended; - - if (Platform.is('orsay')) { - ime = new IMEShell_Common(); - - if ($('.settings-input--free').length > 0) { - ime.setUseNumberMode(true); - } - - ime.inputboxID = 'orsay-keyboard'; - ime.setUseIMEDim(false); - ime.setMaxlength(256); - ime.inputTitle = Lang.translate('search_input') + "..."; - - ime.onKeyPressFunc = function (key, str, id) { - switch (key) { - case 29443: // Enter Key - - case 88: //return - - case 45: - //exit - _this.listener.send('enter'); - - ime.onClose(); - input.blur(); - break; - } - }; - - ime.setOnTextChangeFunc = function (e) { - input.val(e); - var now_value = input.val(); - - if (last_value !== now_value) { - last_value = now_value; - stated = ended = false; - - _this.listener.send('change', { - value: now_value - }); - } - }; - } - - input.on('keyup change input keypress', function (e) { - var now_value = input.val(); - - if (last_value !== now_value) { - last_value = now_value; - stated = ended = false; - - _this.listener.send('change', { - value: now_value - }); - } - }); - input.on('blur', function () { - Keypad.enable(); - time_blur = Date.now(); - if (Platform.is('android') && Platform.screen('tv')) input.attr('disabled', 'true'); - }); - input.on('focus', function () { - Keypad.disable(); - time_focus = Date.now(); - }); - input.on('keyup', function (e) { - if (time_focus + 1000 > Date.now()) return; - var keys = [13, 65376, 29443, 117, 65385, 461, 27]; - var valu = input.val(); - var cart = e.target.selectionStart; - - if (keys.indexOf(e.keyCode) >= 0 && !Utils$2.isTouchDevice()) { - e.preventDefault(); - console.log('Keyboard', 'blur key:', e.keyCode, 'value:', valu); - input.blur(); - } - - if ((e.keyCode == 13 || e.keyCode == 65376) && !Utils$2.isTouchDevice()) _this.listener.send('enter'); - - if (e.keyCode == 37 && cart == 0 && height == window.innerHeight) { - if (stated) input.blur(), _this.listener.send('left'); - stated = true; - ended = false; - } - - if (e.keyCode == 39 && cart >= valu.length && height == window.innerHeight) { - if (ended) input.blur(), _this.listener.send('right'); - ended = true; - stated = false; - } - - if (e.keyCode == 40) { - if (height == window.innerHeight) input.blur(), _this.listener.send('down'); - } - - if (e.keyCode == 38) { - if (height == window.innerHeight) input.blur(), _this.listener.send('up'); - } - }); - input.on('hover:focus', function () { - if (Platform.is('orsay')) ime.onShow(); - input.removeAttr('disabled'); - input.focus(); - }); - input.on('hover:enter', function () { - if (time_blur + 1000 < Date.now()) { - if (Platform.is('orsay')) ime.onShow(); - input.focus(); - } - }); - var keyboard = $('.simple-keyboard'); - - if (!Platform.is('orsay') && (window.SpeechRecognition || window.webkitSpeechRecognition) && !params.nomic) { - var mic = $("
    \n \n \n \n \n \n
    "); - mic.on('hover:enter', function () { - if (Platform.is('android')) { - Android.voiceStart(); - window.voiceResult = _this.value.bind(_this); - } else if (recognition) { - try { - if (recognition.record) recognition.stop();else recognition.start(); - } catch (e) { - recognition.stop(); - } - } - }); - keyboard.addClass('simple-keyboard--with-mic').append(mic); - } - - keyboard.append(input); - if (mobile) keyboard.addClass('simple-keyboard--with-textarea'); - - if (Platform.screen('mobile')) { - var buttons = $('
    ' + Lang.translate('ready') + '
    ' + Lang.translate('cancel') + '
    '); - buttons.find('.simple-keyboard-buttons__enter').on('click', function () { - input.blur(); - - _this.listener.send('enter'); - }); - buttons.find('.simple-keyboard-buttons__cancel').on('click', function () { - _this.value(''); - - window.history.back(); - }); - $('.simple-keyboard').append(buttons); - } - } else { - var layout = typeof params.layout == 'string' ? Layers.get(params.layout) : params.layout || Layers.get('default'); - var press = Date.now(); - _keyBord = new _keyClass({ - display: { - '{BKSP}': ' ', - '{ENTER}': ' ', - '{SHIFT}': ' ', - '{SPACE}': ' ', - '{LANG}': ' ', - '{ABC}': 'Aa', - '{SIM}': '#+', - '{SEARCH}': Lang.translate('search'), - '{MIC}': "\n \n \n \n " - }, - layout: layout, - onChange: function onChange(value) { - _this.listener.send('change', { - value: value - }); - }, - onKeyPress: function onKeyPress(button) { - if (Date.now() - press < 100) return; - press = Date.now(); - if (button === "{SHIFT}" || button === "{SIM}" || button === "{ABC}") _this._handle(button);else if (button === '{MIC}') { - if (Platform.is('android')) { - Android.voiceStart(); - window.voiceResult = _this.value.bind(_this); - } else if (recognition) { - try { - if (recognition.record) recognition.stop();else recognition.start(); - } catch (e) { - recognition.stop(); - } - } - } else if (button === '{LANG}') { - var codes = Lang.codes(); - var items = []; - - var select_code = _keyBord.options.layoutName.split('-')[0]; - - items.push({ - title: codes.ru, - value: 'default', - selected: select_code == 'default' - }); - Arrays.getKeys(codes).forEach(function (code) { - if (layout[code]) { - items.push({ - title: codes[code], - value: code, - selected: select_code == code - }); - } - }); - setTimeout(function () { - Select.show({ - title: Lang.translate('title_choice_language'), - items: items, - onSelect: function onSelect(item) { - Select.hide(); - Storage.set('keyboard_default_lang', item.value); - var shifted = _keyBord.options.layoutName.split('-')[1] == 'shift'; - var new_layout = item.value + (shifted ? '-shift' : ''); - - _this.shifted(!shifted, new_layout, item.value); - - _keyBord.setOptions({ - layoutName: new_layout - }); - - last = false; - _keyBord.options.lastLayerSelect = _keyBord.options.layoutName; - Controller.toggle('keybord'); - $('.simple-keyboard').attr('shifted', Boolean(shifted)); - Controller.collectionFocus($('.simple-keyboard [data-skbtn="{LANG}"]')[0], $('.simple-keyboard')); - }, - onBack: function onBack() { - Select.hide(); - Controller.toggle('keybord'); - } - }); - }, 300); - } else if (button === '{SPACE}') { - _this.value(_keyBord.getInput() + ' '); - } else if (button === '{BKSP}') { - _this.value(_keyBord.getInput().slice(0, -1)); - } else if (button === '{ENTER}' || button === '{SEARCH}') { - _this.listener.send('enter'); - } - } - }); - var lang = Storage.get('keyboard_default_lang', Storage.get('language', 'ru')); - - _keyBord.setOptions({ - layoutName: lang == 'ru' ? 'default' : Arrays.getKeys(layout).indexOf(lang) >= 0 ? lang : layout.en ? 'en' : 'default' - }); - - $('.simple-keyboard').addClass('hg-style-' + (params.layout || 'default')); - } - - this.speechRecognition(); - }; - - this.speechRecognition = function () { - var _this2 = this; - - var SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; - console.log('Speech', 'status:', SpeechRecognition ? true : false); - - if (SpeechRecognition) { - recognition = new SpeechRecognition(); - recognition.continuous = false; - recognition.addEventListener("start", function () { - console.log('Speech', 'start'); - $('.simple-keyboard [data-skbtn="{mic}"]').css('color', 'red'); - $('.simple-keyboard-mic').addClass('record'); - recognition.record = true; - Noty.show(Lang.translate('keyboard_listen')); - }); - recognition.addEventListener("end", function () { - console.log('Speech', 'end'); - $('.simple-keyboard [data-skbtn="{mic}"]').css('color', 'white'); - $('.simple-keyboard-mic').removeClass('record'); - recognition.record = false; - }); - recognition.addEventListener("result", function (event) { - console.log('Speech', 'result:', event.resultIndex, event.results[event.resultIndex]); - var current = event.resultIndex; - var transcript = event.results[current][0].transcript; - console.log('Speech', 'transcript:', transcript); - - if (transcript.toLowerCase().trim() === "stop recording") { - recognition.stop(); - } else { - if (transcript.toLowerCase().trim() === "reset input") { - _this2.value(''); - } else { - _this2.value(transcript); - } - } - }); - recognition.addEventListener("error", function (event) { - console.log('Speech', 'error:', event); - - if (event.error == 'not-allowed') { - Noty.show(Lang.translate('keyboard_nomic')); - } - - recognition.stop(); - }); - } else { - $('.simple-keyboard [data-skbtn="{mic}"]').css('opacity', '0.3'); - } - }; - - this.value = function (value) { - if (simple) { - input.val(value); - - if (mobile) { - input[0].style.height = 'auto'; - input[0].style.height = input[0].scrollHeight + 'px'; - } - } else _keyBord.setInput(value); - - last_value = value; - this.listener.send('change', { - value: value - }); - }; - - this._layout = function () { - var _this3 = this; - - var keys = $('.simple-keyboard .hg-button').addClass('selector'); - Controller.collectionSet($('.simple-keyboard')); - Controller.collectionFocus(last || keys[0], $('.simple-keyboard')); - $('.simple-keyboard .hg-button:not(.binded)').on('hover:enter', function (e) { - Controller.collectionFocus($(this)[0]); - - _keyBord.handleButtonClicked($(this).attr('data-skbtn'), e); - }).on('hover:focus', function (e) { - last = e.target; - - _this3.listener.send('hover', { - button: e.target - }); - }); - keys.addClass('binded'); - $('.simple-keyboard').addClass('hg-style-' + (params.layout || 'default')); - }; - - this.shifted = function (shifted, layout, code) { - if (!(shifted && _keyBord.options.layout[layout])) { - var shift_layer = Arrays.clone(_keyBord.options.layout[code]); - shift_layer = shift_layer.map(function (button) { - return button.toUpperCase(); - }); - _keyBord.options.layout[layout] = shift_layer; - } - }; - - this._handle = function (button) { - var current_layout = _keyBord.options.layoutName, - layout = 'default', - focus; - var shifted = current_layout.split('-')[1] == 'shift'; - var code = current_layout.split('-')[0]; - $('.simple-keyboard').attr('shifted', Boolean(!shifted)); - - if (button == '{SHIFT}') { - if (shifted) layout = code;else layout = code + '-shift'; - this.shifted(shifted, layout, code); - } else if (button == '{SIM}') { - layout = 'sim'; - focus = '{ABC}'; - _keyBord.options.lastLayerSelect = current_layout; - } else if (button == '{ABC}') { - layout = _keyBord.options.lastLayerSelect || 'default'; - focus = '{SIM}'; - } - - _keyBord.setOptions({ - layoutName: layout - }); - - last = false; - Controller.toggle('keybord'); - Controller.collectionFocus($('.simple-keyboard [data-skbtn="' + (focus || button) + '"]')[0], $('.simple-keyboard')); - }; - - this.toggle = function () { - var _this4 = this; - - Controller.add('keybord', { - toggle: function toggle() { - if (simple) { - Controller.collectionSet($('.simple-keyboard')); - Controller.collectionFocus(mobile ? $('.simple-keyboard-input') : false, $('.simple-keyboard')); - } else _this4._layout(); - }, - update: function update() {}, - up: function up() { - if (!Navigator.canmove('up')) { - _this4.listener.send('up'); - } else Navigator.move('up'); - }, - down: function down() { - if (!Navigator.canmove('down')) { - _this4.listener.send('down'); - } else Navigator.move('down'); - }, - left: function left() { - if (!Navigator.canmove('left')) { - _this4.listener.send('left'); - } else Navigator.move('left'); - }, - right: function right() { - if (!Navigator.canmove('right')) { - _this4.listener.send('right'); - } else Navigator.move('right'); - }, - back: function back() { - _this4.listener.send('back'); - } - }); - Controller.toggle('keybord'); - }; - - this.destroy = function () { - try { - if (simple) { - input.remove(); - } else _keyBord.destroy(); - - if (recognition) recognition.stop(); - } catch (e) {} - - this.listener.destroy(); - Keypad.enable(); - }; - } - - var html$5, - keyboard, - input, - input_value = ''; - /** - * Заустить редактор - * @param {{title:string, value:string, free:boolean, nosave:boolean}} params - * @param {function} call - */ - - function edit(params, call) { - html$5 = Template$1.get('settings_input'); - input = html$5.find('.settings-input__input'); - var lamp = Storage.field('keyboard_type') == 'lampa' || params.keyboard == 'lampa'; - if (!lamp) input.hide(); - $('body').addClass('keyboard-input--visible').append(html$5); - keyboard = new create$2(params); - keyboard.listener.follow('change', function (event) { - input_value = event.value.trim(); - input.toggleClass('filled', Boolean(event.value)); - input.html(Utils$2.inputDisplay(event.value)); - }); - keyboard.listener.follow('enter', function (event) { - back$1(); - call(input_value); - }); - html$5.toggleClass('settings-input--free', params.free ? true : false); - $('.settings-input__links', html$5).toggleClass('hide', params.nosave ? true : false); - if (params.title) html$5.find('.settings-input__content').prepend('
    ' + params.title + '
    '); - keyboard.listener.follow('down', function (event) { - if (params.nosave) return; - var members = Storage.get('setting_member', []); - var links = []; - links.push({ - title: (members.indexOf(input_value) == -1 ? Lang.translate('settings_add') : Lang.translate('settings_remove')) + ' ' + Lang.translate('settings_this_value'), - subtitle: input_value, - add: true - }); - members.forEach(function (link) { - links.push({ - title: link, - subtitle: Lang.translate('settings_user_links'), - url: link, - member: true - }); - }); - links = links.concat([{ - title: '127.0.0.1:8090', - subtitle: Lang.translate('settings_for_local'), - url: '127.0.0.1:8090' - }]); - Select.show({ - title: Lang.translate('title_links'), - items: links, - onSelect: function onSelect(a) { - if (a.add) { - if (members.indexOf(a.subtitle) == -1) { - Arrays.insert(members, 0, a.subtitle); - Noty.show(Lang.translate('settings_added') + ' (' + a.subtitle + ')'); - } else { - Arrays.remove(members, a.subtitle); - Noty.show(Lang.translate('settings_removed') + ' (' + a.subtitle + ')'); - } - - Storage.set('setting_member', members); - } else { - keyboard.value(a.url); - } - - keyboard.toggle(); - }, - onLong: function onLong(a, elem) { - if (a.member) { - Arrays.remove(members, a.url); - Noty.show(Lang.translate('settings_removed') + ' (' + a.url + ')'); - Storage.set('setting_member', members); - $(elem).css({ - opacity: 0.4 - }); - } - }, - onBack: function onBack() { - keyboard.toggle(); - } - }); - }); - keyboard.listener.follow('back', function () { - back$1(); - call(input_value); - }); - keyboard.create(); - keyboard.value(params.value); - keyboard.toggle(); - input_value = params.value; - Helper.show('keyboard', Lang.translate('helper_keyboard')); - return keyboard; - } - /** - * Назад - */ - - - function back$1() { - destroy(); - Controller.toggle('settings_component'); - } - /** - * Уничтожить - */ - - - function destroy() { - keyboard.destroy(); - html$5.remove(); - $('body').removeClass('keyboard-input--visible'); - html$5 = null; - keyboard = null; - input = null; - } - - var Input = { - edit: edit - }; - - var values = {}; - var defaults = {}; - var listener$1 = start$8(); - /** - * Запуск - */ - - function init$d() { - if (Platform.is('tizen')) { - select$1('player', { - 'inner': '#{settings_param_player_inner}', - 'tizen': 'Tizen' - }, 'tizen'); - select$1('player_iptv', { - 'inner': '#{settings_param_player_inner}', - 'tizen': 'Tizen' - }, 'tizen'); - select$1('player_torrent', { - 'inner': '#{settings_param_player_inner}', - 'tizen': 'Tizen' - }, 'tizen'); - } - - if (Platform.is('orsay')) { - select$1('player', { - 'inner': '#{settings_param_player_inner}', - 'orsay': 'Orsay' - }, 'orsay'); - select$1('player_iptv', { - 'inner': '#{settings_param_player_inner}', - 'orsay': 'Orsay' - }, 'orsay'); - select$1('player_torrent', { - 'inner': '#{settings_param_player_inner}', - 'orsay': 'Orsay' - }, 'orsay'); - } else if (Platform.is('webos')) { - select$1('player', { - 'inner': '#{settings_param_player_inner}', - 'webos': 'WebOS' - }, 'inner'); - select$1('player_iptv', { - 'inner': '#{settings_param_player_inner}', - 'webos': 'WebOS' - }, 'inner'); - select$1('player_torrent', { - 'inner': '#{settings_param_player_inner}', - 'webos': 'WebOS' - }, 'inner'); - } else if (Platform.is('android')) { - select$1('player', { - 'inner': '#{settings_param_player_inner}', - 'android': 'Android' - }, 'android'); - select$1('player_iptv', { - 'inner': '#{settings_param_player_inner}', - 'android': 'Android' - }, 'android'); - select$1('player_torrent', { - 'android': 'Android' - }, 'android'); - trigger('internal_torrclient', false); - } else if (Platform.desktop() && !Platform.macOS()) { - select$1('player', { - 'inner': '#{settings_param_player_inner}', - 'other': '#{settings_param_player_outside}' - }, 'inner'); - select$1('player_iptv', { - 'inner': '#{settings_param_player_inner}', - 'other': '#{settings_param_player_outside}' - }, 'inner'); - select$1('player_torrent', { - 'inner': '#{settings_param_player_inner}', - 'other': '#{settings_param_player_outside}' - }, 'inner'); - } else if (Platform.macOS()) { - select$1('player', { - 'inner': '#{settings_param_player_inner}', - 'iina': 'IINA', - 'infuse': 'Infuse', - 'mpv': 'MPV', - 'nplayer': 'nPlayer' - }, 'inner'); - select$1('player_iptv', { - 'inner': '#{settings_param_player_inner}', - 'iina': 'IINA', - 'infuse': 'Infuse', - 'mpv': 'MPV', - 'nplayer': 'nPlayer' - }, 'inner'); - select$1('player_torrent', { - 'inner': '#{settings_param_player_inner}', - 'iina': 'IINA', - 'infuse': 'Infuse', - 'mpv': 'MPV', - 'nplayer': 'nPlayer' - }, 'inner'); - } else if (Platform.is('apple')) { - select$1('player', { - 'inner': '#{settings_param_player_inner}', - 'ios': 'iOS', - 'vlc': 'VLC', - 'nplayer': 'nPlayer', - 'infuse': 'Infuse', - 'svplayer': 'SVPlayer' - }, 'inner'); - select$1('player_iptv', { - 'inner': '#{settings_param_player_inner}', - 'ios': 'iOS', - 'vlc': 'VLC', - 'nplayer': 'nPlayer', - 'infuse': 'Infuse', - 'svplayer': 'SVPlayer' - }, 'inner'); - select$1('player_torrent', { - 'inner': '#{settings_param_player_inner}', - 'ios': 'iOS', - 'vlc': 'VLC', - 'nplayer': 'nPlayer', - 'infuse': 'Infuse', - 'svplayer': 'SVPlayer' - }, 'inner'); - } else if (Platform.is('apple_tv')) { - select$1('player', { - 'inner': '#{settings_param_player_inner}', - 'vlc': 'VLC', - 'infuse': 'Infuse', - 'svplayer': 'SVPlayer', - 'tvos': 'tvOS' - }, 'inner'); - select$1('player_iptv', { - 'inner': '#{settings_param_player_inner}', - 'vlc': 'VLC', - 'infuse': 'Infuse', - 'svplayer': 'SVPlayer', - 'tvos': 'tvOS' - }, 'inner'); - select$1('player_torrent', { - 'inner': '#{settings_param_player_inner}', - 'vlc': 'VLC', - 'infuse': 'Infuse', - 'svplayer': 'SVPlayer', - 'tvos': 'tvOS' - }, 'inner'); - } - - trigger('glass_style', Platform.screen('mobile')); - trigger('advanced_animation', Platform.is('apple_tv') || Platform.is('browser') || Platform.desktop() || navigator.userAgent.toLowerCase().indexOf('shield') >= 0); - var screensaver_types = { - 'nature': '#{settings_param_screensaver_nature}', - 'chrome': 'ChromeCast', - 'cub': 'CUB', - 'aerial': 'Aerial' - }; - select$1('screensaver_type', screensaver_types, 'chrome'); - select$1('keyboard_type', { - 'lampa': '#{settings_param_keyboard_lampa}', - 'integrate': '#{settings_param_keyboard_system}' - }, Platform.screen('mobile') || Platform.is('apple_tv') || Platform.macOS() ? 'integrate' : 'lampa'); //язык и комбинации для поиска - - var langcode = Storage.get('language', 'ru'); - var langname = Lang.codes()[langcode]; - var selector = { - 'df': '#{settings_param_torrent_lang_orig}', - 'df_year': '#{settings_param_torrent_lang_orig} + #{torrent_parser_year}', - 'df_lg': '#{settings_param_torrent_lang_orig} + ' + langname, - 'df_lg_year': '#{settings_param_torrent_lang_orig} + ' + langname + ' + #{torrent_parser_year}', - 'lg': langname, - 'lg_year': langname + ' + #{torrent_parser_year}', - 'lg_df': langname + ' + #{settings_param_torrent_lang_orig}', - 'lg_df_year': langname + ' + #{settings_param_torrent_lang_orig} + #{torrent_parser_year}' - }; - if (Arrays.getKeys(selector).indexOf(Storage.get('parse_lang', 'df')) == -1) Storage.set('parse_lang', 'df'); - select$1('parse_lang', selector, 'df'); - select$1('tmdb_lang', Lang.codes(), 'ru'); - var agent = navigator.userAgent.toLowerCase(); - var versi = agent.match(/chrome\/(\d+)/); - versi = versi ? parseInt(versi[1]) : 60; - versi = isNaN(versi) ? 60 : versi; - select$1('protocol', { - 'http': '#{settings_param_no}', - 'https': '#{settings_param_yes}' - }, versi >= 60 ? 'https' : 'http'); - } - /** - * Переключатель - * @param {string} name - название - * @param {boolean} value_default - значение по дефолту - */ - - - function trigger(name, value_default) { - values[name] = { - 'true': '#{settings_param_yes}', - 'false': '#{settings_param_no}' - }; - defaults[name] = value_default; - } - /** - * Выбрать - * @param {string} name - название - * @param {{key:string}} select_data - значение - * @param {string} select_default_value - значение по дефолту - */ - - - function select$1(name, select_data, select_default_value) { - values[name] = select_data; - defaults[name] = select_default_value; - } - /** - * Биндит события на элемент - * @param {object} elems - */ - - - function bind(elems, elems_html) { - elems.on('hover:enter', function (event) { - var elem = $(event.target); - var type = elem.data('type'); - var name = elem.data('name'); - var onChange = elem.data('onChange'); - - if (type == 'toggle') { - var params = values[name]; - var keys = Arrays.isArray(params) ? params : Arrays.getKeys(params), - value = Storage.get(name, defaults[name]) + '', - position = keys.indexOf(value); - position++; - if (position >= keys.length) position = 0; - position = Math.max(0, Math.min(keys.length - 1, position)); - value = keys[position]; - Storage.set(name, value); - update$2(elem, elems, elems_html); - if (onChange) onChange(value); - } - - if (type == 'input') { - Input.edit({ - elem: elem, - name: name, - value: elem.data('string') ? window.localStorage.getItem(name) || defaults[name] : Storage.get(name, defaults[name]) + '' - }, function (new_value) { - Storage.set(name, new_value); - update$2(elem, elems, elems_html); - if (onChange) onChange(new_value); - }); - } - - if (type == 'button') { - listener$1.send('button', { - name: name - }); - if (onChange) onChange(); - } - - if (type == 'add') { - Input.edit({ - value: '' - }, function (new_value) { - if (new_value && Storage.add(name, new_value)) { - displayAddItem(elem, new_value); - listener$1.send('update_scroll'); - } - }); - } - - if (type == 'select') { - var _params = values[name]; - - var _value = Storage.get(name, defaults[name]) + ''; - - var items = []; - - for (var i in _params) { - items.push({ - title: Lang.translate(_params[i]), - value: i, - selected: i == _value - }); - } - - var enabled = Controller.enabled().name; - Select.show({ - title: Lang.translate('title_choice'), - items: items, - onBack: function onBack() { - Controller.toggle(enabled); - }, - onSelect: function onSelect(a) { - Storage.set(name, a.value); - update$2(elem, elems, elems_html); - Controller.toggle(enabled); - if (onChange) onChange(a.value); - } - }); - } - }).on('hover:hover', function (e) { - Navigator.focused(e.target); - }).each(function () { - if (!$(this).data('static')) update$2($(this), elems, elems_html); - }); - - if (elems.eq(0).data('type') == 'add') { - displayAddList(elems.eq(0)); - } - } - /** - * Добавить дополнительное полу - * @param {object} elem - * @param {object} element - */ - - - function displayAddItem(elem, element) { - var name = elem.data('name'); - var item = $('
    ' + element + '
    ' + '
    '); - item.on('hover:long', function () { - var list = Storage.get(name, '[]'); - Arrays.remove(list, element); - Storage.set(name, list); - item.css({ - opacity: 0.5 - }); - }); - elem.after(item); - } - /** - * Вывести дополнительные поля - * @param {object} elem - */ - - - function displayAddList(elem) { - var list = Storage.get(elem.data('name'), '[]'); - list.forEach(function (element) { - displayAddItem(elem, element); - }); - listener$1.send('update_scroll'); - } - /** - * Обновляет значения на элементе - * @param {object} elem - */ - - - function update$2(elem, elems, elems_html) { - var name = elem.data('name'); - var key = elem.data('string') ? window.localStorage.getItem(name) || defaults[name] : Storage.get(name, defaults[name] + ''); - var val = typeof values[name] == 'string' ? key : values[name][key] || values[name][defaults[name]]; - var plr = elem.attr('placeholder'); - if (!val && plr) val = plr; - elem.find('.settings-param__value').text(Lang.translate(val)); - var children = elem.data('children'); - - if (children) { - var parent = elems_html ? elems_html.find('[data-parent="' + children + '"]') : elems.filter('[data-parent="' + children + '"]'); - var value = elem.data('children-value'); - var visibl = value ? Storage.field(name) !== value : !Storage.field(name); - if (elem.data('children-reverse')) visibl = !visibl; - parent.toggleClass('hide', visibl); - parent.filter('[data-visible-value]').each(function () { - $(this).toggleClass('hide', $(this).data('visible-value') !== key); - }); - listener$1.send('update_scroll_position'); - } - } - /** - * Получить значение параметра - * @param {string} name - * @returns * - */ - - - function field$1(name) { - return Storage.get(name, defaults[name] + ''); - } - /** - * Добовляем селекторы - */ - - - select$1('interface_size', { - 'small': '#{settings_param_interface_size_small}', - 'normal': '#{settings_param_interface_size_normal}', - 'bigger': '#{settings_param_interface_size_bigger}' - }, 'normal'); - select$1('poster_size', { - 'w200': '#{settings_param_poster_quality_low}', - 'w300': '#{settings_param_poster_quality_average}', - 'w500': '#{settings_param_poster_quality_high}' - }, 'w200'); - select$1('parser_torrent_type', { - 'jackett': 'Jackett', - 'prowlarr': 'Prowlarr', - 'torrserver': 'TorrServer' - }, 'jackett'); - select$1('jackett_interview', { - 'all': '#{settings_param_jackett_interview_all}', - 'healthy': '#{settings_param_jackett_interview_healthy}' - }, 'all'); - select$1('torlook_parse_type', { - 'native': '#{settings_param_parse_directly}', - 'site': '#{settings_param_parse_api}' - }, 'native'); - select$1('background_type', { - 'complex': '#{settings_param_background_complex}', - 'simple': '#{settings_param_background_simple}', - 'poster': '#{settings_param_background_image}' - }, 'simple'); - select$1('pages_save_total', { - '1': '1', - '2': '2', - '3': '3', - '4': '4', - '5': '5' - }, '5'); - select$1('player', { - 'inner': '#{settings_param_player_inner}' - }, 'inner'); - select$1('player_iptv', { - 'inner': '#{settings_param_player_inner}' - }, 'inner'); - select$1('player_torrent', { - 'inner': '#{settings_param_player_inner}' - }, 'inner'); - select$1('torrserver_use_link', { - 'one': '#{settings_param_link_use_one}', - 'two': '#{settings_param_link_use_two}' - }, 'one'); - select$1('subtitles_size', { - 'small': '#{settings_param_subtitles_size_small}', - 'normal': '#{settings_param_subtitles_size_normal}', - 'large': '#{settings_param_subtitles_size_bigger}' - }, 'normal'); - select$1('screensaver_time', { - '1': '1', - '2': '2', - '5': '5', - '10': '10' - }, '5'); - select$1('parse_lang', { - 'df': '#{settings_param_torrent_lang_orig}' - }, 'df'); - select$1('parse_timeout', { - '15': '15', - '30': '30', - '60': '60' - }, '15'); - select$1('player_rewind', { - '5': '5', - '10': '10', - '15': '15', - '20': '20', - '30': '30', - '50': '50', - '100': '100' - }, '20'); - select$1('player_timecode', { - 'again': '#{settings_param_player_timecode_again}', - 'continue': '#{settings_param_player_timecode_continue}', - 'ask': '#{settings_param_player_timecode_ask}' - }, 'continue'); - select$1('player_scale_method', { - 'transform': 'Transform', - 'calculate': '#{settings_param_player_scale_method}' - }, 'transform'); - select$1('player_hls_method', { - 'application': '#{settings_param_player_hls_app}', - 'hlsjs': '#{settings_param_player_hls_js}' - }, 'application'); - select$1('source', { - 'tmdb': 'TMDB', - 'cub': 'CUB' - }, 'tmdb'); - select$1('start_page', { - 'main': '#{title_main}', - 'favorite@bookmarks': '#{settings_input_links}', - 'favorite@history': '#{title_history}', - 'mytorrents': '#{title_mytorrents}', - 'last': '#{title_last}' - }, 'main'); - select$1('scroll_type', { - 'css': 'CSS', - 'js': 'Javascript' - }, 'css'); - select$1('card_views_type', { - 'preload': '#{settings_param_card_view_load}', - 'view': '#{settings_param_card_view_all}' - }, 'preload'); - select$1('navigation_type', { - 'controll': '#{settings_param_navigation_remote}', - 'mouse': '#{settings_param_navigation_mouse}' - }, 'controll'); - select$1('keyboard_type', { - 'lampa': '#{settings_param_keyboard_lampa}', - 'integrate': '#{settings_param_keyboard_system}' - }, 'lampa'); - select$1('card_interfice_type', { - 'old': '#{settings_param_card_interface_old}', - 'new': '#{settings_param_card_interface_new}' - }, 'new'); - select$1('glass_opacity', { - 'easy': '#{settings_param_glass_easy}', - 'medium': '#{settings_param_glass_medium}', - 'blacked': '#{settings_param_glass_blacked}' - }, 'easy'); - select$1('interface_sound_level', { - '100': '100', - '80': '80', - '60': '60', - '40': '40', - '20': '20' - }, '60'); - select$1('time_offset', { - 'n-10': '-10', - 'n-9': '-9', - 'n-8': '-8', - 'n-7': '-7', - 'n-6': '-6', - 'n-5': '-5', - 'n-4': '-4', - 'n-3': '-3', - 'n-2': '-2', - 'n-1': '-1', - 'n0': '0', - 'n1': '1', - 'n2': '2', - 'n3': '3', - 'n4': '4', - 'n5': '5', - 'n6': '6', - 'n7': '7', - 'n8': '8', - 'n9': '9', - 'n10': '10' - }, 'n0'); - select$1('video_quality_default', { - '480': '480p', - '720': '720p', - '1080': '1080p', - '1440': '1440p', - '2160': '2160p' - }, '1080'); - select$1('player_launch_trailers', { - 'inner': '#{settings_param_player_inner}', - 'youtube': 'YouTube' - }, 'inner'); - /** - * Добовляем триггеры - */ - - trigger('animation', true); - trigger('background', true); - trigger('torrserver_savedb', false); - trigger('torrserver_preload', false); - trigger('parser_use', false); - trigger('cloud_use', false); - trigger('account_use', false); - trigger('torrserver_auth', false); - trigger('mask', true); - trigger('playlist_next', true); - trigger('internal_torrclient', true); - trigger('subtitles_stroke', true); - trigger('subtitles_backdrop', false); - trigger('screensaver', true); - trigger('proxy_tmdb', true); - trigger('proxy_tmdb_auto', true); - trigger('proxy_other', true); - trigger('parse_in_search', false); - trigger('subtitles_start', false); - trigger('helper', true); - trigger('light_version', false); - trigger('player_normalization', false); - trigger('card_quality', true); - trigger('card_episodes', true); - trigger('card_interfice_poster', true); - trigger('glass_style', false); - trigger('black_style', false); - trigger('hide_outside_the_screen', true); - trigger('card_interfice_cover', true); - trigger('card_interfice_reactions', true); - trigger('cache_images', false); - trigger('interface_sound_play', false); - /** - * Добовляем поля - */ - - select$1('jackett_url', '', ''); - select$1('jackett_key', '', ''); - select$1('prowlarr_url', '', ''); - select$1('prowlarr_key', '', ''); - select$1('torrserver_url', '', ''); - select$1('torrserver_url_two', '', ''); - select$1('torrserver_login', '', ''); - select$1('torrserver_password', '', ''); - select$1('parser_website_url', '', ''); - select$1('torlook_site', '', 'w41.torlook.info'); - select$1('cloud_token', '', ''); - select$1('account_email', '', ''); - select$1('account_password', '', ''); - select$1('device_name', '', 'Lampa'); - select$1('player_nw_path', '', 'C:/Program Files/VideoLAN/VLC/vlc.exe'); - select$1('tmdb_proxy_api', '', ''); - select$1('tmdb_proxy_image', '', ''); - var Params = { - listener: listener$1, - init: init$d, - bind: bind, - update: update$2, - field: field$1, - select: select$1, - trigger: trigger, - values: values, - defaults: defaults - }; - - var network$2 = new create$p(); - var api = Utils$2.protocol() + object$2.cub_domain + '/api/'; - - var WorkerArray = /*#__PURE__*/function () { - function WorkerArray(field) { - _classCallCheck(this, WorkerArray); - - this.field = field; - this.empty = []; - this.data = []; - this.limit = 3000; - this.loaded = false; - } - - _createClass(WorkerArray, [{ - key: "init", - value: function init(class_type) { - var _this = this; - - var timer_update; - var start_time = Date.now(); - this.class_type = class_type; - console.log('StorageWorker', this.field, 'start follow'); - Storage.listener.follow('change', function (e) { - if (_this.field == e.name && _this.loaded && Account.canSync() && Account.hasPremium()) { - try { - _this.save(e.value); - } catch (e) { - console.log('StorageWorker', _this.field, e.message); - } - } - - if (e.name == 'account') { - clearTimeout(timer_update); - timer_update = setTimeout(_this.update.bind(_this, true), 5 * 1000); - } - }); - Socket.listener.follow('message', function (e) { - if (e.method == 'storage' && e.data.name == _this.field) { - try { - if (e.data.remove) _this.removeFromSocket(e.data);else _this.updateFromSocket(e.data); - } catch (e) { - console.log('StorageWorker', _this.field, e.message); - } - } - }); - Socket.listener.follow('open', function (e) { - if (Date.now() - start_time > 1000 * 60 * 5) { - clearTimeout(timer_update); - timer_update = setTimeout(_this.update.bind(_this, false, true), 10 * 1000); - } - }); - this.update(); - setInterval(this.update.bind(this), 1000 * 60 * 10); - } - }, { - key: "restrict", - value: function restrict(result) { - if (Arrays.isObject(result)) { - var keys = Arrays.getKeys(result); - - if (keys.length > this.limit) { - var remv = keys.slice(0, keys.length - this.limit); - remv.forEach(function (k) { - delete result[k]; - }); - } - } else if (result.length > this.limit) { - result = result.slice(result.length - this.limit); - } - - return result; - } - }, { - key: "parse", - value: function parse(from, nolisten) { - var to = Storage.cache(this.field, this.limit, Arrays.clone(this.empty)); - this.filter(from, to); - Storage.set(this.field, to, nolisten); - this.data = this.restrict(Arrays.decodeJson(localStorage.getItem(this.field), Arrays.clone(this.empty))); - Lampa.Listener.send('worker_storage', { - type: 'insert', - name: this.field, - from: from, - to: to - }); - } - }, { - key: "filter", - value: function filter(from, to) { - from.forEach(function (a) { - if (to.indexOf(a) == -1) to.push(a); - }); - } - }, { - key: "update", - value: function update(full, nolisten) { - var _this2 = this; - - var account = Account.canSync(); - - if (account && Account.hasPremium()) { - console.log('StorageWorker', this.field, 'update start'); - var url = api + 'storage/data/' + encodeURIComponent(this.field) + '/' + this.class_type; - var all = full; - if (Storage.get('storage_' + this.field + '_update_time', '0') + 1000 * 60 * 60 * 24 < Date.now()) all = true; - if (all) url = url + '?full=true'; - network$2.silent(url, function (result) { - try { - _this2.parse(result.data, nolisten); - - console.log('StorageWorker', _this2.field, 'update end'); - } catch (e) { - console.log('StorageWorker', _this2.field, e.message); - } - - Storage.set('storage_' + _this2.field + '_update_time', Date.now()); - _this2.loaded = true; - }, false, false, { - headers: { - token: account.token, - profile: account.profile.id - } - }); - } - } - }, { - key: "removeFromSocket", - value: function removeFromSocket(data) { - Arrays.remove(this.data, data.value); - var store = Storage.cache(this.field, this.limit, Arrays.clone(this.empty)); - Arrays.remove(store, data.value); - Storage.set(this.field, store, true); - } - }, { - key: "updateFromSocket", - value: function updateFromSocket(data) { - var from = [data.value]; - this.parse(from, true); - } - }, { - key: "send", - value: function send(id, value) { - if (!Account.hasPremium()) return; - console.log('StorageWorker', 'save:', this.field, id, value); - var str = JSON.stringify(value); - - if (str.length < 10000) { - Socket.send('storage', { - params: { - id: id, - name: this.field, - value: value - } - }); - } - } - }, { - key: "sendRemove", - value: function sendRemove(id, value) { - var str = JSON.stringify(value); - console.log('StorageWorker', 'remove:', this.field, id, value); - - if (str.length < 10000) { - Socket.send('storage', { - params: { - id: id, - name: this.field, - value: value, - remove: true - } - }); - } - } - }, { - key: "sendClean", - value: function sendClean() { - Socket.send('storage', { - params: { - id: null, - name: this.field, - value: '', - clean: true - } - }); - } - }, { - key: "save", - value: function save(value) { - var _this3 = this; - - var uniq = value.filter(function (a) { - return _this3.data.indexOf(a) == -1; - }); - uniq.forEach(function (val) { - _this3.data.push(val); - - _this3.send(null, val); - }); - } - }, { - key: "remove", - value: function remove(value) { - Arrays.remove(this.data, value); - this.sendRemove(null, value); - } - }, { - key: "clean", - value: function clean() { - this.data = []; - this.sendClean(); - } - }]); - - return WorkerArray; - }(); - - var WorkerFilterID = /*#__PURE__*/function (_WorkerArray) { - _inherits(WorkerFilterID, _WorkerArray); - - var _super = _createSuper(WorkerFilterID); - - function WorkerFilterID() { - _classCallCheck(this, WorkerFilterID); - - return _super.apply(this, arguments); - } - - _createClass(WorkerFilterID, [{ - key: "filter", - value: function filter(from, to) { - from.forEach(function (a) { - var find = to.find(function (b) { - return b.id == a.id; - }); - if (!find) to.push(a);else { - to[to.indexOf(find)] = a; - } - }); - } - }, { - key: "removeFromSocket", - value: function removeFromSocket(data) { - var find = this.data.find(function (a) { - return a.id == data.id; - }); - if (find) Arrays.remove(this.data, find); - var store = Storage.cache(this.field, this.limit, Arrays.clone(this.empty)); - find = store.find(function (a) { - return a.id == data.id; - }); - if (find) Arrays.remove(store, find); - Storage.set(this.field, store, true); - } - }, { - key: "updateFromSocket", - value: function updateFromSocket(data) { - var from = [data.value]; - this.parse(from, true); - } - }, { - key: "save", - value: function save(value) { - var _this4 = this; - - var uniq = []; - value.forEach(function (val) { - var find = _this4.data.find(function (a) { - return a.id == val.id; - }); - - if (!find) { - _this4.data.push(_typeof(val) == 'object' ? Arrays.clone(val) : val); - - uniq.push(val); - } else if (JSON.stringify(val) !== JSON.stringify(find)) { - _this4.data[_this4.data.indexOf(find)] = _typeof(val) == 'object' ? Arrays.clone(val) : val; - uniq.push(val); - } - }); - uniq.forEach(function (val) { - _this4.send(val.id, val); - }); - } - }, { - key: "remove", - value: function remove(id) { - var find = this.data.find(function (a) { - return a.id == id; - }); - if (find) Arrays.remove(this.data, find); - this.sendRemove(id, null); - } - }]); - - return WorkerFilterID; - }(WorkerArray); - - var WorkerObject = /*#__PURE__*/function (_WorkerArray2) { - _inherits(WorkerObject, _WorkerArray2); - - var _super2 = _createSuper(WorkerObject); - - function WorkerObject(params) { - var _this5; - - _classCallCheck(this, WorkerObject); - - _this5 = _super2.call(this, params); - _this5.data = {}; - _this5.empty = {}; - return _this5; - } - - _createClass(WorkerObject, [{ - key: "filter", - value: function filter(from, to) { - for (var _id in from) { - to[_id] = from[_id]; - } - } - }, { - key: "removeFromSocket", - value: function removeFromSocket(data) { - delete this.data[id]; - var store = Storage.cache(this.field, this.limit, Arrays.clone(this.empty)); - delete store[id]; - Storage.set(this.field, store, true); - } - }, { - key: "updateFromSocket", - value: function updateFromSocket(data) { - var object = {}; - object[data.id] = data.value; - this.parse(object, true); - } - }, { - key: "save", - value: function save(value) { - var _this6 = this; - - var uniq = []; - - for (var _id2 in value) { - var a = value[_id2]; - var b = this.data[_id2]; - - if (!this.data[_id2]) { - this.data[_id2] = _typeof(a) == 'object' ? Arrays.clone(a) : a; - uniq.push(_id2); - } else { - a = JSON.stringify(a); - b = JSON.stringify(b); - - if (a !== b) { - this.data[_id2] = _typeof(value[_id2]) == 'object' ? Arrays.clone(value[_id2]) : value[_id2]; - uniq.push(_id2); - } - } - } - - uniq.forEach(function (id) { - _this6.send(id, value[id]); - }); - } - }, { - key: "remove", - value: function remove(id) { - delete this.data[id]; - this.sendRemove(id, null); - } - }, { - key: "clean", - value: function clean() { - this.data = {}; - this.sendClean(); - } - }]); - - return WorkerObject; - }(WorkerArray); - - var Workers = { - //['string',0499383] - array_string: WorkerArray, - //[{'id':'049994',...}] - array_object_id: WorkerFilterID, - //{'id048994':{...}, ...} - object_object: WorkerObject, - //{'id399884':'string', ...} - object_string: WorkerObject - }; - - var listener = start$8(); - var readed$1 = {}; - var workers = {}; - - function init$c() { - sync('online_view', 'array_string'); - sync('torrents_view', 'array_string'); - sync('search_history', 'array_string'); //sync('menu_sort','array_string') - //sync('menu_hide','array_string') - //sync('timetable','array_object_id') слишком большие данные, что-то потом придумаю - - sync('online_last_balanser', 'object_string'); - sync('user_clarifys', 'object_object'); - sync('torrents_filter_data', 'object_object'); - } - - function get(name, empty) { - var value = readed$1[name] || window.localStorage.getItem(name) || empty || ''; - if (value == 'true' || value == 'false') return value == 'true' ? true : false; - if (readed$1[name] && (Arrays.isObject(value) || Arrays.isArray(value))) return readed$1[name]; - var convert = parseInt(value); - if (!isNaN(convert) && /^\d+$/.test(value)) return convert; - var i = typeof value == 'string' ? value[0] : ''; - - if (i == '[' || i == '{') { - try { - value = JSON.parse(value); - } catch (error) {} - } - - readed$1[name] = value; - return value; - } - - function value(name, empty) { - return window.localStorage.getItem(name) || empty || ''; - } - - function set(name, value, nolisten) { - try { - if (Arrays.isObject(value) || Arrays.isArray(value)) { - var str = JSON.stringify(value); - window.localStorage.setItem(name, str); - } else { - window.localStorage.setItem(name, value); - } - - readed$1[name] = value; - } catch (e) {} - - if (!nolisten) listener.send('change', { - name: name, - value: value - }); - } - - function add$2(name, new_value) { - var list = get(name, '[]'); - - if (list.indexOf(new_value) == -1) { - list.push(new_value); - set(name, list); - listener.send('add', { - name: name, - value: new_value - }); - return true; - } - } - - function field(name) { - return Params.field(name); - } - - function cache(name, max, empty) { - var result = get(name, JSON.stringify(empty)); - - if (Arrays.isObject(empty)) { - var keys = Arrays.getKeys(result); - - if (keys.length > max) { - var remv = keys.slice(0, keys.length - max); - remv.forEach(function (k) { - delete result[k]; - }); - set(name, result); - } - } else if (result.length > max) { - result = result.slice(result.length - max); - set(name, result); - } - - return result; - } - - function sync(field_name, class_type) { - if (Workers[class_type] && !workers[field_name]) { - workers[field_name] = new Workers[class_type](field_name); - workers[field_name].init(class_type); - } - } - - function remove(field_name, value) { - if (workers[field_name]) workers[field_name].remove(value); - } - - function clean(field_name) { - if (workers[field_name]) workers[field_name].clean(); - } - - function clear$1(full) { - if (full) { - Noty.show(Lang.translate('settings_clear_cache')); - localStorage.clear(); - } else { - Noty.show(Lang.translate('settings_clear_cache_only')); - var need = ['online_view', 'ser_clarifys', 'torrents_view', 'account_bookmarks', 'recomends_list', 'file_view', 'timetable', 'search_history', 'recomends_scan']; - var more = ['online_', 'file_view_', 'storage_']; - - for (var key in localStorage) { - if (more.find(function (w) { - return key.indexOf(w) >= 0; - })) need.push(key); - } - - need.forEach(function (a) { - localStorage.removeItem(a); - }); - } - - setTimeout(function () { - window.location.reload(); - }, 3000); - } - - function getsize(call) { - if (localStorage) { - var i = 0; - var t = setInterval(function () { - i += 250; - - try { - localStorage.setItem('testsize', new Array(i * 1024 + 1).join('a')); - } catch (e) { - localStorage.removeItem('testsize'); - clearInterval(t); - } - - call((i - 250) * 1024); - }, 100); - } else { - call(5000 * 1024); - } - } - - var Storage = { - listener: listener, - init: init$c, - get: get, - set: set, - field: field, - cache: cache, - add: add$2, - value: value, - sync: sync, - remove: remove, - clear: clear$1, - clean: clean, - getsize: getsize - }; - - var meta = { - languages: { - ru: { - code: 'ru', - name: 'Русский', - lang_choice_title: 'Добро пожаловать', - lang_choice_subtitle: 'Выберите свой язык' - }, - en: { - code: 'en', - name: 'English', - lang_choice_title: 'Welcome', - lang_choice_subtitle: 'Choose your language' - }, - uk: { - code: 'uk', - name: 'Українська', - lang_choice_title: 'Ласкаво просимо', - lang_choice_subtitle: 'Виберіть мову' - }, - be: { - code: 'be', - name: 'Беларуская', - lang_choice_title: 'Сардэчна запрашаем', - lang_choice_subtitle: 'Выберыце сваю мову' - }, - zh: { - code: 'zh', - name: '简体中文', - lang_choice_title: '欢迎', - lang_choice_subtitle: '选择你的语言' - }, - pt: { - code: 'pt', - name: 'Português', - lang_choice_title: 'Bem-vindo', - lang_choice_subtitle: 'Escolhe o teu idioma' - }, - bg: { - code: 'bg', - name: 'Български', - lang_choice_title: 'Здравейте', - lang_choice_subtitle: 'Изберете вашият език' - }, - he: { - code: 'he', - name: 'עִברִית', - lang_choice_title: 'ברוך הבא', - lang_choice_subtitle: 'בחר את השפה שלך' - } - } - }; - - var ru = { - lang_choice_title: 'Добро пожаловать', - lang_choice_subtitle: 'Выберите свой язык', - more: 'Еще', - show_more: 'Показать ещё', - more_results: 'Показать больше результатов', - loading: 'Загрузка', - nofind_movie: 'Не удалось найти фильм.', - noname: 'Без названия', - nochoice: 'Не выбрано', - cancel: 'Отменить', - confirm: 'Подтверждаю', - sure: 'Вы уверены?', - nodata: 'Нет данных', - back: 'Назад', - ready: 'Готово', - close_app_modal: 'Вы уверены, что хотите покинуть приложение?', - connected_seeds: 'подкл.', - search: 'Поиск', - search_input: 'Введите текст', - search_empty: 'История поиска пуста.', - search_delete: 'Влево - удалить', - search_start_typing: 'Начните вводить текст для поиска.', - search_searching: 'Идет поиск...', - search_start: 'Начать поиск', - search_nofound: 'По вашему запросу ничего не найдено.', - full_genre: 'Жанр', - full_production: 'Производство', - full_date_of_release: 'Дата релиза', - full_budget: 'Бюджет', - full_countries: 'Страны', - full_like: 'Нравится', - full_torrents: 'Торренты', - full_trailers: 'Трейлеры', - full_detail: 'Подробно', - full_notext: 'Без описания.', - full_series_release: 'Выход серий', - full_next_episode: 'Следующая', - full_episode_days_left: 'Осталось дней', - full_trailer_official: 'Официальный', - full_trailer_no_official: 'Неофициальный', - full_season: 'Cезон', - full_episode: 'Эпизод', - full_directing: 'Режиссура', - full_writing: 'Сценарий', - full_keywords: 'Теги', - full_crew: 'Еще', - full_editing: 'Монтаж', - full_creator: 'Создатель', - settings_cub_sync: 'Синхронизация', - settings_cub_sync_descr: 'Синхронизация с сервисом CUB: синхронизация ваших закладок, истории просмотров, меток и тайм-кодов. Сайт: www.cub.red', - settings_cub_account: 'Аккаунт', - settings_cub_logged_in_as: 'Вошли как', - settings_cub_profile: 'Профиль', - settings_cub_sync_btn: 'Синхронизировать', - settings_cub_sync_btn_descr: 'Сохранить локальные закладки в аккаунт CUB', - settings_cub_backup: 'Бэкап', - settings_cub_backup_descr: 'Сохранить или загрузить бэкап данных', - settings_cub_logout: 'Выйти из аккаунта', - settings_cub_signin: 'Авторизация', - settings_cub_not_specified: 'Не указан', - settings_cub_password: 'Пароль', - settings_cub_status: 'Статус', - settings_cub_backup_import: 'Импорт', - settings_cub_backup_export: 'Экспорт', - settings_cub_backup_export_descr: 'Сохранить настройки в облако', - settings_cub_backup_import_descr: 'Восстановить настройки из облака', - settings_cub_sync_filters: 'Синхронизация фильтров', - settings_cub_sync_calendar: 'Синхронизация календаря', - settings_cub_sync_quality: 'Синхронизация отметок (качество)', - settings_cub_sync_search: 'Синхронизация истории поиска', - settings_cub_sync_recomends: 'Синхронизация рекомендаций', - settings_cub_sync_timecodes: 'Синхронизация тайм-кодов', - settings_cub_signin_button: 'Выполнить вход', - settings_input_links: 'Избранное', - settings_interface_type: 'Облегчённая версия', - settings_interface_size: 'Размер интерфейса', - settings_interface_background: 'Фон', - settings_interface_background_use: 'Показывать фон', - settings_interface_background_type: 'Тип фона', - settings_interface_performance: 'Быстродействие', - settings_interface_animation: 'Анимация', - settings_interface_advanced_animation: 'Продвинутая анимация', - settings_interface_animation_descr: 'Анимация карточек и контента', - settings_interface_attenuation: 'Затухание', - settings_interface_attenuation_descr: 'Плавное затухание карточек снизу и сверху', - settings_interface_scroll: 'Тип скролинга', - settings_interface_view_card: 'Тип просмотра карточек', - settings_interface_view_card_descr: 'По мере скроллинга ленты карточки будут подгружаться постепенно или загружаться все', - settings_interface_lang: 'Язык интерфейса', - settings_interface_lang_reload: 'Необходимо перезапустить приложение, нажмите «OK» для перезагрузки', - settings_interface_card_interfice: 'Интерфейс карточек', - settings_interface_card_poster: 'Показать постер', - settings_interface_card_cover: 'Показать обложку', - settings_interface_card_reactions: 'Показать реакции', - settings_interface_glass: 'Стекло', - settings_interface_glass_descr: 'Показывать интерфейс в стекловидном стиле', - settings_interface_glass_opacity: 'Прозрачность стекла', - settings_interface_black_style: 'Чёрный стиль', - settings_interface_hide_outside_the_screen: 'Скрывать карточки за пределами экрана', - settings_interface_hide_outside_the_screen_descr: 'Это ускорит рендер интерфейса и улучшит производительность', - settings_interface_sound: 'Системные звуки', - settings_interface_sound_play: 'Переходы', - settings_interface_sound_level: 'Уровень громкости', - settings_main_account: 'Аккаунт', - settings_main_interface: 'Интерфейс', - settings_main_player: 'Плеер', - settings_main_parser: 'Парсер', - settings_main_torrserver: 'TorrServer', - settings_main_plugins: 'Расширения', - settings_main_rest: 'Остальное', - settings_rest_start: 'Стартовая страница', - settings_rest_start_descr: 'С какой страницы начинать при запуске', - settings_rest_source: 'Источник', - settings_rest_source_use: 'Основной источник', - settings_rest_source_descr: 'Откуда брать информацию о фильмах', - settings_rest_tmdb_lang: 'На каком языке отображать данные с TMDB', - settings_rest_tmdb_prox: 'Проксировать TMDB', - settings_rest_tmdb_prox_auto: 'Включить прокси автоматически', - settings_rest_tmdb_posters: 'Разрешение постеров TMDB', - settings_rest_screensaver: 'Скринсейвер', - settings_rest_screensaver_use: 'Показывать заставку при бездействии', - settings_rest_screensaver_type: 'Тип заставки', - settings_rest_screensaver_time: 'Через сколько минут запустить скринсейвер', - settings_rest_helper: 'Подсказки', - settings_rest_helper_use: 'Показывать подсказки', - settings_rest_helper_reset: 'Показать подсказки снова', - settings_rest_pages: 'Сколько страниц хранить в памяти', - settings_rest_pages_descr: 'Хранит страницы в том состоянии, в котором вы их покинули.', - settings_rest_time: 'Сместить время', - settings_rest_navigation: 'Тип навигации', - settings_rest_keyboard: 'Тип клавиатуры', - settings_rest_device: 'Название устройства', - settings_rest_device_placeholder: 'Например: Моя Лампа', - settings_rest_cache: 'Очистить кэш', - settings_rest_tmdb_example: 'Например:', - settings_rest_tmdb_api_descr: 'Для получения данных', - settings_rest_tmdb_image_descr: 'Для получения изображений', - settings_rest_card_quality: 'Отметки качества', - settings_rest_card_quality_descr: 'Отображать отметки качества на карточках', - settings_rest_card_episodes: 'Отметки эпизодов', - settings_rest_card_episodes_descr: 'Отображать отметки эпизодов на карточках', - settings_rest_cache_images: 'Кэш изображений', - settings_rest_cache_images_descr: 'Кэшировать постеры и фоны в локальное хранилище', - settings_rest_protocol_use: 'Безопасное соединение', - settings_rest_protocol_descr: 'Использовать протокол HTTPS', - settings_rest_cache_only: 'Только кеш', - settings_rest_cache_only_descr: 'Основные настройки сохранятся', - settings_rest_cache_all: 'Кеш и данные', - settings_rest_cache_all_descr: 'Будут очищены все настройки и данные', - settings_rest_cache_calculate: 'Сколько осталось памяти', - settings_parser_use: 'Использовать парсер', - settings_parser_use_descr: 'Тем самым, вы соглашаетесь принять на себя всю ответственность за использование публичных ссылок для просмотра торрент и онлайн контента.', - settings_parser_type: 'Тип парсера для торрентов', - settings_parser_jackett_placeholder: 'Например: 192.168.х', - settings_parser_jackett_link: 'Ссылка', - settings_parser_jackett_link_descr: 'Укажите ссылку на скрипт Jackett', - settings_parser_prowlarr_link_descr: 'Укажите ссылку на сервер Prowlarr', - settings_parser_jackett_key_placeholder: 'Например: sa0sk83d..', - settings_parser_jackett_key: 'Api-ключ', - settings_parser_jackett_key_descr: 'Находится в Jackett', - settings_parser_prowlarr_key_descr: 'Находится во вкладке настроек Prowlarr в категории основное', - settings_parser_torlook_type: 'Метод парсинга сайта TorLook', - settings_parser_scraperapi_placeholder: 'Например: scraperapi.com', - settings_parser_scraperapi_link: 'Ссылка на парсер сайтов', - settings_parser_scraperapi_descr: 'Зарегистрируйтесь на сайте scraperapi.com, введите ссылку api.scraperapi.com?api_key=...&url={q}
    В {q} будет поставляться сайт w41.torlook.info', - settings_parser_search: 'Поиск', - settings_parser_search_descr: 'На каком языке производить поиск?', - settings_parser_in_search: 'Парсер в поиске', - settings_parser_in_search_descr: 'Показывать результаты в поиске?', - settings_parser_timeout_title: 'Таймаут парсера', - settings_parser_timeout_descr: 'Время (в секундах) ожидания ответа от сервера', - settings_player_type: 'Тип плеера', - settings_player_type_descr: 'Каким плеером воспроизводить видео', - settings_player_iptv_type: 'Тип плеера для IPTV', - settings_player_iptv_type_descr: 'Каким плеером воспроизводить IPTV-каналы', - settings_player_torrent_type: 'Тип плеера для торрентов', - settings_player_torrent_type_descr: 'Каким плеером воспроизводить торренты', - settings_player_reset: 'Сбросить плеер по умолчанию', - settings_player_reset_descr: 'Сбрасывает выбранный Android-плеер в приложении', - settings_player_path: 'Путь к плееру', - settings_player_path_descr: 'Укажите путь к исполняемому файлу плеера', - settings_player_normalization: 'Нормализация звука', - settings_player_normalization_descr: 'Нормализирует звук в один уровень, понижает громкие звуки и повышает тихие.', - settings_player_next_episode: 'Следующая серия', - settings_player_next_episode_descr: 'Автоматически переключать на следующую серию по окончании текущей', - settings_player_timecode: 'Тайм-код', - settings_player_timecode_descr: 'Продолжить с последнего места просмотра', - settings_player_scale: 'Метод масштабирования', - settings_player_scale_descr: 'Каким образом производить вычисления для масштабирования видео', - settings_player_subs: 'Субтитры', - settings_player_subs_use: 'Включить', - settings_player_subs_use_descr: 'Всегда включать субтитры после запуска видео', - settings_player_subs_size: 'Размер', - settings_player_subs_size_descr: 'Размер субтитров на экране', - settings_player_subs_stroke_use: 'Использовать окантовку', - settings_player_subs_stroke_use_descr: 'Субтитры будут обведены черным цветом для улучшения читаемости', - settings_player_subs_backdrop_use: 'Использовать подложку', - settings_player_subs_backdrop_use_descr: 'Субтитры будут отображаться на полупрозрачной подложке для улучшения читаемости', - settings_player_quality: 'Качество видео по умолчанию', - settings_player_quality_descr: 'Предпочтительное качество видео для просмотра', - settings_player_hls_title: 'Обработка потока .m3u8', - settings_player_hls_descr: 'Не трогайте этот параметр, если не знаете, зачем он.', - settings_player_rewind_title: 'Перемотка', - settings_player_rewind_descr: 'Интервал перемотки в секундах', - settings_player_launch_trailers: 'Плеер для трейлеров', - settings_plugins_notice: 'Для применения плагина необходимо перезагрузить приложение', - settings_plugins_add: 'Добавить плагин', - settings_plugins_add_descr: 'Для удаления добавленного плагина удерживайте или нажмите дважды клавишу (OK) на нем', - settings_plugins_install: 'Установить плагин', - settings_plugins_install_descr: 'Установить плагин из списка доступных', - settings_server_link: 'Использовать ссылку', - settings_server_links: 'Ссылки', - settings_server_placeholder: 'Например: 192.168.х', - settings_server_link_one: 'Основная ссылка', - settings_server_link_one_descr: 'Укажите основную ссылку на TorrServer', - settings_server_link_two: 'Дополнительная ссылка', - settings_server_link_two_descr: 'Укажите дополнительную ссылку на TorrServer', - settings_server_additionally: 'Дополнительно', - settings_server_client: 'Встроенный клиент', - settings_server_client_descr: 'Использовать встроенный JS-клиент TorrServer, иначе запускается системный.', - settings_server_base: 'Сохранять в базу', - settings_server_base_descr: 'Торрент будет добавлен в базу TorrServer', - settings_server_preload: 'Использовать буфер пред.загрузки', - settings_server_preload_descr: 'Дожидаться заполнения буфера предварительной загрузки TorrServer перед проигрыванием', - settings_server_auth: 'Авторизация', - settings_server_password_use: 'Вход по паролю', - settings_server_login: 'Логин', - settings_server_password: 'Пароль', - settings_server_not_specified: 'Не указан', - settings_webos_launcher: 'Запуск приложения', - settings_webos_launcher_add_device: 'Установить как стартовое', - settings_webos_launcher_remove_device: 'Убрать из стартовых приложений', - settings_parental_control_param_time_always: 'Всегда', - settings_parental_control_param_time_once: 'Один раз', - settings_parental_control_param_time_10: 'Через 10 минут', - settings_parental_control_param_time_20: 'Через 20 минут', - settings_parental_control_param_time_30: 'Через 30 минут', - settings_parental_control_param_time_60: 'Через 1 час', - settings_parental_control_param_time_120: 'Через 2 часа', - settings_parental_control_change_pin: 'Изменить PIN-код', - settings_parental_control_demand_title: 'Когда запрашивать', - settings_parental_control_demand_descr: 'Через какое время запрашивать PIN-код', - settings_parental_control_enabled: 'Включено', - settings_parental_control_disabled: 'Отключено', - parental_control_input_new_code: 'Введите новый PIN-код', - parental_control_confirm_new_code: 'Повторите PIN-код', - parental_control_no_match_code: 'PIN-код не совпадает с прошлым кодом', - parental_control_input_code: 'Введите PIN-код', - parental_control_input_error: 'Вы ввели неправильный PIN-код', - torent_nohash_reasons: 'Причины', - torent_nohash_reason_one: 'TorServer не смог скачать торрент файл', - torent_nohash_reason_two: 'Ответ от TorServer', - torent_nohash_reason_three: 'Ссылка', - torent_nohash_do: 'Что делать?', - torent_nohash_do_one: 'Проверьте правильно ли вы настроили Jackett', - torent_nohash_do_two: 'Приватные источники могут не выдавать ссылку на файл', - torent_nohash_do_three: 'Убедитесь что Jackett тоже может скачать файл', - torent_nohash_do_four: 'Написать в нашу Telegram-группу: @lampa_group', - torent_nohash_do_five: 'Укажите какой фильм, какая раздача и по возможности фото этой раздачи', - torrent_error_text: 'Не удалось подключиться к TorrServer. Давайте быстро пройдёмся по списку возможных проблем и всё проверим.', - torrent_error_step_1: 'Запущен ли TorrServer', - torrent_error_step_2: 'Динамический IP-адрес', - torrent_error_step_3: 'Протокол и порт', - torrent_error_step_4: 'Блокировка антивирусами', - torrent_error_step_5: 'Проверьте на доступность', - torrent_error_step_6: 'Все равно не работает', - torrent_error_info_1: 'Убедитесь, что вы запустили TorrServer на устройстве, где он установлен.', - torrent_error_info_2: 'Частая ошибка, изменился IP-адрес устройства с TorrServer. Убедитесь, что IP-адрес, который вы ввели - {ip}, совпадает с адресом устройства, на котором установлен TorrServer.', - torrent_error_info_3: 'Для подключения к TorrServer, необходимо указать протокол http:// в начале и порт :8090 в конце адреса. Убедитесь, что после IP-адреса указан порт, ваш текущий адрес - {ip}', - torrent_error_info_4: 'Частое явление, антивирус или брандмауэр может блокировать доступ по IP-адресу, попробуйте отключить антивирус и брандмауэр.', - torrent_error_info_5: 'На любом другом устройстве в этой же сети, откройте в браузере адрес {ip} и проверьте, доступен ли веб-интерфейс TorrServer.', - torrent_error_info_6: 'Если после всех проверок всё равно возникает ошибка подключения, попробуйте перезагрузить TorrServer и интернет-адаптер.', - torrent_error_info_7: 'Если проблема не устранена, пишите в Telegram-группу @lampa_group с текстом (Lampa не подключается к TorrServer после всех проверок, текущий адрес {ip})', - torrent_error_start: 'Начать проверку', - torrent_error_nomatrix: 'Не удалось подтвердить версию Matrix', - torrent_error_made: 'Выполнено', - torrent_error_from: 'из', - torrent_error_next: 'Далее', - torrent_error_complite: 'Завершить', - torrent_error_connect: 'Ошибка подключения', - torrent_error_check_no_auth: 'Сервер ответил на запрос, но не удалось пройти авторизацию', - torrent_install_need: 'Необходим TorrServer', - torrent_install_text: 'TorrServer – приложение, которое позволяет просматривать контент из торрент-файлов в онлайн режиме.

    Более детальную информацию по установке вы найдете в Telegram-группах, указанных ниже.', - torrent_install_contact: 'Telegram-группы', - torrent_item_bitrate: 'Битрейт', - torrent_item_seeds: 'Раздают', - torrent_item_grabs: 'Качают', - torrent_item_mb: 'Мбит/с', - torrent_serial_episode: 'Серия', - torrent_serial_season: 'Сезон', - torrent_serial_date: 'Выход', - torrent_get_magnet: 'Запрашиваю magnet ссылку', - torrent_remove_title: 'Удалить', - torrent_remove_descr: 'Торрент будет удален из вашего списка', - torrent_parser_any_one: 'Любое', - torrent_parser_any_two: 'Любой', - torrent_parser_no_choice: 'Не выбрано', - torrent_parser_yes: 'Да', - torrent_parser_no: 'Нет', - torrent_parser_quality: 'Качество', - torrent_parser_subs: 'Субтитры', - torrent_parser_voice: 'Перевод', - torrent_parser_tracker: 'Трекер', - torrent_parser_year: 'Год', - torrent_parser_season: 'Сезон', - torrent_parser_sort_by_seeders: 'По раздающим', - torrent_parser_sort_by_size: 'По размеру', - torrent_parser_sort_by_name: 'По названию', - torrent_parser_sort_by_tracker: 'По источнику', - torrent_parser_sort_by_date: 'По дате', - torrent_parser_sort_by_viewed: 'По просмотренным', - torrent_parser_voice_dubbing: 'Дубляж', - torrent_parser_voice_polyphonic: 'Многоголосый', - torrent_parser_voice_two: 'Двухголосый', - torrent_parser_voice_amateur: 'Любительский', - torrent_parser_reset: 'Сбросить фильтр', - torrent_parser_empty: 'Не удалось получить результатов', - torrent_parser_no_hash: 'Не удалось получить HASH', - torrent_parser_added_to_mytorrents: 'добавлено в «Мои торренты»', - torrent_parser_add_to_mytorrents: 'Добавить в «Мои торренты»', - torrent_parser_label_title: 'Пометить', - torrent_parser_label_descr: 'Пометить раздачу с флагом (просмотрено)', - torrent_parser_label_cancel_title: 'Снять отметку', - torrent_parser_label_cancel_descr: 'Снять отметку с раздачи (просмотрено)', - torrent_parser_timeout: 'Время ожидания истекло', - torrent_parser_nofiles: 'Не удалось извлечь подходящие файлы', - torrent_parser_set_link: 'Укажите ссылку для парсинга', - torrent_parser_request_error: 'Ошибка в запросе', - torrent_parser_magnet_error: 'Не удалось получить magnet ссылку', - torrent_parser_no_responce: 'Парсер не отвечает на запрос', - torrent_parser_torlook_fallback_search_notification: 'Парсер Jackett не доступен или настройки подключения не верны. Осуществляется поиск в Torlook...', - about_text: 'Приложение полностью бесплатное и использует публичные ссылки для получения информации о видео, новинках, популярных фильмах и т.д. Вся доступная информация используется исключительно в познавательных целях, приложение не использует свои собственные серверы для распространения информации.', - about_channel: 'Наш канал', - about_group: 'Группа', - about_version: 'Версия', - about_donate: 'Донат', - title_watched: 'Вы смотрели', - title_settings: 'Настройки', - title_collections: 'Подборки', - title_company: 'Компания', - title_actors: 'Актеры', - title_actor: 'Актер', - title_actress: 'Актриса', - title_person: 'Персона', - title_persons: 'Персоны', - title_comments: 'Комментарии', - title_torrents: 'Торренты', - title_trailers: 'Трейлеры', - title_watch: 'Смотреть', - title_error: 'Ошибка', - title_links: 'Ссылки', - title_choice: 'Выбрать', - title_main: 'Главная', - title_book: 'Закладки', - title_like: 'Нравится', - title_wath: 'Позже', - title_look: 'Смотрю', - title_scheduled: 'Запланировано', - title_viewed: 'Просмотрено', - title_thrown: 'Брошено', - title_continued: 'Продолжение следует', - title_history: 'История просмотров', - title_mytorrents: 'Мои торренты', - title_last: 'Последняя', - title_action: 'Действие', - title_producer: 'Режиссер', - title_collection: 'Коллекция', - title_recomendations: 'Рекомендации', - title_similar: 'Похожие', - title_about: 'О приложении', - title_timetable: 'Расписание', - title_relises: 'Цифровые релизы', - title_catalog: 'Каталог', - title_category: 'Категория', - title_parser: 'Парсер', - title_type: 'Тип', - title_rating: 'Рейтинг', - title_country: 'Страна', - title_year: 'Год', - title_genre: 'Жанр', - title_filter: 'Фильтр', - title_notice: 'Уведомления', - title_files: 'Файлы', - title_now_watch: 'Сейчас смотрят', - title_latest: 'Последнее добавление', - title_continue: 'Продолжить просмотр', - title_recomend_watch: 'Рекомендуем посмотреть', - title_new_episodes: 'Новые серии', - title_popular: 'Популярное', - title_popular_movie: 'Популярные фильмы', - title_popular_tv: 'Популярные сериалы', - title_new_this_year: 'Новинки этого года', - title_hight_voite: 'С высоким рейтингом', - title_new: 'Новинки', - title_trend_day: 'Сегодня в тренде', - title_trend_week: 'В тренде за неделю', - title_upcoming: 'Смотрите в кинозалах', - title_top_movie: 'Топ фильмы', - title_top_tv: 'Топ сериалы', - title_tv_today: 'Сегодня в эфире', - title_this_week: 'На этой неделе', - title_in_top: 'В топе', - title_out: 'Выход', - title_out_confirm: 'Да, выйти', - title_continue_two: 'Продолжить', - title_choice_language: 'Выбрать язык', - title_subscribe: 'Подписаться', - title_subscribes: 'Подписки', - title_unsubscribe: 'Отписаться', - title_language: 'Язык оригинала', - title_language_short: 'Язык', - title_ongoing: 'Онгоинги', - title_pgrating: 'Возрастное ограничение', - title_card: 'Карточка', - title_seasons: 'Сезоны', - title_episodes: 'Серии', - title_rewiews: 'Отзывы', - title_channel: 'Канал', - title_in_high_quality: 'В высоком качестве', - title_author: 'Автор', - title_buffer: 'Буфер', - title_upcoming_episodes: 'Ближайшие выходы эпизодов', - title_reactions: 'Реакции', - title_last_year: 'Прошлый год', - title_reset: 'Перезагрузить', - title_left: 'Осталось', - title_parental_control: 'Родительский контроль', - title_worth_rewatch: 'Стоит пересмотреть', - reactions_none: 'Нет реакций', - reactions_fire: 'Супер', - reactions_nice: 'Неплохо', - reactions_think: 'Смотрибельно', - reactions_bore: 'Скука', - reactions_shit: 'Плохо', - reactions_ready: 'Вы уже оставили реакцию', - subscribe_success: 'Вы успешно подписались', - subscribe_error: 'Возникла ошибка при подписке, попробуйте позже', - subscribe_noinfo: 'Не удалось получить информацию, попробуйте позже', - company_headquarters: 'Штаб', - company_homepage: 'Сайт', - company_country: 'Страна', - country_ad: 'Андорра', - country_ae: 'ОАЭ', - country_af: 'Афганистан', - country_al: 'Албания', - country_am: 'Армения', - country_ao: 'Ангола', - country_ar: 'Аргентина', - country_at: 'Австрия', - country_au: 'Австралия', - country_aw: 'Аруба', - country_az: 'Азербайджан', - country_bа: 'Босния и Герцеговина', - country_bd: 'Бангладеш', - country_be: 'Бельгия', - country_bg: 'Болгария', - country_bh: 'Бахрейн', - country_bi: 'Бурунди', - country_bj: 'Бенин', - country_bo: 'Боливия', - country_br: 'Бразилия', - country_bs: 'Багамские о-ва', - country_bt: 'Бутан', - country_bw: 'Ботсвана', - country_by: 'Беларусь', - country_ca: 'Канада', - country_ch: 'Швейцария', - country_cl: 'Чили', - country_cm: 'Камерун', - country_cn: 'Китай', - country_co: 'Колумбия', - country_cr: 'Коста-Рика', - country_cu: 'Куба', - country_cv: 'Кабо-Верде', - country_cy: 'Кипр', - country_cz: 'Чехия', - country_de: 'Германия', - country_dj: 'Джибути', - country_dk: 'Дания', - country_do: 'Доминикана', - country_dz: 'Алжир', - country_ec: 'Эквадор', - country_ee: 'Эстония', - country_eg: 'Египет', - country_es: 'Испания', - country_et: 'Эфиопия', - country_fi: 'Финляндия', - country_fo: 'Фарерские о-ва', - country_fr: 'Франция', - country_ga: 'Габон', - country_gb: 'Великобритания', - country_ge: 'Грузия', - country_gh: 'Гана', - country_gl: 'Гренландия', - country_gp: 'Гваделупа', - country_gr: 'Греция', - country_gt: 'Гватемала', - country_hk: 'Гонконг', - country_hr: 'Хорватия', - country_ht: 'Гаити', - country_hu: 'Венгрия', - country_id: 'Индонезия', - country_ie: 'Ирландия', - country_il: 'Израиль', - country_in: 'Индия', - country_iq: 'Ирак', - country_ir: 'Иран', - country_is: 'Исландия', - country_it: 'Италия', - country_jm: 'Ямайка', - country_jo: 'Иордания', - country_jp: 'Япония', - country_ke: 'Кения', - country_kg: 'Киргизия', - country_kh: 'Камбоджа', - country_kp: 'Северная Корея', - country_kr: 'Южная Корея', - country_kz: 'Казахстан', - country_kw: 'Кувейт', - country_la: 'Лаос', - country_lb: 'Ливан', - country_li: 'Лихтенштейн', - country_lk: 'Шри-Ланка', - country_lr: 'Либерия', - country_lt: 'Литва', - country_lu: 'Люксембург', - country_lv: 'Латвия', - country_ly: 'Ливия', - country_ma: 'Марокко', - country_mc: 'Монако', - country_md: 'Молдова', - country_me: 'Черногория', - country_mk: 'Македония', - country_mm: 'Мьянма', - country_mn: 'Монголия', - country_mo: 'Макао', - country_mt: 'Мальта', - country_mu: 'Маврикий', - country_mv: 'Мальдивы', - country_mw: 'Малави', - country_mx: 'Мексика', - country_my: 'Малайзия', - country_mz: 'Мозамбик', - country_na: 'Намибия', - country_ne: 'Нигер', - country_ng: 'Нигерия', - country_ni: 'Никарагуа', - country_nl: 'Нидерланды', - country_no: 'Норвегия', - country_np: 'Непал', - country_nz: 'Новая Зеландия', - country_om: 'Оман', - country_pa: 'Панама', - country_pe: 'Перу', - country_pg: 'Папуа - Новая Гвинея', - country_ph: 'Филиппины', - country_pk: 'Пакистан', - country_pl: 'Польша', - country_pr: 'Пуэрто-Рико', - country_ps: 'Палестина', - country_pt: 'Португалия', - country_py: 'Парагвай', - country_qa: 'Катар', - country_ro: 'Румыния', - country_rs: 'Сербия', - country_ru: 'Россия', - country_rw: 'Руанда', - country_sa: 'Саудовская Аравия', - country_sd: 'Судан', - country_se: 'Швеция', - country_sg: 'Сингапур', - country_si: 'Словения', - country_sk: 'Словакия', - country_sn: 'Сенегал', - country_su: 'СССР', - country_sv: 'Сальвадор', - country_sy: 'Сирия', - country_th: 'Таиланд', - country_tj: 'Таджикистан', - country_tm: 'Туркменистан', - country_tn: 'Тунис', - country_tr: 'Турция', - country_tw: 'Тайвань', - country_tz: 'Танзания', - country_ua: 'Украина', - country_ug: 'Уганда', - country_us: 'США', - country_uy: 'Уругвай', - country_uz: 'Узбекистан', - country_ve: 'Венесуэла', - country_vn: 'Вьетнам', - country_ws: 'Самоа', - country_xk: 'Косово', - country_ye: 'Йемен', - country_yu: 'Югославия', - country_za: 'ЮАР', - country_zm: 'Замбия', - country_zw: 'Зимбабве', - filter_clarify: 'Уточнить', - filter_clarify_two: 'Уточнить поиск', - filter_set_name: 'Указать название', - filter_sorted: 'Сортировать', - filter_filtred: 'Фильтр', - filter_any: 'Любой', - filter_combinations: 'Комбинации', - filter_alt_names: 'Другие названия', - filter_rating_from: 'от', - filter_rating_to: 'до', - filter_lang_af: 'Африкаанс', - filter_lang_ar: 'Арабский', - filter_lang_az: 'Азербайджанский', - filter_lang_ba: 'Башкирский', - filter_lang_be: 'Белорусский', - filter_lang_bg: 'Болгарский', - filter_lang_bn: 'Бенгальский', - filter_lang_bs: 'Боснийский', - filter_lang_ca: 'Каталанский', - filter_lang_ce: 'Чеченский', - filter_lang_cs: 'Чешский', - filter_lang_da: 'Датский', - filter_lang_de: 'Немецкий', - filter_lang_el: 'Греческий', - filter_lang_en: 'Английский', - filter_lang_es: 'Испанский', - filter_lang_et: 'Эстонский', - filter_lang_fa: 'Персидский', - filter_lang_fi: 'Финский', - filter_lang_fr: 'Французский', - filter_lang_ga: 'Ирландский', - filter_lang_gl: 'Галисийский', - filter_lang_gn: 'Гуарани', - filter_lang_he: 'Иврит', - filter_lang_hi: 'Хинди', - filter_lang_hr: 'Хорватский', - filter_lang_hu: 'Венгерский', - filter_lang_hy: 'Армянский', - filter_lang_id: 'Индонезийский', - filter_lang_is: 'Исландский', - filter_lang_it: 'Итальянский', - filter_lang_ja: 'Японский', - filter_lang_ka: 'Грузинский', - filter_lang_kk: 'Казахский', - filter_lang_ko: 'Корейский', - filter_lang_ks: 'Кашмири', - filter_lang_ku: 'Курдский', - filter_lang_ky: 'Киргизский', - filter_lang_lt: 'Литовский', - filter_lang_lv: 'Латышский', - filter_lang_mi: 'Маори', - filter_lang_mk: 'Македонский', - filter_lang_mn: 'Монгольский', - filter_lang_mo: 'Молдавский', - filter_lang_mt: 'Мальтийский', - filter_lang_ne: 'Непальский', - filter_lang_nl: 'Нидерландский', - filter_lang_no: 'Норвежский', - filter_lang_pa: 'Панджаби', - filter_lang_pl: 'Польский', - filter_lang_ps: 'Пушту', - filter_lang_pt: 'Португальский', - filter_lang_ro: 'Румынский', - filter_lang_ru: 'Русский', - filter_lang_si: 'Сингальский', - filter_lang_sk: 'Словацкий', - filter_lang_sl: 'Словенский', - filter_lang_sm: 'Самоанский', - filter_lang_so: 'Сомалийский', - filter_lang_sq: 'Албанский', - filter_lang_sr: 'Сербский', - filter_lang_sv: 'Шведский', - filter_lang_sw: 'Суахили', - filter_lang_ta: 'Тамильский', - filter_lang_tg: 'Таджикский', - filter_lang_th: 'Тайский', - filter_lang_tk: 'Туркменский', - filter_lang_tr: 'Турецкий', - filter_lang_tt: 'Татарский', - filter_lang_ur: 'Урду', - filter_lang_uk: 'Украинский', - filter_lang_uz: 'Узбекский', - filter_lang_vi: 'Вьетнамский', - filter_lang_yi: 'Идиш', - filter_lang_zh: 'Китайский', - filter_genre_ac: 'Боевик', - filter_genre_ad: 'Приключения', - filter_genre_mv: 'Мультфильм', - filter_genre_cm: 'Комедия', - filter_genre_cr: 'Криминал', - filter_genre_dc: 'Документальный', - filter_genre_dr: 'Драма', - filter_genre_fm: 'Семейный', - filter_genre_fe: 'Фэнтези', - filter_genre_hi: 'История', - filter_genre_ho: 'Ужасы', - filter_genre_mu: 'Музыка', - filter_genre_de: 'Детектив', - filter_genre_md: 'Мелодрама', - filter_genre_fa: 'Фантастика', - filter_genre_tv: 'Телевизионный фильм', - filter_genre_tr: 'Триллер', - filter_genre_mi: 'Военный', - filter_genre_ve: 'Вестерн', - filter_genre_aa: 'Боевик и Приключения', - filter_genre_ch: 'Детский', - filter_genre_nw: 'Новости', - filter_genre_rs: 'Реалити-шоу', - filter_genre_hf: 'НФ и Фэнтези', - filter_genre_op: 'Мыльная опера', - filter_genre_tc: 'Ток-шоу', - filter_genre_mp: 'Война и Политика', - empty_title: 'Пусто', - empty_text: 'По вашему фильтру ничего не нашлось, уточните фильтр.', - empty_title_two: 'Здесь пусто', - empty_text_two: 'На данный момент список пустой', - back_to_card: 'Вернуться в карточку', - menu_main: 'Главная', - menu_movies: 'Фильмы', - menu_tv: 'Сериалы', - menu_catalog: 'Каталог', - menu_filter: 'Фильтр', - menu_collections: 'Подборки', - menu_relises: 'Релизы', - menu_anime: 'Аниме', - menu_bookmark: 'Закладки', - menu_like: 'Нравится', - menu_time: 'Позже', - menu_history: 'История', - menu_timeline: 'Расписание', - menu_torrents: 'Торренты', - menu_settings: 'Настройки', - menu_about: 'Информация', - menu_console: 'Консоль', - menu_multmovie: 'Мультфильмы', - menu_multtv: 'Мультсериалы', - menu_feed: 'Лента', - lampa_movie_title: 'Ламповое кино', - lampa_movie_descr: 'Следите за новинками на своем смартфоне.
    Телеграм: @lampa_movie', - plugins_catalog_work: 'Рабочие плагины', - plugins_catalog_work_descr: 'Плагины, которые точно работают в лампе.', - plugins_catalog_popular: 'Популярные плагины среди пользователей', - plugins_catalog_popular_descr: 'Установка из неизвестных источников может привести к некорректной работе приложения.', - plugins_online: 'Просмотр онлайн', - plugins_check_fail: 'Не удалось проверить работоспособность плагина. Однако это не означает, что плагин не работает. Перезагрузите приложение для выяснения, загружается ли плагин.', - plugins_need_reload: 'Для применения плагина необходимо перезагрузить приложение', - plugins_install: 'Установить', - plugins_install_ready: 'Этот плагин уже установлен.', - plugins_installed: 'Установок', - plugins_load_from: 'Загружено из CUB', - plugins_ok_for_check: 'Нажмите (OK) для проверки плагина', - plugins_no_loaded: 'При загрузке приложения, часть плагинов не удалось загрузить', - plugins_remove: 'Удалить плагины', - plugins_add_success: 'Плагин успешно подключен', - time_viewed: 'Просмотрено', - time_from: 'из', - time_reset: 'Сбросить тайм-код', - settings_clear_cache: 'Кеш и данные очищены', - settings_clear_cache_only: 'Кеш очищен', - settings_user_links: 'Пользовательская ссылка', - settings_for_local: 'Для локального TorrServer', - settings_add: 'Добавить', - settings_remove: 'Удалить', - settings_this_value: 'текущее значение', - settings_added: 'Добавлено', - settings_removed: 'Удалено', - settings_reset: 'Сброс настроек', - settings_param_player_inner: 'Встроенный', - settings_param_player_outside: 'Внешний', - settings_param_yes: 'Да', - settings_param_no: 'Нет', - settings_param_interface_size_small: 'Меньше', - settings_param_interface_size_normal: 'Нормальный', - settings_param_interface_size_bigger: 'Больше', - settings_param_poster_quality_low: 'Низкое', - settings_param_poster_quality_average: 'Среднее', - settings_param_poster_quality_high: 'Высокое', - settings_param_parse_directly: 'Напрямую', - settings_param_parse_api: 'Через API сайта', - settings_param_background_complex: 'Сложный', - settings_param_background_simple: 'Простой', - settings_param_background_image: 'Картинка', - settings_param_link_use_one: 'Основную', - settings_param_link_use_two: 'Дополнительную', - settings_param_subtitles_size_small: 'Маленькие', - settings_param_subtitles_size_normal: 'Обычные', - settings_param_subtitles_size_bigger: 'Большие', - settings_param_screensaver_nature: 'Природа', - settings_param_torrent_lang_orig: 'Оригинал', - settings_param_player_timecode_again: 'Начать с начала', - settings_param_player_timecode_continue: 'Продолжить', - settings_param_player_timecode_ask: 'Спрашивать', - settings_param_player_scale_method: 'Рассчитать', - settings_param_player_hls_app: 'Системный', - settings_param_player_hls_js: 'Программный', - settings_param_card_view_load: 'Подгружать', - settings_param_card_view_all: 'Показать все', - settings_param_navigation_remote: 'Пульт', - settings_param_navigation_mouse: 'Пульт с мышкой', - settings_param_keyboard_lampa: 'Встроенная', - settings_param_keyboard_system: 'Системная', - settings_param_card_interface_old: 'Старый', - settings_param_card_interface_new: 'Новый', - settings_param_glass_easy: 'Прозрачная', - settings_param_glass_medium: 'Полупрозрачная', - settings_param_glass_blacked: 'Затемнённая', - settings_param_jackett_interview_all: 'Все', - settings_param_jackett_interview_healthy: 'Только доступные', - settings_parser_jackett_interview: 'Опрашивать трекеры', - helper_keyboard: 'После ввода значения нажмите кнопку «Назад» для сохранения', - helper_torrents: 'Удерживайте клавишу (ОК) для вызова контекстного меню', - helper_cleared: 'Успешно, подсказки будут показаны заново.', - helper_torrents_view: 'Для сброса тайм-кода и вызова меню удерживайте клавишу (ОК)', - fav_sync_title: 'Синхронизация закладок', - fav_sync_text: 'Ваши любимые закладки вместе с Вами. Подключите синхронизацию и просматривайте на любом устройстве.

    Для этого зарегистрируйтесь на сайте www.cub.red, создайте профиль и авторизуйтесь в приложение.', - fav_sync_site: 'Сайт', - fav_remove_title: 'Удалить из истории', - fav_remove_descr: 'Удалить выделенную карточку', - fav_clear_title: 'Очистить историю', - fav_clear_descr: 'Удалить все карточки из истории', - fav_clear_label_title: 'Очистить метки', - fav_clear_label_descr: 'Очистить метки о просмотрах', - fav_clear_time_title: 'Очистить тайм-коды', - fav_clear_time_descr: 'Очистить все тайм-коды', - fav_label_cleared: 'Отметки очищены', - fav_time_cleared: 'Тайм-коды очищены', - timetable_empty: 'В этом разделе будут отображаться даты выхода новых серий', - player_quality: 'Качество', - player_tracks: 'Аудиодорожки', - player_disabled: 'Отключено', - player_unknown: 'Неизвестно', - player_subs: 'Субтитры', - player_size_default_title: 'По умолчанию', - player_size_default_descr: 'Размер видео по умолчанию', - player_size_cover_title: 'Расширить', - player_size_cover_descr: 'Расширяет видео на весь экран', - player_size_fill_title: 'Заполнить', - player_size_fill_descr: 'Вместить видео на весь экран', - player_size_s115_title: 'Увеличить 115%', - player_size_s115_descr: 'Увеличить видео на 115%', - player_size_s130_title: 'Увеличить 130%', - player_size_s130_descr: 'Увеличить видео на 130%', - player_size_v115_title: 'По вертикали 115%', - player_size_v115_descr: 'Увеличить видео на 115%', - player_size_v130_title: 'По вертикали 130%', - player_size_v130_descr: 'Увеличить видео на 130%', - player_video_size: 'Размер видео', - player_playlist: 'Плейлист', - player_error_one: 'Не удалось декодировать видео', - player_error_two: 'Видео не найдено или повреждено', - player_start_from: 'Продолжить просмотр с', - player_not_found: 'Плеер не найден', - player_lauch: 'Запустить плеер', - player_speed_default_title: 'Обычная', - player_speed_two_descr: 'Воспроизводиться без звука', - player_video_speed: 'Скорость воспроизведения', - player_share_title: 'Поделиться', - player_share_descr: 'Запустить это видео на другом устройстве', - player_normalization_power_title: 'Сила нормализации', - player_normalization_smooth_title: 'Скорость нормализации', - player_normalization_step_none: 'Нулевая', - player_normalization_step_low: 'Низкое', - player_normalization_step_medium: 'Среднее', - player_normalization_step_hight: 'Высокое', - player_normalization: 'Нормализация', - player_youtube_no_played: 'К сожалению, это видео не доступно в вашем регионе, возможно, оно было заблокировано или удалено.', - player_youtube_start_play: 'Для начала проигрывания видео, нажмите кнопку "Плей"', - broadcast_open: 'Открыть карточку на другом устройстве', - broadcast_play: 'Выберите устройство для просмотра', - card_new_episode: 'Новая серия', - card_book_remove: 'Убрать из закладок', - card_book_add: 'В закладки', - card_book_descr: 'Смотрите в меню (Закладки)', - card_like_remove: 'Убрать из понравившихся', - card_like_add: 'Нравится', - card_like_descr: 'Смотрите в меню (Нравится)', - card_wath_remove: 'Убрать из ожидаемых', - card_wath_add: 'Смотреть позже', - card_wath_descr: 'Смотрите в меню (Позже)', - card_history_remove: 'Убрать из истории', - card_history_add: 'В историю', - card_history_descr: 'Смотрите в меню (История)', - keyboard_listen: 'Говорите, я слушаю...', - keyboard_nomic: 'Нет доступа к микрофону', - notice_new_quality: 'Доступно новое качество', - notice_quality: 'Качество', - notice_new_episode: 'Новая серия', - notice_none: 'У вас еще нет никаких уведомлений, зарегистрируйтесь на сайте www.cub.red, чтобы следить за новыми сериями и релизами.', - notice_in_quality: 'В качестве', - notice_none_account: 'У вас еще нет никаких уведомлений, добавьте сериалы в закладки и ожидайте уведомления о новых сериях.', - notice_none_system: 'На данный момент у вас отсутствуют уведомления. Мы обязательно оповестим вас, когда появятся новые уведомления.', - copy_link: 'Копировать ссылку на видео', - copy_secuses: 'Ссылка скопирована в буфер обмена', - copy_error: 'Ошибка при копирование ссылки', - account_sync_to_profile: 'Все закладки будут перенесены в профиль', - account_sync_secuses: 'Все закладки успешно перенесены', - account_profiles: 'Профили', - account_profiles_empty: 'Не удалось получить список профилей', - account_authorized: 'Авторизованы', - account_logged_in: 'Вы вошли под аккаунтом', - account_login_failed: 'Вход не выполнен', - account_login_wait: 'Ожидаем входа в аккаунт', - account_profile_main: 'Общий', - account_export_secuses: 'Экспорт успешно завершён', - account_export_fail: 'Ошибка при экспорте', - account_export_fail_500: 'Неизвестная ошибка', - account_export_fail_610: 'Вы исчерпали лимит на сегодня', - account_export_fail_200: 'Ошибка базы данных, попробуйте позже', - account_export_fail_600: 'Ошибка, не удалось загрузить файл', - account_export_fail_620: 'Ошибка, файл не передан', - account_import_secuses: 'Импорт успешно завершён', - account_import_fail: 'Ошибка при импорте', - account_imported: 'импортировано', - account_reload_after: 'перезагрузка через 5 сек.', - account_create: 'Откройте больше возможностей с аккаунтом CUB. Зарегистрируйтесь на сайте и получите доступ к синхронизации ваших закладок, тайм-кодов и других возможностей аккаунта CUB.', - account_premium: 'Раскройте новые горизонты с аккаунтом CUB Premium! Наслаждайтесь увеличенными лимитами и обогащенным функционалом сервиса. Дополнительные возможности ждут вас уже сегодня!', - account_premium_more: 'Подробнее о CUB Premium', - account_limited: 'Вы достигли максимального лимита. Увеличьте лимит с аккаунтом CUB Premium. Подробнее на сайте ', - account_premium_include_1: 'Увеличение количество закладок', - account_premium_include_2: 'Увеличение истории просмотров', - account_premium_include_3: 'Увеличение количество тайм-кодов', - account_premium_include_4: 'Количество профилей на аккаунт', - account_premium_include_5: 'Уведомления', - account_premium_include_6: 'Синхронизация данных', - account_premium_include_text_1: 'Больше закладок - больше возможностей! Сохраняйте свои любимые фильмы и сериалы, создавайте списки просмотра и наслаждайтесь просмотром в любое удобное время.', - account_premium_include_text_2: 'Увеличьте историю просмотров в приложении и следите за тем, что уже посмотрели. Легко находите и пересматривайте свои любимые фильмы и сериалы.', - account_premium_include_text_3: 'Не бойтесь пропустить ни одной важной сцены! Увеличьте количество тайм-кодов в приложении и легко отслеживайте, где остановились в просмотре любимых фильмов и сериалов.', - account_premium_include_text_4: 'Получите больше свободы с нашим премиум доступом! Увеличьте количество профилей на аккаунте и позвольте своим друзьям и близким наслаждаться фильмами и сериалами вместе с вами. Никаких ограничений - наслаждайтесь просмотром с любимыми людьми.', - account_premium_include_text_5: 'Не пропустите ни одной новой серии или перевода! Получайте уведомления вовремя и будьте в курсе всех обновлений. Увеличьте свой кинопоток вместе с нами и получайте уведомления о выходе новых серий и переводов прямо на свой смартфон.', - account_premium_include_text_6: 'Синхронизуйте свои данные между устройствами с премиум доступом! Больше не нужно тратить время на поиск последнего эпизода, на котором вы остановились. С нашим премиум доступом вы можете синхронизировать свои данные между устройствами, чтобы продолжать просмотр с места, где вы остановились, на любом устройстве, где установлено приложение.', - account_code_enter: 'Введите шестизначный код', - account_code_error: 'Возможно, вы ввели неверный или устаревший код', - account_code_wrong: 'Возможно, вы указали неверный формат', - account_code_where: 'Перейдите на сайт и введите указанный там код.', - account_code_input: 'Ввести код', - network_noconnect: 'Нет подключения к сети', - network_404: 'Запрошенная страница не найдена. [404]', - network_401: 'Авторизация не удалась', - network_500: 'Внутренняя ошибка сервера. [500]', - network_parsererror: 'Запрошенный синтаксический анализ JSON завершился неудачно.', - network_timeout: 'Время запроса истекло.', - network_abort: 'Запрос был прерван.', - network_error: 'Неизвестная ошибка', - size_zero: '0 Байт', - size_byte: 'Байт', - size_kb: 'КБ', - size_mb: 'МБ', - size_gb: 'ГБ', - size_tb: 'ТБ', - size_pp: 'ПБ', - speed_bit: 'бит/c', - speed_kb: 'Кбит/c', - speed_mb: 'Мбит/c', - speed_gb: 'Гбит/c', - speed_tb: 'Тбит/c', - speed_pp: 'Пбит/c', - month_1: 'Январь', - month_2: 'Февраль', - month_3: 'Март', - month_4: 'Апрель', - month_5: 'Ма', - month_6: 'Июнь', - month_7: 'Июль', - month_8: 'Август', - month_9: 'Сентябрь', - month_10: 'Октябрь', - month_11: 'Ноябрь', - month_12: 'Декабрь', - day_1: 'Понедельник', - day_2: 'Вторник', - day_3: 'Среда', - day_4: 'Четверг', - day_5: 'Пятница', - day_6: 'Суббота', - day_7: 'Воскресенье', - month_1_e: 'Января', - month_2_e: 'Февраля', - month_3_e: 'Марта', - month_4_e: 'Апреля', - month_5_e: 'Мая', - month_6_e: 'Июня', - month_7_e: 'Июля', - month_8_e: 'Августа', - month_9_e: 'Сентября', - month_10_e: 'Октября', - month_11_e: 'Ноября', - month_12_e: 'Декабря', - week_1: 'Пн', - week_2: 'Вт', - week_3: 'Ср', - week_4: 'Чт', - week_5: 'Пт', - week_6: 'Сб', - week_7: 'Вс', - time_h: 'ч.', - time_m: 'м.', - time_s: 'с.', - extensions_enable: 'Включить', - extensions_disable: 'Отключить', - extensions_check: 'Проверить статус', - extensions_install: 'Установить', - extensions_info: 'Информация', - extensions_edit: 'Редактировать', - extensions_change_name: 'Изменить название', - extensions_change_link: 'Изменить ссылку', - extensions_remove: 'Удалить', - extensions_set_name: 'Введите название плагина', - extensions_set_url: 'Введите адрес плагина', - extensions_ready: 'Этот плагин уже установлен', - extensions_no_info: 'Без информации', - extensions_no_name: 'Без названия', - extensions_worked: 'Рабочий', - extensions_no_plugin: 'Плагин не подтверждён ', - extensions_add: 'Добавить плагин', - extensions_from_memory: 'Установленные в память ', - extensions_from_cub: 'Установленные из CUB', - extensions_from_popular: 'Популярные плагины', - extensions_from_lib: 'Библиотека плагинов', - extensions_from_connected: 'Подключенные плагины', - extensions_hpu_best: 'Популярные', - extensions_hpu_recomend: 'Рекомендуем', - extensions_hpu_theme: 'Темы', - extensions_hpu_screensaver: 'Скринсейвер', - extensions_hpu_video: 'Видео', - extensions_hpu_control: 'Управление', - extensions_hpu_other: 'Разное', - extensions_hpu_: 'Остальное', - speedtest_connect: 'подключение', - speedtest_test: 'тестирование', - speedtest_ready: 'готово', - speedtest_button: 'Тестировать скорость', - change_source_on_cub: 'Сменить источник на CUB', - tv_status_returning_series: 'Онгоинг', - tv_status_planned: 'Запланировано', - tv_status_in_production: 'В производстве', - tv_status_ended: 'Завершено', - tv_status_canceled: 'Отменено', - tv_status_pilot: 'Пилотный', - tv_status_released: 'Выпущенный', - tv_status_rumored: 'По слухам', - tv_status_post_production: 'Скоро', - input_detection_touch: 'Хотите переключить на сенсорное управление?', - input_detection_mouse: 'Хотите переключить на управление мышью?', - input_detection_remote: 'Хотите переключить на управление пультом?', - https_text: 'Вы используйте протокол HTTPS, c которым Lampa работает некорректно. Для корректной работы приложения используйте адрес с протоколом HTTP', - premiere_author_recomend_1: 'Закажите пиццу и готовьтесь к драйву.', - premiere_author_recomend_2: 'Вечеринка только начинается.', - premiere_author_recomend_3: 'Подготовьтесь к адреналину.', - premiere_author_recomend_4: 'Готовы к незабываемому вечеру?', - premiere_author_recomend_5: 'Рекомендую к просмотру.', - premiere_title: 'Премьера', - termsofuse_t_01: 'Правила использования', - termsofuse_t_02: 'Lampa - это удобный инструмент для ознакомления с новинками киноиндустрии, включая фильмы, сериалы, мультфильмы и другую информацию. Для получения информации о фильмах используется открытый источник - сайт themoviedb.org', - termsofuse_t_03: 'Контент', - termsofuse_t_04: 'Lampa использует API (Application Programming Interface) от каталога themoviedb.org для получения информации о фильмах и телесериалах, а также для просмотра связанных с ними медиафайлов, таких как постеры, трейлеры и другое.', - termsofuse_t_05: 'API от themoviedb.org позволяет приложению Lampa получать доступ к базе данных фильмов и телесериалов, предоставляя возможность поиска медиафайлов и просмотра информации о них.', - termsofuse_t_06: 'Взаимодействие между приложением Lampa и themoviedb.org происходит через запросы к API, которые отправляются из приложения Lampa на серверы themoviedb.org для получения информации и медиафайлов. Themoviedb.org обрабатывает запросы и отправляет обратно в приложение Lampa запрошенные данные.', - termsofuse_t_07: 'Таким образом, благодаря использованию API от themoviedb.org, приложение Lampa предоставляет пользователям доступ к обширной базе данных фильмов и телесериалов, соблюдая при этом условия использования и ограничения, установленные правообладателем.', - termsofuse_t_08: 'Расширения', - termsofuse_t_09: 'Расширения - это мощный инструмент, предоставляемый для приложения Lampa, который позволяет пользователям расширить его возможности, добавить дополнительный функционал и изменить контент в соответствии с их потребностями.', - termsofuse_t_10: 'Однако, следует отметить, что пользователи устанавливают расширения на свой страх и риск. Все последствия, возникающие в результате использования расширений, ложатся на пользователя. Пользователям рекомендуется быть осторожными при установке и использовании расширений, тщательно оценивая их надежность и безопасность.', - termsofuse_t_11: 'Нарушения авторских прав', - termsofuse_t_12: 'Если вы обнаружили нарушение авторских прав в приложении Lampa - свяжитесь с разработчиками, используя раздел Контакты приложения. Однако, важно учесть, что приложение Lampa использует API от каталога themoviedb.org, который предоставляет открытый доступ к информации о фильмах и сериалах. Это означает, что информация, которая отображается в приложении Lampa, является общедоступной и не нарушает авторских прав.', - termsofuse_t_13: 'Если вы считаете, что в приложении Lampa все же есть контент, нарушающий авторские права - обратитесь к правообладателю этого контента с просьбой удалить его со страниц сайта themoviedb.org. В свою очередь, приложение Lampa может удалить контент при получении соответствующего уведомления о нарушении авторских прав.', - install_app_apk_text: 'Мы заметили, что для запуска Lampa на Android вы используете MediaStationX. Мы рекомендуем вам установить Lampa в виде APK-приложения. Вы можете скачать последнюю версию приложения здесь:', - ad: 'Реклама', - ad_disable: 'Подписавшись на CUB Premium, вы забудете о рекламе.', - ad_after: 'Реклама через', - ad_skip: 'Пропустить', - ad_continue_after: 'Просмотр начнется через', - discuss_rules_title: 'Следуйте правилам и уважайте других — создаём комфорт вместе!', - discuss_rules_rule_1: 'Не используйте слова, состоящие только из цифр.', - discuss_rules_rule_2: 'Пишите на одном языке, используйте слова из 5 и более букв.', - discuss_rules_rule_3: 'Используйте знаки препинания и завершайте предложения точками.', - discuss_rules_rule_4: 'Избегайте непонятных символов !?#%', - discuss_rules_rule_5: 'Пишите полные предложения, используйте предложение из 5 и более слов.', - discuss_rules_rule_6: 'Не используйте слишком длинные слова.', - discuss_rules_rule_7: 'Постарайтесь уместится в 300 символов.', - discuss_voited: 'Спасибо за вашу оценку! Ваш голос помогает улучшать контент.' - }; - - var en = { - lang_choice_title: 'Welcome', - lang_choice_subtitle: 'Choose your language', - more: 'More', - show_more: 'Show more', - more_results: 'Show more results', - loading: 'Loading', - nofind_movie: 'The movie could not be found.', - noname: 'Untitled', - nochoice: 'Not chosen', - cancel: 'Cancel', - confirm: 'I confirm', - sure: 'Are you sure?', - nodata: 'No data', - back: 'Back', - ready: 'Ready', - close_app_modal: 'Are you sure you want to leave the app?', - connected_seeds: 'connected', - search: 'Search', - search_input: 'Enter text', - search_empty: 'Search history is empty.', - search_delete: 'Left - delete', - search_start_typing: 'Start typing search text.', - search_searching: 'Search in progress...', - search_start: 'To start searching', - search_nofound: 'Nothing was found according to your request.', - full_genre: 'Genre', - full_production: 'Production', - full_date_of_release: 'date of release', - full_budget: 'Budget', - full_countries: 'Countries', - full_like: 'Like', - full_torrents: 'Torrents', - full_trailers: 'Trailers', - full_detail: 'In detail', - full_notext: 'No description.', - full_series_release: 'Series release', - full_next_episode: 'Next', - full_episode_days_left: 'Days left', - full_trailer_official: 'Official', - full_trailer_no_official: 'Informal', - full_season: 'Season', - full_episode: 'Episode', - full_directing: 'Directing', - full_writing: 'Writing', - full_keywords: 'Tags', - settings_cub_sync: 'Synchronization', - settings_cub_sync_descr: 'Synchronization with the CUB service: Synchronization of your bookmarks, browsing history, tags and timecodes. Website: www.cub.red', - settings_cub_account: 'Account', - settings_cub_logged_in_as: 'Logged in as', - settings_cub_profile: 'Profile', - settings_cub_sync_btn: 'Synchronize', - settings_cub_sync_btn_descr: 'Save local bookmarks to CUB account', - settings_cub_backup: 'Backup', - settings_cub_backup_descr: 'Save or load backup data', - settings_cub_logout: 'Sign out', - settings_cub_signin: 'Authorization', - settings_cub_not_specified: 'Not specified', - settings_cub_password: 'Password', - settings_cub_status: 'Status', - settings_cub_backup_import: 'Import', - settings_cub_backup_export: 'Export', - settings_cub_sync_filters: 'Filters sync', - settings_cub_sync_calendar: 'Calendar sync', - settings_cub_sync_quality: 'Quality sync', - settings_cub_sync_search: 'Search history sync', - settings_cub_sync_recomends: 'Recommendations sync', - settings_cub_sync_timecodes: 'Timecode Synchronization', - settings_input_links: 'Favorites', - settings_interface_type: 'Lite version', - settings_interface_size: 'Interface size', - settings_interface_background: 'Background', - settings_interface_background_use: 'Show background', - settings_interface_background_type: 'Background type', - settings_interface_performance: 'Performance', - settings_interface_animation: 'Animation', - settings_interface_animation_descr: 'Animation of cards and content', - settings_interface_attenuation: 'Attenuation', - settings_interface_attenuation_descr: 'Smooth fading of cards from below and from above', - settings_interface_scroll: 'Scroll Type', - settings_interface_view_card: 'Card view type', - settings_interface_view_card_descr: 'As you scroll the feed, the cards will load gradually or load all', - settings_interface_lang: 'Interface language', - settings_interface_lang_reload: 'You need to restart the application, click "OK" to restart.', - settings_main_account: 'Account', - settings_main_interface: 'Interface', - settings_main_player: 'Player', - settings_main_parser: 'Parser', - settings_main_torrserver: 'TorrServer', - settings_main_plugins: 'Extensions', - settings_main_rest: 'Other', - settings_rest_start: 'Start page', - settings_rest_start_descr: 'Which page to start at startup', - settings_rest_source: 'Source', - settings_rest_source_use: 'Main source', - settings_rest_source_descr: 'Where to get information about films', - settings_rest_tmdb_lang: 'What language to display data from TMDB', - settings_rest_tmdb_prox: 'Proxy TMDB', - settings_rest_tmdb_prox_auto: 'Enable proxy automatically', - settings_rest_tmdb_posters: 'Resolution of TMDB posters', - settings_rest_screensaver: 'Screensaver', - settings_rest_screensaver_use: 'Show splash screen when idle', - settings_rest_screensaver_type: 'Screen saver type', - settings_rest_helper: 'Hints', - settings_rest_helper_use: 'Show hints', - settings_rest_helper_reset: 'Show hints again', - settings_rest_pages: 'How many pages to keep in memory', - settings_rest_pages_descr: 'Keeps pages in the state you left them in', - settings_rest_time: 'Shift time', - settings_rest_navigation: 'Navigation type', - settings_rest_keyboard: 'Keyboard type', - settings_rest_device: 'Device name', - settings_rest_device_placeholder: 'For example: My Lamp', - settings_rest_cache: 'Clear cache', - settings_rest_cache_descr: 'All settings and data will be cleared', - settings_rest_tmdb_example: 'For example:', - settings_rest_tmdb_api_descr: 'To get data', - settings_rest_tmdb_image_descr: 'To get images', - settings_rest_card_quality: 'Quality marks', - settings_rest_card_quality_descr: 'Display quality marks on cards', - settings_rest_card_episodes: 'Episode marks', - settings_rest_card_episodes_descr: 'Display episode markers on cards', - settings_parser_use: 'Use parser', - settings_parser_use_descr: 'Hereby, you agree to accept all responsibility for the use of public links to view torrent and online content.', - settings_parser_type: 'Parser type for torrents', - settings_parser_jackett_placeholder: 'For example: 192.168.x', - settings_parser_jackett_link: 'Link', - settings_parser_jackett_link_descr: 'Provide a link to the Jackett script', - settings_parser_jackett_key_placeholder: 'For example: sa0sk83d..', - settings_parser_jackett_key: 'Api key', - settings_parser_jackett_key_descr: 'Located in Jackett', - settings_parser_torlook_type: 'TorLook site parsing method', - settings_parser_scraperapi_placeholder: 'For example: scraperapi.com', - settings_parser_scraperapi_link: 'Link to site parser', - settings_parser_scraperapi_descr: 'Register on the site scraperapi.com, enter the link api.scraperapi.com?api_key=...&url={q}
    W41.torlook.info will be delivered to {q}', - settings_parser_search: 'Search', - settings_parser_search_descr: 'What language to search in?', - settings_parser_in_search: 'Parser in search', - settings_parser_in_search_descr: 'Show search results?', - settings_parser_timeout_title: 'Parser timeout', - settings_parser_timeout_descr: 'Time in seconds to wait for a response from the server', - settings_player_type: 'Player type', - settings_player_type_descr: 'Which player to play', - settings_player_iptv_type: 'Player type for IPTV', - settings_player_iptv_type_descr: 'Which player to play IPTV channels', - settings_player_reset: 'Reset default player', - settings_player_reset_descr: 'Resets the selected Android player in the application', - settings_player_path: 'Path to the player', - settings_player_path_descr: 'Specify the path to the player .exe', - settings_player_normalization: 'Sound normalization', - settings_player_normalization_descr: 'Normalizes sound to one level, lowers loud sounds and boosts quiet ones.', - settings_player_next_episode: 'Next episode', - settings_player_next_episode_descr: 'Automatically switch to the next series after the end of the current one', - settings_player_timecode: 'Timecode', - settings_player_timecode_descr: 'Continue from last viewed location', - settings_player_scale: 'Scaling Method', - settings_player_scale_descr: 'How to calculate video scaling', - settings_player_subs: 'Subtitles', - settings_player_subs_use: 'Turn on', - settings_player_subs_use_descr: 'Always turn on subtitles after starting a video', - settings_player_subs_size: 'The size', - settings_player_subs_size_descr: 'Screen size of subtitles', - settings_player_subs_stroke_use: 'Use edging', - settings_player_subs_stroke_use_descr: 'Subtitles will be outlined in black for better readability', - settings_player_subs_backdrop_use: 'Use an underlay', - settings_player_subs_backdrop_use_descr: 'Subtitles will be displayed on a translucent backing to improve readability', - settings_player_quality: 'Default video quality', - settings_player_quality_descr: 'Preferred video quality for viewing', - settings_player_hls_title: 'Processing the .m3u8 stream', - settings_player_hls_descr: 'Do not touch this parameter if you do not know why it is.', - settings_plugins_notice: 'To apply the plugin, you need to restart the application', - settings_plugins_add: 'Add Plugin', - settings_plugins_add_descr: 'To delete an added plugin, hold or double-click the (OK) key on it', - settings_plugins_install: 'Install Plugin', - settings_plugins_install_descr: 'Install a plugin from the list of available', - settings_server_link: 'Use link', - settings_server_links: 'Links', - settings_server_placeholder: 'For example: 192.168.X', - settings_server_link_one: 'Main Link', - settings_server_link_one_descr: 'Specify the main link to the TorrServer script', - settings_server_link_two: 'Additional link', - settings_server_link_two_descr: 'Provide an additional link to the TorrServer script', - settings_server_additionally: 'Additionally', - settings_server_client: 'Embedded client', - settings_server_client_descr: 'Use the built-in TorrServer JS client, otherwise the system one starts.', - settings_server_base: 'Save to database', - settings_server_base_descr: 'The torrent will be added to the TorrServer database', - settings_server_preload: 'Use prefetch buffer', - settings_server_preload_descr: 'Wait for TorrServer\'s preload buffer to fill before playing', - settings_server_auth: 'Authorization', - settings_server_password_use: 'Password login', - settings_server_login: 'Login', - settings_server_password: 'Password', - settings_server_not_specified: 'Not specified', - torent_nohash_reasons: 'The reasons', - torent_nohash_reason_one: 'TorServer was unable to download the torrent file', - torent_nohash_reason_two: 'Reply from TorServer', - torent_nohash_reason_three: 'Link', - torent_nohash_do: 'What to do?', - torent_nohash_do_one: 'Check if you configured Jackett correctly', - torent_nohash_do_two: 'Private sources may not provide a link to the file', - torent_nohash_do_three: 'Make sure Jackett can download the file too', - torent_nohash_do_four: 'Write to our telegram group: @lampa_group', - torent_nohash_do_five: 'Specify which movie, which distribution and, if possible, a photo of this distribution', - torrent_error_text: 'Failed to connect to TorrServer. Let\'s quickly go through the list of possible problems and check everything.', - torrent_error_step_1: 'Is TorrServer running', - torrent_error_step_2: 'Dynamic IP', - torrent_error_step_3: 'Protocol and Port', - torrent_error_step_4: 'Antivirus blocking', - torrent_error_step_5: 'Check for availability', - torrent_error_step_6: 'Still doesn\'t work', - torrent_error_info_1: 'Make sure you have launched TorrServer on the device where it is installed.', - torrent_error_info_2: 'A common mistake, the IP address of the device with TorrServer has changed. Make sure that the IP address you entered - {ip} - matches the address of the device on which TorrServer is installed.', - torrent_error_info_3: 'To connect to TorrServer, you must specify the protocol http:// at the beginning and port :8090 at the end of the address. Make sure there is a port after the IP address, your current address is {ip}', - torrent_error_info_4: 'Frequent occurrence, antivirus or firewall can block access by IP address, try disabling antivirus and firewall.', - torrent_error_info_5: 'On any other device on the same network, open the {ip} address in a browser and check if the TorrServer web interface is available.', - torrent_error_info_6: 'If, after all the checks, a connection error still occurs, try restarting TorrServer and the Internet adapter.', - torrent_error_info_7: 'If the problem persists, write to the Telegram group @lampa_group with the text (Lampa does not connect to TorrServer after all checks, the current address is {ip})', - torrent_error_start: 'Start verification', - torrent_error_nomatrix: 'Failed to verify Matrix version', - torrent_error_made: 'Performed', - torrent_error_from: 'from', - torrent_error_next: 'Further', - torrent_error_complite: 'To complete', - torrent_error_connect: 'Connection error', - torrent_install_need: 'Requires TorrServer', - torrent_install_text: 'TorrServer is an application that allows you to view content from torrent files online.

    More detailed information on installation can be found in the Telegram groups below.', - torrent_install_contact: 'Telegram groups', - torrent_item_bitrate: 'Bitrate', - torrent_item_seeds: 'Seeds', - torrent_item_grabs: 'Leechers', - torrent_item_mb: 'Mbps', - torrent_serial_episode: 'Series', - torrent_serial_season: 'Season', - torrent_serial_date: 'Exit', - torrent_get_magnet: 'Requesting a magnet link', - torrent_remove_title: 'Delete', - torrent_remove_descr: 'The torrent will be removed from your list', - torrent_parser_any_one: 'Any', - torrent_parser_any_two: 'Any', - torrent_parser_no_choice: 'Not chosen', - torrent_parser_yes: 'Yes', - torrent_parser_no: 'No', - torrent_parser_quality: 'Quality', - torrent_parser_subs: 'Subtitles', - torrent_parser_voice: 'Translation', - torrent_parser_tracker: 'tracker', - torrent_parser_year: 'Year', - torrent_parser_season: 'Season', - torrent_parser_sort_by_seeders: 'By distributors', - torrent_parser_sort_by_size: 'To size', - torrent_parser_sort_by_name: 'by name', - torrent_parser_sort_by_tracker: 'By source', - torrent_parser_sort_by_date: 'By date', - torrent_parser_sort_by_viewed: 'Viewed', - torrent_parser_voice_dubbing: 'Dubbing', - torrent_parser_voice_polyphonic: 'Polyphonic', - torrent_parser_voice_two: 'Two-voiced', - torrent_parser_voice_amateur: 'Amateur', - torrent_parser_reset: 'Reset filter', - torrent_parser_empty: 'Failed to get results', - torrent_parser_no_hash: 'Failed to get HASH', - torrent_parser_added_to_mytorrents: 'added to "My torrents"', - torrent_parser_add_to_mytorrents: 'Add to "My torrents"', - torrent_parser_label_title: 'Flag', - torrent_parser_label_descr: 'Flag a hand with a flag (viewed)', - torrent_parser_label_cancel_title: 'Uncheck', - torrent_parser_label_cancel_descr: 'Remove the mark from the distribution (viewed)', - torrent_parser_timeout: 'Timeout expired', - torrent_parser_nofiles: 'Failed to extract suitable files', - torrent_parser_set_link: 'Specify a link for parsing', - torrent_parser_request_error: 'Request error', - torrent_parser_magnet_error: 'Failed to get magnet link', - torrent_parser_no_responce: 'The parser is not responding to the request', - torrent_parser_torlook_fallback_search_notification: 'Jackett parser is not available or the connection settings are incorrect. Searching Torlook...', - about_text: 'The application is completely free and uses public links to get information about videos, new releases, popular movies, etc. All available information is used solely for educational purposes, the application does not use its own servers to distribute information.', - about_channel: 'Our channel', - about_group: 'Group', - about_version: 'Version', - about_donate: 'Donat', - title_watched: 'You watched', - title_settings: 'Settings', - title_collections: 'Collections', - title_company: 'Company', - title_actors: 'Actors', - title_actor: 'Actor', - title_actress: 'Actress', - title_person: 'Person', - title_persons: 'Persons', - title_comments: 'Comments', - title_torrents: 'Torrents', - title_trailers: 'Trailers', - title_watch: 'Watch', - title_error: 'Error', - title_links: 'Links', - title_choice: 'Choose', - title_main: 'Home', - title_book: 'Bookmarks', - title_like: 'Like', - title_wath: 'Later', - title_history: 'Browsing history', - title_mytorrents: 'My torrents', - title_last: 'Last', - title_action: 'Action', - title_producer: 'Producer', - title_collection: 'Collection', - title_recomendations: 'Recommendations', - title_similar: 'Similar', - title_about: 'About the application', - title_timetable: 'Schedule', - title_relises: 'Digital releases', - title_catalog: 'Catalog', - title_category: 'Category', - title_parser: 'Parser', - title_type: 'Type of', - title_rating: 'Rating', - title_country: 'Country', - title_year: 'Year', - title_genre: 'Genre', - title_filter: 'Filter', - title_notice: 'Notifications', - title_files: 'Files', - title_now_watch: 'Watching now', - title_latest: 'Last addition', - title_continue: 'Continue browsing', - title_recomend_watch: 'We recommend to see', - title_new_episodes: 'New episodes', - title_popular: 'Popular', - title_popular_movie: 'Popular films', - title_popular_tv: 'Popular TV shows', - title_new_this_year: 'New this year', - title_hight_voite: 'Highly rated', - title_new: 'New', - title_trend_day: 'Today in trend', - title_trend_week: 'Trending for the week', - title_upcoming: 'Watch in cinemas', - title_top_movie: 'Top movies', - title_top_tv: 'Top series', - title_tv_today: 'On air today', - title_this_week: 'This week', - title_in_top: 'Top', - title_out: 'Exit', - title_out_confirm: 'Yes, get out', - title_continue_two: 'Proceed', - title_choice_language: 'Choose a language', - title_subscribe: 'Subscribe', - title_subscribes: 'Subscriptions', - title_unsubscribe: 'Unsubscribe', - title_language: 'Original language', - subscribe_success: 'You have successfully subscribed', - subscribe_error: 'An error occurred while subscribing, please try again later', - subscribe_noinfo: 'Failed to retrieve information, please try again later', - company_headquarters: 'Headquarters', - company_homepage: 'Website', - company_country: 'Country', - country_ad: 'Andorra', - country_ae: 'UAE', - country_af: 'Afghanistan', - country_al: 'Albania', - country_am: 'Armenia', - country_ao: 'Angola', - country_ar: 'Argentina', - country_at: 'Austria', - country_au: 'Australia', - country_aw: 'Aruba', - country_az: 'Azerbaijan', - country_bа: 'Bosnia & Herzegovina', - country_bd: 'Bangladesh', - country_be: 'Belgium', - country_bg: 'Bulgaria', - country_bh: 'Bahrain', - country_bi: 'Burundi', - country_bj: 'Benin', - country_bo: 'Bolivia', - country_br: 'Brazil', - country_bs: 'Bahamas', - country_bt: 'Bhutan', - country_bw: 'Botswana', - country_by: 'Belarus', - country_ca: 'Canada', - country_ch: 'Switzerland', - country_cl: 'Chile', - country_cm: 'Cameroon', - country_cn: 'China', - country_co: 'Colombia', - country_cr: 'Costa Rica', - country_cu: 'Cuba', - country_cv: 'Cape Verde', - country_cy: 'Cyprus', - country_cz: 'Czech Republic', - country_de: 'Germany', - country_dj: 'Djibouti', - country_dk: 'Denmark', - country_do: 'Dominican Republic', - country_dz: 'Algeria', - country_ec: 'Ecuador', - country_ee: 'Estonia', - country_eg: 'Egypt', - country_es: 'Spain', - country_et: 'Ethiopia', - country_fi: 'Finland', - country_fo: 'Faroe Islands', - country_fr: 'France', - country_ga: 'Gabon', - country_gb: 'United Kingdom', - country_ge: 'Georgia', - country_gh: 'Ghana', - country_gl: 'Greenland', - country_gp: 'Guadeloupe', - country_gr: 'Greece', - country_gt: 'Guatemala', - country_hk: 'Hong Kong', - country_hr: 'Croatia', - country_ht: 'Haiti', - country_hu: 'Hungary', - country_id: 'Indonesia', - country_ie: 'Ireland', - country_il: 'Israel', - country_in: 'India', - country_iq: 'Iraq', - country_ir: 'Iran', - country_is: 'Iceland', - country_it: 'Italy', - country_jm: 'Jamaica', - country_jo: 'Jordan', - country_jp: 'Japan', - country_ke: 'Kenya', - country_kg: 'Kyrgyzstan', - country_kh: 'Cambodia', - country_kp: 'North Korea', - country_kr: 'South Korea', - country_kz: 'Kazakhstan', - country_kw: 'Kuwait', - country_la: 'Laos', - country_lb: 'Lebanon', - country_li: 'Liechtenstein', - country_lk: 'Sri Lanka', - country_lr: 'Liberia', - country_lt: 'Lithuania', - country_lu: 'Luxembourg', - country_lv: 'Latvia', - country_ly: 'Libya', - country_ma: 'Morocco', - country_mc: 'Monaco', - country_md: 'Moldova', - country_me: 'Montenegro', - country_mk: 'Macedonia', - country_mm: 'Myanmar', - country_mn: 'Mongolia', - country_mo: 'Macau', - country_mt: 'Malta', - country_mu: 'Mauritius', - country_mv: 'Maldives', - country_mw: 'Malawi', - country_mx: 'Mexico', - country_my: 'Malaysia', - country_mz: 'Mozambique', - country_na: 'Namibia', - country_ne: 'Niger', - country_ng: 'Nigeria', - country_ni: 'Nicaragua', - country_nl: 'Netherlands', - country_no: 'Norway', - country_np: 'Nepal', - country_nz: 'New Zealand', - country_om: 'Oman', - country_pa: 'Panama', - country_pe: 'Peru', - country_pg: 'Papua New Guinea', - country_ph: 'Philippines', - country_pk: 'Pakistan', - country_pl: 'Poland', - country_pr: 'Puerto Rico', - country_ps: 'Palestinian Territory', - country_pt: 'Portugal', - country_py: 'Paraguay', - country_qa: 'Qatar', - country_ro: 'Romania', - country_rs: 'Serbia', - country_ru: 'Russia', - country_rw: 'Rwanda', - country_sa: 'Saudi Arabia', - country_sd: 'Sudan', - country_se: 'Sweden', - country_sg: 'Singapore', - country_si: 'Slovenia', - country_sk: 'Slovakia', - country_sn: 'Senegal', - country_su: 'USSR', - country_sv: 'El Salvador', - country_sy: 'Syria', - country_th: 'Thailand', - country_tj: 'Tajikistan', - country_tm: 'Turkmenistan', - country_tn: 'Tunisia', - country_tr: 'Turkey', - country_tw: 'Taiwan', - country_tz: 'Tanzania', - country_ua: 'Ukraine', - country_ug: 'Uganda', - country_us: 'USA', - country_uy: 'Uruguay', - country_uz: 'Uzbekistan', - country_ve: 'Venezuela', - country_vn: 'Viet Nam', - country_xk: 'Kosovo', - country_ws: 'Samoa', - country_ye: 'Yemen', - country_yu: 'Yugoslavia', - country_za: 'South Africa', - country_zm: 'Zambia', - country_zw: 'Zimbabwe', - filter_clarify: 'Clarify', - filter_clarify_two: 'Refine Search', - filter_set_name: 'Specify title', - filter_sorted: 'Sort', - filter_filtred: 'Filter', - filter_any: 'Any', - filter_combinations: 'Combinations', - filter_alt_names: 'Other names', - filter_rating_from: 'from', - filter_rating_to: 'to', - filter_lang_af: 'Afrikaans', - filter_lang_ar: 'Arabic', - filter_lang_az: 'Azerbaijani', - filter_lang_ba: 'Bashkir', - filter_lang_be: 'Belarusian', - filter_lang_bg: 'Bulgarian', - filter_lang_bn: 'Bengali', - filter_lang_bs: 'Bosnian', - filter_lang_ca: 'Catalan', - filter_lang_ce: 'Chechen', - filter_lang_cs: 'Czech', - filter_lang_da: 'Danish', - filter_lang_de: 'German', - filter_lang_el: 'Greek', - filter_lang_en: 'English', - filter_lang_es: 'Spanish', - filter_lang_et: 'Estonian', - filter_lang_fa: 'Persian', - filter_lang_fi: 'Finnish', - filter_lang_fr: 'French', - filter_lang_ga: 'Irish', - filter_lang_gl: 'Galician', - filter_lang_gn: 'Guarani', - filter_lang_he: 'Hebrew', - filter_lang_hi: 'Hindi', - filter_lang_hr: 'Croatian', - filter_lang_hu: 'Hungarian', - filter_lang_hy: 'Armenian', - filter_lang_id: 'Indonesian', - filter_lang_is: 'Icelandic', - filter_lang_it: 'Italian', - filter_lang_ja: 'Japanese', - filter_lang_ka: 'Georgian', - filter_lang_kk: 'Kazakh', - filter_lang_ko: 'Korean', - filter_lang_ks: 'Kashmiri', - filter_lang_ku: 'Kurdish', - filter_lang_ky: 'Kirghiz', - filter_lang_lt: 'Lithuanian', - filter_lang_lv: 'Latvian', - filter_lang_mi: 'Maori', - filter_lang_mk: 'Macedonian', - filter_lang_mn: 'Mongolian', - filter_lang_mo: 'Moldavian', - filter_lang_mt: 'Maltese', - filter_lang_ne: 'Nepali', - filter_lang_nl: 'Dutch (Nederlands)', - filter_lang_no: 'Norwegian', - filter_lang_pa: 'Punjabi', - filter_lang_pl: 'Polish', - filter_lang_ps: 'Pushto', - filter_lang_pt: 'Portuguese', - filter_lang_ro: 'Romanian', - filter_lang_ru: 'Russian', - filter_lang_si: 'Sinhalese', - filter_lang_sk: 'Slovak', - filter_lang_sl: 'Slovenian', - filter_lang_sm: 'Samoan', - filter_lang_so: 'Somali', - filter_lang_sq: 'Albanian', - filter_lang_sr: 'Serbian', - filter_lang_sv: 'Swedish', - filter_lang_sw: 'Swahili', - filter_lang_ta: 'Tamil', - filter_lang_tg: 'Tajik', - filter_lang_th: 'Thai', - filter_lang_tk: 'Turkmen', - filter_lang_tr: 'Turkish', - filter_lang_tt: 'Tatar', - filter_lang_ur: 'Urdu', - filter_lang_uk: 'Ukrainian', - filter_lang_uz: 'Uzbek', - filter_lang_vi: 'Vietnamese', - filter_lang_yi: 'Yiddish', - filter_lang_zh: 'Chinese', - filter_genre_ac: 'Action', - filter_genre_ad: 'Adventures', - filter_genre_mv: 'Cartoon', - filter_genre_cm: 'Comedy', - filter_genre_cr: 'Crime', - filter_genre_dc: 'Documentary', - filter_genre_dr: 'Drama', - filter_genre_fm: 'Family', - filter_genre_fe: 'Fantasy', - filter_genre_hi: 'Story', - filter_genre_ho: 'Horror', - filter_genre_mu: 'Music', - filter_genre_de: 'Detective', - filter_genre_md: 'Melodrama', - filter_genre_fa: 'Fiction', - filter_genre_tv: 'TV film', - filter_genre_tr: 'Thriller', - filter_genre_mi: 'Military', - filter_genre_ve: 'Western', - filter_genre_aa: 'Action & Adventure', - filter_genre_ch: 'Children\'s', - filter_genre_nw: 'News', - filter_genre_rs: 'Reality show', - filter_genre_hf: 'Sci-Fi and Fantasy', - filter_genre_op: 'Soap opera', - filter_genre_tc: 'Talk show', - filter_genre_mp: 'War and Politics', - empty_title: 'Empty', - empty_text: 'Nothing found for your filter, please refine your filter.', - empty_title_two: 'It\'s empty here', - empty_text_two: 'The list is currently empty.', - menu_main: 'Home', - menu_movies: 'Movies', - menu_tv: 'Series', - menu_catalog: 'Catalog', - menu_filter: 'Filter', - menu_collections: 'Collections', - menu_relises: 'Releases', - menu_anime: 'Anime', - menu_bookmark: 'Bookmarks', - menu_like: 'Like', - menu_time: 'Later', - menu_history: 'History', - menu_timeline: 'Schedule', - menu_torrents: 'Torrents', - menu_settings: 'Settings', - menu_about: 'Information', - menu_console: 'Console', - menu_multmovie: 'Cartoons', - menu_multtv: 'Animated series', - plugins_catalog_work: 'Working plugins', - plugins_catalog_work_descr: 'Plugins that work exactly in the lamp.', - plugins_catalog_popular: 'Popular plugins among users', - plugins_catalog_popular_descr: 'Installation from unknown sources may cause the application to work incorrectly.', - plugins_online: 'View online', - plugins_check_fail: 'Failed to test the functionality of the plugin. However, this does not mean that the plugin does not work. Reload the application to see if the plugin is loading.', - plugins_need_reload: 'To apply the plugin, you need to restart the application', - plugins_install: 'Install', - plugins_install_ready: 'This plugin is already installed.', - plugins_installed: 'Installations', - plugins_load_from: 'Loaded from CUB', - plugins_ok_for_check: 'Click (OK) to test the plugin', - plugins_no_loaded: 'When loading the application, some plugins could not be loaded', - time_viewed: 'Viewed', - time_from: 'from', - time_reset: 'Reset timecode', - settings_clear_cache: 'Cache and data cleared', - settings_user_links: 'Custom Link', - settings_for_local: 'For local TorrServer', - settings_add: 'Add', - settings_remove: 'Delete', - settings_this_value: 'present value', - settings_added: 'Added', - settings_removed: 'Removed', - settings_param_player_inner: 'Lampa', - settings_param_player_outside: 'External', - settings_param_yes: 'Yes', - settings_param_no: 'No', - settings_param_interface_size_small: 'Smaller', - settings_param_interface_size_normal: 'Normal', - settings_param_interface_size_bigger: 'More', - settings_param_poster_quality_low: 'Low', - settings_param_poster_quality_average: 'Average', - settings_param_poster_quality_high: 'High', - settings_param_parse_directly: 'Directly', - settings_param_parse_api: 'Through the website API', - settings_param_background_complex: 'Complex', - settings_param_background_simple: 'Simple', - settings_param_background_image: 'Picture', - settings_param_link_use_one: 'Main', - settings_param_link_use_two: 'Additional', - settings_param_subtitles_size_small: 'small', - settings_param_subtitles_size_normal: 'Ordinary', - settings_param_subtitles_size_bigger: 'Large', - settings_param_screensaver_nature: 'Nature', - settings_param_torrent_lang_orig: 'Original', - settings_param_torrent_lang_ru: 'Russian', - settings_param_player_timecode_again: 'Start over', - settings_param_player_timecode_continue: 'Proceed', - settings_param_player_timecode_ask: 'To ask', - settings_param_player_scale_method: 'Calculate', - settings_param_player_hls_app: 'Systemic', - settings_param_player_hls_js: 'Program', - settings_param_card_view_load: 'Upload', - settings_param_card_view_all: 'Show all', - settings_param_navigation_remote: 'Remote controller', - settings_param_navigation_mouse: 'Remote control with mouse', - settings_param_keyboard_lampa: 'Lampa', - settings_param_keyboard_system: 'Systemic', - helper_keyboard: 'After entering the value, press the "Back" button to save', - helper_torrents: 'Hold down the (OK) key to bring up the context menu', - helper_cleared: 'Success, tooltips will be shown again.', - helper_torrents_view: 'Hold down the (OK) key to reset the timecode and display the menu', - fav_sync_title: 'Bookmark sync', - fav_sync_text: 'Your favorite bookmarks with you. Connect synchronization and view on any device.

    To do this, register on the site www.cub.red, create a profile and log in to the application.', - fav_sync_site: 'Website', - fav_remove_title: 'Remove from history', - fav_remove_descr: 'Delete selected card', - fav_clear_title: 'Clear the history', - fav_clear_descr: 'Delete all cards from history', - fav_clear_label_title: 'Clear labels', - fav_clear_label_descr: 'Clear View Tags', - fav_clear_time_title: 'Clear Timecodes', - fav_clear_time_descr: 'Clear all timecodes', - fav_label_cleared: 'Marks cleared', - fav_time_cleared: 'Timecodes cleared', - timetable_empty: 'This section will display the release dates of new episodes.', - player_quality: 'Quality', - player_tracks: 'Audio tracks', - player_disabled: 'Disabled', - player_unknown: 'Unknown', - player_subs: 'Subtitles', - player_size_default_title: 'Default', - player_size_default_descr: 'Default video size', - player_size_cover_title: 'Expand', - player_size_cover_descr: 'Expands video to full screen', - player_size_fill_title: 'Fill', - player_size_fill_descr: 'Fit video to full screen', - player_size_s115_title: 'Zoom 115%', - player_size_s115_descr: 'Enlarge video by 115%', - player_size_s130_title: 'Zoom 130%', - player_size_s130_descr: 'Enlarge video by 130%', - player_size_v115_title: 'Vertical 115%', - player_size_v115_descr: 'Enlarge video by 115%', - player_size_v130_title: 'Vertical 130%', - player_size_v130_descr: 'Enlarge video by 130%', - player_video_size: 'Video size', - player_playlist: 'Playlist', - player_error_one: 'Failed to decode video', - player_error_two: 'Video not found or corrupted', - player_start_from: 'Continue browsing from', - player_not_found: 'Player not found', - player_lauch: 'Launch player', - player_speed_default_title: 'Plain', - player_speed_two_descr: 'Play without sound', - player_video_speed: 'Playback speed', - player_share_title: 'Share', - player_share_descr: 'Play this video on another device', - player_normalization_power_title: 'Normalization power', - player_normalization_smooth_title: 'Normalization speed', - player_normalization_step_low: 'Low', - player_normalization_step_medium: 'Average', - player_normalization_step_hight: 'High', - player_youtube_no_played: 'Sorry, this video is not available in your region and may have been blocked or removed.', - player_youtube_start_play: 'To start playing the video, click the "Play" button.', - broadcast_open: 'Open card on another device', - broadcast_play: 'Choose the device to watch on', - card_new_episode: 'New series', - card_book_remove: 'Remove from bookmarks', - card_book_add: 'To bookmarks', - card_book_descr: 'Look in the menu (Bookmarks)', - card_like_remove: 'Remove from favorites', - card_like_add: 'Like', - card_like_descr: 'Look at the menu (Like)', - card_wath_remove: 'Remove from expected', - card_wath_add: 'Watch Later', - card_wath_descr: 'See the menu (Later)', - card_history_remove: 'Remove from history', - card_history_add: 'Into history', - card_history_descr: 'Look in the menu (History)', - keyboard_listen: 'Speak, I\'m listening...', - keyboard_nomic: 'No microphone access', - notice_new_quality: 'New quality available', - notice_quality: 'Quality', - notice_new_episode: 'New series', - notice_none: 'You don\'t have any notifications yet, register at www.cub.red to follow new episodes and releases.', - notice_in_quality: 'As', - notice_none_account: 'You don\'t have any notifications yet, bookmark the series and wait for notifications of new episodes.', - notice_none_system: 'You currently have no notifications. We will be sure to notify you when new notifications become available.', - copy_link: 'Copy video link', - copy_secuses: 'Link copied to clipboard', - copy_error: 'Error copying link', - account_sync_to_profile: 'All bookmarks will be moved to the profile', - account_sync_secuses: 'All bookmarks have been successfully transferred', - account_profiles: 'Profiles', - account_profiles_empty: 'Failed to get list of profiles', - account_authorized: 'Authorized', - account_logged_in: 'You are logged in', - account_login_failed: 'Login failed', - account_login_wait: 'Waiting for login', - account_profile_main: 'General', - account_export_secuses: 'Export completed successfully', - account_export_fail: 'Export error', - account_import_secuses: 'Import completed successfully', - account_import_fail: 'Import error', - account_imported: 'imported', - account_reload_after: 'reboot after 5 sec.', - account_create: 'Discover more opportunities with a CUB account. Register at and get access to sync your bookmarks, timecodes and other CUB account features.', - account_premium: 'Discover more features with a CUB Premium account. Increasing limits and access to additional features of the service.', - account_premium_more: 'Learn more about CUB Premium', - account_limited: 'You have reached the maximum limit. Increase the limit with a CUB Premium account. Learn more at ', - account_code_enter: 'Enter a six-digit code', - account_code_error: 'Perhaps you entered an incorrect or outdated code', - account_code_wrong: 'Perhaps you entered an incorrect format', - account_code_where: 'Go to the website and enter the code provided there.', - account_code_input: 'Enter code', - settings_cub_signin_button: 'Sign in', - network_noconnect: 'No network connection', - network_404: 'The requested page was not found. [404]', - network_401: 'Authorization failed', - network_500: 'Internal Server Error. [500]', - network_parsererror: 'The requested JSON parsing failed.', - network_timeout: 'Request timed out.', - network_abort: 'The request has been aborted.', - network_error: 'Unknown error', - size_zero: '0 Byte', - size_byte: 'Byte', - size_kb: 'KB', - size_mb: 'MB', - size_gb: 'GB', - size_tb: 'TB', - size_pp: 'PB', - speed_bit: 'bps', - speed_kb: 'Kbps', - speed_mb: 'Mbps', - speed_gb: 'Gbps', - speed_tb: 'Tbps', - speed_pp: 'Pbps', - month_1: 'January', - month_2: 'February', - month_3: 'March', - month_4: 'April', - month_5: 'May', - month_6: 'June', - month_7: 'July', - month_8: 'August', - month_9: 'September', - month_10: 'October', - month_11: 'November', - month_12: 'December', - day_1: 'Monday', - day_2: 'Tuesday', - day_3: 'Wednesday', - day_4: 'Thursday', - day_5: 'Friday', - day_6: 'Saturday', - day_7: 'Sunday', - month_1_e: 'January', - month_2_e: 'February', - month_3_e: 'March', - month_4_e: 'April', - month_5_e: 'May', - month_6_e: 'June', - month_7_e: 'July', - month_8_e: 'August', - month_9_e: 'September', - month_10_e: 'October', - month_11_e: 'November', - month_12_e: 'December', - week_1: 'Mon', - week_2: 'Tue', - week_3: 'Wed', - week_4: 'Thu', - week_5: 'Fri', - week_6: 'Sat', - week_7: 'Sun', - extensions_enable: 'Turn on', - extensions_disable: 'Disable', - extensions_check: 'Check status', - extensions_install: 'Install', - extensions_info: 'Information', - extensions_edit: 'Edit', - extensions_change_name: 'Change name', - extensions_change_link: 'Change link', - extensions_remove: 'Delete', - extensions_set_name: 'Enter plugin name', - extensions_set_url: 'Enter plugin url', - extensions_ready: 'This plugin is already installed', - extensions_no_info: 'Without information', - extensions_no_name: 'Untitled', - extensions_worked: 'Worker', - extensions_no_plugin: 'Plugin not verified', - extensions_add: 'Add Plugin', - extensions_from_memory: 'Installed in memory', - extensions_from_cub: 'Installed from CUB', - extensions_from_popular: 'Popular plugins', - extensions_from_lib: 'Plugin Library', - extensions_from_connected: 'Connected plugins', - settings_webos_launcher: 'Application launch', - settings_webos_launcher_add_device: 'Install as starter app', - settings_webos_launcher_remove_device: 'Remove from starter spplications', - player_normalization: 'Normalization', - change_source_on_cub: 'Change source to CUB', - settings_param_jackett_interview_all: 'All', - settings_param_jackett_interview_healthy: 'Available only', - settings_parser_jackett_interview: 'Poll trackers', - title_ongoing: 'Ongoings', - title_pgrating: 'Age limit', - settings_interface_card_interfice: 'Card interface', - settings_interface_card_poster: 'Show poster', - title_card: 'Card', - settings_param_card_interface_old: 'Old', - settings_param_card_interface_new: 'New', - title_seasons: 'Seasons', - title_episodes: 'Episodes', - title_rewiews: 'Reviews', - settings_interface_glass: 'Glass', - settings_interface_glass_descr: 'Show interface in glassy style', - settings_interface_black_style: 'Black style', - plugins_remove: 'Remove plugins', - plugins_add_success: 'Plugin connected successfully', - settings_reset: 'Reset', - title_channel: 'Channel', - input_detection_touch: 'Want to switch to touch control?', - input_detection_mouse: 'Want to switch to mouse control?', - input_detection_remote: 'Want to switch to remote control?', - settings_interface_hide_outside_the_screen: 'Hide cards off screen', - settings_interface_hide_outside_the_screen_descr: 'This will speed up UI rendering and improve performance', - https_text: 'You are using the HTTPS protocol, in this protocol the lamp does not work correctly. For the correct operation of the lamp, use the address with the HTTP protocol', - extensions_hpu_best: 'Popular', - extensions_hpu_recomend: 'Recommended', - extensions_hpu_theme: 'Themes', - extensions_hpu_screensaver: 'Screensaver', - extensions_hpu_video: 'Video', - extensions_hpu_control: 'Control', - extensions_hpu_other: 'Miscellaneous', - extensions_hpu_: 'Other', - title_author: 'Author', - title_buffer: 'Buffer', - settings_rest_screensaver_time: 'After how many minutes to start the screensaver', - time_h: 'h.', - time_m: 'm.', - time_s: 's.', - settings_param_glass_easy: 'Transparent', - settings_param_glass_medium: 'Semitransparent', - settings_param_glass_blacked: 'Blacked out', - settings_interface_glass_opacity: 'Glass transparency', - torrent_error_check_no_auth: 'The server responded to the request, but the authorization failed', - settings_interface_card_cover: 'Show cover', - title_upcoming_episodes: 'Upcoming episode releases', - settings_rest_cache_images: 'Image cache', - settings_rest_cache_images_descr: 'Cache posters and backgrounds to local storage', - settings_player_rewind_title: 'Rewind', - settings_player_rewind_descr: 'Rewind interval in seconds', - settings_interface_card_reactions: 'Show reactions', - title_look: 'Looking', - title_scheduled: 'Scheduled', - title_viewed: 'Viewed', - title_thrown: 'Thrown', - title_reactions: 'Reactions', - reactions_none: 'No reactions', - reactions_fire: 'Great', - reactions_nice: 'Nice', - reactions_think: 'Interesting', - reactions_bore: 'Boring', - reactions_shit: 'Bad', - reactions_ready: 'You have already left a reaction', - settings_player_launch_trailers: 'Trailer Player', - title_continued: 'To be continued', - title_language_short: 'Language', - speedtest_connect: 'connection', - speedtest_test: 'testing', - speedtest_ready: 'ready', - speedtest_button: 'Test Speed', - termsofuse_t_01: 'Terms of Use', - termsofuse_t_02: 'Lampa is a convenient tool for exploring the latest news in the film industry, including movies, TV shows, cartoons, and other information. To obtain information about movies, an open-source website, themoviedb.org, is used.', - termsofuse_t_03: 'Content', - termsofuse_t_04: 'Lampa utilizes the API (application programming interface) from the themoviedb.org catalog to retrieve information about movies and TV shows, as well as to view associated media files such as posters, trailers, and more.', - termsofuse_t_05: 'The themoviedb.org API allows the Lampa application to access a database of movies and TV shows, providing the ability to search and view media file information.', - termsofuse_t_06: 'The interaction between the Lampa application and themoviedb.org occurs through API requests that are sent from the Lampa application to the themoviedb.org servers to obtain information and media files. Themoviedb.org processes the requests and sends the requested data back to the Lampa application.', - termsofuse_t_07: 'Thus, thanks to the use of the themoviedb.org API, the Lampa application provides users with access to an extensive database of movies and TV shows, while complying with the terms of use and restrictions set by the rights holder.', - termsofuse_t_08: 'Extensions', - termsofuse_t_09: 'Extensions are a powerful tool provided for the Lampa application, allowing users to enhance its capabilities, add additional functionality, and modify content according to their needs.', - termsofuse_t_10: 'However, it should be noted that users install extensions at their own risk. All consequences arising from the use of extensions are the responsibility of the user. Users are advised to exercise caution when installing and using extensions, carefully evaluating their reliability and security.', - termsofuse_t_11: 'Copyright Infringements', - termsofuse_t_12: 'If you discover any copyright infringement in the Lampa application, you should contact the developers of the Lampa application. You can use the contacts provided in the Lampa application to do so. However, it is important to note that the Lampa application uses the API from the themoviedb.org catalog, which provides open access to information about movies and TV shows. This means that the information displayed in the Lampa application is publicly available and does not infringe on copyright.', - termsofuse_t_13: 'If you believe that the Lampa application still contains content that violates your copyright, you can contact the rights holder of that content and request its removal from the themoviedb.org website. In turn, the Lampa application can remove content upon receiving a proper copyright infringement notification.', - settings_rest_protocol_use: 'Secure connection', - settings_rest_protocol_descr: 'Use HTTPS protocol', - install_app_apk_text: 'We noticed that you are using MediaStationX to run Lampa on Android. We recommend that you install Lampa as an APK application. You can download the latest version of the application here:', - tv_status_returning_series: 'Returning series', - tv_status_planned: 'Planned', - tv_status_in_production: 'In Production', - tv_status_ended: 'Ended', - tv_status_canceled: 'Canceled', - tv_status_pilot: 'Pilot', - tv_status_released: 'Released', - tv_status_rumored: 'Rumored', - tv_status_post_production: 'Post Production', - title_last_year: 'Last year', - title_reset: 'Reboot', - back_to_card: 'Return to card', - premiere_author_recomend_1: 'Order pizza and get ready for some excitement.', - premiere_author_recomend_2: 'The party is just getting started.', - premiere_author_recomend_3: 'Get ready for some adrenaline.', - premiere_author_recomend_4: 'Ready for an unforgettable evening?', - premiere_author_recomend_5: 'I recommend watching it.', - premiere_title: 'Premiere', - settings_clear_cache_only: 'Cache Cleared', - settings_rest_cache_only: 'Only Cache', - settings_rest_cache_only_descr: 'Basic settings will be preserved', - settings_rest_cache_all: 'Cache and Data', - settings_rest_cache_all_descr: 'All settings and data will be cleared', - settings_rest_cache_calculate: 'How much memory is left', - title_left: 'Left', - account_export_fail_500: 'Unknown error', - account_export_fail_610: 'You have exceeded the limit for today', - account_export_fail_200: 'Database error, please try again later', - account_export_fail_600: 'Error, failed to upload the file', - account_export_fail_620: 'Error, file not transmitted', - title_parental_control: 'Parental Control', - settings_parental_control_param_time_always: 'Always', - settings_parental_control_param_time_once: 'Once', - settings_parental_control_param_time_10: 'In 10 minutes', - settings_parental_control_param_time_20: 'In 20 minutes', - settings_parental_control_param_time_30: 'In 30 minutes', - settings_parental_control_param_time_60: 'In 1 hour', - settings_parental_control_param_time_120: 'In 2 hours', - settings_parental_control_change_pin: 'Change PIN', - settings_parental_control_demand_title: 'When to Prompt', - settings_parental_control_demand_descr: 'After how much time to prompt for the PIN', - settings_parental_control_enabled: 'Enabled', - settings_parental_control_disabled: 'Disabled', - parental_control_input_new_code: 'Enter new PIN code', - parental_control_confirm_new_code: 'Confirm PIN code', - parental_control_no_match_code: 'PIN code does not match the previous code', - parental_control_input_code: 'Enter PIN code', - parental_control_input_error: 'You entered an incorrect PIN code', - title_worth_rewatch: 'Worth a rewatch', - ad_disable: 'By subscribing to CUB Premium, you will forget about advertising.', - ad_after: 'Advertising via', - ad: 'Advertising', - ad_skip: 'Skip', - ad_continue_after: 'Viewing will start in', - settings_parser_prowlarr_link_descr: 'Provide a link to the Prowlarr server', - settings_parser_prowlarr_key_descr: 'Located in the Prowlarr settings tab in the general category', - settings_player_torrent_type: 'Player type for torrents', - settings_player_torrent_type_descr: 'Which player to play torrents', - full_crew: 'More', - full_editing: 'Editing', - full_creator: 'Creator', - player_normalization_step_none: 'Zero', - settings_cub_backup_export_descr: 'Save settings to the cloud', - settings_cub_backup_import_descr: 'Restore settings from the cloud', - settings_interface_sound: 'System sounds', - settings_interface_sound_play: 'Transitions', - settings_interface_sound_level: 'Volume level', - settings_interface_advanced_animation: 'Advanced animation' - }; - - var langs = {}; - var keys = {}; - var lang_default = 'ru'; - Object.defineProperty(langs, 'ru', { - get: function get() { - return ru; - } - }); - Object.defineProperty(langs, 'en', { - get: function get() { - return en; - } - }); - - for (var code$1 in meta.languages) { - keys[code$1] = meta.languages[code$1].name; - if (!langs[code$1]) langs[code$1] = {}; - langs[code$1].lang_choice_title = meta.languages[code$1].lang_choice_title; - langs[code$1].lang_choice_subtitle = meta.languages[code$1].lang_choice_subtitle; - } - /** - * Перевести - * @param {string} name - * @param {string} custom_code - ru/en/uk... - * @returns - */ - - - function translate(name, custom_code) { - name = name + ''; - var code = custom_code || Storage.get('language', 'ru'); - if (!langs[code]) code = lang_default; - - if (name.indexOf('#{') >= 0) { - return name.replace(/#{([a-z_0-9-]+)}/g, function (e, s) { - return langs[code][s] || langs[lang_default][s] || s; - }); - } else { - return langs[code][name] || langs[lang_default][name] || name; - } - } - /** - * Добавить переводы - * @param {{key_name:{en:string,ru:string}}} data - */ - - - function add$1(data) { - for (var name in data) { - for (var _code in data[name]) { - if (langs[_code]) { - langs[_code][name] = data[name][_code]; - } - } - } - } - /** - * Добавить перевод для кода - * @param {string} code - * @param {{key1:string,key2:string}} data - */ - - - function AddTranslation(code, data) { - if (!langs[code]) langs[code] = {}; - - for (var name in data) { - langs[code][name] = data[name]; - } - } - /** - * Добавить коды - * @param {{code_name:string}} new_codes - */ - - - function addCodes(new_codes) { - for (var i in new_codes) { - keys[i] = new_codes[i]; - langs[i] = {}; - } - } - /** - * Получить список кодов - * @returns {{ru:string,en:string}} - */ - - - function codes() { - return Arrays.clone(keys); - } - - function selected$1(check_codes) { - return check_codes.indexOf(Storage.get('language', 'ru')) >= 0 ? true : false; - } - - var Lang = { - translate: translate, - add: add$1, - codes: codes, - addCodes: addCodes, - AddTranslation: AddTranslation, - selected: selected$1 - }; - - var data = {}; - data.type = { - title: '#{title_type}', - items: [{ - title: '#{menu_movies}', - selected: true, - cat: 'movie' - }, { - title: '#{menu_multmovie}', - cat: 'multmovie' - }, { - title: '#{menu_tv}', - cat: 'tv' - }, { - title: '#{menu_multtv}', - cat: 'multtv' - }, { - title: '#{menu_anime}', - cat: 'anime' - }] - }; - data.rating = { - title: '#{title_rating}', - items: [{ - title: '#{filter_any}' - }, { - title: '#{filter_rating_from} 8', - start: 8 - }, { - title: '#{filter_rating_from} 6', - start: 6 - }, { - title: '#{filter_rating_from} 4', - start: 4 - }, { - title: '#{filter_rating_from} 2', - start: 2 - }, { - title: '#{filter_rating_from} 1 #{filter_rating_to} 3', - voite: '1-3' - }, { - title: '#{filter_rating_from} 3 #{filter_rating_to} 6', - voite: '3-6' - }, { - title: '#{filter_rating_from} 6 #{filter_rating_to} 8', - voite: '6-8' - }, { - title: '#{filter_rating_from} 8 #{filter_rating_to} 9', - voite: '8-9' - }] - }; - data.pgrating = { - title: '#{title_pgrating}', - items: [{ - title: '#{filter_any}' - }] - }; - data.language = { - title: '#{title_language}', - items: [{ - title: '#{filter_lang_ru}', - code: 'ru' - }, { - title: '#{filter_lang_uk}', - code: 'uk' - }, { - title: '#{filter_lang_en}', - code: 'en' - }, { - title: '#{filter_lang_be}', - code: 'be' - }, { - title: '#{filter_lang_zh}', - code: 'zh|cn' - }, { - title: '#{filter_lang_ja}', - code: 'ja' - }, { - title: '#{filter_lang_ko}', - code: 'ko' - }, { - title: '#{filter_lang_af}', - code: 'af' - }, { - title: '#{filter_lang_sq}', - code: 'sq' - }, { - title: '#{filter_lang_ar}', - code: 'ar' - }, { - title: '#{filter_lang_az}', - code: 'az' - }, { - title: '#{filter_lang_hy}', - code: 'hy' - }, { - title: '#{filter_lang_ba}', - code: 'ba' - }, { - title: '#{filter_lang_bg}', - code: 'bg' - }, { - title: '#{filter_lang_bn}', - code: 'bn' - }, { - title: '#{filter_lang_bs}', - code: 'bs' - }, { - title: '#{filter_lang_ca}', - code: 'ca' - }, { - title: '#{filter_lang_ce}', - code: 'ce' - }, { - title: '#{filter_lang_cs}', - code: 'cs' - }, { - title: '#{filter_lang_da}', - code: 'da' - }, { - title: '#{filter_lang_ka}', - code: 'ka' - }, { - title: '#{filter_lang_de}', - code: 'de' - }, { - title: '#{filter_lang_el}', - code: 'el' - }, { - title: '#{filter_lang_es}', - code: 'es' - }, { - title: '#{filter_lang_et}', - code: 'et' - }, { - title: '#{filter_lang_fa}', - code: 'fa' - }, { - title: '#{filter_lang_fi}', - code: 'fi' - }, { - title: '#{filter_lang_fr}', - code: 'fr' - }, { - title: '#{filter_lang_ga}', - code: 'ga' - }, { - title: '#{filter_lang_gl}', - code: 'gl' - }, { - title: '#{filter_lang_gn}', - code: 'gn' - }, { - title: '#{filter_lang_he}', - code: 'he' - }, { - title: '#{filter_lang_hi}', - code: 'hi' - }, { - title: '#{filter_lang_hr}', - code: 'hr' - }, { - title: '#{filter_lang_hu}', - code: 'hu' - }, { - title: '#{filter_lang_id}', - code: 'id' - }, { - title: '#{filter_lang_is}', - code: 'is' - }, { - title: '#{filter_lang_it}', - code: 'it' - }, { - title: '#{filter_lang_kk}', - code: 'kk' - }, { - title: '#{filter_lang_ks}', - code: 'ks' - }, { - title: '#{filter_lang_ku}', - code: 'ku' - }, { - title: '#{filter_lang_ky}', - code: 'ky' - }, { - title: '#{filter_lang_lt}', - code: 'lt' - }, { - title: '#{filter_lang_lv}', - code: 'lv' - }, { - title: '#{filter_lang_mi}', - code: 'mi' - }, { - title: '#{filter_lang_mk}', - code: 'mk' - }, { - title: '#{filter_lang_mn}', - code: 'mn' - }, { - title: '#{filter_lang_mo}', - code: 'mo' - }, { - title: '#{filter_lang_mt}', - code: 'mt' - }, { - title: '#{filter_lang_no}', - code: 'no|nb|nn' - }, { - title: '#{filter_lang_ne}', - code: 'ne' - }, { - title: '#{filter_lang_nl}', - code: 'nl' - }, { - title: '#{filter_lang_pa}', - code: 'pa' - }, { - title: '#{filter_lang_pl}', - code: 'pl' - }, { - title: '#{filter_lang_ps}', - code: 'ps' - }, { - title: '#{filter_lang_pt}', - code: 'pt' - }, { - title: '#{filter_lang_ro}', - code: 'ro' - }, { - title: '#{filter_lang_si}', - code: 'si' - }, { - title: '#{filter_lang_sk}', - code: 'sk' - }, { - title: '#{filter_lang_sl}', - code: 'sl' - }, { - title: '#{filter_lang_sm}', - code: 'sm' - }, { - title: '#{filter_lang_so}', - code: 'so' - }, { - title: '#{filter_lang_sr}', - code: 'sr' - }, { - title: '#{filter_lang_sv}', - code: 'sv' - }, { - title: '#{filter_lang_sw}', - code: 'sw' - }, { - title: '#{filter_lang_ta}', - code: 'ta' - }, { - title: '#{filter_lang_tg}', - code: 'tg' - }, { - title: '#{filter_lang_th}', - code: 'th' - }, { - title: '#{filter_lang_tk}', - code: 'tk' - }, { - title: '#{filter_lang_tr}', - code: 'tr' - }, { - title: '#{filter_lang_tt}', - code: 'tt' - }, { - title: '#{filter_lang_ur}', - code: 'ur' - }, { - title: '#{filter_lang_uz}', - code: 'uz' - }, { - title: '#{filter_lang_vi}', - code: 'vi' - }, { - title: '#{filter_lang_yi}', - code: 'yi' - }] - }; - data.genres_movie = { - title: '#{title_genre}', - items: [{ - "id": 28, - "title": "#{filter_genre_ac}", - checkbox: true - }, { - "id": 12, - "title": "#{filter_genre_ad}", - checkbox: true - }, { - "id": 16, - "title": "#{filter_genre_mv}", - checkbox: true - }, { - "id": 35, - "title": "#{filter_genre_cm}", - checkbox: true - }, { - "id": 80, - "title": "#{filter_genre_cr}", - checkbox: true - }, { - "id": 99, - "title": "#{filter_genre_dc}", - checkbox: true - }, { - "id": 18, - "title": "#{filter_genre_dr}", - checkbox: true - }, { - "id": 10751, - "title": "#{filter_genre_fm}", - checkbox: true - }, { - "id": 14, - "title": "#{filter_genre_fe}", - checkbox: true - }, { - "id": 36, - "title": "#{filter_genre_hi}", - checkbox: true - }, { - "id": 27, - "title": "#{filter_genre_ho}", - checkbox: true - }, { - "id": 10402, - "title": "#{filter_genre_mu}", - checkbox: true - }, { - "id": 9648, - "title": "#{filter_genre_de}", - checkbox: true - }, { - "id": 10749, - "title": "#{filter_genre_md}", - checkbox: true - }, { - "id": 878, - "title": "#{filter_genre_fa}", - checkbox: true - }, { - "id": 10770, - "title": "#{filter_genre_tv}", - checkbox: true - }, { - "id": 53, - "title": "#{filter_genre_tr}", - checkbox: true - }, { - "id": 10752, - "title": "#{filter_genre_mi}", - checkbox: true - }, { - "id": 37, - "title": "#{filter_genre_ve}", - checkbox: true - }] - }; - data.genres_tv = { - title: '#{title_genre}', - items: [{ - "id": 10759, - "title": "#{filter_genre_aa}", - checkbox: true - }, { - "id": 16, - "title": "#{filter_genre_mv}", - checkbox: true - }, { - "id": 35, - "title": "#{filter_genre_cm}", - checkbox: true - }, { - "id": 80, - "title": "#{filter_genre_cr}", - checkbox: true - }, { - "id": 99, - "title": "#{filter_genre_dc}", - checkbox: true - }, { - "id": 18, - "title": "#{filter_genre_dr}", - checkbox: true - }, { - "id": 10751, - "title": "#{filter_genre_fm}", - checkbox: true - }, { - "id": 10762, - "title": "#{filter_genre_ch}", - checkbox: true - }, { - "id": 9648, - "title": "#{filter_genre_de}", - checkbox: true - }, { - "id": 10763, - "title": "#{filter_genre_nw}", - checkbox: true - }, { - "id": 10764, - "title": "#{filter_genre_rs}", - checkbox: true - }, { - "id": 10765, - "title": "#{filter_genre_hf}", - checkbox: true - }, { - "id": 10766, - "title": "#{filter_genre_op}", - checkbox: true - }, { - "id": 10767, - "title": "#{filter_genre_tc}", - checkbox: true - }, { - "id": 10768, - "title": "#{filter_genre_mp}", - checkbox: true - }, { - "id": 37, - "title": "#{filter_genre_ve}", - checkbox: true - }] - }; - data.sort = { - title: '#{filter_sorted}', - items: [{ - title: '#{filter_any}' - }, { - title: '#{title_new}', - sort: 'now' - }, { - title: '#{title_now_watch}', - sort: 'now_playing' - }, { - title: '#{title_in_top}', - sort: 'top' - }, { - title: '#{title_ongoing}', - sort: 'airing' - }] - }; - data.quality = { - title: '#{player_quality}', - items: [{ - title: '#{filter_any}' - }, { - title: '#{title_in_high_quality}', - uhd: true - }] - }; - data.year = { - title: '#{title_year}', - items: [{ - title: '#{filter_any}', - any: true - }] - }; - var i = 100, - y = new Date().getFullYear(); - - for (var a = 0; a < 5; a++) { - data.year.items.push({ - title: y - a - }); - } - - while (i -= 5) { - var end = y - (99 - i); - data.year.items.push({ - title: end + 5 + '-' + end - }); - } - - for (var _a = 18; _a >= 0; _a -= 3) { - data.pgrating.items.push({ - title: _a + '+', - pg: _a - }); - } - - for (var _a2 = 15; _a2 >= 0; _a2 -= 3) { - data.pgrating.items.push({ - title: '#{filter_rating_from} ' + _a2 + ' #{filter_rating_to} ' + (_a2 + 3), - pg: _a2 + '-' + (_a2 + 3) - }); - } - - data.language.items.forEach(function (i) { - return i.checkbox = true; - }); - - function select(where, a) { - where.forEach(function (element) { - element.selected = false; - }); - a.selected = true; - } - - function selected(where) { - var title = []; - where.items.forEach(function (a) { - if (a.selected || a.checked) title.push(a.title); - }); - where.subtitle = title.length ? title.join(', ') : Lang.translate('nochoice'); - } - - function main() { - for (var i in data) { - selected(data[i]); - } - - var cat = data.type.items.find(function (s) { - return s.selected; - }).cat; - var type = cat.indexOf('movie') >= 0 ? 'movie' : 'tv'; - var items = [{ - title: Lang.translate('search_start'), - search: true - }, data.type, data.rating, data['genres_' + type], data.language, data.year]; - if (Storage.field('source') == 'cub') items.push(data.pgrating, data.sort, data.quality); - items.forEach(function (itm) { - itm.title = Lang.translate(itm.title); - if (itm.subtitle) itm.subtitle = Lang.translate(itm.subtitle); - - if (itm.items) { - itm.items.forEach(function (inr) { - inr.title = Lang.translate(inr.title); - }); - } - }); - Select.show({ - title: Lang.translate('title_filter'), - items: items, - onBack: function onBack() { - Controller.toggle('content'); - }, - onSelect: function onSelect(a) { - if (a.search) search();else submenu(a); - } - }); - } - - function queryForTMDB() { - var query = []; - var cat = data.type.items.find(function (s) { - return s.selected; - }).cat; - var type = cat.indexOf('movie') >= 0 ? 'movie' : 'tv'; - var genres = []; - var languages = []; - data.rating.items.forEach(function (a) { - if (a.selected && (a.voite || a.start)) { - if (a.start) { - query.push('vote_average.gte=' + a.start); - } else { - query.push('vote_average.gte=' + a.voite.split('-')[0]); - query.push('vote_average.lte=' + a.voite.split('-')[1]); - } - } - }); - data.language.items.forEach(function (a) { - if (a.checked) languages.push(a.code); - }); - data.year.items.forEach(function (a) { - if (a.selected && !a.any) { - var need = type == 'movie' ? 'primary_release_date' : 'first_air_date'; - - if (a.title.indexOf('-') >= 0) { - query.push(need + '.lte=' + a.title.split('-')[0] + '-12-31'); - query.push(need + '.gte=' + a.title.split('-')[1] + '-01-01'); - } else { - query.push((type == 'movie' ? 'primary_release_year' : 'first_air_date_year') + '=' + a.title); - } - } - }); - data['genres_' + type].items.forEach(function (a) { - if (a.checked) genres.push(a.id); - }); - if (cat == 'multmovie' || cat == 'multtv' && genres.indexOf(16) == -1) genres.push(16); - if (cat == 'movie' || cat == 'tv') query.push('without_genres=16'); - - if (genres.length) { - query.push('with_genres=' + genres.join(',')); - } - - if (cat == 'anime' && languages.indexOf('ja') == -1) languages.push('ja'); - - if (languages.length) { - query.push('with_original_language=' + languages.join('|')); - } - - return 'discover/' + type + '?' + query.join('&'); - } - - function queryForCUB() { - var query = []; - var cat = data.type.items.find(function (s) { - return s.selected; - }).cat; - var type = cat.indexOf('movie') >= 0 ? 'movie' : 'tv'; - var genres = []; - var sort = data.sort.items.find(function (s) { - return s.selected && s.sort; - }); - var quality = data.quality.items.find(function (s) { - return s.selected && s.uhd; - }); - var languages = []; - data.rating.items.forEach(function (a) { - if (a.selected && (a.voite || a.start)) { - if (a.start) { - query.push('vote=' + a.start); - } else { - query.push('vote=' + a.voite.split('-')[0] + '-' + a.voite.split('-')[1]); - } - } - }); - data.language.items.forEach(function (a) { - if (a.checked) languages.push(a.code); - }); - data.year.items.forEach(function (a) { - if (a.selected && !a.any) { - if (a.title.indexOf('-') >= 0) { - query.push('airdate=' + a.title.split('-')[1] + '-' + a.title.split('-')[0]); - } else { - query.push('airdate=' + a.title); - } - } - }); - data.pgrating.items.forEach(function (a) { - if (a.selected) { - if (a.title.indexOf('-') >= 0) { - query.push('pgrating=' + a.pg.split('-')[0] + '-' + a.pg.split('-')[1]); - } else { - query.push('pgrating=' + a.pg); - } - } - }); - data['genres_' + type].items.forEach(function (a) { - if (a.checked) genres.push(a.id); - }); - if (cat == 'multmovie' || cat == 'multtv' && genres.indexOf(16) == -1) genres.push(16); - if (cat == 'movie' || cat == 'tv') query.push('without_genres=16'); - - if (genres.length) { - query.push('genre=' + genres.join(',')); - } - - if (cat == 'anime') type = 'anime'; - - if (languages.length) { - query.push('language=' + languages.join(',')); - } - - if (sort) query.push('sort=' + sort.sort); - if (quality) query.push('uhd=true'); - return '?cat=' + type + '&' + query.join('&'); - } - - function search() { - Controller.toggle('content'); - var source = Storage.field('source'); - var query = source == 'cub' ? queryForCUB() : queryForTMDB(); - var activity = { - url: query, - title: Lang.translate('title_filter'), - component: 'category_full', - source: source == 'cub' ? 'cub' : 'tmdb', - card_type: true, - page: 1 - }; - var object = Activity$1.active(); - if (object.component == 'category_full' && (object.url.indexOf('discover') == 0 || object.url.indexOf('?cat=') == 0)) Activity$1.replace(activity, true);else Activity$1.push(activity); - } - - function submenu(item) { - Select.show({ - title: item.title, - items: item.items, - onBack: main, - onSelect: function onSelect(a) { - select(item.items, a); - main(); - } - }); - } - - function show$2() { - main(); - } - - var Filter = { - show: show$2 - }; - - var html$4; - var last; - var scroll; - var edit_mode; - var sort_item; - var sort_timer; - var visible_timer; - - function init$b() { - html$4 = Template$1.get('menu'); - scroll = new create$q({ - mask: true, - over: true - }); - if (!window.lampa_settings.torrents_use) html$4.find('[data-action="mytorrents"]').remove(); - - if (!Lang.selected(['ru', 'uk', 'be'])) { - html$4.find('[data-action="relise"],[data-action="anime"],[data-action="feed"]').remove(); - } - - Lampa.Listener.send('menu', { - type: 'start', - body: html$4 - }); - updateSort(); - observe(); - controller(); - $('body').on('mouseup', function (e) { - if ($('body').hasClass('menu--open') && DeviceInput.canClick(e.originalEvent)) { - $('body').toggleClass('menu--open', false); - disableEditMode(); - Controller.toggle('content'); - } - }); - scroll.minus(); - scroll.append(html$4); - Lampa.Listener.send('menu', { - type: 'end' - }); - } - - function observe() { - if (typeof MutationObserver == 'undefined') return; - var observer = new MutationObserver(function (mutations) { - for (var i = 0; i < mutations.length; i++) { - var mutation = mutations[i]; - - if (mutation.type == 'childList' && !mutation.removedNodes.length) { - var selectors = Array.from(mutation.target.querySelectorAll('.selector')).filter(function (s) { - return !s.checked; - }); - if (selectors.length) updateSort(); - selectors.forEach(function (s) { - s.checked = true; - - if (!$(s).data('binded_events')) { - $(s).on('hover:focus', function (e) { - last = e.target; - scroll.update($(e.target), true); - }).on('hover:hover hover:touch', function (e) { - last = e.target; - }); - } - }); - } - } - }); - observer.observe(html$4[0], { - childList: true, - subtree: true - }); - } - - function controller() { - Controller.add('menu', { - toggle: function toggle() { - Controller.collectionSet(html$4); - Controller.collectionFocus(last, html$4, true); - clearTimeout(visible_timer); - $('.wrap__left').removeClass('wrap__left--hidden'); - $('body').toggleClass('menu--open', true); - }, - update: function update() {}, - right: function right() { - if (edit_mode) { - if (sort_item) { - sort_item.removeClass('traverse'); - sort_item = false; - } else disableEditMode(); - } else Controller.toggle('content'); - }, - up: function up() { - if (sort_item) { - sort_item.prev().insertAfter(sort_item); - scroll.update(sort_item, true); - saveSort(); - } else if (Navigator.canmove('up')) Navigator.move('up');else Controller.toggle('head'); - }, - left: function left() { - if (edit_mode) { - if (!sort_item) { - sort_item = $(last); - sort_item.addClass('traverse'); - } else { - sort_item.removeClass('traverse'); - sort_item = false; - var name = $(last).text().trim(); - var hide = Storage.get('menu_hide', '[]'); - - if (hide.indexOf(name) == -1) { - if ($('.menu__list:eq(0) .menu__item:not(.hidden)', html$4).length > 3) hide.push(name); - } else hide.splice(hide.indexOf(name), 1); - - Storage.set('menu_hide', hide); - hideItems(); - } - } - }, - down: function down() { - if (sort_item) { - sort_item.next().insertBefore(sort_item); - scroll.update(sort_item, true); - saveSort(); - } else if (Navigator.canmove('down')) Navigator.move('down'); - }, - gone: function gone() { - $('body').toggleClass('menu--open', false); - visible_timer = setTimeout(function () { - $('.wrap__left').addClass('wrap__left--hidden'); - }, 300); - }, - back: function back() { - Activity$1.backward(); - } - }); - } - - function updateSort() { - clearTimeout(sort_timer); - sort_timer = setTimeout(function () { - checkSort(); - bindItems(); - }, 500); - } - - function checkSort() { - var memory = Storage.get('menu_sort', '[]'); - var anon = getSort(); - anon.forEach(function (item) { - if (memory.indexOf(item) == -1) memory.push(item); - }); - Storage.set('menu_sort', memory); - orderSort(); - hideItems(); - } - - function getSort() { - var items = []; - $('.menu__list:eq(0) .menu__item', html$4).each(function () { - items.push($(this).text().trim()); - }); - return items; - } - - function saveSort() { - Storage.set('menu_sort', getSort()); - } - - function orderSort() { - var items = Storage.get('menu_sort', '[]'); - - if (items.length) { - var list = $('.menu__list:eq(0)', html$4); - items.forEach(function (item) { - var el = $('.menu__item:contains("' + item + '")', list); - if (el.length) el.appendTo(list); - }); - } - } - - function hideItems() { - var items = Storage.get('menu_hide', '[]'); - $('.menu__item', html$4).removeClass('hidden'); - - if (items.length) { - var list = $('.menu__list:eq(0)', html$4); - items.forEach(function (item) { - var el = $('.menu__item:contains("' + item + '")', list); - if (el.length) el.addClass('hidden'); - }); - } - } - - function enableEditMode() { - html$4.addClass('editable'); - edit_mode = true; - scroll.update($(last), true); - } - - function disableEditMode() { - html$4.removeClass('editable'); - edit_mode = false; - - if (sort_item) { - sort_item.removeClass('traverse'); - sort_item = false; - } - - if ($(last).hasClass('hidden')) { - var list = $('.menu__list:eq(0)', html$4); - var items = $('.menu__item', list); - var inx = items.index($(last)); - var nohide = items.not('.hidden'); - if (nohide.eq(inx).length) last = nohide.eq(inx)[0];else if (nohide.eq(inx - 1).length) last = nohide.eq(inx - 1)[0];else last = nohide.eq(0)[0]; - Controller.collectionFocus(last, html$4); - scroll.update($(last), true); - } - } - - function bindItems() { - var list = $('.menu__list:eq(0)', html$4); - $('.menu__item', list).not('.binded').each(function () { - var item = $(this); - item.on('hover:long', function () { - if (typeof MutationObserver !== 'undefined') enableEditMode(); - }); - item.addClass('binded'); - }); - } - - function prepared(action, name) { - if (name.indexOf(action) >= 0) { - var comp = Lampa.Activity.active().component; - if (name.indexOf(comp) >= 0) Activity$1.replace();else return true; - } - } - - function ready() { - html$4.find('.selector').data('binded_events', true).on('hover:enter', function (e) { - var action = $(e.target).data('action'); - var type = $(e.target).data('type'); - if (action == 'catalog') catalog(); - - if (action == 'movie' || action == 'tv' || action == 'anime') { - Activity$1.push({ - url: action, - title: (action == 'movie' ? Lang.translate('menu_movies') : action == 'anime' ? Lang.translate('menu_anime') : Lang.translate('menu_tv')) + ' - ' + Storage.field('source').toUpperCase(), - component: 'category', - source: action == 'anime' ? 'cub' : Storage.field('source') - }); - } - - if (prepared(action, ['main'])) { - Activity$1.push({ - url: '', - title: Lang.translate('title_main') + ' - ' + Storage.field('source').toUpperCase(), - component: 'main', - source: Storage.field('source') - }); - } - - if (prepared(action, ['myperson'])) { - Activity$1.push({ - title: Lang.translate('title_persons'), - component: 'myperson' - }); - } - - if (action == 'search') Controller.toggle('search'); - if (action == 'settings') Controller.toggle('settings'); - - if (action == 'about') { - var about = Template$1.get('about'); - - if (window.lampa_settings.white_use) { - about.find('.about__contacts > div:eq(1)').remove(); - } - - if (Platform.is('android')) { - about.find('.platform_android').removeClass('hide'); - about.find('.version_android').text(Platform.version('android')); - } - - about.find('.version_app').text(Platform.version('app')); - Modal.open({ - title: Lang.translate('title_about'), - html: about, - size: 'medium', - onBack: function onBack() { - Modal.close(); - Controller.toggle('content'); - } - }); - } - - if (action == 'favorite') { - Activity$1.push({ - url: '', - title: Lang.translate(type == 'book' ? 'settings_input_links' : 'title_history'), - component: type == 'history' ? 'favorite' : 'bookmarks', - type: type, - page: 1 - }); - } - - if (action == 'subscribes') { - Activity$1.push({ - url: '', - title: Lang.translate('title_subscribes'), - component: 'subscribes', - page: 1 - }); - } - - if (prepared(action, ['timetable'])) { - Activity$1.push({ - url: '', - title: Lang.translate('title_timetable'), - component: 'timetable', - page: 1 - }); - } - - if (prepared(action, ['feed'])) { - Activity$1.push({ - url: '', - title: Lang.translate('menu_feed'), - component: 'feed', - page: 1 - }); - } - - if (prepared(action, ['mytorrents'])) { - Activity$1.push({ - url: '', - title: Lang.translate('title_mytorrents'), - component: 'mytorrents', - page: 1 - }); - } - - if (prepared(action, ['relise'])) { - Activity$1.push({ - url: '', - title: Lang.translate('title_relises'), - component: 'relise', - page: 1 - }); - } - - if (action == 'console') { - Controller.toggle('console'); - } - - if (action == 'filter') Filter.show(); - }).on('hover:focus', function (e) { - last = e.target; - scroll.update($(e.target), true); - }).on('hover:hover hover:touch', function (e) { - last = e.target; - }); - } - - function catalog() { - Api.menu({ - source: Storage.field('source') - }, function (menu) { - Select.show({ - title: Lang.translate('title_catalog'), - items: menu, - onSelect: function onSelect(a) { - var tmdb = Storage.field('source') == 'tmdb' || Storage.field('source') == 'cub'; - Activity$1.push({ - url: Storage.field('source') == 'tmdb' ? 'movie' : 'movie', - title: (a.title || Lang.translate('title_catalog')) + ' - ' + Storage.field('source').toUpperCase(), - component: tmdb ? 'category' : 'category_full', - genres: a.id, - id: a.id, - source: Storage.field('source'), - card_type: true, - page: 1 - }); - }, - onBack: function onBack() { - Controller.toggle('menu'); - } - }); - }); - } - - function render$2() { - return scroll.render(); - } - - var Menu = { - render: render$2, - init: init$b, - ready: ready - }; - - function render$1() { - var icon = "\n \n \n "; - var text = { - ru: "\u0422\u0440\u0438 \u0433\u043E\u0434\u0430 \u043D\u0430\u0437\u0430\u0434 \u043C\u044B \u0437\u0430\u043F\u0443\u0441\u0442\u0438\u043B\u0438 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 Lampa, \u0447\u0442\u043E\u0431\u044B \u043F\u043E\u0434\u0430\u0440\u0438\u0442\u044C \u0432\u0430\u043C \u043C\u0438\u0440 \u043B\u044E\u0431\u0438\u043C\u044B\u0445 \u0444\u0438\u043B\u044C\u043C\u043E\u0432, \u0441\u0435\u0440\u0438\u0430\u043B\u043E\u0432 \u0438 \u043C\u0443\u043B\u044C\u0442\u0444\u0438\u043B\u044C\u043C\u043E\u0432 \u0432 \u0443\u0434\u043E\u0431\u043D\u043E\u043C \u0444\u043E\u0440\u043C\u0430\u0442\u0435. \u0411\u043B\u0430\u0433\u043E\u0434\u0430\u0440\u044F \u0432\u0430\u043C, \u043D\u0430\u0448\u0435\u043C\u0443 \u0441\u043E\u043E\u0431\u0449\u0435\u0441\u0442\u0432\u0443, \u043C\u044B \u0441\u0442\u0430\u043B\u0438 \u0431\u043E\u043B\u044C\u0448\u0435, \u043B\u0443\u0447\u0448\u0435 \u0438 \u0438\u043D\u0442\u0435\u0440\u0435\u0441\u043D\u0435\u0435! \u0412 \u0447\u0435\u0441\u0442\u044C \u043D\u0430\u0448\u0435\u0433\u043E \u0434\u043D\u044F \u0440\u043E\u0436\u0434\u0435\u043D\u0438\u044F \u043C\u044B \u043F\u043E\u0434\u0433\u043E\u0442\u043E\u0432\u0438\u043B\u0438 \u043E\u0441\u043E\u0431\u044B\u0439 \u043F\u043E\u0434\u0430\u0440\u043E\u043A: \u0441\u043A\u0438\u0434\u043A\u0438 \u043D\u0430 \u043F\u043E\u0434\u043F\u0438\u0441\u043A\u0443 CUB Premium! \u0422\u0435\u043F\u0435\u0440\u044C \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044C \u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E\u0441\u0442\u044C \u043D\u0430\u0441\u043B\u0430\u0434\u0438\u0442\u044C\u0441\u044F \u0432\u0441\u0435\u043C\u0438 \u043F\u0440\u0435\u0438\u043C\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u043C\u0438 \u043F\u0440\u0435\u043C\u0438\u0443\u043C-\u0444\u0443\u043D\u043A\u0446\u0438\u0439 \u043F\u043E \u0435\u0449\u0451 \u0431\u043E\u043B\u0435\u0435 \u0432\u044B\u0433\u043E\u0434\u043D\u043E\u0439 \u0446\u0435\u043D\u0435.\n

    \n \u0410\u043A\u0446\u0438\u044F \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 10 \u0434\u043D\u0435\u0439 \u2014 \u0441 20 \u0441\u0435\u043D\u0442\u044F\u0431\u0440\u044F \u043F\u043E 30 \u0441\u0435\u043D\u0442\u044F\u0431\u0440\u044F! \u041D\u0435 \u0443\u043F\u0443\u0441\u0442\u0438\u0442\u0435 \u0448\u0430\u043D\u0441 \u0441\u0442\u0430\u0442\u044C \u0447\u0430\u0441\u0442\u044C\u044E \u043A\u043B\u0443\u0431\u0430 CUB Premium \u0438 \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C \u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C \u043E\u0442 \u0432\u0430\u0448\u0435\u0433\u043E \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F! \u0412\u0441\u0435 \u043F\u043E\u0434\u0440\u043E\u0431\u043D\u043E\u0441\u0442\u0438 \u043D\u0430 \u043D\u0430\u0448\u0435\u043C \u0441\u0430\u0439\u0442\u0435 cub.red/premium\n

    \n \u0421\u043F\u0430\u0441\u0438\u0431\u043E, \u0447\u0442\u043E \u0432\u044B\u0431\u0438\u0440\u0430\u0435\u0442\u0435 Lampa \u0438 \u043F\u0440\u0430\u0437\u0434\u043D\u0443\u0435\u0442\u0435 \u0432\u043C\u0435\u0441\u0442\u0435 \u0441 \u043D\u0430\u043C\u0438!", - uk: "\u0422\u0440\u0438 \u0440\u043E\u043A\u0438 \u0442\u043E\u043C\u0443 \u043C\u0438 \u0437\u0430\u043F\u0443\u0441\u0442\u0438\u043B\u0438 \u0434\u043E\u0434\u0430\u0442\u043E\u043A Lampa, \u0449\u043E\u0431 \u043F\u043E\u0434\u0430\u0440\u0443\u0432\u0430\u0442\u0438 \u0432\u0430\u043C \u0441\u0432\u0456\u0442 \u0443\u043B\u044E\u0431\u043B\u0435\u043D\u0438\u0445 \u0444\u0456\u043B\u044C\u043C\u0456\u0432, \u0441\u0435\u0440\u0456\u0430\u043B\u0456\u0432 \u0442\u0430 \u043C\u0443\u043B\u044C\u0442\u0444\u0456\u043B\u044C\u043C\u0456\u0432 \u0443 \u0437\u0440\u0443\u0447\u043D\u043E\u043C\u0443 \u0444\u043E\u0440\u043C\u0430\u0442\u0456. \u0417\u0430\u0432\u0434\u044F\u043A\u0438 \u0432\u0430\u043C, \u043D\u0430\u0448\u0456\u0439 \u0441\u043F\u0456\u043B\u044C\u043D\u043E\u0442\u0456, \u043C\u0438 \u0441\u0442\u0430\u043B\u0438 \u0431\u0456\u043B\u044C\u0448\u0438\u043C\u0438, \u043A\u0440\u0430\u0449\u0438\u043C\u0438 \u0442\u0430 \u0446\u0456\u043A\u0430\u0432\u0456\u0448\u0438\u043C\u0438! \u041D\u0430 \u0447\u0435\u0441\u0442\u044C \u043D\u0430\u0448\u043E\u0433\u043E \u0434\u043D\u044F \u043D\u0430\u0440\u043E\u0434\u0436\u0435\u043D\u043D\u044F \u043C\u0438 \u043F\u0456\u0434\u0433\u043E\u0442\u0443\u0432\u0430\u043B\u0438 \u043E\u0441\u043E\u0431\u043B\u0438\u0432\u0438\u0439 \u043F\u043E\u0434\u0430\u0440\u0443\u043D\u043E\u043A: \u0437\u043D\u0438\u0436\u043A\u0438 \u043D\u0430 \u043F\u0456\u0434\u043F\u0438\u0441\u043A\u0443 CUB Premium! \u0422\u0435\u043F\u0435\u0440 \u0443 \u0432\u0430\u0441 \u0454 \u043C\u043E\u0436\u043B\u0438\u0432\u0456\u0441\u0442\u044C \u043D\u0430\u0441\u043E\u043B\u043E\u0434\u0438\u0442\u0438\u0441\u044F \u0432\u0441\u0456\u043C\u0430 \u043F\u0435\u0440\u0435\u0432\u0430\u0433\u0430\u043C\u0438 \u043F\u0440\u0435\u043C\u0456\u0443\u043C-\u0444\u0443\u043D\u043A\u0446\u0456\u0439 \u0437\u0430 \u0449\u0435 \u0431\u0456\u043B\u044C\u0448 \u0432\u0438\u0433\u0456\u0434\u043D\u043E\u044E \u0446\u0456\u043D\u043E\u044E.\n

    \n \u0410\u043A\u0446\u0456\u044F \u0434\u0456\u0454 10 \u0434\u043D\u0456\u0432 \u2014 \u0437 20 \u0432\u0435\u0440\u0435\u0441\u043D\u044F \u0434\u043E 30 \u0432\u0435\u0440\u0435\u0441\u043D\u044F! \u041D\u0435 \u0432\u0442\u0440\u0430\u0442\u044C\u0442\u0435 \u0448\u0430\u043D\u0441 \u0441\u0442\u0430\u0442\u0438 \u0447\u0430\u0441\u0442\u0438\u043D\u043E\u044E \u043A\u043B\u0443\u0431\u0443 CUB Premium \u0442\u0430 \u043E\u0442\u0440\u0438\u043C\u0430\u0442\u0438 \u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C \u0432\u0456\u0434 \u0432\u0430\u0448\u043E\u0433\u043E \u0434\u043E\u0434\u0430\u0442\u043A\u0430! \u0423\u0441\u0456 \u0434\u0435\u0442\u0430\u043B\u0456 \u043D\u0430 \u043D\u0430\u0448\u043E\u043C\u0443 \u0441\u0430\u0439\u0442\u0456 cub.red/premium.\n

    \n \u0414\u044F\u043A\u0443\u0454\u043C\u043E, \u0449\u043E \u043E\u0431\u0438\u0440\u0430\u0454\u0442\u0435 Lampa \u0456 \u0441\u0432\u044F\u0442\u043A\u0443\u0454\u0442\u0435 \u0440\u0430\u0437\u043E\u043C \u0437 \u043D\u0430\u043C\u0438!" - }; - var html = $("\n
    \n
    \n \n
    \n\n
    ".concat(text[Storage.get('language', 'ru')], "
    \n
    ")); - var btn = $(''); - btn.on('hover:enter', function () { - Modal.open({ - title: '', - size: 'medium', - html: html, - mask: false, - onBack: function onBack() { - Modal.close(); - Controller.toggle('head'); - } - }); - Utils$2.imgLoad(html.find('img')[0], 'https://cdn.cub.red/img/other/birthday_3_years.jpg', function () { - html.addClass('loaded'); - }, function () { - html.addClass('noload'); - }); - }); - btn.append(icon); - $('.head .head__actions .open--settings').after(btn); - } - - function start$2() { - var date_start = '2024-09-20T10:00:00'; - var date_end = '2024-09-30T22:00:00'; - var time_start = new Date(date_start).getTime(); - var time_end = new Date(date_end).getTime(); - var time_now = new Date().getTime(); - if (time_now > time_start && time_now < time_end && Lang.selected(['ru', 'uk'])) render$1(); - } - - var Birthday = { - start: start$2 - }; - - function app() { - var app = $('#app').empty(); - var wrap = Template$1.get('wrap'); - wrap.find('.wrap__left').append(Menu.render()); - wrap.find('.wrap__content').append(Activity$1.render()); - app.append(Background.render()); - app.append(Head.render()); - app.append(wrap); - app.append(Settings.render()); - app.append(Search.render()); - Birthday.start(); - } - - var Render = { - app: app - }; - - var html$3; - var object; - - function init$a() { - html$3 = Template$1.get('iframe'); - } - - function show$1() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - object = params; - - html$3.find('iframe').attr('src', params.url)[0].onload = function () { - html$3.addClass('iframe--loaded'); - }; - - $('body').append(html$3); - toggle$1(); - } - - function toggle$1() { - Controller.add('iframe', { - toggle: function toggle() {}, - back: close$1 - }); - Controller.toggle('iframe'); - } - - function close$1() { - html$3.removeClass('iframe--loaded'); - html$3.detach(); - html$3.find('iframe').attr('src', ''); - if (object.onBack) object.onBack(); - } - - function render() { - return html$3; - } - - var Iframe = { - init: init$a, - show: show$1, - close: close$1, - render: render - }; - - var items = {}; - var times = 0; - var html$2; - var scroll_tabs; - var scroll_body; - var last_tab; - - function init$9() { - Keypad.listener.follow('keydown', function (e) { - if (e.code == 38 || e.code == 29460) { - var enable = Controller.enabled(); - - if (enable.name == 'head') { - times++; - - if (times > 10) { - Controller.toggle('console'); - } - } else { - times = 0; - } - } - }); - Controller.add('console', { - toggle: function toggle() { - build(); - Controller.toggle('console-tabs'); - }, - back: back - }); - Controller.add('console-tabs', { - toggle: function toggle() { - Controller.collectionSet(scroll_tabs.render()); - Controller.collectionFocus(scroll_tabs.render().find('.console__tab[data-name="' + Utils$2.hash(last_tab) + '"]')[0], scroll_tabs.render()); - }, - down: function down() { - Controller.toggle('console-body'); - }, - right: function right() { - Navigator.move('right'); - }, - left: function left() { - Navigator.move('left'); - }, - back: back - }); - follow(); - } - - function back() { - times = 0; - scroll_tabs.destroy(); - scroll_body.destroy(); - html$2.remove(); - Controller.toggle('head'); - } - - function show(name) { - scroll_body.clear(); - scroll_body.reset(); - - if (items[name]) { - items[name].forEach(function (element) { - var item = $(element); - item.on('hover:focus', function (e) { - scroll_body.update($(e.target)); - }); - - if (name == 'Request') { - item.on('hover:enter', function (e) { - var str = item.text(); - var mth = str.match(/error of (.*?) :/); - - if (mth && mth[1]) { - Iframe.show({ - url: mth[1], - onBack: function onBack() { - Controller.toggle('console-body'); - } - }); - } - }); - } - - scroll_body.append(item); - }); - } - - Controller.add('console-body', { - toggle: function toggle() { - Controller.collectionSet(scroll_body.render()); - Controller.collectionFocus(false, scroll_body.render()); - }, - up: function up() { - if (Navigator.canmove('up')) Navigator.move('up');else Controller.toggle('console-tabs'); - }, - down: function down() { - Navigator.move('down'); - }, - back: back - }); - Controller.toggle('console-body'); - } - - function tab(name, lines) { - var elem = $('
    ' + Utils$2.shortText(name, 10) + ' - ' + lines.length + '
    '); - elem.on('hover:enter', function () { - show(name); - last_tab = name; - }).on('hover:focus', function (e) { - scroll_tabs.update($(e.target)); - }); - scroll_tabs.append(elem); - if (!last_tab) last_tab = name; - if (last_tab == name) show(name); - } - - function build() { - html$2 = Template$1.get('console'); - scroll_body = new create$q({ - over: true, - mask: true - }); - scroll_tabs = new create$q({ - horizontal: true - }); - - for (var i in items) { - tab(i, items[i]); - } - - html$2.find('.console__tabs').append(HeadBackward(Lang.translate('menu_console'))).append(scroll_tabs.render()); - html$2.find('.console__body').append(scroll_body.render()); - scroll_body.height(html$2.find('.console__tabs')); - $('body').append(html$2); - } - - function add(name, message) { - if (!items[name]) items[name] = []; - var where = items[name]; - var time = Utils$2.parseTime(Date.now()).time; - - try { - Arrays.insert(where, 0, '
    ' + time + ' - ' + message + '
    '); - } catch (e) { - Arrays.insert(where, 0, '
    ' + time + ' - Failed to print line
    '); - } - - if (where.length > 50) where.pop(); - } - - function escapeHtml(text) { - return text.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'"); - } - - function decode(arr) { - if (Arrays.isObject(arr) || Arrays.isArray(arr)) { - try { - arr = JSON.stringify(arr); - } catch (e) { - arr = '[noview]'; - } - } else if (typeof arr === 'string' || typeof arr === 'number' || typeof arr === 'boolean') { - arr = escapeHtml(arr + ''); - } else { - var a = []; - - for (var i in arr) { - a.push(i + ': ' + arr[i]); - } - - arr = JSON.stringify(a); - } - - arr = Utils$2.shortText(arr, 600); - return arr; - } - - function follow() { - var log = console.log; - - console.log = function () { - var msgs = []; - var mcon = []; - - while (arguments.length) { - var arr = [].shift.call(arguments); - msgs.push(decode(arr)); - mcon.push(arr); - } - - var name = msgs[0]; - - if (msgs.length < 2) { - name = 'Other'; - } else { - msgs[0] = '' + msgs[0] + ''; - } - - add(name, msgs.join(' ')); - log.apply(console, mcon); - }; - - window.addEventListener("error", function (e) { - var welcome = $('.welcome'); - - if (welcome.length) { - welcome.fadeOut(500, function () { - Noty.show('Error: ' + (e.error || e).message + '

    ' + stack, { - time: 8000 - }); - }); - } - - var stack = (e.error && e.error.stack ? e.error.stack : e.stack || '').split("\n").join('
    '); - var message = typeof e.error == 'string' ? e.error : (e.error || e).message; - add('Script', message + '

    ' + stack); - if (!(stack.indexOf('resetTopStyle') >= 0 || stack.indexOf('Blocked a frame') >= 0)) Noty.show('Error: ' + message + '

    ' + stack, { - time: 8000 - }); - }); - } - - var Console = { - init: init$9 - }; - - function create$1() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var html = Template$1.get('files', params.movie); - html.addClass('layer--width'); - - if (params.movie.id) { - html.find('.selector').on('hover:enter', function () { - if (Activity$1.all().length > 1) { - Activity$1.back(); - } else { - Activity$1.push({ - url: params.movie.url, - component: 'full', - id: params.movie.id, - method: params.movie.name ? 'tv' : 'movie', - card: params.movie, - source: params.movie.source - }); - } - }); - } else { - html.find('.selector').removeClass('selector'); - } - - this.render = function () { - return html; - }; - - this.append = function (add) { - html.find('.files__body').append(add); - }; - - this.destroy = function () { - html.remove(); - html = null; - }; - - this.clear = function () { - html.find('.files__body').empty(); - }; - } - - var body; - var code = 0; - var network$1 = new create$p(); - var fields = ['torrents_view', 'plugins', 'favorite', 'file_view']; - var timer; - var readed; - /** - * Запуск - */ - - function init$8() { - if (Storage.field('cloud_use')) status(1); - Settings.listener.follow('open', function (e) { - body = null; - - if (e.name == 'cloud') { - body = e.body; - renderStatus(); - } - }); - Storage.listener.follow('change', function (e) { - if (e.name == 'cloud_token') { - login(start$1); - } else if (e.name == 'cloud_use') { - if (e.value == 'true') login(start$1);else status(0); - } else if (fields.indexOf(e.name) >= 0) { - clearTimeout(timer); - timer = setTimeout(update$1, 500); - } - }); - login(start$1); - } - /** - * Статус - * @param {Int} c - код - */ - - - function status(c) { - code = c; - renderStatus(); - } - /** - * Рендер статуса - */ - - - function renderStatus() { - if (body) { - var item = body.find('.settings--cloud-status'), - name = item.find('.settings-param__name'), - desc = item.find('.settings-param__descr'); - - if (code == 0) { - name.text('Отключено'); - desc.text('Включите синхронизацию'); - } - - if (code == 1) { - name.text('Не авторизованы'); - desc.text('Необходимо авторизоваться '); - } - - if (code == 2) { - name.text('Авторизация не удалась'); - desc.text('Проверьте введённые данные и повторите попытку'); - } - - if (code == 3) { - name.text('Вошли'); - desc.text('Вы успешно авторизовались'); - } - - if (code == 4) { - var time = Utils$2.parseTime(Storage.get('cloud_time', '2021.01.01')); - name.text('Синхронизовано'); - desc.text(time.full + ' в ' + time.time); - } - } - } - /** - * Проверка авторизации - * @param {Function} good - успешно - * @param {Function} fail - провал - */ - - - function login(good, fail) { - if (Storage.get('cloud_token') && Storage.field('cloud_use')) { - network$1.silent('https://api.github.com/gists', function (data) { - status(3); - if (good) good(); - network$1.silent('https://api.github.com/gists/' + data.id, false, false, false, { - type: 'delete', - beforeSend: { - name: 'Authorization', - value: 'bearer ' + Storage.get('cloud_token') - }, - headers: { - 'Accept': 'application/vnd.github.v3+json' - } - }); - }, function () { - status(2); - if (fail) fail(); - }, JSON.stringify({ - 'files': { - 'lampa-login.json': { - 'content': '{"login":true}' - } - } - }), { - beforeSend: { - name: 'Authorization', - value: 'bearer ' + Storage.get('cloud_token') - }, - headers: { - 'Accept': 'application/vnd.github.v3+json' - } - }); - } else { - status(Storage.field('cloud_use') ? 1 : 0); - if (fail) fail(); - } - } - /** - * Считываем файл и обновляем данные с облака - */ - - - function read(call) { - var time = Storage.get('cloud_time', '2021.01.01'); - - if (time !== readed.item.updated_at) { - network$1.silent(readed.file.raw_url, function (data) { - Storage.set('cloud_time', readed.item.updated_at); - - for (var i in data) { - Storage.set(i, data[i], true); - } - - status(4); - if (call) call(); - }); - } else if (call) call(); - } - /** - * Обновляем состояние - */ - - - function update$1() { - save(); - } - /** - * Получаем список файлов - */ - - - function start$1(call) { - if (Storage.get('cloud_token') && Storage.field('cloud_use')) { - network$1.silent('https://api.github.com/gists', function (data) { - var file; - var item; - data.forEach(function (elem) { - for (var i in elem.files) { - if (elem.files[i].filename == 'lampa-data.json') { - item = elem; - file = elem.files[i]; - } - } - }); - - if (file) { - Storage.set('cloud_data_id', item.id); - readed = { - file: file, - item: item - }; - read(call); - } else save(call); - }, function () {}, false, { - beforeSend: { - name: 'Authorization', - value: 'bearer ' + Storage.get('cloud_token') - }, - headers: { - 'Accept': 'application/vnd.github.v3+json' - } - }); - } - } - /** - * Сохраняем закладки в облако - */ - - - function save(call) { - if (Storage.get('cloud_token') && Storage.field('cloud_use')) { - var conent = JSON.stringify({ - torrents_view: Storage.get('torrents_view', '[]'), - plugins: Storage.get('plugins', '[]'), - favorite: Storage.get('favorite', '{}'), - file_view: Storage.get('file_view', '{}'), - setting_member: Storage.get('setting_member', '[]') - }, null, 4); - var id = Storage.get('cloud_data_id', ''); - network$1.silent('https://api.github.com/gists' + (id ? '/' + id : ''), function (data) { - Storage.set('cloud_time', data.updated_at); - Storage.set('cloud_data_id', data.id); - status(4); - if (call) call(); - }, function () { - Storage.set('cloud_data_id', ''); - status(5); - }, JSON.stringify({ - 'files': { - 'lampa-data.json': { - 'content': conent - } - } - }), { - beforeSend: { - name: 'Authorization', - value: 'bearer ' + Storage.get('cloud_token') - }, - headers: { - 'Accept': 'application/vnd.github.v3+json' - } - }); - } - } - - var Cloud = { - init: init$8 - }; - - function create() { - var html; - - this.create = function () { - html = Template$1.get('info'); - }; - - this.update = function (data) { - var nofavorite = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; - var create = ((data.release_date || data.first_air_date || '0000') + '').slice(0, 4); - var vote = parseFloat((data.vote_average || 0) + '').toFixed(1); - html.find('.info__title').text(data.title); - html.find('.info__title-original').text((create == '0000' ? '' : create + ' - ') + (data.original_title || '')); - html.find('.info__vote span').text(vote); - html.find('.info__vote').toggleClass('hide', !(vote > 0)); - html.find('.info__icon').removeClass('active'); - - if (!nofavorite) { - var status = Favorite.check(data); - $('.icon--book', html).toggleClass('active', status.book); - $('.icon--like', html).toggleClass('active', status.like); - $('.icon--wath', html).toggleClass('active', status.wath); - } - - html.find('.info__right').toggleClass('hide', nofavorite); - }; - - this.render = function () { - return html; - }; - - this.empty = function () { - this.update({ - title: Lang.translate('more'), - original_title: Lang.translate('more_results'), - vote_average: 0 - }, true); - }; - - this.destroy = function () { - html.remove(); - html = null; - }; - } - - var VideoQuality = { - get: function get() { - return ''; - }, - add: function add() { - return false; - } - }; - - /* - let tizen = { - ApplicationControlData: ()=>{}, - ApplicationControl: ()=>{}, - application:{ - launchAppControl: ()=>{} - } - } - */ - - /** - * Запуск - */ - - function init$7() { - if (typeof tizen !== 'undefined') { - setInterval(lauchPick, 1000 * 60 * 10); - lauchPick(); - deepLink(); - window.addEventListener('appcontrol', deepLink); - - try { - console.log('Tizen', 'current id', tizen.application.getCurrentApplication().appInfo.id); - } catch (e) {} - } - } - /** - * Установить данные - * @param {{sections:[{title:string,position:integer,tiles:[{cardToTile}]}]}} data - */ - - - function setPick(data) { - var service_id = tizen.application.getCurrentApplication().appInfo.id.split('.')[0] + '.service'; - var controll_data = new tizen.ApplicationControlData('caller', ['ForegroundApp', JSON.stringify(data)]); - var controll_app = new tizen.ApplicationControl('http://tizen.org/appcontrol/operation/pick', null, 'image/*', null, [controll_data]); - tizen.application.launchAppControl(controll_app, service_id, function () { - console.log('Tizen', 'service', 'launch success'); - }, function (error) { - console.log('Tizen', 'service', 'error:', JSON.stringify(error)); - }); - } - /** - * Карточку в данные - * @param {{title:string, name:string, poster_path:string, release_date:string}} card - карточка - * @param {string} subtitle - * @returns {{title:string, subtitle:string, image_ratio:string, image_url:string, action_data:string, is_playable:boolean}} - */ - - - function cardToTile(card, subtitle) { - var relise = ((card.release_date || card.first_air_date || '0000') + '').slice(0, 4); - var elem = { - title: card.title || card.name, - subtitle: subtitle || relise, - image_ratio: '1by1', - image_url: card.poster ? card.poster : card.img ? card.img : 'http://imagetmdb.com/t/p/w300/' + card.poster_path, - action_data: JSON.stringify(card), - is_playable: false - }; - return elem; - } - /** - * Строим данные - */ - - - function lauchPick() { - var data = { - sections: [] - }; - console.log('Tizen', 'start pick'); - var status = new status$2(3); - - status.onComplite = function (result) { - if (result.popular) data.sections.push(result.popular); - if (result.continues) data.sections.push(result.continues); - if (result.notice) data.sections.push(result.notice); - console.log('Tizen', 'set sections', data.sections.length); - if (data.sections.length) setPick(data); - }; - - Account.notice(function (notices) { - var new_notices = notices.filter(function (n) { - return !n.viewed; - }).slice(0, 3); - - if (new_notices.length) { - var section = { - title: Lang.translate('title_notice'), - tiles: [], - position: 0 - }; - new_notices.forEach(function (noty) { - var info = JSON.parse(noty.data); - section.tiles.push(cardToTile(info.card, info.type == 'new_episode' ? Lang.translate('notice_new_episode') : Lang.translate('notice_in_quality'))); - }); - status.append('notice', section); - } else status.error(); - }); - TMDB.get('movie/popular', {}, function (result) { - if (result.results.length) { - var section = { - title: Lang.translate('title_popular_movie'), - position: 2, - tiles: result.results.slice(0, 10).map(function (c) { - return cardToTile(c); - }) - }; - status.append('popular', section); - } else status.error(); - }, status.error.bind(status)); - var continues = Favorite.continues('tv'); - - if (continues.length) { - var section = { - title: Lang.translate('title_continue'), - position: 1, - tiles: continues.slice(0, 7).map(function (c) { - return cardToTile(c); - }) - }; - status.append('continues', section); - } else status.error(); - } - /** - * Перехват запроса на открытие карточки - */ - - - function deepLink() { - var requestedAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); - - if (requestedAppControl) { - var appControlData = requestedAppControl.appControl.data; - - for (var i = 0; i < appControlData.length; i++) { - if (appControlData[i].key == 'PAYLOAD') { - var action_data = JSON.parse(appControlData[i].value[0]).values; - var json = JSON.parse(action_data); - window.start_deep_link = { - url: json.url, - component: 'full', - id: json.id, - method: json.name ? 'tv' : 'movie', - card: json, - source: json.source || 'tmdb' - }; - - if (window.appready) { - Activity$1.push(window.start_deep_link); - } - - console.log('Tizen', 'open deep link', window.start_deep_link); - } - } - } - } - - var Tizen = { - init: init$7 - }; - - function component(object) { - var scroll = new create$q({ - mask: true, - over: true, - scroll_by_item: true, - end_ratio: 1.5 - }); - var items = []; - var html = document.createElement('div'); - var active = 0; - - this.create = function () {}; - - this.empty = function () { - var button; - - if (object.source == 'tmdb') { - button = $(''); - button.find('.selector').on('hover:enter', function () { - Storage.set('source', 'cub'); - Activity$1.replace({ - source: 'cub' - }); - }); - } - - var empty = new create$a(); - if (button) empty.append(button); - html.appendChild(empty.render(true)); - this.start = empty.start; - this.activity.loader(false); - this.activity.toggle(); - }; - - this.loadNext = function () { - var _this = this; - - if (this.next && !this.next_wait && items.length) { - this.next_wait = true; - this.next(function (new_data) { - _this.next_wait = false; - new_data.forEach(_this.append.bind(_this)); - Layer.visible(items[active + 1].render(true)); - }, function () { - _this.next_wait = false; - }); - } - }; - - this.build = function (data) { - var _this2 = this; - - scroll.minus(); - - scroll.onWheel = function (step) { - if (!Controller.own(_this2)) _this2.start(); - if (step > 0) _this2.down();else if (active > 0) _this2.up(); - }; - - scroll.onEnd = this.loadNext.bind(this); - if (this.onLinesBuild) this.onLinesBuild(data); - data.forEach(this.append.bind(this)); - html.appendChild(scroll.render(true)); - Layer.update(html); - this.activity.loader(false); - this.activity.toggle(); - Layer.visible(html); - }; - - this.append = function (element) { - if (element.ready) return; - element.ready = true; - var item = new create$h(element, { - url: element.url, - genres: object.genres, - object: object, - card_wide: element.wide, - card_small: element.small, - card_broad: element.broad, - card_collection: element.collection, - card_category: element.category, - card_events: element.card_events, - cardClass: element.cardClass, - nomore: element.nomore, - type: element.line_type || 'cards' - }); - item.create(); - this.push(item, element); - }; - - this.back = function () { - Activity$1.backward(); - }; - - this.push = function (item, element) { - item.onDown = this.down.bind(this); - item.onUp = this.up.bind(this); - item.onBack = this.back.bind(this); - if (this.onMore) item.onMore = this.onMore.bind(this); - items.push(item); - if (this.onAppend) this.onAppend(item, element); - scroll.append(item.render(true)); - }; - - this.down = function () { - active++; - active = Math.min(active, items.length - 1); - scroll.update(items[active].render(true)); - items[active].toggle(); - }; - - this.up = function () { - active--; - - if (active < 0) { - active = 0; - Controller.toggle('head'); - } else { - items[active].toggle(); - scroll.update(items[active].render(true)); - } - }; - - this.start = function () { - var _this3 = this; - - Controller.add('content', { - link: this, - toggle: function toggle() { - if (_this3.activity.canRefresh()) return false; - if (items.length) items[active].toggle(); - }, - update: function update() {}, - left: function left() { - if (Navigator.canmove('left')) Navigator.move('left');else Controller.toggle('menu'); - }, - right: function right() { - Navigator.move('right'); - }, - up: function up() { - if (Navigator.canmove('up')) Navigator.move('up');else Controller.toggle('head'); - }, - down: function down() { - if (Navigator.canmove('down')) Navigator.move('down'); - }, - back: this.back - }); - Controller.toggle('content'); - }; - - this.refresh = function () { - this.activity.needRefresh(); - }; - - this.pause = function () {}; - - this.stop = function () {}; - - this.render = function (js) { - return js ? html : $(html); - }; - - this.destroy = function () { - Arrays.destroy(items); - scroll.destroy(); - html.remove(); - items = []; - }; - } - - function open$1(callSelected, callCancel) { - var html = Template$1.get('lang_choice', {}); - var scroll = new create$q({ - mask: true, - over: true - }); - var codes = Lang.codes(); - - function selector(code) { - var item = $('
    ' + codes[code] + '
    '); - item.on('hover:enter', function (e) { - if (callSelected) callSelected(code); - html.fadeOut(300, function () { - scroll.destroy(); - html.remove(); - scroll = null; - html = null; - }); - }).on('hover:focus', function (e) { - scroll.update($(e.target), true); - $('.lang__selector-item', html).removeClass('last-focus'); - $(e.target).addClass('last-focus'); - html.find('.lang__title').text(Lang.translate('lang_choice_title', code)); - html.find('.lang__subtitle').text(Lang.translate('lang_choice_subtitle', code)); - }); - scroll.append(item); - } - - for (var code in codes) { - selector(code); - } - - html.find('.lang__selector').append(scroll.render()); - $('body').append(html); - Controller.add('language', { - toggle: function toggle() { - var focus = html.find('[data-code="' + Storage.get('language', 'ru') + '"]'); - Controller.collectionSet(scroll.render()); - Controller.collectionFocus(focus[0], scroll.render()); - }, - up: function up() { - Navigator.move('up'); - }, - down: function down() { - Navigator.move('down'); - }, - back: function back() { - if (callCancel) { - scroll.destroy(); - html.remove(); - scroll = null; - html = null; - callCancel(); - } - } - }); - Controller.toggle('language'); - } - - var LangChoice = { - open: open$1 - }; - - function init$6() { - if (!Platform.is('webos')) return; - var field = $("
    \n
    \n \n \n \n \n \n \n
    \n
    ".concat(Lang.translate('settings_webos_launcher'), "
    \n
    ")); - Settings.main().render().find('[data-component="more"]').after(field); - Settings.main().update(); - Lampa.Template.add('settings_webos_launcher', "
    \n
    \n
    #{settings_webos_launcher_add_device}
    \n
    \n
    \n
    #{settings_webos_launcher_remove_device}
    \n
    \n
    "); - Settings.listener.follow('open', function (e) { - var appid = webOS.fetchAppId(); - console.log('WebOS', 'current appid:', appid); - if (appid.length == 0) appid = window.lampa_settings.iptv ? 'icva' : 'com.lampa.tv'; - - if (e.name == 'webos_launcher') { - e.body.find('[data-name="add"]').unbind('hover:enter').on('hover:enter', function () { - webOS.service.request("luna://com.webos.service.eim", { - method: "addDevice", - parameters: { - "appId": appid, - "pigImage": "/pigImage.jpg", - "type": "MVPD_IP", - "showPopup": true, - "label": "Lampa", - "description": "Lampa app for LG webOS" - }, - onSuccess: function onSuccess(res) { - Noty.show(Lang.translate('settings_added')); - }, - onFailure: function onFailure(res) { - Noty.show(Lang.translate('title_error') + ': ' + res.errorText); - } - }); - }); - e.body.find('[data-name="remove"]').unbind('hover:enter').on('hover:enter', function () { - webOS.service.request("luna://com.webos.service.eim", { - method: "deleteDevice", - parameters: { - "appId": appid, - "showPopup": true - }, - onSuccess: function onSuccess(res) { - Noty.show(Lang.translate('settings_added')); - }, - onFailure: function onFailure(res) { - Noty.show(Lang.translate('title_error') + ': ' + res.errorText); - } - }); - }); - } - }); - } - - var WebOSLauncher = { - init: init$6 - }; - - function open(callSelected) { - var html = Template$1.get('lang_choice', {}); - var scroll = new create$q({ - mask: true, - over: true - }); - - function btn(name, select) { - var item = $('
    ' + name + '
    '); - item.on('hover:enter', function (e) { - if (select) select(); - }).on('hover:focus', function (e) { - scroll.update($(e.target), true); - }).on('click', function (e) { - if (select && DeviceInput.canClick(e.originalEvent)) select(); - }); - scroll.append(item); - } - - function destroy() { - html.fadeOut(300, function () { - scroll.destroy(); - html.remove(); - scroll = null; - html = null; - }); - Controller.add('developer', { - toggle: function toggle() {} - }); - } - - function close() { - destroy(); - callSelected(); - } - - var btns = [{ - name: Lang.translate('title_continue_two'), - select: close - }, { - name: Lang.translate('plugins_remove'), - select: function select() { - Storage.set('plugins', []); - close(); - } - }, { - name: Lang.translate('settings_reset'), - select: function select() { - localStorage.clear(); - window.location.reload(); - destroy(); - } - }]; - btns.forEach(function (item) { - btn(item.name, item.select); - }); - html.find('.lang__selector').append(scroll.render()); - $('body').append(html); - Controller.add('developer', { - toggle: function toggle() { - Controller.collectionSet(scroll.render()); - Controller.collectionFocus(false, scroll.render()); - }, - up: function up() { - Navigator.move('up'); - }, - down: function down() { - Navigator.move('down'); - } - }); - Controller.toggle('developer'); - } - - var Developer = { - open: open - }; - - var CardClass = /*#__PURE__*/function () { - function CardClass(params) { - _classCallCheck(this, CardClass); - - this.params = params; - } - - _createClass(CardClass, [{ - key: "create", - value: function create() { - this.build(); - this.image(); - } - }, { - key: "build", - value: function build() { - var _this = this; - - this.card = Template$1.js('card'); - this.img = this.card.querySelector('.card__img') || {}; - this.card.querySelector('.card__title').innerText = this.params.title; - this.card.querySelector('.card__age').innerText = this.params.subtitle; - this.box = document.createElement('div'); - this.box.classList.add('card__textbox'); - this.box.innerText = this.params.text; - this.card.querySelector('.card__view').appendChild(this.box); - this.card.addEventListener('hover:enter', function () { - var tpl = Template$1.get('cub_premium'); - tpl.find('.cub-premium__title').text(Lang.translate('title_notice')); - tpl.find('.cub-premium__descr').eq(0).empty().text(Lang.translate('ad_notice_' + _this.params.type)); - Modal.open({ - title: '', - size: 'medium', - mask: true, - html: tpl, - onBack: function onBack() { - Modal.close(); - Controller.toggle('content'); - } - }); - }); - this.card.addEventListener('visible', this.visible.bind(this)); - } - }, { - key: "image", - value: function image() { - var _this2 = this; - - this.img.onload = function () { - _this2.card.classList.add('card--loaded'); - }; - - this.img.onerror = function () { - TMDB$1.broken(); - console.log('Img', 'noload', _this2.img.src); - _this2.img.src = './img/img_broken.svg'; - }; - } - }, { - key: "visible", - value: function visible() { - if (this.params.poster) this.img.src = Api.img(this.params.poster);else if (this.params.img) this.img.src = this.params.img;else this.img.src = './img/img_broken.svg'; - } - }, { - key: "destroy", - value: function destroy() { - this.img.onerror = function () {}; - - this.img.onload = function () {}; - - this.img.src = ''; - this.card.remove(); - this.card = null; - this.img = null; - } - }, { - key: "render", - value: function render(js) { - return js ? this.card : $(this.card); - } - }]); - - return CardClass; - }(); - - var Watched = /*#__PURE__*/function () { - function Watched() { - var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - _classCallCheck(this, Watched); - - var n = Math.floor(Math.random() * 5) + 1; - Arrays.extend(params, { - title: params.card.title || params.card.name, - subtitle: Lang.translate('title_notice'), - poster: params.card.poster_path, - text: Lang.translate('ad_notice_' + params.type + '_text_' + n) - }); - this.card = new CardClass(params); - this.card.create(); - } - - _createClass(Watched, [{ - key: "destroy", - value: function destroy() { - this.card.destroy(); - } - }, { - key: "render", - value: function render(js) { - return this.card.render(js); - } - }]); - - return Watched; - }(); - - var network; - - function init$5() { - network = new create$p(); - Socket.listener.follow('message', function (e) { - if (e.method == 'premiere') update(e.data); - }); - } - - function update(data) { - var id = data.type + '/' + data.id; - console.log('Premiere', 'load:', data, 'exist:', Boolean(Notice$1.classes.lampa.notices.find(function (n) { - return n.id == id; - }))); - if (Notice$1.classes.lampa.notices.find(function (n) { - return n.id == id; - })) return; - var codes = Arrays.getKeys(Lang.codes()); - network.silent(TMDB$1.api(id + '?append_to_response=translations,credits&language=' + Storage.get('language', 'ru') + '&api_key=' + TMDB$1.key()), function (movie) { - network.silent(TMDB$1.api(id + '/images?include_image_language=' + codes.join(',') + '&language=' + Storage.get('language', 'ru') + '&api_key=' + TMDB$1.key()), function (images) { - var card = Arrays.clone(movie); - console.log('Premiere', 'card loaded', card); - delete card.translations; - delete card.credits; - delete card.credits; - delete card.spoken_languages; - delete card.production_companies; - delete card.production_countries; - var notice = { - id: id, - from: 'cub', - title: {}, - text: {}, - time: Date.now(), - poster: {}, - card: card - }; - movie.translations.translations.filter(function (t) { - return codes.indexOf(t.iso_639_1) >= 0; - }).forEach(function (t) { - notice.title[t.iso_639_1] = Lang.translate('premiere_title') + ': ' + (t.data.title || t.data.name || movie.title || movie.name); - notice.text[t.iso_639_1] = (t.data.overview || movie.overview || '').slice(0, 130) + '...'; - }); - images.posters.forEach(function (i) { - notice.poster[i.iso_639_1] = i.file_path; - }); - - if (movie.credits && movie.credits.cast) { - var casts = movie.credits.cast.filter(function (c) { - return c.known_for_department.toLowerCase() == 'acting'; - }); - - if (casts.length) { - notice.author = {}; - codes.forEach(function (c) { - notice.author[c] = { - name: casts[0].name || casts[0].character, - img: casts[0].profile_path, - text: Lang.translate('premiere_author_recomend_' + (Math.floor(Math.random() * 5) + 1)) - }; - }); - } - } - - Notice$1.pushNotice('lampa', notice, function () { - console.log('Premiere', 'card added'); - }, function (er) { - console.log('Premiere', 'card added error:', er); - }); - }); - }); - } - - var Premiere = { - init: init$5 - }; - - var BotClass = /*#__PURE__*/function () { - function BotClass(params) { - _classCallCheck(this, BotClass); - - this.params = params; - this.build(); - this.image(); - } - - _createClass(BotClass, [{ - key: "build", - value: function build() { - var _this = this; - - this.card = Template$1.js('ad_bot'); - this.img = this.card.querySelector('.ad-bot__img') || {}; - this.card.querySelector('.ad-bot__title').innerText = this.params.title; - this.card.querySelector('.ad-bot__text').innerText = this.params.text; - this.card.querySelector('.ad-bot__more').innerText = Lang.translate('full_detail'); - this.card.querySelector('.ad-bot__info').innerText = Lang.translate('ad_disable'); - this.card.addEventListener('hover:enter', function () { - var tpl = Template$1.get('cub_premium'); - tpl.find('.cub-premium__title').text(Lang.translate('title_notice')); - tpl.find('.cub-premium__descr').eq(0).empty().text(Lang.translate('ad_notice_' + _this.params.type)); - Modal.open({ - title: '', - size: 'medium', - mask: true, - html: tpl, - onBack: function onBack() { - Modal.close(); - Controller.toggle('content'); - } - }); - }); - this.visible(); - } - }, { - key: "image", - value: function image() { - var _this2 = this; - - this.img.onload = function () { - _this2.card.classList.add('img--loaded'); - }; - - this.img.onerror = function () { - TMDB$1.broken(); - console.log('Img', 'noload', _this2.img.src); - _this2.img.src = './img/img_broken.svg'; - }; - } - }, { - key: "visible", - value: function visible() { - if (this.params.poster) this.img.src = Api.img(this.params.poster);else if (this.params.img) this.img.src = this.params.img;else this.img.src = './img/img_broken.svg'; - } - }, { - key: "destroy", - value: function destroy() { - this.img.onerror = function () {}; - - this.img.onload = function () {}; - - this.img.src = ''; - this.card.remove(); - this.card = null; - this.img = null; - } - }, { - key: "render", - value: function render(js) { - return js ? this.card : $(this.card); - } - }]); - - return BotClass; - }(); - - function init$4() { - if (Account.logged() && Lang.selected(['ru', 'uk', 'be', 'bg'])) { - var user = Storage.get('account_user', '{}'); - if (user.premium && !Account.hasPremium()) setTimeout(push, 5000); - } - } - - function push() { - var id = 'extend_premium'; - if (Notice$1.classes.lampa.notices.find(function (n) { - return n.id == id; - })) return; - var notice = { - id: id, - from: 'cub', - title: { - ru: 'Продлите CUB Premium прямо сейчас!', - uk: 'Продовжіть CUB Premium прямо зараз!', - be: 'Працягнеце CUB Premium прама зараз!', - bg: 'Подновете CUB Premium точно сега!' - }, - text: { - ru: 'Ваша подписка на CUB Premium истекла! Не упустите шанс продлить доступ к эксклюзивному контенту и дополнительным функциям. Обновите премиум-статус сейчас и наслаждайтесь всеми преимуществами CUB без ограничений!', - uk: 'Ваша передплата на CUB Premium закінчилася! Не пропустіть шанс продовжити доступ до ексклюзивного контенту та додаткових функцій. Оновіть преміум-статус зараз та насолоджуйтесь усіма перевагами CUB без обмежень!', - be: 'Ваша падпіска на CUB Premium скончылася! Не выпусціце шанец падоўжыць доступ да эксклюзіўнага кантэнту і дадатковым функцый. Абнавіце прэміум-статус зараз і атрымлівайце асалоду ад усімі перавагамі CUB без абмежаванняў!', - bg: 'Вашият абонамент за CUB Premium е изтекъл! Не пропускайте шанса си да подновите достъпа си до ексклузивно съдържание и допълнителни функции. Надстройте до премиум статус сега и се насладете на всички предимства на CUB без ограничения!' - }, - time: Date.now(), - icon: 'https://' + object$2.cub_domain + '/img/icons/premium_two.svg' - }; - Notice$1.pushNotice('lampa', notice, function () {}, function (er) {}); - } - - var Extend = { - init: init$4 - }; - - function init$3() { - Lang.add({ - ad_notice_tv_text_1: { - ru: 'Будьте в курсе новых серий - получайте уведомления о переводах на свой смартфон!', - uk: 'Будьте в курсі нових серій - отримуйте сповіщення про переклади на свій смартфон!', - be: 'Будзьце ў курсе новых серый - атрымлівайце апавяшчэння аб перакладах на свой смартфон!', - bg: 'Бъдете в час с новите серии - получавайте уведомление за преводите на своят смартфон!' - }, - ad_notice_tv_text_2: { - ru: 'Никогда не пропускайте новую серию - получайте уведомления о переводах на свой смартфон!', - uk: 'Ніколи не пропускайте нову серію - отримуйте сповіщення про переклади на свій смартфон!', - be: 'Ніколі не прапускайце новую серыю - атрымлівайце апавяшчэння аб перакладах на свой смартфон!', - bg: 'Бъдете в час с новите серии - получавайте уведомление за преводите на своят смартфон!' - }, - ad_notice_tv_text_3: { - ru: 'Оставайтесь в центре событий - получайте уведомления о переводах новых серий на свой смартфон!', - uk: 'Залишайтесь у центрі подій - отримуйте повідомлення про переведення нових серій на свій смартфон!', - be: 'Заставайцеся ў цэнтры падзей - атрымлівайце апавяшчэння аб перакладах новых серый на свой смартфон!', - bg: 'Бъдете в центъра на събитията - получавайте уведомление за преводите на новите серии на своят смартфон!' - }, - ad_notice_tv_text_4: { - ru: 'Будьте первыми, кто узнает о переводах новых серий - получайте уведомления на свой смартфон!', - uk: 'Будьте першими, хто дізнається про переклади нових серій – отримуйте повідомлення на свій смартфон!', - be: 'Будзьце першымі, хто даведаецца аб перакладах новых серый - атрымлівайце апавяшчэння на свой смартфон!', - bg: 'Бъдете първи, за да узнаете за превода на нови серии - получавайте уведомление на своят смартфон!' - }, - ad_notice_tv_text_5: { - ru: 'Не пропустите ни одной новой серии - получайте уведомления о переводах на свой смартфон и смотрите сериалы в любимом переводе!', - uk: 'Не пропустіть жодної нової серії – отримуйте повідомлення про переклади на свій смартфон та дивіться серіали у улюбленому перекладі!', - be: 'Не прапусціце ніводнай новай серыі - атрымлівайце апавяшчэнні аб перакладах на свой смартфон і глядзіце серыялы ў любімым перакладзе!', - bg: 'Не пропускайте нито една серия - получавайте уведомление за преводите на своят смартфон и гледайте сериалите с желаният превод!' - }, - ad_notice_tv: { - ru: 'Получение уведомлений о переводе сериала на свой смартфон - это удобный способ всегда оставаться в курсе и не пропустить ни одной серии. Вы больше не будете терять время на поиски новых серий и следить за релизами вручную. Просто подпишитесь на перевод и получайте уведомления о выходе новых серий на свой смартфон. Это сэкономит вам время и сделает просмотр сериалов еще более комфортным.', - uk: 'Отримання повідомлень про переведення серіалу на свій смартфон – це зручний спосіб завжди залишатися в курсі та не пропустити жодної серії. Ви більше не будете гаяти час на пошуки нових серій і стежити за релізами вручну. Просто підпишіться на переклад та отримуйте повідомлення про вихід нових серій на свій смартфон. Це заощадить вам час і зробить перегляд серіалів ще комфортнішим.', - be: 'Атрыманне апавяшчэнняў аб пераводзе серыяла на свой смартфон - гэта зручны спосаб заўсёды заставацца ў курсе і не прапусціць ніводнай серыі. Вы больш не будзеце марнаваць час на пошукі новых серый і сачыць за рэлізамі ўручную. Проста падпішыцеся на пераклад і атрымлівайце апавяшчэнні аб выхадзе новых серый на свой смартфон. Гэта зэканоміць вам час і зробіць прагляд серыялаў яшчэ камфортнейшым.', - bg: 'Получавайте уведомление за преведени сериали на своят смартфон - това е удобен начин винаги да си в час и да не пропуснеш нито една серия. Повече няма да губите време в търсене на нови излъчени серии. Това ще спести времето ви и ще направи прегледа на сериали още по-комфортно' - }, - ad_bot_tv_title: { - ru: 'Уведомления на вашем смартфоне', - uk: 'Сповіщення на вашому смартфоні', - be: 'Апавешчанні на вашым смартфоне', - bg: 'Известия на вашия смартфон' - }, - ad_bot_tv_text: { - ru: 'Будьте в курсе самых ожидаемых моментов! Теперь вы можете получать мгновенные уведомления о выходе новых серий и фильмов прямо на свой смартфон.', - uk: 'Будьте в курсі найочікуваніших моментів! Тепер ви можете отримувати миттєві сповіщення про виход нових серіалів і фільмів прямо на свій смартфон.', - be: 'Будзьце ў курсе самых чаканых момантаў! Цяпер вы можаце атрымліваць хуткія апавешчанні аб выходзе новых сэрыяў і фільмаў проста на свой смартфон.', - bg: 'Бъдете в течение на най-очакваните моменти! Сега можете да получавате мигновени известия за излизането на нови серии и филми директно на вашия смартфон.' - } - }); - Lampa.Listener.follow('line', function (event) { - if (event.type == 'create' && event.data.ad && !Account.hasPremium() && Lang.selected(['ru', 'uk', 'be', 'bg']) && !Personal.confirm()) { - var item; - - if (event.data.ad == 'bot') { - item = new BotClass({ - card: event.data.results[0], - type: event.data.type, - title: Lang.translate('ad_bot_tv_title'), - text: Lang.translate('ad_bot_tv_text'), - poster: event.data.results[0].poster_path - }); - } else { - item = new Watched({ - card: event.data.results[0], - type: event.data.type - }); - } - - item.render(true).on('hover:focus', function (e) { - event.scroll.update(e.target); - }); - event.items.push(item); - event.scroll.append(item.render(true)); - } - }); - Premiere.init(); - Extend.init(); - Preroll.init(); - } - - var AdManager = { - init: init$3 - }; - - function init$2() { - if (Platform.screen('mobile')) { - var bar = Template$1.get('navigation_bar', {}); - bar.find('.navigation-bar__item').on('click', function () { - var action = $(this).data('action'); - if (action == 'back') window.history.back();else if (action == 'main') { - Activity$1.push({ - url: '', - title: Lang.translate('title_main') + ' - ' + Storage.field('source').toUpperCase(), - component: 'main', - source: Storage.field('source') - }); - } else if (action == 'search') { - Lampa.Search.open(); - } else if (action == 'settings') { - Controller.toggle('settings'); - } - }); - $('body').append(bar); - } - } - - var NavigationBar = { - init: init$2 - }; - - function Endless(onRender) { - var _this = this; - - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var wrap = document.createElement('div'); - var position = params.position || 0; - wrap.addClass('endless'); - wrap.addEventListener('mousewheel', function (e) { - _this.move(e.wheelDelta / 120 > 0 ? -1 : 1); - }); - var touch; - - var touchStart = function touchStart(e) { - var point = e.touches[0] || e.changedTouches[0]; - touch = { - position: position, - from: point.clientY, - to: 0 - }; - window.addEventListener('touchend', touchEnd); - window.addEventListener('touchmove', touchMove); - }; - - var touchMove = function touchMove(e) { - var point = e.touches[0] || e.changedTouches[0]; - - if (touch) { - var to = Math.round((point.clientY - touch.from) / (window.innerHeight * 0.1)); - - if (touch.to !== to) { - var move = touch.position - to; - touchEnd(); - - _this.to(move); - } - } - }; - - var touchEnd = function touchEnd(e) { - window.removeEventListener('touchend', touchEnd); - window.removeEventListener('touchmove', touchMove); - touch = false; - }; - - wrap.addEventListener('touchstart', touchStart); - - this.move = function (dir) { - var dif = position - (position + dir); - position += dir; - this.draw(dif); - }; - - this.to = function (to) { - var dif = position - to; - position = to; - this.draw(dif); - }; - - this.draw = function (dif) { - var render = onRender(position); - - if (render) { - wrap.removeClass('endless-up endless-down'); - wrap.style.animation = 'none'; - wrap.offsetHeight; - wrap.style.animation = null; - wrap.empty().append(render); - wrap.addClass(dif == -1 ? 'endless-down' : 'endless-up'); - } - }; - - this.render = function () { - return wrap; - }; - - this.destroy = function () { - wrap.remove(); - }; - - this.draw(0); - } - - function hide() { - Settings.listener.follow('open', function (e) { - if (e.name == 'main') { - e.body.find(['player', 'account', 'parser', 'server', 'plugins'].map(function (a) { - return '[data-component="' + a + '"]'; - }).join(', ')).addClass('hide'); - } else { - e.body.find(['start_page', 'card_quality', 'card_episodes', 'proxy_tmdb_auto', 'proxy_tmdb', 'tmdb_proxy_api', 'tmdb_proxy_image', 'card_interfice_type', 'source'].map(function (a) { - return '[data-name="' + a + '"]'; - }).join(', ')).addClass('hide'); - } - }); - var head = $('.head'); - var menu = $('.menu'); - $('.open--broadcast, .open--search,.open--notice,.open--premium', head).remove(); - $(['catalog', 'feed', 'filter', 'relise', 'anime', 'favorite', 'subscribes', 'timetable', 'mytorrents', 'console', 'about'].map(function (a) { - return '[data-action="' + a + '"]'; - }).join(', '), menu).remove(); - Arrays.remove(TMDB.genres.movie, TMDB.genres.movie.find(function (g) { - return g.id == 99; - })); - var genres_id = [99, 10764, 10766, 10767, 10768, 10763]; - genres_id.forEach(function (id) { - Arrays.remove(TMDB.genres.tv, TMDB.genres.tv.find(function (g) { - return g.id == id; - })); - }); - Lampa.Listener.follow('full', function (e) { - if (e.type == 'complite') { - e.object.activity.render().find('.full-start-new__buttons, .full-start__icons, .full-start__footer').remove(); - } - }); - } - - function init$1() { - if (window.lampa_settings.demo) { - Lampa.Listener.follow('app', function (e) { - if (e.type == 'ready') hide(); - }); - } - } - - var Demo = { - init: init$1 - }; - - var html$1; - var tout; - var xmlHTTP; - var controll; - var active = {}; - var graph = []; - - function init() { - Settings.listener.follow('open', function (e) { - if (e.name == 'server') { - var btn = $("
    \n
    ".concat(Lang.translate('speedtest_button'), "
    \n
    ")); - btn.on('hover:enter', function () { - if (Torserver.ip()) { - var params = { - url: Torserver.url() + '/download/300' - }; - - if (Storage.field('torrserver_auth')) { - params.login = Storage.get('torrserver_login'); - params.password = Storage.get('torrserver_password'); - } - - start(params); - } - }); - $('[data-name="torrserver_url_two"]', e.body).after(btn); - } - }); - } - - function start(params) { - if (html$1) html$1.remove(); - active = params; - controll = Controller.enabled().name; - html$1 = Template$1.js('speedtest'); - html$1.append(HeadBackward('', true)); - document.body.append(html$1); - var textpath = Array.from(html$1.querySelectorAll('textpath')); - textpath.forEach(function (element) { - element.html(element.getAttribute('data-text')); - }); - html$1.find('#speedtest_num-text').html('Mbps'); - toggle(); - if (active.url) testUrl(active.url); - } - - function speed2deg(v) { - v = parseFloat(v); - return v >= 1000 ? 200 : v < 20 ? v * 4 : v < 30 ? (v - 20) * 2 + 80 : v < 60 ? (v - 30) / 1.5 + 100 : v < 100 ? (v - 60) / 2 + 120 : v < 200 ? (v - 100) / 5 + 140 : v < 500 ? (v - 200) / 15 + 160 : (v - 500) / 25 + 180; - } - - function hslToRgb(hue, sat, light) { - hue = hue % 360, hue += hue < 0 ? hue += 360 : 0, sat /= 100, light /= 100; - - function f(n) { - var k = (n + hue / 30) % 12; - var a = sat * Math.min(light, 1 - light); - return parseInt((light - a * Math.max(-1, Math.min(k - 3, 9 - k, 1))) * 255); - } - - return "#" + ((1 << 24) + (f(0) << 16) + (f(8) << 8) + f(4)).toString(16).slice(1); - } - - function setSpeed(v) { - v = parseFloat(v); - html$1.find('#speedtest_num').innerHTML = v < 1 ? v.toFixed(3) : v < 10 ? v.toFixed(2) : v < 100 ? v.toFixed(1) : Math.round(v); - var r = speed2deg(v); - var b = html$1.find('#speedtest_progress'); - var l = 1256.8; - b.style['stroke-dasharray'] = l * r / 360 + ',' + l; - b.style.stroke = hslToRgb(330 + r, 80, 45); - html$1.find('#speedtest_graph').setAttribute('points', graph.map(function (pt) { - return pt.join(','); - }).join(' ')); - } - - function normalizeUrl(base, link) { - if (link[0] === '/') return base.replace(/^(https?:\/\/[^\/]+).*$/i, '$1') + link; - if (/^https?:?\/\//i.test(link)) return link; - base = base.replace(/\/[^\/]*(\?.*)?$/, '') + '/'; - return base + link; - } - - function testUrl(url) { - if (!/\.m3u8?(\?.*)?$/i.test(url)) return testSpeed(url); - - var errorFn = function errorFn(e) { - html$1.find('#speedtest_status').html(Lang.translate('network_error')); - }; - - xmlHTTP = new XMLHttpRequest(); - $.ajax({ - url: url, - cache: false, - dataType: 'text', - xhr: function xhr() { - return xmlHTTP; - }, - success: function success(data) { - if (data.substr(0, 7) !== '#EXTM3U') return errorFn(); - var i = 0, - links = [], - bandwidth = 0, - setLink = false, - m, - l = data.split(/\r?\n/); - data = null; - - for (; links.length < 100 && i < l.length; i++) { - if (!!(m = l[i].match(/^#EXTINF:\s*(-?\d+(\.\d*)?)\s*,.*$/))) { - setLink = true; - } else if (!!(m = l[i].match(/^#EXT-X-STREAM-INF:(.+,)?\s*BANDWIDTH=(\d+)\s*(,.+)?$/))) { - if (bandwidth < parseInt(m[2])) { - bandwidth = parseInt(m[2]); - setLink = true; - } else setLink = false; - } else if (setLink && !!(m = l[i].match(/^[^#].+$/i))) { - links.push(normalizeUrl(xmlHTTP.responseURL, m[0].trim())); - setLink = false; - } - } - - if (links.length === 0) return errorFn(); - if (bandwidth > 0) return testUrl(links.pop()); - testSpeed(links[0]); - }, - error: errorFn - }); - } - - function testSpeed(url) { - var context = this; - var status = html$1.find('#speedtest_status'); - var time; - status.innerHTML = Lang.translate('speedtest_connect'); - graph = [[-250, -250]]; - var speed = 0, - speedMbps = 0; - setSpeed(0); - xmlHTTP = new XMLHttpRequest(); - xmlHTTP.open('GET', Utils$2.addUrlComponent(url, 'vr=' + new Date() * 1), true); - if (active.login && active.password) xmlHTTP.setRequestHeader("Authorization", "Basic " + Base64.encode(active.login + ":" + active.password)); - xmlHTTP.responseType = 'arraybuffer'; - - xmlHTTP.onprogress = function (e) { - if (!time || time === true) return; - var load = e.timeStamp - time; - speed = Math.ceil(e.loaded * 8000 / load); // Бит в секунду - - speedMbps = speed / 1000 / 1000; - var x = Math.max(Math.min(load, 1e4) * 500 / 1e4, Math.min(e.loaded, 3e8) * 500 / 3e8) - 250, - y = -(speed2deg(speedMbps) / 4 + 250); - graph.push([x.toFixed(1), y.toFixed(1)]); - setSpeed(speedMbps); - if (load >= 1e4 || e.loaded > 3e8) xmlHTTP.abort(); - }; - - xmlHTTP.onreadystatechange = function (e) { - if (xmlHTTP.readyState === 2) { - time = e.timeStamp; - status.innerHTML = Lang.translate('speedtest_test'); - tout = setTimeout(function () { - xmlHTTP.abort(); - }, 15e3); - } - }; - - var endTest = function endTest(e) { - clearTimeout(tout); - setSpeed(speedMbps); - status.innerHTML = Lang.translate('speedtest_ready'); - time = false; - if (typeof active.onEnd === 'function') active.onEnd.apply(context, [speedMbps, xmlHTTP]); - }; - - xmlHTTP.onload = endTest; - xmlHTTP.onabort = endTest; - xmlHTTP.onerror = endTest; - xmlHTTP.send(); - } - - function toggle() { - Controller.add('speedtest', { - toggle: function toggle() { - Controller.clear(); - }, - back: close - }); - Controller.toggle('speedtest'); - } - - function close() { - if (xmlHTTP) xmlHTTP.abort(); - clearTimeout(tout); - html$1.remove(); - html$1 = false; - xmlHTTP = false; - if (active.onBack) active.onBack();else Controller.toggle(controll); - active = {}; - } - - var Speedtest = { - init: init, - close: close, - start: start - }; - - /** - * Настройки движка - */ - - if (typeof window.lampa_settings == 'undefined') { - window.lampa_settings = {}; - } - - var appletv = navigator.userAgent.toLowerCase().indexOf("ipad") > -1 && window.innerWidth == 1920 && window.innerHeight == 1080; - Arrays.extend(window.lampa_settings, { - socket_use: true, - socket_url: 'wss://cub.red:8010', - socket_methods: true, - account_use: true, - account_sync: true, - plugins_use: true, - plugins_store: true, - torrents_use: appletv ? false : true, - white_use: false, - lang_use: true, - read_only: false, - dcma: false, - push_state: true - }); - /** - * Для вебось маркета и других маркетов, демо режим, задрали черти. - */ - //window.lampa_settings.demo = window.lampa_settings.white_use && typeof webOS !== 'undefined' && webOS.platform.tv === true - - if (window.localStorage.getItem('remove_white_and_demo')) { - window.lampa_settings.demo = false; - window.lampa_settings.white_use = false; - } - - window.Lampa = { - Listener: start$8(), - Lang: Lang, - Subscribe: start$8, - Storage: Storage, - Platform: Platform, - Utils: Utils$2, - Params: Params, - Menu: Menu, - Head: Head, - Notice: Notice$1, - NoticeClass: NoticeClass, - NoticeClassLampa: NoticeLampa, - Background: Background, - Favorite: Favorite, - Select: Select, - Controller: Controller, - Activity: Activity$1, - Keypad: Keypad, - Template: Template$1, - Component: Component, - Reguest: create$p, - Filter: create$5, - Files: create$1, - Explorer: Explorer, - Scroll: create$q, - Empty: create$a, - Arrays: Arrays, - Noty: Noty, - Player: Player, - PlayerVideo: PlayerVideo, - PlayerInfo: PlayerInfo, - PlayerPanel: PlayerPanel, - PlayerIPTV: PlayerIPTV, - PlayerPlaylist: PlayerPlaylist, - Timeline: Timeline, - Modal: Modal, - Api: Api, - Cloud: Cloud, - Settings: Settings, - SettingsApi: SettingsApi, - Android: Android, - Card: Card, - Info: create, - Account: Account, - Socket: Socket, - Input: Input, - Screensaver: Screensaver$2, - Recomends: Recomends, - VideoQuality: VideoQuality, - TimeTable: TimeTable, - Broadcast: Broadcast, - Helper: Helper, - InteractionMain: component, - InteractionCategory: component$i, - InteractionLine: create$h, - Status: status$2, - Plugins: Plugins, - Extensions: Extensions, - Tizen: Tizen, - Layer: Layer, - Console: Console, - Iframe: Iframe, - Parser: Parser, - Manifest: object$2, - TMDB: TMDB$1, - Base64: Base64, - Loading: Loading, - YouTube: YouTube, - WebOSLauncher: WebOSLauncher, - Event: Event, - Search: Search, - DeviceInput: DeviceInput, - Worker: AppWorker, - DB: IndexedDB, - NavigationBar: NavigationBar, - Endless: Endless, - Color: Color, - Cache: Cache, - Torrent: Torrent, - Torserver: Torserver, - Speedtest: Speedtest, - Processing: Processing, - ParentalControl: ParentalControl, - VPN: VPN - }; - - function closeApp() { - if (Platform.is('apple_tv')) window.location.assign('exit://exit'); - if (Platform.is('tizen')) tizen.application.getCurrentApplication().exit(); - if (Platform.is('webos') && typeof window.close == 'function') window.close(); - if (Platform.is('android')) Android.exit(); - if (Platform.is('orsay')) Orsay.exit(); - if (Platform.is('netcast')) window.NetCastBack(); - } - - function popupCloseApp() { - var controller = Controller.enabled().name; - Modal.open({ - title: '', - align: 'center', - zIndex: 300, - html: $('
    ' + Lang.translate('close_app_modal') + '
    '), - buttons: [{ - name: Lang.translate('settings_param_no'), - onSelect: function onSelect() { - Modal.close(); - Controller.toggle(controller); - } - }, { - name: Lang.translate('settings_param_yes'), - onSelect: function onSelect() { - Modal.close(); - Controller.toggle(controller); - closeApp(); - } - }] - }); - } - - function prepareApp() { - if (window.prepared_app) return; - $('body').append(Noty.render()); - DeviceInput.init(); - Platform.init(); - Params.init(); - Controller.observe(); - Console.init(); - Keypad.init(); - Layer.init(); - Storage.init(); - /** Передаем фокус в контроллер */ - - Navigator.follow('focus', function (event) { - Controller.focus(event.elem); - }); - /** Выход в начальном скрине */ - - Keypad.listener.follow('keydown', function (e) { - if (window.appready || Controller.enabled().name == 'modal') return; - if (e.code == 8 || e.code == 27 || e.code == 461 || e.code == 10009 || e.code == 88) popupCloseApp(); - }); - /** Отключаем правый клик */ - - if (window.innerWidth > 1280) window.addEventListener("contextmenu", function (e) { - return e.preventDefault(); - }); - /** Если это тач дивайс */ - - if (!Platform.screen('tv')) $('body').addClass('touch-device'); - /** Start - для orsay одни стили, для других другие */ - - var old_css = $('link[href="css/app.css"]'); - - if (Platform.is('orsay')) { - var urlStyle = 'http://lampa.mx/css/app.css?v'; //Для нового типа виджета берем сохраненный адрес загрузки - - if (Orsay.isNewWidget()) { - //Для фрейм загрузчика запишем полный url - if (location.protocol != 'file:') { - var newloaderUrl = location.href.replace(/[^/]*$/, ''); - - if (newloaderUrl.slice(-1) == '/') { - newloaderUrl = newloaderUrl.substring(0, newloaderUrl.length - 1); - } - - if (Orsay.getLoaderUrl() != newloaderUrl) { - Orsay.setLoaderUrl(newloaderUrl); - } - } - - console.log('Loader', 'start url: ', Orsay.getLoaderUrl()); - urlStyle = Orsay.getLoaderUrl() + '/css/app.css?v'; - } - - Utils$2.putStyle([urlStyle + object$2.css_version], function () { - old_css.remove(); - }); - } else if (old_css.length) { - Utils$2.putStyle(['https://yumata.github.io/lampa/css/app.css?v' + object$2.css_version], function () { - old_css.remove(); - }); - } - - Layer.update(); - window.prepared_app = true; - } - - function developerApp(proceed) { - var expect = true; - var pressed = 0; - var timer = setTimeout(function () { - expect = false; - proceed(); - }, 1000); - - var check = function check() { - pressed++; - - if (pressed === 3) { - clearTimeout(timer); - expect = false; - Keypad.enable(); - Developer.open(function () { - Keypad.disable(); - proceed(); - }); - console.log('Developer mode', 'on'); - } - }; - - var keydown = function keydown(event) { - if (expect) { - if (event.keyCode === 38 || event.keyCode === 29460 || event.keyCode === 50400012) check(); - } else { - document.removeEventListener('keydown', keydown); - } - }; - - $('.welcome').on('click', function (e) { - if (expect && DeviceInput.canClick(e.originalEvent)) check(); - }); - window.addEventListener("keydown", keydown); - } - - function startApp() { - var _this = this; - - if (window.appready) return; - var start_time = 0; - /** Стартуем */ - - Lampa.Listener.send('app', { - type: 'start' - }); - /** Инициализируем классы */ - - Personal.init(); - Settings.init(); - Select.init(); - Favorite.init(); - Background.init(); - Head.init(); - Notice$1.init(); - Menu.init(); - Activity$1.init(); - Screensaver$2.init(); - Cloud.init(); - Socket.init(); - Account.init(); - Extensions.init(); - Plugins.init(); - Recomends.init(); - TimeTable.init(); - Helper.init(); - Tizen.init(); - Player.init(); - Iframe.init(); - Parser.init(); - WebOSLauncher.init(); - Theme$2.init(); - AdManager.init(); - NavigationBar.init(); - Demo.init(); - Speedtest.init(); - VPN.init(); - Processing.init(); - ParentalControl.init(); - /** Надо зачиcтить, не хорошо светить пароль ;) */ - - Storage.set('account_password', ''); - /** Чтоб не писали по 100 раз */ - - Storage.set('parser_torrent_type', Storage.get('parser_torrent_type') || 'jackett'); - /** Инфа */ - - var ratio = window.devicePixelRatio || 1; - console.log('App', 'screen size:', window.innerWidth * ratio + ' / ' + window.innerHeight * ratio); - console.log('App', 'interface size:', window.innerWidth + ' / ' + window.innerHeight); - console.log('App', 'pixel ratio:', window.devicePixelRatio); - console.log('App', 'user agent:', navigator.userAgent); - console.log('App', 'is tv:', Platform.screen('tv')); - console.log('App', 'is mobile:', Platform.screen('mobile')); - console.log('App', 'is touch:', Utils$2.isTouchDevice()); - console.log('App', 'is PWA:', Utils$2.isPWA()); - console.log('App', 'platform:', Storage.get('platform', 'noname')); - /** Выход из приложения */ - - Activity$1.listener.follow('backward', function (event) { - if (!start_time) start_time = Date.now(); - - if (event.count == 1 && Date.now() > start_time + 1000 * 2) { - var enabled = Controller.enabled(); - Select.show({ - title: Lang.translate('title_out'), - items: [{ - title: Lang.translate('title_out_confirm'), - out: true - }, { - title: Lang.translate('cancel') - }], - onSelect: function onSelect(a) { - if (a.out) { - Activity$1.out(); - Controller.toggle(enabled.name); - closeApp(); - } else { - Controller.toggle(enabled.name); - } - }, - onBack: function onBack() { - Controller.toggle(enabled.name); - } - }); - } - }); - /** Ренедрим лампу */ - - Render.app(); - /** Проверяем уведомления */ - - Notice$1.drawCount(); - /** Обновляем слои */ - - Layer.update(); - /** Активируем последнию активность */ - - setTimeout(Activity$1.last.bind(Activity$1), 500); - /** Гасим свет :D */ - - setTimeout(function () { - Keypad.enable(); - Screensaver$2.enable(); - $('.welcome').fadeOut(500, function () { - $(_this).remove(); - }); - }, 1000); - /** End */ - - /** Start - если это андроид */ - - if (Platform.is('android')) { - Params.listener.follow('button', function (e) { - if (e.name === 'reset_player') { - Android.resetDefaultPlayer(); - } - }); - Favorite.listener.follow('add,added,remove', function (e) { - Android.updateChannel(e.where); - }); - } - /** End */ - - /** Start - записываем популярные фильмы */ - - - Favorite.listener.follow('add,added', function (e) { - if (e.where == 'history' && e.card.id) { - $.get(Utils$2.protocol() + 'tmdb.' + object$2.cub_domain + '/watch?id=' + e.card.id + '&cat=' + (e.card.original_name ? 'tv' : 'movie')); - } - }); - /** End */ - - /** Start - следим за переключением в лайт версию и обновляем интерфейс */ - - Storage.listener.follow('change', function (e) { - if (e.name == 'light_version') { - $('body').toggleClass('light--version', Storage.field('light_version')); - Layer.update(); - } - - if (e.name == 'keyboard_type') { - $('body').toggleClass('system--keyboard', Storage.field('keyboard_type') == 'lampa' ? false : true); - } - }); - /** End */ - - /** Start - проверка статуса для торрента */ - - var torrent_net = new create$p(); - - function check(name) { - if (Platform.is('android') && !Storage.field('internal_torrclient')) return; - var item = $('[data-name="' + name + '"]').find('.settings-param__status').removeClass('active error wait').addClass('wait'); - var url = Storage.get(name); - - if (url) { - torrent_net.timeout(10000); - var head = { - dataType: 'text' - }; - var auth = Storage.field('torrserver_auth'); - - if (auth) { - head.headers = { - Authorization: "Basic " + Base64.encode(Storage.get('torrserver_login') + ':' + Storage.get('torrserver_password')) - }; - } - - torrent_net["native"](Utils$2.checkEmptyUrl(Storage.get(name)), function () { - item.removeClass('wait').addClass('active'); - }, function (a, c) { - if (a.status == 401) { - item.removeClass('wait').addClass('active'); - Noty.show(Lang.translate('torrent_error_check_no_auth') + ' - ' + url, { - time: 5000 - }); - } else { - item.removeClass('wait').addClass('error'); - Noty.show(torrent_net.errorDecode(a, c) + ' - ' + url, { - time: 5000 - }); - } - }, false, head); - } - } - - Storage.listener.follow('change', function (e) { - if (e.name == 'torrserver_url') check(e.name); - if (e.name == 'torrserver_url_two') check(e.name); - if (e.name == 'torrserver_use_link') check(e.value == 'one' ? 'torrserver_url' : 'torrserver_url_two'); - }); - Settings.listener.follow('open', function (e) { - if (e.name == 'more' && window.location.protocol == 'https:') { - $('[data-name="protocol"]', e.body).remove(); - } - - if (e.name == 'server') { - var name = Storage.field('torrserver_use_link') == 'one' ? 'torrserver_url' : 'torrserver_url_two'; - check(name); - - if (!Account.hasPremium() && Lang.selected(['ru', 'be', 'uk']) && !Personal.confirm()) { - var ad = $("\n
    \n
    \n \u0410\u0440\u0435\u043D\u0434\u043E\u0432\u0430\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443 \u043D\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0435\u0437 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0438 \u0438 \u043D\u0430\u0441\u0442\u0440\u043E\u0435\u043A.\n
    \n \n
    \u0420\u0435\u043A\u043B\u0430\u043C\u0430 - https://tsarea.us
    \n
    \n "); - $('[data-name="torrserver_use_link"]', e.body).after(ad); - } - } else torrent_net.clear(); - - if (e.name == 'interface' && window.lampa_settings.lang_use) { - $('.settings-param:eq(0)', e.body).on('hover:enter', function () { - LangChoice.open(function (code) { - Modal.open({ - title: '', - html: $('
    ' + Lang.translate('settings_interface_lang_reload') + '
    '), - onBack: function onBack() { - window.location.reload(); - }, - onSelect: function onSelect() { - window.location.reload(); - } - }); - Storage.set('language', code, true); - Storage.set('tmdb_lang', code, true); - }, function () { - Controller.toggle('settings_component'); - }); - }).find('.settings-param__value').text(Lang.translate(Lang.codes()[Storage.get('language', 'ru')])); - } - }); - /** End */ - - /** Добавляем класс платформы */ - - $('body').addClass('platform--' + (Platform.get() || 'noname')); - /** Включаем лайт версию если было включено */ - - $('body').toggleClass('light--version', Storage.field('light_version')).toggleClass('system--keyboard', Storage.field('keyboard_type') == 'lampa' ? false : true); - /** Добавляем hls и dash плагин */ - - var video_libs = ['hls/hls.js', 'dash/dash.js']; - video_libs = video_libs.map(function (lib) { - return window.location.protocol == 'file:' ? 'https://yumata.github.io/lampa/vender/' + lib : './vender/' + lib; - }); - Utils$2.putScript(video_libs, function () {}); - /** Сообщаем о готовности */ - - Lampa.Listener.send('app', { - type: 'ready' - }); - /** Меню готово */ - - Menu.ready(); - /** Лампа полностью готова */ - - window.appready = true; - /** Start - активация режима GOD, жмем 🠔🠔 🠕🠕 🠖🠖 🠗🠗 */ - - var mask = [37, 37, 38, 38, 39, 39, 40, 40], - psdg = -1; - Keypad.listener.follow('keydown', function (e) { - if (e.code == 37 && psdg < 0) { - psdg = 0; - } - - if (psdg >= 0 && mask[psdg] == e.code) psdg++;else psdg = -1; - - if (psdg == 8) { - psdg = -1; - console.log('God', 'enabled'); - Noty.show('God enabled'); - window.god_enabled = true; - } - }); - /** Start - активация полной лампы, жмем 🠔🠔 🠕🠕 🠔🠔 🠕🠕 */ - - var mask_full = [37, 37, 38, 38, 37, 37, 38, 38], - psdg_full = -1; - Keypad.listener.follow('keydown', function (e) { - if (e.code == 37 && psdg_full < 0) { - psdg_full = 0; - } - - if (psdg_full >= 0 && mask_full[psdg_full] == e.code) psdg_full++;else psdg_full = -1; - - if (psdg_full == 8) { - psdg_full = -1; - Noty.show('Full enabled'); - window.localStorage.setItem('remove_white_and_demo', 'true'); - var controller = Controller.enabled().name; - Modal.open({ - title: '', - align: 'center', - zIndex: 300, - html: $('
    ' + Lang.translate('settings_interface_lang_reload') + '
    '), - buttons: [{ - name: Lang.translate('settings_param_no'), - onSelect: function onSelect() { - Modal.close(); - Controller.toggle(controller); - } - }, { - name: Lang.translate('settings_param_yes'), - onSelect: function onSelect() { - window.location.reload(); - } - }] - }); - } - }); - /** Быстрый доступ к закладкам через кнопки */ - - var color_keys = { - '406': 'history', - '405': 'wath', - '404': 'like', - '403': 'book' - }; - Keypad.listener.follow('keydown', function (e) { - if (!Player.opened()) { - if (color_keys[e.code]) { - var type = color_keys[e.code]; - Activity$1.push({ - url: '', - title: type == 'book' ? Lang.translate('title_book') : type == 'like' ? Lang.translate('title_like') : type == 'history' ? Lang.translate('title_history') : Lang.translate('title_wath'), - component: 'favorite', - type: type, - page: 1 - }); - } - } - }); - /** Обновление состояния карточек каждые 5 минут */ - - var last_card_update = Date.now(); - - var lets_card_update = function lets_card_update() { - if (last_card_update < Date.now() - 1000 * 60 * 5) { - last_card_update = Date.now(); - Activity$1.renderLayers(true).forEach(function (layer) { - var cards = Array.from(layer.querySelectorAll('.card')); - cards.forEach(function (card) { - Utils$2.trigger(card, 'update'); - }); - }); - } - }; - - setInterval(function () { - if (!Player.opened()) lets_card_update(); - }, 1000 * 60); - Player.listener.follow('destroy', function () { - setTimeout(lets_card_update, 1000); - }); - Lampa.Listener.follow('activity', function (e) { - if (e.type == 'archive' && e.object.activity) { - var cards = Array.from(e.object.activity.render(true).querySelectorAll('.card.focus')); - cards.forEach(function (card) { - Utils$2.trigger(card, 'update'); - }); - } - }); - - if (Platform.is('android') || Platform.is('browser') || Platform.is('apple_tv') || Platform.desktop()) { - Sound$1.add('hover', { - url: 'https://yumata.github.io/lampa/sound/hover.ogg' - }); - Sound$1.add('enter', { - url: 'https://yumata.github.io/lampa/sound/hover.ogg' - }); - } - /** End */ - - } - - function loadLang() { - var code = window.localStorage.getItem('language') || 'ru'; - - var call = function call() { - /** Принудительно стартовать */ - setTimeout(startApp, 1000 * 5); - /** Загружаем плагины и стартуем лампу */ - - Plugins.load(startApp); - }; - - if (['ru', 'en'].indexOf(code) >= 0) call();else { - $.ajax({ - url: (location.protocol == 'file:' || Platform.is('nw') ? 'https://yumata.github.io/lampa/' : './') + 'lang/' + code + '.js', - dataType: 'text', - timeout: 10000, - success: function success(data) { - var translate = {}; - - try { - eval((data + '').replace(/export default/g, 'translate = ').trim()); - } catch (e) {} - - Lang.AddTranslation(code, translate); - call(); - }, - error: call - }); - } - } - - function loadApp() { - prepareApp(); - - if (window.localStorage.getItem('language') || !window.lampa_settings.lang_use) { - developerApp(loadLang); - } else { - LangChoice.open(function (code) { - Storage.set('language', code, true); - Storage.set('tmdb_lang', code, true); - Keypad.disable(); - loadLang(); - }); - Keypad.enable(); - } - } - - if (navigator.userAgent.toLowerCase().indexOf('crosswalk') > -1) { - var checkReady = function checkReady() { - if (window.innerWidth > 0) loadApp();else { - setTimeout(checkReady, 100); - } - }; - - checkReady(); - } else loadApp(); - -})();