AI Content Writer
Create compelling content with the power of artificial intelligence
AI is crafting your content…
`)
.join(”);
suggestionscontainersss.style.display = ‘block’;
}
function applySuggestion(suggestion) {
alert(‘Suggestion noted: ‘ + suggestion + ‘\n\nThis would typically trigger specific content modifications based on the suggestion type.’);
}
function formatText(command) {
const editor = document.getElementById(‘editor’);
const start = editor.selectionStart;
const end = editor.selectionEnd;
const selectedText = editor.value.substring(start, end);
if (selectedText) {
let formattedText = selectedText;
switch(command) {
case ‘bold’:
formattedText = `**${selectedText}**`;
break;
case ‘italic’:
formattedText = `*${selectedText}*`;
break;
case ‘underline’:
formattedText = `${selectedText}`;
break;
}
editor.value = editor.value.substring(0, start) + formattedText + editor.value.substring(end);
updateStats();
}
}
function insertList() {
const editor = document.getElementById(‘editor’);
const cursorPos = editor.selectionStart;
const listItems = ‘\n\n• Item 1\n• Item 2\n• Item 3\n\n’;
editor.value = editor.value.substring(0, cursorPos) + listItems + editor.value.substring(cursorPos);
updateStats();
}
function clearContent() {
if (confirm(‘Are you sure you want to clear all content?’)) {
document.getElementById(‘editor’).value = ”;
updateStats();
}
}
function copyContent() {
const editor = document.getElementById(‘editor’);
editor.select();
document.execCommand(‘copy’);
const btn = event.target.closest(‘.toolbar-btn’);
const originalText = btn.innerHTML;
btn.innerHTML = ‘ Copied!’;
btn.style.background = ‘#28a745’;
btn.style.color = ‘white’;
setTimeout(() => {
btn.innerHTML = originalText;
btn.style.background = ”;
btn.style.color = ”;
}, 2000);
}
function exportContent() {
const content = document.getElementById(‘editor’).value;
const topic = document.getElementById(‘topic’).value || ‘content’;
const blob = new Blob([content], { type: ‘text/plain’ });
const url = URL.createObjectURL(blob);
const a = document.createElement(‘a’);
a.href = url;
a.download = `${topic.replace(/\s+/g, ‘_’)}_content.txt`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}
function updateStats() {
const content = document.getElementById(‘editor’).value;
const words = content.trim() ? content.trim().split(/\s+/).length : 0;
const characters = content.length;
const sentences = content.trim() ? content.split(/[.!?]+/).filter(s => s.trim().length > 0).length : 0;
const readTime = Math.ceil(words / 200); // Average reading speed
document.getElementById(‘wordCount’).textContent = words;
document.getElementById(‘charCount’).textContent = characters;
document.getElementById(‘readTime’).textContent = readTime;
document.getElementById(‘sentences’).textContent = sentences;
}
// Real-time stats update
document.getElementById(‘editor’).addEventListener(‘input’, updateStats);
// Initialize stats
updateStats();
// Add some visual flair
document.addEventListener(‘DOMContentLoaded’, function() {
const statCards = document.querySelectorAll(‘.stat-card’);
statCards.forEach((card, index) => {
setTimeout(() => {
card.style.animation = ‘pulse 0.6s ease-in-out’;
}, index * 200);
});
});



Leave a Reply