summaryrefslogtreecommitdiff
path: root/assets/js
diff options
context:
space:
mode:
authormayx <mayx@outlook.com>2026-06-30 16:00:55 +0000
committermayx <mayx@outlook.com>2026-06-30 16:00:55 +0000
commit7943cc7d6ae9214ba9e70a141bbe27fbd98a923a (patch)
tree934b13ae191b00bc74ad33ee2c42490f591ae308 /assets/js
parent772e3ed0b70dffe303ebacb5680ee9650efe3c76 (diff)
Update 5 filesHEADmaster
- /_data/other_repo_list.csv - /index.html - /_posts/2026-07-01-vibe-coding.md - /assets/js/main_new.js - /assets/js/main.js
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/main.js20
-rw-r--r--assets/js/main_new.js20
2 files changed, 20 insertions, 20 deletions
diff --git a/assets/js/main.js b/assets/js/main.js
index e926618..ed21874 100644
--- a/assets/js/main.js
+++ b/assets/js/main.js
@@ -17,6 +17,25 @@ function initVisitors() {
}
}
+function highlightKeyword() {
+ var match = location.search.match(/[?&]kw=([^&]+)/);
+ var kw = match ? $.trim(decodeURIComponent(match[1].replace(/\+/g, ' '))) : '';
+ if (!kw) return;
+
+ var reg = new RegExp('(' + kw.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + ')', 'gi');
+ var escapeMap = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' };
+
+ $('section, section *').not('script, style, textarea').contents().filter(function () {
+ return this.nodeType === 3;
+ }).each(function () {
+ var escapedText = this.nodeValue.replace(/[&<>"']/g, function (m) { return escapeMap[m]; });
+ var highlighted = escapedText.replace(reg, '<mark>$1</mark>');
+ if (escapedText !== highlighted) {
+ $(this).replaceWith(highlighted);
+ }
+ });
+}
+
$(function () {
(function () {
var $backToTopTxt = "返回顶部", $backToTopEle = $('<div class="backToTop"></div>').appendTo($("body"))
@@ -42,6 +61,7 @@ $(function () {
});
console.warn("Mayx may already be Dead");
}
+ highlightKeyword();
});
function getSearchJSON(callback) {
diff --git a/assets/js/main_new.js b/assets/js/main_new.js
index a6c10c6..c697391 100644
--- a/assets/js/main_new.js
+++ b/assets/js/main_new.js
@@ -1,22 +1,3 @@
-function highlightKeyword() {
- var match = location.search.match(/[?&]kw=([^&]+)/);
- var kw = match ? $.trim(decodeURIComponent(match[1].replace(/\+/g, ' '))) : '';
- if (!kw) return;
-
- var reg = new RegExp('(' + kw.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + ')', 'gi');
- var escapeMap = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' };
-
- $('section, section *').not('script, style, textarea').contents().filter(function() {
- return this.nodeType === 3;
- }).each(function() {
- var escapedText = this.nodeValue.replace(/[&<>"']/g, function(m) { return escapeMap[m]; });
- var highlighted = escapedText.replace(reg, '<mark>$1</mark>');
- if (escapedText !== highlighted) {
- $(this).replaceWith(highlighted);
- }
- });
-}
-
function initCopyButtons() {
$('.copy').remove();
$('div.highlight').each(function () {
@@ -33,6 +14,5 @@ function initCopyButtons() {
}
$(function () {
- highlightKeyword();
initCopyButtons();
}); \ No newline at end of file