تست: تفاوت میان نسخهها
ظاهر
بدون خلاصۀ ویرایش |
بدون خلاصۀ ویرایش |
||
خط ۱: | خط ۱: | ||
<html lang="fa" dir="rtl"> | <html lang="fa" dir="rtl"> | ||
<head> | <head> | ||
خط ۴۹: | خط ۴۸: | ||
font-size: 16px; | font-size: 16px; | ||
box-sizing: border-box; | box-sizing: border-box; | ||
} | |||
.quick-search { | |||
width: 200px !important; | |||
display: inline-block; | |||
margin-left: 10px; | |||
} | } | ||
button { | button { | ||
خط ۶۸: | خط ۷۲: | ||
flex-wrap: wrap; | flex-wrap: wrap; | ||
margin-top: 10px; | margin-top: 10px; | ||
} | |||
.navigation-buttons { | |||
display: flex; | |||
justify-content: center; | |||
margin: 15px 0; | |||
gap: 10px; | |||
} | |||
.nav-btn { | |||
background-color: #6c757d; | |||
} | |||
.nav-btn:hover { | |||
background-color: #545b62; | |||
} | |||
.view-original { | |||
background-color: #28a745; | |||
} | |||
.view-original:hover { | |||
background-color: #218838; | |||
} | } | ||
.iframe-container { | .iframe-container { | ||
خط ۷۴: | خط ۹۶: | ||
border-radius: 8px; | border-radius: 8px; | ||
overflow: hidden; | overflow: hidden; | ||
position: relative; | |||
} | } | ||
iframe { | iframe { | ||
خط ۷۹: | خط ۱۰۲: | ||
height: 600px; | height: 600px; | ||
border: none; | border: none; | ||
} | |||
.content-only { | |||
/* استایل برای نمایش فقط محتوا */ | |||
} | } | ||
.help-text { | .help-text { | ||
خط ۸۵: | خط ۱۱۱: | ||
margin-top: 5px; | margin-top: 5px; | ||
} | } | ||
.admin- | .admin-only { | ||
display: none; | |||
background-color: #f8f9fa; | background-color: #f8f9fa; | ||
border: | border: 1px dashed #dc3545; | ||
padding: 15px; | padding: 15px; | ||
border-radius: | border-radius: 4px; | ||
margin-top: | margin-top: 10px; | ||
} | } | ||
.admin-label { | .admin-label { | ||
color: # | color: #dc3545; | ||
font-weight: bold; | font-weight: bold; | ||
} | } | ||
. | .quick-search-container { | ||
display: flex; | |||
align-items: center; | |||
margin-bottom: 15px; | |||
} | } | ||
. | .quick-search-label { | ||
margin-bottom: 0; | |||
margin-left: 10px; | |||
white-space: nowrap; | |||
margin- | |||
} | } | ||
</style> | </style> | ||
خط ۱۱۶: | خط ۱۴۰: | ||
<div class="search-section"> | <div class="search-section"> | ||
<!-- جستجوی سریع --> | |||
<div class="quick-search-container"> | |||
<label for="quickSearch" class="quick-search-label">جستجوی سریع:</label> | |||
<input type="text" id="quickSearch" class="quick-search" placeholder="نام کتاب..."> | |||
<button id="quickSearchBtn">برو</button> | |||
</div> | |||
<div class="form-group"> | <div class="form-group"> | ||
<label for="bookSelect">انتخاب کتاب از لیست:</label> | <label for="bookSelect">انتخاب کتاب از لیست:</label> | ||
خط ۱۲۵: | خط ۱۵۶: | ||
<option value="انجیل">انجیل</option> | <option value="انجیل">انجیل</option> | ||
<option value="تورات">تورات</option> | <option value="تورات">تورات</option> | ||
<option value="مزامیر">مزامیر</option> | |||
<option value="امثال">امثال</option> | |||
<option value="اشعیا">اشعیا</option> | |||
<option value="متی">متی</option> | |||
<option value="مرقس">مرقس</option> | |||
<option value="لوقا">لوقا</option> | |||
<option value="یوحنا">یوحنا</option> | |||
<!-- میتوانید کتابهای بیشتری به این لیست اضافه کنید --> | |||
</select> | </select> | ||
</div> | </div> | ||
<!-- بخش مدیریتی - فقط برای مدیران قابل نمایش --> | |||
<div id="adminSection" class="admin-only"> | |||
<!-- بخش مدیریتی - | |||
<div id="adminSection" class="admin- | |||
<div class="form-group"> | <div class="form-group"> | ||
<label for="bookSearch" class="admin-label">ثبت کتاب جدید (مخصوص مدیران):</label> | <label for="bookSearch" class="admin-label">ثبت کتاب جدید (مخصوص مدیران):</label> | ||
<input type="text" id="bookSearch" placeholder="نام کتاب جدید را وارد کنید..."> | <input type="text" id="bookSearch" placeholder="نام کتاب جدید را وارد کنید..."> | ||
<div class="help-text">فقط مدیران | <div class="help-text">این بخش فقط برای مدیران سیستم قابل مشاهده است</div> | ||
</div> | </div> | ||
<div class="button-group"> | <div class="button-group"> | ||
<button id="createNew | <button id="createNew">ایجاد صفحه جدید</button> | ||
</div> | </div> | ||
</div> | </div> | ||
<div class="button-group"> | |||
<div class=" | <button id="showBook">نمایش کتاب</button> | ||
<button | |||
</div> | </div> | ||
</div> | </div> | ||
خط ۱۵۶: | خط ۱۸۷: | ||
<div class="iframe-container"> | <div class="iframe-container"> | ||
<iframe id="contentFrame" src="about:blank"></iframe> | <iframe id="contentFrame" src="about:blank"></iframe> | ||
</div> | |||
<!-- دکمههای ناوبری --> | |||
<div class="navigation-buttons"> | |||
<button id="prevBook" class="nav-btn">کتاب قبل</button> | |||
<button id="nextBook" class="nav-btn">کتاب بعد</button> | |||
<button id="viewOriginal" class="view-original">مشاهده در صفحه اصلی</button> | |||
</div> | </div> | ||
</div> | </div> | ||
<script> | <script> | ||
document.addEventListener('DOMContentLoaded', function() { | document.addEventListener('DOMContentLoaded', function() { | ||
const bookSelect = document.getElementById('bookSelect'); | const bookSelect = document.getElementById('bookSelect'); | ||
const bookSearch = document.getElementById('bookSearch'); | const bookSearch = document.getElementById('bookSearch'); | ||
const quickSearch = document.getElementById('quickSearch'); | |||
const quickSearchBtn = document.getElementById('quickSearchBtn'); | |||
const showBookBtn = document.getElementById('showBook'); | const showBookBtn = document.getElementById('showBook'); | ||
const createNewBtn = document.getElementById('createNew'); | const createNewBtn = document.getElementById('createNew'); | ||
const contentFrame = document.getElementById('contentFrame'); | const contentFrame = document.getElementById('contentFrame'); | ||
const adminSection = document.getElementById('adminSection'); | const adminSection = document.getElementById('adminSection'); | ||
const prevBookBtn = document.getElementById('prevBook'); | |||
const nextBookBtn = document.getElementById('nextBook'); | |||
const viewOriginalBtn = document.getElementById('viewOriginal'); | |||
let currentBookIndex = -1; | |||
const books = [ | |||
'کتاب_اول', 'کتاب_دوم', 'کتاب_سوم', 'انجیل', 'تورات', | |||
'مزامیر', 'امثال', 'اشعیا', 'متی', 'مرقس', 'لوقا', 'یوحنا' | |||
]; | |||
// بررسی آیا در دامنه pediabible هستیم | // بررسی آیا در دامنه pediabible هستیم | ||
خط ۲۰۱: | خط ۲۲۶: | ||
// بررسی آیا کاربر مدیر است | // بررسی آیا کاربر مدیر است | ||
function isAdminUser() { | function isAdminUser() { | ||
return localStorage.getItem('isAdmin') === 'true' || | |||
return localStorage.getItem('isAdmin') === 'true'; | document.cookie.includes('isAdmin=true') || | ||
window.location.search.includes('admin=true'); | |||
} | } | ||
// | // دریافت فقط محتوای صفحه | ||
function | function loadContentOnly(bookName) { | ||
if ( | const encodedBookName = encodeURIComponent(bookName); | ||
// استفاده از action=render برای دریافت فقط محتوا | |||
const contentUrl = `https://www.pediabible.com/index.php/${encodedBookName}?action=render`; | |||
contentFrame.src = contentUrl; | |||
// به روزرسانی ایندکس کتاب جاری | |||
currentBookIndex = books.indexOf(bookName); | |||
updateNavigationButtons(); | |||
} | |||
// به روزرسانی وضعیت دکمههای ناوبری | |||
function updateNavigationButtons() { | |||
prevBookBtn.disabled = currentBookIndex <= 0; | |||
nextBookBtn.disabled = currentBookIndex >= books.length - 1; | |||
if (prevBookBtn.disabled) { | |||
prevBookBtn.style.opacity = '0.5'; | |||
prevBookBtn.style.cursor = 'not-allowed'; | |||
} else { | |||
prevBookBtn.style.opacity = '1'; | |||
prevBookBtn.style.cursor = 'pointer'; | |||
} | |||
if (nextBookBtn.disabled) { | |||
nextBookBtn.style.opacity = '0.5'; | |||
nextBookBtn.style.cursor = 'not-allowed'; | |||
} else { | } else { | ||
nextBookBtn.style.opacity = '1'; | |||
nextBookBtn.style.cursor = 'pointer'; | |||
} | } | ||
} | } | ||
// | // جستجو در لیست کتابها | ||
function | function searchInBooks(searchTerm) { | ||
const normalizedSearch = searchTerm.trim().toLowerCase(); | |||
return | if (!normalizedSearch) return null; | ||
return books.find(book => | |||
book.toLowerCase().includes(normalizedSearch) || | |||
getBookDisplayName(book).toLowerCase().includes(normalizedSearch) | |||
); | |||
} | } | ||
// تنظیمات اولیه | // دریافت نام نمایشی کتاب | ||
function getBookDisplayName(bookId) { | |||
const option = bookSelect.querySelector(`option[value="${bookId}"]`); | |||
return option ? option.text : bookId; | |||
} | |||
// تنظیمات اولیه | |||
function initializePage() { | function initializePage() { | ||
if (!isInPediabibleDomain()) { | if (!isInPediabibleDomain()) { | ||
alert('این صفحه فقط در دامنه pediabible قابل دسترسی است'); | alert('این صفحه فقط در دامنه pediabible قابل دسترسی است'); | ||
خط ۲۲۹: | خط ۲۹۰: | ||
} | } | ||
if (isAdminUser()) { | |||
adminSection.style.display = 'block'; | |||
} | |||
updateNavigationButtons(); | |||
} | } | ||
// | // رویدادهای صفحه | ||
bookSelect.addEventListener('change', function() { | bookSelect.addEventListener('change', function() { | ||
if (this.value && isAdminUser()) { | if (this.value && isAdminUser()) { | ||
bookSearch.value = this.options[this.selectedIndex].text; | bookSearch.value = this.options[this.selectedIndex].text; | ||
} | |||
}); | |||
// جستجوی سریع | |||
quickSearchBtn.addEventListener('click', function() { | |||
const searchTerm = quickSearch.value.trim(); | |||
if (!searchTerm) { | |||
alert('لطفاً نام کتاب را وارد کنید'); | |||
return; | |||
} | |||
const foundBook = searchInBooks(searchTerm); | |||
if (foundBook) { | |||
bookSelect.value = foundBook; | |||
loadContentOnly(foundBook); | |||
} else { | |||
alert(`کتاب "${searchTerm}" یافت نشد`); | |||
} | |||
}); | |||
quickSearch.addEventListener('keypress', function(e) { | |||
if (e.key === 'Enter') { | |||
quickSearchBtn.click(); | |||
} | } | ||
}); | }); | ||
خط ۲۴۷: | خط ۳۲۹: | ||
// نمایش کتاب انتخاب شده | // نمایش کتاب انتخاب شده | ||
showBookBtn.addEventListener('click', function() { | showBookBtn.addEventListener('click', function() { | ||
const bookName = bookSelect.value; | |||
if (bookName) { | if (bookName) { | ||
loadContentOnly(bookName); | |||
} else { | } else { | ||
alert('لطفاً یک کتاب از لیست انتخاب کنید'); | alert('لطفاً یک کتاب از لیست انتخاب کنید'); | ||
خط ۲۶۸: | خط ۳۴۵: | ||
} | } | ||
if (!isAdminUser()) { | if (!isAdminUser()) { | ||
alert('شما مجوز ایجاد کتاب جدید را ندارید'); | alert('شما مجوز ایجاد کتاب جدید را ندارید'); | ||
خط ۲۷۵: | خط ۳۵۱: | ||
const encodedBookName = encodeURIComponent(bookName); | const encodedBookName = encodeURIComponent(bookName); | ||
const | const newPageUrl = `https://www.pediabible.com/index.php/${encodedBookName}`; | ||
fetch(newPageUrl) | |||
fetch( | |||
.then(response => { | .then(response => { | ||
if (response.status === 404) { | if (response.status === 404) { | ||
window.open(newPageUrl + '?action=edit', '_blank'); | |||
window.open( | |||
alert(`صفحه جدید برای "${bookName}" در حال ایجاد است`); | alert(`صفحه جدید برای "${bookName}" در حال ایجاد است`); | ||
} else { | } else { | ||
alert(`صفحه "${bookName}" از قبل وجود دارد`); | |||
loadContentOnly(bookName); | |||
} | } | ||
}) | }) | ||
.catch(error => { | .catch(error => { | ||
console.error('Error:', error); | console.error('Error:', error); | ||
window.open(newPageUrl + '?action=edit', '_blank'); | |||
window.open( | |||
}); | }); | ||
}); | |||
// ناوبری بین کتابها | |||
prevBookBtn.addEventListener('click', function() { | |||
if (currentBookIndex > 0) { | |||
const prevBook = books[currentBookIndex - 1]; | |||
bookSelect.value = prevBook; | |||
loadContentOnly(prevBook); | |||
} | |||
}); | |||
nextBookBtn.addEventListener('click', function() { | |||
if (currentBookIndex < books.length - 1) { | |||
const nextBook = books[currentBookIndex + 1]; | |||
bookSelect.value = nextBook; | |||
loadContentOnly(nextBook); | |||
} | |||
}); | |||
// مشاهده در صفحه اصلی | |||
viewOriginalBtn.addEventListener('click', function() { | |||
const currentBook = bookSelect.value; | |||
if (currentBook) { | |||
const encodedBookName = encodeURIComponent(currentBook); | |||
window.open(`https://www.pediabible.com/index.php/${encodedBookName}`, '_blank'); | |||
} else { | |||
alert('لطفاً ابتدا یک کتاب انتخاب کنید'); | |||
} | |||
}); | }); | ||
خط ۳۱۰: | خط ۴۰۰: | ||
initializePage(); | initializePage(); | ||
// | // برای تست | ||
window. | if (window.location.search.includes('setadmin=true')) { | ||
localStorage.setItem('isAdmin', 'true'); | |||
adminSection.style.display = 'block'; | |||
} | alert('حالت مدیر فعال شد'); | ||
} | |||
if (window.location.search.includes('removeadmin=true')) { | |||
localStorage.setItem('isAdmin', 'false'); | |||
adminSection.style.display = 'none'; | |||
alert('حالت مدیر غیرفعال شد'); | |||
} | |||
}); | }); | ||
</script> | </script> | ||
</body> | </body> | ||
</html> | </html> |
نسخهٔ ۱۲ اکتبر ۲۰۲۵، ساعت ۱۷:۴۱
کتابخانه پدیا بایبل
این بخش فقط برای مدیران سیستم قابل مشاهده است