/* "We Teach, It Learn" — the result column, and the chain that feeds it. * * The three results are the Golden Circle made concrete (Rev 4.1 §1.3). Each * layer shows a chapter, the trade it makes, and the benefit a person feels: * * WHY the belief, shown through a chapter that proves it * HOW the method — what NEUON does instead of the old way * WHAT the capability, in one line * * Colour follows the CHAPTER, not the state, so a viewer learns the palette * once and reads it everywhere: NEUMotion blue, NEUNature green, and so on. * * A cycle runs as a chain: a raw signal lights, charges the core, and the core * delivers to one result — so the section shows cause and effect rather than * three things blinking independently. * * [RG] the benefit wording is mine. Replace with NEUON's own. */ (function () { var slots = Array.prototype.slice.call(document.querySelectorAll('[data-res]')); if (!slots.length) return; var signals = Array.prototype.slice.call(document.querySelectorAll('[data-signal]')); var core = document.querySelector('.teach3__brain [data-netgraph]'); var reduced = matchMedia('(prefers-reduced-motion: reduce)').matches; /* chapter → the colour it owns everywhere on the site */ var NEU = { neumotion: { name: 'NEUMotion', c: '#2f8fff' }, // blue neunature: { name: 'NEUNature', c: '#3ddc97' }, // green neucity: { name: 'NEUCity', c: '#ffa53d' }, // amber, like roadworks neufactory: { name: 'NEUFactory', c: '#b98cff' }, // violet neuslm: { name: 'NEUDoc', c: '#38d9d3' }, // cyan neutalents: { name: 'NEUTalents', c: '#ff7ac8' }, // pink neustudio: { name: 'NEUStudio', c: '#ffd54a' }, // yellow neustory: { name: 'NEUStory', c: '#8ec5ff' }, // pale blue }; var POOL = { why: [ ['neumotion', 'Markerless', 'No suits, no lab booking — measured anywhere a camera can see.'], ['neunature', 'Seen early', 'A change in the canopy is noticed in weeks, not at the next survey.'], ['neucity', 'Yours to keep','The road data stays in Sarawak, and so does the decision.'], ['neutalents', 'Careers here', 'The talent that builds it does not have to leave home.'], ], how: [ ['neuslm', 'Paperless', 'Forms read once, never re-keyed, and the archive answers back.'], ['neucity', 'Tireless', 'Every road, every run — instead of an inspection twice a year.'], ['neufactory', 'On the line', 'Caught at the station that caused it, not at the end of the shift.'], ['neumotion', 'Affordable', 'A camera and a laptop, instead of a rig that costs more than the clinic.'], ], what: [ ['neuslm', 'Small models', 'Runs on modest hardware, without paying by the token.'], ['neumotion', 'Quantified', 'Movement turned into numbers a physio can act on.'], ['neunature', 'Recognised', 'A species named from a photograph, by anyone holding a phone.'], ['neufactory', 'Decided', 'Understanding turned into an operational decision, automatically.'], ], }; var state = slots.map(function (li) { return { li: li, pool: POOL[li.dataset.layer] || POOL.what, at: Math.floor(Math.random() * (POOL[li.dataset.layer] || POOL.what).length), neu: li.querySelector('[data-neu]'), trade: li.querySelector('[data-trade]'), benefit: li.querySelector('[data-benefit]'), }; }); function show(s, n) { var r = s.pool[n]; var meta = NEU[r[0]] || { name: r[0], c: '#8ec5ff' }; s.li.style.setProperty('--neu', meta.c); s.neu.textContent = meta.name; s.trade.textContent = r[1]; s.benefit.textContent = r[2]; s.li.classList.remove('is-turning'); void s.li.offsetWidth; // restart the flash s.li.classList.add('is-turning'); } state.forEach(function (s) { show(s, s.at); }); /* ================= the lightning ================= * A signal that only nudges sideways doesn't read as anything. So the bolt * is drawn: a jagged line from the signal to the ball, a fork onto two real * dots inside it, then a second bolt out to the result that lands. * * Everything is driven by requestAnimationFrame rather than CSS transitions, * because the bolt has to be redrawn against wherever the elements actually * are on screen right now — the ball is spinning underneath it. */ var NSVG = 'http://www.w3.org/2000/svg'; var bolts = document.querySelector('[data-bolts]'); function frame() { var r = bolts.getBoundingClientRect(); bolts.setAttribute('viewBox', '0 0 ' + Math.round(r.width) + ' ' + Math.round(r.height)); return r; } /* where on an element the charge leaves from or arrives at */ function anchor(el, side, box) { var b = el.getBoundingClientRect(); var x = side === 'r' ? b.right : side === 'l' ? b.left : b.left + b.width / 2; return { x: x - box.left, y: b.top + b.height / 2 - box.top }; } /* a jagged path between two points — the wobble scales with the distance, so a short fork doesn't look like a scribble */ function jag(a, b, chaos) { var dx = b.x - a.x, dy = b.y - a.y; var len = Math.sqrt(dx * dx + dy * dy) || 1; var nx = -dy / len, ny = dx / len; // the perpendicular var steps = Math.max(3, Math.min(7, Math.round(len / 34))); var d = 'M' + a.x.toFixed(1) + ' ' + a.y.toFixed(1); for (var i = 1; i < steps; i++) { var t = i / steps; var off = (Math.random() - 0.5) * len * (chaos || 0.16) * Math.sin(t * Math.PI); d += ' L' + (a.x + dx * t + nx * off).toFixed(1) + ' ' + (a.y + dy * t + ny * off).toFixed(1); } return d + ' L' + b.x.toFixed(1) + ' ' + b.y.toFixed(1); } function strike(a, b, colour, ms, chaos, done) { if (!bolts) { if (done) done(); return; } var path = document.createElementNS(NSVG, 'path'); path.setAttribute('class', 'bolt'); path.setAttribute('d', jag(a, b, chaos)); path.style.stroke = colour || '#8ec5ff'; bolts.appendChild(path); var glow = path.cloneNode(true); glow.setAttribute('class', 'bolt bolt--glow'); bolts.insertBefore(glow, path); var len = path.getTotalLength() || 1; [path, glow].forEach(function (p) { p.style.strokeDasharray = len; p.style.strokeDashoffset = len; }); var head = document.createElementNS(NSVG, 'circle'); head.setAttribute('class', 'bolt__head'); head.setAttribute('r', 3.2); head.style.fill = colour || '#8ec5ff'; bolts.appendChild(head); var t0 = null; function run(now) { if (t0 === null) t0 = now; var t = Math.min(1, (now - t0) / (ms || 260)); [path, glow].forEach(function (p) { p.style.strokeDashoffset = (len * (1 - t)).toFixed(1); }); var pt = path.getPointAtLength(len * t); head.setAttribute('cx', pt.x.toFixed(1)); head.setAttribute('cy', pt.y.toFixed(1)); if (t < 1) return requestAnimationFrame(run); head.remove(); [path, glow].forEach(function (p) { p.classList.add('is-gone'); setTimeout(function () { p.remove(); }, 340); }); if (done) done(); } requestAnimationFrame(run); } /* ---- the chain: signal → the ball's dots → one result ---- */ function chain(force) { if (document.hidden && !force) return; // don't churn in a background tab var sig = signals[Math.floor(Math.random() * signals.length)]; var s = state[Math.floor(Math.random() * state.length)]; var next; do { next = Math.floor(Math.random() * s.pool.length); } while (next === s.at && s.pool.length > 1); s.at = next; var hue = (NEU[s.pool[next][0]] || {}).c || '#8ec5ff'; if (sig) { sig.classList.add('is-sending'); setTimeout(function () { sig.classList.remove('is-sending'); }, 700); } if (bolts && core && sig) { var box = frame(); var from = anchor(sig, 'r', box); var mid = anchor(core, 'c', box); // 1 · the trunk: the signal reaches the ball strike(from, mid, '#8ec5ff', 240, 0.18, function () { // 2 · the fork: it hits real dots, and they flare var dots = core._dots ? core._dots() : []; for (var i = 0; i < 2 && dots.length; i++) { var n = dots[Math.floor(Math.random() * dots.length)]; var to = anchor(n.g, 'c', box); strike(mid, to, '#fff', 160, 0.3); (function (node) { setTimeout(function () { core._flash(node); }, 120); })(n); } // 3 · and leaves for the result that is about to change setTimeout(function () { strike(mid, anchor(s.li, 'l', box), hue, 300, 0.14); }, 180); }); } // the core takes the charge a beat later setTimeout(function () { if (core) { core.classList.add('is-charging'); setTimeout(function () { core.classList.remove('is-charging'); }, 600); } }, 260); // and delivers it a beat after that setTimeout(function () { show(s, s.at); }, 760); } if (reduced) return; state.forEach(function (s, i) { s.li._next = function () { show(s, (s.at = (s.at + 1) % s.pool.length)); }; }); window._teachChain = chain; // so it can be driven when testing setInterval(chain, 2600); })();