吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3136|回复: 38
上一主题 下一主题
收起左侧

[其他原创] 给小学生做的课程表工具

  [复制链接]
跳转到指定楼层
楼主
amitder 发表于 2025-12-18 01:11 回帖奖励
给小学生做的课程表工具
借鉴-给孩子做的课程表工具
https://www.52pojie.cn/thread-2079550-1-1.html
(出处: 吾爱破解论坛)


可以自己配置课程,自由增减课节,并且点击打印到A4纸

按要求附上源码
[HTML] 纯文本查看 复制代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>&#127894;&#65039; 课程表 &#127894;&#65039;</title>
    <style>
        [url=home.php?mod=space&uid=476974]@import[/url] url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700&family=Comic+Neue:wght@400;700&display=swap');

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        :root {
            --blue-light: #E0F7FA;
            --blue-medium: #80DEEA;
            --blue-dark: #26C6DA;
            --cyan-light: #B2EBF2;
            --cyan-medium: #4DD0E1;
            --text-dark: #263238;
            --text-light: #546E7A;
            --white: #FFFFFF;
            --shadow: 0 8px 32px rgba(38, 198, 218, 0.2);
            --shadow-hover: 0 12px 48px rgba(38, 198, 218, 0.3);
        }

        body {
            font-family: 'Noto Sans SC', 'Comic Neue', sans-serif;
            background: linear-gradient(135deg, #E0F7FA 0%, #B2EBF2 50%, #80DEEA 100%);
            color: var(--text-dark);
            line-height: 1.6;
            min-height: 100vh;
            position: relative;
            overflow-x: hidden;
        }

        /* 装饰元素样式 */
        .decoration {
            position: fixed;
            pointer-events: none;
            z-index: 0;
        }
        .butterfly { font-size: 2rem; animation: float 6s ease-in-out infinite; }
        .flower { font-size: 1.5rem; animation: spin 20s linear infinite; }
        .star { font-size: 1.2rem; animation: twinkle 2s ease-in-out infinite; }
        .butterfly:nth-child(1) { top: 10%; left: 5%; animation-delay: 0s; }
        .butterfly:nth-child(2) { top: 20%; right: 8%; animation-delay: 1s; }
        .butterfly:nth-child(3) { bottom: 15%; left: 10%; animation-delay: 2s; }
        .butterfly:nth-child(4) { bottom: 25%; right: 5%; animation-delay: 3s; }
        .flower:nth-child(5) { top: 30%; left: 3%; }
        .flower:nth-child(6) { top: 60%; right: 4%; }
        .flower:nth-child(7) { bottom: 10%; left: 15%; }
        .star:nth-child(8) { top: 15%; left: 20%; animation-delay: 0.5s; }
        .star:nth-child(9) { top: 50%; right: 15%; animation-delay: 1s; }
        .star:nth-child(10) { bottom: 20%; right: 20%; animation-delay: 1.5s; }

        @keyframes float { 0%,100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-20px) rotate(10deg); } }
        @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
        @keyframes twinkle { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(1.2); } }

        .container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 2rem;
            position: relative;
            z-index: 1;
        }

        .header {
            text-align: center;
            margin-bottom: 1rem;
            animation: fadeInDown 0.8s ease;
            background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(224,247,250,0.9) 100%);
            padding: 1rem;
            border-radius: 30px;
            box-shadow: var(--shadow);
            border: 3px solid var(--blue-medium);
        }
        .header h1 {
            font-size: 2.5rem;
            font-weight: 700;
            background: linear-gradient(135deg, #26C6DA 0%, #4DD0E1 50%, #26C6DA 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            margin-bottom: 0.5rem;
            font-family: 'Comic Neue', 'Noto Sans SC', sans-serif;
        }
        .title-edit {
            margin-top: 1rem;
        }
        .title-edit input {
            padding: 0.5rem;
            border: 2px solid var(--blue-medium);
            border-radius: 15px;
            font-size: 1rem;
            width: 200px;
            text-align: center;
        }
        .title-edit button {
            margin-left: 0.5rem;
            padding: 0.5rem 1rem;
            background-color: var(--blue-dark);
            color: white;
            border: none;
            border-radius: 15px;
            cursor: pointer;
        }
        .subtitle {
            color: var(--text-light);
            font-size: 1rem;
        }

        .main-content {
            display: grid;
            grid-template-columns: 420px 1fr;
            gap: 2rem;
            animation: fadeInUp 0.8s ease;
        }

        /* 配置面板 */
        .config-panel {
            background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(224,247,250,0.95) 100%);
            border: 3px solid var(--blue-medium);
            border-radius: 30px;
            padding: 2rem;
            box-shadow: var(--shadow);
            transition: all 0.3s ease;
        }
        .config-panel:hover {
            box-shadow: var(--shadow-hover);
            transform: translateY(-2px);
        }
        .config-panel h2 {
            font-size: 1.5rem;
            margin-bottom: 1.5rem;
            color: var(--blue-dark);
            font-family: 'Comic Neue', 'Noto Sans SC', sans-serif;
            text-align: center;
        }

        .class-count-control {
            margin-bottom: 1.5rem;
            text-align: center;
        }
        .class-count-control button {
            padding: 0.5rem 1rem;
            background-color: var(--blue-medium);
            color: var(--text-dark);
            border: none;
            border-radius: 15px;
            cursor: pointer;
            margin: 0 0.5rem;
            transition: all 0.2s ease;
            font-size: 1.2rem;
            width: 40px;
            height: 40px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        .class-count-control button:hover {
            background-color: var(--blue-dark);
            color: white;
        }
        .class-count-display {
            font-size: 1.2rem;
            font-weight: bold;
            margin: 0 1rem;
        }

        .day-selector {
            display: grid;
            grid-template-columns: repeat(5, 1fr); /* 修改为5列(周一到周五) */
            gap: 0.5rem;
            margin-bottom: 2rem;
        }
        .day-btn {
            padding: 0.8rem 0.3rem;
            border: 2px solid var(--blue-medium);
            background: white;
            color: var(--text-dark);
            border-radius: 15px;
            cursor: pointer;
            font-size: 0.85rem;
            font-weight: 600;
            transition: all 0.3s ease;
            position: relative;
        }
        .day-btn:hover {
            background: var(--blue-light);
            border-color: var(--blue-dark);
            transform: translateY(-3px) scale(1.05);
            box-shadow: 0 5px 15px rgba(38,198,218,0.3);
        }
        .day-btn.active {
            background: linear-gradient(135deg, var(--blue-dark) 0%, var(--cyan-medium) 100%);
            border-color: var(--blue-dark);
            color: white;
            box-shadow: 0 5px 20px rgba(38,198,218,0.4);
            transform: scale(1.1);
        }
        .day-btn.active::after {
            content: '&#128150;';
            position: absolute;
            top: -10px;
            right: -5px;
            font-size: 1rem;
        }

        .form-section {
            margin-bottom: 2rem;
            background: rgba(255,255,255,0.6);
            padding: 1.5rem;
            border-radius: 20px;
            border: 2px dashed var(--blue-medium);
        }
        .form-section h3 {
            font-size: 1.2rem;
            margin-bottom: 1rem;
            color: var(--blue-dark);
            font-family: 'Comic Neue', 'Noto Sans SC', sans-serif;
            text-align: center;
        }

        .course-input {
            margin-bottom: 1rem;
            position: relative;
        }
        /* 时间段切换按钮样式 */
        .time-switch {
            position: absolute;
            top: 0;
            right: 10px;
            display: flex;
            gap: 0.3rem;
        }
        .time-switch-btn {
            padding: 0.3rem 0.6rem;
            border: 1px solid var(--blue-medium);
            border-radius: 8px;
            background: white;
            color: var(--text-dark);
            font-size: 0.75rem;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        .time-switch-btn.active {
            background: var(--blue-dark);
            color: white;
            border-color: var(--blue-dark);
        }

        .course-input label {
            display: block;
            margin-bottom: 0.5rem;
            color: var(--text-dark);
            font-size: 0.9rem;
            font-weight: 600;
        }
        .course-input input {
            width: 100%;
            padding: 0.9rem 1rem;
            background: white;
            border: 2px solid var(--blue-medium);
            border-radius: 15px;
            color: var(--text-dark);
            font-size: 0.95rem;
            transition: all 0.3s ease;
            font-family: 'Noto Sans SC', sans-serif;
        }
        .course-input input:focus {
            outline: none;
            border-color: var(--blue-dark);
            box-shadow: 0 0 0 4px rgba(38,198,218,0.2);
        }

        /* 按钮样式 */
        .action-buttons {
            display: flex;
            gap: 1rem;
            margin-top: 2rem;
        }
        .btn {
            flex: 1;
            padding: 1rem 1.5rem;
            border: none;
            border-radius: 20px;
            font-size: 1rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            font-family: 'Noto Sans SC', sans-serif;
        }
        .btn-save {
            background: linear-gradient(135deg, #26C6DA 0%, #00BCD4 100%);
            color: white;
            box-shadow: 0 5px 20px rgba(38,198,218,0.4);
        }
        .btn-clear {
            background: linear-gradient(135deg, #4DD0E1 0%, #00ACC1 100%);
            color: white;
            box-shadow: 0 5px 20px rgba(77,208,225,0.4);
        }
        .btn-print {
            background: linear-gradient(135deg, #80DEEA 0%, #26C6DA 100%);
            color: white;
            box-shadow: 0 5px 20px rgba(128,222,234,0.4);
            padding: 1rem 2rem;
            border: none;
            border-radius: 20px;
            font-size: 1rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        /* 预览面板 */
        .preview-panel {
            background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(229,212,255,0.95) 100%);
            border: 3px solid var(--cyan-medium);
            border-radius: 30px;
            padding: 2rem;
            box-shadow: var(--shadow);
        }
        .preview-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 2rem;
        }
        .preview-header h2 {
            font-size: 1.5rem;
            color: var(--cyan-medium);
            font-family: 'Comic Neue', 'Noto Sans SC', sans-serif;
        }

        /* 课程表样式 */
        .schedule-table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
            background: white;
            border-radius: 20px;
            overflow: hidden;
            box-shadow: 0 5px 20px rgba(0,0,0,0.1);
        }
        .schedule-table th, .schedule-table td {
            padding: 1rem;
            text-align: center;
            border: 2px solid var(--blue-light);
        }
        .schedule-table th {
            background: linear-gradient(135deg, var(--blue-medium) 0%, var(--cyan-light) 100%);
            font-weight: 700;
            color: var(--text-dark);
            font-size: 1rem;
        }
        .schedule-table td {
            background: white;
            color: var(--text-dark);
            transition: all 0.3s ease;
            font-size: 0.95rem;
            font-weight: 500;
            cursor: pointer; /* 添加鼠标指针样式 */
        }
        .schedule-table td:hover {
            background: var(--blue-light);
            transform: scale(1.05);
            box-shadow: 0 3px 10px rgba(38,198,218,0.2);
        }
        .schedule-table td.rest-cell {
            background: linear-gradient(135deg, #E0F7FA 0%, #80DEEA 100%);
            color: var(--blue-dark);
            font-weight: 700;
        }
        .schedule-table td.course-cell {
            background: linear-gradient(135deg, #B2EBF2 0%, #4DD0E1 100%);
            color: var(--text-dark);
            font-weight: 600;
        }
        .schedule-table td.empty-cell {
            color: var(--text-light);
            font-style: italic;
        }
        /* 上午/下午节次样式(仅背景色区分,无文字) */
        .morning-slot {
            background: linear-gradient(135deg, #FFF8E1 0%, #FFECB3 100%);
            font-weight: bold;
            color: #FF8F00;
            cursor: default; /* 节次单元格不响应点击 */
        }
        .afternoon-slot {
            background: linear-gradient(135deg, #E1F5FE 0%, #B3E5FC 100%);
            font-weight: bold;
            color: #0288D1;
            cursor: default; /* 节次单元格不响应点击 */
        }
        .time-divider {
            background: linear-gradient(135deg, var(--blue-dark) 0%, var(--cyan-medium) 100%);
            color: white;
            font-weight: bold;
            font-size: 1.1rem;
            cursor: default; /* 分割线不响应点击 */
        }

        /* 弹窗样式 */
        .course-modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.5);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 9999;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s ease;
        }
        .course-modal-overlay.active {
            opacity: 1;
            visibility: visible;
        }
        .course-modal {
            background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(224,247,250,0.98) 100%);
            border: 3px solid var(--blue-medium);
            border-radius: 30px;
            padding: 2rem;
            max-width: 500px;
            width: 90%;
            max-height: 80vh;
            overflow-y: auto;
            box-shadow: 0 20px 60px rgba(38,198,218,0.4);
            transform: scale(0.8) translateY(-20px);
            transition: all 0.3s ease;
            position: relative;
        }
        .course-modal-overlay.active .course-modal {
            transform: scale(1) translateY(0);
        }
        .course-options {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 0.8rem;
            margin-bottom: 1.5rem;
        }
        .course-option {
            padding: 0.8rem 0.5rem;
            background: white;
            border: 2px solid var(--blue-light);
            border-radius: 15px;
            cursor: pointer;
            font-size: 0.9rem;
            font-weight: 600;
            color: var(--text-dark);
            transition: all 0.3s ease;
            text-align: center;
        }
        .course-option:hover {
            background: var(--blue-light);
            border-color: var(--blue-medium);
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(38,198,218,0.2);
        }
        .course-option.rest-option {
            background: linear-gradient(135deg, #E0F7FA 0%, #80DEEA 100%);
            border-color: var(--blue-medium);
        }
        .course-option.rest-option:hover {
            background: linear-gradient(135deg, #80DEEA 0%, #4DD0E1 100%);
        }
        .custom-course-input {
            margin-top: 1rem;
            display: none;
        }
        .custom-course-input.active {
            display: block;
        }
        .custom-course-input input {
            width: 100%;
            padding: 0.8rem 1rem;
            border: 2px solid var(--blue-medium);
            border-radius: 15px;
            font-size: 1rem;
            margin-bottom: 1rem;
        }
        .custom-course-input button {
            padding: 0.8rem 2rem;
            background: var(--blue-dark);
            color: white;
            border: none;
            border-radius: 15px;
            cursor: pointer;
            font-weight: 600;
        }
        .modal-close {
            position: absolute;
            top: 20px;
            right: 20px;
            background: none;
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
            color: var(--text-light);
        }
        .modal-close:hover {
            color: #ff4444;
        }

        /* 打印样式 */
        .print-only {
            display: none;
        }
        [url=home.php?mod=space&uid=945662]@media[/url] print {
            body { background: white; color: black; }
            .container, .decoration { display: none; }
            .print-only { display: block; padding: 15mm; }
            .print-header {
                text-align: center;
                margin-bottom: 20px;
                border-bottom: 3px solid #26C6DA;
                padding-bottom: 15px;
                position: relative;
            }
            .print-header h1 {
                font-size: 26pt;
                color: #26C6DA;
                margin-bottom: 8px;
                font-family: 'Comic Neue', 'Noto Sans SC', sans-serif;
            }
            .print-owner {
                font-size: 14pt;
                color: #4DD0E1;
                font-weight: bold;
                margin: 8px 0;
            }
            .schedule-table {
                width: 100%;
                border-collapse: collapse;
                margin-top: 10px;
                page-break-inside: avoid;
            }
            .schedule-table th, .schedule-table td {
                border: 2px solid #80DEEA;
                padding: 10px 5px;
                text-align: center;
            }
            .morning-slot {
                background: #FFF8E1 !important;
                color: #FF8F00 !important;
            }
            .afternoon-slot {
                background: #E1F5FE !important;
                color: #0288D1 !important;
            }
            .time-divider {
                background: #26C6DA !important;
                color: white !important;
            }
            .print-footer {
                margin-top: 15px;
                text-align: center;
                font-size: 11pt;
                color: #26C6DA;
                border-top: 2px solid #80DEEA;
                padding-top: 10px;
                font-weight: bold;
            }
        }

        /* 响应式 */
        @media (max-width: 1200px) {
            .main-content { grid-template-columns: 1fr; }
            .config-panel { max-width: 600px; margin: 0 auto; }
        }
        @media (max-width: 768px) {
            .container { padding: 1rem; }
            .header h1 { font-size: 2rem; }
            .day-selector { grid-template-columns: repeat(5, 1fr); } /* 保持5列 */
            .action-buttons { flex-direction: column; }
            .preview-header { flex-direction: column; gap: 1rem; align-items: stretch; }
            .time-switch { position: static; margin-bottom: 0.5rem; }
        }

        /* 通知动画 */
        @keyframes fadeInDown {
            from { opacity: 0; transform: translateY(-20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        @keyframes fadeInUp {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }

        /* 通知样式 */
        .notification {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background: linear-gradient(135deg, var(--blue-dark) 0%, var(--cyan-medium) 100%);
            color: white;
            padding: 1rem 1.5rem;
            border-radius: 15px;
            box-shadow: 0 5px 20px rgba(38,198,218,0.4);
            z-index: 9999;
            opacity: 0;
            transform: translateY(20px);
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        .notification.show {
            opacity: 1;
            transform: translateY(0);
            animation: pulse 1s ease-in-out;
        }
    </style>
</head>
<body>
    <!-- 装饰元素 -->
    <div class="decoration butterfly">&#127894;&#65039;</div>
    <div class="decoration butterfly">&#127894;&#65039;</div>
    <div class="decoration butterfly">&#127894;&#65039;</div>
    <div class="decoration butterfly">&#127894;&#65039;</div>
    <div class="decoration flower">&#127800;</div>
    <div class="decoration flower">&#127804;</div>
    <div class="decoration flower">&#128144;</div>
    <div class="decoration star">&#10024;</div>
    <div class="decoration star">&#127775;</div>
    <div class="decoration star">&#128171;</div>

    <div class="container">
        <div class="header">
            <h1 id="mainTitle">&#127894;&#65039; 课程表 &#127894;&#65039;</h1>
            <p class="subtitle">记录每日学习计划,让学习更有条理</p>
            <div class="title-edit">
                <input type="text" id="titleInput" placeholder="输入课程表标题">
                <button>保存标题</button>
            </div>
        </div>

        <div class="main-content">
            <div class="config-panel">
                <h2>课程设置</h2>
                
                <div class="class-count-control">
                    <button id="decreaseBtn">-</button>
                    <span class="class-count-display">上午 <span id="morningClassCount">4</span> 节 | 下午 <span id="afternoonClassCount">3</span> 节</span>
                    <button id="increaseBtn">+</button>
                </div>
                
                <div class="day-selector">
                    <button class="day-btn active" data-day="monday">周一</button>
                    <button class="day-btn" data-day="tuesday">周二</button>
                    <button class="day-btn" data-day="wednesday">周三</button>
                    <button class="day-btn" data-day="thursday">周四</button>
                    <button class="day-btn" data-day="friday">周五</button>
                    <!-- 移除周六周日按钮 -->
                </div>
                
                <div class="form-section">
                    <h3>上午课程</h3>
                    <div id="morningCourses">
                        <!-- 上午课程输入框将通过JS动态生成 -->
                    </div>
                </div>
                
                <div class="form-section">
                    <h3>下午课程</h3>
                    <div id="afternoonCourses">
                        <!-- 下午课程输入框将通过JS动态生成 -->
                    </div>
                </div>
                
                <div class="action-buttons">
                    <button class="btn btn-save">
                        <span>&#128190; 保存课程表</span>
                    </button>
                    <button class="btn btn-clear">
                        <span>&#129529; 清空当前天</span>
                    </button>
                </div>
            </div>
            
            <div class="preview-panel">
                <div class="preview-header">
                    <h2 id="previewTitle">课程表预览</h2>
                    <button class="btn-print">
                        <span>&#128424;&#65039; 打印课程表</span>
                    </button>
                </div>
                
                <table class="schedule-table" id="scheduleTable">
                    <!-- 课程表内容将通过JS动态生成 -->
                </table>
            </div>
        </div>
    </div>
    
    <!-- 打印专用区域 -->
    <div class="print-only">
        <div class="print-header">
            <h1 id="printMainTitle">&#127894;&#65039; 课程表 &#127894;&#65039;</h1>
            <div class="print-owner" id="printOwner">—— 学习计划 ——</div>
            <div id="printDate"></div>
        </div>
        <table class="schedule-table" id="printTable">
            <!-- 打印用课程表内容将通过JS动态生成 -->
        </table>
        <div class="print-footer">
            祝学习愉快,天天进步!&#128522;
        </div>
    </div>
    
    <!-- 课程选择弹窗 -->
    <div class="course-modal-overlay" id="courseModal">
        <div class="course-modal">
            <button class="modal-close">×</button>
            <h3 style="text-align: center; margin-bottom: 1.5rem; color: var(--blue-dark);">选择课程</h3>
            <div class="course-options">
                <div class="course-option">&#9999;&#65039; 语文</div>
                <div class="course-option">&#128290; 数学</div>
                <div class="course-option">&#128292; 英语</div>
                <div class="course-option">&#129342;&#127995; 体育</div>
                <div class="course-option">&#127932; 音乐</div>
                <div class="course-option">&#127912; 美术</div>
                <div class="course-option">&#9878; 道法</div>
                <div class="course-option rest-option">&#128366; 自习</div>
                <div class="course-option rest-option">&#128164; 午休</div>
                <div class="course-option">自定义...</div>
            </div>
            <div class="custom-course-input" id="customCourseInput">
                <input type="text" id="customCourseText" placeholder="输入课程名称">
                <button>添加</button>
            </div>
        </div>
    </div>
    
    <!-- 通知组件 -->
    <div class="notification" id="notification"></div>

    <script>
        // 全局变量
        let currentDay = 'monday';
        let currentInputId = '';
        // 新增:存储预览表格点击的位置信息
        let previewClickInfo = {
            day: '',        // 星期(monday/tuesday等)
            timeSlot: '',   // 时间段(morning/afternoon)
            index: -1       // 节次索引
        };
        // 修改:移除周六周日的数据结构
        let scheduleData = {
            monday: { morning: [], afternoon: [], morningSort: [1, 2, 3, 4], afternoonSort: [5, 6, 7] },
            tuesday: { morning: [], afternoon: [], morningSort: [1, 2, 3, 4], afternoonSort: [5, 6, 7] },
            wednesday: { morning: [], afternoon: [], morningSort: [1, 2, 3, 4], afternoonSort: [5, 6, 7] },
            thursday: { morning: [], afternoon: [], morningSort: [1, 2, 3, 4], afternoonSort: [5, 6, 7] },
            friday: { morning: [], afternoon: [], morningSort: [1, 2, 3, 4], afternoonSort: [5, 6, 7] }
            // 移除周六周日数据
        };
        
        // 初始化
        document.addEventListener('DOMContentLoaded', function() {
            // 加载保存的数据
            loadScheduleData();
            // 加载自定义标题
            loadTitle();
            
            // 渲染课程输入框
            renderClassInputs();
            
            // 渲染课程表
            renderSchedule();
            
            // 设置日期显示
            updatePrintDate();
            
            // 绑定日期选择事件
            document.querySelectorAll('.day-btn').forEach(btn => {
                btn.addEventListener('click', function() {
                    document.querySelectorAll('.day-btn').forEach(b => b.classList.remove('active'));
                    this.classList.add('active');
                    currentDay = this.dataset.day;
                    renderClassInputs();
                });
            });
            
            // 绑定时间段切换事件(事件委托)
            document.addEventListener('click', function(e) {
                if (e.target.classList.contains('time-switch-btn')) {
                    const time = e.target.dataset.time;
                    const classNum = parseInt(e.target.dataset.classnum);
                    const parent = e.target.parentElement;
                    
                    // 更新按钮状态
                    parent.querySelectorAll('.time-switch-btn').forEach(btn => {
                        btn.classList.remove('active');
                    });
                    e.target.classList.add('active');
                    
                    // 移动课程
                    moveClassBetweenTimeSlots(classNum, time);
                }
            });
            
            // 绑定预览表格点击事件
            document.getElementById('scheduleTable').addEventListener('click', function(e) {
                handlePreviewTableClick(e);
            });
        });
        
        // 处理预览表格点击事件
        function handlePreviewTableClick(e) {
            const td = e.target.closest('td');
            if (!td) return;
            
            // 跳过节次单元格和分割线
            if (td.classList.contains('morning-slot') || 
                td.classList.contains('afternoon-slot') || 
                td.classList.contains('time-divider')) {
                return;
            }
            
            const tr = td.parentElement;
            const rowIndex = Array.from(tr.parentElement.children).indexOf(tr);
            const cellIndex = Array.from(tr.children).indexOf(td);
            
            // 跳过表头和节次列
            if (cellIndex === 0) return;
            
            // 修改:只保留周一到周五
            const days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'];
            // 检查单元格索引是否有效(1-5对应周一到周五)
            if (cellIndex < 1 || cellIndex > 5) return;
            
            const targetDay = days[cellIndex - 1];
            
            // 确定时间段和节次索引
            const morningRows = scheduleData[currentDay].morningSort.length;
            let timeSlot, sectionIndex;
            
            if (rowIndex <= morningRows) {
                // 上午时间段
                timeSlot = 'morning';
                sectionIndex = rowIndex - 1; // 减1是因为表头占了一行
            } else if (rowIndex > morningRows + 1) { // +1是因为午休分割线占了一行
                // 下午时间段
                timeSlot = 'afternoon';
                sectionIndex = rowIndex - morningRows - 2; // 减2是因为表头+午休分割线
            } else {
                // 午休分割线
                return;
            }
            
            // 验证索引有效性
            if (sectionIndex < 0 || 
                (timeSlot === 'morning' && sectionIndex >= scheduleData[targetDay].morningSort.length) ||
                (timeSlot === 'afternoon' && sectionIndex >= scheduleData[targetDay].afternoonSort.length)) {
                return;
            }
            
            // 存储点击位置信息
            previewClickInfo = {
                day: targetDay,
                timeSlot: timeSlot,
                index: sectionIndex
            };
            
            // 打开选课弹窗
            openCourseModal('preview_' + targetDay + '_' + timeSlot + '_' + sectionIndex);
        }
        
        // 保存自定义标题
        function saveTitle() {
            const title = document.getElementById('titleInput').value.trim();
            if (title) {
                // 更新页面标题
                document.title = `&#127894;&#65039; ${title} &#127894;&#65039;`;
                
                // 更新主标题
                document.getElementById('mainTitle').textContent = `&#127894;&#65039; ${title} &#127894;&#65039;`;
                
                // 更新预览标题
                document.getElementById('previewTitle').textContent = `${title}预览`;
                
                // 更新打印标题
                document.getElementById('printMainTitle').textContent = `&#127894;&#65039; ${title} &#127894;&#65039;`;
                
                // 保存到本地存储
                localStorage.setItem('scheduleTitle', title);
                
                showNotification(`标题已设置为:${title}`);
            } else {
                // 恢复默认标题
                document.title = '&#127894;&#65039; 课程表 &#127894;&#65039;';
                document.getElementById('mainTitle').textContent = '&#127894;&#65039; 课程表 &#127894;&#65039;';
                document.getElementById('previewTitle').textContent = '课程表预览';
                document.getElementById('printMainTitle').textContent = '&#127894;&#65039; 课程表 &#127894;&#65039;';
                
                // 清除本地存储
                localStorage.removeItem('scheduleTitle');
                
                showNotification('标题已恢复为默认值');
            }
        }
        
        // 加载自定义标题
        function loadTitle() {
            const title = localStorage.getItem('scheduleTitle');
            if (title) {
                document.title = `&#127894;&#65039; ${title} &#127894;&#65039;`;
                document.getElementById('mainTitle').textContent = `&#127894;&#65039; ${title} &#127894;&#65039;`;
                document.getElementById('previewTitle').textContent = `${title}预览`;
                document.getElementById('printMainTitle').textContent = `&#127894;&#65039; ${title} &#127894;&#65039;`;
                document.getElementById('titleInput').value = title;
            }
        }
        
        // 更改课程节数
        function changeClassCount(delta) {
            const morningCount = scheduleData[currentDay].morningSort.length;
            const afternoonCount = scheduleData[currentDay].afternoonSort.length;
            
            // 限制课程节数在1-10之间
            if (delta > 0) {
                // 增加课程节数
                const newClassNum = morningCount + afternoonCount + 1;
                if (morningCount <= afternoonCount && morningCount < 10) {
                    scheduleData[currentDay].morningSort.push(newClassNum);
                } else if (afternoonCount < 10) {
                    scheduleData[currentDay].afternoonSort.push(newClassNum);
                }
            } else {
                // 减少课程节数
                if (morningCount > afternoonCount && morningCount > 1) {
                    scheduleData[currentDay].morningSort.pop();
                } else if (afternoonCount > 1) {
                    scheduleData[currentDay].afternoonSort.pop();
                }
            }
            
            // 更新所有天的节数配置(保持一致)
            Object.keys(scheduleData).forEach(day => {
                scheduleData[day].morningSort = [...scheduleData[currentDay].morningSort];
                scheduleData[day].afternoonSort = [...scheduleData[currentDay].afternoonSort];
            });
            
            // 更新显示并保存
            updateClassCountDisplay();
            renderClassInputs();
            renderSchedule();
            saveScheduleData();
            
            showNotification(`课程节数已调整:上午${scheduleData[currentDay].morningSort.length}节,下午${scheduleData[currentDay].afternoonSort.length}节`);
        }
        
        // 更新课程节数显示
        function updateClassCountDisplay() {
            document.getElementById('morningClassCount').textContent = scheduleData[currentDay].morningSort.length;
            document.getElementById('afternoonClassCount').textContent = scheduleData[currentDay].afternoonSort.length;
        }
        
        // 渲染课程输入框
        function renderClassInputs() {
            const morningContainer = document.getElementById('morningCourses');
            const afternoonContainer = document.getElementById('afternoonCourses');
            
            morningContainer.innerHTML = '';
            afternoonContainer.innerHTML = '';
            
            // 渲染上午课程输入框(上午从第1节开始编号)
            scheduleData[currentDay].morningSort.forEach((classNum, index) => {
                morningContainer.innerHTML += `
                    <div class="course-input">
                        <label>上午第${index + 1}节 &#128214;</label>
                        <div class="time-switch">
                            <button class="time-switch-btn active" data-time="morning" data-classnum="${classNum}">上午</button>
                            <button class="time-switch-btn" data-time="afternoon" data-classnum="${classNum}">下午</button>
                        </div>
                        <input type="text" id="morning${index}" list="courseList" 
                               placeholder="例如:语文" value="${scheduleData[currentDay].morning[index] || ''}"
                              >
                    </div>
                `;
            });
            
            // 渲染下午课程输入框(下午从第1节开始编号)
            scheduleData[currentDay].afternoonSort.forEach((classNum, index) => {
                afternoonContainer.innerHTML += `
                    <div class="course-input">
                        <label>下午第${index + 1}节 &#127769;</label>
                        <div class="time-switch">
                            <button class="time-switch-btn" data-time="morning" data-classnum="${classNum}">上午</button>
                            <button class="time-switch-btn active" data-time="afternoon" data-classnum="${classNum}">下午</button>
                        </div>
                        <input type="text" id="afternoon${index}" list="courseList" 
                               placeholder="例如:数学" value="${scheduleData[currentDay].afternoon[index] || ''}"
                              >
                    </div>
                `;
            });
        }
        
        // 渲染课程表
        function renderSchedule() {
            const table = document.getElementById('scheduleTable');
            const printTable = document.getElementById('printTable');
            
            // 修改:表头只保留周一到周五
            let tableHtml = `
                <tr>
                    <th>节次/星期</th>
                    <th>周一</th>
                    <th>周二</th>
                    <th>周三</th>
                    <th>周四</th>
                    <th>周五</th>
                    <!-- 移除周六周日列 -->
                </tr>
            `;
            
            // 生成上午课程行(从第1节开始)
            // 修改:只遍历周一到周五
            const days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'];
            scheduleData[currentDay].morningSort.forEach((classNum, index) => {
                tableHtml += '<tr>';
                // 上午节次单元格(只显示第X节)
                tableHtml += `<td class="morning-slot"><strong>第${index + 1}节</strong></td>`;
                
                // 遍历星期
                days.forEach(day => {
                    // 找到对应的索引
                    const idx = scheduleData[day].morningSort.indexOf(classNum);
                    // 获取课程名称
                    const course = idx !== -1 ? scheduleData[day].morning[idx] : '';
                    
                    // 根据课程内容设置单元格样式
                    if (course === '休息' || course === '午休') {
                        tableHtml += `<td class="rest-cell">${course}</td>`;
                    } else if (course) {
                        tableHtml += `<td class="course-cell">${course}</td>`;
                    } else {
                        tableHtml += `<td class="empty-cell">--</td>`;
                    }
                });
                tableHtml += '</tr>';
            });
            
            // 添加午休分割线
            // 修改:分割线列数改为6(节次列+5个星期列)
            tableHtml += `
                <tr>
                    <td class="time-divider" colspan="6">—— 午休分割线 ——</td>
                </tr>
            `;
            
            // 生成下午课程行(从第1节开始)
            scheduleData[currentDay].afternoonSort.forEach((classNum, index) => {
                tableHtml += '<tr>';
                // 下午节次单元格(只显示第X节)
                tableHtml += `<td class="afternoon-slot"><strong>第${index + 1}节</strong></td>`;
                
                // 遍历星期
                days.forEach(day => {
                    // 找到对应的索引
                    const idx = scheduleData[day].afternoonSort.indexOf(classNum);
                    // 获取课程名称
                    const course = idx !== -1 ? scheduleData[day].afternoon[idx] : '';
                    
                    // 根据课程内容设置单元格样式
                    if (course === '休息' || course === '午休') {
                        tableHtml += `<td class="rest-cell">${course}</td>`;
                    } else if (course) {
                        tableHtml += `<td class="course-cell">${course}</td>`;
                    } else {
                        tableHtml += `<td class="empty-cell">--</td>`;
                    }
                });
                tableHtml += '</tr>';
            });
            
            // 更新表格内容
            table.innerHTML = tableHtml;
            printTable.innerHTML = tableHtml;
        }
        
        // 在上午和下午之间移动课程
        function moveClassBetweenTimeSlots(classNum, targetTime) {
            // 从原时间段移除
            let sourceTime = targetTime === 'morning' ? 'afternoon' : 'morning';
            let sourceIndex = scheduleData[currentDay][`${sourceTime}Sort`].indexOf(classNum);
            
            if (sourceIndex !== -1) {
                // 获取课程内容
                let courseContent = scheduleData[currentDay][sourceTime][sourceIndex];
                
                // 从源数组移除
                scheduleData[currentDay][`${sourceTime}Sort`].splice(sourceIndex, 1);
                scheduleData[currentDay][sourceTime].splice(sourceIndex, 1);
                
                // 添加到目标数组
                scheduleData[currentDay][`${targetTime}Sort`].push(classNum);
                scheduleData[currentDay][targetTime].push(courseContent);
                
                // 对目标数组排序
                scheduleData[currentDay][`${targetTime}Sort`].sort((a, b) => a - b);
                
                // 更新所有天的节数配置(保持一致)
                Object.keys(scheduleData).forEach(day => {
                    scheduleData[day].morningSort = [...scheduleData[currentDay].morningSort];
                    scheduleData[day].afternoonSort = [...scheduleData[currentDay].afternoonSort];
                });
                
                // 重新渲染
                updateClassCountDisplay();
                renderClassInputs();
                renderSchedule();
                saveScheduleData();
                
                showNotification(`课程已移动到${targetTime === 'morning' ? '上午' : '下午'}`);
            }
        }
        
        // 打开课程选择弹窗
        function openCourseModal(inputId) {
            currentInputId = inputId;
            document.getElementById('courseModal').classList.add('active');
            document.getElementById('customCourseInput').classList.remove('active');
            document.getElementById('customCourseText').value = '';
        }
        
        // 关闭课程选择弹窗
        function closeCourseModal() {
            document.getElementById('courseModal').classList.remove('active');
            // 重置预览点击信息
            previewClickInfo = { day: '', timeSlot: '', index: -1 };
        }
        
        // 选择课程
        function selectCourse(courseName) {
            if (currentInputId) {
                // 判断是配置面板输入还是预览表格点击
                if (currentInputId.startsWith('preview_')) {
                    // 预览表格点击更新
                    if (previewClickInfo.day && previewClickInfo.timeSlot && previewClickInfo.index >= 0) {
                        // 更新对应位置的课程数据
                        scheduleData[previewClickInfo.day][previewClickInfo.timeSlot][previewClickInfo.index] = courseName;
                        
                        // 重新渲染课程表
                        renderSchedule();
                        
                        // 如果当前编辑的就是这个天,同步更新输入框
                        if (previewClickInfo.day === currentDay) {
                            renderClassInputs();
                        }
                        
                        // 保存数据
                        saveScheduleData();
                        
                        showNotification(`${previewClickInfo.day === currentDay ? '本周' : getDayName(previewClickInfo.day)}${previewClickInfo.timeSlot === 'morning' ? '上午' : '下午'}第${previewClickInfo.index + 1}节已设置为:${courseName}`);
                    }
                } else {
                    // 配置面板输入更新
                    const input = document.getElementById(currentInputId);
                    if (input) {
                        input.value = courseName;
                        realTimeUpdateSchedule();
                    }
                }
            }
            closeCourseModal();
        }
        
        // 获取星期名称
        function getDayName(dayKey) {
            const dayMap = {
                'monday': '周一',
                'tuesday': '周二',
                'wednesday': '周三',
                'thursday': '周四',
                'friday': '周五'
                // 移除周六周日映射
            };
            return dayMap[dayKey] || dayKey;
        }
        
        // 显示自定义课程输入框
        function showCustomCourseInput() {
            document.getElementById('customCourseInput').classList.add('active');
            document.getElementById('customCourseText').focus();
        }
        
        // 添加自定义课程
        function addCustomCourse() {
            const courseName = document.getElementById('customCourseText').value.trim();
            if (courseName) {
                selectCourse(courseName);
            }
        }
        
        // 实时更新课程表
        function realTimeUpdateSchedule() {
            // 获取当前输入的时间段和索引
            const isMorning = currentInputId.startsWith('morning');
            const index = parseInt(currentInputId.replace(isMorning ? 'morning' : 'afternoon', ''));
            
            // 更新数据
            if (isMorning) {
                scheduleData[currentDay].morning[index] = document.getElementById(currentInputId).value.trim();
            } else {
                scheduleData[currentDay].afternoon[index] = document.getElementById(currentInputId).value.trim();
            }
            
            // 重新渲染课程表
            renderSchedule();
        }
        
        // 保存课程表
        function saveSchedule() {
            // 收集所有输入框的值
            document.querySelectorAll('#morningCourses input, #afternoonCourses input').forEach(input => {
                const isMorning = input.id.startsWith('morning');
                const index = parseInt(input.id.replace(isMorning ? 'morning' : 'afternoon', ''));
                
                if (isMorning) {
                    scheduleData[currentDay].morning[index] = input.value.trim();
                } else {
                    scheduleData[currentDay].afternoon[index] = input.value.trim();
                }
            });
            
            // 保存数据
            saveScheduleData();
            
            // 更新课程表
            renderSchedule();
            
            // 显示通知
            showNotification('课程表已保存成功!');
        }
        
        // 清空当前天的课程
        function clearSchedule() {
            if (confirm('确定要清空当前天的所有课程吗?')) {
                scheduleData[currentDay].morning = Array(scheduleData[currentDay].morningSort.length).fill('');
                scheduleData[currentDay].afternoon = Array(scheduleData[currentDay].afternoonSort.length).fill('');
                
                // 保存数据
                saveScheduleData();
                
                // 重新渲染
                renderClassInputs();
                renderSchedule();
                
                // 显示通知
                showNotification('当前天的课程已清空');
            }
        }
        
        // 保存课程表数据到本地存储
        function saveScheduleData() {
            localStorage.setItem('scheduleData', JSON.stringify(scheduleData));
        }
        
        // 从本地存储加载课程表数据
        function loadScheduleData() {
            const savedData = localStorage.getItem('scheduleData');
            if (savedData) {
                // 加载数据时过滤掉周六周日(如果有)
                const loadedData = JSON.parse(savedData);
                scheduleData = {
                    monday: loadedData.monday || { morning: [], afternoon: [], morningSort: [1,2,3,4], afternoonSort: [5,6,7] },
                    tuesday: loadedData.tuesday || { morning: [], afternoon: [], morningSort: [1,2,3,4], afternoonSort: [5,6,7] },
                    wednesday: loadedData.wednesday || { morning: [], afternoon: [], morningSort: [1,2,3,4], afternoonSort: [5,6,7] },
                    thursday: loadedData.thursday || { morning: [], afternoon: [], morningSort: [1,2,3,4], afternoonSort: [5,6,7] },
                    friday: loadedData.friday || { morning: [], afternoon: [], morningSort: [1,2,3,4], afternoonSort: [5,6,7] }
                };
            }
            updateClassCountDisplay();
        }
        
        // 更新打印日期
        function updatePrintDate() {
            const now = new Date();
            const options = { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' };
            document.getElementById('printDate').textContent = `更新于:${now.toLocaleDateString('zh-CN', options)}`;
        }
        
        // 显示通知
        function showNotification(message) {
            const notification = document.getElementById('notification');
            notification.textContent = message;
            notification.classList.add('show');
            
            setTimeout(() => {
                notification.classList.remove('show');
            }, 3000);
        }
    </script>
</body>
</html>
小学课程表.rar (9.43 KB, 下载次数: 179)




免费评分

参与人数 3吾爱币 +9 热心值 +3 收起 理由
blankTest001 + 1 + 1 热心回复!
liuzhijie0329 + 1 + 1 我很赞同!
hrh123 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

沙发
redhatelnet 发表于 2025-12-18 16:41
不错的工具
3#
j542936 发表于 2025-12-18 16:41
4#
keng1717 发表于 2025-12-18 16:57
5#
xyml828 发表于 2025-12-18 17:02
正需要,谢谢分享。
6#
hcg777 发表于 2025-12-18 17:03
做得太好了,感谢分享
7#
badboysky 发表于 2025-12-18 17:05
又一个思路的版本?一会我发下之前我的修改版,哈哈,你的皮肤适合男孩版!!
8#
asunkai 发表于 2025-12-18 17:12
谢谢分享。
9#
asunkai 发表于 2025-12-18 17:22
本帖最后由 asunkai 于 2025-12-18 17:27 编辑

已经弄好,谢谢
10#
xiaowua 发表于 2025-12-18 20:31
这个好,可以修改名字了
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-11-8 10:17

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表