Spaces:
Paused
Paused
Upload 27 files
Browse filesFiles changed (2)
- README.md+2-4
- floating_tutor.py+3-53
60 unmodified lines6162636465666768697060 unmodified lines- a deterministic local tutor for core explanations and image/OCR checking,plus an optional OpenAI route when `OPENAI_API_KEY` is configured;- a persistent bottom-right **Ask Tutor** control on the first page and every tab;both its launcher and pop-up are attached directly to the browser viewport,self-adjust at the top or bottom during page/nested-panel scrolling, resizing,zoom, orientation changes, and mobile-keyboard viewport changes, open overthe page without changing tabs, keep their own compact mission-linked conversation, andhyperlinks to the full multimodal tutor;- a protected **Examination lock** that disables the mission generator, everytraining tab, worksheet tools, theory, progress, and Ask Tutor during an60 unmodified lines616263646566676860 unmodified lines- a deterministic local tutor for core explanations and image/OCR checking,plus an optional OpenAI route when `OPENAI_API_KEY` is configured;- a persistent bottom-right **Ask Tutor** control on the first page and every tab;it stays in the current viewport while the learner scrolls, opens over the page withoutchanging tabs, keeps its own compact mission-linked conversation, andhyperlinks to the full multimodal tutor;- a protected **Examination lock** that disables the mission generator, everytraining tab, worksheet tools, theory, progress, and Ask Tutor during an
99 unmodified lines10010110210310410510610710810911081 unmodified lines1921931941951961971982 unmodified lines20120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525611 unmodified lines2682692702712722732749 unmodified lines2842852862872882892902912922932942952966 unmodified lines30330430530630730830931031131231331431599 unmodified lineswidth: min(430px, calc(100vw - 28px)) !important;z-index: 2147482999 !important;}#floating-tutor-panel.viewport-panel-portal {inset: auto !important;position: fixed !important;transform: translate3d(0, 0, 0) !important;}.floating-tutor-dialog-header {align-items: center;border-bottom: 1px solid #e2e8f0;81 unmodified lines() => {const PROXY_ID = "floating-tutor-viewport-launcher";const NATIVE_ID = "floating-tutor-launcher";const PANEL_ID = "floating-tutor-panel";const nativeButton = () => {const host = document.getElementById(NATIVE_ID);2 unmodified linesreturn host.querySelector("button");};const viewportMetrics = () => {const mobile = window.matchMedia("(max-width: 520px)").matches;const inset = mobile ? 12 : 18;const viewport = window.visualViewport;const viewportWidth = viewport ? viewport.width : document.documentElement.clientWidth;const viewportHeight = viewport ? viewport.height : document.documentElement.clientHeight;const extraRight = viewport? Math.max(0, window.innerWidth - viewport.offsetLeft - viewport.width): 0;const extraBottom = viewport? Math.max(0, window.innerHeight - viewport.offsetTop - viewport.height): 0;return {mobile, inset, viewportWidth, viewportHeight, extraRight, extraBottom};};const pinToViewport = (button) => {if (!button) return;const {inset, extraRight, extraBottom} = viewportMetrics();button.style.setProperty("position", "fixed", "important");button.style.setProperty("right", `${inset + extraRight}px`, "important");button.style.setProperty("bottom", `${inset + extraBottom}px`, "important");button.style.setProperty("left", "auto", "important");button.style.setProperty("top", "auto", "important");button.style.setProperty("transform", "translate3d(0, 0, 0)", "important");button.style.setProperty("visibility", "visible", "important");button.style.setProperty("z-index", "2147483000", "important");};const portalAndPinPanel = (button) => {const panel = document.getElementById(PANEL_ID);if (!panel) return null;if (panel.parentElement !== document.body) document.body.appendChild(panel);panel.classList.add("viewport-panel-portal");const {inset, viewportWidth, viewportHeight, extraRight, extraBottom} = viewportMetrics();const launcherHeight = Math.max(42, button?.getBoundingClientRect().height || 44);const panelWidth = Math.max(180, Math.min(430, viewportWidth - inset * 2));const panelBottom = inset + extraBottom + launcherHeight + 12;const panelHeight = Math.max(140, viewportHeight - launcherHeight - inset * 3 - 12);panel.style.setProperty("position", "fixed", "important");panel.style.setProperty("right", `${inset + extraRight}px`, "important");panel.style.setProperty("bottom", `${panelBottom}px`, "important");panel.style.setProperty("left", "auto", "important");panel.style.setProperty("top", "auto", "important");panel.style.setProperty("width", `${panelWidth}px`, "important");panel.style.setProperty("max-height", `${panelHeight}px`, "important");panel.style.setProperty("transform", "translate3d(0, 0, 0)", "important");panel.style.setProperty("z-index", "2147482999", "important");return panel;};const install = () => {let proxy = document.getElementById(PROXY_ID);if (!proxy) {11 unmodified lines}pinToViewport(proxy);portalAndPinPanel(proxy);const nativeHost = document.getElementById(NATIVE_ID);if (nativeHost) {nativeHost.classList.add("viewport-proxy-active");9 unmodified lineslet frame = 0;const schedulePin = () => {window.cancelAnimationFrame(frame);frame = window.requestAnimationFrame(() => {const proxy = install();pinToViewport(proxy);portalAndPinPanel(proxy);});};window.__m1TutorViewportSchedule = schedulePin;window.addEventListener("scroll", schedulePin, {passive: true, capture: true});document.addEventListener("scroll", schedulePin, {passive: true, capture: true});window.addEventListener("resize", schedulePin, {passive: true});6 unmodified lineschildList: true,subtree: true,});if (window.ResizeObserver) {const resizeObserver = new ResizeObserver(schedulePin);resizeObserver.observe(document.documentElement);resizeObserver.observe(document.body);window.__m1TutorViewportResizeObserver = resizeObserver;}window.__m1TutorViewportHeartbeat = window.setInterval(schedulePin, 1200);}install();99 unmodified lines10010110210310410581 unmodified lines1871881891901911922 unmodified lines19519619719819920020120220320420520620720820921021121221321421521621721821911 unmodified lines2312322332342352369 unmodified lines2462472482492502512522536 unmodified lines26026126226326426599 unmodified lineswidth: min(430px, calc(100vw - 28px)) !important;z-index: 2147482999 !important;}.floating-tutor-dialog-header {align-items: center;border-bottom: 1px solid #e2e8f0;81 unmodified lines() => {const PROXY_ID = "floating-tutor-viewport-launcher";const NATIVE_ID = "floating-tutor-launcher";const nativeButton = () => {const host = document.getElementById(NATIVE_ID);2 unmodified linesreturn host.querySelector("button");};const pinToViewport = (button) => {if (!button) return;const mobile = window.matchMedia("(max-width: 520px)").matches;const inset = mobile ? 12 : 18;const viewport = window.visualViewport;const extraRight = viewport? Math.max(0, window.innerWidth - viewport.offsetLeft - viewport.width): 0;const extraBottom = viewport? Math.max(0, window.innerHeight - viewport.offsetTop - viewport.height): 0;button.style.setProperty("position", "fixed", "important");button.style.setProperty("right", `${inset + extraRight}px`, "important");button.style.setProperty("bottom", `${inset + extraBottom}px`, "important");button.style.setProperty("left", "auto", "important");button.style.setProperty("top", "auto", "important");button.style.setProperty("z-index", "2147483000", "important");};const install = () => {let proxy = document.getElementById(PROXY_ID);if (!proxy) {11 unmodified lines}pinToViewport(proxy);const nativeHost = document.getElementById(NATIVE_ID);if (nativeHost) {nativeHost.classList.add("viewport-proxy-active");9 unmodified lineslet frame = 0;const schedulePin = () => {window.cancelAnimationFrame(frame);frame = window.requestAnimationFrame(() => pinToViewport(install()));};window.addEventListener("scroll", schedulePin, {passive: true, capture: true});document.addEventListener("scroll", schedulePin, {passive: true, capture: true});window.addEventListener("resize", schedulePin, {passive: true});6 unmodified lineschildList: true,subtree: true,});}install();
README.md+2-4
floating_tutor.py+3-53