View file xmyx.ru/files/radio/mainRadioss.js

File size: 25.02Kb
if (function () {
        var e;

        function t() {
            e = {};
            for (var t = document.cookie.split(";"), a = /^[\s]*([^\s]+?)$/i, n = 0, o = t.length; o > n; n++) {
                var i = t[n].split("=");
                2 == i.length && (e[i[0].match(a)[1]] = unescape(i[1].match(a) ? i[1].match(a)[1] : ""))
            }
        }

        window.getCookie = function (a) {
            return t(), e[a]
        }, window.setCookie = function (e, t, a, n) {
            var o = window.locDomain, i = "";
            if (a) {
                var r = new Date;
                r.setTime(r.getTime() + 24 * a * 60 * 60 * 1e3), i = "; expires=" + r.toGMTString()
            }
            document.cookie = [e, "=", escape(t), i, "; path=/", o ? "; domain=." + o : "", n && "https:" == locProtocol ? "; secure" : ""].join("")
        }, window.clearCookie = function (e) {
            setCookie(e, null, -1)
        }
    }(), function (e, t) {
        var a = !1, n = [], o = function () {
            if (!a && (a = !0, e.htmlNode = geByTag1("html"), e.bodyNode = geByTag1("body"), n)) {
                for (var o = null; o = n.shift();) o.call(t);
                n = null
            }
        };
        t.addEventListener ? t.addEventListener("DOMContentLoaded", function () {
            t.removeEventListener("DOMContentLoaded", arguments.callee, !1), o()
        }, !1) : t.attachEvent && t.attachEvent("onreadystatechange", function () {
            "complete" === t.readyState && (t.detachEvent("onreadystatechange", arguments.callee), o())
        }), e.addEventListener ? e.addEventListener("load", o, !1) : e.attachEvent ? e.attachEvent("onload", o) : e.onload = o;

        function i(e) {
            a ? e.call(t) : n.push(e)
        }

        e.onDOMReady = i
    }(window, document), !window._ua) var _ua = navigator.userAgent.toLowerCase();
var browser = {
    version: (_ua.match(/.+(?:me|ox|on|rv|it|era|ie)[\/: ]([\d.]+)/) || [0, "0"])[1],
    opera: /opera/i.test(_ua),
    msie: /msie/i.test(_ua) && !/opera/i.test(_ua),
    msie6: /msie 6/i.test(_ua) && !/opera/i.test(_ua),
    msie7: /msie 7/i.test(_ua) && !/opera/i.test(_ua),
    msie8: /msie 8/i.test(_ua) && !/opera/i.test(_ua),
    msie9: /msie 9/i.test(_ua) && !/opera/i.test(_ua),
    mozilla: /firefox/i.test(_ua),
    chrome: /chrome/i.test(_ua),
    safari: !/chrome/i.test(_ua) && /webkit|safari|khtml/i.test(_ua),
    iphone: /iphone/i.test(_ua),
    ipod: /ipod/i.test(_ua),
    iphone4: /iphone.*OS 4/i.test(_ua),
    ipod4: /ipod.*OS 4/i.test(_ua),
    ipad: /ipad/i.test(_ua),
    ios: +(_ua.match(/.+(?:ipod|ipad|iphone.*os) ([\d.]+)_/i) || [0, 0])[1],
    android: /android/i.test(_ua),
    bada: /bada/i.test(_ua),
    opera_mini: /opera mini/i.test(_ua),
    uc_mini: /mobile safari.*ucbrowser/i.test(_ua),
    mobile: /iphone|ipod|ipad|opera mini|opera mobi|iemobile/i.test(_ua),
    msie_mobile: /iemobile/i.test(_ua),
    safari_mobile: /iphone|ipod|ipad/i.test(_ua),
    opera_mobile: /opera mini|opera mobi/i.test(_ua),
    mac: /mac/i.test(_ua)
}, mobPlatforms = {1: 1, 2: 1, 3: 1, 4: 1, 5: 1};
browser.desktop = (browser.opera || browser.msie || browser.mozilla || browser.chrome || browser.safari) && !browser.mobile;
var isTouch = "ontouchstart" in window;

