forked from UKSOURCE/cms.hailearning.edu.vn
refactor: enhance home page structure and content management
This commit is contained in:
@@ -13,32 +13,18 @@
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-medium">Heading</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="faqHeading"
|
||||
value="<%= data.faq?.heading || '' %>"
|
||||
placeholder="e.g., Got Questions? We've Got Answers"
|
||||
/>
|
||||
<input type="text" class="form-control" id="faqHeading" value="<%= data.faq?.heading || '' %>"
|
||||
placeholder="e.g., Got Questions? We've Got Answers" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-medium">Subheading</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="faqSubheading"
|
||||
value="<%= data.faq?.subheading || '' %>"
|
||||
placeholder="e.g., Visa FAQs"
|
||||
/>
|
||||
<input type="text" class="form-control" id="faqSubheading" value="<%= data.faq?.subheading || '' %>"
|
||||
placeholder="e.g., Visa FAQs" />
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label class="form-label fw-medium">Description</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
id="faqDescription"
|
||||
rows="3"
|
||||
placeholder="Enter description"
|
||||
><%= data.faq?.description || '' %></textarea>
|
||||
<textarea class="form-control" id="faqDescription" rows="3"
|
||||
placeholder="Enter description"><%= data.faq?.description || '' %></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -48,16 +34,33 @@
|
||||
<!-- FAQ Items -->
|
||||
<div class="col-md-12">
|
||||
<div class="card border shadow-sm">
|
||||
<div class="card-header bg-white">
|
||||
<div class="card-header bg-white d-flex justify-content-between align-items-center">
|
||||
<h6 class="mb-0">
|
||||
<i class="fas fa-question-circle me-2"></i>FAQ Items
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<% (data.faq?.items || []).forEach(function(item, index) { %>
|
||||
<div class="card mb-3 bg-light border">
|
||||
<div class="card-body" id="faqItemsContainer">
|
||||
<%
|
||||
const faqItems = (data.faq && Array.isArray(data.faq.items) && data.faq.items.length === 5)
|
||||
? data.faq.items
|
||||
: (data.faq && Array.isArray(data.faq.items) && data.faq.items.length > 0)
|
||||
? (function () {
|
||||
const clone = data.faq.items.slice(0, 5);
|
||||
while (clone.length < 5) clone.push({});
|
||||
return clone;
|
||||
})()
|
||||
: [{}, {}, {}, {}, {}];
|
||||
%>
|
||||
<% faqItems.forEach(function(item, index) { %>
|
||||
<div class="card mb-3 bg-light border faq-item" data-index="<%= index %>">
|
||||
<div class="card-header d-flex justify-content-between align-items-center bg-white">
|
||||
<h6 class="card-title fw-bold mb-0">FAQ
|
||||
<span class="faq-item-label">
|
||||
<%= index + 1 %>
|
||||
</span>
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h6 class="card-title fw-bold mb-3">FAQ <%= index + 1 %></h6>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-12">
|
||||
<label class="form-label fw-medium">Question</label>
|
||||
@@ -98,23 +101,13 @@
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-medium">Label</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="faqCtaLabel"
|
||||
value="<%= data.faq?.ctaButton?.label || '' %>"
|
||||
placeholder="e.g., contact us"
|
||||
/>
|
||||
<input type="text" class="form-control" id="faqCtaLabel" value="<%= data.faq?.ctaButton?.label || '' %>"
|
||||
placeholder="e.g., contact us" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label fw-medium">Link</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="faqCtaHref"
|
||||
value="<%= data.faq?.ctaButton?.href || '' %>"
|
||||
placeholder="/contact"
|
||||
/>
|
||||
<input type="text" class="form-control" id="faqCtaHref" value="<%= data.faq?.ctaButton?.href || '' %>"
|
||||
placeholder="/contact" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -122,3 +115,34 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Register scraper to collect FAQ data before form submit
|
||||
window.homeScrapers = window.homeScrapers || {};
|
||||
window.homeScrapers.faq = () => {
|
||||
const getVal = (id) => (document.getElementById(id)?.value || "").trim();
|
||||
|
||||
const items = [];
|
||||
document.querySelectorAll(".faq-item").forEach((el, idx) => {
|
||||
const index = el.getAttribute("data-index") || idx;
|
||||
|
||||
const question = getVal(`faqQuestion_${index}`);
|
||||
const answer = getVal(`faqAnswer_${index}`);
|
||||
|
||||
if (question || answer) {
|
||||
items.push({ question, answer });
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
heading: getVal("faqHeading"),
|
||||
subheading: getVal("faqSubheading"),
|
||||
description: getVal("faqDescription"),
|
||||
ctaButton: {
|
||||
label: getVal("faqCtaLabel"),
|
||||
href: getVal("faqCtaHref")
|
||||
},
|
||||
items
|
||||
};
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user