2 lines
14 KiB
JavaScript
2 lines
14 KiB
JavaScript
/* ZONGHENG PC 2018 Copyright (c) 2018 (ZONGHENG FETEAM) lastUpdate: 2022-08-02 15:45:47*/
|
|
define(["donate","widget","chapterForums","chapterReport"],function(e,r,o){var i=$("body").attr("bookId"),a=($("body").attr("chapterId"),$("body").attr("lastChapterId")),n=$("body").attr("nextChapterId"),s="chapterflow"===$("body").attr("scriptSign")?1:0,t=($("body").attr("forumid"),$(window).width()),d=CookieUtil,c="rSet",l=[1,3,1,14,1];t<1200?l[1]=1:t<1400&&(l[1]=2);var p=[0,640,800,960,1100,1440,1700],h=h||{save:function(e){e=e.join("_");d.setCookie({name:c,value:e,path:"/",domain:document.domain||"book.zongheng.com",expires:31536e3})},setDef:function(){this.save(l),d.getCookie("ui_read_setting")&&d.setCookie({name:"ui_read_setting",value:null,path:"/",domain:".zongheng.com",expires:-1})},getStatData:function(){var e=this.setting;return{setting_color:["0","默认","蓝色","绿色","粉色","浅灰","羊皮","纸纹","黑色"][parseInt(e[0])],setting_font:["0","宋体","黑体","微软雅黑","楷体"][parseInt(e[2])],setting_font_size:e[3],setting_page_breadth:["0","640","800","默认","1280"][parseInt(e[1])]}},setChange:function(e,t){this.setting[e]=t},color:function(e){document.body.className="rb_"+e,$('a[data-style="'+e+'"]').addClass("active").siblings().removeClass("active"),this.setChange(0,e)},serbarPos:function(e){$("#uiGPUserAct").css({"margin-left":Math.floor(e/2+10)+"px"}),$("#uiGPReaderAct").css({"margin-left":"-"+Math.floor(e/2+70)+"px"})},setGpdOffset:function(){var e=$(document).scrollTop(),t=$("#readerFt").height(),a=$(window).height(),r=$("#uiGPUserAct").height(),o=$("body").height(),i=$("#readerFt").eq(0).offset().top;i<=e?($("#uiGPReaderAct").css({position:"fixed",top:"0px"}),$(".chapter_forum").addClass("fixed")):($("#uiGPReaderAct").css({position:"absolute",top:i}),$(".chapter_forum").removeClass("fixed")),i+t-a<=e&&200<=o||o<a?$("#uiGPUserAct").css({position:"absolute",top:i+t-r,bottom:"auto"}):$("#uiGPUserAct").css({position:"fixed",bottom:"0px",top:"auto"})},width:function(e){var t=p[e];$("#reader_warp").hasClass("rw_comment_open")?($("#reader_warp").attr("class","rw_"+e+" rw_comment_open"),t+=400):$("#reader_warp").attr("class","rw_"+e),$('a[data-width="'+e+'"]').addClass("active").siblings().removeClass("active"),this.setChange(1,e),this.serbarPos(t)},fontFace:function(e){$("#readerFt").attr("class","rft_"+e),$('a[data-font="'+e+'"]').addClass("active").siblings().removeClass("active"),this.setChange(2,e)},fontSize:function(e){e<10&&(e=14),$("#readerFt").css("font-size",e+"px"),$(".sbw_font .nowfont").html(e),this.setChange(3,e+"")},comment:function(e){0==e?($("#j_selectCommentBtn").addClass("off").removeClass("on"),$(".reader_box").addClass("parCommentHide")):($("#j_selectCommentBtn").addClass("on").removeClass("off"),$(".reader_box").removeClass("parCommentHide")),this.setChange(4,e)},build:function(e){e=e||d.getCookie(c).split("_"),this.color(e[0]),this.width(e[1]),this.fontFace(e[2]),this.fontSize(e[3]),this.comment(e[4])},close:function(){$("#uiGPReaderAct").find('[data-pname="readerSetting"]').hide(),$("#uiGPReaderAct").find("a.readerSetting").removeClass("active")},jump:function(e,t){"chapterflow"!=this.type&&("0"!=a||0!==t?"0"!=n||1!==t?location.href=Domain.bookHostName+"/chapter/"+i+"/"+e+".html":$('[data-hook="pageEnd"]').click():$('[data-hook="pageStart"]').click())},end:function(){var e="",e="true"==$("body").attr("chapterDelayRelease")?"1":"0";this.endUrl=Domain.bookHostName+"/readmore1/"+i+"/"+e+".html"},autoScroll:function(e){var t,a,r=this;function o(){t=document.documentElement.scrollTop||document.body.scrollTop,t++,window.scroll(0,t),a=document.documentElement.scrollTop||document.body.scrollTop,t!=a&&i()}function i(){clearInterval(r.scrolltimer)}"start"==e&&function(){r.scrolltimer=setInterval(o,30);try{document.selection?document.selection.empty():document.getSelection().removeAllRanges()}catch(e){}}(),"stop"==e&&i()},sendFootPrint:function(e,t){!0===UserUtil.isLogin&&$.ajax({type:"get",url:"/api/footprint/trace",data:{bookId:e,chapterId:t},cache:!1,"async":!0,dataType:"json"})},init:function(){d.getCookie(c)||this.setDef(),this.setting=d.getCookie(c).split("_"),this.type=$("body").attr("scriptSign"),this.build(this.setting),$(".gamepad").fadeIn()}};h.showChapterList=function(e){$("#reader_warp").addClass("rw_comment_open"),o.resetForm(),h.serbarPos($("#reader_warp").width());$(".chapter_forum_tit h3").eq(0);var t=$(".chapter_forum_tit h3").eq(1);$(".chapter_forum_tit h3").show().addClass("active"),0==e?($(".ch_form").show(),$(".par_form").hide(),t.hide()):($(".ch_form").hide(),$(".par_form").show(),t.siblings().removeClass("active")),$("#Jchapter_forum").removeClass("showSendTextArea")},h.hideChapterList=function(){$("#Jchapter_forum").removeClass("showSendTextArea"),$("#reader_warp").removeClass("rw_comment_open"),h.serbarPos($("#reader_warp").width())},h.parShow=function(e,t){var a=$("#Jchapter_forum");a.removeClass("showSendTextArea").attr("data-cha","cha"),$(".chapter_thread_list").scrollTop(0),e.hasClass("active")?(e.removeClass("active"),$(".chapter_ipt").attr("data-ctype",0),"cha"==a.attr("data-cha")?($(".ch_form").show(),$(".par_form").hide(),$(".chapter_forum_tit h3").eq(0).addClass("active"),$(".chapter_forum_tit h3").eq(1).hide(),o.forumsChapter1(t)):h.hideChapterList()):(e.addClass("active").siblings().removeClass("active"),h.showChapterList(1),$(".chapter_ipt").attr("data-ctype",1),a=o.md5_par(t).md5_arr[e.index()],$(".chapter_thread").attr("data-par",e.index()),o.paraComments(t,a)),$("#uiGPReaderAct .gpd_btnpal a.view").hide()},h.init(),$(window).scroll(function(){h.setGpdOffset()}),h.setGpdOffset(),$("#uiGPReaderAct .gpd_btnpal a.readerSetting").click(function(){$(this).toggleClass("active"),$(this).hasClass("active")?$(".gpd_flt_setting").show():$(".gpd_flt_setting").hide()}),$("a[data-style]").click(function(){h.color($(this).attr("data-style"))}),$("a[data-font]").click(function(){h.fontFace($(this).attr("data-font"))}),$("a[data-size]").click(function(){var e=parseInt($(".nowfont").html());if("big"==$(this).attr("data-size")){if(30<(e+=2))return}else if((e-=2)<14)return;h.fontSize(e)}),$("a[data-width]").click(function(){h.width($(this).attr("data-width"))}),$("#j_selectCommentBtn").click(function(){$(this).hasClass("off")?(h.comment(1),o.getParagraphCodes(i,$("body").attr("chapterId"))):h.comment(0)}),$("#uiGPReaderAct .gpd_btnLine .confirm").click(function(){h.save(h.setting),$("#j_selectCommentBtn").hasClass("off")&&($("#reader_warp").removeClass("rw_comment_open"),$("#uiGPReaderAct .gpd_btnpal a.view").show()),h.build(),h.close()}),$("#uiGPReaderAct .gpd_btnLine .reset").click(function(){h.save(l),$("#j_selectCommentBtn").hasClass("off")&&($("#reader_warp").removeClass("rw_comment_open"),$("#uiGPReaderAct .gpd_btnpal a.view").show()),h.build(),h.close()}),$("#uiGPReaderAct .gpd_close").click(function(){h.build(),$("#j_selectCommentBtn").hasClass("off")&&($("#reader_warp").removeClass("rw_comment_open"),$("#uiGPReaderAct .gpd_btnpal a.view").show()),h.build(),h.close()}),$("#uiGPReaderAct .bookShelf,.marker").live("click",function(){var e,t,a;e=this,UserUtil.isLogin?(t="shelf",(a=$(e)).hasClass("added")||(a.attr("tomeId")!=undefined&&(t="bookmarker"),e={bookId:$("body").attr("bookId")},"bookmarker"==t&&(e.tomeId=a.attr("tomeId"),e.chapterId=a.attr("chapterId")),$.ajax({type:"get",url:"/api/user/addtoshelf",data:e,cache:!1,"async":!0,dataType:"jsonp",error:function(){r.Toast("意外错误")},timeout:1e4,success:function(e){e&&(201!=e.status&&202!=e.status?1==e.status?(r.Toast(e.msg),"shelf"==t?a.addClass("added").html("已加入"):($(".marker[class*='added']").removeClass("added"),a.addClass("added"),!0!==$("#uiGPReaderAct .gpd_btnpal .bookShelf").hasClass("added")&&$("#uiGPReaderAct .gpd_btnpal .bookShelf").addClass("added").html("已加入"))):r.Toast(e.msg):UserUtil.login())}}))):UserUtil.login()}),$("#uiGPReaderAct .gpd_btnpal a.view").click(function(){$(this).hide(),h.showChapterList(0);var e=$("body").attr("chapterId");$(".chapter_ipt").attr("data-ctype",0),$(".reader_main .content .active").removeClass("active"),o.forumsChapter1(e),$("#Jchapter_forum").attr("data-cha","cha")}),$(".chapter_forum_close").click(function(){h.hideChapterList(),$("#Jchapter_forum").attr("data-cha"," "),$(".reader_main .content .active").removeClass("active"),$("#uiGPReaderAct .gpd_btnpal a.view").show()}),document.oncontextmenu=function(){return!1},$(document).keydown(function(e){var t=e.srcElement||e.target;if(null!=t&&1==t.nodeType){t=t.nodeName.toLowerCase();if("input"==t||"textarea"==t)return!0}return 67!=e.keyCode||1!=e.ctrlKey}),$(document).keyup(function(e){var t=e.srcElement||e.target;if(null!=t&&1==t.nodeType){t=t.nodeName.toLowerCase();if("input"==t||"textarea"==t)return!0}$("body").attr("chapterDelayRelease");switch(e.keyCode){case 37:h.jump(a,0);break;case 39:h.jump(n,1);break;case 13:location.href=Domain.bookHostName+"/showchapter/"+i+".html"}return!0}),$("#readerFt").dblclick(function(e){e=e.srcElement||e.target;if(null!=e&&1==e.nodeType){e=e.nodeName.toLowerCase();if("input"==e||"textarea"==e)return!0}h.autoScroll("stop"),h.autoScroll("start")}),$("#readerFt").mousedown(function(){h.autoScroll("stop")});var m,u=new r.Custom({html:'<style>.orderWin_wrap{padding:20px;}.orderWin_wrap .orderInfo{border-bottom: 1px dotted #ccc;height:110px;line-height: 45px;}.orderWin_wrap .orderInfo ul li{background:url(../images/dot_li.png) no-repeat left center;padding-left:12px}.orderWin_wrap .ordernum{font-size: 14px;color:#4a4a4a}.orderWin_wrap .orderpaynum{font-size: 16px;font-weight:bold;color:#4a4a4a}.orderWin_wrap .ordernum b{color:#000;font-weight:bold}.orderWin_wrap .orderwn_usermoney b,.orderWin_wrap .orderpaynum b{color:#A11313;font-weight:bold}.orderWin_wrap .ordertips{line-height: 26px;padding:10px 0;height:60px;}.orderWin_wrap .ordertips .orderError em{width:12px;height:12px;background: url(//rcode.zongheng.com/v2018/images/order_ico.png) -30px 0 no-repeat;margin-right:5px;float: left;margin-top:7px;}.orderWin_wrap .ordertips .orderopt{position: relative;}.orderWin_wrap .ordertips .orderopt em{top:7px;}.orderWin_wrap .ordertips .orderopt input{margin-right:7px;}</style><div class="orderWin_wrap"><div class="orderInfo"><ul> <li class="ordernum">仅订阅本章 <li class="orderpaynum">本次订阅将消耗 <b id="order-data-money">--</b> 纵横币</li></ul></div><div class="ordertips"><div class="orderError" id="order-tip-error"><em></em>余额不足</div><div id="order-tip-money" class="orderwn_usermoney"></div></div><div class="ui_widget_conbtn clearfix"> <button class="confirm" id="order-btn-charge" data-cb="confirm">去充值</button></div></div>',id:"OrderConfirmDialog",tit:"订阅VIP章节",height:342});return $("#order-ckx-autoorder").click(function(){!0===$(this).is(":checked")?$(this).val(1):$(this).val(0)}),$("#order-btn-charge").click(function(){window.open(Domain.payHostName),u.close(),r.Confirm({con:"在新打开的页面上完成充值操作",tip:"充值成功后可进行以下操作",beforeOpen:function(){},close:!0,confirmTxt:"继续购买",cancelTxt:"余额查询",cb:{confirm:function(){UserUtil.getUserInfo()},cancel:function(){location.href=Domain.homeHostName}}})}),$(".order_jump .reader_obtnred").live("click",function(){var e,t,a;$(this).hasClass("ordering")||($(this).attr("data-chapterId"),(e=$(this).attr("data-price"))>UserUtil.userInfo.money?($("#order-data-money").html(e),e=e-UserUtil.userInfo.money,$("#order-tip-money").html("当前余额:"+UserUtil.userInfo.money+" 纵横币,还需支付 <b>"+e+"</b> 纵横币"),u.open()):(t=$(this),a=t.attr("data-chapterId"),$.ajax({type:"post",url:"/api/user/consume/order",data:{bookId:i,chapterids:a,autoOrder:$("#order-ckx-autoorder").attr("checked")?1:0},beforeSend:function(){t.addClass("ordering").children("p").html("订阅中...")},cache:!1,dataType:"json",error:function(){t.removeClass("ordering").children("p").html("订阅本章"),r.Alert("出错了..")},timeout:1e4,success:function(e){e?202!==e.status&&201!==e.status?1===e.status?(r.Toast({txt:"订阅成功",time:2e3,mask:!0,onHide:function(){1==s?location.href=Domain.bookHostName+"/totaltome/"+i+"/"+a+".html":location.reload()}}),UserUtil.getUserInfo()):(r.Alert(e.msg),t.removeClass("ordering").children("p").html("订阅本章")):r.Alert(e.msg,UserUtil.login):r.Alert("出错了..")}})))}),$('[data-hook="pageStart"]').click(function(){r.Alert("没有上一章了!")}),0<$('[data-hook="pageEnd"]').length&&(m=new r.Custom({html:"",id:"endPageDialogTarget",tit:"",header:!1}),$("#endPageDialogTarget").load("/book/readmore/"+i+".html?ver="+(new Date).getTime(),function(e){$("#endPageDialogTarget").find(".ui_widget_close").bind("click",function(){m.close()}),$("#btn-endpage-donate").bind("click",function(){m.close(),$("#uiGPUserAct .gpd_btnpal .donate").click()}),$("#endPageDialogTarget").prepend('<div class="ui_shadow"></div>'),$("#endPageDialogTarget").find(".r_author_head").children("img").error(function(){$(this).attr("src",UserUtil.defaultImg)})}),$('[data-hook="pageEnd"]').click(function(){m.open(),ZSAQ&&ZSAQ.push({event:"viewBookLastChapter",data:{book_id:i}})})),$.ajax({type:"get",url:Domain.hostName+"/api/recommend/game/list.htm",data:{category:12,t:(new Date).getTime()},dataType:"jsonp","async":!0,error:function(){},success:function(e){if(0==e.ret&&0<e.data.length)for(var t=e.data,a=(new Date).getTime(),r=0,o=t.length;r<o;r++){var i="85|ad|reader|"+t[r].name;if(!t[r].remark||t[r].remark.indexOf("|")<0)return;function n(e){if(0!=e.length)if(null==e.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/))return"err"}if("err"==n(t[r].remark.split("|")[0])||"err"==n(t[r].remark.split("|")[1]))return;var s=new Date(t[r].remark.split("|")[0]),d=new Date(t[r].remark.split("|")[1]),c=t[r].imgUrl;t[r].startUrl||t[r].officialLink;if(0<=a-s&&0<=d-a){$(".readerPageWrap .goodgame").css("background-image","url("+c+")").html('<a href="'+t[r].officialLink+'" target="_blank" style="background-image: url(data:image/gif; base64,AAAA);float:right;width:50%;" id="game0825"></a><a href="'+t[r].startUrl+'" target="_blank" style="background-image: url(data:image/gif; base64,AAAA);float:left;width:50%" id="game0826"></a>').show(),$("#game0826,#game0825").click(function(){zh_spck(i)});break}}}}),h}); |