1// PC 2function delHistoryArticlePC(articleid){ 3 $('.nav-user-first .history-content #article_'+articleid).remove(); 4 history_delete(articleid); 5 if($('.nav-user-first .history-content .history-item').length == 0){ 6 $('.nav-user-first .history-content').html(`<div class="empty">ÔÝʱûÓÐÔĶÁ¼Ç¼</div>`); 7 } 8} 9// PC 10function showHistoryListPC(){ 11 var historyList = history_get(); 12 $('.nav-user-first .history-content').html(''); 13 if(historyList.length){ 14 for(var i=0;i<historyList.length;i++){ 15 var articleInfo = historyList[i]; 16 $('.nav-user-first .history-content').append(` 17 <div class="history-item clearfix" id="article_${articleInfo.articleid}"> 18 <a href="${articleInfo.articlelink}" class="history-img fl"> 19 <div class="cover-box"> 20 <img src="${articleInfo.cover_image}" alt="${articleInfo.articlename}"> 21 </div> 22 </a> 23 <div class="history-info tl"> 24 <a href="${articleInfo.articlelink}"><h1 class="line-clamp-1">${articleInfo.articlename}</h1></a> 25 <p class="line-clamp-1"><span class="tag">×÷Õߣº</span><a>${articleInfo.author?articleInfo.author:'ÔÝÎÞ'}</a></p> 26 <p class="line-clamp-1"><span class="tag">¶Áµ½£º</span><a href="${articleInfo.chapterlink_read}">${articleInfo.chaptername_read}</a></p> 27 <p class="clearfix"><span onclick='delHistoryArticlePC(${articleInfo.articleid})' class="tag delete">ɾ³ý</span><a href="${articleInfo.chapterlink_read}" class="select-color fr">µã»÷¼ÌÐøÔĶÁ>></a></p> 28 </div> 29 </div> 30 `); 31 } 32 }else{ 33 $('.nav-user-first .history-content').html(`<div class="empty">ÔÝʱûÓÐÔĶÁ¼Ç¼</div>`); 34 } 35} 36 37// h5 38function delHistoryArticleH5(articleid){ 39 $('.history-page .block-content #'+articleid).remove(); 40 history_delete(articleid); 41 if($('.history-page .block-content li').length == 0){ 42 $('.history-page .block-content').html(`<div class="mt30 tc mb30"><img src="/style/empty.svg" style="width:10rem;"><div class="mt10">±§Ç¸£¬ÔÝÎÞÔĶÁÀúÊ·</div></div>`); 43 } 44} 45// h5 46function showHistoryListH5(){ 47 var historyList = history_get(); 48 $('.history-page .block-content').html(''); 49 if(historyList.length){ 50 for(var i=0;i<historyList.length;i++){ 51 var articleInfo = historyList[i]; 52 $('.history-page .block-content').append(` 53 <li class="block-img-item clearfix" id="${articleInfo.articleid}"> 54 <a href="${articleInfo.articlelink}" class="article-img"> 55 <img height="100" width="80" src="${articleInfo.cover_image}" onerror="this.src='/style/noimg.jpg'"> 56 </a> 57 <div class="article-info"> 58 <a href="${articleInfo.articlelink}" class="title line-clamp-1">${articleInfo.articlename}</a> 59 <a href="/author/${articleInfo.author}.html" class="author">×÷Õߣº${articleInfo.author?articleInfo.author:'ÔÝÎÞ'}</a> 60 <a href="${articleInfo.chapterlink_read}" class="author line-clamp-1">¿´µ½£º${articleInfo.chaptername_read}</a> 61 <span><a onclick='delHistoryArticleH5(${articleInfo.articleid})'><font color=red>ÔÚÁбíÖÐɾ³ý±¾Êé</font></a></span> 62 </div> 63 </li> 64 `); 65 } 66 }else{ 67 $('.history-page .block-content').html(`<div class="mt30 tc mb30"><img src="/style/empty.svg" style="width:10rem;"><div class="mt10">±§Ç¸£¬ÔÝÎÞÔĶÁÀúÊ·</div></div>`); 68 } 69} 70// ±£´æµ±Ç°ÔĶÁÊý¾Ý 71function history_save(articleInfo){ 72 console.log('±£´æÔĶÁ¼Ç¼',articleInfo); 73 var articleKey = 'read_book'; 74 var articleid = articleInfo.articleid?articleInfo.articleid:0; 75 var articlename = articleInfo.articlename?articleInfo.articlename:''; 76 var articlelink = articleInfo.articlelink?articleInfo.articlelink:''; 77 var cover_image = articleInfo.cover_image?articleInfo.cover_image:''; 78 var author = articleInfo.author?articleInfo.author:''; 79 if(!articleid || !articlename || !cover_image)return {status:false,desc:'Êý¾ÝÒì³£'}; 80 var chapterid_read = articleInfo.chapterid_read?articleInfo.chapterid_read:0; 81 var chaptername_read = articleInfo.chaptername_read?articleInfo.chaptername_read:''; 82 var chapterlink_read = articleInfo.chapterlink_read?articleInfo.chapterlink_read:''; 83 84 // »ñÈ¡±£´æµÄÊý¾Ý 85 var read_book = localStorage.getItem(articleKey); 86 read_book = read_book?read_book.split('#'):[]; 87 var new_read_book = [articleid]; 88 read_book.map(function(item){ 89 if(item != articleid){ 90 new_read_book.push(item); 91 } 92 }); 93 // ±£´æ×îеÄ×÷Æ·id
94 localStorage.setItem(articleKey,new_read_book.join('#')); 95 // ¿ªÊ¼´¦ÀíÕÂ½Ú 96 var articleInfo = { 97 articleid:articleid, 98 articlename:articlename, 99 articlelink:articlelink, 100 cover_image:cover_image, 101 author:author, 102 chapterid_read:chapterid_read, 103 chaptername_read:chaptername_read, 104 chapterlink_read:chapterlink_read 105 } 106 localStorage.setItem(articleid,JSON.stringify(articleInfo)); 107} 108// »ñÈ¡×÷Æ·ÔĶÁÐÅÏ¢ 109function history_get(){ 110 var articleKey = 'read_book'; 111 var history_list = []; 112 var read_book = localStorage.getItem(articleKey); 113 read_book = read_book?read_book.split('#'):[]; 114 for(var i=0;i<read_book.length;i++){ 115 var tempInfo = localStorage.getItem(read_book[i]) 116 history_list.push(JSON.parse(tempInfo)); 117 } 118 return history_list; 119} 120// ɾ³ýÔĶÁÀúÊ· 121function history_delete(articleid){ 122 console.log('ɾ³ýÔĶÁÀúÊ·',articleid); 123 var articleKey = 'read_book'; 124 var read_book = localStorage.getItem(articleKey); 125 read_book = read_book?read_book.split('#'):[]; 126 if(articleid){ 127 var new_read_book = []; 128 read_book.map(function(item){ 129 if(item != articleid){ 130 new_read_book.push(item); 131 } 132 }); 133 // ±£´æ×îеÄ×÷Æ·id 134 localStorage.setItem(articleKey,new_read_book.join('#')); 135 localStorage.removeItem(articleid); 136 }else{ 137 read_book.map(function(item){ 138 localStorage.removeItem(item); 139 }); 140 localStorage.removeItem(articleKey); 141 } 142}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.