function isArray(e) {
    return "[object Array]" === Object.prototype.toString.call(e)
}

function isObject(e) {
    return "[object Object]" === Object.prototype.toString.call(e)
}

function escapeRE(e) {
    return e ? e.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1") : ""
}

function htsc(e) {
    return e.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/\'/g, "&#39;").replace(/%/g, "&#37;")
}

function stripTags(e) {
    return e.replace(/<[^>]+>/g, "")
}

function timeNow() {
    return +new Date
}

function lsSet(e, t) {
    if ("undefined" != typeof t) try {
        return localStorage.setItem(e, JSON.stringify(t))
    } catch (a) {
    } else try {
        return localStorage.removeItem(e)
    } catch (a) {
    }
    return !1
}

function lsGet(e) {
    try {
        return JSON.parse(localStorage.getItem(e))
    } catch (t) {
    }
    return !1
}

function ssSet(e, t) {
    if ("undefined" != typeof t) try {
        return sessionStorage.setItem(e, JSON.stringify(t))
    } catch (a) {
    } else try {
        return sessionStorage.removeItem(e)
    } catch (a) {
    }
    return !1
}

function ssGet(e) {
    try {
        return JSON.parse(sessionStorage.getItem(e))
    } catch (t) {
    }
    return !1
}

function getValues(e) {
    if (!isArray(e)) return e.call ? e() : e;
    for (var t = [], a = 0, n = e.length; n > a; a++) t.push(getValues(e[a]));
    return t
}

function ce(e, t) {
    var n = document.createElement(e);
    return t && extend(n, t), n
}

function extend() {
    var e = Array.prototype.slice.call(arguments), t = e.shift();
    if (!e.length) return t;
    for (var a = 0, n = e.length; n > a; a++) for (var o in e[a]) "layerX" != o && "layerY" != o && (t[o] = e[a][o]);
    return t
}

function each(e, t) {
    if (!e) return e;
    if (isObject(e) || "undefined" == typeof e.length) {
        for (var a in e) if (e.hasOwnProperty(a) && t.call(e[a], a, e[a]) === !1) break
    } else for (var n = 0, o = e.length; o > n && t.call(e[n], n, e[n]) !== !1; n++) ;
    return e
}

var rf = function () {
    return !1
};

function addEvent(e, t, a) {
    if (e = ge(e), a = a || rf, e && 3 != e.nodeType && 8 != e.nodeType) {
        e.setInterval && e != window && (e = window);
        for (var t = t.split(" "), n = 0, o = t.length; o > n; n++) {
            var i = t[n];
            e.addEventListener ? e.addEventListener(i, a, !1) : e.attachEvent && e.attachEvent("on" + i, a)
        }
    }
}

function removeEvent(e, t, a) {
    if (e = ge(e), a = a || rf, e && 3 != e.nodeType && 8 != e.nodeType) for (var t = t.split(" "), n = 0, o = t.length; o > n; n++) {
        var i = t[n];
        e.removeEventListener ? e.removeEventListener(i, a, !1) : e.detachEvent && e.detachEvent("on" + i, a)
    }
}

function cancelEvent(e) {
    return (e = e || window.event) ? (e = e.originalEvent || e, e.preventDefault && e.preventDefault(), e.stopPropagation && e.stopPropagation(), e.cancelBubble = !0, e.returnValue = !1, !1) : !1
}

function se() {
    var e = [], t = Array.prototype.slice.call(arguments);
    return function (a, n) {
        if (a) if (a.apply) e.push(a); else if ("__clear" === a) if (n) {
            for (var o = 0, i = e.length; i > o; o++) if (e[o] === n) {
                e.splice(o, 1);
                break
            }
        } else e = []; else {
            var r = Array.prototype.slice.call(arguments);
            r.shift();
            for (var s = 0, i = e.length; i > s; s++) e[s].apply(window, getValues(t).concat(r))
        }
    }
}

function ge(e) {
    return "string" == typeof e ? document.getElementById(e) : e
}

