oss2024hnu / coursegraph-js

HTML5로 전공과목 정보 YAML 파일을 전공이수체계도나 표로 시각화하는 프로젝트
MIT License
3 stars 48 forks source link

과목 데이터 자동 갱신 기능 추가 #213

Closed leeseungho55 closed 2 months ago

leeseungho55 commented 2 months ago

// 예시코드(js) document.getElementById('courseForm').addEventListener('submit', function(event) { event.preventDefault(); const courseName = document.getElementById('courseName').value; const courseDetails = document.getElementById('courseDetails').value;

// 과목 데이터를 서버로 전송
fetch('/updateCourse', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({ courseName, courseDetails })
})
.then(response => response.json())
.then(data => {
    if (data.success) {
        alert('과목이 성공적으로 추가/수정되었습니다.');
        // 과목 목록 갱신
        loadCourseList();
    } else {
        alert('과목 추가/수정에 실패했습니다.');
    }
});

});

function loadCourseList() { fetch('/getCourses') .then(response => response.json()) .then(data => { const courseList = document.getElementById('courseList'); courseList.innerHTML = ''; data.courses.forEach(course => { const div = document.createElement('div'); div.textContent = ${course.name}: ${course.details}; courseList.appendChild(div); }); }); }

// 페이지 로드 시 과목 목록 로드 document.addEventListener('DOMContentLoaded', loadCourseList);

leeseungho55 commented 2 months ago

Show.html의 JS 코드 향후 적용 후 리퀘스트할 예정

kyagrd commented 2 months ago

지금 백엔드 아니고 프론트엔드 프로젝트입니다. 뭔가요 정말?