Guestbook
Guestbook
Guest List
const widget = document.querySelector("#cap");widget.addEventListener("solve", function (e) { const token = e.detail.token; if (token){ console.log("Captured") //document.getElementById("Submit").disabled = "false"; var button = document.getElementById('Submit'); // Set the 'disabled' property to false to enable it button.disabled = false; } });$.ajaxSetup({ headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': 'Bearer fdf17fe21a5c7662f2adcb65e79d40739fa8e5dc089e64ee382f3dadd142e4e67919a4050808f042d6441682d69961b51bcf57007fa69535b2a7d4c9599277b3c8e6623dcaa7f48195f23508760a33604051cf17b42f3f9d3c3f620cca8eb53e19cda3181a258a4ed1c355b8458e7945cdf5a46dd68c896629c7c011237f88cf', }});async function fetchArticles() { const apiUrl = 'https://api.paulhitt.com/api/guestbooks';const fetchOptions = { method: 'GET', // Can be 'POST', 'PUT', etc. headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': 'Bearer fdf17fe21a5c7662f2adcb65e79d40739fa8e5dc089e64ee382f3dadd142e4e67919a4050808f042d6441682d69961b51bcf57007fa69535b2a7d4c9599277b3c8e6623dcaa7f48195f23508760a33604051cf17b42f3f9d3c3f620cca8eb53e19cda3181a258a4ed1c355b8458e7945cdf5a46dd68c896629c7c011237f88cf', }}; try { const response = await fetch(apiUrl,fetchOptions); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); console.log(data); // The response data will be a JSON object with 'data' and 'meta' properties // You can process and display the data in your frontend here displayArticles(data.data); } catch (error) { console.error('Error fetching data:', error); }}// Helper function to display the fetched data (example)function displayArticles(articles) { const container = document.getElementById('articles-container'); // Assume you have a div with this id if (container) { articles.forEach(article => { const articleElement = document.createElement('div'); articleElement.innerHTML = ` <font color="#fff" size="2" face="monospace, Georgia, Serif"> ${article.name} - ${article.createdAt}</font><br /> <font size="2" face="monospace, Georgia, Serif" color="#fff">${article.message}</font></p> <p> `; container.appendChild(articleElement); }); }}fetchArticles();$("form").submit(function (event) { var formData = { name: $("#Name").val(), message: $("#Message").val(), }; event.preventDefault(); //prevent default action $.post( "https://api.paulhitt.com/api/guestbooks", JSON.stringify({ "data": formData}) ).done(function(data){ document.forms[0].reset(); alert("Form submitted. Thanks!"); });});