Advanced Review Generator Tool
Advanced Review Generator Tool
Live Preview
Generated Review Code (Copy & Paste into HTML View):
`;
if (isPreview) {
const previewFrame = document.getElementById('livePreviewFrame');
previewFrame.contentDocument.open();
previewFrame.contentDocument.write(generatedHTML.trim());
previewFrame.contentDocument.close();
document.getElementById('livePreviewContainer').style.display = 'block';
document.getElementById('generatedReviewOutput').style.display = 'none'; // Hide code output when showing preview
} else {
document.getElementById('reviewOutputContent').textContent = generatedHTML.trim();
document.getElementById('generatedReviewOutput').style.display = 'block';
document.getElementById('livePreviewContainer').style.display = 'none'; // Hide preview when showing code output
}
}
function copyReview() {
const reviewOutputContent = document.getElementById('reviewOutputContent');
const textToCopy = reviewOutputContent.textContent;
navigator.clipboard.writeText(textToCopy)
.then(() => {
alert('Review code copied to clipboard!');
})
.catch(err => {
console.error('Failed to copy review: ', err);
const textArea = document.createElement("textarea");
textArea.value = textToCopy;
textArea.style.position = "fixed";
textArea.style.left = "-999999px";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
document.execCommand('copy');
alert('Review code copied to clipboard (fallback)!');
} catch (ex) {
alert('Failed to copy review code. Please copy manually from the box.');
} finally {
document.body.removeChild(textArea);
}
});
}
function clearAllFields() {
if (confirm('Are you sure you want to clear all fields? This action cannot be undone.')) {
document.getElementById('productName').value = 'Your Awesome Product';
document.getElementById('productType').value = 'Product';
document.getElementById('reviewSectionTitle').value = 'Latest reviews from our customers';
document.getElementById('reviewSectionDescription').value = '';
document.getElementById('aggregateRatingValue').value = '5.0';
document.getElementById('reviewCount').value = '200+';
document.getElementById('titleColor').value = '#FF0000';
document.getElementById('descriptionColor').value = '#008000';
document.getElementById('reviewCardBgColor').value = '#f8f8f8';
document.getElementById('reviewCardBorderColor').value = '#eee';
document.getElementById('gridColumns').value = 'repeat(auto-fit, minmax(280px, 1fr))';
document.getElementById('dateDisplayFormat').value = 'MMM DD, YYYY';
const userReviewsContainer = document.getElementById('userReviewsContainer');
userReviewsContainer.innerHTML = `
`;
reviewCounter = 1;
updateRemoveButtonsVisibility();
document.getElementById('generatedReviewOutput').style.display = 'none';
document.getElementById('livePreviewContainer').style.display = 'none';
const firstTextArea = document.getElementById('reviewText1');
if (firstTextArea) {
updateCharCount(firstTextArea);
}
}
}