/* if (navigator.userAgent.toLowerCase().match(/(ipod|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null) { let url = window.location.href; window.location = url.replace("//www", "//m"); } */ // function login() { // if ($.cookie('ss_username')) { // document.writeln('欢迎你: '+$.cookie('ss_username')+' | 退出登录'); // } else { // document.writeln('用户登陆 | 用户注册'); // } // } function search() { document.writeln('
'); document.writeln(''); document.writeln(""); document.writeln('
'); } function textselect() { document.writeln(''); } function formatDate(time) { var date = new Date(time); var month = date.getMonth()+1; var day = date.getDate(); var hour = date.getHours(); var minute = date.getMinutes(); if (month < 10) month = '0' + month; if (day < 10) day = '0' + day; if (hour < 10) hour = '0' + hour; if (minute < 10) minute = '0' + minute; return month+'-'+day+' '+hour+':'+minute; } function init(type){ var articleid = $('body').attr('article-id') || 0, chapterid = $('body').attr('chapter-id') || 0; if (chapterid > 0) { var book = {name:$('body').attr('article-name'),author:$('body').attr('article-author'),dataid:$('body').attr('data-id')||0,readid:chapterid,readname:$('h1').text(),readtime:$.now()}; window.localStorage.setItem('book_'+articleid, JSON.stringify(book)); var theme = function(v){ if (typeof v === 'undefined') v = window.localStorage.getItem('theme') || 'day'; $('body').attr('class', v); $('li.theme a.'+v).addClass('on').siblings().removeClass('on'); window.localStorage.setItem('theme', v); }; var size = function(v){ if (typeof v === 'undefined') v = parseInt(window.localStorage.getItem('size')) || 24; $('li.size a.num').text(v); $('#content').css('font-size', v); $('li.size a').removeClass('disabled'); if (v<=10) $('li.size a.dec').addClass('disabled'); if (v>=50) $('li.size a.inc').addClass('disabled'); $('#fontsize').text(v); window.localStorage.setItem('size', v); }; $('li.theme a').click(function(){ theme($(this).attr('class')); }); $('li.size a').click(function(){ if ($(this).hasClass('disabled')) return; size(parseInt($('#fontsize').text()) + ($(this).hasClass('dec') ? -2 : 2)); }); $('li.reset').click(function(){ theme('day'); size(24); }); theme(); size(); $(document).keydown(function(e){ switch (e.which) { case 37: $(window).attr('location', $('#pager_prev').attr('href')); break; case 39: $(window).attr('location', $('#pager_next').attr('href')); break; case 13: $(window).attr('location', $('#pager_current').attr('href')); break; } }); } } function showone(n){ $('.commend').hide(); $('#ft'+n).show(); } function addbookcase(aid,name,cid,cname){ if($.cookie('ss_userid') && $.cookie('PHPSESSID') != -1) { rico_data = { articleid: aid, articlename: name, chapterid: cid, chaptername: cname } $.ajax({ type: "post", url: "/addbookcase/", data: rico_data, success: function(data){ alert(data); } }) }else{ if (window.confirm("\n永久书架需要登录才能使用,转到登录页面吗?")) { window.location.href = "/login/"; }else{ return; } } } function delbookcase(aid){ if (window.confirm("\n确定要删除吗?")) { if($.cookie('ss_userid') && $.cookie('PHPSESSID') != -1) { rico_data = { articleid: aid, }, $.ajax({ type: "post", url: "/delbookcase/", data: rico_data, success: function(data){ alert(data); window.location.reload(); } }) } }else{ return; } } function register_check() { if ($('#regname').val() == '' || $('#regpass').val() == '' || $('#repass').val() == '' || $('#email').val() == '') { alert('每项都必须填写'); return false; }; if($('#regpass').val() !== $('#repass').val()){ alert('两次输入的密码不一致'); return false; } return true; } function gotop(){$('body,html').animate({scrollTop:0},100);} let bookmax = 50; function LastRead(){this.bookList="bookList"} LastRead.prototype={ set:function(bid,uri,bookname,chaptername,author,img_url){ if(!(bid&&uri&&bookname&&chaptername&&author&&img_url))return; var v=bid+'#'+uri+'#'+bookname+'#'+chaptername+'#'+author+'#'+img_url; var aBooks = lastread.getBook(); var aBid = new Array(); for (i=0; i= bookmax) { lastread.remove(aBooks[0][0]); aBooks = lastread.getBook(); } } this.setItem(bid,v); this.setBook(bid) }, get:function(k){ return this.getItem(k)?this.getItem(k).split("#"):""; }, remove:function(k){ this.removeItem(k); this.removeBook(k) }, setBook:function(v){ var reg=new RegExp("(^|#)"+v); var books = this.getItem(this.bookList); if(books==""){ books=v; } else{ if(books.search(reg)==-1){ books+="#"+v; } else{ books.replace(reg,"#"+v); } } this.setItem(this.bookList,books) }, getBook:function(){ var v=this.getItem(this.bookList)?this.getItem(this.bookList).split("#"):Array(); var books=Array(); if(v.length){ for(var i=0;i3)books.push(tem); } } return books }, removeBook:function(v){ var reg=new RegExp("(^|#)"+v); var books=this.getItem(this.bookList); if(!books){ books=""; } else{ if(books.search(reg)!=-1){ books=books.replace(reg,""); } } this.setItem(this.bookList,books) }, setItem:function(k,v){ if(!!window.localStorage){ localStorage.setItem(k,v); } else{ var expireDate=new Date(); var EXPIR_MONTH=30*24*3600*1000; expireDate.setTime(expireDate.getTime()+12*EXPIR_MONTH); document.cookie=k+"="+encodeURIComponent(v)+";expires="+expireDate.toGMTString()+"; path=/"; } }, getItem:function(k){ var value=""; var result=""; if(!!window.localStorage){ result=window.localStorage.getItem(k); value=result||""; } else{ var reg=new RegExp("(^| )"+k+"=([^;]*)(;|\x24)"); var result=reg.exec(document.cookie); if(result){ value=decodeURIComponent(result[2])||""; } } return value }, removeItem:function(k){ if(!!window.localStorage){ window.localStorage.removeItem(k); } else{ var expireDate=new Date(); expireDate.setTime(expireDate.getTime()-1000); document.cookie=k+"= "+";expires="+expireDate.toGMTString(); } }, removeAll:function(){ if(!!window.localStorage){ window.localStorage.clear(); } else{ var v=this.getItem(this.bookList)?this.getItem(this.bookList).split("#"):Array(); var books=Array(); if(v.length){ for( i in v ){ var tem=this.removeItem(v[k]); } } this.removeItem(this.bookList); } } } function removebook(k){lastread.remove(k);showtempbooks();}function removeall(){lastread.removeAll();showtempbooks();} function showtempbooks(){ var books=lastread.getBook().reverse(); //倒序 bookhtml = ''; if (books.length){ for(var i=0 ;i'; bookhtml += '

'+books[i][2]+'

作者:'+books[i][4]+'

'; bookhtml += '

已读到:'+books[i][3]+'

'; bookhtml += ''; bookhtml += ''; */ bookhtml += '
  • '+books[i][5]+''+books[i][2]+''+books[i][3]+''+books[i][4]+'删除
  • '; } } }else{ bookhtml += '还没有阅读记录哦 ( ˙﹏˙ )( ˙﹏˙ ),去找找书看吧。'; } $("#tempBookcase").html(bookhtml); } window.lastread = new LastRead();