function geByClass(e, t, a) {
    if (t = ge(t) || document, a = a || "*", t.getElementsByClassName) {
        var n = t.getElementsByClassName(e);
        if ("*" == a) return Array.prototype.slice.call(n);
        var o = [];
        a = a.toUpperCase();
        for (var i = 0, r = n.length; r > i; i++) n[i].tagName.toUpperCase() == a && o.push(n[i]);
        return o
    }
    for (var n = geByTag(a, t), o = [], s = new RegExp("(^|\\s)" + escapeRE(e) + "(\\s|$)"), i = 0, r = n.length; r > i; i++) s.test(n[i].className) && o.push(n[i]);
    return o
}

function geByClass1(e, t, a) {
    return geByClass(e, t, a)[0]
}

function gpeByClass(e, t) {
    if (t = ge(t), !t) return null;
    for (; t = t.parentNode;) if (hasClass(e, t)) return t;
    return null
}

function geByTag(e, t) {
    return (ge(t) || document).getElementsByTagName(e)
}

function geByTag1(e, t) {
    return geByTag(e, t)[0]
}

function remove(e) {
    return e = ge(e), e && e.parentNode ? e.parentNode.removeChild(e) : !1
}

function tag(e) {
    return e = ge(e), (e && e.tagName || "").toLowerCase()
}

function show(e) {
    var t = ge(e);
    t && (t.style.display = t.oldstyle || (hasClass("_ib", t) ? "inline-block" : hasClass("_i", t) || "span" == tag(t) ? "inline" : "block"))
}

function hide(e) {
    var t = ge(e);
    t && ("none" != t.style.display && (t.oldstyle = t.style.display), t.style.display = "none")
}

function val(e, t) {
    if (e = ge(e), !e) return "";
    var a = e.tagName.toLowerCase(), n = "input" == a || "textarea" == a || "select" == a,
        o = n && ("radio" == e.type || "checkbox" == e.type);
    return "undefined" == typeof t ? n ? o ? e.checked : e.value : e.innerHTML : void(n ? o ? e.checked = t : e.value = t : (e.innerHTML = t))
}

function attr(e, t, a) {
    return (e = ge(e)) ? "undefined" == typeof a ? "data-" == t.substr(0, 5) && e.dataset ? e.dataset[t.substr(5).replace(/-([a-z0-9])/, function (e, t) {
        return t.toUpperCase()
    })] || !1 : e.getAttribute && e.getAttribute(t) || !1 : a === !1 ? e.removeAttribute && e.removeAttribute(t) || !1 : void(e.setAttribute && e.setAttribute(t, a)) : void 0
}

function hasClass(e, t, a) {
    return (t = ge(t)) ? new RegExp("(^|\\s)" + (a ? e : escapeRE(e)) + "(\\s|$)").test(t.className) : void 0
}

function addClass(e, t) {
    (t = ge(t)) && !hasClass(e, t) && (t.className = (t.className ? t.className + " " : "") + e)
}

function removeClass(e, t, a) {
    (t = ge(t)) && hasClass(e, t, a) && (t.className = (t.className || "").replace(new RegExp("(^|\\s)" + (a ? e : escapeRE(e)) + "(\\s|$)"), function (e, t, a) {
        return t && a ? " " : ""
    }))
}

function getXY(e) {
    if (e = ge(e), !e) return [0, 0];
    var t = 0, a = 0;
    if (e.offsetParent) do t += e.offsetLeft, a += e.offsetTop; while (e = e.offsetParent);
    return [t, a]
}

