<script src="lib/zepto.min.js"></script> <script> window.jQuery = $; </script> <script src="js/jquery.base64.js"></script> <script src="js/jquery.jsonp.js"></script> <script> (function(){ var Util=(function(){ var prefix="html5_reader_" var StorageGetter=function(key){ return localStorage.getItem(prefix+key); } var StorageSetter=function(key,val){ return localStorage.setItem(prefix+key,val); } var getBSONP = function(url,callback){ return $.jsonp({ url:url, cache:true, callback:'duokan_fiction_chapter', success:function(result){ debugger var data = $.base64.decode(result); var json = decodeURIComponent(escape(data)); callback(data); } }) } return{ getBSONP:getBSONP, StorageGetter:StorageGetter, StorageSetter:StorageSetter } })(); var Win = $(window); var Doc = $(document); //节点缓存声明 var Dom = { top_nav:$('#top-nav'), bottom_nav:$('.bottom_content'), nav_pannel:$('.nav-pannel,.nav-pannel-bk'), bk_container:$('#bk-container'), bottomRight:$('.bottom_right .item-wrap') } //主程序 function main(){ var readerModel = ReaderModel(); readerModel.init(); EvetHanlder(); } //获取阅读内容 function ReaderModel(){ var Chapter_id; var init = function(){ getFictionInfo(function(){ getCurChapterContent(Chapter_id,function(){ }); }) } var getFictionInfo = function(callback){ $.get('data/chapter.json',function(data){ Chapter_id=data.chapters[1].chapter_id; callback&&callback(data); },'json'); } var getCurChapterContent = function(chapter_id,callback){ $.get('data/data'+chapter_id+'.json',function(data){ if(data.result == 0){ var url = data.jsonp; Util.getBSONP(url,function(data){ callback&&callback(data); }); } },'json') } return{ init:init } }