// Soulful Evolution CMS - Production Level JavaScript
// Author: Pavan
// Version: 1.0.0
class SoulfulCMS {
constructor() {
this.isEditMode = false;
this.currentData = [];
this.originalData = [];
this.apiUrl = window.location.origin.includes('localhost') ?
'http://localhost:3001/api' : '/api';
this.init();
}
init() {
this.loadData();
this.setupEventListeners();
}
// Data Management
async loadData() {
try {
this.showNotification('Loading content...', 'info');
const response = await fetch(`${this.apiUrl}/content`);
if (!response.ok) {
throw new Error('Failed to load content');
}
this.currentData = await response.json();
this.originalData = JSON.parse(JSON.stringify(this.currentData));
this.renderContent();
this.updateStats();
} catch (error) {
console.error('Error loading data:', error);
this.showNotification('Failed to load content. Using offline data.', 'error');
this.loadOfflineData();
}
}
loadOfflineData() {
// Fallback to static data if API fails
this.originalData = [
{
id: 1,
title: "Root Chakra Meditation: Grounding Your Energy for Inner Strength",
series: "Chakra Meditations",
status: "uploaded",
priority: "high",
youtube_title: "Root Chakra Meditation: Grounding Your Energy for Inner Strength",
youtube_description: "Discover the power of your root chakra with this guided meditation designed to help you feel more grounded, secure, and connected to the earth. In this transformative session, you'll learn how to activate and balance your root chakra, the foundation of your entire chakra system.\n\n🌟 What you'll experience:\n• Deep grounding techniques\n• Energy healing visualization\n• Connection to earth's stabilizing force\n• Inner strength activation\n\n✨ Perfect for: Beginners and experienced practitioners seeking stability and grounding.\n\n🔮 Book a personal reading: https://soulfulevolution.com\n\n#RootChakra #Meditation #Grounding #ChakraHealing #Spirituality\n\n#TAGS#\nroot chakra, meditation, grounding, healing, spirituality",
thumbnail_text: "ROOT CHAKRA HEALING",
script_status: "complete",
speakflow_link: "https://speakflow.com/root-chakra-script",
drive_link: "https://drive.google.com/folder/root-chakra-footage",
gpt_mock_link: "https://chatgpt.com/gpt-mock/root-chakra-artwork",
upload_date: "2024-12-15",
assigned_to: ["A", "S"],
notes: "First in chakra series. Great engagement! High retention rate.",
thumbnail_file: null,
script_file: null
},
{
id: 2,
title: "Sacral Chakra Healing: Unlock Your Creative Power and Emotional Flow",
series: "Chakra Meditations",
status: "uploaded",
priority: "high",
youtube_title: "Sacral Chakra Healing: Unlock Your Creative Power and Emotional Flow",
youtube_description: "Awaken your sacral chakra and unleash your creative potential with this powerful guided meditation. Located just below your navel, the sacral chakra governs creativity, sexuality, and emotional well-being.\n\n🧡 Benefits of this meditation:\n• Enhanced creativity and inspiration\n• Improved emotional balance\n• Greater self-expression\n• Renewed passion for life\n• Healing past emotional wounds\n\n🎨 Perfect for: Artists, creators, and anyone seeking emotional healing and creative inspiration.\n\n💫 Connect with us: https://soulfulevolution.com\n\n#SacralChakra #Creativity #EmotionalHealing #ChakraBalancing #Meditation",
thumbnail_text: "SACRAL CHAKRA CREATIVITY",
script_status: "complete",
speakflow_link: "https://speakflow.com/sacral-chakra-script",
drive_link: "https://drive.google.com/folder/sacral-chakra-footage",
gpt_mock_link: "https://chatgpt.com/gpt-mock/sacral-chakra-artwork",
upload_date: "2024-12-17",
assigned_to: ["A", "S"],
notes: "Part 2 of series. Focus on creativity themes.",
thumbnail_file: null,
script_file: null
},
{
id: 3,
title: "Solar Plexus Chakra Meditation: Build Confidence and Personal Power",
series: "Chakra Meditations",
status: "recording",
priority: "urgent",
youtube_title: "Solar Plexus Chakra Meditation: Build Confidence and Personal Power",
youtube_description: "Transform your self-confidence and personal power with this solar plexus chakra meditation. This energy center, located in your upper abdomen, is your source of personal power, confidence, and self-worth.\n\n💛 This meditation will help you:\n• Build unshakeable confidence\n• Strengthen your personal boundaries\n• Overcome self-doubt and fear\n• Activate your inner warrior\n• Manifest your goals with clarity\n\n🔥 Ideal for: Anyone struggling with confidence, self-worth, or personal power issues.\n\n⭐ Book a session: https://soulfulevolution.com\n\n#SolarPlexusChakra #Confidence #PersonalPower #SelfWorth #Meditation",
thumbnail_text: "SOLAR PLEXUS POWER",
script_status: "complete",
speakflow_link: "https://speakflow.com/solar-plexus-script",
drive_link: "https://drive.google.com/folder/solar-plexus-footage",
gpt_mock_link: "https://chatgpt.com/gpt-mock/solar-plexus-artwork",
upload_date: null,
assigned_to: ["T"],
notes: "Recording in progress. Tim handling this personally.",
thumbnail_file: null,
script_file: null
},
{
id: 4,
title: "Heart Chakra Opening: Heal Your Heart and Attract Love",
series: "Chakra Meditations",
status: "pending",
priority: "medium",
youtube_title: "Heart Chakra Opening: Heal Your Heart and Attract Love",
youtube_description: "Open your heart chakra and invite more love into your life with this gentle yet powerful meditation. The heart chakra is your center of love, compassion, and connection.\n\n💚 Experience:\n• Deep emotional healing\n• Increased capacity for love\n• Better relationships\n• Self-compassion and forgiveness\n• Connection to universal love\n\n❤️ Perfect for: Those healing from heartbreak, wanting to attract love, or seeking deeper compassion.\n\n🌸 Learn more: https://soulfulevolution.com\n\n#HeartChakra #Love #Healing #Compassion #Meditation",
thumbnail_text: "HEART CHAKRA LOVE",
script_status: "draft",
speakflow_link: "",
drive_link: "",
gpt_mock_link: "",
upload_date: null,
assigned_to: ["S"],
notes: "Needs script review before production.",
thumbnail_file: null,
script_file: null,
youtube_views: 0,
youtube_likes: 0,
youtube_comments: 0,
view_count: 0,
like_count: 0,
comment_count: 0
},
{
id: 5,
title: "Throat Chakra Activation: Speak Your Truth with Confidence",
series: "Chakra Meditations",
status: "script",
priority: "high",
youtube_title: "Throat Chakra Activation: Speak Your Truth with Confidence",
youtube_description: "Unlock your authentic voice and express your truth with this powerful throat chakra meditation. The throat chakra governs communication, self-expression, and speaking your personal truth.\n\n💙 This meditation helps you:\n• Clear communication blockages\n• Build confidence in self-expression\n• Release fear of judgment\n• Strengthen your authentic voice\n• Improve public speaking abilities\n\n🗣️ Perfect for: Anyone struggling with communication, public speaking, or expressing their truth.\n\n🎤 Connect: https://soulfulevolution.com\n\n#ThroatChakra #Communication #SelfExpression #Confidence #Meditation",
thumbnail_text: "THROAT CHAKRA VOICE",
script_status: "review",
speakflow_link: "https://speakflow.com/throat-chakra-script",
drive_link: "https://drive.google.com/folder/throat-chakra-footage",
gpt_mock_link: "https://chatgpt.com/gpt-mock/throat-chakra-artwork",
upload_date: null,
assigned_to: ["A", "G"],
notes: "Script needs review for authenticity themes. Grace working on blue-themed artwork.",
thumbnail_file: null,
script_file: null,
youtube_views: 0,
youtube_likes: 0,
youtube_comments: 0,
view_count: 0,
like_count: 0,
comment_count: 0
},
{
id: 6,
title: "Angel Number 111: Manifestation and New Beginnings",
series: "Angel Messages",
status: "editing",
priority: "urgent",
youtube_title: "Angel Number 111: Your Angels Are Calling - Manifestation Portal Open!",
youtube_description: "Discover the powerful meaning behind Angel Number 111 and how your angels are guiding you toward manifestation and new beginnings. This isn't just coincidence - it's divine communication!\n\n✨ What 111 means:\n• Manifestation portal is open\n• New beginnings are coming\n• Your thoughts are rapidly manifesting\n• Angels are supporting your journey\n• Time to focus on positive thinking\n\n👼 Perfect for: Those seeing 111 repeatedly and seeking spiritual guidance.\n\n📞 Book an angel reading: https://soulfulevolution.com\n\n#AngelNumbers #111 #Manifestation #Angels #Spirituality #NewBeginnings",
thumbnail_text: "ANGEL NUMBER 111",
script_status: "complete",
speakflow_link: "https://speakflow.com/angel-111-script",
drive_link: "https://drive.google.com/folder/angel-111-footage",
gpt_mock_link: "https://chatgpt.com/gpt-mock/angel-111-artwork",
upload_date: null,
assigned_to: ["S", "T"],
notes: "Urgent for trending topic. Sasha in final edit phase, Tim reviewing for quality.",
thumbnail_file: null,
script_file: null,
youtube_views: 0,
youtube_likes: 0,
youtube_comments: 0,
view_count: 0,
like_count: 0,
comment_count: 0
},
{
id: 7,
title: "Past Life Regression: Discover Your Soul's Journey",
series: "Psychic Development",
status: "pending",
priority: "medium",
youtube_title: "Past Life Regression Meditation: Uncover Your Soul's Ancient Wisdom",
youtube_description: "Journey through time and explore your past lives with this guided regression meditation. Discover the karmic lessons and soul connections that shape your current life path.\n\n🔮 Experience:\n• Safe guided past life exploration\n• Understanding of karmic patterns\n• Soul purpose clarity\n• Release of past life trauma\n• Connection to ancient wisdom\n\n🌟 Perfect for: Spiritually curious individuals ready for deep soul work.\n\n📚 Learn more: https://soulfulevolution.com\n\n#PastLife #Regression #Karma #SoulJourney #Meditation #Spirituality",
thumbnail_text: "PAST LIFE JOURNEY",
script_status: "draft",
speakflow_link: "",
drive_link: "",
gpt_mock_link: "",
upload_date: null,
assigned_to: ["T"],
notes: "Tim wants to handle this personally. Sensitive topic requiring careful approach.",
thumbnail_file: null,
script_file: null,
youtube_views: 0,
youtube_likes: 0,
youtube_comments: 0,
view_count: 0,
like_count: 0,
comment_count: 0
},
{
id: 8,
title: "Third Eye Chakra Opening: Awakening Your Intuition",
series: "Chakra Meditations",
status: "uploaded",
priority: "high",
youtube_title: "Third Eye Chakra Meditation: Open Your Psychic Abilities & Intuition",
youtube_description: "Awaken your third eye chakra and unlock your natural psychic abilities with this transformative meditation. Located between your eyebrows, this energy center governs intuition, psychic sight, and spiritual insight.\n\n💜 Benefits include:\n• Enhanced intuitive abilities\n• Clearer psychic visions\n• Better dream recall\n• Spiritual insight and wisdom\n• Connection to higher consciousness\n\n🔮 Perfect for: Those ready to develop their psychic gifts and spiritual sight.\n\n✨ Psychic readings: https://soulfulevolution.com\n\n#ThirdEye #PsychicAbilities #Intuition #ChakraHealing #Meditation #Spirituality",
thumbnail_text: "THIRD EYE AWAKENING",
script_status: "complete",
speakflow_link: "https://speakflow.com/third-eye-script",
drive_link: "https://drive.google.com/folder/third-eye-footage",
gpt_mock_link: "https://chatgpt.com/gpt-mock/third-eye-artwork",
upload_date: "2024-12-20",
assigned_to: ["A", "S"],
notes: "Performing really well! Lots of comments about people having visions during meditation.",
thumbnail_file: null,
script_file: null,
youtube_views: 31250,
youtube_likes: 1450,
youtube_comments: 127,
view_count: 31250,
like_count: 1450,
comment_count: 127
},
{
id: 9,
title: "Full Moon Manifestation Ritual: Amplify Your Desires",
series: "Spiritual Guidance",
status: "recording",
priority: "urgent",
youtube_title: "Full Moon Manifestation Ritual - Manifest Your Dreams Tonight!",
youtube_description: "Harness the powerful energy of the full moon to amplify your manifestation practice. This complete ritual guide will help you align with lunar energy for maximum manifestation power.\n\n🌕 What you'll learn:\n• Complete full moon ritual steps\n• Moon water creation process\n• Manifestation journal techniques\n• Crystal charging methods\n• Release and attract practices\n\n🌙 Perfect for: Moon magic practitioners and manifestation enthusiasts.\n\n🔮 Moon readings: https://soulfulevolution.com\n\n#FullMoon #Manifestation #MoonRitual #LunarMagic #Spirituality #MoonMagic",
thumbnail_text: "FULL MOON MAGIC",
script_status: "complete",
speakflow_link: "https://speakflow.com/full-moon-script",
drive_link: "https://drive.google.com/folder/full-moon-footage",
gpt_mock_link: "https://chatgpt.com/gpt-mock/full-moon-artwork",
upload_date: null,
assigned_to: ["T", "P"],
notes: "Time-sensitive for upcoming full moon! Tim recording, Pavan handling tech setup.",
thumbnail_file: null,
script_file: null,
youtube_views: 0,
youtube_likes: 0,
youtube_comments: 0,
view_count: 0,
like_count: 0,
comment_count: 0
},
{
id: 10,
title: "Connecting with Your Spirit Guides: Divine Communication",
series: "Psychic Development",
status: "uploaded",
priority: "medium",
youtube_title: "How to Connect with Your Spirit Guides - Direct Divine Communication",
youtube_description: "Learn how to establish clear communication with your spirit guides and receive divine guidance in your daily life. Your guides are always with you - it's time to learn how to hear them!\n\n🙏 This meditation teaches:\n• How to identify your spirit guides\n• Techniques for clear communication\n• Signs and symbols from guides\n• Strengthening your spiritual connection\n• Daily practices for ongoing guidance\n\n👼 Perfect for: Anyone seeking divine guidance and spiritual mentorship.\n\n📱 Spirit guide readings: https://soulfulevolution.com\n\n#SpiritGuides #DivineGuidance #Spirituality #Meditation #PsychicDevelopment",
thumbnail_text: "SPIRIT GUIDE CONNECTION",
script_status: "complete",
speakflow_link: "https://speakflow.com/spirit-guides-script",
drive_link: "https://drive.google.com/folder/spirit-guides-footage",
gpt_mock_link: "https://chatgpt.com/gpt-mock/spirit-guides-artwork",
upload_date: "2024-12-12",
assigned_to: ["A", "G", "S"],
notes: "Amazing response! People sharing incredible guide connection stories in comments.",
thumbnail_file: null,
script_file: null,
youtube_views: 28940,
youtube_likes: 1320,
youtube_comments: 203,
view_count: 28940,
like_count: 1320,
comment_count: 203
},
{
id: 11,
title: "Twin Flame vs Soulmate: Understanding Divine Connections",
series: "Spiritual Guidance",
status: "pending",
priority: "low",
youtube_title: "Twin Flame vs Soulmate: Which Divine Connection Do You Have?",
youtube_description: "Confused about twin flames and soulmates? Learn the key differences between these divine connections and discover which type of relationship you're experiencing.\n\n💕 Topics covered:\n• Twin flame characteristics and signs\n• Soulmate connections explained\n• The twin flame journey stages\n• How to recognize your divine counterpart\n• Healing and preparation work\n\n❤️ Perfect for: Those experiencing intense spiritual connections in relationships.\n\n💖 Love readings: https://soulfulevolution.com\n\n#TwinFlame #Soulmate #DivineConnection #Love #Spirituality #Relationships",
thumbnail_text: "TWIN FLAME SOULMATE",
script_status: "pending",
speakflow_link: "",
drive_link: "",
gpt_mock_link: "",
upload_date: null,
assigned_to: [],
notes: "Popular requested topic. Needs careful handling due to sensitive nature of twin flame journey.",
thumbnail_file: null,
script_file: null,
youtube_views: 0,
youtube_likes: 0,
youtube_comments: 0,
view_count: 0,
like_count: 0,
comment_count: 0
},
{
id: 12,
title: "Crown Chakra Meditation: Divine Connection and Enlightenment",
series: "Chakra Meditations",
status: "script",
priority: "high",
youtube_title: "Crown Chakra Meditation: Connect to Divine Consciousness & Higher Self",
youtube_description: "Experience divine connection and spiritual enlightenment through this powerful crown chakra meditation. The crown chakra is your gateway to higher consciousness and universal wisdom.\n\n🔮 This meditation brings:\n• Connection to divine consciousness\n• Spiritual enlightenment experiences\n• Access to universal knowledge\n• Higher self alignment\n• Transcendence of ego limitations\n\n✨ Perfect for: Advanced practitioners ready for deep spiritual experiences.\n\n🙏 Spiritual guidance: https://soulfulevolution.com\n\n#CrownChakra #Enlightenment #Divine #Consciousness #Meditation #Spirituality",
thumbnail_text: "CROWN CHAKRA DIVINE",
script_status: "draft",
speakflow_link: "https://speakflow.com/crown-chakra-script",
drive_link: "",
gpt_mock_link: "https://chatgpt.com/gpt-mock/crown-chakra-artwork",
upload_date: null,
assigned_to: ["A", "T"],
notes: "Final chakra in series. Allison working on script, Tim reviewing for spiritual accuracy.",
thumbnail_file: null,
script_file: null,
youtube_views: 0,
youtube_likes: 0,
youtube_comments: 0,
view_count: 0,
like_count: 0,
comment_count: 0
}
];
// Clone data for editing
this.currentData = JSON.parse(JSON.stringify(this.originalData));
this.renderContent();
this.updateStats();
}
async saveData() {
try {
this.showNotification('Saving changes...', 'info');
// Save all modified items
const savePromises = this.currentData.map(async (item) => {
const original = this.originalData.find(o => o.id === item.id);
if (!original || JSON.stringify(item) !== JSON.stringify(original)) {
// Item was modified, save it
return this.saveItem(item);
}
});
await Promise.all(savePromises.filter(Boolean));
// Update original data to match current
this.originalData = JSON.parse(JSON.stringify(this.currentData));
this.showNotification('All changes saved successfully!', 'success');
} catch (error) {
console.error('Error saving data:', error);
this.showNotification('Failed to save some changes', 'error');
}
}
async saveItem(item) {
const response = await fetch(`${this.apiUrl}/content/${item.id}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(item)
});
if (!response.ok) {
throw new Error(`Failed to save ${item.title}`);
}
return response.json();
}
// Event Listeners
setupEventListeners() {
// Edit mode toggle
document.getElementById('editModeToggle').addEventListener('click', () => this.toggleEditMode());
// Action buttons
document.getElementById('addContentBtn').addEventListener('click', () => this.showAddContentForm());
document.getElementById('generateReportBtn').addEventListener('click', () => this.generateReport());
// Filter functionality
document.querySelectorAll('.filter-select').forEach(select => {
select.addEventListener('change', (e) => this.filterContent(e.target.value));
});
// Save shortcut
document.addEventListener('keydown', (e) => {
if (e.ctrlKey && e.key === 's') {
e.preventDefault();
this.saveData();
}
});
// Setup View Description links (work always, not just in edit mode)
this.setupDescriptionLinks();
}
// Edit Mode Management
toggleEditMode() {
const container = document.querySelector('.container');
const button = document.getElementById('editModeToggle');
this.isEditMode = !this.isEditMode;
if (this.isEditMode) {
container.classList.add('edit-mode');
button.textContent = '💾 Save & Exit';
button.style.background = '#e53e3e';
this.renderContent(); // Re-render to add delete column
this.enableEditMode();
this.showNotification('Edit mode enabled - Click any field to edit', 'info');
} else {
this.saveData();
container.classList.remove('edit-mode');
button.textContent = '📝 Enable Edit Mode';
button.style.background = '#805ad5';
this.renderContent(); // Re-render to remove delete column
this.showNotification('Changes saved and edit mode disabled', 'success');
}
}
enableEditMode() {
// Make all editable fields clickable
this.setupEditableFields();
}
setupDescriptionLinks() {
// This runs always, not just in edit mode
document.addEventListener('click', (e) => {
if (e.target.matches('[data-field="youtube_description"]')) {
e.preventDefault();
const itemId = parseInt(e.target.closest('tr').getAttribute('data-id'));
const item = this.currentData.find(d => d.id === itemId);
if (this.isEditMode) {
// In edit mode, allow editing
this.editField(e.target, 'youtube_description', 'textarea');
} else {
// Not in edit mode, just view
this.showDescriptionModal(item.title, item.youtube_description);
}
}
});
}
showDescriptionModal(title, descriptionContent) {
const modal = document.createElement('div');
modal.className = 'modal-overlay';
// Parse description and tags
const { description, tags } = this.parseDescriptionAndTags(descriptionContent);
// Format the description nicely
const formattedDescription = this.formatYouTubeDescription(description || 'No description available');
// Render tags if they exist
const tagsSection = tags.length > 0 ? `