const ajaxHotNovelsUrl = ajaxUrl + "/hot-novels",
    ajaxLatestNovelsUrl = ajaxUrl + "/latest-novels",
    ajaxNovelRateUrl = ajaxUrl + "/rate-novel",
    ajaxReportChapterUrl = ajaxUrl + "/report-chapter",
    ajaxUserSettingsUrl = ajaxUrl + "/user-settings",
    ajaxIncreaseNovelViewsUrl = ajaxUrl + "/increase-novel-views",
    ajaxIncreaseChapterViewsUrl = ajaxUrl + "/increase-chapter-views",
    ajaxSearchNovelUrl = ajaxUrl + "/search-novel",
    ajaxChapterOptionUrl = ajaxUrl + "/chapter-option",
    ajaxFollowNovel = ajaxUrl + "/follow-novel",
    ajaxChapterArchiveUrl = ajaxUrl + "/chapter-archive",
    ajaxShowFullContent = ajaxUrl + "/show-full-content",
    ajaxGetMainHistory = ajaxUrl + "/getHistorys"



function installLater(a) { $.cookie("install_app", 1, { path: "/", expires: a }), $("#install-app-modal").modal("hide") }

function getUrlParameter(a) { var e, t, n = decodeURIComponent(window.location.search.substring(1)).split("&"); for (t = 0; t < n.length; t++) { if ((e = n[t].split("="))[0] === a) return (void 0 === e[1] ? "" : e[1]).replace(/\+/g, " ").trim() } }

function increaseNovelViews(a) { $.ajax({ url: ajaxIncreaseNovelViewsUrl, data: { id: a, _csrf: csrf }, type: "POST" }) }

function increaseChapterViews(a) { $.ajax({ url: ajaxIncreaseChapterViewsUrl, data: { id: a, _csrf: csrf }, type: "POST" }) }

function chapterJump(a, e, t) { 
    $(".chr-nav").on("click", "button.chr-jump", (function() {
         $("button.chr-jump").attr("disabled", !0), $.get(ajaxChapterOptionUrl, { novelId: a, currentChapterId: e }).done((function(a) {

             $(".chr-jump").replaceWith(a);
             const optionValue = $(".chr-jump option[chapter-id='" + e + "']").val();
             $(".chr-jump").val(optionValue), 
             $(".chr-jump").on("change", (function() { window.location = $(this).val() })) 
            })) 
        })
 )
 }

function loadChapterArchive(a) {
    $.get(ajaxChapterArchiveUrl, { novelId: a }).done((function(a) {
        $("#chapter-archive").replaceWith(a);
        pushHistory();
    }));
}


function getContent (novel_id,chapter_id) {
    $.ajax({ method: "POST", url: ajaxShowFullContent, data: { novel_id: novel_id,chapter_id : chapter_id, _csrf: csrf } }).done((function(res) {
            if(res.success) {
                $("#chr-content").find("h1,h2,h3,h4,h5,h6,br,p").remove();
                $("#chr-content div:first").after(res.content);
            }
    }));
}


