Files
mincojs/color.html
2025-10-30 20:14:04 +09:00

113 lines
2.5 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>MincoJS — カラープレイグラウンド</title>
<style>
body {
font-family: monospace;
background: #fdfaf7;
color: #333;
margin: 20px;
transition: background 0.5s ease;
}
textarea {
width: 100%;
height: 120px;
font-family: monospace;
}
pre {
width: 100%;
height: 180px;
border: 1px solid #aaa;
background: #fff;
overflow-y: auto;
padding: 8px;
white-space: pre-wrap;
}
#error {
border: 1px solid #c33;
background: #fee;
color: #900;
padding: 8px;
white-space: pre-wrap;
min-height: 1.5em;
}
#inputField {
width: 100%;
padding: 4px;
font-family: monospace;
border: 1px solid #aaa;
}
button { margin: 4px; }
footer {
margin-top: 2em;
font-size: 0.9em;
color: #666;
border-top: 1px solid #ccc;
padding-top: 0.5em;
}
</style>
</head>
<body>
<h2>🎨 MincoJSサンプルカラープレイグラウンド</h2>
<p>入力欄に「red」「skyblue」「#ffcc00」などを書いて、実行してみようにゃ。</p>
<textarea id="code">// 入力欄の色を背景に反映するサンプルです
let color = input();
print("🎨 色を変えるにゃ → " + color);
document.body.style.background = color;
print("🌈 わぁ、世界が " + color + " に染まった!");
</textarea><br>
<label for="inputField">入力欄:</label>
<input id="inputField" type="text" value="skyblue" placeholder="好きな色の名前か #コード を入力してにゃ"><br>
<button onclick="runCode()">▶ 実行</button>
<button onclick="clearOutput()">🧹 クリア</button>
<h3>出力</h3>
<pre id="output"></pre>
<h3>エラー</h3>
<div id="error"></div>
<footer>
🏡 <a href="list.html">MincoJS Village に戻る</a>
</footer>
<script>
const output = document.getElementById('output');
const errorBox = document.getElementById('error');
const inputField = document.getElementById('inputField');
function print(...args) {
output.textContent += args.join(' ') + "\n";
output.scrollTop = output.scrollHeight;
}
function input() {
return inputField.value;
}
function clearOutput() {
output.textContent = '';
errorBox.textContent = '';
document.body.style.background = '#fdfaf7';
}
function runCode() {
const code = document.getElementById('code').value;
try {
errorBox.textContent = '';
new Function('print', 'input', code)(print, input);
} catch (e) {
errorBox.textContent = '❌ ' + e.message;
}
}
</script>
</body>
</html>