Liveweave: Generative AI Web Editor & HTML/CSS/JS Playground
Initializing
Liveweave
Web
expand_more
home
Home
Palette
Color Explorer
arrow_outward
Polyline
Graphics Editor
arrow_outward
frame_source
Python Playground
arrow_outward
build
Tools
expand_more
restart_alt
Load "Hello Weaver!"
post_add
Generate Lorem ipsum...
code
Format HTML
code_blocks
Format CSS
data_object
Format JavaScript
library_add
Library
expand_more
A
Algolia JS
Animate CSS
Apex Charts JS
B
Bulma CSS
Bootstrap
C
Chart JS
Chartist
Create JS
D
D3
Dojo
F
Foundation
Fullpage JS
G
Granim JS
Google Charts
H
Halfmoon
J
jQuery
M
Materialize
Moment JS
Masonry JS
Milligram CSS
P
Pure CSS
Primer CSS
Popper JS
Pattern CSS
Picnic CSS
R
React JS
Raphael JS
Raisin CSS
S
Semantic UI
Skeleton CSS
Spectre CSS
Tachyons CSS
T
Tailwind
Three JS
U
UI Kit
Vis JS
W
Water CSS
download
Download
expand_more
developer_mode
Download as HTML
folder_zip
Download as .ZIP
cloud_upload
Fork
account_circle
Login
settings
Settings
expand_more
Editor font
14
px
A
A
Night mode
Line number
Mini map
Word wrap
sync_alt
Reset Settings
smart_display
Run
left_panel_close
AI Assistant
dashboard
All
HTML
CSS
JS
visibility
Preview
bolt
Live Preview
terminal
JS Console
<!DOCTYPE html> <html> <head> <title>Meet your Robot</title> </head> <body> <!-- Start your code here --> <div class="lab"> <header class="header"> <div class="brand"> <div class="brand-mark">β³</div> <div> <h1>ROBOT<span>LAB</span></h1> <p>YOUR LITTLE ARTIFICIAL FRIEND</p> </div> </div> <div class="online"><span></span> ROBOT ONLINE</div> </header> <main class="workspace"> <section class="stage-panel"> <div class="stage-heading"> <div> <div class="eyebrow">EXPERIMENT 001</div> <h2>Meet your robot.</h2> </div> <div class="version">MODEL R-01</div> </div> <div class="stage" id="stage"> <div class="stars"> <i></i><i></i><i></i><i></i><i></i> </div> <div class="floor-grid"></div> <div class="robot-wrap" id="robot" data-mood="happy" role="button" tabindex="0" aria-label="Click to interact with the robot"> <div class="antenna"> <div class="antenna-ball"></div> <div class="antenna-stem"></div> </div> <div class="robot-head"> <div class="ear ear-left"></div> <div class="ear ear-right"></div> <div class="face"> <div class="eyes"> <div class="eye"><i></i></div> <div class="eye"><i></i></div> </div> <div class="mouth"></div> <div class="cheek cheek-left"></div> <div class="cheek cheek-right"></div> </div> <div class="head-bolt"></div> </div> <div class="neck"></div> <div class="arms"> <div class="arm arm-left"> <div class="shoulder"></div> <div class="arm-piece"></div> <div class="hand"><i></i><i></i><i></i></div> </div> <div class="arm arm-right"> <div class="shoulder"></div> <div class="arm-piece"></div> <div class="hand"><i></i><i></i><i></i></div> </div> </div> <div class="torso"> <div class="chest-top"> <span class="chest-light"></span> <span class="chest-light"></span> <span class="chest-light"></span> </div> <div class="chest-screen"> <div class="screen-face">β‘</div> </div> <div class="chest-label">R - 01</div> </div> <div class="legs"> <div class="leg leg-left"> <div class="leg-joint"></div> <div class="foot"></div> </div> <div class="leg leg-right"> <div class="leg-joint"></div> <div class="foot"></div> </div> </div> </div> <div class="robot-shadow"></div> <div class="speech" id="speech">Hello, human! π</div> <div class="stage-hint">TAP THE ROBOT TO INTERACT</div> </div> <div class="status-bar"> <div><span class="status-dot"></span> <span id="status">Feeling happy</span></div> <div id="action-label">IDLE MODE</div> </div> </section> <aside class="controls"> <div class="control-heading"> <div class="eyebrow">CONTROL CENTER</div> <div class="control-title">Robot settings</div> </div> <section class="control-section"> <div class="section-label">01 / PERSONALITY</div> <div class="moods"> <button class="mood active" data-mood="happy"><span>π</span>Happy</button> <button class="mood" data-mood="curious"><span>π€</span>Curious</button> <button class="mood" data-mood="sleepy"><span>π΄</span>Sleepy</button> <button class="mood" data-mood="angry"><span>π </span>Angry</button> </div> </section> <section class="control-section"> <div class="section-label">02 / ACTIONS</div> <div class="actions"> <button class="action-btn" data-action="wave"><span>π</span> Wave</button> <button class="action-btn" data-action="dance"><span>π</span> Dance</button> <button class="action-btn" data-action="walk"><span>πΆ</span> Walk</button> <button class="action-btn" data-action="jump"><span>β¬οΈ</span> Jump</button> <button class="action-btn wide" data-action="celebrate"><span>π</span> Celebrate!</button> </div> </section> <section class="control-section"> <div class="section-label">03 / APPEARANCE</div> <div class="color-row"> <label for="body-color">Body color</label> <input type="color" id="body-color" value="#e6e9ed"> </div> <div class="color-row"> <label for="eye-color">Eye glow</label> <input type="color" id="eye-color" value="#54d9e8"> </div> </section> <section class="control-section"> <div class="slider-heading"> <label for="speed">Animation speed</label> <strong id="speed-value">1.0Γ</strong> </div> <input type="range" id="speed" min="0.5" max="2.5" step="0.1" value="1"> <div class="range-labels"><span>SLOW</span><span>FAST</span></div> </section> <button id="reset" class="reset-btn">β» Reset robot</button> </aside> </main> <footer> <span>ROBOT LAB</span> <span>BUILT FOR CURIOSITY β¦ VERSION 1.0</span> </footer> </div> <!-- End your code here --> </body> </html>
@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700;800&display=swap'); :root { --bg: #10151d; --panel: #171f2a; --line: #283441; --text: #e8edf2; --muted: #82909e; --accent: #55dce9; --body-color: #e6e9ed; --eye-color: #54d9e8; --duration: 1s; } * { box-sizing: border-box; } body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif; } button, input { font: inherit; } .lab { max-width: 1120px; margin: auto; padding: 24px 30px 18px; } .header, footer { display: flex; justify-content: space-between; align-items: center; } .header { border-bottom: 1px solid var(--line); padding-bottom: 20px; } .brand { display: flex; gap: 12px; align-items: center; } .brand-mark { width: 39px; height: 39px; display: grid; place-items: center; background: #20343d; color: var(--accent); border: 1px solid #36515a; border-radius: 11px; font-size: 24px; } .brand h1 { font-size: 16px; letter-spacing: 2px; margin: 0; font-weight: 800; } .brand h1 span { color: var(--accent); margin-left: 4px; } .brand p, .eyebrow, .section-label, .version, .online, footer, .stage-hint, .range-labels { font-family: 'DM Mono', monospace; letter-spacing: 1.2px; } .brand p { color: var(--muted); font-size: 8px; margin: 4px 0 0; } .online { color: #9eacb9; font-size: 9px; display: flex; align-items: center; gap: 8px; } .online span, .status-dot { width: 7px; height: 7px; border-radius: 50%; background: #5ce3a2; box-shadow: 0 0 10px #5ce3a2; } .workspace { display: grid; grid-template-columns: minmax(0, 1fr) 275px; gap: 20px; padding-top: 24px; } .stage-panel, .controls { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; } .stage-panel { padding: 22px; min-width: 0; } .stage-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 17px; } .eyebrow { color: #7f919f; font-size: 9px; } .stage-heading h2 { margin: 6px 0 0; font-size: 23px; letter-spacing: -.7px; } .version { font-size: 9px; color: #8295a4; border: 1px solid var(--line); padding: 7px 9px; border-radius: 6px; } .stage { height: 435px; border: 1px solid #2c3b49; border-radius: 12px; overflow: hidden; position: relative; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 45%, #283b4b 0%, #192735 38%, #111b27 78%); perspective: 850px; } .floor-grid { position: absolute; height: 48%; width: 150%; bottom: -22%; left: -25%; transform: rotateX(65deg); transform-origin: top; background-image: linear-gradient(#43607335 1px, transparent 1px), linear-gradient(90deg, #43607335 1px, transparent 1px); background-size: 38px 38px; mask-image: linear-gradient(to bottom, #000, transparent); } .stars i { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #8debf2; box-shadow: 0 0 8px #8debf2; opacity: .5; } .stars i:nth-child(1) { top: 16%; left: 16%; } .stars i:nth-child(2) { top: 25%; left: 79%; } .stars i:nth-child(3) { top: 48%; left: 12%; } .stars i:nth-child(4) { top: 17%; left: 64%; } .stars i:nth-child(5) { top: 57%; left: 87%; } .robot-wrap { position: relative; width: 190px; height: 300px; z-index: 2; transform-style: preserve-3d; cursor: pointer; animation: idle-float 3s ease-in-out infinite; outline: none; } .robot-wrap:focus-visible { filter: drop-shadow(0 0 12px #55dce9); } @keyframes idle-float { 0%, 100% { transform: translateY(0) rotateY(-8deg); } 50% { transform: translateY(-8px) rotateY(8deg); } } /* Head */ .antenna { position: absolute; top: 0; left: 91px; height: 33px; width: 8px; z-index: 2; } .antenna-stem { width: 5px; height: 27px; margin: 6px auto 0; border-radius: 5px; background: linear-gradient(90deg, #697784, #e3e8ec, #687986); } .antenna-ball { position: absolute; width: 12px; height: 12px; left: -2px; top: 0; border-radius: 50%; background: var(--eye-color); box-shadow: 0 0 13px var(--eye-color); } .robot-head { position: absolute; top: 28px; left: 34px; width: 122px; height: 103px; border-radius: 36px 36px 31px 31px; background: linear-gradient(130deg, #fff, var(--body-color) 48%, #9da9b3); border: 2px solid #ffffff55; box-shadow: inset -7px -8px 14px #52616c40, 0 8px 18px #0005; z-index: 4; transform-origin: center bottom; transition: transform .35s; } .ear { position: absolute; width: 12px; height: 27px; top: 36px; border-radius: 8px; background: linear-gradient(90deg, #65737f, #e5e9ec); } .ear-left { left: -9px; } .ear-right { right: -9px; } .face { position: absolute; inset: 12px 10px; border-radius: 26px; background: linear-gradient(140deg, #253847, #101b28); border: 1px solid #667b8b; overflow: hidden; } .eyes { position: absolute; top: 24px; left: 0; right: 0; display: flex; justify-content: center; gap: 19px; } .eye { width: 17px; height: 21px; border-radius: 50%; background: var(--eye-color); box-shadow: 0 0 9px var(--eye-color), 0 0 18px color-mix(in srgb, var(--eye-color), transparent 40%); position: relative; overflow: hidden; transition: .25s; } .eye i { position: absolute; width: 5px; height: 6px; background: #fff; border-radius: 50%; top: 4px; left: 4px; } .mouth { position: absolute; width: 23px; height: 10px; border-bottom: 3px solid var(--eye-color); border-radius: 0 0 50% 50%; bottom: 16px; left: 38px; transition: .2s; } .cheek { position: absolute; width: 9px; height: 5px; border-radius: 50%; background: #f38b89; opacity: .7; top: 55px; } .cheek-left { left: 12px; } .cheek-right { right: 12px; } .head-bolt { position: absolute; width: 7px; height: 7px; background: #7b8994; border-radius: 50%; top: 7px; right: 13px; } /* Neck and body */ .neck { position: absolute; top: 126px; left: 82px; width: 26px; height: 17px; background: linear-gradient(90deg, #64717c, #e6e9ed, #73818c); border-radius: 5px; z-index: 1; } .torso { position: absolute; top: 139px; left: 43px; width: 105px; height: 107px; border-radius: 25px 25px 29px 29px; background: linear-gradient(130deg, #fff, var(--body-color) 43%, #a3adb6); border: 2px solid #ffffff55; box-shadow: inset -8px -9px 15px #53616d45, 0 8px 18px #0004; z-index: 3; } .chest-top { display: flex; justify-content: center; gap: 6px; padding-top: 10px; } .chest-light { width: 5px; height: 5px; border-radius: 50%; background: var(--eye-color); box-shadow: 0 0 6px var(--eye-color); } .chest-screen { width: 45px; height: 39px; margin: 8px auto 0; border-radius: 9px; background: linear-gradient(140deg, #263c4a, #101b26); border: 1px solid #617786; display: grid; place-items: center; box-shadow: inset 0 0 9px #0008; } .screen-face { font-size: 24px; color: var(--eye-color); text-shadow: 0 0 8px var(--eye-color); transform: translateY(-4px); } .chest-label { font: 8px 'DM Mono', monospace; text-align: center; color: #61717d; margin-top: 5px; letter-spacing: 2px; } /* Arms */ .arm { position: absolute; top: 148px; width: 30px; height: 83px; z-index: 2; transform-origin: 50% 10px; } .arm-left { left: 19px; transform: rotate(12deg); } .arm-right { right: 19px; transform: rotate(-12deg); } .shoulder { position: absolute; width: 29px; height: 29px; border-radius: 50%; background: linear-gradient(140deg, #fff, #aeb8c0); border: 2px solid #ffffff55; z-index: 2; } .arm-piece { position: absolute; top: 20px; left: 6px; width: 18px; height: 48px; border-radius: 10px; background: linear-gradient(90deg, #86949e, #f0f2f4, #9ba7b0); transform-origin: top center; } .hand { position: absolute; top: 61px; left: 4px; width: 22px; height: 22px; border-radius: 8px 8px 11px 11px; background: linear-gradient(135deg, #fff, #aab4bc); display: flex; justify-content: center; gap: 2px; padding-top: 13px; } .hand i { width: 3px; height: 6px; background: #74818a; border-radius: 3px; } /* Legs */ .legs { position: absolute; top: 238px; left: 0; right: 0; z-index: 2; } .leg { position: absolute; width: 28px; height: 53px; transform-origin: top center; } .leg-left { left: 59px; } .leg-right { right: 59px; } .leg-joint { width: 24px; height: 26px; margin: auto; border-radius: 8px; background: linear-gradient(90deg, #86939d, #e9edf0, #9ba6af); } .foot { position: absolute; bottom: 0; left: -5px; width: 37px; height: 15px; border-radius: 7px 9px 7px 7px; background: linear-gradient(120deg, #e6e9ed, #8996a0); box-shadow: 0 4px 7px #0005; } .robot-shadow { position: absolute; bottom: 52px; left: 50%; transform: translateX(-50%); width: 135px; height: 19px; border-radius: 50%; background: #0007; filter: blur(8px); } /* Mood changes */ .robot-wrap[data-mood="happy"] .mouth { height: 12px; border-bottom-width: 4px; } .robot-wrap[data-mood="curious"] .robot-head { transform: rotate(9deg); } .robot-wrap[data-mood="curious"] .eyes { top: 19px; } .robot-wrap[data-mood="curious"] .mouth { width: 9px; height: 9px; border: 2px solid var(--eye-color); border-radius: 50%; left: 45px; } .robot-wrap[data-mood="sleepy"] .eye { height: 5px; margin-top: 9px; border-radius: 5px; } .robot-wrap[data-mood="sleepy"] .mouth { width: 10px; height: 5px; border-bottom: 2px solid var(--eye-color); } .robot-wrap[data-mood="sleepy"] { animation-duration: 5s; } .robot-wrap[data-mood="angry"] .eye { border-radius: 3px 3px 9px 9px; height: 14px; margin-top: 5px; } .robot-wrap[data-mood="angry"] .mouth { width: 18px; height: 4px; border-radius: 0; border-bottom: 0; border-top: 3px solid var(--eye-color); } /* Actions */ .robot-wrap.action-wave .arm-right { animation: wave var(--duration) ease-in-out 2; } .robot-wrap.action-wave .robot-head { animation: nod var(--duration) ease-in-out 2; } @keyframes wave { 0%, 100% { transform: rotate(-12deg); } 25%, 65% { transform: rotate(-145deg); } 45%, 85% { transform: rotate(-125deg); } } @keyframes nod { 0%, 100% { transform: rotate(0); } 30%, 70% { transform: rotate(-9deg); } } .robot-wrap.action-dance { animation: dance var(--duration) ease-in-out 2; } @keyframes dance { 0%, 100% { transform: translateY(0) rotateY(-8deg) rotateZ(0); } 25% { transform: translateY(-10px) rotateZ(-13deg) rotateY(18deg); } 50% { transform: translateY(0) rotateZ(13deg) rotateY(-18deg); } 75% { transform: translateY(-12px) rotateZ(-9deg) rotateY(12deg); } } .robot-wrap.action-dance .arm-left { animation: dance-arm var(--duration) ease-in-out 2; } .robot-wrap.action-dance .arm-right { animation: dance-arm var(--duration) ease-in-out 2 reverse; } @keyframes dance-arm { 0%, 100% { transform: rotate(12deg); } 50% { transform: rotate(-95deg); } } .robot-wrap.action-walk .leg-left { animation: step var(--duration) ease-in-out 3; } .robot-wrap.action-walk .leg-right { animation: step var(--duration) ease-in-out 3 reverse; } .robot-wrap.action-walk .arm-left { animation: walk-arm var(--duration) ease-in-out 3; } .robot-wrap.action-walk .arm-right { animation: walk-arm var(--duration) ease-in-out 3 reverse; } @keyframes step { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(30deg); } } @keyframes walk-arm { 0%, 100% { transform: rotate(12deg); } 50% { transform: rotate(-35deg); } } .robot-wrap.action-jump { animation: jump var(--duration) cubic-bezier(.2,.8,.3,1) 2; } @keyframes jump { 0%, 100% { transform: translateY(0) rotateY(-8deg); } 45% { transform: translateY(-85px) rotateY(12deg); } } .robot-wrap.action-jump .arm { animation: jump-arms var(--duration) ease 2; } @keyframes jump-arms { 0%, 100% { transform: rotate(12deg); } 50% { transform: rotate(-120deg); } } .robot-wrap.action-celebrate { animation: dance var(--duration) ease-in-out 3; } .robot-wrap.action-celebrate .arm { animation: celebrate-arm var(--duration) ease-in-out 3; } @keyframes celebrate-arm { 0%, 100% { transform: rotate(12deg); } 50% { transform: rotate(-155deg); } } .speech { position: absolute; z-index: 5; top: 16%; left: 50%; transform: translateX(-50%) translateY(7px); background: #f1f7f8; color: #203341; padding: 9px 13px; border-radius: 10px; font-size: 11px; font-weight: 700; white-space: nowrap; opacity: 0; pointer-events: none; transition: .2s; } .speech.show { opacity: 1; transform: translateX(-50%) translateY(0); } .stage-hint { position: absolute; bottom: 14px; font-size: 8px; color: #708493; } /* Status and controls */ .status-bar { display: flex; justify-content: space-between; align-items: center; padding: 14px 2px 0; font-size: 10px; color: #a7b4bf; } .status-bar > div:first-child { display: flex; gap: 8px; align-items: center; } .status-dot { width: 6px; height: 6px; } #action-label { font: 9px 'DM Mono', monospace; color: var(--accent); } .controls { padding: 20px 17px; } .control-title { font-size: 18px; font-weight: 700; margin-top: 5px; } .control-section { border-top: 1px solid var(--line); padding: 17px 0; margin-top: 16px; } .section-label { font-size: 9px; color: #8194a3; margin-bottom: 12px; } .moods { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; } .mood, .action-btn { border: 1px solid #30404d; background: #1d2935; color: #bdc8d1; border-radius: 8px; cursor: pointer; transition: .2s; } .mood { padding: 9px 6px; font-size: 10px; display: flex; align-items: center; justify-content: center; gap: 6px; } .mood span { font-size: 15px; } .mood:hover, .action-btn:hover { border-color: #5b8996; background: #233542; } .mood.active { border-color: #4fc8d7; color: #75e3ed; background: #203640; box-shadow: inset 0 0 12px #55dce910; } .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; } .action-btn { padding: 10px 5px; font-size: 10px; font-weight: 600; } .action-btn span { margin-right: 4px; font-size: 14px; } .action-btn.wide { grid-column: span 2; } .color-row, .slider-heading { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: #b9c5ce; margin-bottom: 12px; } .color-row input { width: 34px; height: 25px; padding: 2px; border: 1px solid #40515e; border-radius: 6px; background: #25313d; cursor: pointer; } .slider-heading { margin-bottom: 12px; } .slider-heading strong { color: var(--accent); font: 11px 'DM Mono', monospace; } input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; } .range-labels { display: flex; justify-content: space-between; font-size: 8px; color: #708391; margin-top: 5px; } .reset-btn { width: 100%; padding: 11px; background: #263642; border: 1px solid #354a57; border-radius: 8px; color: #b9d0d9; font-size: 11px; font-weight: 700; cursor: pointer; } .reset-btn:hover { background: #304653; } footer { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; color: #647583; font-size: 8px; } footer span:first-child { color: #91a4b0; } @media (max-width: 760px) { .lab { padding: 16px 12px; } .workspace { grid-template-columns: 1fr; } .stage { height: 390px; } .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; } .control-heading, .reset-btn { grid-column: span 2; } .control-section { margin-top: 10px; } } @media (max-width: 420px) { .stage-panel { padding: 13px; } .stage { height: 355px; } .controls { padding: 15px 12px; } footer { font-size: 7px; } }
const robot = document.getElementById("robot"); const speech = document.getElementById("speech"); const statusText = document.getElementById("status"); const actionLabel = document.getElementById("action-label"); const messages = { happy: ["Hello, human! π", "It's a beautiful day!", "I like you! π€", "Beep boop!"], curious: ["What is that?", "Interesting...", "Can I investigate?", "Hmm. π€"], sleepy: ["Just five more minutes...", "Zzz... π΄", "Low battery...", "Wake me later."], angry: ["Who changed my settings?", "I am NOT amused.", "Beep! Beep!", "System displeased."] }; const moodStatus = { happy: "Feeling happy", curious: "Feeling curious", sleepy: "Feeling sleepy", angry: "Feeling grumpy" }; const actionMessages = { wave: "Hello there! π", dance: "Check out my moves! πΊ", walk: "Going for a walk!", jump: "Wheeeee! π", celebrate: "WE DID IT! π" }; let currentMood = "happy"; let speechTimer; let actionTimer; let speed = 1; function say(message) { speech.textContent = message; speech.classList.add("show"); clearTimeout(speechTimer); speechTimer = setTimeout(() => { speech.classList.remove("show"); }, 1800); } function setMood(mood) { currentMood = mood; robot.dataset.mood = mood; document.querySelectorAll(".mood").forEach(button => { button.classList.toggle("active", button.dataset.mood === mood); }); statusText.textContent = moodStatus[mood]; const options = messages[mood]; say(options[Math.floor(Math.random() * options.length)]); } document.querySelectorAll(".mood").forEach(button => { button.addEventListener("click", () => { setMood(button.dataset.mood); }); }); function performAction(action) { robot.classList.remove( "action-wave", "action-dance", "action-walk", "action-jump", "action-celebrate" ); // Restart the animation even if the same action is selected again. void robot.offsetWidth; robot.classList.add("action-" + action); actionLabel.textContent = action.toUpperCase() + " MODE"; say(actionMessages[action]); clearTimeout(actionTimer); actionTimer = setTimeout(() => { robot.classList.remove("action-" + action); actionLabel.textContent = "IDLE MODE"; }, action === "celebrate" ? 3000 / speed : 2200 / speed); } document.querySelectorAll(".action-btn").forEach(button => { button.addEventListener("click", () => { performAction(button.dataset.action); }); }); // Click the robot to make it respond. function interact() { const randomMood = messages[currentMood]; say(randomMood[Math.floor(Math.random() * randomMood.length)]); if (currentMood === "happy") { performAction("wave"); } else if (currentMood === "curious") { robot.classList.remove("action-wave"); robot.classList.add("action-wave"); actionLabel.textContent = "INVESTIGATING"; setTimeout(() => actionLabel.textContent = "IDLE MODE", 1500); } else if (currentMood === "sleepy") { say("Please don't disturb me... π΄"); } else { performAction("jump"); } } robot.addEventListener("click", interact); robot.addEventListener("keydown", event => { if (event.key === "Enter" || event.key === " ") { event.preventDefault(); interact(); } }); // Appearance controls. document.getElementById("body-color").addEventListener("input", event => { document.documentElement.style.setProperty("--body-color", event.target.value); }); document.getElementById("eye-color").addEventListener("input", event => { document.documentElement.style.setProperty("--eye-color", event.target.value); }); // Animation speed. document.getElementById("speed").addEventListener("input", event => { speed = Number(event.target.value); document.documentElement.style.setProperty("--duration", (1 / speed) + "s"); document.getElementById("speed-value").textContent = speed.toFixed(1) + "Γ"; }); // Reset everything. document.getElementById("reset").addEventListener("click", () => { clearTimeout(actionTimer); clearTimeout(speechTimer); robot.className = "robot-wrap"; robot.dataset.mood = "happy"; document.documentElement.style.setProperty("--body-color", "#e6e9ed"); document.documentElement.style.setProperty("--eye-color", "#54d9e8"); document.documentElement.style.setProperty("--duration", "1s"); document.getElementById("body-color").value = "#e6e9ed"; document.getElementById("eye-color").value = "#54d9e8"; document.getElementById("speed").value = 1; document.getElementById("speed-value").textContent = "1.0Γ"; speed = 1; actionLabel.textContent = "IDLE MODE"; setMood("happy"); say("Systems restored. Hello again!"); });
terminal
JavaScript Console
Preview
Clear
close
βΊ
Run