# คู่มือการใช้งาน Documentation System ## ภาพรวม ระบบเอกสารนี้เป็นระบบแสดงผลไฟล์ Markdown แบบเรียลไทม์ที่ออกแบบมาเพื่อแสดงเอกสารของ Kotchasan Framework ## คุณสมบัติหลัก ### 🌐 หลายภาษา - รองรับภาษาไทยและอังกฤษ - เปลี่ยนภาษาได้แบบเรียลไทม์ - ไฟล์เอกสารแยกตามภาษา ### 🎨 ธีม - โหมดสว่าง (Light Mode) - โหมดมืด (Dark Mode) - เปลี่ยนธีมได้ทันที ### 📱 Responsive Design - รองรับทุกขนาดหน้าจอ - Mobile-first design - Touch-friendly interface ## การใช้งานพื้นฐาน ### 1. เปิดระบบเอกสาร ```bash # เปิดไฟล์ index.html ในเบราว์เซอร์ open index.html # หรือใช้ local server python3 -m http.server 8000 # เปิด http://localhost:8000 ``` ### 2. การนำทาง #### เมนูด้านซ้าย - แสดงรายการเอกสารทั้งหมด - คลิกเพื่อเปลี่ยนเอกสาร - แสดงสถานะเอกสารที่เลือก #### การเปลี่ยนภาษา - คลิกปุ่ม 🌐 TH/EN - ระบบจะโหลดเอกสารภาษาที่เลือก - รองรับการเปลี่ยนภาษาแบบเรียลไทม์ #### การเปลี่ยนธีม - คลิกปุ่ม 🌙 Dark/☀️ Light - เปลี่ยนสีพื้นหลังและข้อความ - บันทึกการตั้งค่าใน localStorage ### 3. การอ่านเอกสาร #### Markdown Support - รองรับ Markdown syntax ครบถ้วน - Code highlighting สำหรับ PHP, JavaScript, CSS - ตาราง, รายการ, ลิงก์ #### Code Blocks ```markdown ```php 🆕 ฟีเจอร์ใหม่ ``` ```javascript document.getElementById('newFeatureBtn').addEventListener('click', () => { // ฟังก์ชันใหม่ }); ``` #### เพิ่มเมนู ```javascript // เพิ่มเมนูใหม่ function addCustomMenu() { const menu = document.getElementById('fileTree'); const newItem = document.createElement('div'); newItem.className = 'file-item'; newItem.textContent = 'เมนูใหม่'; newItem.onclick = () => loadCustomContent(); menu.appendChild(newItem); } ``` ## การแก้ไขปัญหา ### ปัญหาที่พบบ่อย #### 1. ไฟล์ไม่โหลด **สาเหตุ:** - ชื่อไฟล์ผิด - ไฟล์ไม่อยู่ในตำแหน่งที่ถูกต้อง - สิทธิ์ไฟล์ไม่ถูกต้อง **วิธีแก้:** ```bash # ตรวจสอบชื่อไฟล์ ls -la docs/th/ # ตรวจสอบสิทธิ์ chmod 644 docs/th/*.md # ตรวจสอบโครงสร้าง tree docs/ ``` #### 2. ธีมไม่เปลี่ยน **สาเหตุ:** - JavaScript error - CSS ไม่โหลด - Cache เบราว์เซอร์ **วิธีแก้:** ```javascript // ตรวจสอบ console console.log('Theme:', currentTheme); // ล้าง cache localStorage.clear(); location.reload(); ``` #### 3. ภาษาไม่เปลี่ยน **สาเหตุ:** - ไฟล์ .md ไม่มีในภาษาที่เลือก - ชื่อไฟล์ไม่ตรงกัน - JavaScript error **วิธีแก้:** ```javascript // ตรวจสอบไฟล์ที่มี console.log('Available docs:', Object.keys(docs)); // ตรวจสอบภาษา console.log('Current lang:', currentLang); ``` ### การ Debug #### เปิด Developer Tools ```javascript // ตรวจสอบสถานะ console.log('Current language:', currentLang); console.log('Current theme:', currentTheme); console.log('Available documents:', Object.keys(docs)); console.log('Current document:', currentDoc); ``` #### ตรวจสอบ Network 1. เปิด Developer Tools (F12) 2. ไปที่แท็บ Network 3. ดูการโหลดไฟล์ .md 4. ตรวจสอบ HTTP status codes ## การ Deploy ### 1. เตรียมไฟล์ ```bash # สร้างไฟล์สำหรับ production cp -r docs/ production/ cp index.html production/ cp README.md production/ ``` ### 2. อัปโหลด ```bash # ใช้ rsync rsync -avz production/ user@server:/var/www/docs/ # ใช้ scp scp -r production/* user@server:/var/www/docs/ ``` ### 3. ตั้งค่า Web Server #### Apache ```apache ServerName docs.yourdomain.com DocumentRoot /var/www/docs AllowOverride All Require all granted ``` #### Nginx ```nginx server { listen 80; server_name docs.yourdomain.com; root /var/www/docs; index index.html; location / { try_files $uri $uri/ /index.html; } location ~ \.md$ { add_header Content-Type text/plain; } } ``` ## การบำรุงรักษา ### การอัปเดตเอกสาร ```bash # อัปเดตเอกสาร git pull origin main # ตรวจสอบการเปลี่ยนแปลง git diff HEAD~1 # ทดสอบการทำงาน python3 -m http.server 8000 ``` ### การสำรองข้อมูล ```bash # สำรองไฟล์ tar -czf docs-backup-$(date +%Y%m%d).tar.gz docs/ # สำรองฐานข้อมูล (ถ้ามี) mysqldump -u user -p database > backup.sql ``` ### การติดตามการใช้งาน ```javascript // เพิ่ม Google Analytics gtag('config', 'GA_MEASUREMENT_ID'); // ติดตามการเปลี่ยนภาษา function trackLanguageChange(lang) { gtag('event', 'language_change', { 'language': lang }); } // ติดตามการเปลี่ยนธีม function trackThemeChange(theme) { gtag('event', 'theme_change', { 'theme': theme }); } ``` ## การพัฒนาต่อ ### การเพิ่มฟีเจอร์ใหม่ #### 1. Search Functionality ```javascript // เพิ่มฟังก์ชันค้นหา function addSearch() { const searchInput = document.createElement('input'); searchInput.type = 'text'; searchInput.placeholder = 'ค้นหาเอกสาร...'; searchInput.onkeyup = (e) => searchDocuments(e.target.value); document.querySelector('.header-controls').appendChild(searchInput); } function searchDocuments(query) { const results = Object.keys(docs).filter(doc => doc.toLowerCase().includes(query.toLowerCase()) ); // แสดงผลการค้นหา } ``` #### 2. Print Functionality ```javascript // เพิ่มฟังก์ชันพิมพ์ function addPrintButton() { const printBtn = document.createElement('button'); printBtn.className = 'btn'; printBtn.innerHTML = '🖨️ พิมพ์'; printBtn.onclick = () => window.print(); document.querySelector('.header-controls').appendChild(printBtn); } ``` #### 3. Export Functionality ```javascript // เพิ่มฟังก์ชันส่งออก function addExportButton() { const exportBtn = document.createElement('button'); exportBtn.className = 'btn'; exportBtn.innerHTML = '📄 ส่งออก'; exportBtn.onclick = () => exportDocument(); document.querySelector('.header-controls').appendChild(exportBtn); } function exportDocument() { const content = document.getElementById('content').innerHTML; const blob = new Blob([content], { type: 'text/html' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `${currentDoc}.html`; a.click(); } ``` --- **หมายเหตุ**: คู่มือนี้ครอบคลุมการใช้งานระบบเอกสาร สำหรับข้อมูลเพิ่มเติมโปรดดูที่ [API Reference](api-reference.md)