$(() => {
$("div.pn-widget").click();
})
// This is a simple listener for clicking on the close button in the error message.
$('#close-error-btn').click(function () {
$('#error-message-wrapper').hide();
});
// This is the listener that will receive the post message from your front-end JS in case of an error.
window.addEventListener("message", function (e) {
// We verify that the error message is coming from Piano, so it must be what we're looking for.
if (typeof e.data.piano != 'undefined') {
// Get the object with the result.
var result = e.data.piano;
console.log('MESSAGE', e.data.piano);
// We know how this object should be structured, so we're checking for the "success" field.
// We're expecting it to be false, so we can show an error message.
if (!result.success) {
// Show the error block.
$('#error-message-wrapper').show();
// Append the text message into the block.
$('#error-message').text(result.message);
}
}
return;
}, false);
// ------------------------------------------------------------------------------------------------------------------------------------
// START Template include script
// Allot of this code is dealing with the fact that the page attributes are not ready until some arbitray time in the future
// Version 1.1
// ------------------------------------------------------------------------------------------------------------------------------------
var retryCounter = 20;
function loadTemplateIncludeScript() {
var scriptSrc = document.getElementById('piano-glide-init').dataset.templateIncludeScript;
if (!scriptSrc) { if (retryCounter > 0) { setTimeout(loadTemplateIncludeScript, 100); retryCounter--; } else { console.error('FAILED: Loading piano template include script no templateIncludeScript set'); } return; }
var script = document.createElement('script'); script.setAttribute("src", scriptSrc); document.head.appendChild(script);
}
loadTemplateIncludeScript();
// ------------------------------------------------------------------------------------------------------------------------------------
// END Template include script
// ------------------------------------------------------------------------------------------------------------------------------------