' + error + '
' + (errorId ? '
Error ID: ' + errorId + '
' : '') + '
';
cl.lightbox(message, {
closeOnEsc: true,
closeOnClickOutside: true,
afterClose: function () {
window.location.reload(true);
}
});
}
function doSecondaryLookup(postParams) {
state = GETTING_DATA;
$.post(serviceUrl.replace('__SERVICE_ID__', actionType), postParams || { n: nonce }, function (data) {
data.id && (errorId = data.id);
if (data.error) {
bailout();
} else {
pushInfoIntoDoc(data);
}
}).fail(bailout);
}
// automatically highlight the email address in the reply flap
function autoSelectEmail() {
var $email = $('.anonemail');
if ($email.length) {
var text = $email[0];
text.select();
$email.on('click', function () {
text.select();
});
}
}
function showEmailCopiedNotice() {
var notice = document.querySelector('.reply-email-copied-notice');
// replace with clone to make the animation restart
var clone = notice.cloneNode(true);
clone.classList.add('fade-out-2sec');
notice.parentNode.replaceChild(clone, notice);
// remove the fade-out class to prevent it from re-showing when flap
// is re-shown after being closed
setTimeout(function () {
clone.classList.remove('fade-out-2sec');
}, 2000);
}
function pushInfoIntoDoc(data) {
state = IDLE_WITH_NONCE;
if (data.fb) {
$('#postingbody').html(data.fb);
}
if ($replyInfo) {
if (data.replyContent) {
$replyInfo.html(data.replyContent);
var $phoneButton = $('.show-phone', $replyInfo);
if ($phoneButton.length) {
// note: the number isn't there, just hiding the decorations around it
$('.reply-tel-number', $replyInfo).hide();
// the first click does everything; therefore, ignore subsequent clicks
$phoneButton.one('click', function () {
$phoneButton.addClass('reply-tickle');
if (state === IDLE_WITH_NONCE) {
actionType = 'tel';
doSecondaryLookup();
}// else, we're already executing the process
});
} // else this post doesn't have phone contact info
var $emailButton = $('.show-email', $replyInfo);
if ($emailButton.length) {
// the first click does everything; therefore, ignore subsequent clicks
$emailButton.one('click', function () {
// the tickle is taken away when the button is replaced by the email info
$emailButton.addClass('reply-tickle');
if (state === IDLE_WITH_NONCE) {
actionType = 'mailto';
doSecondaryLookup(); // normal handling
}// else, we're already executing the process
});
} // else this post doesn't have mail contact info
if (actionType === 'reply') {
$replyInfo.show();
autoSelectEmail();
flapIsOpen = true;
}
}
var $replyTelNumber = $('#reply-tel-number', $replyInfo);
if (data.phone && $replyTelNumber && $replyTelNumber.length) {
$replyTelNumber.text(
data.phoneExtString ? `${data.phone} ${data.phoneExtString}` : data.phone
);
$('.reply-tel-number', $replyInfo).show();
$('.show-phone').remove();
var $node = $('.reply-tel-text.tel', $replyInfo);
if ($node.length) {
$node.replaceWith('