From 27b9f2299e82246dbbc7e915970ca0b22b4de0e9 Mon Sep 17 00:00:00 2001 From: yequari Date: Sat, 3 Jan 2026 16:06:26 -0700 Subject: [PATCH] allow embed customization --- ui/static/js/guestbook.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ui/static/js/guestbook.js b/ui/static/js/guestbook.js index 8a6dcac..21eb926 100644 --- a/ui/static/js/guestbook.js +++ b/ui/static/js/guestbook.js @@ -1,3 +1,4 @@ + class GuestbookForm extends HTMLElement { static get observedAttributes() { return ['guestbook']; @@ -6,6 +7,8 @@ class GuestbookForm extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); + let template = document.getElementById("custom-guestbook-form"); + this.templateContent = template.content; this._guestbook = this.getAttribute('guestbook') || ''; this._postUrl = `${this._guestbook}/comments/create/remote` this.render(); @@ -63,6 +66,7 @@ class GuestbookForm extends HTMLElement { `; + this.shadowRoot.appendChild(document.importNode(this.templateContent, true)) } } @@ -74,9 +78,12 @@ class CommentList extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); + let template = document.getElementById("custom-guestbook-comments"); + this.templateContent = template.content; this.comments = []; this.loading = false; this.error = null; + } connectedCallback() { @@ -169,9 +176,11 @@ class CommentList extends HTMLElement { } `; + this.shadowRoot.appendChild(document.importNode(this.templateContent, true)) } } customElements.define('guestbook-form', GuestbookForm); customElements.define('guestbook-comments', CommentList); + -- 2.30.2