var _num = 100; function LastRead() { this.bookList = "bookList" } LastRead.prototype = { set: function (bid, tid, title, texttitle, read_page, author, tmpbook) { if (!(bid && tid && title && texttitle, read_page)) return; var v = bid + '#' + tid + '#' + title + '#' + texttitle + '#' + read_page + '#' + author + '#' + tmpbook; 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; i < v.length; i++) { var tem = this.getItem(v[i]).split('#'); if (i > v.length - (_num + 1)) { if (tem.length > 3) books.push(tem); } else { lastread.remove(tem[0]); } } } 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 showbook() { var showbook = document.getElementById('newcase'); var books = lastread.getBook(); var bookhtml = ''; if (books.length) { var k = 1; for (var i = books.length - 1; i > -1; i--) { var articlename = books[i][2]; var lastchapter = books[i][3]; var lastchapterid = books[i][1]; var read_page = parseInt(books[i][4]); var tmpbook_del = books[i][0]; var author = books[i][5]; var read_ym = parseInt(read_page + 1); if (books[i][6] > 0) { var articleid = parseInt(books[i][0].replace('t', '')); var shortid = parseInt(articleid / 1000); var mybook_aid = parseInt(books[i][6]); var mybook_cid = parseInt(books[i][1] - articleid); info_url = tag_info_rewrite.replace(/{aid}/, articleid); info_url = info_url.replace(/{bid}/, shortid); read_url = tag_read_rewrite.replace(/{aid}/, articleid); read_url = read_url.replace(/{bid}/, shortid); read_url = read_url.replace(/{cid}/, lastchapterid); read_page_url = tag_read_page_rewrite.replace(/{aid}/, articleid); read_page_url = read_page_url.replace(/{bid}/, shortid); read_page_url = read_page_url.replace(/{cid}/, lastchapterid); read_page_url = read_page_url.replace(/{pid}/, read_page); } else { var articleid = parseInt(books[i][0]); var shortid = parseInt(articleid / 1000); var mybook_aid = articleid; var mybook_cid = books[i][1]; info_url = info_rewrite.replace(/{aid}/, articleid); info_url = info_url.replace(/{bid}/, shortid); read_url = read_rewrite.replace(/{aid}/, articleid); read_url = read_url.replace(/{bid}/, shortid); read_url = read_url.replace(/{cid}/, lastchapterid); read_page_url = read_page_rewrite.replace(/{aid}/, articleid); read_page_url = read_page_url.replace(/{bid}/, shortid); read_page_url = read_page_url.replace(/{cid}/, lastchapterid); read_page_url = read_page_url.replace(/{pid}/, read_page); } var info_url, read_url; var c = ''; if ((k % 2) == 0) { c = 'hot_saleEm'; } if (read_page == 0) { page_word = ''; } else { page_word = '第' + read_ym + '页'; } if (read_page == 0) { jxyd = '继续阅读'; } else { jxyd = '继续阅读'; } var jxyd; bookhtml += '
小说作者:' + author + '
上次阅读:' + lastchapter + page_word + '