1(async function (doc, win, layer, hotRankList, keyword) { 2 const sanitizeSearchKeyword = (k) => { 3 let out = '', cn = 0, en = 0; 4 for (const ch of String(k ?? '')) { 5 if (/[\u4e00-\u9fa5]/.test(ch)) { 6 if (cn < 20) { out += ch; cn++; } 7 } else if (/[a-zA-Z0-9]/.test(ch)) { 8 if (en < 30) { out += ch; en++; } 9 } 10 } 11 return out; 12 }; 13 const tipInvalidKeyword = (raw) => { if (raw) layer.msg('å ³é®è¯ä» æ¯æä¸æã忝忰å'); }; 14 const buildSearchUrl = (k) => `/search/${encodeURIComponent(sanitizeSearchKeyword(k))}/`; 15 // å表(æç´¢ç»æ) 16 class SortList { 17 constructor(selector, url) { 18 const _this = this; 19 this.$archive = () => $(selector); 20 this.keyword = keyword; 21 this.url = url; 22 this.sort = ''; 23 this.page = 1; 24 25 // åé 26 $(document).on('change', '.xqbj-search-sort input[name="searchsort"][type="radio"]', function() { 27 _this.sort = $(this).val(); 28 _this.page = 1; 29 _this.load(); 30 }); 31 } 32 33 // å ¥å£æ¹æ³ 34 load() { 35 this.showLoading(); 36 this.fetchData() 37 .done((html) => { 38 this.renderList(html); 39 this.bindEvents(); 40 }) 41 .fail(() => { 42 layer.msg('æ°æ®è¯·æ±å¤±è´¥'); 43 }) 44 .always(() => { 45 this.goTop(); 46 setTimeout(() => { 47 layer.closeAll('loading') 48 }, 500); 49 }); 50 } 51 52 // è¯·æ± 53 fetchData() { 54 const data = { 55 q: this.keyword, 56 sort: this.sort, 57 page: this.page, 58 }; 59 60 return $.ajax({ 61 url: this.url, 62 method: 'GET', 63 data 64 }); 65 } 66 67 // 渲æ[å端å¤ç] 68 renderList(html) { 69 this.$archive().fadeOut('fast', () => { 70 // [å端å¤ç] 71 // this.$archive.replaceWith(this.listTemplate()).fadeIn(300); 72 this.$archive().replaceWith(html).fadeIn(300); 73 }); 74 } 75 76 // 模æ¿(å表 + å页)[å端å¤ç] 77 listTemplate = (html) => { 78 return ` 79 <div id="archive" role="main"> 80 <article itemscope itemtype="http://schema.org/BlogPosting" class=""> 81 <div class="display-none" itemscope itemprop="author" itemtype="http://schema.org/Person"> 82 <meta itemprop="name" content="çç"/> 83 <meta itemprop="url" content=""/> 84 </div> 85 <div class="display-none" itemscope itemprop="publisher" itemtype="http://schema.org/Organization"> 86 <meta itemprop="name" content="çç"/> 87 <div itemscope itemprop="logo" itemtype="http://schema.org/ImageObject"> 88 <meta itemprop="url" content="/usr/themes/Mirages/images/51cg.png?v=3&s=50&r=G&d="> 89 </div> 90 </div> 91 <meta itemprop="url mainEntityOfPage" content="https://51cg1.com/archives/207221/" /> 92 <meta itemprop="dateModified" content="2025-05-19T09:10:30+00:00"> 93 <a href="https://51cg1.com/archives/207221/" > 94 <div class="post-card" id="post-card-207221" > 95 <div class="blog-background"></div> 96 <script type="text/javascript"> 97 loadBannerDirect('https://pic.sqbcn.cn/upload_01/xiao/20250517/2025051717181423596.jpeg', '', document.querySelector('#post-card-207221'), '-1', document.querySelector('#post-card-207221').offsetWidth, document.querySelector('#post-card-207221').offsetHeight); 98 </script> 99 <div class="post-card-mask "> 100 <div class="post-card-container"> 101 <h2 class="post-card-title" itemprop="headline">æ¥æ¬AV女ä¼è·¯è¾¹æ©ç´ 人 å¶éä¸å½çç·ä¸é è½¦å æ¿ææä¹ çé äºåç©50䏿¥å æåå¥³ä¼ å½¢è±¡ç¬é´é«å¤§ï¼</h2> 102 <div class="post-card-info">
103 <span itemprop="author" itemscope itemtype="http://schema.org/Person">çç ⢠</span> <span itemprop="datePublished" content="2025-05-17T16:18:00+00:00">2025 å¹´ 05 æ 17 æ¥ â¢ </span> 104 <span>仿¥åç, çç娱ä¹</span> 105 </div> 106 </div> 107 </div> 108 </div> 109 </a> 110 </article> 111 <article itemscope itemtype="http://schema.org/BlogPosting" class=""> 112 <div class="display-none" itemscope itemprop="author" itemtype="http://schema.org/Person"> 113 <meta itemprop="name" content="ç表妹"/> 114 <meta itemprop="url" content=""/> 115 </div> 116 <div class="display-none" itemscope itemprop="publisher" itemtype="http://schema.org/Organization"> 117 <meta itemprop="name" content="ç表妹"/> 118 <div itemscope itemprop="logo" itemtype="http://schema.org/ImageObject"> 119 <meta itemprop="url" content="/usr/themes/Mirages/images/51cg.png?v=3&s=50&r=G&d="> 120 </div> 121 </div> 122 <meta itemprop="url mainEntityOfPage" content="https://51cg1.com/archives/206994/" /> 123 <meta itemprop="dateModified" content="2025-05-19T09:10:36+00:00"> 124 <a href="https://51cg1.com/archives/206994/" > 125 <div class="post-card" id="post-card-206994" > 126 <div class="blog-background"></div> 127 <script type="text/javascript"> 128 loadBannerDirect('https://pic.sqbcn.cn/upload_01/xiao/20250516/2025051621385232406.jpeg', '', document.querySelector('#post-card-206994'), '-1', document.querySelector('#post-card-206994').offsetWidth, document.querySelector('#post-card-206994').offsetHeight); 129 </script> 130 <div class="post-card-mask "> 131 <div class="post-card-container"> 132 <h2 class="post-card-title" itemprop="headline">å°æ¹¾æåç¦å©å§¬å¥³ç¥ 波衣 éå ·èªæ °å·æ°´ç§æåé è¿è·ç¦»å±ç¤ºç¾ä¹³å«©ç©´æ éé æ å¨åå¾é诱人ï¼</h2> 133 <div class="post-card-info"> 134 <span itemprop="author" itemscope itemtype="http://schema.org/Person">ç表妹 ⢠</span> <span itemprop="datePublished" content="2025-05-17T16:00:00+00:00">2025 å¹´ 05 æ 17 æ¥ â¢ </span> 135 <span>仿¥åç, ç½çº¢é»æ</span> 136 </div> 137 </div> 138 </div> 139 </div> 140 </a> 141 </article> 142 <article itemscope itemtype="http://schema.org/BlogPosting" class=""> 143 <div class="display-none" itemscope itemprop="author" itemtype="http://schema.org/Person"> 144 <meta itemprop="name" content="ç表妹"/> 145 <meta itemprop="url" content=""/> 146 </div> 147 <div class="display-none" itemscope itemprop="publisher" itemtype="http://schema.org/Organization"> 148 <meta itemprop="name" content="ç表妹"/> 149 <div itemscope itemprop="logo" itemtype="http://schema.org/ImageObject"> 150 <meta itemprop="url" content="/usr/themes/Mirages/images/51cg.png?v=3&s=50&r=G&d="> 151 </div> 152 </div> 153 <meta itemprop="url mainEntityOfPage" content="https://51cg1.com/archives/206989/" /> 154 <meta itemprop="dateModified" content="2025-05-19T09:10:44+00:00"> 155 <a href="https://51cg1.com/archives/206989/" > 156 <div class="post-card" id="post-card-206989" > 157 <div class="blog-background"></div> 158 <script type="text/javascript"> 159 loadBannerDirect('https://pic.sqbcn.cn/upload_01/xiao/20250516/2025051620282659908.jpeg', '', document.querySelector('#post-card-206989'), '-1', document.querySelector('#post-card-206989').offsetWidth, document.querySelector('#post-card-206989').offsetHeight); 160 </script> 161 <div class="post-card-mask "> 162 <div class="post-card-container"> 163 <h2 class="post-card-title" itemprop="headline">æååå·®å¥³ç¥ ç§æéå ·æç©´ç¹å ç²å«©èç©´æ·«æ°´æ³æ»¥ èæ¡è髿½®å·æ¶ ç»é¢æ©å°çï¼</h2> 164 <div class="post-card-info">
165 <span itemprop="author" itemscope itemtype="http://schema.org/Person">ç表妹 ⢠</span> <span itemprop="datePublished" content="2025-05-17T15:30:00+00:00">2025 å¹´ 05 æ 17 æ¥ â¢ </span> 166 <span>仿¥åç, éªç·éªå¥³</span> 167 </div> 168 </div> 169 </div> 170 </div> 171 </a> 172 </article> 173 <article itemscope itemtype="http://schema.org/BlogPosting" class=""> 174 <div class="display-none" itemscope itemprop="author" itemtype="http://schema.org/Person"> 175 <meta itemprop="name" content="çäºå¥"/> 176 <meta itemprop="url" content=""/> 177 </div> 178 <div class="display-none" itemscope itemprop="publisher" itemtype="http://schema.org/Organization"> 179 <meta itemprop="name" content="çäºå¥"/> 180 <div itemscope itemprop="logo" itemtype="http://schema.org/ImageObject"> 181 <meta itemprop="url" content="/usr/themes/Mirages/images/51cg.png?v=3&s=50&r=G&d="> 182 </div> 183 </div> 184 <meta itemprop="url mainEntityOfPage" content="https://51cg1.com/archives/207136/" /> 185 <meta itemprop="dateModified" content="2025-05-19T09:09:56+00:00"> 186 <a href="https://51cg1.com/archives/207136/" > 187 <div class="post-card" id="post-card-207136" > 188 <div class="blog-background"></div> 189 <script type="text/javascript"> 190 loadBannerDirect('https://pic.sqbcn.cn/upload_01/xiao/20250516/2025051621454710950.jpeg', '', document.querySelector('#post-card-207136'), '-1', document.querySelector('#post-card-207136').offsetWidth, document.querySelector('#post-card-207136').offsetHeight); 191 </script> 192 <div class="post-card-mask "> 193 <div class="post-card-container"> 194 <h2 class="post-card-title" itemprop="headline">æé³æ¨ç¹åå¹³å°åå·®æ¯ç é²è¸èªæ °è£¸èåé æå¥¶é²ç©´è¶ çº§æ·«éª æ§æèº«æä»¤äººè¡èå·å¼ ï¼</h2> 195 <div class="post-card-info"> 196 <span itemprop="author" itemscope itemtype="http://schema.org/Person">çäºå¥ ⢠</span> <span itemprop="datePublished" content="2025-05-17T15:21:00+00:00">2025 å¹´ 05 æ 17 æ¥ â¢ </span> 197 <span>仿¥åç, ç½çº¢é»æ</span> 198 </div> 199 </div> 200 </div> 201 </div> 202 </a> 203 </article> 204 205 <div class="page-nav page-nav-ajax"> 206 <div class="page-jump"> 207 <div id="pageForm" method="get"> 208 <span class="page-info"> 12/518 </span> 209 <input type="number" id="pageNum"> 210 <button id="submitBtn">跳转</button> 211 </div> 212 </div> 213 <ul class="page-navigator"> 214 <li class="prev"><a href="javascript:void(0);" data-page="11">ä¸ä¸é¡µ</a></li> 215 <li><span></span></li> 216 <li class="next"><a href="javascript:void(0);" data-page="13">ä¸ä¸é¡µ</a></li> 217 </ul> 218 </div> 219 </div> 220 `; 221 } 222 223 // äºä»¶ 224 bindEvents() { 225 const _this = this; 226 $(doc).off('click.pageNav') 227 228 // ä¸ä¸é¡µ 229 .on('click.pageNav', '.page-nav-ajax .prev a', function (e) { 230 e.preventDefault(); 231 _this.page = $(this)?.data('page') || 1; 232 // console.log('prev clicked', $(this).data('page')); 233 _this.load(); 234 }) 235 236 // ä¸ä¸é¡µ 237 .on('click.pageNav', '.page-nav-ajax .next a', function (e) { 238 e.preventDefault(); 239 _this.page = $(this)?.data('page') || 1; 240 _this.load(); 241 }) 242 243 // 跳转æé® 244 .on('click.pageNav', '.page-nav-ajax #submitBtn', function (e) { 245 e.preventDefault(); 246 const input = $(this).closest('.page-nav-ajax').find('input').val(); 247 248 _this.page = (1 * input || 1); 249 _this.load(); 250 }); 251 } 252 253 // æ¾ç¤ºå è½½å¨ç» 254 showLoading() { 255 layer.load(0); 256 } 257 258 // æ¾ç¤ºå è½½å¨ç» 259 goTop() { 260 window.scrollTo({ 261 top: 0, 262 behavior: 'smooth' 263 }); 264 } 265 } 266 267 // 导èª(头é¨å¯¼èª) 268 class NavSearch { 269 constructor(hoturl, url, throttleInterval, keyLength) { 270 const _this = this; 271 this.hoturl = hoturl; 272 this.url = url; 273 this.throttleInterval = throttleInterval; 274 this.keyLength = keyLength; 275 this.domparser = new DOMParser(); 276 277 // 模æ¿å®ä¹(åå²) 278 this.hotTemplate = (c = []) => { 279 const list = Array.isArray(c) ? c.slice(0, 10) : []; 280 const hasData = list.length > 0; 281 return ` 282 <div class="container-search-context"> 283 <div class="search-container"> 284 <div class="search-title">
285 <span>åå²è®°å½</span> 286 <div class="r-text on-history-clear"> 287 <div class="xqbj-icon-delete icon"></div> 288 æ¸ ç©ºè®°å½ 289 </div> 290 </div> 291 <div class="container-search-tags"> 292 <div class="list history-record"> 293 <div class="no-data">ææ æ°æ®</div> 294 </div> 295 </div> 296 297 <div class="search-title search-border"> 298 <span>çé¨æç´¢</span> 299 </div> 300 <div class="container-search-hots"> 301 ${ 302 hasData 303 ? ` 304 <div class="rank-list"> 305 ${(c.slice(0, 10)).map((e, index) => ` 306 <a href="${e.permalink}" class="rank-card"> 307 ${index <= 2 ? `<div class="xqbj-icon-rank-${index + 1}"></div>` : `<div class="rank-card-icon">${index + 1}</div>`} 308 <div class="rank-card-title text-line-ellipsis-1"> 309 ${e.title} 310 </div> 311 ${index <= 9 ? `<i class="xqbj-icon-hot"></i>` : ``} 312 <div class="view">${e.hot_formatted} ç度</div> 313 </a> 314 `).join("")} 315 </div> 316 ` 317 : `<div class="no-data">ææ æ°æ®</div>` 318 } 319 </div> 320 </div> 321 </div> 322 `; 323 }; 324 325 326 this.seaTemplate = (c) => { 327 const list = Array.isArray(c?.list) ? c.list.slice(0, 20) : []; 328 if (list.length === 0) return ""; 329 330 return ` 331 <div class="container-search-context"> 332 <div class="search-container"> 333 <div class="container-search-hots container-search-lists"> 334 <div class="rank-list"> 335 ${list.map((e) => ` 336 <a href="${e.url}" class="rank-card"> 337 <div class="xqbj-icon-search1"></div> 338 <div class="rank-card-title text-line-ellipsis-1">${e.title ?? ""}</div> 339 </a> 340 `).join("")} 341 </div> 342 </div> 343 </div> 344 </div> 345 `; 346 }; 347 348 349 // 2026-03-23 start 350 $(document).on('click', '.expand-btn', function (event) { 351 event.stopPropagation(); // 鲿¢å泡 352 $('ul.expand-contract-group').toggle(); 353 }); 354 355 // ç¹å»å ¶ä»å°æ¹å ³é 356 $(document).on('click', function (event) { 357 if ( 358 !$(event.target).closest('.expand-btn').length && 359 !$(event.target).closest('ul.expand-contract-group').length 360 ) { 361 $('ul.expand-contract-group').hide(); 362 } 363 }); 364 // 2026-03-23 end 365 366 // åå§(mobile) 367 $(doc).on('click', 'form#search-form', function () { 368 top.location.href = '/search-page.html'; 369 }); 370 371 // è¾å ¥(mobile) 372 $(doc).on('input', '#input-mobile-control-key', _this.debounce(function() { 373 const navSearchContainer = $(this).closest('.nav-search-container'); 374 const hotSearchContainer = navSearchContainer.find('.container-hot-search').get(0); 375 const listSearchContainer = navSearchContainer.find('.container-list-search').get(0);
376 const keyword = $(this).val().trim(); 377 378 if (keyword) { 379 _this.fetchSearchData(keyword) 380 .done((d) => { 381 const data = { 382 list: d.map(e => ({ title: e, url: buildSearchUrl(e) })) 383 }; 384 385 // 渲è²å¤ç 386 data.list = data.list.map(item => { 387 const safeKeyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); 388 const regex = new RegExp(safeKeyword, 'g'); 389 390 return { 391 ...item, 392 title: item.title.replace(regex, `<span class="keyword">${keyword}</span>`) 393 }; 394 }); 395 396 // ä¹±åºå¤ç 397 // data.list = data.list.sort(() => Math.random() - 0.5); 398 399 // æ¨¡æ¿æå»º 400 const tpl = _this.seaTemplate(data); 401 402 // æ¨¡æ¿æ¸²æ 403 $(listSearchContainer).html(tpl); 404 }) 405 .fail(() => { 406 // layer.msg('æ°æ®è¯·æ±å¤±è´¥'); 407 // console.log('æ°æ®è¯·æ±å¤±è´¥'); 408 }) 409 .always(() => { 410 $(listSearchContainer).addClass('show'); 411 $(hotSearchContainer).removeClass('show'); 412 }); 413 } else { 414 $(listSearchContainer).removeClass('show'); 415 $(hotSearchContainer).removeClass('show'); 416 } 417 }, _this.throttleInterval)); 418 419 420 // æç´¢(pc) 421 $(doc).on('click', '.input-mobile-search-btn-pc', function () { 422 onPcInputSearch() 423 }); 424 // æç´¢(pc)å车äºä»¶ 425 $(doc).on('keydown', '.search-input', function (event) { 426 if (event.keyCode === 13) { 427 event.preventDefault(); 428 onPcInputSearch() 429 } 430 }) 431 // pcæç´¢å¤çé»è¾ 432 function onPcInputSearch(event) { 433 const keywordval = $('.search-input').val().trim(); 434 const keywordhtml = _this.domparser.parseFromString(keywordval, 'text/html'); 435 const keyword = sanitizeSearchKeyword(keywordhtml.body.textContent); 436 437 if(keyword.length < 1) { 438 tipInvalidKeyword(keywordval); 439 return; 440 } 441 try { 442 // éè¦[å端å¤ç] 443 top.location.href = buildSearchUrl(keyword); 444 } finally { 445 $HistoryRecord.add(keyword); 446 } 447 } 448 449 // æç´¢(mobile) 450 $(doc).on('click', '.input-mobile-search-btn', function () { 451 const navSearchContainer = $(this).closest('.van-nav-bar'); 452 const keywordval = navSearchContainer.find('#input-mobile-control-key').val().trim(); 453 const keywordhtml = _this.domparser.parseFromString(keywordval, 'text/html'); 454 const keyword = sanitizeSearchKeyword(keywordhtml.body.textContent); 455 456 if(keyword.length < 1) { 457 tipInvalidKeyword(keywordval); 458 return; 459 } 460 try { 461 // éè¦[å端å¤ç] 462 top.location.href = buildSearchUrl(keyword); 463 } finally { 464 $HistoryRecord.add(keyword); 465 } 466 }); 467 468 // xf0714 æç´¢-é®ç(mobile) start 469 $('#input-mobile-control-key').on('keydown', function (event) { 470 if (event.key === 'Enter') { 471 event.preventDefault(); // 鲿¢è¡¨åæäº¤ 472 const navSearchContainer = $(this).closest('.van-nav-bar');
473 const keywordval = navSearchContainer.find('#input-mobile-control-key').val().trim(); 474 const keywordhtml = _this.domparser.parseFromString(keywordval, 'text/html'); 475 const keyword = sanitizeSearchKeyword(keywordhtml.body.textContent); 476 if (!keyword) { 477 tipInvalidKeyword(keywordval); 478 return; 479 } 480 try { 481 // éè¦[å端å¤ç] 482 top.location.href = buildSearchUrl(keyword); 483 } finally { 484 $HistoryRecord.add(keyword); 485 } 486 } 487 }); 488 // xf0714 æç´¢-é®ç(mobile) end 489 490 491 // åå§(desktop) 492 $(doc).on('click', '.nav-search-container.nav-search-container-hook', function () { 493 // $(this).addClass('expand').find('#input-desktop-control-key').focus(); 494 win.location.href = '/search-page.html'; 495 }); 496 497 // è¾å ¥(desktop) 498 // $(doc).on('input', '#input-desktop-control-key', _this.debounce(function() { 499 // const navSearchContainer = $(this).closest('.nav-search-container'); 500 // const hotSearchContainer = navSearchContainer.find('.container-hot-search').get(0); 501 // const listSearchContainer = navSearchContainer.find('.container-list-search').get(0); 502 // const keywordhtml = _this.domparser.parseFromString($(this).val(), 'text/html'); 503 // const keyword = keywordhtml.body.textContent; 504 // 505 // if(keyword.length < 1) { 506 // return; 507 // } 508 // if (keyword) { 509 // _this.fetchSearchData(keyword) 510 // .done((d) => { 511 // 512 // const data = { 513 // list: d.map(e => ({ title: e, url: buildSearchUrl(e) })) 514 // }; 515 // 516 // // 渲è²å¤ç 517 // data.list = data.list.map(item => { 518 // const safeKeyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); 519 // const regex = new RegExp(safeKeyword, 'g'); 520 // 521 // return { 522 // ...item, 523 // title: item.title.replace(regex, `<span class="keyword">${keyword}</span>`) 524 // }; 525 // }); 526 // 527 // // ä¹±åºå¤ç 528 // // data.list = data.list.sort(() => Math.random() - 0.5); 529 // 530 // // æ¨¡æ¿æå»º 531 // const tpl = _this.seaTemplate(data); 532 // 533 // // æ¨¡æ¿æ¸²æ 534 // $(listSearchContainer).html(tpl); 535 // }) 536 // .fail(() => { 537 // // layer.msg('æ°æ®è¯·æ±å¤±è´¥'); 538 // // console.log('æ°æ®è¯·æ±å¤±è´¥'); 539 // }) 540 // .always(() => { 541 // $(listSearchContainer).addClass('show'); 542 // $(hotSearchContainer).removeClass('show'); 543 // }); 544 // } else { 545 // $(listSearchContainer).removeClass('show'); 546 // $(hotSearchContainer).addClass('show'); 547 // } 548 // }, _this.throttleInterval)); 549 550 // åºå失ç¦(desktop) 551 $(doc).on('mouseleave', '#navbarCollapse', function () { 552 // console.log("@åºå失ç¦(desktop)"); 553 const navSearchContainer = $(this).find('.nav-search-container'); 554 const navSearchinput = $(this).find('#input-desktop-control-key'); 555 556 if(navSearchinput.val() === '') { 557 $(navSearchContainer).removeClass('expand'); 558 $(navSearchinput).val('').blur(); 559 } 560 }); 561 562 // ç¹å»å¤±ç¦(desktop) 563 $(doc).on('click', function (event) { 564 // console.log("@ç¹å»å¤±ç¦(desktop)"); 565 const navSearchContainer = $('#navbarCollapse .nav-search-container'); 566 if($(event.target).closest('#navbarCollapse').length) { 567 568 } else if($(event.target).closest('.on-history-delete').length) { 569 570 } else { 571 $(navSearchContainer).removeClass('expand'); 572 $(_this).val(''); 573 } 574 }); 575 576 // 确认(desktop) 577 $(doc).on('keydown', '#input-desktop-control-key', function (e) { 578 if (e.key === 'Enter') {
579 const keywordval = $(this).val().trim(); 580 const keywordhtml = _this.domparser.parseFromString(keywordval, 'text/html'); 581 const keyword = sanitizeSearchKeyword(keywordhtml.body.textContent); 582 if (!keyword) tipInvalidKeyword(keywordval); 583 if (keyword) { 584 try { 585 top.location.href = buildSearchUrl(keyword); 586 } finally { 587 $HistoryRecord.add(keyword); 588 } 589 } 590 } 591 }); 592 593 // è¿å 594 $(doc).on('click', '.backbtn', function () { 595 const currentUrl = window.location.href; 596 597 if (currentUrl.includes('search-page')) { 598 top.location.href = '/'; 599 } else if (window.location.protocol === 'file:' || (!document.referrer && document.referrer.startsWith('file://'))) { 600 top.location.href = `/`; 601 } else if (!document.referrer) { 602 top.location.href = `/`; 603 } else { 604 const fallbackUrl = '/'; 605 const firstUrl = sessionStorage.getItem('firstNonSearchUrl'); 606 if (firstUrl) { 607 top.location.href = firstUrl; 608 } else { 609 top.location.href = fallbackUrl; 610 } 611 } 612 }); 613 614 // æç´¢å岿¶é(mobile and desktop) 615 $(doc).on('click', '.container-search-tags a, .container-search-lists a, .xqbj-search-tags-list a, .xqbj-search-none a', function (event) { 616 const keywordhtml = _this.domparser.parseFromString($(event.target)?.text()?.replace(/(^\s*)|(\s*$)/g, ""), 'text/html'); 617 const keyword = keywordhtml.body.textContent; 618 try { 619 $HistoryRecord.add(keyword); 620 } catch (error) { 621 // console.log("åå²ä¿¡æ¯æ¶é失败", error); 622 } 623 }); 624 625 // 626 this.init(); 627 } 628 629 // åå§å 630 init() { 631 const _this = this; 632 const navSearchContainer = $("#navbar .nav-search-container"); 633 const hotSearchContainer = navSearchContainer.find('.container-hot-search').get(0); 634 635 // æ¨¡æ¿æå»º 636 const tpl = _this.hotTemplate(hotRankList); 637 638 // æ¨¡æ¿æ¸²æ 639 $(hotSearchContainer).html(tpl); 640 641 // 642 $(hotSearchContainer).addClass('show'); 643 644 // 645 win?.$HistoryRecord && win?.$HistoryRecord.init(); 646 647 } 648 649 // æç´¢è¯·æ± 650 fetchSearchData(keyword) { 651 const _this = this; 652 if(keyword.length <= _this.keyLength) throw new Error('å ³é®è¯é¿åº¦å¿ 须大äº2'); 653 654 const data = { 655 q: encodeURIComponent(keyword) 656 }; 657 658 return $.ajax({ 659 url: `${this.url}`, 660 method: 'GET', 661 data 662 }); 663 } 664 665 // çé¨è¯·æ± 666 fetchHotData() { 667 const _this = this; 668 return $.ajax({ 669 url: _this.hoturl, 670 method: 'POST' 671 }); 672 } 673 674 // èæµ 675 debounce(func, delay) { 676 let timer = null; 677 return function(...args) { 678 if (timer) clearTimeout(timer); 679 timer = setTimeout(() => { 680 func.apply(this, args); 681 timer = null; 682 }, delay); 683 }; 684 } 685 } 686 687 // åå²(æç´¢åå²) 688 class HistoryRecord { 689 constructor() { 690 this.key = '__GLOBAL_SEARCH_HISTORY__'; // localStorage ç key 691 this.max = 8; // æå¤ä¿å 20 æ¡è®°å½ 692 this.listcontainer = 'div.history-record'; // å表容å¨å ç´ 693 this.init(); // åå§å è½½è®°å½ 694 } 695 696 // å è½½ 697 init() { 698 const _this = this; 699 const history = JSON.parse(localStorage.getItem(this.key)) || []; 700 this.show(history); 701 702 // äºä»¶ 703 _this.event(); 704 } 705 706 // äºä»¶ 707 event() { 708 const _this = this; 709 $(doc).on('click', '.on-history-clear', function () { 710 _this.clear(); 711 }); 712 713 $(doc).on('click', '.on-history-delete', function (e) { 714 e.preventDefault();
715 const keyword = $(this).closest('button').data('keyword'); 716 _this.del(keyword); 717 }); 718 719 $(doc).on('click', '.search-history-item', function (e) { 720 e.preventDefault(); 721 const keyword = sanitizeSearchKeyword($(this).data('keyword')); 722 if (!keyword) return; 723 top.location.href = buildSearchUrl(keyword); 724 }); 725 } 726 727 // æ¾ç¤º(æä½) 728 show(historys) { 729 const $container = $(this.listcontainer); 730 $container && $container.each((index, c) => { 731 let tpl = '<div class="no-data">ææ è®°å½</div>'; 732 if(historys?.length > 0) { 733 /* æç´¢seoä¼å start */ 734 tpl = historys.map(item => `<button data-keyword="${item}" class="search-history-item"><span class="text-line-ellipsis-1">${item}</span></button>`).join(''); 735 /* æç´¢seoä¼å end */ 736 } 737 c.innerHTML = tpl; 738 }); 739 } 740 741 // æ·»å 742 add(keyword) { 743 if (!keyword) return; 744 745 let history = JSON.parse(localStorage.getItem(this.key)) || []; 746 747 // å»é + æ·»å å°å¼å¤´ + éå¶æ°é 748 history = [keyword, ...history.filter(item => item !== keyword)].slice(0, this.max); 749 750 localStorage.setItem(this.key, JSON.stringify(history)); 751 this.show(history); 752 } 753 754 // å é¤ 755 del(keyword) { 756 if (!keyword) return; 757 758 let history = JSON.parse(localStorage.getItem(this.key)) || []; 759 760 // å é¤ 761 history = history.filter(k => k !== keyword); 762 763 localStorage.setItem(this.key, JSON.stringify(history)); 764 this.show(history); 765 } 766 767 // æ¸ ç©º 768 clear() { 769 localStorage.removeItem(this.key); 770 this.show([]); 771 } 772 } 773 774 775 776 // åå§å 777 document.addEventListener('DOMContentLoaded', function () { 778 const isSearchPage = window.location.pathname.includes('/search/'); 779 const landingKey = 'firstNonSearchUrl'; 780 781 if (!isSearchPage) { 782 sessionStorage.setItem(landingKey, window.location.href); 783 } 784 win['$NavSearch'] = new NavSearch( 785 '/action/suggest', // ç鍿¥å£(åºå¼) 786 '/action/suggest', 500, 0 // æç´¢æ¥å£ 787 ); 788 win['$SortList'] = new SortList( 789 "div#archive", 790 '/action/search_by' 791 ); 792 win['$HistoryRecord'] = new HistoryRecord(); 793 }, false); 794 795 function buildUrlWithToken(href, token) { 796 if (!token) return href; 797 try { 798 var url = new URL(href, window.location.href); 799 url.searchParams.set('token', token); 800 return url.href; 801 } catch (error) { 802 var separator = href.indexOf('?') === -1 ? '?' : '&'; 803 return href + separator + 'token=' + encodeURIComponent(token); 804 } 805 } 806 807document.addEventListener('click', function (e) { 808 const target = e.target 809 if (!target || !target.closest) return 810 const link = target.closest('a.ip_activity_link') 811 if (!link) return 812 e.preventDefault() 813 let token = null 814 try { 815 token = JSON.parse(window.localStorage.getItem('__token__')) 816 } catch (e) { 817 token = window.localStorage.getItem('__token__') 818 } 819 const rawHref = 820 link.dataset.rawHref || 821 link.getAttribute('href') || 822 '' 823 824 if (!rawHref) return 825 link.dataset.rawHref = rawHref 826 const finalUrl = token 827 ? buildUrlWithToken(rawHref, token) 828 : rawHref 829 830 window.open(finalUrl, '_blank') 831 832 }, { passive: false }) 833 834 835})(document, window, layer, hotRankList, keyword);
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.