function chapterDetail(a, e) {

    const host_name  = window.location.host;
    const novel_id = a.id;
    const chapter_id = e.id;
    const sub_site = $('meta[name="sub_site"]').attr('content');
    if(sub_site == 'true') {
        let currentUrl = new URL(window.location.href);
            currentUrl.search = "";
            window.history.pushState({}, document.title, currentUrl.toString());
    }
    if(sub_site == 'true' || host_name == 'novelbin.com') { 
        let main_url = $('.header-logo').attr('href');

        if(main_url) {
            main_url += `?novel_id=${novel_id}&chapter_id=${chapter_id}`;
            $('.header-logo').attr('href', main_url);
        }

        let novel_url = $('.novel-link').attr('href');

        if(novel_url) {
            novel_url += `?novel_id=${novel_id}&chapter_id=${chapter_id}`;
            $('.novel-link').attr('href', novel_url);
        }
    }   
    $navBar = $(".toggle-nav-open"),
        $navBar.on("click", (function() {
            var a = $(this).hasClass("active") ? "close" : "open";
            n("nav-bar", a), i("nav-bar", a), $("header").toggle(), $(".navbar-breadcrumb").toggle()
        })),
        $nextChap = $("#next_chap"),
        $prevChap = $("#prev_chap"),
        $(document).keydown((function(a) {
            var e = a.target.tagName.toLowerCase();
            if ("input" != e && "textarea" != e) {
                var t = a.charCode ? a.charCode : a.keyCode;
                39 == t || 68 == t ? $nextChap.attr("disabled") || (window.location = $nextChap.attr("href")) : 37 != t && 65 != t || $prevChap.attr("disabled") || (window.location = $prevChap.attr("href"))
            }
        })),
        $container = $("#container"),
        $footer = $("footer"),
        $chapter = $("#chapter"),
        $chapterContent = $("#chr-content");
    var t = $chapterContent.html();

    function n(a, e) {
        var n;
        if (e) switch (a) {
            case "background":
                $container.css("background-color", e), "#232323" == e ? ($container.addClass("dark-background"), $footer.addClass("footer-dark")) : ($container.removeClass("dark-background"), $footer.removeClass("footer-dark"));
                break;
            case "font-family":
                $chapterContent.css("font-family", e);
                break;
            case "font-size":
                $chapterContent.css("font-size", e);
                break;
            case "line-height":
                $chapterContent.css("line-height", e);
                break;
            case "nav-bar":
                "open" == e ? ($("body").addClass("toggleNav"), $("#container").addClass("active"), $navBar.find(".glyphicon").removeClass("glyphicon-menu-up").addClass("glyphicon-menu-down"), $navBar.addClass("active")) : ($navBar.removeClass("active"), $("#container").removeClass("active"), $navBar.find(".glyphicon").removeClass("glyphicon-menu-down").addClass("glyphicon-menu-up"), $("body").removeClass("toggleNav"));
                break;
            case "fluid-switch":
                "yes" == e ? ($chapter.removeClass("container"), $chapter.addClass("container-fluid")) : ($chapter.addClass("container"), $chapter.removeClass("container-fluid"));
                break;
            case "onebreak-switch":
                "yes" == e ? $chapterContent.html((n = $chapterContent.html(), n.replace(/<br>/g, ""))) : $chapterContent.html(function(a) {
                    var e = "<p>",
                        t = a.split(e),
                        n = "";
                    for (var i in t) {
                        var o = t[i].trim();
                        n += "<p>" + o, -1 === o.indexOf("</p>") && (n += "</p>"), n += "<br>"
                    }
                    return n = (n = n.replace(/(<br\s*\/?>){1,}/gi, "<br>")).replace(/<p><br><br><\/p>/gi, "")
                }(t));
                break
        }
    }

    function i(a, e) {
        var t = o();
        switch (a) {
            case "background":
                t.background = e;
                break;
            case "font-family":
                t.fontFamily = e;
                break;
            case "font-size":
                t.fontSize = e;
                break;
            case "line-height":
                t.lineHeight = e;
                break;
            case "nav-bar":
                t.navBar = e;
                break;
            case "fluid-switch":
                t.fluidSwitch = e;
                break;
            case "onebreak-switch":
                t.onebreakSwitch = e;
                break
        }
        var n = new Date;
        n.setTime(n.getTime() + 6048e5),
            $.cookie("chapter_style", JSON.stringify(t), { path: "/", expires: n });
        var i = { style: t };
        $.ajax({ method: "POST", url: ajaxUserSettingsUrl, data: { settings: JSON.stringify(i), _csrf: csrf } }).done((function(a) {}))
    }

    function o() {
        var a = $.cookie("chapter_style");
        return (a = a ? JSON.parse(a) : {}).background || (a.background = "#F4F4F4"), a.fontFamily || (a.fontFamily = "Arial, sans-serif"), a.fontSize || (a.fontSize = "18px"), a.lineHeight || (a.lineHeight = "160%"), a.fluidSwitch || (a.fluidSwitch = "no"), a.onebreakSwitch || (a.onebreakSwitch = "no"), a.navBar || (a.navBar = "close"), a
    }
    $options = $("#options"),
        $options.show(),
        $optionBackground = $("#option-background"),
        $optionFontFamily = $("#option-font-family"),
        $optionFontSize = $("#option-font-size"), $optionLineHeight = $("#option-line-height"),
        $optionFluidSwitch = $("input[type=radio][name=fluid-switch]"),
        $optionNoLineBreak = $("input[type=radio][name=onebreak-switch]"),
        $optionBackground.on("change", (function() { n("background", $(this).val()), i("background", $(this).val()) })),
        $optionFontFamily.on("change", (function() { n("font-family", $(this).val()), i("font-family", $(this).val()) })),
        $optionFontSize.on("change", (function() { n("font-size", $(this).val()), i("font-size", $(this).val()) })),
        $optionLineHeight.on("change", (function() { n("line-height", $(this).val()), i("line-height", $(this).val()) })),
        $optionFluidSwitch.on("change", (function() { n("fluid-switch", $(this).val()), i("fluid-switch", $(this).val()) })),
        $optionNoLineBreak.on("change", (function() { n("onebreak-switch", $(this).val()), i("onebreak-switch", $(this).val()) }));
    var r = o();
    $optionBackground.val(r.background), $optionFontFamily.val(r.fontFamily), $optionFontSize.val(r.fontSize), $optionLineHeight.val(r.lineHeight), r.navBar, $optionFluidSwitch.val([r.fluidSwitch]), $optionNoLineBreak.val([r.onebreakSwitch]), a.chapter = e, jQuery(document).ready((function() {
        
        // var e = $.cookie("novels_history");
        // for (var t in e = e ? JSON.parse(e) : []) { 
        //     if (e[t].id == a.id) { e.splice(t, 1); break } 
        // }
        // 10 == e.length && e.splice(-1, 1), 
        // e.unshift(a);
        // var n = new Date;
        // n.setTime(n.getTime() + 6048e5),
        // $.cookie("novels_history", JSON.stringify(e), { path: "/", expires: n })
        
        var e = localStorage.getItem("novels_history");
        e = e ? JSON.parse(e) : [];

        for (var t in e) {
             if (e[t].id == a.id) { 
                  e.splice(t, 1); 
             break;
        }
        }
        if (e.length >= 10) {
            e.pop(); 
        }
        e.unshift(a); 
        localStorage.setItem("novels_history", JSON.stringify(e)); 



    })), $("#chr-error").on("click", (function() {
        const a = prompt("Please describe error", "");
        if (null !== a) {
            const t = window.location.href;
            $.ajax({ method: "POST", url: ajaxReportChapterUrl, data: { _csrf: csrf, novelId : novel_id, chapterId: e.id, reason: a, url: t } }).done((function(a) {})), alert("Thanks report")
        }
    })), chapterJump(a.id, e.id, e.url);


}
function escapeHtml(text) {
    var map = {
      '&': '&amp;',
      '<': '&lt;',
      '>': '&gt;',
      '"': '&quot;',
      "'": '&#039;'
    };
    
    return text.replace(/[&<>"']/g, function(m) { return map[m]; });
  }

function novelDetailHistory() {
    const main_site = $('meta[name="main_site"]').attr('content');
    if(main_site == 'true') {

    const urlParams = new URLSearchParams(window.location.search);
    const novelId = urlParams.get('novel_id');
    const chapterId = urlParams.get('chapter_id');
    
    if(novelId &&chapterId ) {
        const chapter = {
            novel_id : novelId,
            chapter_id : chapterId,
        }
        var e = localStorage.getItem("main_history"); 
        e = e ? JSON.parse(e) : []; 

        for (var t in e) {
             if (e[t].novel_id == chapter.novel_id) { 
                  e.splice(t, 1); 
             break;
        }
        }
        if (e.length >= 5) {
            e.pop(); 
        }
        e.unshift(chapter); 
        localStorage.setItem("main_history", JSON.stringify(e)); 

        const currentDomain = window.location.hostname;
        const newUrl = `https://${currentDomain}${window.location.pathname}`;
        window.history.replaceState({}, '', newUrl);
    }
}
}

function novelDetail() {
    $(".showmore a").on("click", (function(a) { a.preventDefault(), $(this).parent().css({ height: 0 }), $(".tag-container").css({ "max-height": "2000px" }) }));
    var a = $.cookie("novels_rating");
    a = a ? JSON.parse(a) : [], $rating = $("#rating"), $rating.rateit({ max: 10, step: 1, backingfld: "#rateVal" });
    var e = ["Nothing to say...", "WTF", "What the hell is this ?!", "Lolz", "Normal", "Not bad", "Uhm... Good", "Good", "Best", "Wonderful"];
    $rating.bind("over", (function(a, t) { $(this).attr("title", e[t - 1]), $("#text__rating").html(e[t - 1]) })), $rating.bind("mouseleave", (function() { $("#text__rating").html("") }));
    const t = $rating.data("novel-id");
    ! function(e) { for (var t in a) { if (a[t].id == e) return !0 } return !1 }(t) ? $rating.bind("rated", (function(e) {
        var n = $(this),
            i = n.rateit("value");
        ! function(e) {
            var t = { id: e },
                n = !1;
            for (var i in a) { if (a[i].id == t.id) { n = !0; break } }
            n || a.push(t);
            var o = new Date;
            o.setTime(o.getTime() + 6048e5), $.cookie("novels_rating", JSON.stringify(a), { path: "/", expires: o })
        }(t), n.rateit("readonly", !0), $.ajax({ url: ajaxNovelRateUrl, data: { id: t, value: i, _csrf: csrf }, type: "POST", success: function(a) { alert("Thank you for your rating!") }, error: function(a, e, t) { $("#response").append('<li style="color:red">' + e + "</li>") } })
    })): $rating.rateit("readonly", !0), $("#novel-detail-tabs").find('a[href="#tab-chapters"]').on("shown.bs.tab", (function(a) { $("#chapter-archive").find(".loading").length && loadChapterArchive(t) })), $("#novel-detail-tabs").find('a[href="#tab-comment"]').on("shown.bs.tab", (function(a) { showNovelComment() })), "" !== location.hash && $('a[href="' + location.hash.replace("-title", "") + '"]').tab("show"), $('a[data-toggle="tab"]').on("shown.bs.tab", (function(a) { location.hash = $(a.target).attr("href").substr(1) + "-title" }))


    if(localStorage.getItem('follow_novels')) {
        const follow_novels = JSON.parse(localStorage.getItem('follow_novels'));
        const novel_id = $('#btn-follow').data('id');
        if(follow_novels.includes(novel_id)) {
            $("#btn-follow").hide();
        }
    };


    $("#btn-follow").on("click", (function() {
        const novel_name = $(this).data('name');
        const novel_id = $(this).data('id');
        console.log($.cookie('email'));

        const email = $.cookie('email') ? $.cookie('email') : prompt(`Dear reader \nPlease enter your email address to receive the latest chapter of the ${novel_name} novel.`, "");
        const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
          if (null !== email && emailPattern.test(email)) {
            const re_email = $.cookie('email') ? $.cookie('email') :  prompt(`Dear reader \nWe apologize for the inconvenience, but please enter your email again for the most accurate verification process.`, "");
            if(re_email == email) {
                $.ajax({ method: "POST", 
                url: ajaxFollowNovel, 
                data: { _csrf: csrf, novel_id : novel_id, email: email , novel_name : novel_name} }).
                done((function(res) {
                    if(res.success) {
                        $.cookie('email', email, {expires: 1,path: "/"});
                        localStorage.removeItem('follow_novels');
                        localStorage.setItem('follow_novels', JSON.stringify(res.follow_novels));
                        $("#btn-follow").hide();
                        alert(res.msg)
                    } else {
                        alert(res.msg)
                    }

                }))
            } else {
                $.cookie('email', '', {path: "/"});
                alert("We noticed that the email entered does not match between the two inputs. Please try again.")
            }

         
          } else {
            alert("The email you provided is in an incorrect format. Please try again.");
            $.cookie('email', '', {path: "/"});
          }
    }));
}

function pushHistory() {
    const main_site = $('meta[name="main_site"]').attr('content');
    if(main_site == 'true') {
        $('.chapter-title').click(function() {
            const chapter = {
                novel_id : $(this).data('novel_id'),
                chapter_id : $(this).data('chapter_id'),
            }
            var e = localStorage.getItem("main_history"); 
            e = e ? JSON.parse(e) : []; 
    
            for (var t in e) {
                 if (e[t].novel_id == chapter.novel_id) { 
                      e.splice(t, 1); 
                 break;
            }
            }
            if (e.length >= 5) {
                e.pop(); 
            }
            e.unshift(chapter); 
            localStorage.setItem("main_history", JSON.stringify(e)); 
        });
    }
}

$((function() { 
    pushHistory();
}))



function turnOffNotify() {
    $("#turn_off_noti").on("click", function() { 
        $.cookie('notShowNotify', true, { expires: 1/24 });
    });
}

function siteIndex() {
    const a = screen.width <= 768;

    const main_site = $('meta[name="main_site"]').attr('content');
    if(main_site == 'true') {

    const urlParams = new URLSearchParams(window.location.search);
    const novelId = urlParams.get('novel_id');
    const chapterId = urlParams.get('chapter_id');
    
    if(novelId &&chapterId ) {
        const chapter = {
            novel_id : novelId,
            chapter_id : chapterId,
        }
        var e = localStorage.getItem("main_history"); // Lấy dữ liệu từ localStorage
        e = e ? JSON.parse(e) : []; // Chuyển đổi thành mảng nếu dữ liệu tồn tại, nếu không, tạo mảng mới

        for (var t in e) {
             if (e[t].novel_id == chapter.novel_id) { // Kiểm tra nếu có mục trùng lặp với a.id
                  e.splice(t, 1); // Xóa mục trùng lặp
             break;
        }
        }
        if (e.length >= 5) {
            e.pop(); // Nếu mảng đã đủ 5 phần tử, loại bỏ phần tử cuối cùng
        }
        e.unshift(chapter); 
        localStorage.setItem("main_history", JSON.stringify(e)); // Lưu mảng mới vào localStorage

        const currentDomain = window.location.hostname;
        const newUrl = `https://${currentDomain}${window.location.pathname}`;
        window.history.replaceState({}, '', newUrl);
    }

    const chapters = localStorage.getItem("main_history");
    $.ajax({ method: "POST", url: ajaxGetMainHistory, data: { chapters: chapters, _csrf: csrf } }).done((function(res) {
            if(res.success) {
                var e = res.chaptersData;
                if ((e = e ? e: []).length > 0) {
                    for (var t in e = e.slice(0, 5), $novelHistory = $("#novel-history-main"), $novelHistory.append('<div class="header-list"><h2>Your novel reading</h2></div>'), e) {
                        var n = '<div class="row"><div class="col-xs-7 col-sm-6 col-md-8 col-title-history"><span class="glyphicon glyphicon-chevron-right"></span>';
                        n += '<h3><a href="' + (i = e[t]).url + '">' + i.name + "</a></h3></div>", n += '<div class="col-xs-5 col-sm-6 col-md-4 text-info">', n += '&nbsp;&nbsp;<a href="' + i.chapter.url + '"><span class="chr-text">' + i.chapter.name + "</span></a></div>", n += "</div></div>", a && (n = (n = n.replace("Chapter ", "C")).replace("Volume ", "V")), $novelHistory.append(n)
                    }
                    for (var t in $novelHistory = $("#novel-history-sidebar"), $novelHistory.append('<div class="header-list"><h2>Your novel reading</h2></div>'), e) {
                        var i;
                        n = '<div class="row"><div class="col-md-5 col-lg-7"><span class="glyphicon glyphicon-chevron-right"></span>';
                        n += '<h3><a href="' + (i = e[t]).url + '">' + i.name + "</a></h3></div>", n += '<div class="col-md-7 col-lg-5 text-info">', n += '&nbsp;&nbsp;<a href="' + i.chapter.url + '"><span class="chr-text">' + i.chapter.name + "</span></a></div>", n += "</div></div>", a && (n = (n = n.replace("Chapter ", "C")).replace("Volume ", "V")), $novelHistory.append(n)
                    }
                }
            }
     }));

    } else {
        var e = localStorage.getItem("novels_history");
        if ((e = e ? JSON.parse(e) : []).length > 0) {
            for (var t in e = e.slice(0, 5), $novelHistory = $("#novel-history-main"), $novelHistory.append('<div class="header-list"><h2>Your novel reading</h2></div>'), e) {
                var n = '<div class="row"><div class="col-xs-7 col-sm-6 col-md-8 col-title-history"><span class="glyphicon glyphicon-chevron-right"></span>';
                n += '<h3><a href="' + (i = e[t]).url + '">' + i.name + "</a></h3></div>", n += '<div class="col-xs-5 col-sm-6 col-md-4 text-info">', n += '&nbsp;&nbsp;<a href="' + i.chapter.url + '"><span class="chr-text">' + i.chapter.name + "</span></a></div>", n += "</div></div>", a && (n = (n = n.replace("Chapter ", "C")).replace("Volume ", "V")), $novelHistory.append(n)
            }
            for (var t in $novelHistory = $("#novel-history-sidebar"), $novelHistory.append('<div class="header-list"><h2>Your novel reading</h2></div>'), e) {
                var i;
                n = '<div class="row"><div class="col-md-5 col-lg-7"><span class="glyphicon glyphicon-chevron-right"></span>';
                n += '<h3><a href="' + (i = e[t]).url + '">' + i.name + "</a></h3></div>", n += '<div class="col-md-7 col-lg-5 text-info">', n += '&nbsp;&nbsp;<a href="' + i.chapter.url + '"><span class="chr-text">' + i.chapter.name + "</span></a></div>", n += "</div></div>", a && (n = (n = n.replace("Chapter ", "C")).replace("Volume ", "V")), $novelHistory.append(n)
            }
        }
    }
}
$((function() {

    const a = screen.width <= 768;

    function e(a, e, n) { $.ajax({ method: "GET", url: e, data: n }).done((function(e) { a.fadeOut(50, (function() { a.html(""), a.fadeIn(50, (function() { a.html(e), pushHistory(), t() })) })) })) }

    function t() {
        $(".chr-text").each((function(e, t) {
            if (a) {
                var n = $(this).html();
                n = (n = n.replace("Chapter ", "C")).replace("Volume ", "V"), $(this).html(n)
            }
        }))
    }

    function n(a) { $.get(ajaxSearchNovelUrl, { keyword: a  }).done((function(a) { $(".list-search-res").html(a) })) }
    $("#hot-genre-select").on("change", (function() {
            const a = $(this).val();
            e($("#index-novel-hot").find(".index-novel"), ajaxHotNovelsUrl, { genre: a })
        })), $("#new-genre-select").on("change", (function() {
            const a = $(this).val();
            e($("#novel-list-index").find(".index-novel"), ajaxLatestNovelsUrl, { genre: a })
        })), t(),
        function() {
            const a = $("#search-input");
            a.val(getUrlParameter("keyword"));
            const e = $(".list-search-res");
            var t = null;
            a.keyup((function() {
                var a;
                clearTimeout(t), 0 === (a = $(this).val()).length ? e.html("").addClass("hide") : 3 <= a.length && (e.html('<img src="/img/loading-search.gif" alt="loading">').removeClass("hide"), t = setTimeout((function() { n(a) }), 300))
            })), a.bind("paste", (function() {
                clearTimeout(t);
                var a = this;
                setTimeout((function() {
                    var i = $(a).val();
                    0 === i.length ? e.html("").addClass("hide") : 3 <= i.length && (e.html('<img src="/img/loading-search.gif" alt="loading">').removeClass("hide"), t = setTimeout((function() { n(i) }), 300))
                }), 0)
            })), $("html").click((function(e) { a !== e.target.id && $(".list-search-res").html("").addClass("hide") }))
        }(), $(".panel-collapse").on("show.bs.collapse", (function() { $(this).siblings(".panel-heading").addClass("active") })), $(".panel-collapse").on("hide.bs.collapse", (function() { $(this).siblings(".panel-heading").removeClass("active") })),
        function() {
            if (!$.cookie("install_app") && (e = !1, a = navigator.userAgent || navigator.vendor || window.opera, (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) && (e = !0), e)) {
                var a, e, t, n = "";
                navigator.userAgent.toLowerCase().indexOf("android") > -1 && (n = function() { if (!appInfo.android) return ""; var a = appInfo.android.url; return '<div id="install-app-modal" class="modal fade" tabindex="-1" role="dialog">\n  <div class="modal-dialog" role="document" style="z-index: 999999">\n    <div class="modal-content">\n      <div class="modal-header">\n        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>\n        <h4 class="modal-title">Install App</h4>\n      </div>\n      <div class="modal-body" style="text-align: center">\n        <p><strong>ReadNovelFull</strong> Android App version ' + appInfo.android.version + ' with new features. Install now !!!</p>        <p><a href="' + a + '" title="Android App ReadNovelFull" target="_blank">               <img alt="Android App ReadNovelFull" width="100" height="100"                    src="/img/app-icon.png"></a>        </p>        <p><a href="' + a + '"                title="Android App ReadNovelFull" target="_blank"><strong class="text-info">NovelFull - Reading novel online & offline</strong></a></p>      </div>\n      <div class="modal-footer">\n        <button type="button" class="btn btn-default" onclick="installLater(30);">Installed</button>\n        <button type="button" class="btn btn-default" onclick="installLater(1);">Later</button>\n        <a type="button" class="btn btn-danger" onclick="installLater(30);"           href="' + a + '" target="_blank">Install</a>      </div>\n    </div>\n  </div>\n</div>' }()), t = navigator.userAgent.toLowerCase(), /ipad|iphone|ipod/.test(t) && !window.MSStream && (n = function() { if (!appInfo.ios) return ""; var a = appInfo.ios.url; return '<div id="install-app-modal" class="modal fade" tabindex="-1" role="dialog">\n  <div class="modal-dialog" role="document" style="z-index: 999999">\n    <div class="modal-content">\n      <div class="modal-header">\n        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>\n        <h4 class="modal-title">Install App</h4>\n      </div>\n      <div class="modal-body" style="text-align: center">\n        <p><strong>ReadNovelFull</strong> iOS App version ' + appInfo.ios.version + ' with new features. Install now !!!</p>        <p><a href="' + a + '" title="iOS App ReadNovelFull" target="_blank">               <img alt="iOS App ReadNovelFull" width="100" height="100"                    src="/img/app-icon.png"></a>        </p>        <p><a href="' + a + '"                title="iOS App ReadNovelFull" target="_blank"><strong class="text-info">NovelFull - Reading novel online & offline</strong></a></p>      </div>\n      <div class="modal-footer">\n        <button type="button" class="btn btn-default" onclick="installLater(30);">Installed</button>\n        <button type="button" class="btn btn-default" onclick="installLater(1);">Later</button>\n        <a type="button" class="btn btn-danger" onclick="installLater(30);"           href="' + a + '" target="_blank">Install</a>      </div>\n    </div>\n  </div>\n</div>' }()), n && ($("body").append(n), $("#install-app-modal").modal("show"))
            }
        }(),
        function() {
            var a = $.cookie("_ga");
            if (a) {
                var e = a.replace(/^.+\.(.+?\..+?)$/, "$1");
                e && $.cookie("_gaClientId", e, { path: "/", expires: 365 })
            }
        }(), $("#page_jump").bind("click", (function(a) { a.stopPropagation() }))
}));