Репозитории /
Promptly /
public/viewer.html
viewer.html
| 1 | <!DOCTYPE html> |
| 2 | <html lang="ru"> |
| 3 | <head> |
| 4 | <meta charset="UTF-8"> |
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | <title>Promptly — демонстрация</title> |
| 7 | <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext y='.9em' font-size='90'%3E%F0%9F%8E%A4%3C/text%3E%3C/svg%3E"> |
| 8 | <style> |
| 9 | :root { |
| 10 | --bg: #101014; |
| 11 | --panel: rgba(30, 30, 30, .5); |
| 12 | --panel-strong: rgba(30, 30, 30, .68); |
| 13 | --border: rgba(255, 255, 255, .08); |
| 14 | --accent: #4cc2ff; |
| 15 | --accent-2: #7fd4ff; |
| 16 | --text: #e5e5e5; |
| 17 | --muted: #aaa; |
| 18 | } |
| 19 | * { box-sizing: border-box; } |
| 20 | html, body { margin: 0; height: 100%; } |
| 21 | body { |
| 22 | font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; |
| 23 | background: var(--bg); color: var(--text); overflow: hidden; |
| 24 | } |
| 25 | button { border: none; border-radius: 11px; padding: 9px 14px; font: inherit; cursor: pointer; transition: .16s; background: rgba(255,255,255,.08); color: var(--text); } |
| 26 | button:hover:not(:disabled) { background: rgba(255,255,255,.16); } |
| 27 | button:disabled { opacity: .3; cursor: default; } |
| 28 | input, select, textarea { font: inherit; } |
| 29 | .mode { display: none; } |
| 30 | body.mode-audience .mode.audience { display: flex; } |
| 31 | body.mode-speaker .mode.speaker { display: flex; } |
| 32 | |
| 33 | .live { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: #8fdcff; letter-spacing: .4px; font-weight: 600; } |
| 34 | .live .dot { width: 8px; height: 8px; border-radius: 50%; background: #7fd4ff; box-shadow: 0 0 10px #7fd4ff; animation: pulse 1.2s infinite; } |
| 35 | @keyframes pulse { 50% { opacity: .25; } } |
| 36 | |
| 37 | /* ==================== ЗРИТЕЛЬ ==================== */ |
| 38 | #audience { |
| 39 | position: fixed; inset: 0; align-items: center; justify-content: center; padding: 2.4vmin; |
| 40 | background: |
| 41 | radial-gradient(1000px 560px at 50% -20%, rgba(99, 102, 241, .22), transparent 62%), |
| 42 | radial-gradient(760px 460px at 105% 115%, rgba(217, 70, 239, .14), transparent 60%); |
| 43 | } |
| 44 | .audience-frame { |
| 45 | position: relative; overflow: hidden; border-radius: 16px; |
| 46 | width: min(100%, calc((100vh - 4.8vmin) * 16 / 9)); |
| 47 | aspect-ratio: 16 / 9; |
| 48 | box-shadow: 0 30px 90px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .07); |
| 49 | } |
| 50 | .audience-progress { |
| 51 | position: absolute; left: 0; right: 0; bottom: 0; height: 3px; z-index: 40; |
| 52 | background: rgba(255, 255, 255, .08); pointer-events: none; |
| 53 | } |
| 54 | .audience-progress > div { |
| 55 | height: 100%; width: 0; border-radius: 0 3px 3px 0; |
| 56 | background: linear-gradient(90deg, #1795d8, #7fd4ff); |
| 57 | box-shadow: 0 0 10px rgba(232, 121, 249, .8); |
| 58 | transition: width .4s cubic-bezier(.2, .7, .3, 1); |
| 59 | } |
| 60 | .audience-frame .sv-button { cursor: default; } |
| 61 | .audience-frame .sv-button:hover { filter: none; } |
| 62 | .audience-frame .sv-button:active { transform: none; } |
| 63 | .audience-frame .sv-audio { cursor: default; pointer-events: none; } |
| 64 | |
| 65 | .hud { |
| 66 | position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(8px); |
| 67 | display: flex; gap: 16px; align-items: center; |
| 68 | background: rgba(10, 14, 28, .78); border: 1px solid var(--border); |
| 69 | padding: 8px 10px 8px 20px; border-radius: 999px; font-size: 13px; color: #cbd5e1; |
| 70 | opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; backdrop-filter: blur(14px); |
| 71 | z-index: 60; |
| 72 | } |
| 73 | .hud.visible { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; } |
| 74 | .hud .hud-title { max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; color: #e2e8f0; } |
| 75 | .hud .hud-counter { font-variant-numeric: tabular-nums; color: var(--muted); } |
| 76 | .hud button { padding: 6px 11px; border-radius: 999px; font-size: 13px; } |
| 77 | |
| 78 | /* ==================== ДОКЛАДЧИК ==================== */ |
| 79 | #speaker { flex-direction: column; height: 100vh; overflow: hidden; } |
| 80 | .speaker-head { |
| 81 | display: flex; align-items: center; gap: 14px; padding: 11px 18px; |
| 82 | background: rgba(10, 14, 28, .75); border-bottom: 1px solid var(--border); |
| 83 | } |
| 84 | .brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; min-width: 0; } |
| 85 | .brand .brand-mark { font-size: 18px; } |
| 86 | .brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34vw; } |
| 87 | .head-meta { display: flex; align-items: center; gap: 14px; margin-left: auto; flex-shrink: 0; } |
| 88 | .timer { font-variant-numeric: tabular-nums; font-weight: 700; color: #9fd8ff; font-size: 15px; } |
| 89 | .counter { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; } |
| 90 | .head-actions { display: flex; gap: 8px; flex-shrink: 0; } |
| 91 | .head-actions button { padding: 8px 13px; font-size: 13px; } |
| 92 | .head-actions .icon { padding: 8px 11px; } |
| 93 | |
| 94 | .speaker-main { |
| 95 | flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 390px; |
| 96 | gap: 14px; padding: 14px 16px; |
| 97 | } |
| 98 | .notes-card { |
| 99 | display: flex; flex-direction: column; min-height: 0; padding: 20px 24px; |
| 100 | background: linear-gradient(160deg, rgba(99, 102, 241, .13), rgba(12, 17, 33, .72) 55%); |
| 101 | border: 1px solid rgba(129, 140, 248, .22); border-radius: 20px; |
| 102 | box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05); |
| 103 | } |
| 104 | .card-label { display: flex; align-items: center; gap: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 1.3px; font-weight: 800; color: var(--accent); margin-bottom: 12px; } |
| 105 | .card-label .spacer { flex: 1; } |
| 106 | .slide-pill { font-size: 11px; letter-spacing: .3px; text-transform: none; color: #bfe7ff; background: rgba(99, 102, 241, .2); border: 1px solid rgba(129, 140, 248, .3); border-radius: 999px; padding: 3px 9px; } |
| 107 | .notes-body { flex: 1; overflow-y: auto; font-size: clamp(19px, 2.05vw, 31px); line-height: 1.48; color: #e2e8f0; white-space: pre-wrap; padding-right: 6px; } |
| 108 | .notes-body:empty::before { content: 'Нет пометок к этому слайду'; color: #475569; } |
| 109 | .left-col { display: flex; flex-direction: column; gap: 14px; min-height: 0; } |
| 110 | .left-col .notes-card { flex: 1; min-height: 0; } |
| 111 | |
| 112 | /* Консоль команд */ |
| 113 | .console-card { |
| 114 | display: flex; flex-direction: column; min-height: 0; height: clamp(190px, 27vh, 300px); flex-shrink: 0; |
| 115 | padding: 12px 14px; background: rgba(7, 10, 20, .82); |
| 116 | border: 1px solid rgba(129, 140, 248, .22); border-radius: 16px; |
| 117 | box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04); |
| 118 | } |
| 119 | .console-card .card-label { margin-bottom: 8px; } |
| 120 | .console-card .card-label a { color: #bfe7ff; font-size: 10px; text-decoration: none; border: 1px solid rgba(129,140,248,.35); border-radius: 999px; padding: 2px 8px; } |
| 121 | .console-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; outline: none; padding-right: 2px; } |
| 122 | .console-list:focus-visible { box-shadow: 0 0 0 2px rgba(129, 140, 248, .45); border-radius: 8px; } |
| 123 | .console-item { display: flex; align-items: flex-start; gap: 9px; width: 100%; text-align: left; padding: 7px 9px; border-radius: 9px; background: rgba(255,255,255,.035); border: 1px solid transparent; flex-shrink: 0; } |
| 124 | .console-item:hover { background: rgba(255,255,255,.09); } |
| 125 | .console-item.active { background: rgba(99, 102, 241, .18); border-color: rgba(129, 140, 248, .55); } |
| 126 | .console-idx { font-size: 10px; font-weight: 700; color: #9fd8ff; background: rgba(99,102,241,.22); border-radius: 5px; padding: 1px 6px; margin-top: 2px; font-variant-numeric: tabular-nums; } |
| 127 | .console-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; } |
| 128 | .console-meta b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } |
| 129 | .console-meta small { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } |
| 130 | .console-item .run { font-size: 10px; color: #bfe7ff; padding: 2px 7px; border-radius: 999px; border: 1px solid rgba(129,140,248,.35); flex-shrink: 0; } |
| 131 | .console-empty { color: #64748b; font-size: 12px; line-height: 1.5; padding: 6px 2px; } |
| 132 | .console-log { flex-shrink: 0; margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,.07); max-height: 52px; overflow-y: auto; font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; font-size: 10.5px; line-height: 1.45; color: #8ea0bd; white-space: pre-wrap; } |
| 133 | .console-log:empty::before { content: 'Готово. ↑ ↓ — выбор, Enter — запуск.'; color: #475569; } |
| 134 | |
| 135 | /* Окно Chrome / видео */ |
| 136 | .window-row, .video-row { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); border-radius: 10px; padding: 7px 8px; } |
| 137 | .window-row + .window-row, .video-row + .video-row { margin-top: 6px; } |
| 138 | .window-meta, .video-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; } |
| 139 | .window-meta b, .video-meta b { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } |
| 140 | .window-meta small, .video-meta small { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } |
| 141 | .window-row button, .video-row button { padding: 5px 8px; font-size: 11px; border-radius: 8px; flex-shrink: 0; } |
| 142 | .window-status { width: 7px; height: 7px; border-radius: 50%; background: #475569; flex-shrink: 0; } |
| 143 | .window-status.on { background: #4ade80; box-shadow: 0 0 8px rgba(74, 222, 128, .8); } |
| 144 | .window-select { margin-bottom: 7px; } |
| 145 | .window-select select { width: 100%; padding: 6px 8px; font-size: 12px; border-radius: 8px; background: rgba(255,255,255,.05); border: 1px solid var(--border); color: var(--text); } |
| 146 | .window-hint { margin: 6px 0 0; font-size: 10.5px; line-height: 1.4; color: #64748b; } |
| 147 | .window-hint code { color: #9fd8ff; } |
| 148 | |
| 149 | .side { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 3px; } |
| 150 | .card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 12px; flex-shrink: 0; } |
| 151 | .card .card-label { margin-bottom: 9px; font-size: 10px; } |
| 152 | .preview-frame { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #0b1020; border: 1px solid rgba(255,255,255,.06); } |
| 153 | .preview-frame .sv-button { cursor: pointer; } |
| 154 | .preview-next { opacity: .82; } |
| 155 | |
| 156 | .interact-list { display: flex; flex-direction: column; gap: 7px; max-height: 210px; overflow-y: auto; } |
| 157 | .interact-empty { color: #64748b; font-size: 12px; line-height: 1.4; padding: 2px 0; } |
| 158 | .interact-item { display: flex; align-items: center; gap: 9px; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.06); border-radius: 10px; padding: 6px 8px; } |
| 159 | .interact-icon { width: 26px; height: 26px; flex-shrink: 0; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 12px; background: rgba(99, 102, 241, .22); color: #bfe7ff; } |
| 160 | .interact-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; } |
| 161 | .interact-meta b { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } |
| 162 | .interact-meta small { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } |
| 163 | .interact-item button { padding: 5px 9px; font-size: 11px; border-radius: 8px; flex-shrink: 0; } |
| 164 | .interact-item.playing { border-color: rgba(129, 140, 248, .5); background: rgba(99, 102, 241, .12); } |
| 165 | .badge-hidden { font-size: 9.5px; color: #fbbf24; border: 1px solid rgba(251, 191, 36, .35); border-radius: 999px; padding: 1px 6px; } |
| 166 | |
| 167 | .audio-card .audio-row { display: flex; align-items: center; gap: 10px; font-size: 12px; color: #cbd5e1; margin-bottom: 8px; } |
| 168 | .audio-row span { width: 62px; flex-shrink: 0; } |
| 169 | .audio-row input[type="range"] { flex: 1; min-width: 0; accent-color: #4cc2ff; height: 4px; } |
| 170 | .audio-row output { width: 34px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 11px; } |
| 171 | .music-state { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; padding-top: 9px; border-top: 1px solid rgba(255,255,255,.06); } |
| 172 | .music-state .music-name { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } |
| 173 | .music-state button { padding: 6px 10px; font-size: 11.5px; border-radius: 9px; } |
| 174 | .music-state button.on { background: rgba(99, 102, 241, .35); color: #fff; } |
| 175 | |
| 176 | .viewers-card { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: #cbd5e1; } |
| 177 | .viewers-card strong { font-size: 22px; color: #8fdcff; font-variant-numeric: tabular-nums; } |
| 178 | |
| 179 | .controls { |
| 180 | display: flex; align-items: center; gap: 14px; padding: 12px 18px; |
| 181 | background: rgba(10, 14, 28, .75); border-top: 1px solid var(--border); |
| 182 | } |
| 183 | .controls .nav { |
| 184 | font-size: 15px; font-weight: 700; padding: 13px 26px; border-radius: 13px; |
| 185 | background: linear-gradient(90deg, #1795d8, #38bdf8); color: #fff; flex-shrink: 0; |
| 186 | } |
| 187 | .controls .nav:hover:not(:disabled) { filter: brightness(1.12); background: linear-gradient(90deg, #1795d8, #38bdf8); } |
| 188 | .dots { flex: 1; display: flex; gap: 6px; overflow-x: auto; padding: 4px; align-items: center; justify-content: center; } |
| 189 | .dots .dot { padding: 6px 10px; border-radius: 8px; font-size: 12px; background: rgba(255,255,255,.06); color: var(--muted); min-width: 30px; flex-shrink: 0; font-variant-numeric: tabular-nums; } |
| 190 | .dots .dot.active { background: linear-gradient(90deg, #1795d8, #38bdf8); color: #fff; font-weight: 700; } |
| 191 | |
| 192 | /* ==================== ОВЕРЛЕЙ / КНОПКА ЗВУКА / ТОСТ ==================== */ |
| 193 | .unlock-audio { |
| 194 | position: fixed; right: 22px; bottom: 22px; z-index: 150; |
| 195 | display: flex; align-items: center; gap: 9px; padding: 13px 20px; border-radius: 999px; |
| 196 | background: linear-gradient(90deg, #1795d8, #38bdf8); color: #fff; font-weight: 700; font-size: 14px; |
| 197 | box-shadow: 0 14px 40px rgba(99, 102, 241, .45); animation: unlockPulse 1.8s infinite; |
| 198 | } |
| 199 | .unlock-audio[hidden] { display: none; } |
| 200 | @keyframes unlockPulse { 50% { box-shadow: 0 14px 54px rgba(168, 85, 247, .7); } } |
| 201 | |
| 202 | .overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5, 7, 15, .88); backdrop-filter: blur(10px); z-index: 200; } |
| 203 | .overlay[hidden] { display: none; } |
| 204 | .overlay-card { background: #111827; border: 1px solid rgba(255,255,255,.1); border-radius: 22px; padding: 36px 44px; text-align: center; max-width: 480px; box-shadow: 0 30px 80px rgba(0,0,0,.6); } |
| 205 | .overlay-card h2 { margin: 0 0 10px; font-size: 23px; } |
| 206 | .overlay-card p { color: var(--muted); margin: 0 0 24px; line-height: 1.5; } |
| 207 | .overlay-card button { background: linear-gradient(90deg, #1795d8, #38bdf8); font-size: 15px; padding: 12px 24px; } |
| 208 | |
| 209 | /* Пульт окна Chrome */ |
| 210 | .window-remote { position: fixed; inset: 0; z-index: 220; display: flex; align-items: center; justify-content: center; background: rgba(4, 6, 14, .86); backdrop-filter: blur(10px); padding: 18px; } |
| 211 | .window-remote[hidden] { display: none; } |
| 212 | .window-remote-card { width: min(980px, 100%); max-height: 94vh; display: flex; flex-direction: column; gap: 12px; background: #0c1120; border: 1px solid rgba(255,255,255,.1); border-radius: 20px; padding: 14px; box-shadow: 0 30px 90px rgba(0,0,0,.7); } |
| 213 | .window-remote-head { display: flex; align-items: center; gap: 10px; } |
| 214 | .window-remote-head h3 { margin: 0; font-size: 15px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } |
| 215 | .window-remote-head .live { font-size: 10.5px; } |
| 216 | .window-remote-stage { position: relative; flex: 1; min-height: 0; aspect-ratio: 16 / 9; max-height: 62vh; background: #02040a; border: 1px solid rgba(255,255,255,.08); border-radius: 12px; overflow: hidden; cursor: crosshair; } |
| 217 | .window-remote-stage img { width: 100%; height: 100%; object-fit: fill; display: block; } |
| 218 | .window-remote-stage .remote-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #64748b; font-size: 13px; text-align: center; padding: 20px; } |
| 219 | .window-remote-keys { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; } |
| 220 | .window-remote-keys button { padding: 7px 10px; font-size: 12px; border-radius: 8px; } |
| 221 | .window-remote-text { display: flex; gap: 8px; } |
| 222 | .window-remote-text input { flex: 1; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--border); background: rgba(255,255,255,.05); color: var(--text); font: inherit; } |
| 223 | .window-remote-text button { padding: 8px 14px; } |
| 224 | |
| 225 | .restart-btn { background: linear-gradient(90deg, #1795d8, #38bdf8); color: #fff; font-weight: 650; } |
| 226 | .restart-btn:hover { filter: brightness(1.12); } |
| 227 | .toast { |
| 228 | position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(12px); |
| 229 | background: rgba(127, 29, 29, .92); border: 1px solid rgba(248, 113, 113, .5); color: #fee2e2; |
| 230 | padding: 10px 18px; border-radius: 12px; font-size: 13px; z-index: 180; max-width: 70vw; |
| 231 | opacity: 0; pointer-events: none; transition: .25s; |
| 232 | } |
| 233 | .toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); } |
| 234 | |
| 235 | @media (max-width: 980px) { |
| 236 | .speaker-main { grid-template-columns: 1fr; overflow-y: auto; } |
| 237 | .side { overflow: visible; flex-direction: row; flex-wrap: wrap; } |
| 238 | .side .card { flex: 1; min-width: 160px; } |
| 239 | .notes-card { min-height: 240px; } |
| 240 | .console-card { height: 230px; } |
| 241 | .head-actions .label { display: none; } |
| 242 | .window-remote-stage { max-height: 52vh; } |
| 243 | .window-remote-card { padding: 10px; } |
| 244 | } |
| 245 | @media (max-width: 700px) { |
| 246 | .speaker-head { flex-wrap: wrap; row-gap: 8px; padding: 10px 12px; } |
| 247 | .brand { font-size: 14px; } |
| 248 | .brand span { max-width: 42vw; } |
| 249 | .head-meta { gap: 10px; } |
| 250 | .side { flex-direction: column; flex-wrap: nowrap; } |
| 251 | .side .card { flex: 0 0 auto; min-width: 0; } |
| 252 | .speaker-main { padding: 10px; gap: 10px; } |
| 253 | .notes-card { padding: 16px 18px; min-height: 200px; } |
| 254 | .notes-body { font-size: 19px; } |
| 255 | .console-card { height: 210px; padding: 10px 11px; } |
| 256 | .console-meta b { font-size: 12px; } |
| 257 | .controls { padding: 10px 12px; gap: 9px; } |
| 258 | .controls .nav { padding: 11px 16px; font-size: 13px; } |
| 259 | } |
| 260 | |
| 261 | body { background: #101014 url('/img/bipfr-bg.png') center / cover fixed no-repeat; } |
| 262 | .speaker-head { background: rgba(30, 30, 30, .62); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); } |
| 263 | .notes-card, .console-card, .side .card { background: rgba(20, 20, 25, .6); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-color: rgba(255,255,255,.08); } |
| 264 | .brand-mark { width: 12px; height: 12px; border-radius: 4px; background: #4cc2ff; box-shadow: 0 0 10px rgba(76,194,255,.7); display: inline-block; flex-shrink: 0; } |
| 265 | button { touch-action: manipulation; } |
| 266 | @media (max-width: 700px) { |
| 267 | body.mode-speaker { overflow: auto; } |
| 268 | .speaker-head button, .controls button { min-height: 40px; } |
| 269 | .brand span { max-width: 52vw; } |
| 270 | } |
| 271 | |
| 272 | </style> |
| 273 | </head> |
| 274 | <body class="mode-audience"> |
| 275 | <!-- ============ РЕЖИМ ЗРИТЕЛЯ ============ --> |
| 276 | <div id="audience" class="mode audience"> |
| 277 | <div class="audience-frame" id="audience-frame"> |
| 278 | <div class="audience-progress" id="audience-progress"><div></div></div> |
| 279 | </div> |
| 280 | <div class="hud" id="hud"> |
| 281 | <span class="hud-title" id="a-title"></span> |
| 282 | <span class="hud-counter" id="a-counter">0 / 0</span> |
| 283 | <button id="a-exit" title="Выйти">×</button> |
| 284 | </div> |
| 285 | </div> |
| 286 | |
| 287 | <!-- ============ РЕЖИМ ДОКЛАДЧИКА ============ --> |
| 288 | <div id="speaker" class="mode speaker"> |
| 289 | <header class="speaker-head"> |
| 290 | <div class="brand"><span class="brand-mark"></span><span id="s-title">Загрузка…</span></div> |
| 291 | <div class="head-meta"> |
| 292 | <span class="live"><span class="dot"></span> LIVE</span> |
| 293 | <span class="timer" id="timer">00:00</span> |
| 294 | <span class="counter" id="s-counter">0 / 0</span> |
| 295 | </div> |
| 296 | <div class="head-actions"> |
| 297 | <button id="docs-link" title="Справочник Lua"><span class="label">Lua</span></button> |
| 298 | <button id="copy-link" title="Скопировать ссылку для зрителей"><span class="label">Зрителям</span></button> |
| 299 | <button id="open-audience" title="Открыть окно зрителя"><span class="label">Открыть</span></button> |
| 300 | <button class="icon" id="fullscreen" title="Полный экран">⤢</button> |
| 301 | <button class="icon" id="s-exit" title="Выйти">×</button> |
| 302 | </div> |
| 303 | </header> |
| 304 | |
| 305 | <main class="speaker-main"> |
| 306 | <div class="left-col"> |
| 307 | <section class="notes-card"> |
| 308 | <div class="card-label"> |
| 309 | Пометки докладчика |
| 310 | <span class="spacer"></span> |
| 311 | <span class="slide-pill" id="notes-slide">Слайд 1</span> |
| 312 | </div> |
| 313 | <div class="notes-body" id="s-notes"></div> |
| 314 | </section> |
| 315 | |
| 316 | <section class="console-card"> |
| 317 | <div class="card-label"> |
| 318 | Консоль команд |
| 319 | <span class="spacer"></span> |
| 320 | <span class="slide-pill" id="console-count">0</span> |
| 321 | <a href="docs.html" target="_blank" rel="noopener">Lua API</a> |
| 322 | </div> |
| 323 | <div class="console-list" id="console-list" tabindex="0"></div> |
| 324 | <div class="console-log" id="console-log"></div> |
| 325 | </section> |
| 326 | </div> |
| 327 | |
| 328 | <aside class="side"> |
| 329 | <div class="card"> |
| 330 | <div class="card-label">Текущий слайд</div> |
| 331 | <div class="preview-frame" id="current-preview"></div> |
| 332 | </div> |
| 333 | |
| 334 | <div class="card"> |
| 335 | <div class="card-label">Следующий</div> |
| 336 | <div class="preview-frame preview-next" id="next-preview"></div> |
| 337 | </div> |
| 338 | |
| 339 | <div class="card" id="window-card" hidden> |
| 340 | <div class="card-label"> |
| 341 | Окно Chrome |
| 342 | <span class="spacer"></span> |
| 343 | <button id="window-refresh" title="Обновить список окон" style="padding:2px 7px;font-size:11px;border-radius:6px;">↻</button> |
| 344 | </div> |
| 345 | <div class="window-select"> |
| 346 | <select id="window-select"></select> |
| 347 | </div> |
| 348 | <div id="window-list"></div> |
| 349 | <p class="window-hint" id="window-hint"></p> |
| 350 | </div> |
| 351 | |
| 352 | <div class="card" id="video-card" hidden> |
| 353 | <div class="card-label">Видео на слайде</div> |
| 354 | <div id="video-list"></div> |
| 355 | </div> |
| 356 | |
| 357 | <div class="card"> |
| 358 | <div class="card-label"> |
| 359 | Интерактив слайда |
| 360 | <span class="spacer"></span> |
| 361 | <span class="slide-pill">только докладчик</span> |
| 362 | </div> |
| 363 | <div class="interact-list" id="interact"></div> |
| 364 | </div> |
| 365 | |
| 366 | <div class="card audio-card"> |
| 367 | <div class="card-label">Звук</div> |
| 368 | <div class="audio-row"> |
| 369 | <span>Фон</span> |
| 370 | <input type="range" id="bgm-vol" min="0" max="100" step="1" value="50"> |
| 371 | <output id="bgm-out">50%</output> |
| 372 | </div> |
| 373 | <div class="audio-row"> |
| 374 | <span>Эффекты</span> |
| 375 | <input type="range" id="sfx-vol" min="0" max="100" step="1" value="80"> |
| 376 | <output id="sfx-out">80%</output> |
| 377 | </div> |
| 378 | <div class="music-state"> |
| 379 | <span class="music-name" id="music-name">Фоновая музыка не задана</span> |
| 380 | <button id="music-toggle" disabled>Включить</button> |
| 381 | </div> |
| 382 | </div> |
| 383 | |
| 384 | <div class="card viewers-card"> |
| 385 | <span>Зрителей</span> |
| 386 | <strong id="audience-count">0</strong> |
| 387 | </div> |
| 388 | </aside> |
| 389 | </main> |
| 390 | |
| 391 | <footer class="controls"> |
| 392 | <button id="prev" class="nav" disabled>← Назад</button> |
| 393 | <div class="dots" id="dots"></div> |
| 394 | <button id="next" class="nav" disabled>Вперёд →</button> |
| 395 | </footer> |
| 396 | </div> |
| 397 | |
| 398 | <button class="unlock-audio" id="unlock-audio" hidden>Включить звук</button> |
| 399 | |
| 400 | <div class="toast" id="toast"></div> |
| 401 | |
| 402 | <div class="overlay" id="overlay" hidden> |
| 403 | <div class="overlay-card"> |
| 404 | <h2 id="overlay-title">Демонстрация остановлена</h2> |
| 405 | <p id="overlay-text">Организатор завершил показ.</p> |
| 406 | <div style="display:flex;gap:8px;justify-content:center;flex-wrap:wrap"> |
| 407 | <button id="overlay-restart" class="restart-btn" hidden>Начать заново</button> |
| 408 | <button onclick="location.href = 'index.html'">На главную</button> |
| 409 | </div> |
| 410 | </div> |
| 411 | </div> |
| 412 | |
| 413 | <div class="window-remote" id="window-remote" hidden> |
| 414 | <div class="window-remote-card"> |
| 415 | <div class="window-remote-head"> |
| 416 | <span class="live"><span class="dot"></span> LIVE</span> |
| 417 | <h3 id="window-remote-title">Окно Chrome</h3> |
| 418 | <button id="window-remote-close" title="Закрыть">×</button> |
| 419 | </div> |
| 420 | <div class="window-remote-stage" id="window-remote-stage"> |
| 421 | <img id="window-remote-frame" alt=""> |
| 422 | <div class="remote-empty" id="window-remote-empty">Нажмите «Транслировать» в панели окна</div> |
| 423 | </div> |
| 424 | <div class="window-remote-keys"> |
| 425 | <button data-key="Escape">Esc</button> |
| 426 | <button data-key="Tab">Tab</button> |
| 427 | <button data-key="Enter">Enter</button> |
| 428 | <button data-key="Backspace">⌫</button> |
| 429 | <button data-key="ArrowLeft">←</button> |
| 430 | <button data-key="ArrowUp">↑</button> |
| 431 | <button data-key="ArrowDown">↓</button> |
| 432 | <button data-key="ArrowRight">→</button> |
| 433 | <button data-key="PageUp">PgUp</button> |
| 434 | <button data-key="PageDown">PgDn</button> |
| 435 | </div> |
| 436 | <div class="window-remote-text"> |
| 437 | <input id="window-remote-text" placeholder="Текст для ввода в окно…" autocomplete="off"> |
| 438 | <button id="window-remote-send">Ввести</button> |
| 439 | </div> |
| 440 | </div> |
| 441 | </div> |
| 442 | |
| 443 | <script src="vendor/fengari-web.js"></script> |
| 444 | <script src="js/lua-bridge.js"></script> |
| 445 | <script src="js/slide-view.js"></script> |
| 446 | <script src="js/audio-controller.js"></script> |
| 447 | <script> |
| 448 | const params = new URLSearchParams(location.search); |
| 449 | const presentationId = params.get('id'); |
| 450 | const mode = params.get('mode') === 'speaker' ? 'speaker' : 'audience'; |
| 451 | document.body.className = `mode-${mode}`; |
| 452 | |
| 453 | const state = { |
| 454 | title: '', |
| 455 | slides: [], |
| 456 | slideIndex: 0, |
| 457 | variables: {}, |
| 458 | vars: {}, |
| 459 | music: { src: '', volume: 0.5 }, |
| 460 | lua: '', |
| 461 | commands: [], |
| 462 | commandsLoaded: false, |
| 463 | graph: { positions: {}, scripts: [], audios: [], variables: [], links: [], jumps: {} }, |
| 464 | media: {}, |
| 465 | windowStates: {}, |
| 466 | windowFrames: {}, |
| 467 | windowTargets: [], |
| 468 | windowEndpoint: '', |
| 469 | activeWindow: null, |
| 470 | consoleIndex: 0, |
| 471 | consoleLines: [], |
| 472 | ready: false, |
| 473 | ended: false, |
| 474 | startedAt: Date.now(), |
| 475 | }; |
| 476 | |
| 477 | let ws = null; |
| 478 | let reconnecting = false; |
| 479 | let luaRuntime = null; |
| 480 | let lastVarsSent = ''; |
| 481 | let lastSlideIndex = null; |
| 482 | |
| 483 | // ---------- Lua-анимации: слои перехода и Web Animations ---------- |
| 484 | const luaLayers = { in: null, out: null }; |
| 485 | let outRemoveTimer = null; |
| 486 | let luaAnimEnd = 0; |
| 487 | |
| 488 | function escapeSelector(value) { |
| 489 | return window.CSS && CSS.escape ? CSS.escape(value) : String(value); |
| 490 | } |
| 491 | |
| 492 | function resolveAnimTarget(target) { |
| 493 | const key = String(target == null ? '' : target); |
| 494 | if (key === 'in') return luaLayers.in || audienceFrame.querySelector('.sv-root'); |
| 495 | if (key === 'out') return luaLayers.out; |
| 496 | const root = luaLayers.in || audienceFrame.querySelector('.sv-root'); |
| 497 | if (key === '' || key === 'slide') return root; |
| 498 | if (root) { |
| 499 | const inner = root.querySelector(`[data-el="${escapeSelector(key)}"]`); |
| 500 | if (inner) return inner; |
| 501 | } |
| 502 | return audienceFrame.querySelector(`[data-el="${escapeSelector(key)}"]`); |
| 503 | } |
| 504 | |
| 505 | // Кадры из Lua: { opacity = {0, 1}, y = {6, 0}, scale = 1.2 } → keyframes WAAPI. |
| 506 | // x/y — относительные смещения в % от размера холста (transform), w/h — абсолютные %. |
| 507 | function buildKeyframes(frames, rootEl) { |
| 508 | const entries = Object.entries(frames || {}).filter(([, value]) => value !== null && value !== undefined); |
| 509 | if (!entries.length) return []; |
| 510 | const norm = entries.map(([prop, value]) => [prop, Array.isArray(value) ? value : [value]]); |
| 511 | const count = Math.max(...norm.map(([, values]) => values.length)); |
| 512 | const baseW = (rootEl && rootEl.clientWidth) || 1280; |
| 513 | const baseH = (rootEl && rootEl.clientHeight) || 720; |
| 514 | const keys = []; |
| 515 | for (let i = 0; i < count; i += 1) { |
| 516 | const key = {}; |
| 517 | const parts = []; |
| 518 | for (const [prop, values] of norm) { |
| 519 | const raw = values[Math.min(i, values.length - 1)]; |
| 520 | const n = Number(raw); |
| 521 | if (prop === 'opacity') key.opacity = Number.isFinite(n) ? n : raw; |
| 522 | else if (prop === 'x') parts.push(`translateX(${Number.isFinite(n) ? (n / 100) * baseW : 0}px)`); |
| 523 | else if (prop === 'y') parts.push(`translateY(${Number.isFinite(n) ? (n / 100) * baseH : 0}px)`); |
| 524 | else if (prop === 'w') key.width = `${n}%`; |
| 525 | else if (prop === 'h') key.height = `${n}%`; |
| 526 | else if (prop === 'scale') parts.push(`scale(${Number.isFinite(n) ? n : 1})`); |
| 527 | else if (prop === 'rotate') parts.push(`rotate(${Number.isFinite(n) ? n : 0}deg)`); |
| 528 | else key[prop] = raw; |
| 529 | } |
| 530 | if (parts.length) key.transform = parts.join(' '); |
| 531 | keys.push(key); |
| 532 | } |
| 533 | return keys; |
| 534 | } |
| 535 | |
| 536 | function animateTarget(target, frames, opts = {}) { |
| 537 | const node = resolveAnimTarget(target); |
| 538 | if (!node || typeof node.animate !== 'function') return; |
| 539 | const rootEl = node.closest ? (node.closest('.sv-root') || node) : node; |
| 540 | const keyframes = buildKeyframes(frames, rootEl); |
| 541 | if (!keyframes.length) return; |
| 542 | const duration = Math.min(Math.max(Number(opts.duration) || 500, 16), 10000); |
| 543 | const delay = Math.min(Math.max(Number(opts.delay) || 0, 0), 10000); |
| 544 | const fill = ['forwards', 'backwards', 'both'].includes(opts.fill) ? opts.fill : 'both'; |
| 545 | const animation = node.animate(keyframes, { |
| 546 | duration, |
| 547 | delay, |
| 548 | easing: String(opts.easing || 'cubic-bezier(.2, .7, .3, 1)'), |
| 549 | fill, |
| 550 | }); |
| 551 | node._luaAnims = node._luaAnims || []; |
| 552 | node._luaAnims.push(animation); |
| 553 | luaAnimEnd = Math.max(luaAnimEnd, Date.now() + duration + delay + 60); |
| 554 | if (animation.finished && typeof animation.finished.catch === 'function') animation.finished.catch(() => {}); |
| 555 | } |
| 556 | |
| 557 | function clearAnimTarget(target) { |
| 558 | const node = resolveAnimTarget(target); |
| 559 | if (!node) return; |
| 560 | (node._luaAnims || []).forEach((item) => { |
| 561 | try { item.cancel(); } catch (error) { /* уже завершена */ } |
| 562 | }); |
| 563 | node._luaAnims = []; |
| 564 | } |
| 565 | |
| 566 | function transitionNodeFor(slide) { |
| 567 | if (!slide || !luaRuntime) return null; |
| 568 | const list = (state.graph && state.graph.transitions) || []; |
| 569 | return list.find((node) => node.slideId === slide.id && String(node.code || '').trim()) || null; |
| 570 | } |
| 571 | |
| 572 | function runEnterAnims(slide) { |
| 573 | if (!luaRuntime || !slide) return; |
| 574 | const list = ((state.graph && state.graph.anims) || []) |
| 575 | .filter((node) => node.slideId === slide.id && String(node.code || '').trim()); |
| 576 | list.forEach((node) => { |
| 577 | state.vars = luaRuntime.run(node.code, `анимация «${node.name || 'без названия'}»`); |
| 578 | }); |
| 579 | if (list.length) syncVars(); |
| 580 | } |
| 581 | |
| 582 | function findPluginInstance(id) { |
| 583 | return ((state.graph && state.graph.plugins) || []).find((node) => node.id === id) || null; |
| 584 | } |
| 585 | |
| 586 | // Исполняет ноду плагина: модуль-снимок + вызов выбранной функции. |
| 587 | // Функция может быть локальной — вызов дописывается в тот же чанк. |
| 588 | function runPluginNode(node) { |
| 589 | if (!luaRuntime || !node || !node.fn || !String(node.code || '').trim()) return; |
| 590 | const args = String(node.args || '').trim(); |
| 591 | const code = `${node.code}\n\nreturn ${node.fn}(${args})`; |
| 592 | state.vars = luaRuntime.run(code, `плагин «${node.name || node.fn}»`); |
| 593 | syncVars(); |
| 594 | } |
| 595 | |
| 596 | // Проходит цепь от выхода слайда через переходы, анимации и плагины. |
| 597 | // Переходы и анимации слайда исполняются отдельно, здесь — только ноды плагинов. |
| 598 | function runChainNodes(fromSlide, port) { |
| 599 | if (mode !== 'speaker' || !luaRuntime || !fromSlide) return; |
| 600 | const links = (state.graph && state.graph.links) || []; |
| 601 | const outgoing = new Map(); |
| 602 | links.forEach((link) => { |
| 603 | const key = `${link.from.kind}|${link.from.id}`; |
| 604 | if (!outgoing.has(key)) outgoing.set(key, []); |
| 605 | outgoing.get(key).push(link); |
| 606 | }); |
| 607 | let current = (outgoing.get(`slide|${fromSlide.id}`) || []).find((link) => link.from.port === port); |
| 608 | const visited = new Set(); |
| 609 | for (let step = 0; current && step < 32; step += 1) { |
| 610 | const to = current.to; |
| 611 | if (!to || to.kind === 'slide') break; |
| 612 | const key = `${to.kind}|${to.id}`; |
| 613 | if (visited.has(key)) break; |
| 614 | visited.add(key); |
| 615 | if (to.kind === 'plugin') runPluginNode(findPluginInstance(to.id)); |
| 616 | current = (outgoing.get(key) || []).find((link) => link.from.port === 'out'); |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | const $ = (id) => document.getElementById(id); |
| 621 | const audienceFrame = $('audience-frame'); |
| 622 | const currentPreview = $('current-preview'); |
| 623 | const nextPreview = $('next-preview'); |
| 624 | const interactEl = $('interact'); |
| 625 | const notesEl = $('s-notes'); |
| 626 | const dotsEl = $('dots'); |
| 627 | const prevBtn = $('prev'); |
| 628 | const nextBtn = $('next'); |
| 629 | const timerEl = $('timer'); |
| 630 | const audienceCountEl = $('audience-count'); |
| 631 | const overlay = $('overlay'); |
| 632 | const unlockBtn = $('unlock-audio'); |
| 633 | const toastEl = $('toast'); |
| 634 | const bgmSlider = $('bgm-vol'); |
| 635 | const sfxSlider = $('sfx-vol'); |
| 636 | const musicToggle = $('music-toggle'); |
| 637 | const musicName = $('music-name'); |
| 638 | const consoleListEl = $('console-list'); |
| 639 | const consoleLogEl = $('console-log'); |
| 640 | const windowCard = $('window-card'); |
| 641 | const windowListEl = $('window-list'); |
| 642 | const windowSelectEl = $('window-select'); |
| 643 | const windowHintEl = $('window-hint'); |
| 644 | const videoCard = $('video-card'); |
| 645 | const videoListEl = $('video-list'); |
| 646 | const windowRemote = $('window-remote'); |
| 647 | const windowRemoteFrame = $('window-remote-frame'); |
| 648 | const windowRemoteEmpty = $('window-remote-empty'); |
| 649 | const windowRemoteTitle = $('window-remote-title'); |
| 650 | |
| 651 | // ---------- Аудио ---------- |
| 652 | const audio = window.createAudioController({ |
| 653 | onBlocked: () => { |
| 654 | unlockBtn.hidden = false; |
| 655 | }, |
| 656 | onState: () => updateAudioPanel(), |
| 657 | onEnded: () => { |
| 658 | if (mode === 'speaker') renderSpeaker(); |
| 659 | }, |
| 660 | }); |
| 661 | |
| 662 | function clamp01(value) { |
| 663 | return Math.max(0, Math.min(1, Number(value) || 0)); |
| 664 | } |
| 665 | |
| 666 | function currentSlide() { |
| 667 | return state.slides[state.slideIndex] || { elements: [], notes: '', background: {} }; |
| 668 | } |
| 669 | |
| 670 | function isAudioPlaying(id) { |
| 671 | return audio.getPlayingEffectIds().includes(id); |
| 672 | } |
| 673 | |
| 674 | function findAudio(id) { |
| 675 | if (!id) return null; |
| 676 | for (const slide of state.slides) { |
| 677 | const found = (slide.elements || []).find((el) => el.type === 'audio' && el.id === id); |
| 678 | if (found) return found; |
| 679 | } |
| 680 | return null; |
| 681 | } |
| 682 | |
| 683 | function sendAudio(command) { |
| 684 | audio.applyCommand(command); |
| 685 | if (ws && ws.readyState === WebSocket.OPEN) { |
| 686 | ws.send(JSON.stringify({ type: 'audio', command })); |
| 687 | } |
| 688 | updateAudioPanel(); |
| 689 | if (['play', 'stop', 'music', 'musicStop'].includes(command.action)) refreshSlides(); |
| 690 | } |
| 691 | |
| 692 | function playAudioById(id) { |
| 693 | const element = findAudio(id); |
| 694 | if (!element) { |
| 695 | showToast(`Аудио ${id} не найдено`); |
| 696 | return; |
| 697 | } |
| 698 | sendAudio({ action: 'play', id: element.id, src: element.src, loop: !!element.loop, volume: element.volume }); |
| 699 | } |
| 700 | |
| 701 | function stopAudioById(id) { |
| 702 | sendAudio({ action: 'stop', id: id || '*' }); |
| 703 | } |
| 704 | |
| 705 | function startMusic(src) { |
| 706 | const nextSrc = src || audio.getState().musicSrc || state.music.src; |
| 707 | if (!nextSrc) { |
| 708 | showToast('Не задан источник фоновой музыки (настройки презентации)'); |
| 709 | return; |
| 710 | } |
| 711 | sendAudio({ action: 'music', src: nextSrc, play: true }); |
| 712 | } |
| 713 | |
| 714 | function updateAudioPanel() { |
| 715 | const snapshot = audio.getState(); |
| 716 | if (document.activeElement !== bgmSlider) { |
| 717 | bgmSlider.value = String(Math.round(snapshot.bgm * 100)); |
| 718 | } |
| 719 | if (document.activeElement !== sfxSlider) { |
| 720 | sfxSlider.value = String(Math.round(snapshot.sfx * 100)); |
| 721 | } |
| 722 | $('bgm-out').textContent = `${Math.round(snapshot.bgm * 100)}%`; |
| 723 | $('sfx-out').textContent = `${Math.round(snapshot.sfx * 100)}%`; |
| 724 | const src = snapshot.musicSrc || state.music.src; |
| 725 | musicName.textContent = src ? (src.split('/').pop() || src).slice(0, 40) : 'Фоновая музыка не задана'; |
| 726 | musicName.title = src || ''; |
| 727 | musicToggle.disabled = !src && !snapshot.musicPlaying; |
| 728 | musicToggle.classList.toggle('on', snapshot.musicPlaying); |
| 729 | musicToggle.textContent = snapshot.musicPlaying ? 'Пауза' : 'Включить'; |
| 730 | } |
| 731 | |
| 732 | // ---------- Видео ---------- |
| 733 | function findSlideElements(type) { |
| 734 | const result = []; |
| 735 | state.slides.forEach((slide, index) => { |
| 736 | (slide.elements || []).forEach((element) => { |
| 737 | if (element.type === type) result.push({ element, slide, index }); |
| 738 | }); |
| 739 | }); |
| 740 | return result; |
| 741 | } |
| 742 | |
| 743 | function applyMediaCommand(command) { |
| 744 | if (!command || !command.elementId) return; |
| 745 | state.media[command.elementId] = command; |
| 746 | document.querySelectorAll(`video[data-media-id="${command.elementId}"]`).forEach((video) => { |
| 747 | video._applyingRemote = true; |
| 748 | try { |
| 749 | if (command.action === 'videoPlay') video.play().catch(() => {}); |
| 750 | else if (command.action === 'videoPause') video.pause(); |
| 751 | else if (command.action === 'videoRestart') { |
| 752 | video.currentTime = 0; |
| 753 | video.play().catch(() => {}); |
| 754 | } else if (command.action === 'videoSeek') { |
| 755 | video.currentTime = Number(command.time) || 0; |
| 756 | } |
| 757 | } catch (error) { |
| 758 | /* видео ещё не готово */ |
| 759 | } |
| 760 | setTimeout(() => { |
| 761 | video._applyingRemote = false; |
| 762 | }, 80); |
| 763 | }); |
| 764 | } |
| 765 | |
| 766 | function sendMedia(command) { |
| 767 | applyMediaCommand(command); |
| 768 | if (mode === 'speaker' && ws && ws.readyState === WebSocket.OPEN) { |
| 769 | ws.send(JSON.stringify({ type: 'media', command })); |
| 770 | } |
| 771 | } |
| 772 | |
| 773 | function videoEvent(element, type, video) { |
| 774 | if (mode !== 'speaker') return; |
| 775 | if (type === 'play') sendMedia({ action: 'videoPlay', elementId: element.id, time: video.currentTime }); |
| 776 | else if (type === 'pause') sendMedia({ action: 'videoPause', elementId: element.id, time: video.currentTime }); |
| 777 | else if (type === 'seek') sendMedia({ action: 'videoSeek', elementId: element.id, time: video.currentTime }); |
| 778 | } |
| 779 | |
| 780 | function renderVideoPanel() { |
| 781 | videoCard.hidden = mode !== 'speaker'; |
| 782 | const videos = currentSlide().elements ? currentSlide().elements.filter((el) => el.type === 'video') : []; |
| 783 | videoCard.hidden = mode !== 'speaker' || !videos.length; |
| 784 | if (videoCard.hidden) return; |
| 785 | videoListEl.innerHTML = ''; |
| 786 | videos.forEach((element) => { |
| 787 | const row = document.createElement('div'); |
| 788 | row.className = 'video-row'; |
| 789 | row.innerHTML = `<div class="video-meta"><b></b><small></small></div> |
| 790 | <button data-media="videoPlay">Пуск</button> |
| 791 | <button data-media="videoPause">Пауза</button> |
| 792 | <button data-media="videoRestart">↺</button>`; |
| 793 | row.querySelector('b').textContent = element.label || (element.src ? element.src.split('/').pop() : 'Видео'); |
| 794 | row.querySelector('small').textContent = element.src ? 'синхронизируется со зрителями' : 'не задан источник'; |
| 795 | row.querySelectorAll('[data-media]').forEach((button) => { |
| 796 | button.disabled = !element.src; |
| 797 | button.addEventListener('click', () => { |
| 798 | sendMedia({ action: button.dataset.media, elementId: element.id }); |
| 799 | }); |
| 800 | }); |
| 801 | videoListEl.appendChild(row); |
| 802 | }); |
| 803 | } |
| 804 | |
| 805 | // ---------- Окно Chrome ---------- |
| 806 | function windowElements() { |
| 807 | return currentSlide().elements ? currentSlide().elements.filter((el) => el.type === 'window') : []; |
| 808 | } |
| 809 | |
| 810 | function windowState(id) { |
| 811 | return state.windowStates[id] || { elementId: id, active: false, targetTitle: '', error: '' }; |
| 812 | } |
| 813 | |
| 814 | function sendWindow(type, payload = {}) { |
| 815 | if (mode !== 'speaker' || !ws || ws.readyState !== WebSocket.OPEN) return false; |
| 816 | ws.send(JSON.stringify({ type, ...payload })); |
| 817 | return true; |
| 818 | } |
| 819 | |
| 820 | function dataUrl(data) { |
| 821 | if (!data) return ''; |
| 822 | return /^data:/.test(data) ? data : `data:image/jpeg;base64,${data}`; |
| 823 | } |
| 824 | |
| 825 | function updateWindowFrameDom(elementId, data) { |
| 826 | state.windowFrames[elementId] = data; |
| 827 | const src = dataUrl(data); |
| 828 | document.querySelectorAll(`.sv-window[data-window-id="${elementId}"]`).forEach((wrap) => { |
| 829 | const img = wrap.querySelector('img.sv-window-frame'); |
| 830 | if (!img) return; |
| 831 | const placeholder = wrap.querySelector('.sv-window-placeholder'); |
| 832 | if (placeholder) placeholder.remove(); |
| 833 | img.src = src; |
| 834 | wrap.dataset.live = '1'; |
| 835 | if (!wrap.querySelector('.sv-window-live')) { |
| 836 | const badge = document.createElement('span'); |
| 837 | badge.className = 'sv-window-live'; |
| 838 | badge.innerHTML = '<i></i>LIVE'; |
| 839 | wrap.appendChild(badge); |
| 840 | } |
| 841 | }); |
| 842 | if (state.activeWindow === elementId) { |
| 843 | windowRemoteFrame.src = src; |
| 844 | windowRemoteEmpty.hidden = true; |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | function renderWindowPanel() { |
| 849 | const windows = windowElements(); |
| 850 | windowCard.hidden = mode !== 'speaker' || !windows.length; |
| 851 | if (windowCard.hidden) return; |
| 852 | |
| 853 | const options = state.windowTargets.map((target) => |
| 854 | `<option value="${String(target.id).replace(/"/g, '"')}">${String(target.title || target.url || target.id).replace(/[<>&]/g, '')}</option>` |
| 855 | ); |
| 856 | const currentTarget = windows[0] && windows[0].targetId; |
| 857 | windowSelectEl.innerHTML = options.length |
| 858 | ? options.join('') |
| 859 | : '<option value="">— нет доступных окон —</option>'; |
| 860 | if (currentTarget && state.windowTargets.some((t) => t.id === currentTarget)) { |
| 861 | windowSelectEl.value = currentTarget; |
| 862 | } |
| 863 | windowHintEl.innerHTML = state.windowTargets.length |
| 864 | ? 'Клик по трансляции в слайде управляет окном. <code>Пульт</code> — клавиши и ввод текста.' |
| 865 | : `Chrome не найден на <code>${state.windowEndpoint || '127.0.0.1:9222'}</code>. Запустите браузер с <code>--remote-debugging-port=9222</code>.`; |
| 866 | |
| 867 | windowListEl.innerHTML = ''; |
| 868 | windows.forEach((element) => { |
| 869 | const info = windowState(element.id); |
| 870 | const row = document.createElement('div'); |
| 871 | row.className = 'window-row'; |
| 872 | row.innerHTML = `<span class="window-status${info.active ? ' on' : ''}"></span> |
| 873 | <div class="window-meta"><b></b><small></small></div> |
| 874 | <button data-window-act="start" title="Транслировать">Пуск</button> |
| 875 | <button data-window-act="remote" title="Пульт управления">Пульт</button> |
| 876 | <button data-window-act="stop" title="Остановить">Стоп</button>`; |
| 877 | row.querySelector('b').textContent = element.label || 'Окно Chrome'; |
| 878 | row.querySelector('small').textContent = info.error |
| 879 | ? info.error.slice(0, 60) |
| 880 | : info.active |
| 881 | ? (info.targetTitle || 'трансляция активна') |
| 882 | : 'не запущено'; |
| 883 | row.querySelectorAll('[data-window-act]').forEach((button) => { |
| 884 | button.addEventListener('click', () => { |
| 885 | const act = button.dataset.windowAct; |
| 886 | if (act === 'start') { |
| 887 | const targetId = windowSelectEl.value || element.targetId || ''; |
| 888 | if (!sendWindow('window-start', { elementId: element.id, targetId })) { |
| 889 | showToast('Нет соединения с сервером'); |
| 890 | } |
| 891 | } else if (act === 'stop') { |
| 892 | sendWindow('window-stop', { elementId: element.id }); |
| 893 | } else if (act === 'remote') { |
| 894 | openWindowRemote(element.id); |
| 895 | } |
| 896 | }); |
| 897 | }); |
| 898 | windowListEl.appendChild(row); |
| 899 | }); |
| 900 | } |
| 901 | |
| 902 | function openWindowRemote(elementId) { |
| 903 | state.activeWindow = elementId; |
| 904 | const element = windowElements().find((item) => item.id === elementId); |
| 905 | windowRemoteTitle.textContent = (element && element.label) || (windowState(elementId).targetTitle) || 'Окно Chrome'; |
| 906 | const data = state.windowFrames[elementId]; |
| 907 | windowRemoteFrame.src = data ? dataUrl(data) : ''; |
| 908 | windowRemoteEmpty.hidden = !!data; |
| 909 | windowRemote.hidden = false; |
| 910 | } |
| 911 | |
| 912 | function closeWindowRemote() { |
| 913 | windowRemote.hidden = true; |
| 914 | state.activeWindow = null; |
| 915 | } |
| 916 | |
| 917 | function sendWindowInput(input) { |
| 918 | if (!state.activeWindow) return; |
| 919 | sendWindow('window-input', { elementId: state.activeWindow, input }); |
| 920 | } |
| 921 | |
| 922 | function maybeAutoStartWindows() { |
| 923 | if (mode !== 'speaker') return; |
| 924 | windowElements().forEach((element) => { |
| 925 | if (!state.windowStates[element.id]) { |
| 926 | state.windowStates[element.id] = { elementId: element.id, active: false, targetTitle: '', error: '' }; |
| 927 | } |
| 928 | if (element.autoStart && !state.windowStates[element.id].active) { |
| 929 | sendWindow('window-start', { elementId: element.id, targetId: element.targetId || '' }); |
| 930 | } |
| 931 | }); |
| 932 | } |
| 933 | |
| 934 | // ---------- Консоль команд ---------- |
| 935 | function logConsole(line) { |
| 936 | const time = new Date(); |
| 937 | const stamp = `${String(time.getHours()).padStart(2, '0')}:${String(time.getMinutes()).padStart(2, '0')}:${String(time.getSeconds()).padStart(2, '0')}`; |
| 938 | state.consoleLines.push(`${stamp} ${line}`); |
| 939 | if (state.consoleLines.length > 60) state.consoleLines.shift(); |
| 940 | consoleLogEl.textContent = state.consoleLines.slice(-6).join('\n'); |
| 941 | consoleLogEl.scrollTop = consoleLogEl.scrollHeight; |
| 942 | } |
| 943 | |
| 944 | function renderConsole() { |
| 945 | if (mode !== 'speaker') return; |
| 946 | $('console-count').textContent = String(state.commands.length); |
| 947 | consoleListEl.innerHTML = ''; |
| 948 | if (!state.commands.length) { |
| 949 | consoleListEl.innerHTML = '<div class="console-empty">Список команд пуст. Добавьте их в редакторе: «Команды». Каждая команда — это Lua-код, который запускается у докладчика.</div>'; |
| 950 | return; |
| 951 | } |
| 952 | state.commands.forEach((command, index) => { |
| 953 | const item = document.createElement('button'); |
| 954 | item.className = 'console-item' + (index === state.consoleIndex ? ' active' : ''); |
| 955 | item.innerHTML = `<span class="console-idx">${index + 1}</span> |
| 956 | <span class="console-meta"><b></b><small></small></span> |
| 957 | <span class="run">▶</span>`; |
| 958 | item.querySelector('b').textContent = command.label || 'Команда'; |
| 959 | item.querySelector('small').textContent = command.description || 'Lua-код'; |
| 960 | item.addEventListener('click', () => { |
| 961 | state.consoleIndex = index; |
| 962 | renderConsole(); |
| 963 | runCommand(command); |
| 964 | }); |
| 965 | consoleListEl.appendChild(item); |
| 966 | }); |
| 967 | } |
| 968 | |
| 969 | function runCommand(command) { |
| 970 | if (mode !== 'speaker' || !command) return; |
| 971 | logConsole(`▸ ${command.label || 'Команда'}`); |
| 972 | if (!String(command.code || '').trim()) { |
| 973 | logConsole('пустой код команды'); |
| 974 | return; |
| 975 | } |
| 976 | runLua(command.code, `команда «${command.label || 'без названия'}»`); |
| 977 | } |
| 978 | |
| 979 | function setConsoleIndex(next) { |
| 980 | if (!state.commands.length) return; |
| 981 | const total = state.commands.length; |
| 982 | state.consoleIndex = ((next % total) + total) % total; |
| 983 | renderConsole(); |
| 984 | const items = consoleListEl.querySelectorAll('.console-item'); |
| 985 | if (items[state.consoleIndex]) items[state.consoleIndex].scrollIntoView({ block: 'nearest' }); |
| 986 | } |
| 987 | |
| 988 | // ---------- Рендер ---------- |
| 989 | function renderAudience(animate) { |
| 990 | const slide = currentSlide(); |
| 991 | $('a-title').textContent = state.title || 'Презентация'; |
| 992 | $('a-counter').textContent = `${state.slides.length ? state.slideIndex + 1 : 0} / ${state.slides.length}`; |
| 993 | const progress = state.slides.length ? ((state.slideIndex + 1) / state.slides.length) * 100 : 0; |
| 994 | $('audience-progress').firstElementChild.style.width = `${progress}%`; |
| 995 | |
| 996 | const luaTrans = animate ? transitionNodeFor(slide) : null; |
| 997 | if (luaTrans) { |
| 998 | // Lua-переход: старый слайд остаётся слоем «out», новый — «in»; скрипт управляет обоими. |
| 999 | const oldRoot = audienceFrame.querySelector('.sv-root'); |
| 1000 | if (oldRoot) oldRoot.remove(); |
| 1001 | SlideView.render(audienceFrame, slide, { |
| 1002 | variables: state.vars, |
| 1003 | animate: false, |
| 1004 | isAudioPlaying, |
| 1005 | windowFrames: state.windowFrames, |
| 1006 | }); |
| 1007 | const newRoot = audienceFrame.querySelector('.sv-root'); |
| 1008 | luaLayers.in = newRoot; |
| 1009 | luaLayers.out = oldRoot || null; |
| 1010 | if (oldRoot) { |
| 1011 | oldRoot.classList.add('sv-layer-out'); |
| 1012 | audienceFrame.appendChild(oldRoot); |
| 1013 | } |
| 1014 | clearTimeout(outRemoveTimer); |
| 1015 | luaAnimEnd = 0; |
| 1016 | state.vars = luaRuntime.run(luaTrans.code, `переход на слайд ${state.slideIndex + 1}`); |
| 1017 | syncVars(); |
| 1018 | const ttl = Math.max(900, Math.min(luaAnimEnd - Date.now() + 250, 8000)); |
| 1019 | outRemoveTimer = setTimeout(() => { |
| 1020 | if (luaLayers.out) { |
| 1021 | luaLayers.out.remove(); |
| 1022 | luaLayers.out = null; |
| 1023 | } |
| 1024 | }, ttl); |
| 1025 | } else { |
| 1026 | if (luaLayers.out) { |
| 1027 | luaLayers.out.remove(); |
| 1028 | luaLayers.out = null; |
| 1029 | } |
| 1030 | SlideView.render(audienceFrame, slide, { |
| 1031 | variables: state.vars, |
| 1032 | animate: !!animate, |
| 1033 | isAudioPlaying, |
| 1034 | windowFrames: state.windowFrames, |
| 1035 | }); |
| 1036 | luaLayers.in = audienceFrame.querySelector('.sv-root'); |
| 1037 | } |
| 1038 | if (animate) runEnterAnims(slide); |
| 1039 | } |
| 1040 | |
| 1041 | function renderSpeaker() { |
| 1042 | const slide = currentSlide(); |
| 1043 | const total = state.slides.length; |
| 1044 | const counterText = `${total ? state.slideIndex + 1 : 0} / ${total}`; |
| 1045 | |
| 1046 | $('s-title').textContent = state.title || 'Презентация'; |
| 1047 | $('s-counter').textContent = counterText; |
| 1048 | $('notes-slide').textContent = `Слайд ${state.slideIndex + 1} из ${total}`; |
| 1049 | notesEl.textContent = slide.notes || ''; |
| 1050 | |
| 1051 | SlideView.render(currentPreview, slide, { |
| 1052 | variables: state.vars, |
| 1053 | isAudioPlaying, |
| 1054 | onAction: executeAction, |
| 1055 | windowFrames: state.windowFrames, |
| 1056 | onWindowInput: (element, input) => sendWindow('window-input', { elementId: element.id, input }), |
| 1057 | onVideoEvent: videoEvent, |
| 1058 | }); |
| 1059 | const nextIndex = stepIndex(1); |
| 1060 | SlideView.render(nextPreview, state.slides[nextIndex] || { elements: [] }, { |
| 1061 | variables: state.vars, |
| 1062 | windowFrames: state.windowFrames, |
| 1063 | staticPreview: true, |
| 1064 | }); |
| 1065 | |
| 1066 | renderInteract(slide); |
| 1067 | renderDots(); |
| 1068 | renderVideoPanel(); |
| 1069 | renderWindowPanel(); |
| 1070 | |
| 1071 | const hasNext = jumpTarget(1) !== null; |
| 1072 | const hasPrev = jumpTarget(-1) !== null; |
| 1073 | prevBtn.disabled = state.ended || (!hasPrev && state.slideIndex <= 0); |
| 1074 | nextBtn.disabled = state.ended || (!hasNext && state.slideIndex >= total - 1); |
| 1075 | updateAudioPanel(); |
| 1076 | } |
| 1077 | |
| 1078 | function renderDots() { |
| 1079 | dotsEl.innerHTML = ''; |
| 1080 | state.slides.forEach((_, index) => { |
| 1081 | const button = document.createElement('button'); |
| 1082 | button.className = 'dot' + (index === state.slideIndex ? ' active' : ''); |
| 1083 | button.textContent = index + 1; |
| 1084 | button.disabled = state.ended; |
| 1085 | button.addEventListener('click', () => navigate(index)); |
| 1086 | dotsEl.appendChild(button); |
| 1087 | }); |
| 1088 | } |
| 1089 | |
| 1090 | function actionDescription(action) { |
| 1091 | if (!action) return 'без действия'; |
| 1092 | switch (action.type) { |
| 1093 | case 'go': return `переход → слайд ${Number(action.slideIndex) + 1}`; |
| 1094 | case 'next': return 'следующий слайд'; |
| 1095 | case 'prev': return 'предыдущий слайд'; |
| 1096 | case 'play': { |
| 1097 | const element = findAudio(action.audioId); |
| 1098 | return `аудио: ${element ? element.label || element.src : action.audioId || '—'}`; |
| 1099 | } |
| 1100 | case 'stop': return 'остановить аудио'; |
| 1101 | case 'lua': return 'Lua-скрипт'; |
| 1102 | default: return action.type; |
| 1103 | } |
| 1104 | } |
| 1105 | |
| 1106 | function renderInteract(slide) { |
| 1107 | interactEl.innerHTML = ''; |
| 1108 | const elements = slide.elements || []; |
| 1109 | const buttons = elements.filter((el) => el.type === 'button'); |
| 1110 | const audios = elements.filter((el) => el.type === 'audio'); |
| 1111 | |
| 1112 | if (!buttons.length && !audios.length) { |
| 1113 | interactEl.innerHTML = '<div class="interact-empty">На этом слайде нет кнопок и аудио.<br>Добавьте их в редакторе.</div>'; |
| 1114 | return; |
| 1115 | } |
| 1116 | |
| 1117 | buttons.forEach((element) => { |
| 1118 | const row = document.createElement('div'); |
| 1119 | row.className = 'interact-item'; |
| 1120 | row.innerHTML = ` |
| 1121 | <span class="interact-icon">▶</span> |
| 1122 | <div class="interact-meta"> |
| 1123 | <b></b> |
| 1124 | <small></small> |
| 1125 | </div> |
| 1126 | <button>Запустить</button>`; |
| 1127 | row.querySelector('b').textContent = element.label || 'Кнопка'; |
| 1128 | row.querySelector('small').textContent = actionDescription(element.action); |
| 1129 | row.querySelector('button').addEventListener('click', () => executeAction(element.action, element)); |
| 1130 | interactEl.appendChild(row); |
| 1131 | }); |
| 1132 | |
| 1133 | audios.forEach((element) => { |
| 1134 | const playing = isAudioPlaying(element.id); |
| 1135 | const row = document.createElement('div'); |
| 1136 | row.className = 'interact-item' + (playing ? ' playing' : ''); |
| 1137 | row.innerHTML = ` |
| 1138 | <span class="interact-icon">${playing ? 'играет' : 'звук'}</span> |
| 1139 | <div class="interact-meta"> |
| 1140 | <b></b> |
| 1141 | <small></small> |
| 1142 | </div> |
| 1143 | <button class="toggle">${playing ? 'Стоп' : 'Играть'}</button>`; |
| 1144 | row.querySelector('b').textContent = element.label || element.src || 'Аудио'; |
| 1145 | row.querySelector('small').textContent = element.visible === false ? 'скрытое аудио' : 'видно на слайде'; |
| 1146 | row.querySelector('button').addEventListener('click', () => { |
| 1147 | if (playing) stopAudioById(element.id); |
| 1148 | else playAudioById(element.id); |
| 1149 | }); |
| 1150 | interactEl.appendChild(row); |
| 1151 | }); |
| 1152 | } |
| 1153 | |
| 1154 | function refreshSlides() { |
| 1155 | renderAudience(false); |
| 1156 | if (mode === 'speaker') renderSpeaker(); |
| 1157 | } |
| 1158 | |
| 1159 | // ---------- Lua ---------- |
| 1160 | function initLuaRuntime() { |
| 1161 | if (!window.createLuaRuntime) { |
| 1162 | console.warn('Lua runtime недоступен'); |
| 1163 | return; |
| 1164 | } |
| 1165 | luaRuntime = window.createLuaRuntime({ |
| 1166 | vars: state.vars, |
| 1167 | go: (index) => navigate(index), |
| 1168 | next: () => go(1), |
| 1169 | prev: () => go(-1), |
| 1170 | play: (id) => playAudioById(id), |
| 1171 | stop: (id) => stopAudioById(id), |
| 1172 | volume: (id, value) => sendAudio({ action: 'effectVolume', id, volume: clamp01(value) }), |
| 1173 | music: (src) => startMusic(src), |
| 1174 | musicPlay: () => startMusic(), |
| 1175 | musicStop: () => sendAudio({ action: 'musicStop' }), |
| 1176 | musicVolume: (value) => { |
| 1177 | const snapshot = audio.getState(); |
| 1178 | sendAudio({ action: 'volumes', bgm: clamp01(value), sfx: snapshot.sfx }); |
| 1179 | }, |
| 1180 | videoPlay: (id) => sendMedia({ action: 'videoPlay', elementId: id }), |
| 1181 | videoPause: (id) => sendMedia({ action: 'videoPause', elementId: id }), |
| 1182 | videoRestart: (id) => sendMedia({ action: 'videoRestart', elementId: id }), |
| 1183 | videoSeek: (id, seconds) => sendMedia({ action: 'videoSeek', elementId: id, time: Number(seconds) || 0 }), |
| 1184 | currentSlide: () => state.slideIndex + 1, |
| 1185 | animate: (target, frames, opts) => animateTarget(target, frames, opts), |
| 1186 | animateClear: (target) => clearAnimTarget(target), |
| 1187 | log: (message) => { |
| 1188 | console.log('[lua]', message); |
| 1189 | logConsole(String(message)); |
| 1190 | }, |
| 1191 | error: (message) => { |
| 1192 | console.error('[lua]', message); |
| 1193 | logConsole(`Ошибка Lua: ${message}`); |
| 1194 | showToast(message); |
| 1195 | }, |
| 1196 | }); |
| 1197 | luaRuntime.setVars(state.vars); |
| 1198 | if (state.lua && state.lua.trim()) { |
| 1199 | state.vars = luaRuntime.run(state.lua, 'скрипт презентации'); |
| 1200 | } |
| 1201 | } |
| 1202 | |
| 1203 | function runLua(code, label) { |
| 1204 | if (!luaRuntime || !code || !String(code).trim()) return; |
| 1205 | state.vars = luaRuntime.run(code, label); |
| 1206 | syncVars(); |
| 1207 | refreshSlides(); |
| 1208 | } |
| 1209 | |
| 1210 | function syncVars() { |
| 1211 | if (mode !== 'speaker') return; |
| 1212 | const payload = JSON.stringify(state.vars || {}); |
| 1213 | if (payload === lastVarsSent) return; |
| 1214 | lastVarsSent = payload; |
| 1215 | if (ws && ws.readyState === WebSocket.OPEN) { |
| 1216 | ws.send(JSON.stringify({ type: 'vars', vars: state.vars })); |
| 1217 | } |
| 1218 | } |
| 1219 | |
| 1220 | // ---------- Действия ---------- |
| 1221 | function executeAction(action, element) { |
| 1222 | if (!action) return; |
| 1223 | switch (action.type) { |
| 1224 | case 'go': |
| 1225 | navigate(Number(action.slideIndex) || 0); |
| 1226 | break; |
| 1227 | case 'next': |
| 1228 | go(1); |
| 1229 | break; |
| 1230 | case 'prev': |
| 1231 | go(-1); |
| 1232 | break; |
| 1233 | case 'play': |
| 1234 | playAudioById(action.audioId); |
| 1235 | break; |
| 1236 | case 'stop': |
| 1237 | stopAudioById(action.audioId); |
| 1238 | break; |
| 1239 | case 'lua': |
| 1240 | runLua(action.code, `кнопка «${element && element.label ? element.label : 'без имени'}»`); |
| 1241 | break; |
| 1242 | default: |
| 1243 | break; |
| 1244 | } |
| 1245 | } |
| 1246 | |
| 1247 | function onSlideEnter(first) { |
| 1248 | if (mode !== 'speaker') return; |
| 1249 | const slide = currentSlide(); |
| 1250 | const previous = state.slides[lastSlideIndex]; |
| 1251 | if (!first && previous && previous.id !== slide.id) { |
| 1252 | runChainNodes(previous, state.slideIndex >= lastSlideIndex ? 'next' : 'prev'); |
| 1253 | } |
| 1254 | if (luaRuntime && slide.lua && slide.lua.trim()) { |
| 1255 | state.vars = luaRuntime.run(slide.lua, `слайд ${state.slideIndex + 1}`); |
| 1256 | syncVars(); |
| 1257 | } |
| 1258 | lastSlideIndex = state.slideIndex; |
| 1259 | } |
| 1260 | |
| 1261 | function stopEffectsAndBroadcast() { |
| 1262 | const ids = audio.getPlayingEffectIds(); |
| 1263 | audio.stopAllEffects(); |
| 1264 | if (mode === 'speaker' && ws && ws.readyState === WebSocket.OPEN) { |
| 1265 | ids.forEach((id) => ws.send(JSON.stringify({ type: 'audio', command: { action: 'stop', id } }))); |
| 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | // ---------- Навигация ---------- |
| 1270 | function navigate(index) { |
| 1271 | if (state.ended) return; |
| 1272 | const next = Math.max(0, Math.min(Number(index) || 0, state.slides.length - 1)); |
| 1273 | if (next === state.slideIndex) return; |
| 1274 | if (ws && ws.readyState === WebSocket.OPEN) { |
| 1275 | ws.send(JSON.stringify({ type: 'navigate', slideIndex: next })); |
| 1276 | } else { |
| 1277 | state.slideIndex = next; |
| 1278 | renderAll(true); |
| 1279 | } |
| 1280 | } |
| 1281 | |
| 1282 | function go(delta) { |
| 1283 | navigate(stepIndex(delta)); |
| 1284 | } |
| 1285 | |
| 1286 | // Связи «Дальше»/«Назад» из графа имеют приоритет над порядком слайдов. |
| 1287 | function jumpTarget(delta) { |
| 1288 | const slide = state.slides[state.slideIndex]; |
| 1289 | if (!slide) return null; |
| 1290 | const jumps = state.graph && state.graph.jumps ? state.graph.jumps : {}; |
| 1291 | const port = delta > 0 ? 'next' : 'prev'; |
| 1292 | const targetId = jumps[slide.id] && jumps[slide.id][port]; |
| 1293 | if (!targetId) return null; |
| 1294 | const index = state.slides.findIndex((item) => item.id === targetId); |
| 1295 | return index >= 0 ? index : null; |
| 1296 | } |
| 1297 | |
| 1298 | function stepIndex(delta) { |
| 1299 | const jump = jumpTarget(delta); |
| 1300 | if (jump !== null) return jump; |
| 1301 | return state.slideIndex + delta; |
| 1302 | } |
| 1303 | |
| 1304 | // ---------- Сообщения сервера ---------- |
| 1305 | function applySync(message) { |
| 1306 | const previousIndex = state.slideIndex; |
| 1307 | const first = !state.ready; |
| 1308 | |
| 1309 | state.title = message.title || 'Без названия'; |
| 1310 | state.slides = Array.isArray(message.slides) ? message.slides : []; |
| 1311 | state.slideIndex = Math.max(0, Math.min(Number(message.slideIndex) || 0, Math.max(state.slides.length - 1, 0))); |
| 1312 | state.music = message.music || { src: '', volume: 0.5 }; |
| 1313 | state.lua = message.lua || ''; |
| 1314 | if (message.graph) state.graph = message.graph; |
| 1315 | if (Array.isArray(message.commands)) state.commands = message.commands; |
| 1316 | |
| 1317 | if (first) { |
| 1318 | state.vars = { ...(message.variables || {}) }; |
| 1319 | } else if (message.variables) { |
| 1320 | state.vars = { ...message.variables, ...state.vars }; |
| 1321 | } |
| 1322 | if (mode === 'speaker' && luaRuntime) luaRuntime.setVars(state.vars); |
| 1323 | |
| 1324 | state.ready = true; |
| 1325 | const slideChanged = first || state.slideIndex !== previousIndex; |
| 1326 | |
| 1327 | if (first) { |
| 1328 | audio.setBgmLevel(state.music.volume); |
| 1329 | // Lua-рантайм нужен и зрителям: переходы и анимации выполняются на каждой странице |
| 1330 | initLuaRuntime(); |
| 1331 | if (mode === 'speaker') { |
| 1332 | if (state.music.src) { |
| 1333 | setTimeout(() => { |
| 1334 | if (!audio.getState().musicPlaying) startMusic(state.music.src); |
| 1335 | }, 450); |
| 1336 | } |
| 1337 | } |
| 1338 | } |
| 1339 | |
| 1340 | if (slideChanged) stopEffectsAndBroadcast(); |
| 1341 | if (mode === 'speaker' && slideChanged) onSlideEnter(first); |
| 1342 | renderAudience(slideChanged); |
| 1343 | if (mode === 'speaker') { |
| 1344 | renderSpeaker(); |
| 1345 | renderConsole(); |
| 1346 | if (slideChanged) { |
| 1347 | maybeAutoStartWindows(); |
| 1348 | if (first) sendWindow('window-targets'); |
| 1349 | } |
| 1350 | } |
| 1351 | document.title = `${state.title} — Promptly`; |
| 1352 | } |
| 1353 | |
| 1354 | function applyVars(vars) { |
| 1355 | if (!vars || typeof vars !== 'object') return; |
| 1356 | state.vars = { ...state.vars, ...vars }; |
| 1357 | if (mode === 'speaker' && luaRuntime) luaRuntime.setVars(state.vars); |
| 1358 | refreshSlides(); |
| 1359 | } |
| 1360 | |
| 1361 | function connect() { |
| 1362 | const wsProto = location.protocol === 'https:' ? 'wss' : 'ws'; |
| 1363 | ws = new WebSocket(`${wsProto}://${location.host}/?id=${encodeURIComponent(presentationId)}&role=${mode}`); |
| 1364 | |
| 1365 | ws.onmessage = (event) => { |
| 1366 | let message; |
| 1367 | try { |
| 1368 | message = JSON.parse(event.data); |
| 1369 | } catch (error) { |
| 1370 | return; |
| 1371 | } |
| 1372 | |
| 1373 | if (message.type === 'sync') { |
| 1374 | applySync(message); |
| 1375 | } else if (message.type === 'vars') { |
| 1376 | applyVars(message.vars); |
| 1377 | } else if (message.type === 'audio') { |
| 1378 | audio.applyCommand(message.command); |
| 1379 | updateAudioPanel(); |
| 1380 | if (['play', 'stop', 'music', 'musicStop'].includes(message.command && message.command.action)) { |
| 1381 | refreshSlides(); |
| 1382 | } |
| 1383 | } else if (message.type === 'audio-state') { |
| 1384 | const snapshot = message.state || {}; |
| 1385 | audio.applyVolumes(snapshot.bgm, snapshot.sfx); |
| 1386 | if (snapshot.musicSrc || snapshot.musicPlaying) { |
| 1387 | audio.applyCommand({ action: 'music', src: snapshot.musicSrc || '', play: !!snapshot.musicPlaying }); |
| 1388 | refreshSlides(); |
| 1389 | } |
| 1390 | } else if (message.type === 'media') { |
| 1391 | applyMediaCommand(message.command); |
| 1392 | if (mode === 'speaker') renderVideoPanel(); |
| 1393 | } else if (message.type === 'media-state') { |
| 1394 | (message.states || []).forEach(applyMediaCommand); |
| 1395 | if (mode === 'speaker') renderVideoPanel(); |
| 1396 | } else if (message.type === 'window-state') { |
| 1397 | const stateInfo = message.state || {}; |
| 1398 | if (stateInfo.elementId) { |
| 1399 | state.windowStates[stateInfo.elementId] = { |
| 1400 | ...(state.windowStates[stateInfo.elementId] || {}), |
| 1401 | ...stateInfo, |
| 1402 | }; |
| 1403 | if (mode === 'speaker') { |
| 1404 | renderWindowPanel(); |
| 1405 | if (state.activeWindow === stateInfo.elementId && stateInfo.targetTitle) { |
| 1406 | windowRemoteTitle.textContent = stateInfo.targetTitle; |
| 1407 | } |
| 1408 | } |
| 1409 | } |
| 1410 | } else if (message.type === 'window-frame') { |
| 1411 | if (message.elementId) updateWindowFrameDom(message.elementId, message.data); |
| 1412 | } else if (message.type === 'window-stop') { |
| 1413 | if (message.elementId) { |
| 1414 | state.windowStates[message.elementId] = { |
| 1415 | ...(state.windowStates[message.elementId] || { elementId: message.elementId }), |
| 1416 | active: false, |
| 1417 | }; |
| 1418 | delete state.windowFrames[message.elementId]; |
| 1419 | refreshSlides(); |
| 1420 | if (state.activeWindow === message.elementId) { |
| 1421 | windowRemoteFrame.src = ''; |
| 1422 | windowRemoteEmpty.hidden = false; |
| 1423 | } |
| 1424 | } |
| 1425 | } else if (message.type === 'window-error') { |
| 1426 | if (message.elementId) { |
| 1427 | state.windowStates[message.elementId] = { |
| 1428 | ...(state.windowStates[message.elementId] || { elementId: message.elementId }), |
| 1429 | active: false, |
| 1430 | error: message.message || '', |
| 1431 | }; |
| 1432 | showToast(`Окно: ${message.message || 'ошибка трансляции'}`); |
| 1433 | if (mode === 'speaker') renderWindowPanel(); |
| 1434 | } |
| 1435 | } else if (message.type === 'window-starting') { |
| 1436 | if (message.elementId) { |
| 1437 | state.windowStates[message.elementId] = { |
| 1438 | ...(state.windowStates[message.elementId] || { elementId: message.elementId }), |
| 1439 | active: true, |
| 1440 | error: '', |
| 1441 | }; |
| 1442 | if (mode === 'speaker') renderWindowPanel(); |
| 1443 | } |
| 1444 | } else if (message.type === 'window-targets') { |
| 1445 | state.windowTargets = Array.isArray(message.targets) ? message.targets : []; |
| 1446 | state.windowEndpoint = message.endpoint || ''; |
| 1447 | if (mode === 'speaker') renderWindowPanel(); |
| 1448 | } else if (message.type === 'sessions') { |
| 1449 | const session = message.sessions.find((item) => item.presentationId === presentationId); |
| 1450 | if (session) { |
| 1451 | audienceCountEl.textContent = session.viewers; |
| 1452 | if (session.startedAt && session.startedAt < state.startedAt) state.startedAt = session.startedAt; |
| 1453 | } |
| 1454 | } else if (message.type === 'session-ended') { |
| 1455 | state.ended = true; |
| 1456 | audio.stopAllEffects(); |
| 1457 | audio.stopMusic(); |
| 1458 | if (mode === 'speaker') renderSpeaker(); |
| 1459 | showOverlay('Демонстрация остановлена', 'Организатор завершил показ.'); |
| 1460 | } else if (message.type === 'error') { |
| 1461 | state.ended = true; |
| 1462 | audio.stopAllEffects(); |
| 1463 | audio.stopMusic(); |
| 1464 | showOverlay('Презентация не найдена', 'Возможно, её удалили.'); |
| 1465 | } |
| 1466 | }; |
| 1467 | |
| 1468 | ws.onclose = (event) => { |
| 1469 | if (state.ended) return; |
| 1470 | if (event.code === 4004) { |
| 1471 | state.ended = true; |
| 1472 | showOverlay('Презентация не найдена', 'Возможно, её удалили.'); |
| 1473 | return; |
| 1474 | } |
| 1475 | if (reconnecting) return; |
| 1476 | reconnecting = true; |
| 1477 | setTimeout(() => { |
| 1478 | reconnecting = false; |
| 1479 | connect(); |
| 1480 | }, 1500); |
| 1481 | }; |
| 1482 | |
| 1483 | ws.onerror = () => ws.close(); |
| 1484 | } |
| 1485 | |
| 1486 | function renderAll(animate) { |
| 1487 | renderAudience(animate); |
| 1488 | if (mode === 'speaker') renderSpeaker(); |
| 1489 | } |
| 1490 | |
| 1491 | function showOverlay(title, message) { |
| 1492 | $('overlay-title').textContent = title; |
| 1493 | $('overlay-text').textContent = message; |
| 1494 | overlay.hidden = false; |
| 1495 | const restart = $('overlay-restart'); |
| 1496 | // Перезапуск имеет смысл, только если презентация цела и это окно докладчика. |
| 1497 | restart.hidden = !(mode === 'speaker'); |
| 1498 | restart.onclick = () => location.reload(); |
| 1499 | } |
| 1500 | |
| 1501 | let toastTimer = null; |
| 1502 | function showToast(message) { |
| 1503 | toastEl.textContent = message; |
| 1504 | toastEl.classList.add('visible'); |
| 1505 | clearTimeout(toastTimer); |
| 1506 | toastTimer = setTimeout(() => toastEl.classList.remove('visible'), 4200); |
| 1507 | } |
| 1508 | |
| 1509 | function updateTimer() { |
| 1510 | if (state.ended) return; |
| 1511 | const seconds = Math.floor((Date.now() - state.startedAt) / 1000); |
| 1512 | const hours = Math.floor(seconds / 3600); |
| 1513 | const minutes = Math.floor((seconds % 3600) / 60); |
| 1514 | const rest = seconds % 60; |
| 1515 | const pad = (value) => String(value).padStart(2, '0'); |
| 1516 | timerEl.textContent = hours > 0 ? `${hours}:${pad(minutes)}:${pad(rest)}` : `${pad(minutes)}:${pad(rest)}`; |
| 1517 | } |
| 1518 | setInterval(updateTimer, 1000); |
| 1519 | |
| 1520 | // ---------- UI события ---------- |
| 1521 | prevBtn.addEventListener('click', () => go(-1)); |
| 1522 | nextBtn.addEventListener('click', () => go(1)); |
| 1523 | $('s-exit').addEventListener('click', () => (location.href = 'index.html')); |
| 1524 | $('a-exit').addEventListener('click', () => (location.href = 'index.html')); |
| 1525 | |
| 1526 | const audienceUrl = () => |
| 1527 | `${location.origin}${location.pathname}?id=${encodeURIComponent(presentationId)}&mode=audience`; |
| 1528 | |
| 1529 | $('copy-link').addEventListener('click', async (event) => { |
| 1530 | const button = event.currentTarget; |
| 1531 | const original = button.innerHTML; |
| 1532 | try { |
| 1533 | await navigator.clipboard.writeText(audienceUrl()); |
| 1534 | button.textContent = 'Скопировано'; |
| 1535 | } catch (error) { |
| 1536 | window.prompt('Ссылка для зрителей:', audienceUrl()); |
| 1537 | } |
| 1538 | setTimeout(() => (button.innerHTML = original), 1600); |
| 1539 | }); |
| 1540 | |
| 1541 | $('open-audience').addEventListener('click', () => window.open(audienceUrl(), '_blank')); |
| 1542 | |
| 1543 | $('fullscreen').addEventListener('click', () => { |
| 1544 | if (!document.fullscreenElement) document.documentElement.requestFullscreen?.(); |
| 1545 | else document.exitFullscreen?.(); |
| 1546 | }); |
| 1547 | |
| 1548 | unlockBtn.addEventListener('click', () => { |
| 1549 | audio.unlock(); |
| 1550 | unlockBtn.hidden = true; |
| 1551 | updateAudioPanel(); |
| 1552 | }); |
| 1553 | |
| 1554 | bgmSlider.addEventListener('input', () => { |
| 1555 | const value = clamp01(Number(bgmSlider.value) / 100); |
| 1556 | const snapshot = audio.getState(); |
| 1557 | sendAudio({ action: 'volumes', bgm: value, sfx: snapshot.sfx }); |
| 1558 | }); |
| 1559 | |
| 1560 | sfxSlider.addEventListener('input', () => { |
| 1561 | const value = clamp01(Number(sfxSlider.value) / 100); |
| 1562 | const snapshot = audio.getState(); |
| 1563 | sendAudio({ action: 'volumes', bgm: snapshot.bgm, sfx: value }); |
| 1564 | }); |
| 1565 | |
| 1566 | musicToggle.addEventListener('click', () => { |
| 1567 | if (audio.getState().musicPlaying) sendAudio({ action: 'musicStop' }); |
| 1568 | else startMusic(); |
| 1569 | }); |
| 1570 | |
| 1571 | $('docs-link').addEventListener('click', () => window.open('docs.html', '_blank')); |
| 1572 | |
| 1573 | // ---------- Консоль ---------- |
| 1574 | consoleListEl.addEventListener('keydown', (event) => { |
| 1575 | if (!state.commands.length) return; |
| 1576 | if (event.key === 'ArrowDown') { |
| 1577 | event.preventDefault(); |
| 1578 | setConsoleIndex(state.consoleIndex + 1); |
| 1579 | } else if (event.key === 'ArrowUp') { |
| 1580 | event.preventDefault(); |
| 1581 | setConsoleIndex(state.consoleIndex - 1); |
| 1582 | } else if (event.key === 'Enter') { |
| 1583 | event.preventDefault(); |
| 1584 | runCommand(state.commands[state.consoleIndex]); |
| 1585 | } else if (event.key === 'Home') { |
| 1586 | event.preventDefault(); |
| 1587 | setConsoleIndex(0); |
| 1588 | } else if (event.key === 'End') { |
| 1589 | event.preventDefault(); |
| 1590 | setConsoleIndex(state.commands.length - 1); |
| 1591 | } |
| 1592 | }); |
| 1593 | consoleListEl.addEventListener('click', () => consoleListEl.focus()); |
| 1594 | |
| 1595 | // ---------- Окно Chrome ---------- |
| 1596 | $('window-refresh').addEventListener('click', () => { |
| 1597 | if (!sendWindow('window-targets')) { |
| 1598 | fetch('/api/windows') |
| 1599 | .then((response) => response.json()) |
| 1600 | .then((data) => { |
| 1601 | state.windowTargets = data.targets || []; |
| 1602 | state.windowEndpoint = data.endpoint || ''; |
| 1603 | renderWindowPanel(); |
| 1604 | }) |
| 1605 | .catch(() => showToast('Сервер недоступен')); |
| 1606 | } |
| 1607 | }); |
| 1608 | |
| 1609 | const remoteStage = $('window-remote-stage'); |
| 1610 | function remotePoint(event) { |
| 1611 | const rect = remoteStage.getBoundingClientRect(); |
| 1612 | if (!rect.width || !rect.height) return null; |
| 1613 | return { |
| 1614 | x: Math.max(0, Math.min(1, (event.clientX - rect.left) / rect.width)), |
| 1615 | y: Math.max(0, Math.min(1, (event.clientY - rect.top) / rect.height)), |
| 1616 | }; |
| 1617 | } |
| 1618 | remoteStage.addEventListener('click', (event) => { |
| 1619 | if (!state.activeWindow) return; |
| 1620 | const point = remotePoint(event); |
| 1621 | if (point) sendWindowInput({ kind: 'click', ...point }); |
| 1622 | }); |
| 1623 | remoteStage.addEventListener( |
| 1624 | 'wheel', |
| 1625 | (event) => { |
| 1626 | if (!state.activeWindow) return; |
| 1627 | event.preventDefault(); |
| 1628 | const point = remotePoint(event); |
| 1629 | if (point) { |
| 1630 | sendWindowInput({ kind: 'wheel', ...point, deltaX: event.deltaX, deltaY: event.deltaY }); |
| 1631 | } |
| 1632 | }, |
| 1633 | { passive: false } |
| 1634 | ); |
| 1635 | |
| 1636 | document.querySelectorAll('[data-key]').forEach((button) => { |
| 1637 | button.addEventListener('click', () => sendWindowInput({ kind: 'key', key: button.dataset.key })); |
| 1638 | }); |
| 1639 | |
| 1640 | $('window-remote-send').addEventListener('click', () => { |
| 1641 | const input = $('window-remote-text'); |
| 1642 | if (!input.value) return; |
| 1643 | sendWindowInput({ kind: 'text', text: input.value }); |
| 1644 | input.value = ''; |
| 1645 | input.focus(); |
| 1646 | }); |
| 1647 | $('window-remote-text').addEventListener('keydown', (event) => { |
| 1648 | if (event.key !== 'Enter') return; |
| 1649 | event.preventDefault(); |
| 1650 | const text = event.currentTarget.value; |
| 1651 | if (text) sendWindowInput({ kind: 'text', text }); |
| 1652 | event.currentTarget.value = ''; |
| 1653 | }); |
| 1654 | $('window-remote-close').addEventListener('click', closeWindowRemote); |
| 1655 | windowRemote.addEventListener('click', (event) => { |
| 1656 | if (event.target === windowRemote) closeWindowRemote(); |
| 1657 | }); |
| 1658 | |
| 1659 | // HUD зрителя появляется при движении мыши |
| 1660 | let hudTimer = null; |
| 1661 | document.addEventListener('mousemove', () => { |
| 1662 | if (mode !== 'audience') return; |
| 1663 | const hud = $('hud'); |
| 1664 | hud.classList.add('visible'); |
| 1665 | clearTimeout(hudTimer); |
| 1666 | hudTimer = setTimeout(() => hud.classList.remove('visible'), 2200); |
| 1667 | }); |
| 1668 | |
| 1669 | document.addEventListener('dblclick', () => { |
| 1670 | if (mode !== 'audience') return; |
| 1671 | if (!document.fullscreenElement) document.documentElement.requestFullscreen?.(); |
| 1672 | else document.exitFullscreen?.(); |
| 1673 | }); |
| 1674 | |
| 1675 | window.addEventListener('keydown', (event) => { |
| 1676 | if (mode !== 'speaker' || state.ended) return; |
| 1677 | if (!windowRemote.hidden) { |
| 1678 | if (event.key === 'Escape') { |
| 1679 | event.preventDefault(); |
| 1680 | closeWindowRemote(); |
| 1681 | } |
| 1682 | return; |
| 1683 | } |
| 1684 | if (event.target.matches('input, textarea, select')) return; |
| 1685 | if (['ArrowRight', 'ArrowDown', ' ', 'PageDown'].includes(event.key)) { |
| 1686 | event.preventDefault(); |
| 1687 | go(1); |
| 1688 | } else if (['ArrowLeft', 'ArrowUp', 'Backspace', 'PageUp'].includes(event.key)) { |
| 1689 | event.preventDefault(); |
| 1690 | go(-1); |
| 1691 | } else if (event.key === 'Home') { |
| 1692 | event.preventDefault(); |
| 1693 | navigate(0); |
| 1694 | } else if (event.key === 'End') { |
| 1695 | event.preventDefault(); |
| 1696 | navigate(state.slides.length - 1); |
| 1697 | } else if (event.key.toLowerCase() === 'f') { |
| 1698 | if (!document.fullscreenElement) document.documentElement.requestFullscreen?.(); |
| 1699 | else document.exitFullscreen?.(); |
| 1700 | } |
| 1701 | }); |
| 1702 | |
| 1703 | // ---------- Инициализация ---------- |
| 1704 | async function init() { |
| 1705 | if (!presentationId) { |
| 1706 | showOverlay('Презентация не найдена', 'В ссылке нет идентификатора презентации.'); |
| 1707 | return; |
| 1708 | } |
| 1709 | updateAudioPanel(); |
| 1710 | try { |
| 1711 | const response = await fetch(`/api/presentations/${encodeURIComponent(presentationId)}`); |
| 1712 | if (!response.ok) { |
| 1713 | showOverlay('Презентация не найдена', 'Возможно, её удалили.'); |
| 1714 | return; |
| 1715 | } |
| 1716 | const presentation = await response.json(); |
| 1717 | state.title = presentation.title; |
| 1718 | state.slides = presentation.slides || []; |
| 1719 | state.slideIndex = presentation.currentSlide || 0; |
| 1720 | state.music = presentation.music || { src: '', volume: 0.5 }; |
| 1721 | state.lua = presentation.lua || ''; |
| 1722 | state.graph = presentation.graph || state.graph; |
| 1723 | state.vars = { ...(presentation.variables || {}) }; |
| 1724 | state.commands = Array.isArray(presentation.commands) ? presentation.commands : []; |
| 1725 | state.ready = false; |
| 1726 | renderAll(false); |
| 1727 | renderConsole(); |
| 1728 | connect(); |
| 1729 | } catch (error) { |
| 1730 | showOverlay('Ошибка загрузки', 'Не удалось загрузить презентацию. Проверьте соединение.'); |
| 1731 | } |
| 1732 | } |
| 1733 | |
| 1734 | init(); |
| 1735 | </script> |
| 1736 | </body> |
| 1737 | </html> |