mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 23:38:56 +00:00
🐛 Fix: fix fixit-encryptor shortcode duplicate binding events
This commit is contained in:
@@ -139,10 +139,11 @@ FixItDecryptor = function (options = {}) {
|
||||
|
||||
/**
|
||||
* initialize fixit-encryptor shortcodes
|
||||
* @param {Element} [$container=document] container element
|
||||
*/
|
||||
_proto.initShortcodes = () => {
|
||||
_proto.initShortcodes = ($container = document) => {
|
||||
customElements.get('fixit-encryptor') || customElements.define('fixit-encryptor', class extends HTMLElement {});
|
||||
const $shortcodes = document.querySelectorAll('fixit-encryptor:not(:has(.decrypted))');
|
||||
const $shortcodes = $container.querySelectorAll('fixit-encryptor:not(:has(.decrypted))');
|
||||
|
||||
$shortcodes.forEach($shortcode => {
|
||||
const decryptorHandler = () => {
|
||||
|
||||
+2
-2
@@ -1047,8 +1047,8 @@ class FixIt {
|
||||
this.decryptor.addEventListener('decrypted', () => {
|
||||
this.decryptor.initShortcodes();
|
||||
})
|
||||
this.decryptor.addEventListener('partial-decrypted', () => {
|
||||
this.decryptor.initShortcodes();
|
||||
this.decryptor.addEventListener('partial-decrypted', ($content) => {
|
||||
this.decryptor.initShortcodes($content);
|
||||
})
|
||||
this.decryptor.initShortcodes();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- .Scratch.Set "version" "v0.3.10-53484f8c" -}}
|
||||
{{- .Scratch.Set "version" "v0.3.10-466bb7b7" -}}
|
||||
{{- .Scratch.Set "this" dict -}}
|
||||
|
||||
{{- partial "init/detection-env.html" . -}}
|
||||
|
||||
@@ -172,7 +172,7 @@
|
||||
{{- end -}}
|
||||
<div class="content" id="content"
|
||||
{{- with $params.endFlag }} data-end-flag="{{ . }}"{{ end }}
|
||||
{{- with $params.password }} data-password="{{ hash.XxHash . }}"{{ end }}
|
||||
{{- with $params.password }} data-password="{{ xxhash . }}"{{ end }}
|
||||
{{- with $params.password }} data-content="{{ $content }}"{{ end -}}
|
||||
>
|
||||
{{- if not $params.password -}}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
{{- dict "Class" "fa-solid fa-unlock" | partial "plugin/icon.html" }} {{ T "single.enterBtn" -}}
|
||||
</button>
|
||||
</div>
|
||||
<div data-password="{{ md5 $password }}" data-content="{{ $content }}"></div>
|
||||
<div data-password="{{ xxhash $password }}" data-content="{{ $content }}"></div>
|
||||
</fixit-encryptor>
|
||||
{{- .Page.Scratch.SetInMap "this" "encryptPartial" true -}}
|
||||
{{- else -}}
|
||||
|
||||
Reference in New Issue
Block a user