function jumppage() { if (event.keycode == 37) location = preview_page; if (event.keycode == 39) location = next_page; if (event.keycode == 13) location = index_page; } document.onkeydown = jumppage; var layerindex; $(function(){ getload(); $('#content').on('click', '.preload button', function(){ getload(); }); $('#content').on('click', '.loadnextpage button', function(){ layerindex = layer.msg('小说转码中...', { icon: 16 ,shade: 0.01,time: 2 }); ajaxload('id='+article_id+'&ekey='+hash+'&cid='+chapter_id+'&basecid='+chapter_id+'&nextpage='+$(this).attr('data-nextpage')+'&pagehash='+$(this).attr('data-pagehash'), chapter_id, false); }); }) function getload(){ if($('.preload').length <= 0){ return; } var loadnum = math.floor(getcookie('loadnum_' + article_id + '_' + chapter_id)); if(loadnum >= 2){ layerindex = layer.msg('转码失败,将进入源站阅读...', { icon: 16 ,shade: 0.01,time: 5 }); setcookie('loadnum_' + article_id + '_' + chapter_id, 0); $('#source').attr('src', sourceurl); $('#source').show(); $('#ifexplorer').css('height', window.innerheight - 150 + 'px'); $('#content').hide(); } else { setcookie('loadnum_' + article_id + '_' + chapter_id, loadnum + 1); layerindex = layer.msg('小说转码中...', { icon: 16 ,shade: 0.01,time: 2 }); $('#content').html(preloadhtml); ajaxload('id='+article_id+'&ekey='+hash+'&cid='+chapter_id+'&basecid='+chapter_id, chapter_id, false); } } function ajaxload(postdata, cid, _async){ var res = ''; $.ajax({ type:'post', url:'/home/index/ajaxchapter', data:postdata, async: true, datatype: "json", success: function(data){ if(data.status == 'success'){ res = data.info.content; if(!_async){ var toloadhtml = ''; if(data.nextpage){ toloadhtml = '
'; } $('#content').html(res+toloadhtml); if(document.getelementbyid("cload")){ $('#cload').html(data.info.chaptercont_par + toloadhtml); content_init(); } if(cid == chapter_id && nextcid > -1){ ajaxload('id='+article_id+'&ekey='+hash+'&cid='+nextcid+'&basecid='+chapter_id, nextcid, true); } if(cid == nextcid || nextcid == -1){ ajaxload('id='+article_id+'&ekey='+hash+'&cid='+prevcid+'&basecid='+chapter_id, prevcid, true); } } } else { if(!_async){ $('#content').html('转码失败,请重试!
'); } } } }); }