
教室アプリ21:給食管理パネル

ボタン一つで「分表示」と「秒表示」を切り替えられる、現場密着型の給食管理タイマー。食事中は文字を削ぎ落とした「分表示」で徳性を育み、片付け時は「秒表示」で機敏な行動を促せます。画像の拡大提示機能も備え、献立表などを美しく提示可能。
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>教室アプリ:給食管理パネル</title>
<style>
body, html {
margin: 0; padding: 0; height: 100%; overflow: hidden;
font-family: 'Helvetica', 'Arial', sans-serif;
background-color: #fff9e6;
}
.container { display: flex; width: 100%; height: 100vh; }
.timer-side {
flex: 1; border-right: 5px solid #ffcc00; background-color: #fff9e6;
display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative;
}
.image-side {
flex: 1; position: relative; overflow: hidden; background-color: #fafafa;
display: flex; align-items: center; justify-content: center;
}
.zoom-content { transition: transform 0.1s ease-out; cursor: move; user-select: none; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.timer-ui { text-align: center; width: 95%; }
h1 {
font-size: 85px;
border-bottom: 6px solid #ffcc00;
margin: 0 0 15px 0;
padding-bottom: 10px;
color: #222;
letter-spacing: 5px;
}
/* 表示モードによってサイズが自動調整されるよう調整 */
#timer { font-size: 210px; font-weight: bold; font-variant-numeric: tabular-nums; line-height: 0.8; color: #333; }
#timer span { font-size: 0.4em; margin-left: 5px; }
#message { font-size: 45px; font-weight: bold; min-height: 80px; margin-top: 20px; }
.ui-overlay { position: absolute; bottom: 15px; width: 95%; left: 2.5%; z-index: 1000; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.controls-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
button, .file-label { font-size: 14px; padding: 6px 15px; cursor: pointer; border-radius: 30px; border: none; background: #4caf50; color: white; font-weight: bold; transition: 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.file-label { background-color: #2196F3 !important; }
button.stop { background-color: #f44336; }
.config-btn { background-color: #ff9800; }
.toggle-display-btn { background-color: #009688; } /* 切替ボタンの色 */
.reset-btn { background-color: #9e9e9e; }
#fileInput { display: none; }
#configModal {
display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
background: white; padding: 25px; border-radius: 20px; border: 4px solid #ffcc00;
z-index: 2000; width: 620px; max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.config-item { margin-bottom: 10px; border-bottom: 2px solid #fff9e6; padding: 10px; border-radius: 8px; background: #fdfdfd; }
.config-header { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; border-bottom: 1px solid #eee; padding-bottom: 5px; }
.config-item label { display: grid; grid-template-columns: 90px 1fr; align-items: center; font-size: 12px; margin-bottom: 2px; }
.time-setting { display: flex; gap: 8px; align-items: center; }
.time-setting input { width: 50px !important; }
.config-item input { width: 95%; padding: 3px; border-radius: 4px; border: 1px solid #ccc; }
.use-check { width: 22px !important; height: 22px !important; cursor: pointer; }
#displayImage { max-width: 95%; max-height: 95%; object-fit: contain; pointer-events: none; border: 1px solid #ddd; display: none; }
.blue-text { color: #0000ff; }
.orange-text { color: #ff6600; }
.red-text { color: #ff0000; }
.green-text { color: #2e7d32; }
.blink { animation: blink-animation 0.4s steps(5, start) infinite; }
@keyframes blink-animation { to { visibility: hidden; } }
</style>
</head>
<body>
<div class="container">
<div class="pane timer-side">
<div class="timer-ui">
<h1 id="titleDisplay">準備中</h1>
<div id="timer">00:00</div>
<div id="message"></div>
</div>
<div class="ui-overlay">
<div class="controls-row">
<button id="startStopBtn" onclick="toggleTimer()">スタート</button>
<button onclick="skipTime(-10)">-10秒</button>
<button onclick="skipTime(10)">+10秒</button>
<button class="config-btn" onclick="toggleConfig()">設定</button>
<button class="toggle-display-btn" onclick="toggleDisplayMode()">表示切替</button>
<button class="reset-btn" onclick="resetTimer()">リセット</button>
<label class="file-label" for="fileInput">画像</label>
<input type="file" id="fileInput" accept="image/*">
</div>
</div>
</div>
<div class="pane image-side">
<div class="zoom-content" id="imageZoom">
<img id="displayImage" src="" alt="画像">
<p id="imgPlaceholder" style="color:#999; font-size: 20px;">画像を選択してください</p>
</div>
</div>
</div>
<div id="configModal">
<h2 style="margin-top:0; border-bottom: 2px solid #ffcc00; text-align: center;">詳細設定(項目選択式)</h2>
<div id="configList"></div>
<button onclick="saveAndCloseConfig()" style="width: 100%; background: #4caf50; margin-top: 15px; color:white; border-radius:10px; padding:12px; font-weight:bold; border:none; cursor:pointer; font-size:18px;">設定を保存して閉じる</button>
</div>
<script>
const defaultPhases = [
{ use: true, name: 'いただきます', time: 0, msg: '感謝していただきましょう', color: 'green-text', countdown: false },
{ use: true, name: 'もぐもぐ', time: 180, msg: 'まずは静かに食べましょう', color: 'green-text', countdown: false },
{ use: true, name: 'もりもり', time: 300, msg: '増やそう', color: 'orange-text', countdown: false },
{ use: true, name: '牛乳①', time: 600, msg: '牛乳を一口飲みましょう',color: 'blue-text', countdown: false },
{ use: true, name: '片付け①', time: 720, msg: '牛乳パックを片付けましょう', color: 'blue-text', countdown: false },
{ use: true, name: 'おかわり', time: 900, msg: 'おかわりチャレンジ!', color: 'orange-text', countdown: true },
{ use: true, name: '食器整理', time: 1080, msg: 'お皿を重ねましょう', color: 'blue-text', countdown: false },
{ use: true, name: '片付け②', time: 1140, msg: '食器をまとめましょう', color: 'blue-text', countdown: true },
{ use: true, name: 'ごちそうさま', time: 1200, msg: '心を込めて、ごちそうさま', color: 'red-text', countdown: true },
{ use: false, name: '清掃準備', time: 1260, msg: '机を下げましょう', color: 'red-text', countdown: false }
];
let phases = JSON.parse(localStorage.getItem('kyushokuConfig_v11')) || defaultPhases;
let seconds = 0;
let timerId = null;
let isRunning = false;
let hasStarted = false;
let displayMode = 'minute-second'; // 'minute-second' か 'minute-only'
function renderConfig() {
const list = document.getElementById('configList');
list.innerHTML = '';
phases.forEach((p, i) => {
const min = Math.floor(p.time / 60);
const sec = p.time % 60;
list.innerHTML += `
<div class="config-item" style="opacity: ${p.use ? '1' : '0.6'}">
<div class="config-header">
<input type="checkbox" class="use-check" id="use-${i}" ${p.use ? 'checked' : ''}>
<strong>項目 ${i+1} を使用する</strong>
</div>
<label>項目名: <input type="text" id="name-${i}" value="${p.name}"></label>
<label>開始時間:
<div class="time-setting">
<input type="number" id="min-${i}" value="${min}"> 分
<input type="number" id="sec-${i}" value="${sec}"> 秒
</div>
</label>
<label>メッセージ: <input type="text" id="msg-${i}" value="${p.msg}"></label>
<label>予告点滅: <input type="checkbox" id="cd-${i}" ${p.countdown ? 'checked' : ''}></label>
</div>
`;
});
}
function saveAndCloseConfig() {
phases = phases.map((p, i) => {
const m = parseInt(document.getElementById(`min-${i}`).value) || 0;
const s = parseInt(document.getElementById(`sec-${i}`).value) || 0;
return {
use: document.getElementById(`use-${i}`).checked,
name: document.getElementById(`name-${i}`).value,
time: (m * 60) + s,
msg: document.getElementById(`msg-${i}`).value,
color: p.color,
countdown: document.getElementById(`cd-${i}`).checked
};
});
localStorage.setItem('kyushokuConfig_v11', JSON.stringify(phases));
toggleConfig();
updateDisplay();
}
function toggleConfig() {
const m = document.getElementById('configModal');
if (m.style.display !== 'block') { renderConfig(); m.style.display = 'block'; }
else { m.style.display = 'none'; }
}
// 表示モードを切り替える関数
function toggleDisplayMode() {
displayMode = (displayMode === 'minute-second') ? 'minute-only' : 'minute-second';
updateDisplay();
}
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
function playFanfare() {
if (audioCtx.state === 'suspended') audioCtx.resume();
const notes = [523.25, 659.25, 783.99, 1046.50];
notes.forEach((freq, i) => {
const osc = audioCtx.createOscillator();
const gain = audioCtx.createGain();
osc.type = 'triangle';
osc.frequency.setValueAtTime(freq, audioCtx.currentTime + i * 0.15);
gain.gain.setValueAtTime(0.1, audioCtx.currentTime + i * 0.15);
gain.gain.exponentialRampToValueAtTime(0.001, audioCtx.currentTime + i * 0.15 + 0.4);
osc.connect(gain); gain.connect(audioCtx.destination);
osc.start(audioCtx.currentTime + i * 0.15); osc.stop(audioCtx.currentTime + i * 0.15 + 0.4);
});
}
function updateDisplay() {
const timerElement = document.getElementById('timer');
const msg = document.getElementById('message');
const title = document.getElementById('titleDisplay');
let min = Math.floor(seconds / 60);
let sec = seconds % 60;
// モードに応じて表示内容を分岐
if (displayMode === 'minute-second') {
timerElement.style.fontSize = "210px";
timerElement.innerText = (min < 10 ? "0" + min : min) + ":" + (sec < 10 ? "0" + sec : sec);
} else {
timerElement.style.fontSize = "240px";
timerElement.innerHTML = min + "<span>分</span>";
}
if (!hasStarted) {
title.innerText = "準備中";
msg.innerText = "";
return;
}
const activePhases = phases.filter(p => p.use).sort((a, b) => a.time - b.time);
let currentIdx = -1;
for (let i = 0; i < activePhases.length; i++) {
if (seconds >= activePhases[i].time) currentIdx = i;
}
timerElement.style.color = "#333";
msg.classList.remove('blink');
if (currentIdx !== -1) {
const current = activePhases[currentIdx];
title.innerText = current.name;
msg.innerText = current.msg;
msg.className = current.color;
const next = activePhases[currentIdx + 1];
if (next && next.countdown) {
const timeToNext = next.time - seconds;
if (timeToNext <= 10 && timeToNext > 0) {
msg.innerText = `${next.name}まで ${timeToNext}秒`;
msg.className = "red-text blink";
timerElement.style.color = "#ff0000";
}
}
if (current.countdown && seconds === current.time && seconds !== 0) { playFanfare(); }
if (currentIdx === activePhases.length - 1 && seconds >= current.time) {
timerElement.style.color = "#ff0000";
}
} else if (activePhases.length > 0) {
title.innerText = "開始待機";
msg.innerText = activePhases[0].name + "までお待ちください";
}
}
function toggleTimer() {
if (audioCtx.state === 'suspended') audioCtx.resume();
if (isRunning) { stopTimer(); } else { hasStarted = true; startTimer(); }
}
function startTimer() { if (!isRunning) { timerId = setInterval(() => { seconds++; updateDisplay(); }, 1000); document.getElementById('startStopBtn').innerText = "一時停止"; isRunning = true; updateDisplay(); } }
function stopTimer() { clearInterval(timerId); document.getElementById('startStopBtn').innerText = "再開"; isRunning = false; }
function resetTimer() { stopTimer(); seconds = 0; hasStarted = false; updateDisplay(); }
function skipTime(addSec) { seconds += addSec; if(seconds < 0) seconds = 0; updateDisplay(); }
const fileInput = document.getElementById('fileInput');
const displayImage = document.getElementById('displayImage');
fileInput.addEventListener('change', e => {
const file = e.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = ev => { displayImage.src = ev.target.result; displayImage.style.display = 'block'; document.getElementById('imgPlaceholder').style.display = 'none'; };
reader.readAsDataURL(file);
}
});
let imgState = { scale: 1, posX: 0, posY: 0 };
const container = document.getElementById('imageZoom');
container.parentElement.addEventListener('wheel', e => { e.preventDefault(); imgState.scale = Math.min(Math.max(0.1, imgState.scale * (e.deltaY > 0 ? 0.9 : 1.1)), 10); container.style.transform = `translate(${imgState.posX}px, ${imgState.posY}px) scale(${imgState.scale})`; });
let isDragging = false, startX, startY;
container.parentElement.addEventListener('mousedown', e => { if (e.button === 0) { isDragging = true; startX = e.clientX - imgState.posX; startY = e.clientY - imgState.posY; } });
window.addEventListener('mousemove', e => { if (isDragging) { imgState.posX = e.clientX - startX; imgState.posY = e.clientY - startY; container.style.transform = `translate(${imgState.posX}px, ${imgState.posY}px) scale(${imgState.scale})`; } });
window.addEventListener('mouseup', () => isDragging = false);
updateDisplay();
</script>
</body>
</html>