function getX(e) {
    return getXY(e)[0]
}
var audio = function () {
    var e = !1, t = !1, a = !1, n = !1, o = function (t) {
            (e || n !== !1) && (e = !1, v && n === !1 || (a = !0, s.pause())), cancelEvent(t), removeEvent(s, "play", o), removeEvent(document, isTouch ? "touchstart" : "click", r);
        }, i = function () {
            n !== !1 && n();
        }, r = function () {
            t && (t = !1, e = !0, s.play(), removeEvent(document, isTouch ? "touchstart" : "click", r));
        }, s = b(), l = Math.random().toString(36).substr(2), c = [], u = null, d = {}, p = "", v = !1, f = !1, g = !1,
        h = !1, _ = null, m = !1, y = !1;

    function b(t) {
        var s = window.Audio ? new Audio : ce("audio");
        s.onerror = function(e){
            audio.next();
        };
        return s.autobuffer = !0, s.muted = !1, t && (s.volume = t.volume, removeEvent(t, "play", w), removeEvent(t, "pause", C), removeEvent(t, "progress", k), removeEvent(t, "timeupdate", x), removeEvent(t, "ended", S), removeEvent(t, "play", o), removeEvent(t, "progress canplaythrough", i), removeEvent(document, isTouch ? "touchstart" : "click", r), t.muted = !0, t.pause(), t.src = null), h = !1, f = !1, g = !1, e = !1, a = !1, n = !1, addEvent(s, "play", w), addEvent(s, "pause", C), addEvent(s, "progress",
            k), addEvent(s, "timeupdate", x), addEvent(s, "ended", S), addEvent(s, "play", o), addEvent(s, "progress canplaythrough", i), addEvent(document, isTouch ? "touchstart" : "click", r), s;
    }

    function w() {
        v || (v = !0, audio.onPlay(!0), ssSet("audio_play", "1"), clearTimeout(_), _ = setTimeout(E, 100));
    }

    function C() {
        return a ? void(a = !1) : void(v && (v = !1, audio.onPause(!0), ssSet("audio_play", "0"), clearTimeout(_)));
    }

    function k() {
        audio.onProgress(!0);
    }

    function x() {
        a || (audio.onProgress(!0), audio.onPositionChanged(!0, audio.position(), audio.duration()), ssSet("audio_pos", audio.position()), !h && s.duration - s.currentTime < .5 && (h = !0), f && (f = !1, audio.next()));
    }

    function S() {
        audio.onEnded(!0), h ? (h = !1, (repeat === true ? audioplayer.playPause(event) : audio.next())) : f = !0;
    }

    function B() {
        return c[u] || !1;
    }

    function z() {
        return B().id || !1;
    }

    function T(e) {
        e && (s.src = e.src, ssSet("audio_src", e.src), s.load(), audio.onSelect(!0, e));
    }

    function E() {
        if (v) {
            var e = lsGet("audio_current_player");
            l != e ? audio.pause() : _ = setTimeout(E, 100);
        }
    }

    function j() {
        var e = z();
        ssSet("audio_id", e), ssSet("audio_pos", 0), m && (document.cookie = m + "=" + e + "; expires=" + (new Date(timeNow() + 864e5)).toUTCString() + "; path=" + y);
    }

    function A(e) {
        ssSet("audio_query", e), m && (document.cookie = m + "q=" + encodeURIComponent(e) + "; expires=" + (new Date(timeNow() + 864e5)).toUTCString() + "; path=" + y);
    }
    var checkRadio = null;
    function isRadio(){
        if(checkRadio === null)
            checkRadio = (ge('radio_container') === null);
        return checkRadio;
    }
    var repeat = false;
    return {
        init: function (e) {
            return audio.support ? (e.cookie && (m = e.cookie, y = e.cookie_path || "/"), void onDOMReady(function () {
                e.playlist && audio.playlist(e.playlist, {q: e.playlist_q || ""});
                var a = ssGet("audio_id");
                if (a) {
                    var n = ssGet("audio_pos"), o = ssGet("audio_vol"), i = ssGet("audio_play");
                    audio.select(a), "1" == i && (null !== n && audio.position(n), null !== o && audio.volume(o), t = !0, audio.play());
                }
            })) : !1;
        },
        isRadio : isRadio,
        support: s.canPlayType && s.canPlayType("audio/mpeg") && "no" != s.canPlayType("audio/mpeg") || !1,
        onPlay: se(z),
        onPause: se(z),
        onDeselect: se(z, function () {
            return audio.duration();
        }),
        onSelect: se(),
        onProgress: se(z, function () {
            return audio.loaded();
        }, function () {
            return audio.duration();
        }),
        onPositionChanged: se(z),
        onVolumeChanged: se(z, function () {
            return s.volume;
        }),
        onEnded: se(z),
        onNotFoundError: se(),
        onEmptyPlaylistError: se(),
        getCurrent: B,
        getCurrentId: z,
        operate: function (e) {
            return audio.support ? void(!e || c[u] && e == c[u].id ? v ? audio.pause() : audio.play() : audio.play(e)) : !1;
        },
        playing: function () {
            return v;
        },
        select: function (e) {
            if (!audio.support) {
                return !1;
            }
            if (e) {
                return c.length ? c[d[e]] ? (z() && audio.onDeselect(!0), u = d[e], T(c[u]), j(), !0) : void audio.onNotFoundError(!0, e) : void audio.onEmptyPlaylistError(!0, e);
            }
        },
        play: function (e) {
            if (!audio.support) {
                return !1;
            }
            if (e) {
                if (v && audio.pause(), !audio.select(e)) {
                    return;
                }
                try {
                    s.currentTime = .01;
                } catch (t$0) {
                }
            }
            v || (s.muted = !1, s.play(), v = !0, audio.onPlay(!0), ssSet("audio_play", "1"), lsSet("audio_current_player", l));
        },
        pause: function () {
            return audio.support ? void(v && (s.pause(), v = !1, audio.onPause(!0), ssSet("audio_play", "0"))) : !1;
        },
        position: function (e, t) {
            if (!audio.support) {
                return !1;
            }
            if ("undefined" == typeof e) {
                return s.currentTime;
            }
            t && (e = audio.duration() * e), e = Math.max(0, Math.min(e, audio.duration()));
            var a = v;
            a && (v = !1, s.pause());
            try {
                s.currentTime = e, audio.onPositionChanged(!0, audio.position(), audio.duration()), ssSet("audio_pos", e), a && (v = !0, s.muted = !1, s.play().catch(function(e){
                    audio.next();
                }));
            } catch (o$1) {
                audio.onPositionChanged(!0, e, audio.duration()), n = function () {
                    n = !1, audio.position(e);
                }, a && (v = !0);
            }
        },
        volume: function (e) {
            if (!audio.support) {
                return !1;
            }
            if ("undefined" == typeof e) {
                return s.volume;
            }
            try {
                s.volume = e || 0;
            } catch (t$2) {
            }
            audio.onVolumeChanged(!0), ssSet("audio_vol", e || 0);
        },
        loaded: function () {
            return s.buffered && s.buffered.length && s.buffered.end(s.buffered.length - 1) || 0;
        },
        duration: function () {
            return c[u] && c[u].dur || s.duration || 0;
        },
        next: function () {
            return audio.support ? (v && audio.pause(), audio.onDeselect(!0), ++u >= c.length && (u = 0), T(c[u]), j(), t = !0, void audio.play()) : !1;
        },
        prev: function () {
            return audio.support ? (v && audio.pause(), audio.onDeselect(!0), --u <= 0 && (u = c.length - 1), T(c[u]), j(), t = !0, void audio.play()) : !1;
        },
        repeat: function () {
            var t = ge("lm_audio");
            if(t) {
                if(repeat === true)
                    removeClass('repeat_enabled', 'lm_audio');
                else
                    addClass('repeat_enabled', 'lm_audio');
            }
            return audio.support ? (repeat = (repeat === true ? false : true) ) : !1;
        },
        playlist: function (e, t) {
            return audio.support ? "undefined" == typeof e ? c : (v && audio.pause(), B() && audio.onDeselect(!0), c = e, p = t && t.q || "", u = null, d = {}, each(e, function (e, t) {
                d[t.id] = e;
            }), A(p), void 0) : !1;
        },
        playlist_q: function () {
            return p;
        }
    };
}(), audioplayer = function () {
    var e = "1" == lsGet("audio_time_left"), t = "", a = "", n = "", o = null, i = 0, r = {};
    audio.onPlay(l), audio.onPause(c), audio.onSelect(u), audio.onDeselect(d), audio.onProgress(function (e, t, a) {
        var n = ge("audio" + e);
        audio.playing() ? (addClass("ai_playing", n), addClass("ai_playing", "lm_audio")) : (removeClass("ai_playing", n), removeClass("ai_playing", "lm_audio")), n && (C(n, t / a), addClass("ai_current", n));
    }), audio.onPositionChanged(p), audio.onVolumeChanged(function (e, t) {
        var a = ge("audio" + e);
        a && x(a, t);
    }), audio.onEnded(function (e) {
        var t = ge("audio" + e);
        t && k(t, 1);
    }), audio.onNotFoundError(v), audio.onEmptyPlaylistError(v);
    function s() {
        each(geByClass("ai_current"), function (e, t) {
            t = S(t), d(t.id, t.dur);
        });
        var e = audio.getCurrentId(), t = ge("audio" + e), a = audio.loaded(), n = audio.position(),
            o = audio.duration();
        audio.playing() ? (addClass("ai_playing", t), addClass("ai_playing", "lm_audio")) : (removeClass("ai_playing", t), removeClass("ai_playing", "lm_audio")), u(audio.getCurrent()), C(t, a / o), p(audio.getCurrentId(), n, o);
    }

    function l(e) {
        addClass("ai_playing", "lm_audio");
        var t = ge("audio" + e);
        t && (addClass("ai_playing", t), addClass("ai_current", t), audioplayer.playback(e));
    }

    function c(e) {
        removeClass("ai_playing", "lm_audio");
        var t = ge("audio" + e);
        t && (removeClass("ai_playing", t), addClass("ai_current", t), audioplayer.playback(e, !0));
    }

    function u(e) {
        if (!e) {
            return void hide("lm_player");
        }
        show("lm_player");
        var t = ge("lm_audio");
        if(t) {
            if (e.title == "")
                hide(geByClass1("dividers", t));
            else
                show(geByClass1("dividers", t));
        }
        t && (val(geByClass1("ai_artist", t), e.artist), val(geByClass1("ai_title", t), e.title));
        var a = ge("audio" + e.id);
        a && (C(a, 0), k(a, 0), w(a, T(0, audio.duration())), x(a, audio.volume()), addClass("ai_current", a));
    }

    function d(e, t) {
        var a = ge("audio" + e);
        removeClass("ai_playing", "lm_audio"), a && (w(a, z(t)), removeClass("ai_playing", a), removeClass("ai_current", a), i = 0, r[e] && delete r[e]);
        if (audio.isRadio())
            $.post("/audio/deleteFile/", {deleteFile: ssGet("audio_src")});
    }

    function p(e, t, a) {
        var n = ge("audio" + e);
        n && (f || k(n, t / a), x(n, audio.volume()), w(n, audioplayer.getFormatedTime(t, a)), t > 1 && (r[e] = 1));
    }

    function v(e) {
        var t = gpeByClass("audios_list", "audio" + e), a = geByClass("audio_item", t), n = [], o = !1;
        each(a, function (t, a) {
            return (a = S(a)) ? (n.push(a), void(a.id == e && (o = !0))) : !0;
        }), audio.playlist(n, {q: attr(t, "data-query")}), o && audio.play(e);
    }

    var f = null, g = null, h = !1, _ = !1;
    addEvent(document, isTouch ? "touchend touchcancel" : "mouseup", y), addEvent(document, isTouch ? "touchmove" : "mousemove", m);
    function m(e) {
        if (f) {
            var t = gpeByClass("audio", f), a = b(f, e);
            e && cancelEvent(e), h && k(t, a), _ && (x(t, a), audio.volume(a)), g = a;
        }
    }

    function y(e) {
        if (f) {
            var t = gpeByClass("audio_item", f), a = b(f, e) || g;
            e && cancelEvent(e), h && (k(t, a), audio.position(a, !0)), _ && x(t, a), f = g = null, h = _ = !1;
        }
    }

    function b(e, t) {
        var a = hasClass("touch", bodyNode) ? 10 : 8,
            n = t.pageX || t.touches && t.touches[0] && t.touches[0].pageX || 0, o = n - getX(e) - a / 2,
            i = e.offsetWidth - a, r = i ? Math.max(0, Math.min(o / i, 1)) : 0;
        return r;
    }

    function w(e, t) {
        if (e) {
            var a = geByClass1("ai_dur", e);
            val(a, t);
        }
    }

    function C(e, t) {
        if (audio.isRadio()) {
            var a = geByClass1("aic_progress_wrap", e);
            if(a !== undefined) {
                var n = geByClass1("aic_load_line", a);
                n.style.width = 100 * Math.max(0, Math.min(t, 1)) + "%";
                if (parseInt(n.style.width) > 0)
                    removeClass("slider_loading_bar", geByClass1("slider_loading_bar", e));
            }
        }
    }

    function k(e, t) {
        if (e) {
            {
                var a = geByClass1("aic_progress_wrap", e), n = geByClass1("aic_progress_line", a);
                geByClass1("aic_slider", n);
            }
            n.style.width = 100 * t + "%";
        }
    }

    function x(e, t) {
        if (e) {
            {
                var a = geByClass1("aic_volume_wrap", e), n = geByClass1("aic_progress_line", a);
                geByClass1("aic_slider", n);
            }
            n.style.width = 100 * t + "%";
        }
    }

    function S(e) {
        if (e = ge(e), !e || !attr(e, "data-id")) {
            return !1;
        }
        var t = attr(e, "data-id"), a = val(geByTag1("input", e)), n = attr(geByClass1("ai_dur", e), "data-dur"),
            o = val(geByClass1("ai_artist", e)), i = val(geByClass1("ai_title", e));
        return {id: t, src: a, dur: n, artist: htsc(stripTags(o)), title: htsc(stripTags(i))};
    }

    function B(e, t, a) {
        if (!e) {
            return "";
        }
        var n = htsc(e.id), o = htsc(e.src), i = +e.dur, r = e.artist, s = e.title, l = e.can_add, c = e.can_del,
            u = s ? '<span class="dividers"> &ndash; </span>' : "", d = isTouch ? "ontouchstart" : "onmousedown", p = "",
            v = "";
    }

    function z(e) {
        var t, a, n, o = 0 > e;
        return e = Math.round(o ? -e : e), a = e % 60, t = 10 > a ? "0" + a : a, e = Math.floor(e / 60), n = e % 60, t = n + ":" + t, e = Math.floor(e / 60), e > 0 && (10 > n && (t = "0" + t), t = e + ":" + t), o && (t = "-" + t), t;
    }

    function T(t, a) {
        return z(e && a ? t - a : t);
    }

    return {
        init: function (e) {
            return audio.support ? (t = e.add_hash || "", a = e.del_hash || "", void(n = e.res_hash || "")) : !1;
        }, initAudio: s, getDOMFromAudio: B, playPause: function (e, t, a) {
            if (audio.support) {
                var n = ge("audio" + t);
                a && t != audio.getCurrentId() ? v(t, !0) : audio.operate(t);
            } else {
                alert('mobile_audio_player_not_support');
            }
            return cancelEvent(e), !1;
        }, getFormatedTime: T, switchTimeFormat: function (t, a) {
            var n = gpeByClass("audio_item", t);
            if (!hasClass("ai_current", n) || hasClass("ai_select", n)) {
                return !0;
            }
            e = !e, lsSet("audio_time_left", e ? "1" : "0");
            var o = ge("audio" + audio.getCurrentId());
            return w(o, T(audio.position(), audio.duration())), a && cancelEvent(a), !1;
        }, setPosition: function (e, t) {
            f || (f = e, h = !0, m(t));
        }, setVolume: function (e, t) {
            f || (f = e, _ = !0, m(t));
        }, playback: function (e, a) {
            if (clearTimeout(o), !a && e && e != i) {
                o = setTimeout(1E4);
            }
        }
    };
}();