1/* 2ä½è :D.Young 3主页ï¼https://yyv.me/ 4githubï¼https://github.com/5iux/sou 5æ¥æï¼2019-07-26 6çæææï¼è¯·å¿å é¤ 7======================================== 8ç± yeetime ä¿®æ¹ 9githubï¼https://github.com/yeetime/sou2 10æ¥æï¼2019-12-13 11======================================== 12ç± imsyy äºæ¬¡ä¿®æ¹ 13githubï¼https://github.com/imsyy/sou2 14æ¥æï¼2022-03-10 15*/ 16 17// é»è®¤æç´¢å¼æå表 18var se_list_preinstall = { 19 '1': { 20 id: 1, 21 title: "ç¾åº¦", 22 url: "https://www.baidu.com/s", 23 name: "wd", 24 icon: "iconfont icon-baidu", 25 }, 26 '2': { 27 id: 2, 28 title: "å¿ åº", 29 url: "https://cn.bing.com/search", 30 name: "q", 31 icon: "iconfont icon-bing", 32 }, 33 '3': { 34 id: 3, 35 title: "è°·æ", 36 url: "https://www.google.com/search", 37 name: "q", 38 icon: "iconfont icon-google", 39 }, 40 '4': { 41 id: 4, 42 title: "æç", 43 url: "https://www.sogou.com/web", 44 name: "query", 45 icon: "iconfont icon-sougousousuo", 46 }, 47 '5': { 48 id: 5, 49 title: "360", 50 url: "https://www.so.com/s", 51 name: "q", 52 icon: "iconfont icon-360sousuo", 53 }, 54 '6': { 55 id: 6, 56 title: "å¾®å", 57 url: "https://s.weibo.com/weibo", 58 name: "q", 59 icon: "iconfont icon-xinlangweibo", 60 }, 61 '7': { 62 id: 7, 63 title: "ç¥ä¹", 64 url: "https://www.zhihu.com/search", 65 name: "q", 66 icon: "iconfont icon-zhihu", 67 }, 68 '8': { 69 id: 8, 70 title: "Github", 71 url: "https://github.com/search", 72 name: "q", 73 icon: "iconfont icon-github", 74 }, 75 '9': { 76 id: 9, 77 title: "BiliBili", 78 url: "https://search.bilibili.com/all", 79 name: "keyword", 80 icon: "iconfont icon-bilibilidonghua", 81 }, 82 '10': { 83 id: 10, 84 title: "æ·å®", 85 url: "https://s.taobao.com/search", 86 name: "q", 87 icon: "iconfont icon-taobao", 88 }, 89 '11': { 90 id: 11, 91 title: "京ä¸", 92 url: "https://search.jd.com/Search", 93 name: "keyword", 94 icon: "iconfont icon-jingdong", 95 } 96}; 97 98// é»è®¤å¿«æ·æ¹å¼ 99var quick_list_preinstall = { 100 '1': { 101 title: "Vercel", 102 url: "https://vercel.com/", 103 }, 104 '2': { 105 title: "GitHub", 106 url: "https://github.com/", 107 }, 108 '3': { 109 title: "Cloudflare", 110 url: "https://dash.cloudflare.com/", 111 }, 112 '4': { 113 title: "W3school", 114 url: "https://www.w3school.com.cn/", 115 }, 116 '5': { 117 title: "è ¾è®¯äº", 118 url: "https://console.cloud.tencent.com/", 119 }, 120 '6': { 121 title: "é¿éäº", 122 url: "https://console.aliyun.com/", 123 }, 124 '7': { 125 title: "ç¾åº¦ç½ç", 126 url: "https://pan.baidu.com/", 127 }, 128 '8': { 129 title: "é¿éäºç", 130 url: "https://www.aliyundrive.com/drive/", 131 }, 132 '9': { 133 title: "Office", 134 url: "https://www.office.com/", 135 }, 136 '10': { 137 title: "åæäº", 138 url: "https://console.upyun.com/", 139 }, 140 '11': { 141 title: "CSDN", 142 url: "https://www.csdn.net/", 143 }, 144 '12': { 145 title: "åå©åå©", 146 url: "https://www.bilibili.com/", 147 } 148}; 149 150// 项ç®è®¾ç½® 151var project_settings_preinstall = { 152 show_weather: "1", 153 show_welcome: "1", 154 auto_focus: "0", 155 show_aplayer: "1", 156 music_playlist_id: "2141128031", 157}; 158 159function canUseLocalStorage() { 160 try { 161 var testKey = "__soso_test__"; 162 localStorage.setItem(testKey, "1"); 163 localStorage.removeItem(testKey); 164 return true; 165 } catch (error) { 166 return false; 167 } 168} 169 170function readStore(key) { 171 if (canUseLocalStorage()) { 172 var localValue = localStorage.getItem(key); 173 if (localValue !== null && localValue !== undefined) { 174 return localValue; 175 } 176 } 177 return Cookies.get(key); 178} 179 180function writeStore(key, value) { 181 var raw = typeof value === "string" ? value : JSON.stringify(value); 182 if (canUseLocalStorage()) { 183 localStorage.setItem(key, raw); 184 } 185 Cookies.set(key, raw, { 186 expires: 36500, 187 sameSite: "Lax" 188 });
189} 190 191function getStoreObject(key, fallback) { 192 var localValue = readStore(key); 193 if (!localValue || localValue === "{}") { 194 writeStore(key, fallback); 195 return JSON.parse(JSON.stringify(fallback)); 196 } 197 try { 198 return JSON.parse(localValue); 199 } catch (error) { 200 writeStore(key, fallback); 201 return JSON.parse(JSON.stringify(fallback)); 202 } 203} 204 205function getStoreValue(key, fallback) { 206 var localValue = readStore(key); 207 if (localValue === undefined || localValue === null || localValue === "") { 208 writeStore(key, String(fallback)); 209 return String(fallback); 210 } 211 return String(localValue); 212} 213 214// è·åæç´¢å¼æå表 215function getSeList() { 216 return getStoreObject('se_list', se_list_preinstall); 217} 218 219// 设置æç´¢å¼æå表 220function setSeList(se_list) { 221 if (se_list) { 222 writeStore('se_list', se_list); 223 return true; 224 } 225 return false; 226} 227 228// è·å¾é»è®¤æç´¢å¼æ 229function getSeDefault() { 230 return getStoreValue('se_default', "1"); 231} 232 233//èæ¯å¾ç 234var bg_img_preinstall = { 235 "type": "1", // 1:使ç¨ä¸»é¢é»è®¤çèæ¯å¾ç 2:å¿ åºæ¯æ¥ 3:éæºé£æ¯ 4:éæºäºæ¬¡å 5:èªå®ä¹å¾ç 236 "path": "", //èªå®ä¹å¾ç 237}; 238 239// è·åèæ¯å¾ç 240function getBgImg() { 241 return getStoreObject('bg_img', bg_img_preinstall); 242} 243 244// è®¾ç½®èæ¯å¾ç 245function setBgImg(bg_img) { 246 if (bg_img) { 247 writeStore('bg_img', bg_img); 248 return true; 249 } 250 return false; 251} 252 253function getProjectSettings() { 254 var settings = getStoreObject('project_settings', project_settings_preinstall); 255 if (!settings || typeof settings !== "object" || Array.isArray(settings)) { 256 settings = JSON.parse(JSON.stringify(project_settings_preinstall)); 257 setProjectSettings(settings); 258 return settings; 259 } 260 // ç¡®ä¿ææé¢è®¾é®é½åå¨ï¼å¦æä¸åå¨å使ç¨é»è®¤å¼ 261 var changed = false; 262 for (var key in project_settings_preinstall) { 263 if (settings[key] === undefined || settings[key] === null) { 264 settings[key] = project_settings_preinstall[key]; 265 changed = true; 266 } 267 } 268 var boolKeys = ["show_weather", "show_welcome", "auto_focus", "show_aplayer"]; 269 for (var i = 0; i < boolKeys.length; i++) { 270 var boolKey = boolKeys[i]; 271 var boolValue = String(settings[boolKey]); 272 if (boolValue !== "0" && boolValue !== "1") { 273 settings[boolKey] = project_settings_preinstall[boolKey]; 274 changed = true; 275 } 276 } 277 var playlistId = String(settings.music_playlist_id || "").trim(); 278 if (!/^\d+$/.test(playlistId)) { 279 settings.music_playlist_id = project_settings_preinstall.music_playlist_id; 280 changed = true; 281 } 282 if (changed) { 283 setProjectSettings(settings); 284 } 285 return settings; 286} 287 288function setProjectSettings(projectSettings) { 289 if (projectSettings) { 290 writeStore('project_settings', projectSettings); 291 return true; 292 } 293 return false; 294} 295 296function isSettingEnabled(value) { 297 return value === "1" || value === 1 || value === true || value === "true"; 298} 299 300function applyProjectSettings() { 301 var projectSettings = getProjectSettings(); 302 var hideWeather = !isSettingEnabled(projectSettings.show_weather); 303 $(".weather").toggle(!hideWeather); 304 if (isSettingEnabled(projectSettings.auto_focus) && window.innerWidth > 768) { 305 setTimeout(function () { 306 $(".wd").focus(); 307 focusWd(); 308 }, 200); 309 } 310 var $aplayer = $("#aplayer-wrap"); 311 if ($aplayer.length) { 312 var shouldShowAplayer = isSettingEnabled(projectSettings.show_aplayer); 313 $aplayer.toggle(shouldShowAplayer); 314 if (shouldShowAplayer) { 315 var playlistId = String(projectSettings.music_playlist_id || "").trim(); 316 if (!/^\d+$/.test(playlistId)) { 317 playlistId = "2141128031"; 318 projectSettings.music_playlist_id = playlistId; 319 setProjectSettings(projectSettings); 320 $(".set-project-option[data-setting='music_playlist_id']").val(playlistId); 321 } 322 var $meting = $aplayer.find("meting-js"); 323 var currentId = String($meting.attr("id") || $aplayer.attr("data-playlist-id") || "").trim(); 324 325 if (currentId !== playlistId) { 326 // ID åçäºååï¼éè¦éæ°å è½½ææ¾å¨ 327 if (typeof window.loadAPlayerAssets === "function") { 328 window.loadAPlayerAssets(true); 329 } 330 } else if (typeof window.loadAPlayerAssets === "function") { 331 window.loadAPlayerAssets(); 332 } 333 } 334 } 335 return projectSettings; 336} 337
338function setProjectSettingsInit() { 339 var projectSettings = getProjectSettings(); 340 $(".set-project-option").each(function () { 341 var settingKey = $(this).attr("data-setting"); 342 if (settingKey && projectSettings[settingKey] !== undefined) { 343 if ($(this).is(":checkbox")) { 344 $(this).prop("checked", isSettingEnabled(projectSettings[settingKey])); 345 } else { 346 $(this).val(projectSettings[settingKey]); 347 } 348 } 349 }); 350} 351 352// 设置-å£çº¸ 353//$('#bg').attr('src','https://api.dujin.org/bing/1920.php') 354function setBgImgInit() { 355 var bg_img = getBgImg(); 356 $("input[name='wallpaper-type'][value=" + bg_img["type"] + "]").click(); 357 if (bg_img["type"] === "5") { 358 $("#wallpaper-url").val(bg_img["path"]); 359 $("#wallpaper-button").fadeIn(100); 360 $("#wallpaper_url").fadeIn(100); 361 } else { 362 $("#wallpaper_url").fadeOut(300); 363 $("#wallpaper-button").fadeOut(300); 364 } 365 366 switch (bg_img["type"]) { 367 case "1": 368 var pictures = new Array(); 369 pictures[0] = './img/background1.webp'; 370 pictures[1] = './img/background2.webp'; 371 pictures[2] = './img/background3.webp'; 372 pictures[3] = './img/background4.webp'; 373 pictures[4] = './img/background5.webp'; 374 pictures[5] = './img/background6.webp'; 375 pictures[6] = './img/background7.webp'; 376 pictures[7] = './img/background8.webp'; 377 pictures[8] = './img/background9.webp'; 378 pictures[9] = './img/background10.webp'; 379 var rd = Math.floor(Math.random() * 10); 380 $('#bg').attr('src', pictures[rd]) //éæºé»è®¤å£çº¸ 381 break; 382 case "2": 383 $('#bg').attr('src', 'https://api.dujin.org/bing/1920.php') //å¿ åºæ¯æ¥ 384 break; 385 case "3": 386 $('#bg').attr('src', 'https://api.ixiaowai.cn/gqapi/gqapi.php') //éæºé£æ¯ 387 break; 388 case "4": 389 $('#bg').attr('src', 'https://api.ixiaowai.cn/api/api.php') //éæºäºæ¬¡å 390 break; 391 case "5": 392 $('#bg').attr('src', bg_img["path"]) //èªå®ä¹ 393 break; 394 } 395} 396 397// æç´¢æ¡é«äº® 398function focusWd() { 399 $("body").addClass("onsearch"); 400} 401 402// æç´¢æ¡åæ¶é«äº® 403function blurWd() { 404 $("body").removeClass("onsearch"); 405 //éèè¾å ¥ 406 $(".wd").val(""); 407 //éèæç´¢å»ºè®® 408 $("#keywords").hide(); 409} 410 411// æç´¢å»ºè®®æç¤º 412function keywordReminder() { 413 var keyword = $(".wd").val(); 414 if (keyword != "") { 415 $.ajax({
416 url: 'https://suggestion.baidu.com/su?wd=' + keyword, 417 dataType: 'jsonp', 418 jsonp: 'cb', //åè°å½æ°çåæ°å(é®å¼)key 419 success: function (data) { 420 //è·å宽度 421 $("#keywords").css("width", $('.sou').width()); 422 $("#keywords").empty().show(); 423 $.each(data.s, function (i, val) { 424 $('#keywords').append(`<div class="keyword" data-id="${i + 1}"><i class='iconfont icon-sousuo'></i>${val}</div>`); 425 }); 426 $("#keywords").attr("data-length", data.s["length"]); 427 $(".keyword").click(function () { 428 $(".wd").val($(this).text()); 429 $("#search-submit").click(); 430 }); 431 }, 432 error: function () { 433 $("#keywords").empty().show(); 434 $("#keywords").hide(); 435 } 436 }) 437 } else { 438 $("#keywords").empty().show(); 439 $("#keywords").hide(); 440 } 441} 442 443// æç´¢æ¡æ°æ®å è½½ 444function searchData() { 445 var se_default = getSeDefault(); 446 var se_list = getSeList(); 447 var defaultSe = se_list[se_default]; 448 if (defaultSe) { 449 $(".search").attr("action", defaultSe["url"]); 450 $("#icon-se").attr("class", defaultSe["icon"]); 451 $(".wd").attr("name", defaultSe["name"]); 452 } 453 454 // 夿çªå£å¤§å°ï¼æ·»å è¾å ¥æ¡èªå¨å®æ 455 // var wid = $("body").width(); 456 // if (wid < 640) { 457 // $(".wd").attr('autocomplete', 'off'); 458 // } else { 459 // $(".wd").focus(); 460 // focusWd(); 461 // } 462} 463 464// æç´¢å¼æå表å è½½ 465function seList() { 466 var html = ""; 467 var se_list = getSeList(); 468 for (var i in se_list) { 469 html += `<div class='se-li' data-url='${se_list[i]["url"]}' data-name='${se_list[i]["name"]}' data-icon='${se_list[i]["icon"]}'> 470 <a class='se-li-text'><i id='icon-sou-list' class='${se_list[i]["icon"]}'></i><span>${se_list[i]["title"]}</span></a></div>`; 471 } 472 $(".search-engine-list").html(html); 473} 474 475// 设置-æç´¢å¼æå表å è½½ 476function setSeInit() { 477 var se_default = getSeDefault(); 478 var se_list = getSeList(); 479 var html = ""; 480 for (var i in se_list) { 481 var tr = `<div class='se_list_div'><div class='se_list_num'>${i}</div>`; 482 if (i === se_default) { 483 tr = `<div class='se_list_div'><div class='se_list_num'> 484 <i class='iconfont icon-home'></i></div>`; 485 } 486 tr += `<div class='se_list_name'>${se_list[i]["title"]}</div> 487 <div class='se_list_button'> 488 <button class='set_se_default' value='${i}' style='border-radius: 8px 0px 0px 8px;'> 489 <i class='iconfont icon-home'></i></button> 490 <button class='edit_se' value='${i}'> 491 <i class='iconfont icon-xiugai'></i></button> 492 <button class='delete_se' value='${i}' style='border-radius: 0px 8px 8px 0px;'> 493 <i class='iconfont icon-delete'></i></button></div> 494 </div>`; 495 html += tr; 496 } 497 $(".se_list_table").html(html); 498} 499 500// è·åå¿«æ·æ¹å¼å表 501function getQuickList() { 502 return getStoreObject('quick_list', quick_list_preinstall); 503} 504 505// è®¾ç½®å¿«æ·æ¹å¼å表 506function setQuickList(quick_list) { 507 if (quick_list) { 508 writeStore('quick_list', quick_list); 509 return true; 510 } 511 return false; 512} 513 514// å¿«æ·æ¹å¼æ°æ®å è½½ 515function quickData() { 516 var html = ""; 517 var quick_list = getQuickList(); 518 for (var i in quick_list) { 519 html += `<div class="quick"> 520 <a href="${quick_list[i]['url']}" target="_blank">${quick_list[i]['title']}</a> 521 </div>`; 522 } 523 $(".quick-all").html(html + `<div class="quick"><a id="set-quick"><i class="iconfont icon-tianjia-"></i></a></div>`); 524} 525 526// 设置-å¿«æ·æ¹å¼å è½½ 527function setQuickInit() { 528 var quick_list = getQuickList(); 529 var html = ""; 530 for (var i in quick_list) { 531 tr = ` 532 <div class='quick_list_div'> 533 <div class='quick_list_div_num'>${i}</div> 534 <div class='quick_list_div_name'>${quick_list[i]['title']}</div> 535 <div class='quick_list_div_button'> 536 <button class='edit_quick' value='${i}' style='border-radius: 8px 0px 0px 8px;'> 537 <i class='iconfont icon-xiugai'></i></button> 538 <button class='delete_quick' value='${i}' style='border-radius: 0px 8px 8px 0px;'> 539 <i class='iconfont icon-delete'></i></button> 540 </div> 541 </div>`; 542 html += tr; 543 } 544 $(".quick_list_table").html(html); 545} 546 547/** 548 * ä¸è½½ææ¬ä¸ºæä»¶ 549 * @param filename æä»¶å 550 * @param text å 容 551 */ 552function download(filename, text) { 553 var element = document.createElement('a'); 554 element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); 555 element.setAttribute('download', filename); 556 557 element.style.display = 'none'; 558 document.body.appendChild(element); 559 560 element.click(); 561 562 document.body.removeChild(element); 563} 564 565// æå¼è®¾ç½® 566function openSet() { 567 $("#menu").addClass('on'); 568 569 openBox(); 570 571 //æ´æ¹è®¾ç½®å¾æ 572 $("#icon-menu").attr("class", "iconfont icon-home"); 573 574 //éèä¹¦ç¾æå¼è®¾ç½® 575 $(".mark").css({ 576 "display": "none", 577 });
578 $(".set").css({ 579 "display": "flex", 580 }); 581} 582 583// å ³é设置 584function closeSet() { 585 $("#menu").removeClass('on'); 586 587 closeBox(); 588 589 //æ´æ¹è®¾ç½®å¾æ 590 $("#icon-menu").attr("class", "iconfont icon-shezhi"); 591 592 //éè设置 593 $(".set").css({ 594 "display": "none", 595 }); 596 597 // å·æ°ä¸»é¡µæ°æ® 598 seList(); 599 quickData(); 600} 601 602// ä¹¦ç¾æ¾ç¤º 603function openBox() { 604 $("#content").addClass('box'); 605 $(".mark").css({ 606 "display": "flex", 607 }); 608 //æ¶é´ä¸ç§» 609 $(".tool-all").css({ 610 "transform": 'translateY(-160%)' 611 }); 612 //èæ¯æ¨¡ç³ 613 $('#bg').css({ 614 "transform": 'scale(1.08)', 615 "filter": "blur(4px)", 616 "transition": "ease 0.3s", 617 }); 618} 619 620// 书ç¾å ³é 621function closeBox() { 622 $("#content").removeClass('box'); 623 $(".mark").css({ 624 "display": "none", 625 }); 626 //æ¶é´ä¸ç§» 627 $(".tool-all").css({ 628 "transform": 'translateY(-110%)' 629 }); 630 //èæ¯æ¨¡ç³ 631 $('#bg').css({ 632 "transform": 'scale(1)', 633 "filter": "blur(0px)", 634 "transition": "ease 0.3s", 635 }); 636} 637 638//æ¾ç¤ºè®¾ç½®æç´¢å¼æå表 639function showSe() { 640 $(".se_list").show(); 641 $(".se_add_preinstall").show(); 642} 643 644//éè设置æç´¢å¼æå表 645function hideSe() { 646 $(".se_list").hide(); 647 $(".se_add_preinstall").hide(); 648} 649 650//æ¾ç¤ºè®¾ç½®å¿«æ·æ¹å¼å表 651function showQuick() { 652 $(".quick_list").show(); 653 $(".se_add_preinstalls").show(); 654} 655 656//éèè®¾ç½®å¿«æ·æ¹å¼å表 657function hideQuick() { 658 $(".quick_list").hide(); 659 $(".se_add_preinstalls").hide(); 660} 661 662 663$(document).ready(function () { 664 665 // 项ç®è®¾ç½®åå§å 666 applyProjectSettings(); 667 setProjectSettingsInit(); 668 669 // æç´¢æ¡æ°æ®å è½½ 670 searchData(); 671 672 // æç´¢å¼æå表å è½½ 673 seList(); 674 675 // å¿«æ·æ¹å¼æ°æ®å è½½ 676 quickData(); 677 678 // å£çº¸æ°æ®å è½½ 679 setBgImgInit(); 680 681 // ç¹å»äºä»¶ 682 $(document).on('click', function (e) { 683 // éæ©æç´¢å¼æç¹å» 684 if ($(".search-engine").is(":hidden") && $(".se").is(e.target) || $(".search-engine").is(":hidden") && $("#icon-se").is(e.target)) { 685 if ($(".se").is(e.target) || $("#icon-se").is(e.target)) { 686 //è·å宽度 687 $(".search-engine").css("width", $('.sou').width() - 30); 688 //åºç°å¨ç» 689 $(".search-engine").slideDown(160); 690 } 691 } else { 692 if (!$(".search-engine").is(e.target) && $(".search-engine").has(e.target).length === 0) { 693 $(".search-engine").slideUp(160); 694 } 695 } 696 697 // èªå¨æç¤ºéè 698 if (!$(".sou").is(e.target) && $(".sou").has(e.target).length === 0) { 699 $("#keywords").hide(); 700 } 701 }); 702 703 // æ¶é´ç¹å» 704 $("#time_text").click(function () { 705 if ($("#content").attr("class") === "box") { 706 closeBox(); 707 closeSet(); 708 blurWd(); 709 } else { 710 openBox(); 711 } 712 }); 713 714 // æç´¢å¼æå表ç¹å» 715 $(".search-engine-list").on("click", ".se-li", function () { 716 var url = $(this).attr('data-url'); 717 var name = $(this).attr('data-name'); 718 var icon = $(this).attr('data-icon'); 719 $(".search").attr("action", url); 720 $(".wd").attr("name", name); 721 $("#icon-se").attr("class", icon); 722 $(".search-engine").slideUp(160); 723 }); 724 725 // æç´¢å¼æå表ç¹å» 726 $(".search-engine-list").on("click", ".se-li", function () { 727 var url = $(this).attr('data-url'); 728 var name = $(this).attr('data-name'); 729 var icon = $(this).attr('data-icon'); 730 $(".search").attr("action", url); 731 $(".wd").attr("name", name); 732 $("#icon-se").attr("class", icon); 733 $(".search-engine").slideUp(160); 734 }); 735 736 // æç´¢æ¡ç¹å»äºä»¶ 737 $(document).on('click', '.sou', function () { 738 focusWd(); 739 $(".search-engine").slideUp(160); 740 });
741 742 $(document).on('click', '.wd', function () { 743 focusWd(); 744 keywordReminder(); 745 $(".search-engine").slideUp(160); 746 }); 747 748 // ç¹å»å ¶ä»åºåå ³éäºä»¶ 749 $(document).on('click', '.close_sou', function () { 750 blurWd(); 751 closeSet(); 752 }); 753 754 // ç¹å»æç´¢å¼ææ¶éèèªå¨æç¤º 755 $(document).on('click', '.se', function () { 756 $('#keywords').toggle(); 757 }); 758 759 // æ¢å¤èªå¨æç¤º 760 $(document).on('click', '.se-li', function () { 761 $('#keywords').show(); 762 }); 763 764 // èªå¨æç¤º (è°ç¨ç¾åº¦ apiï¼ 765 $('.wd').keyup(function (event) { 766 var key = event.keyCode; 767 // å±è½ä¸ä¸é® 768 var shieldKey = [38, 40]; 769 if (shieldKey.includes(key)) return; 770 keywordReminder(); 771 }); 772 773 // ç¹å»èªå¨æç¤ºçæç´¢å»ºè®® 774 $("#keywords").on("click", ".wd", function () { 775 var wd = $(this).text(); 776 $(".wd").val(wd); 777 $(".search").submit(); 778 //éèè¾å ¥ 779 $(".wd").val(""); 780 $("#keywords").hide(); 781 }); 782 783 // èªå¨æç¤ºé®çæ¹åé®éæ©æä½ 784 $(".wd").keydown(function (event) { //ä¸ä¸é®è·åç¦ç¹ 785 var key = event.keyCode; 786 if ($.trim($(this).val()).length === 0) return; 787 788 var id = $(".choose").attr("data-id"); 789 if (id === undefined) id = 0; 790 791 if (key === 38) { 792 /*å䏿é®*/ 793 id--; 794 } else if (key === 40) { 795 /*å䏿é®*/ 796 id++; 797 } else { 798 return; 799 } 800 var length = $("#keywords").attr("data-length"); 801 if (id > length) id = 1; 802 if (id < 1) id = length; 803 804 $(".keyword[data-id=" + id + "]").addClass("choose").siblings().removeClass("choose"); 805 $(".wd").val($(".keyword[data-id=" + id + "]").text()); 806 }); 807 808 // èåç¹å» 809 $("#menu").click(function () { 810 if ($(this).attr("class") === "on") { 811 closeSet(); 812 } else { 813 openSet(); 814 815 // 设置å 容å è½½ 816 setSeInit(); //æç´¢å¼æè®¾ç½® 817 setQuickInit(); //å¿«æ·æ¹å¼è®¾ç½® 818 } 819 }); 820 821 // å¿«æ·æ¹å¼æ·»å æé®ç¹å»ï¼å¨æå ç´ ï¼ä½¿ç¨äºä»¶å§æï¼ 822 $(document).on("click", "#set-quick", function (event) { 823 event.preventDefault(); 824 openSet(); 825 826 // 设置å 容å è½½ 827 setSeInit(); //æç´¢å¼æè®¾ç½® 828 setQuickInit(); //å¿«æ·æ¹å¼è®¾ç½® 829 830 //æ·»å å¿«æ·æ¹å¼ 831 $("#set-quick-menu").trigger('click'); 832 $(".set_quick_list_add").trigger('click'); 833 }); 834 835 // NOISE导èªä¸»é¡µæé®ï¼åå°ä¸»é¡µç¶æ 836 $(document).on("click", "#brand-home, #set-home-link", function (event) { 837 event.preventDefault(); 838 closeSet(); 839 closeBox(); 840 blurWd(); 841 window.location.href = "../index.html"; 842 }); 843 844 // ä¿®æ¹é»è®¤æç´¢å¼æ 845 $(".se_list_table").on("click", ".set_se_default", function () { 846 var name = $(this).val(); 847 iziToast.show({ 848 timeout: 8000, 849 message: 'æ¯å¦è®¾ç½®ä¸ºé»è®¤æç´¢å¼æï¼', 850 buttons: [ 851 ['<button>确认</button>', function (instance, toast) { 852 writeStore('se_default', name); 853 setSeInit(); 854 instance.hide({ 855 transitionOut: 'flipOutX', 856 }, toast, 'buttonName'); 857 iziToast.show({ 858 message: '设置æå' 859 }); 860 setTimeout(function () { 861 window.location.reload() 862 }, 1000); 863 }, true], 864 ['<button>åæ¶</button>', function (instance, toast) { 865 instance.hide({ 866 transitionOut: 'flipOutX', 867 }, toast, 'buttonName'); 868 }] 869 ] 870 }); 871 }); 872 873 // æç´¢å¼ææ·»å 874 $(".set_se_list_add").click(function () { 875 $(".se_add_content input").val(""); 876 877 hideSe(); 878 $(".se_add_content").show(); 879 });
880 881 // æç´¢å¼æä¿å 882 $(".se_add_save").click(function () { 883 var key_inhere = $(".se_add_content input[name='key_inhere']").val(); 884 var key = $(".se_add_content input[name='key']").val(); 885 var title = $(".se_add_content input[name='title']").val(); 886 var url = $(".se_add_content input[name='url']").val(); 887 var name = $(".se_add_content input[name='name']").val(); 888 //var icon = $(".se_add_content input[name='icon']").val(); 889 var icon = "iconfont icon-wangluo"; 890 891 var num = /^\+?[1-9][0-9]*$/; 892 if (!num.test(key)) { 893 iziToast.show({ 894 timeout: 2000, 895 message: 'åºå· ' + key + ' 䏿¯æ£æ´æ°' 896 }); 897 return; 898 } 899 900 var se_list = getSeList(); 901 902 if (se_list[key]) { 903 iziToast.show({ 904 timeout: 8000, 905 message: 'æç´¢å¼æ ' + key + ' å·²ææ°æ®ï¼æ¯å¦è¦çï¼', 906 buttons: [ 907 ['<button>确认</button>', function (instance, toast) { 908 se_list[key] = { 909 title: title, 910 url: url, 911 name: name, 912 icon: icon, 913 }; 914 setSeList(se_list); 915 setSeInit(); 916 $(".se_add_content").hide(); 917 //æ¾ç¤ºå表 918 showSe(); 919 920 instance.hide({ 921 transitionOut: 'flipOutX', 922 }, toast, 'buttonName'); 923 iziToast.show({ 924 message: 'è¦çæå' 925 }); 926 }, true], 927 ['<button>åæ¶</button>', function (instance, toast) { 928 instance.hide({ 929 transitionOut: 'flipOutX', 930 }, toast, 'buttonName'); 931 }] 932 ] 933 }); 934 return; 935 } 936 937 if (key_inhere && key !== key_inhere) { 938 delete se_list[key_inhere]; 939 } 940 941 se_list[key] = { 942 title: title, 943 url: url, 944 name: name, 945 icon: icon, 946 }; 947 setSeList(se_list); 948 setSeInit(); 949 iziToast.show({ 950 timeout: 2000, 951 message: 'æ·»å æå' 952 }); 953 $(".se_add_content").hide(); 954 showSe(); 955 }); 956 957 // å ³é表å 958 $(".se_add_cancel").click(function () { 959 $(".se_add_content").hide(); 960 961 //æ¾ç¤ºå表 962 showSe(); 963 }); 964 965 // æç´¢å¼æä¿®æ¹ 966 $(".se_list").on("click", ".edit_se", function () { 967 968 var se_list = getSeList(); 969 var key = $(this).val(); 970 $(".se_add_content input[name='key_inhere']").val(key); 971 $(".se_add_content input[name='key']").val(key); 972 $(".se_add_content input[name='title']").val(se_list[key]["title"]); 973 $(".se_add_content input[name='url']").val(se_list[key]["url"]); 974 $(".se_add_content input[name='name']").val(se_list[key]["name"]); 975 // $(".se_add_content input[name='icon']").val("iconfont icon-Earth"); 976 977 //éèå表 978 hideSe(); 979 980 $(".se_add_content").show(); 981 }); 982 983 // æç´¢å¼æå é¤ 984 $(".se_list").on("click", ".delete_se", function () { 985 var se_default = getSeDefault(); 986 var key = $(this).val(); 987 if (key == se_default) { 988 iziToast.show({ 989 message: 'é»è®¤æç´¢å¼æä¸å¯å é¤' 990 }); 991 } else { 992 iziToast.show({ 993 timeout: 8000, 994 message: 'æç´¢å¼æ ' + key + ' æ¯å¦å é¤ï¼', 995 buttons: [ 996 ['<button>确认</button>', function (instance, toast) { 997 var se_list = getSeList(); 998 delete se_list[key]; 999 setSeList(se_list); 1000 setSeInit(); 1001 instance.hide({ 1002 transitionOut: 'flipOutX', 1003 }, toast, 'buttonName'); 1004 iziToast.show({ 1005 message: 'å 餿å' 1006 }); 1007 }, true], 1008 ['<button>åæ¶</button>', function (instance, toast) { 1009 instance.hide({ 1010 transitionOut: 'flipOutX', 1011 }, toast, 'buttonName'); 1012 }] 1013 ] 1014 }); 1015 } 1016 });
1017 1018 // æ¢å¤é¢è®¾æç´¢å¼æ 1019 $(".set_se_list_preinstall").click(function () { 1020 iziToast.show({ 1021 timeout: 8000, 1022 message: 'ç°ææç´¢å¼ææ°æ®å°è¢«æ¸ 空', 1023 buttons: [ 1024 ['<button>确认</button>', function (instance, toast) { 1025 setSeList(se_list_preinstall); 1026 writeStore('se_default', "1"); 1027 setSeInit(); 1028 instance.hide({ 1029 transitionOut: 'flipOutX', 1030 }, toast, 'buttonName'); 1031 iziToast.show({ 1032 message: 'éç½®æå' 1033 }); 1034 setTimeout(function () { 1035 window.location.reload() 1036 }, 1000); 1037 }, true], 1038 ['<button>åæ¶</button>', function (instance, toast) { 1039 instance.hide({ 1040 transitionOut: 'flipOutX', 1041 }, toast, 'buttonName'); 1042 }] 1043 ] 1044 }); 1045 }); 1046 1047 // 设置-å¿«æ·æ¹å¼æ·»å 1048 $(".set_quick_list_add").click(function () { 1049 $(".quick_add_content input").val(""); 1050 $(".quick_add_content").show(); 1051 1052 //éèå表 1053 hideQuick(); 1054 }); 1055 1056 // 设置-å¿«æ·æ¹å¼ä¿å 1057 $(".quick_add_save").click(function () { 1058 var key_inhere = $(".quick_add_content input[name='key_inhere']").val(); 1059 var key = $(".quick_add_content input[name='key']").val(); 1060 var title = $(".quick_add_content input[name='title']").val(); 1061 var url = $(".quick_add_content input[name='url']").val(); 1062 var img = $(".quick_add_content input[name='img']").val(); 1063 1064 var num = /^\+?[1-9][0-9]*$/; 1065 if (!num.test(key)) { 1066 iziToast.show({ 1067 timeout: 2000, 1068 message: 'å¿«æ·æ¹å¼ ' + key + ' 䏿¯æ£æ´æ°' 1069 }); 1070 return; 1071 } 1072 1073 var quick_list = getQuickList(); 1074 1075 if (quick_list[key]) { 1076 iziToast.show({ 1077 timeout: 8000, 1078 message: 'å¿«æ·æ¹å¼ ' + key + ' å·²ææ°æ®ï¼æ¯å¦è¦çï¼', 1079 buttons: [ 1080 ['<button>确认</button>', function (instance, toast) { 1081 quick_list[key] = { 1082 title: title, 1083 url: url, 1084 img: img, 1085 }; 1086 setQuickList(quick_list); 1087 setQuickInit(); 1088 $(".quick_add_content").hide(); 1089 //æ¾ç¤ºå表 1090 showQuick(); 1091 1092 instance.hide({ 1093 transitionOut: 'flipOutX', 1094 }, toast, 'buttonName'); 1095 iziToast.show({ 1096 message: 'è¦çæå' 1097 }); 1098 }, true], 1099 ['<button>åæ¶</button>', function (instance, toast) { 1100 instance.hide({ 1101 transitionOut: 'flipOutX', 1102 }, toast, 'buttonName'); 1103 }] 1104 ] 1105 }); 1106 return; 1107 } 1108 1109 if (key_inhere && key != key_inhere) { 1110 delete quick_list[key_inhere]; 1111 } 1112 1113 quick_list[key] = { 1114 title: title, 1115 url: url, 1116 img: img, 1117 }; 1118 setQuickList(quick_list); 1119 setQuickInit(); 1120 $(".quick_add_content").hide(); 1121 iziToast.show({ 1122 timeout: 2000, 1123 message: 'æ·»å æå' 1124 }); 1125 1126 //æ¾ç¤ºå表 1127 showQuick(); 1128 }); 1129 1130 // 设置-å¿«æ·æ¹å¼å ³éæ·»å 表å 1131 $(".quick_add_cancel").click(function () { 1132 $(".quick_add_content").hide(); 1133 1134 //æ¾ç¤ºå表 1135 showQuick(); 1136 }); 1137 1138 //æ¢å¤é¢è®¾å¿«æ·æ¹å¼ 1139 $(".set_quick_list_preinstall").click(function () { 1140 iziToast.show({ 1141 timeout: 8000, 1142 message: 'å¿«æ·æ¹å¼æ°æ®å°è¢«æ¸ 空', 1143 buttons: [ 1144 ['<button>确认</button>', function (instance, toast) { 1145 setQuickList(quick_list_preinstall); 1146 setQuickInit(); 1147 instance.hide({ 1148 transitionOut: 'flipOutX', 1149 }, toast, 'buttonName'); 1150 iziToast.show({ 1151 timeout: 2000, 1152 message: 'éç½®æå' 1153 }); 1154 // setTimeout(function () { 1155 // window.location.reload() 1156 // }, 1000); 1157 }, true], 1158 ['<button>åæ¶</button>', function (instance, toast) { 1159 instance.hide({ 1160 transitionOut: 'flipOutX', 1161 }, toast, 'buttonName'); 1162 }] 1163 ] 1164 }); 1165 });
1166 1167 // å¿«æ·æ¹å¼ä¿®æ¹ 1168 $(".quick_list").on("click", ".edit_quick", function () { 1169 1170 var quick_list = getQuickList(); 1171 var key = $(this).val(); 1172 $(".quick_add_content input[name='key_inhere']").val(key); 1173 $(".quick_add_content input[name='key']").val(key); 1174 $(".quick_add_content input[name='title']").val(quick_list[key]["title"]); 1175 $(".quick_add_content input[name='url']").val(quick_list[key]["url"]); 1176 $(".quick_add_content input[name='img']").val(quick_list[key]["img"]); 1177 1178 //éèå表 1179 hideQuick(); 1180 1181 $(".quick_add_content").show(); 1182 }); 1183 1184 // å¿«æ·æ¹å¼å é¤ 1185 $(".quick_list").on("click", ".delete_quick", function () { 1186 1187 var key = $(this).val(); 1188 1189 iziToast.show({ 1190 timeout: 8000, 1191 message: 'å¿«æ·æ¹å¼ ' + key + ' æ¯å¦å é¤ï¼', 1192 buttons: [ 1193 ['<button>确认</button>', function (instance, toast) { 1194 var quick_list = getQuickList(); 1195 delete quick_list[key]; 1196 setQuickList(quick_list); 1197 setQuickInit(); 1198 instance.hide({ 1199 transitionOut: 'flipOutX', 1200 }, toast, 'buttonName'); 1201 iziToast.show({ 1202 timeout: 2000, 1203 message: 'å 餿å' 1204 }); 1205 }, true], 1206 ['<button>åæ¶</button>', function (instance, toast) { 1207 instance.hide({ 1208 transitionOut: 'flipOutX', 1209 }, toast, 'buttonName'); 1210 }] 1211 ] 1212 }); 1213 }); 1214 1215 // å£çº¸è®¾ç½® 1216 $("#wallpaper").on("click", ".set-wallpaper", function () { 1217 var type = $(this).val(); 1218 var bg_img = getBgImg(); 1219 bg_img["type"] = type; 1220 1221 if (type === "1") { 1222 $('#wallpaper_text').html("æ¾ç¤ºé»è®¤å£çº¸ï¼å·æ°é¡µé¢ä»¥çæ"); 1223 setBgImg(bg_img); 1224 iziToast.show({ 1225 message: 'å£çº¸è®¾ç½®æåï¼å·æ°çæ', 1226 }); 1227 } 1228 1229 if (type === "2") { 1230 $('#wallpaper_text').html("æ¾ç¤ºå¿ åºæ¯æ¥ä¸å¾ï¼æ¯å¤©æ´æ°ï¼å·æ°é¡µé¢ä»¥çæ | API @ ç¼å¥å¥"); 1231 setBgImg(bg_img); 1232 iziToast.show({ 1233 message: 'å£çº¸è®¾ç½®æåï¼å·æ°çæ', 1234 }); 1235 } 1236 1237 if (type === "3") { 1238 $('#wallpaper_text').html("æ¾ç¤ºéæºé£æ¯å¾ï¼æ¯æ¬¡å·æ°åæ´æ¢ï¼å·æ°é¡µé¢ä»¥çæ | API @ å°æª"); 1239 setBgImg(bg_img); 1240 iziToast.show({ 1241 message: 'å£çº¸è®¾ç½®æåï¼å·æ°çæ', 1242 }); 1243 } 1244 1245 if (type === "4") { 1246 $('#wallpaper_text').html("æ¾ç¤ºéæºäºæ¬¡å å¾ï¼æ¯æ¬¡å·æ°åæ´æ¢ï¼å·æ°é¡µé¢ä»¥çæ | API @ å°æª"); 1247 setBgImg(bg_img); 1248 iziToast.show({ 1249 message: 'å£çº¸è®¾ç½®æåï¼å·æ°çæ', 1250 }); 1251 } 1252 1253 if (type === "5") { 1254 $('#wallpaper_text').html("èªå®ä¹å£çº¸å°åï¼è¯·è¾å ¥æ£ç¡®å°åï¼ç¹å»ä¿åä¸å·æ°é¡µé¢ä»¥çæ"); 1255 $("#wallpaper_url").fadeIn(100); 1256 $("#wallpaper-button").fadeIn(100); 1257 $("#wallpaper-url").val(bg_img["path"]); 1258 } else { 1259 $("#wallpaper_url").fadeOut(300); 1260 $("#wallpaper-button").fadeOut(300); 1261 } 1262 }); 1263 1264 // èªå®ä¹å£çº¸è®¾ç½®ä¿å 1265 $(".wallpaper_save").click(function () { 1266 var url = $("#wallpaper-url").val(); 1267 var reg = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?$/; 1268 if (!reg.test(url)) { 1269 iziToast.show({ 1270 message: '请è¾å ¥æ£ç¡®ç龿¥', 1271 }); 1272 } else { 1273 var bg_img = getBgImg(); 1274 bg_img["type"] = "5"; 1275 bg_img["path"] = url; 1276 setBgImg(bg_img); 1277 iziToast.show({ 1278 message: 'èªå®ä¹å£çº¸è®¾ç½®æåï¼å·æ°çæ', 1279 }); 1280 } 1281 });
1282 1283 // 项ç®è®¾ç½®ä¿å 1284 $("#project_settings_save").click(function () { 1285 var currentSettings = getProjectSettings(); 1286 $(".set-project-option").each(function () { 1287 var settingKey = $(this).attr("data-setting"); 1288 if (settingKey) { 1289 if ($(this).is(":checkbox")) { 1290 currentSettings[settingKey] = $(this).is(":checked") ? "1" : "0"; 1291 } else { 1292 var settingValue = String($(this).val() || "").trim(); 1293 if (settingKey === "music_playlist_id" && !/^\d+$/.test(settingValue)) { 1294 settingValue = "2141128031"; 1295 $(this).val(settingValue); 1296 } 1297 currentSettings[settingKey] = settingValue; 1298 } 1299 } 1300 }); 1301 setProjectSettings(currentSettings); 1302 applyProjectSettings(); 1303 iziToast.show({ 1304 timeout: 2000, 1305 message: '项ç®è®¾ç½®å·²ä¿å' 1306 }); 1307 }); 1308 1309 // æçæ°æ®å¯¼åº 1310 $("#my_data_out").click(function () { 1311 var backupData = { 1312 cookies: Cookies.get(), 1313 localStorage: {} 1314 }; 1315 if (canUseLocalStorage()) { 1316 for (var i = 0; i < localStorage.length; i++) { 1317 var storageKey = localStorage.key(i); 1318 backupData.localStorage[storageKey] = localStorage.getItem(storageKey); 1319 } 1320 } 1321 var json = JSON.stringify(backupData); 1322 download("Noisedh-back-up-" + $.now() + ".json", json); 1323 iziToast.show({ 1324 timeout: 2000, 1325 message: '已导åºå¤ä»½æä»¶è³ä¸è½½ç®å½' 1326 }); 1327 }); 1328 1329 // æçæ°æ®å¯¼å ¥ ç¹å»è§¦åæä»¶éæ© 1330 $("#my_data_in").click(function () { 1331 $("#my_data_file").click(); 1332 }); 1333 1334 // éæ©æä»¶å读åæä»¶å 容 1335 $("#my_data_file").change(function () { 1336 var selectedFile = document.getElementById('my_data_file').files[0]; 1337 //var name = selectedFile.name;//读åé䏿件çæä»¶å 1338 //var size = selectedFile.size;//读åé䏿件çå¤§å° 1339 //console.log("æä»¶å:"+name+" 大å°:"+size); 1340 1341 var reader = new FileReader(); //è¿æ¯æ ¸å¿,读åæä½å°±æ¯ç±å®å®æ. 1342 reader.readAsText(selectedFile); //读åæä»¶çå 容,ä¹å¯ä»¥è¯»åæä»¶çURL 1343 reader.onload = function () { 1344 //å½è¯»å宿ååè°è¿ä¸ªå½æ°,ç¶åæ¤æ¶æä»¶çå 容åå¨å°äºresultä¸,ç´æ¥æä½å³å¯ 1345 //console.log(this.result); 1346 1347 // json æ ¼å¼æ ¡éª 1348 var mydata; 1349 try { 1350 mydata = JSON.parse(this.result); 1351 } catch (e) { 1352 iziToast.show({ 1353 timeout: 2000, 1354 message: 'æ°æ®è§£æå¼å¸¸' 1355 }); 1356 return; 1357 } 1358 if (typeof mydata != 'object') { 1359 iziToast.show({ 1360 timeout: 2000, 1361 message: 'æ°æ®æ ¼å¼é误' 1362 }); 1363 return; 1364 } 1365 1366 iziToast.show({ 1367 timeout: 8000, 1368 message: 'å½åæ°æ®å°ä¼è¢«è¦çï¼æ¯å¦ç»§ç»å¯¼å ¥ï¼', 1369 buttons: [ 1370 ['<button>确认</button>', function (instance, toast) { 1371 var cookieData = mydata.cookies ? mydata.cookies : mydata; 1372 for (var key in cookieData) { 1373 writeStore(key, cookieData[key]); 1374 } 1375 if (mydata.localStorage && canUseLocalStorage()) { 1376 for (var localKey in mydata.localStorage) { 1377 localStorage.setItem(localKey, mydata.localStorage[localKey]); 1378 } 1379 } 1380 instance.hide({ 1381 transitionOut: 'flipOutX', 1382 }, toast, 'buttonName'); 1383 iziToast.show({ 1384 timeout: 2000, 1385 message: 'å¯¼å ¥æå' 1386 }); 1387 setTimeout(function () { 1388 window.location.reload() 1389 }, 1000); 1390 }, true], 1391 ['<button>åæ¶</button>', function (instance, toast) { 1392 instance.hide({ 1393 transitionOut: 'flipOutX', 1394 }, toast, 'buttonName'); 1395 setTimeout(function () { 1396 window.location.reload() 1397 }, 1000); 1398 }] 1399 ] 1400 }); 1401 } 1402 });
1403});
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.