/******* Do not edit this file *******
Simple Custom CSS and JS - by Silkypress.com
Saved: Apr 11 2026 | 19:34:38 */
oog js/* Add your CSS code here.

For example:
.example {
    color: red;
}

For brushing up on your CSS knowledge, check out http://www.w3schools.com/css/css_syntax.asp

End of comment */ 


document.addEventListener("DOMContentLoaded", function () {
    const form = document.getElementById("commentForm");
    const list = document.getElementById("commentsList");

    if(!form) return;

    const comments = JSON.parse(localStorage.getItem("comments") || "[]");
    comments.forEach(addCommentToList);

    form.addEventListener("submit", function(e){
        e.preventDefault();

        const name = document.getElementById("name").value.trim();
        const comment = document.getElementById("comment").value.trim();

        if (!name || !comment) return;

        const newComment = {
            name,
            comment,
            date: new Date().toLocaleString()
        };

        comments.push(newComment);
        localStorage.setItem("comments", JSON.stringify(comments));

        addCommentToList(newComment);
        form.reset();
    });

    function addCommentToList(data){
        const div = document.createElement("div");
        div.style.borderBottom = "1px solid #eee";
        div.style.padding = "10px 0";

        div.innerHTML = `
            <p style="margin:0;font-weight:600;color:#111;">
                ${data.name}
                <span style="font-size:12px;color:#777;font-weight:400;">
                • ${data.date}
                </span>
            </p>
            <p style="margin:5px 0 0;color:#333;">${data.comment}</p>
        `;

        list.appendChild(div);
    }
});


function copyLink() {
    navigator.clipboard.writeText("<?php echo get_permalink(); ?>");
    alert("Link copied!");
}
