Categories: Uncategorized

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

"; return; } var url = block.dataset.restUrl + "?post_id=" + encodeURIComponent(block.dataset.postId) + "&keyword=" + encodeURIComponent(keyword); output.innerHTML = "
Searching…
"; submit.disabled = true; output.setAttribute("aria-busy", "true"); fetch(url, { headers: { "X-WP-Nonce": block.dataset.nonce } }) .then(function(r){ return r.json().then(function(data){ return { status: r.status, data: data }; }); }) .then(function(resp){ if (resp.status === 200 && resp.data && resp.data.success) { dpSimilarRender(output, keyword, resp.data); } else if (resp.status === 403) { output.innerHTML = "
Session expired. Please refresh the page and try again.
"; } else if (resp.status === 429) { output.innerHTML = "
Too many searches. Please try again in a few minutes.
" + dpSimilarCta(output, -1); } else { output.innerHTML = "
Search failed. Please try again.
" + dpSimilarCta(output, -1); } }) .catch(function(){ output.innerHTML = "
Could not reach the server. Please check your connection.
" + dpSimilarCta(output, -1); }) .then(function(){ submit.disabled = false; output.removeAttribute("aria-busy"); }); } function dpAskGrokSend(block) { var input = block.querySelector(".dp-ask-grok-input"); var result = block.querySelector(".dp-ask-grok-result"); var send = block.querySelector(".dp-ask-grok-send"); var form = block.querySelector(".dp-ask-grok-form"); var button = block.querySelector(".dp-ask-grok-button"); var intro = block.querySelector(".dp-ask-grok-intro"); var question = (input.value || "").trim(); if (question.length Please ask a question of at least 10 characters."; return; } if (question.length > 500) { result.innerHTML = "
Question is too long. Please keep it under 500 characters.
"; return; } result.innerHTML = "
Asking Grok\u2026 (this can take 10-20 seconds)
"; send.disabled = true; result.setAttribute("aria-busy", "true"); fetch(block.dataset.restUrlAskGrok, { method: "POST", headers: { "Content-Type": "application/json", "X-WP-Nonce": block.dataset.nonce }, body: JSON.stringify({ post_id: parseInt(block.dataset.postId, 10), question: question }) }) .then(function(r){ return r.json().then(function(data){ return { status: r.status, data: data }; }); }) .then(function(resp){ if (resp.status === 429) { if (form) form.style.display = "none"; if (intro) intro.style.display = ""; if (button) { button.style.display = ""; button.disabled = true; button.setAttribute("title", "Daily limit reached. Try again tomorrow."); button.textContent = "Daily limit reached"; } var rateMsg = (resp.data && resp.data.message) ? resp.data.message : "You\u2019ve reached today\u2019s question limit. Please try again tomorrow."; result.innerHTML = "
" + dpSimilarEscape(rateMsg) + "
"; return; } if (resp.status === 403) { result.innerHTML = "
Session expired. Please refresh the page and try again.
"; return; } if (resp.status === 200 && resp.data && resp.data.success) { var safeAnswer = dpSimilarEscape(resp.data.answer || ""); var safeDisclaimer = dpSimilarEscape(resp.data.disclaimer || ""); var answerHtml = "
"; answerHtml += "

" + safeAnswer + "

"; answerHtml += "

\u26a0\ufe0f " + safeDisclaimer + "

"; answerHtml += "
"; result.innerHTML = answerHtml; if (form) form.style.display = "none"; if (intro) intro.style.display = ""; if (button) { button.style.display = ""; button.disabled = true; button.setAttribute("title", "Daily limit reached. Try again tomorrow."); button.textContent = "Daily limit reached"; } return; } if (resp.status === 200 && resp.data && !resp.data.success) { var msg = dpSimilarEscape(resp.data.message || "Could not process your question right now."); result.innerHTML = "
" + msg + "
"; return; } result.innerHTML = "
Could not process your question right now. Please try again later.
"; }) .catch(function(){ result.innerHTML = "
Could not reach the server. Please check your connection and try again.
"; }) .then(function(){ if (send) send.disabled = false; result.removeAttribute("aria-busy"); }); } function dpSimilarRender(output, keyword, data) { var html = ""; if (data.count === 0) { html += "
No matches found for “" + dpSimilarEscape(keyword) + "”.
"; } else { html += "

Articles matching “" + dpSimilarEscape(keyword) + "”

"; html += "
    "; data.results.forEach(function(r){ html += "
  • "; html += "" + r.title + ""; html += "" + r.date + ""; html += "
  • "; }); html += "
"; } html += dpSimilarCta(output, data.count); output.innerHTML = html; } function dpSimilarCta(output, count) { var block = output.closest(".dp-similar-block"); var contactUrl = block ? block.dataset.contactUrl : ""; if (!contactUrl) { return ""; } var ctaText; if (count === -1) { ctaText = "While you wait, here are some other ways to get help:"; } else if (count === 0) { ctaText = "Couldn\u2019t find what you needed? Speak with a professional for personalized help."; } else { ctaText = "Need more help with this topic? Speak with a professional."; } var html = "
"; html += "

" + ctaText + "

"; html += "Talk to a Professional"; html += "
"; var isFullApi = block && block.dataset.isFullApi === "1"; html += "

Or ask our AI assistant a quick question about this topic.

"; html += ""; html += "
"; html += ""; html += ""; html += ""; html += ""; html += "
"; html += "
"; html += "
"; html += "
"; return html; } function dpSimilarEscape(s) { var div = document.createElement("div"); div.textContent = s; return div.innerHTML; }})();
WebAdmin

Share
Published by
WebAdmin