refactor: Refactor duplicated code in theme.js (#655)

* Initial plan

* Refactor duplicated code in theme.js

- Extract highlight text logic into _applyHighlightToText helper method
- Extract search UI reset logic into _resetSearchUI helper method
- Extract content initialization logic into _initContentComponents helper method
- Extract encrypted class toggling into _toggleEncryptedClass helper method
- Reduce code duplication in initSearch, initFixItDecryptor, and init methods

Co-authored-by: Lruihao <33419593+Lruihao@users.noreply.github.com>

* Simplify _toggleEncryptedClass with boolean parameter

- Replace fromClass and toClass parameters with a single show boolean
- Hardcode class names 'encrypted-hidden' and 'decrypted-shown' in function body
- More semantic API: true to show decrypted content, false to hide
- Simplifies all 3 call sites with clearer intent

Co-authored-by: Lruihao <33419593+Lruihao@users.noreply.github.com>

* refactor: remove redundant DOMContentLoaded checks in aplayer and mermaid initialization

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Lruihao <33419593+Lruihao@users.noreply.github.com>
Co-authored-by: Cell <1024@lruihao.cn>
This commit is contained in:
Copilot
2025-11-13 14:46:47 +08:00
committed by GitHub
parent 066c82cc78
commit 96b2f5f8ae
3 changed files with 85 additions and 90 deletions
-6
View File
@@ -11,9 +11,3 @@ window.FixItAPlayer = {
})
},
}
if (document.readyState !== 'loading') {
window.FixItAPlayer.init()
} else {
document.addEventListener('DOMContentLoaded', window.FixItAPlayer.init, false)
}
-6
View File
@@ -116,9 +116,3 @@ window.FixItMermaid = {
init: initMermaid,
}
window.mermaid = mermaid
if (document.readyState !== 'loading') {
initMermaid()
} else {
document.addEventListener('DOMContentLoaded', initMermaid, false)
}