
教室アプリ03:時間割

右下のボタンで表記を切り替え、日付や教科をタップして選択するだけ。自由入力も可能で、操作は極めて直感的。教師の説明を最小限に抑え、子供が自ら明日の準備を見通せる『自律の道具』として設計しました。
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>教室アプリ:時間割</title>
<style>
body { font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif; background: #ffffff ; color: #333 ; text-align: center; padding: 20px; }
.container { max-width: 1000px; margin: auto; }
.control-panel { margin-bottom: 20px; text-align: right; }
.toggle-btn {
padding: 12px 24px; font-size: 1.5rem; cursor: pointer;
background: #2c3e50 ; color: white; border: none; border-radius: 8px;
font-weight: bold; box-shadow: 0 4px 0 #1a252f ;
}
.toggle-btn:active { transform: translateY(2px); box-shadow: none; }
.date-selection {
display: flex; justify-content: center; align-items: center;
gap: 10px; margin-bottom: 40px; border-bottom: 5px solid #2c3e50 ; padding-bottom: 10px;
}
select.date-part {
font-size: 4rem; font-weight: 900; color: #2c3e50 ;
border: none; background-color: transparent; outline: none;
appearance: none; cursor: pointer; text-align: center;
}
.unit { font-size: 2rem; font-weight: 900; color: #2c3e50 ; margin-right: 15px; }
.slot { display: flex; align-items: center; justify-content: center; padding: 8px 0; border-bottom: 4px solid #f0f0f0 ; min-height: 100px; }
.period-input, .subject-select, .custom-input {
font-size: 4rem; font-weight: 900; color: #2c3e50 ;
border: none; background-color: transparent; outline: none;
appearance: none; text-align: center;
}
.period-input { width: 80px; margin-right: 20px; color: #bdc3c7 ; }
.subject-select { width: 550px; cursor: pointer; }
.custom-input {
width: 550px; border-bottom: 3px dashed #e74c3c ; color: #e74c3c ;
display: none;
}
option { font-size: 1.5rem; }
</style>
</head>
<body>
<div class="container">
<div class="control-panel">
<button class="toggle-btn" onclick="toggleLanguage()">ひらがな ⇔ 漢字</button>
</div>
<div class="date-selection">
<select id="month" class="date-part"></select><span class="unit">月</span>
<select id="day" class="date-part"></select><span class="unit">日</span>
<select id="weekday" class="date-part"></select>
</div>
<div id="schedule-container"></div>
</div>
<script>
//
const subjectData = [
{kanji: "国語", hira: "こくご"}, {kanji: "社会", hira: "しゃかい"},
{kanji: "算数", hira: "さんすう"}, {kanji: "理科", hira: "りか"},
{kanji: "生活", hira: "せいかつ"}, {kanji: "音楽", hira: "おんがく"},
{kanji: "図工", hira: "ずこう"}, {kanji: "家庭", hira: "かてい"},
{kanji: "体育", hira: "たいいく"}, {kanji: "道徳", hira: "どうとく"},
{kanji: "外国語", hira: "がいこくご"}, {kanji: "総合", hira: "そうごう"},
{kanji: "学活", ira: "がっかつ"}, {kanji: "行事", hira: "ぎょうじ"},
{kanji: "入力", hira: "にゅうりょく"}, //
{kanji: "自習", hira: "じしゅう"},
{kanji: "なし", hira: "なし"},
{kanji: "-", hira: "-"}
];
let isHiragana = false;
const weekdaysKanji = ["(日)", "(月)", "(火)", "(水)", "(木)", "(金)", "(土)"];
const weekdaysHira = ["(にち)", "(げつ)", "(か)", "(すい)", "(もく)", "(きん)", "(ど)"];
function init() {
const m = document.getElementById('month');
const d = document.getElementById('day');
for(let i=1;i<=12;i++) m.add(new Option(i, i));
for(let i=1;i<=31;i++) d.add(new Option(i, i));
const now = new Date();
m.value = now.getMonth() + 1;
d.value = now.getDate();
updateWeekday();
renderSchedule();
}
function updateWeekday() {
const wSel = document.getElementById('weekday');
const currentIdx = new Date().getDay();
wSel.innerHTML = "";
const list = isHiragana ? weekdaysHira : weekdaysKanji;
list.forEach(w => wSel.add(new Option(w, w)));
wSel.value = list[currentIdx];
}
function renderSchedule() {
const container = document.getElementById('schedule-container');
for (let i = 1; i <= 6; i++) {
const div = document.createElement('div');
div.className = 'slot';
div.innerHTML = `
<input type="text" class="period-input" value="${i}">
<select class="subject-select" onchange="handleSelectChange(this)" data-index="${i-1}">
</select>
<input type="text" class="custom-input" placeholder="..." ondblclick="resetSelect(this)">
`;
container.appendChild(div);
}
updateAllSelects();
}
function handleSelectChange(select) {
const customInput = select.nextElementSibling;
const val = select.value;
if (val === "入力" || val === "にゅうりょく") {
select.style.display = "none";
customInput.style.display = "block";
customInput.focus();
}
}
// 入力ボックスをダブルクリックするとセレクトボックスに戻る機能を追加
function resetSelect(input) {
const select = input.previousElementSibling;
input.value = "";
input.style.display = "none";
select.style.display = "block";
select.value = isHiragana ? "-" : "-";
}
function updateAllSelects() {
const selects = document.querySelectorAll('.subject-select');
selects.forEach((select, idx) => {
const currentVal = select.value;
const currentObj = subjectData.find(s => s.kanji === currentVal || s.hira === currentVal);
select.innerHTML = "";
subjectData.forEach(sub => {
const text = isHiragana ? sub.hira : sub.kanji;
const opt = new Option(text, text);
if(currentObj && (sub.kanji === currentObj.kanji)) opt.selected = true;
if(!currentVal) {
if(idx >= 4 && sub.kanji === "なし") opt.selected = true;
if(idx < 4 && sub.kanji === "-") opt.selected = true;
}
select.add(opt);
});
});
}
function toggleLanguage() {
isHiragana = !isHiragana;
updateWeekday();
updateAllSelects();
}
init();
</script>
</body>
</html>