synthos 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/default-pages/elevenlabs_effects_studio/chat-history.json +1 -0
- package/default-pages/elevenlabs_effects_studio/page.html +1345 -1363
- package/default-pages/elevenlabs_effects_studio/page.json +13 -11
- package/default-pages/elevenlabs_voice_studio/chat-history.json +1 -0
- package/default-pages/elevenlabs_voice_studio/page.html +782 -801
- package/default-pages/elevenlabs_voice_studio/page.json +13 -11
- package/default-pages/json_tools/chat-history.json +1 -0
- package/default-pages/json_tools/page.html +70 -90
- package/default-pages/json_tools/page.json +12 -10
- package/default-pages/my_notes/chat-history.json +1 -0
- package/default-pages/my_notes/page.html +115 -131
- package/default-pages/my_notes/page.json +14 -12
- package/default-pages/neon_asteroids/chat-history.json +1 -0
- package/default-pages/neon_asteroids/page.html +1777 -1803
- package/default-pages/neon_asteroids/page.json +14 -12
- package/default-pages/oregon_trail/chat-history.json +1 -0
- package/default-pages/oregon_trail/page.html +290 -307
- package/default-pages/oregon_trail/page.json +14 -12
- package/default-pages/solar_explorer/chat-history.json +1 -0
- package/default-pages/solar_explorer/page.html +1929 -1951
- package/default-pages/solar_explorer/page.json +14 -12
- package/default-pages/solar_tutorial/chat-history.json +1 -0
- package/default-pages/solar_tutorial/page.html +464 -478
- package/default-pages/solar_tutorial/page.json +12 -10
- package/default-pages/us_map/chat-history.json +1 -0
- package/default-pages/us_map/page.html +170 -193
- package/default-pages/us_map/page.json +14 -12
- package/default-pages/us_map/page.light.png +0 -0
- package/default-pages/us_map_1850/chat-history.json +1 -0
- package/default-pages/us_map_1850/page.html +302 -326
- package/default-pages/us_map_1850/page.json +14 -12
- package/default-pages/western_cities_1850/chat-history.json +1 -0
- package/default-pages/western_cities_1850/page.html +503 -527
- package/default-pages/western_cities_1850/page.json +14 -12
- package/default-themes/aurora-dawn.v3.css +15 -14
- package/default-themes/aurora-dusk.v3.css +26 -26
- package/default-themes/cosmos-dawn.v3.css +15 -14
- package/default-themes/cosmos-dusk.v3.css +26 -26
- package/default-themes/elemental-dawn.v3.css +200 -0
- package/default-themes/nebula-dawn.v3.css +15 -14
- package/default-themes/nebula-dusk.v3.css +24 -24
- package/default-themes/solar-flare-dawn.v3.css +15 -14
- package/default-themes/solar-flare-dusk.v3.css +26 -26
- package/dist/builders/anthropic.d.ts +26 -2
- package/dist/builders/anthropic.d.ts.map +1 -1
- package/dist/builders/anthropic.js +132 -31
- package/dist/builders/anthropic.js.map +1 -1
- package/dist/builders/claudecode.d.ts +13 -0
- package/dist/builders/claudecode.d.ts.map +1 -0
- package/dist/builders/claudecode.js +253 -0
- package/dist/builders/claudecode.js.map +1 -0
- package/dist/builders/index.d.ts +2 -1
- package/dist/builders/index.d.ts.map +1 -1
- package/dist/builders/index.js +8 -1
- package/dist/builders/index.js.map +1 -1
- package/dist/builders/openai.js +2 -1
- package/dist/builders/openai.js.map +1 -1
- package/dist/builders/types.d.ts +31 -7
- package/dist/builders/types.d.ts.map +1 -1
- package/dist/builders/types.js +60 -28
- package/dist/builders/types.js.map +1 -1
- package/dist/connectors/types.d.ts +8 -0
- package/dist/connectors/types.d.ts.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +13 -6
- package/dist/init.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +161 -14
- package/dist/migrations.js.map +1 -1
- package/dist/models/anthropic.d.ts +1 -0
- package/dist/models/anthropic.d.ts.map +1 -1
- package/dist/models/anthropic.js +129 -29
- package/dist/models/anthropic.js.map +1 -1
- package/dist/models/chainOfThought.d.ts.map +1 -1
- package/dist/models/chainOfThought.js +32 -19
- package/dist/models/chainOfThought.js.map +1 -1
- package/dist/models/index.d.ts +2 -2
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +2 -1
- package/dist/models/index.js.map +1 -1
- package/dist/models/providers.d.ts +1 -0
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +12 -4
- package/dist/models/providers.js.map +1 -1
- package/dist/models/types.d.ts +15 -1
- package/dist/models/types.d.ts.map +1 -1
- package/dist/models/types.js.map +1 -1
- package/dist/pages.d.ts +57 -8
- package/dist/pages.d.ts.map +1 -1
- package/dist/pages.js +258 -45
- package/dist/pages.js.map +1 -1
- package/dist/service/createCompletePrompt.d.ts.map +1 -1
- package/dist/service/createCompletePrompt.js +5 -0
- package/dist/service/createCompletePrompt.js.map +1 -1
- package/dist/service/mediaCache.d.ts +36 -0
- package/dist/service/mediaCache.d.ts.map +1 -0
- package/dist/service/mediaCache.js +182 -0
- package/dist/service/mediaCache.js.map +1 -0
- package/dist/service/pageValidator.d.ts +25 -0
- package/dist/service/pageValidator.d.ts.map +1 -0
- package/dist/service/pageValidator.js +315 -0
- package/dist/service/pageValidator.js.map +1 -0
- package/dist/service/server.d.ts.map +1 -1
- package/dist/service/server.js +4 -0
- package/dist/service/server.js.map +1 -1
- package/dist/service/sharedTableSchema.d.ts +73 -0
- package/dist/service/sharedTableSchema.d.ts.map +1 -0
- package/dist/service/sharedTableSchema.js +206 -0
- package/dist/service/sharedTableSchema.js.map +1 -0
- package/dist/service/transformPage.d.ts +49 -11
- package/dist/service/transformPage.d.ts.map +1 -1
- package/dist/service/transformPage.js +354 -241
- package/dist/service/transformPage.js.map +1 -1
- package/dist/service/useApiRoutes.d.ts.map +1 -1
- package/dist/service/useApiRoutes.js +288 -34
- package/dist/service/useApiRoutes.js.map +1 -1
- package/dist/service/useConnectorRoutes.d.ts.map +1 -1
- package/dist/service/useConnectorRoutes.js +170 -32
- package/dist/service/useConnectorRoutes.js.map +1 -1
- package/dist/service/useDataRoutes.d.ts.map +1 -1
- package/dist/service/useDataRoutes.js +59 -2
- package/dist/service/useDataRoutes.js.map +1 -1
- package/dist/service/useExtractRoutes.d.ts +4 -0
- package/dist/service/useExtractRoutes.d.ts.map +1 -0
- package/dist/service/useExtractRoutes.js +304 -0
- package/dist/service/useExtractRoutes.js.map +1 -0
- package/dist/service/usePageRoutes.d.ts +17 -0
- package/dist/service/usePageRoutes.d.ts.map +1 -1
- package/dist/service/usePageRoutes.js +1385 -483
- package/dist/service/usePageRoutes.js.map +1 -1
- package/dist/service/useSharedDataRoutes.d.ts.map +1 -1
- package/dist/service/useSharedDataRoutes.js +54 -2
- package/dist/service/useSharedDataRoutes.js.map +1 -1
- package/dist/settings.d.ts +27 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +40 -1
- package/dist/settings.js.map +1 -1
- package/dist/themes.d.ts +0 -5
- package/dist/themes.d.ts.map +1 -1
- package/dist/themes.js +3 -95
- package/dist/themes.js.map +1 -1
- package/migration-rules/v2-to-v3.md +277 -119
- package/package.json +5 -1
- package/{default-pages/application → required-pages/_shell}/page.html +56 -42
- package/required-pages/_shell/page.json +14 -0
- package/required-pages/_starters/page.html +534 -0
- package/required-pages/_starters/page.json +12 -0
- package/required-pages/builder/page.html +353 -43
- package/required-pages/builder/page.json +12 -10
- package/required-pages/pages/page.html +697 -924
- package/required-pages/pages/page.json +12 -10
- package/required-pages/settings/page.html +1879 -1753
- package/required-pages/settings/page.json +12 -10
- package/required-pages/synthos_apis/page.html +834 -845
- package/required-pages/synthos_apis/page.json +12 -10
- package/required-pages/synthos_scripts/page.html +74 -88
- package/required-pages/synthos_scripts/page.json +12 -10
- package/scripts/append-instructions.py +90 -0
- package/scripts/audit-instructions.py +76 -0
- package/scripts/cleanup-shell-markup.mjs +112 -0
- package/service-connectors/buffer/connector.json +46 -0
- package/service-connectors/canva/connector.json +67 -0
- package/service-connectors/elevenlabs/connector.json +1 -1
- package/src/builders/anthropic.ts +155 -30
- package/src/builders/claudecode.ts +310 -0
- package/src/builders/index.ts +7 -1
- package/src/builders/openai.ts +2 -1
- package/src/builders/types.ts +93 -32
- package/src/connectors/types.ts +8 -0
- package/src/init.ts +13 -7
- package/src/migrations.ts +187 -16
- package/src/models/anthropic.ts +140 -30
- package/src/models/chainOfThought.ts +33 -18
- package/src/models/index.ts +2 -2
- package/src/models/providers.ts +12 -3
- package/src/models/types.ts +21 -1
- package/src/pages.ts +271 -35
- package/src/service/createCompletePrompt.ts +6 -0
- package/src/service/mediaCache.ts +206 -0
- package/src/service/pageValidator.ts +337 -0
- package/src/service/server.ts +4 -0
- package/src/service/sharedTableSchema.ts +236 -0
- package/src/service/transformPage.ts +370 -260
- package/src/service/useApiRoutes.ts +282 -32
- package/src/service/useConnectorRoutes.ts +189 -34
- package/src/service/useDataRoutes.ts +198 -116
- package/src/service/useExtractRoutes.ts +331 -0
- package/src/service/usePageRoutes.ts +1411 -394
- package/src/service/useSharedDataRoutes.ts +184 -109
- package/src/settings.ts +65 -0
- package/src/themes.ts +78 -180
- package/starters/blank_starter/chat-history.json +1 -0
- package/starters/blank_starter/page.dark.png +0 -0
- package/starters/blank_starter/page.html +47 -0
- package/starters/blank_starter/page.json +13 -0
- package/starters/blank_starter/page.light.png +0 -0
- package/starters/calculator_starter/chat-history.json +1 -0
- package/starters/calculator_starter/page.dark.png +0 -0
- package/starters/calculator_starter/page.html +232 -0
- package/starters/calculator_starter/page.json +13 -0
- package/starters/calculator_starter/page.light.png +0 -0
- package/starters/calendar_starter/chat-history.json +1 -0
- package/starters/calendar_starter/page.dark.png +0 -0
- package/starters/calendar_starter/page.html +495 -0
- package/starters/calendar_starter/page.json +13 -0
- package/starters/calendar_starter/page.light.png +0 -0
- package/starters/chat_starter/chat-history.json +1 -0
- package/starters/chat_starter/page.dark.png +0 -0
- package/starters/chat_starter/page.html +351 -0
- package/starters/chat_starter/page.json +13 -0
- package/starters/chat_starter/page.light.png +0 -0
- package/starters/checklist_starter/chat-history.json +1 -0
- package/starters/checklist_starter/page.dark.png +0 -0
- package/starters/checklist_starter/page.html +437 -0
- package/starters/checklist_starter/page.json +13 -0
- package/starters/checklist_starter/page.light.png +0 -0
- package/starters/dashboard_starter/chat-history.json +1 -0
- package/starters/dashboard_starter/page.dark.png +0 -0
- package/starters/dashboard_starter/page.html +195 -0
- package/starters/dashboard_starter/page.json +13 -0
- package/starters/dashboard_starter/page.light.png +0 -0
- package/starters/form_starter/chat-history.json +1 -0
- package/starters/form_starter/page.dark.png +0 -0
- package/starters/form_starter/page.html +313 -0
- package/starters/form_starter/page.json +13 -0
- package/starters/form_starter/page.light.png +0 -0
- package/starters/gallery_starter/chat-history.json +1 -0
- package/starters/gallery_starter/page.dark.png +0 -0
- package/starters/gallery_starter/page.html +418 -0
- package/starters/gallery_starter/page.json +13 -0
- package/starters/gallery_starter/page.light.png +0 -0
- package/starters/generator_starter/chat-history.json +1 -0
- package/starters/generator_starter/page.dark.png +0 -0
- package/starters/generator_starter/page.html +261 -0
- package/starters/generator_starter/page.json +13 -0
- package/starters/generator_starter/page.light.png +0 -0
- package/starters/index.html +538 -0
- package/starters/kanban_starter/chat-history.json +1 -0
- package/starters/kanban_starter/page.dark.png +0 -0
- package/starters/kanban_starter/page.html +432 -0
- package/starters/kanban_starter/page.json +13 -0
- package/starters/kanban_starter/page.light.png +0 -0
- package/starters/presentation_builder/chat-history.json +1 -0
- package/starters/presentation_builder/page.dark.png +0 -0
- package/starters/presentation_builder/page.html +970 -0
- package/starters/presentation_builder/page.json +15 -0
- package/starters/presentation_builder/page.light.png +0 -0
- package/starters/presentation_builder/presentation_voice/voice_config.json +9 -0
- package/starters/pulse_starter/chat-history.json +1 -0
- package/starters/pulse_starter/page.dark.png +0 -0
- package/starters/pulse_starter/page.html +698 -0
- package/starters/pulse_starter/page.json +13 -0
- package/starters/pulse_starter/page.light.png +0 -0
- package/starters/quiz_starter/chat-history.json +1 -0
- package/starters/quiz_starter/page.dark.png +0 -0
- package/starters/quiz_starter/page.html +292 -0
- package/starters/quiz_starter/page.json +13 -0
- package/starters/quiz_starter/page.light.png +0 -0
- package/starters/reference_starter/chat-history.json +1 -0
- package/starters/reference_starter/page.dark.png +0 -0
- package/starters/reference_starter/page.html +250 -0
- package/starters/reference_starter/page.json +13 -0
- package/starters/reference_starter/page.light.png +0 -0
- package/starters/retro_game_starter/chat-history.json +1 -0
- package/starters/retro_game_starter/page.dark.png +0 -0
- package/{default-pages → starters}/retro_game_starter/page.html +1281 -1308
- package/starters/retro_game_starter/page.json +15 -0
- package/starters/retro_game_starter/page.light.png +0 -0
- package/starters/roster_starter/chat-history.json +1 -0
- package/starters/roster_starter/page.dark.png +0 -0
- package/starters/roster_starter/page.html +600 -0
- package/starters/roster_starter/page.json +13 -0
- package/starters/roster_starter/page.light.png +0 -0
- package/starters/server.js +182 -0
- package/starters/start.cmd +1 -0
- package/starters/timeline_starter/chat-history.json +1 -0
- package/starters/timeline_starter/page.dark.png +0 -0
- package/starters/timeline_starter/page.html +446 -0
- package/starters/timeline_starter/page.json +13 -0
- package/starters/timeline_starter/page.light.png +0 -0
- package/starters/tutorial_starter/chat-history.json +1 -0
- package/starters/tutorial_starter/page.dark.png +0 -0
- package/starters/tutorial_starter/page.html +283 -0
- package/starters/tutorial_starter/page.json +13 -0
- package/starters/tutorial_starter/page.light.png +0 -0
- package/static-files/agent.v3.js +122 -0
- package/static-files/connector.v3.js +48 -0
- package/static-files/extract.v3.js +188 -0
- package/static-files/helpers.v3.js +50 -6
- package/static-files/page-bridge.js +114 -0
- package/static-files/page.v3.js +1292 -1290
- package/static-files/script.v3.js +32 -0
- package/static-files/server.v3.js +89 -0
- package/static-files/shell-bridge.v3.js +174 -0
- package/static-files/shell-modals.v3.js +521 -0
- package/static-files/{shell.css → shell.v3.css} +271 -22
- package/static-files/shell.v3.js +1865 -0
- package/static-files/storage.v3.js +176 -0
- package/tests/anthropic.spec.ts +42 -7
- package/tests/builders.spec.ts +72 -4
- package/tests/pageValidator.spec.ts +548 -0
- package/tests/profiles.spec.ts +122 -0
- package/tests/providers.spec.ts +1 -1
- package/tests/sharedTableSchema.spec.ts +242 -0
- package/tests/transformPage.spec.ts +62 -81
- package/default-pages/application/page.json +0 -10
- package/default-pages/retro_game_starter/page.json +0 -12
- package/default-pages/sidebar_page/page.html +0 -51
- package/default-pages/sidebar_page/page.json +0 -10
- package/default-pages/two-panel_page/page.html +0 -68
- package/default-pages/two-panel_page/page.json +0 -10
package/static-files/page.v3.js
CHANGED
|
@@ -1,1290 +1,1292 @@
|
|
|
1
|
-
(function() {
|
|
2
|
-
// Fallback navigation — overridden in section 10 with unsaved-changes guard
|
|
3
|
-
if (!window.__synthOSNavigateTo) {
|
|
4
|
-
window.__synthOSNavigateTo = function(url) { window.location.href = url; };
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
if (window.__synthOSChatPanel) return;
|
|
8
|
-
window.__synthOSChatPanel = true;
|
|
9
|
-
|
|
10
|
-
// Product name — used for branding throughout the page script
|
|
11
|
-
var pn = (window.pageInfo && window.pageInfo.productName) ? window.pageInfo.productName : 'SynthOS';
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
(function() {
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
33
|
-
'
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
'
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
'
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
document.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
window.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
var
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
'</
|
|
213
|
-
'</div>' +
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
document.
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
var
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
'
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
'
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
var
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (!
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
(
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
'
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
var
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
var
|
|
690
|
-
var
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
})
|
|
739
|
-
.
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
var
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
var
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
attachBtn
|
|
910
|
-
attachBtn.
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
menu
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
menuAttachFile
|
|
921
|
-
menuAttachFile.
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
menuScreenshot
|
|
926
|
-
menuScreenshot.
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
overlay
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
instrBar
|
|
973
|
-
instrBar.
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
actions
|
|
979
|
-
actions.
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
captureBtn
|
|
983
|
-
captureBtn.
|
|
984
|
-
captureBtn.
|
|
985
|
-
captureBtn.
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
cancelBtn
|
|
989
|
-
cancelBtn.
|
|
990
|
-
cancelBtn.
|
|
991
|
-
cancelBtn.
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
actions.appendChild(
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
var
|
|
1000
|
-
var
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
currentRect
|
|
1012
|
-
currentRect.
|
|
1013
|
-
currentRect.style.
|
|
1014
|
-
currentRect.style.
|
|
1015
|
-
currentRect.style.
|
|
1016
|
-
currentRect.style.
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
var
|
|
1024
|
-
var
|
|
1025
|
-
var
|
|
1026
|
-
var
|
|
1027
|
-
var
|
|
1028
|
-
var
|
|
1029
|
-
|
|
1030
|
-
currentRect.style.
|
|
1031
|
-
currentRect.style.
|
|
1032
|
-
currentRect.style.
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
isDrawing
|
|
1038
|
-
|
|
1039
|
-
var
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
currentRect
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
var
|
|
1077
|
-
var
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
ctx
|
|
1081
|
-
ctx.
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
Math.round(r.
|
|
1088
|
-
Math.round(r.
|
|
1089
|
-
Math.round(r.
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
var
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
viewerPanel.
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
undoDiv
|
|
1143
|
-
undoDiv.
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
link
|
|
1147
|
-
link.
|
|
1148
|
-
link.
|
|
1149
|
-
link.
|
|
1150
|
-
link.addEventListener('
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
.then(function(
|
|
1164
|
-
|
|
1165
|
-
window.
|
|
1166
|
-
window.
|
|
1167
|
-
|
|
1168
|
-
document.
|
|
1169
|
-
document.
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
var
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
var
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
tryLink
|
|
1203
|
-
tryLink.
|
|
1204
|
-
tryLink.
|
|
1205
|
-
tryLink.
|
|
1206
|
-
tryLink.addEventListener('
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
.then(function(
|
|
1224
|
-
|
|
1225
|
-
window.
|
|
1226
|
-
window.
|
|
1227
|
-
|
|
1228
|
-
document.
|
|
1229
|
-
document.
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
if (
|
|
1235
|
-
if (
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
(
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
overlay
|
|
1250
|
-
overlay.
|
|
1251
|
-
overlay.
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
'<
|
|
1256
|
-
|
|
1257
|
-
'
|
|
1258
|
-
'<div class="flm-dialog-
|
|
1259
|
-
|
|
1260
|
-
'<button class="flm-button
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
window.
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1
|
+
(function() {
|
|
2
|
+
// Fallback navigation — overridden in section 10 with unsaved-changes guard
|
|
3
|
+
if (!window.__synthOSNavigateTo) {
|
|
4
|
+
window.__synthOSNavigateTo = function(url) { window.location.href = url; };
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
if (window.__synthOSChatPanel) return;
|
|
8
|
+
window.__synthOSChatPanel = true;
|
|
9
|
+
|
|
10
|
+
// Product name — used for branding throughout the page script
|
|
11
|
+
var pn = (window.pageInfo && window.pageInfo.productName) ? window.pageInfo.productName : 'SynthOS';
|
|
12
|
+
|
|
13
|
+
// 1. Themed tooltips for chat panel controls
|
|
14
|
+
(function() {
|
|
15
|
+
var style = document.createElement('style');
|
|
16
|
+
style.textContent =
|
|
17
|
+
'.synthos-tooltip {' +
|
|
18
|
+
'position: fixed;' +
|
|
19
|
+
'padding: 6px 10px;' +
|
|
20
|
+
'background: var(--bg-tertiary, #0f0f23);' +
|
|
21
|
+
'color: var(--text-secondary, #b794f6);' +
|
|
22
|
+
'border: 1px solid var(--border-color, rgba(138,43,226,0.3));' +
|
|
23
|
+
'border-radius: 6px;' +
|
|
24
|
+
'font-size: 12px;' +
|
|
25
|
+
'max-width: 150px;' +
|
|
26
|
+
'text-align: center;' +
|
|
27
|
+
'pointer-events: none;' +
|
|
28
|
+
'z-index: 10000;' +
|
|
29
|
+
'box-shadow: 0 2px 8px rgba(0,0,0,0.3);' +
|
|
30
|
+
'opacity: 0;' +
|
|
31
|
+
'transition: opacity 0.15s;' +
|
|
32
|
+
'}' +
|
|
33
|
+
'.synthos-tooltip.visible { opacity: 1; }';
|
|
34
|
+
document.head.appendChild(style);
|
|
35
|
+
|
|
36
|
+
var tip = document.createElement('div');
|
|
37
|
+
tip.className = 'synthos-tooltip';
|
|
38
|
+
document.body.appendChild(tip);
|
|
39
|
+
|
|
40
|
+
function show(el) {
|
|
41
|
+
tip.textContent = el.getAttribute('data-tooltip');
|
|
42
|
+
tip.style.display = 'block';
|
|
43
|
+
tip.classList.remove('visible');
|
|
44
|
+
var r = el.getBoundingClientRect();
|
|
45
|
+
var tw = tip.offsetWidth;
|
|
46
|
+
var left = r.left + (r.width / 2) - (tw / 2);
|
|
47
|
+
if (left < 4) left = 4;
|
|
48
|
+
if (left + tw > window.innerWidth - 4) left = window.innerWidth - tw - 4;
|
|
49
|
+
tip.style.left = left + 'px';
|
|
50
|
+
tip.style.top = (r.top - tip.offsetHeight - 6) + 'px';
|
|
51
|
+
void tip.offsetWidth;
|
|
52
|
+
tip.classList.add('visible');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function hide() {
|
|
56
|
+
tip.classList.remove('visible');
|
|
57
|
+
tip.style.display = 'none';
|
|
58
|
+
}
|
|
59
|
+
hide();
|
|
60
|
+
|
|
61
|
+
function attach(el, text) {
|
|
62
|
+
el.setAttribute('data-tooltip', text);
|
|
63
|
+
el.addEventListener('mouseenter', function() { show(el); });
|
|
64
|
+
el.addEventListener('mouseleave', hide);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
window.__synthOSTooltip = attach;
|
|
68
|
+
})();
|
|
69
|
+
|
|
70
|
+
var chatInput = document.getElementById('chatInput');
|
|
71
|
+
|
|
72
|
+
// 2. Form submit handler — fetch+JSON with attachment support
|
|
73
|
+
var chatForm = document.getElementById('chatForm');
|
|
74
|
+
if (chatForm) {
|
|
75
|
+
chatForm.addEventListener('submit', function(e) {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
|
|
78
|
+
var ci = document.getElementById('chatInput');
|
|
79
|
+
var messageText = ci ? ci.value : '';
|
|
80
|
+
|
|
81
|
+
// Append any captured console errors to the outgoing message
|
|
82
|
+
var errors = window.__synthOSErrors;
|
|
83
|
+
if (errors && errors.length > 0 && messageText.trim()) {
|
|
84
|
+
messageText = messageText + '\n\nCONSOLE_ERRORS:\n' + errors.join('\n---\n');
|
|
85
|
+
window.__synthOSErrors = [];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!messageText.trim()) return;
|
|
89
|
+
|
|
90
|
+
// Show overlay and disable inputs
|
|
91
|
+
var overlay = document.getElementById('loadingOverlay');
|
|
92
|
+
if (overlay) overlay.style.display = 'flex';
|
|
93
|
+
setTimeout(function() {
|
|
94
|
+
if (ci) ci.disabled = true;
|
|
95
|
+
var sb = document.querySelector('.chat-send-btn');
|
|
96
|
+
if (sb) sb.disabled = true;
|
|
97
|
+
}, 50);
|
|
98
|
+
|
|
99
|
+
// Build JSON body with optional attachments
|
|
100
|
+
var body = { message: messageText };
|
|
101
|
+
var attachments = window.__synthOSAttachments;
|
|
102
|
+
if (attachments && attachments.length > 0) {
|
|
103
|
+
body.attachments = attachments.map(function(a) {
|
|
104
|
+
return { mediaType: a.mediaType, data: a.data, name: a.name };
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
fetch(window.location.pathname, {
|
|
109
|
+
method: 'POST',
|
|
110
|
+
headers: { 'Content-Type': 'application/json' },
|
|
111
|
+
body: JSON.stringify(body)
|
|
112
|
+
})
|
|
113
|
+
.then(function(res) { return res.text(); })
|
|
114
|
+
.then(function(html) {
|
|
115
|
+
// Mark page as dirty (unsaved changes) for required-page prompt
|
|
116
|
+
window.__synthOSPageDirty = true;
|
|
117
|
+
// Reset guards so page-v3.js re-initializes on the new DOM
|
|
118
|
+
window.__synthOSChatPanel = false;
|
|
119
|
+
window.__synthOSNavigateTo = null;
|
|
120
|
+
document.open();
|
|
121
|
+
document.write(html);
|
|
122
|
+
document.close();
|
|
123
|
+
})
|
|
124
|
+
.catch(function(err) {
|
|
125
|
+
console.error('Submit failed:', err);
|
|
126
|
+
if (overlay) overlay.style.display = 'none';
|
|
127
|
+
if (ci) ci.disabled = false;
|
|
128
|
+
var sb = document.querySelector('.chat-send-btn');
|
|
129
|
+
if (sb) sb.disabled = false;
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Clear attachments after submit
|
|
133
|
+
window.__synthOSAttachments = [];
|
|
134
|
+
var pillsContainer = document.querySelector('.attachment-pills');
|
|
135
|
+
if (pillsContainer) pillsContainer.innerHTML = '';
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// 2b. Enter submits, Shift+Enter adds newline
|
|
140
|
+
(function() {
|
|
141
|
+
var ci = document.getElementById('chatInput');
|
|
142
|
+
if (!ci) return;
|
|
143
|
+
ci.addEventListener('keydown', function(e) {
|
|
144
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
145
|
+
e.preventDefault();
|
|
146
|
+
var form = document.getElementById('chatForm');
|
|
147
|
+
if (form) form.requestSubmit();
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
})();
|
|
151
|
+
|
|
152
|
+
// 3. Save modal — themed modal with title, categories, greeting
|
|
153
|
+
(function() {
|
|
154
|
+
|
|
155
|
+
// Detect if current page is a Builders, System, or Starters page (start with blank fields)
|
|
156
|
+
var isBuilder = window.pageInfo && Array.isArray(window.pageInfo.categories) &&
|
|
157
|
+
(window.pageInfo.categories.indexOf('Builders') !== -1 ||
|
|
158
|
+
window.pageInfo.categories.indexOf('System') !== -1 ||
|
|
159
|
+
window.pageInfo.categories.indexOf('_Starters') !== -1);
|
|
160
|
+
|
|
161
|
+
// Original title for change detection
|
|
162
|
+
var originalTitle = (window.pageInfo && window.pageInfo.title) ? window.pageInfo.title : '';
|
|
163
|
+
|
|
164
|
+
// --- Create save modal ---
|
|
165
|
+
var modal = document.createElement('div');
|
|
166
|
+
modal.id = 'synthos-saveModal';
|
|
167
|
+
modal.className = 'modal-overlay';
|
|
168
|
+
modal.innerHTML =
|
|
169
|
+
'<div class="modal-content" style="max-width:480px;">' +
|
|
170
|
+
'<div class="modal-header">' +
|
|
171
|
+
'<span>Save Page</span>' +
|
|
172
|
+
'<button type="button" class="brainstorm-close-btn" id="synthos-saveCloseBtn">×</button>' +
|
|
173
|
+
'</div>' +
|
|
174
|
+
'<div class="modal-body" style="display:flex;flex-direction:column;gap:12px;padding:16px 20px;">' +
|
|
175
|
+
'<div>' +
|
|
176
|
+
'<label style="display:block;margin-bottom:4px;font-size:13px;color:var(--text-secondary);">Display Title <span style="color:var(--accent-primary);">*</span></label>' +
|
|
177
|
+
'<input type="text" id="synthos-saveTitleInput" class="brainstorm-input" placeholder="Enter a display title..." style="width:100%;box-sizing:border-box;">' +
|
|
178
|
+
'<div id="synthos-saveTitleError" style="color:#ff6b6b;font-size:12px;margin-top:4px;display:none;">Title is required</div>' +
|
|
179
|
+
'</div>' +
|
|
180
|
+
'<div>' +
|
|
181
|
+
'<label style="display:block;margin-bottom:4px;font-size:13px;color:var(--text-secondary);">Categories <span style="color:var(--accent-primary);">*</span></label>' +
|
|
182
|
+
'<input type="text" id="synthos-saveCategoriesInput" class="brainstorm-input" placeholder="e.g. Tool, Game, Utility" style="width:100%;box-sizing:border-box;">' +
|
|
183
|
+
'<div id="synthos-saveCategoriesError" style="color:#ff6b6b;font-size:12px;margin-top:4px;display:none;">At least one category is required</div>' +
|
|
184
|
+
'</div>' +
|
|
185
|
+
'<div>' +
|
|
186
|
+
'<label style="display:block;margin-bottom:4px;font-size:13px;color:var(--text-secondary);">Greeting <span style="font-size:11px;opacity:0.7;">(optional)</span></label>' +
|
|
187
|
+
'<input type="text" id="synthos-saveGreetingInput" class="brainstorm-input" placeholder="Available when title changes" style="width:100%;box-sizing:border-box;" disabled>' +
|
|
188
|
+
'<div style="font-size:11px;color:var(--text-secondary);margin-top:4px;opacity:0.7;" id="synthos-saveGreetingHint">Change the title to enable a custom greeting.</div>' +
|
|
189
|
+
'</div>' +
|
|
190
|
+
'</div>' +
|
|
191
|
+
'<div class="modal-footer" style="display:flex;justify-content:flex-end;gap:8px;padding:12px 20px;">' +
|
|
192
|
+
'<button type="button" class="brainstorm-send-btn" id="synthos-saveCancelBtn" style="background:transparent;border:1px solid var(--border-color);color:var(--text-secondary);">Cancel</button>' +
|
|
193
|
+
'<button type="button" class="brainstorm-send-btn" id="synthos-saveConfirmBtn">Save</button>' +
|
|
194
|
+
'</div>' +
|
|
195
|
+
'</div>';
|
|
196
|
+
document.body.appendChild(modal);
|
|
197
|
+
|
|
198
|
+
// --- Create error modal ---
|
|
199
|
+
var errorModal = document.createElement('div');
|
|
200
|
+
errorModal.id = 'synthos-errorModal';
|
|
201
|
+
errorModal.className = 'modal-overlay';
|
|
202
|
+
errorModal.innerHTML =
|
|
203
|
+
'<div class="modal-content" style="max-width:400px;">' +
|
|
204
|
+
'<div class="modal-header">' +
|
|
205
|
+
'<span>Error</span>' +
|
|
206
|
+
'<button type="button" class="brainstorm-close-btn" id="synthos-errorCloseBtn">×</button>' +
|
|
207
|
+
'</div>' +
|
|
208
|
+
'<div class="modal-body" style="padding:16px 20px;">' +
|
|
209
|
+
'<p id="synthos-errorMessage" style="margin:0;color:var(--text-primary);"></p>' +
|
|
210
|
+
'</div>' +
|
|
211
|
+
'<div class="modal-footer" style="display:flex;justify-content:flex-end;padding:12px 20px;">' +
|
|
212
|
+
'<button type="button" class="brainstorm-send-btn" id="synthos-errorOkBtn">OK</button>' +
|
|
213
|
+
'</div>' +
|
|
214
|
+
'</div>';
|
|
215
|
+
document.body.appendChild(errorModal);
|
|
216
|
+
|
|
217
|
+
// --- Element references ---
|
|
218
|
+
var titleInput = document.getElementById('synthos-saveTitleInput');
|
|
219
|
+
var categoriesInput = document.getElementById('synthos-saveCategoriesInput');
|
|
220
|
+
var greetingInput = document.getElementById('synthos-saveGreetingInput');
|
|
221
|
+
var greetingHint = document.getElementById('synthos-saveGreetingHint');
|
|
222
|
+
var titleError = document.getElementById('synthos-saveTitleError');
|
|
223
|
+
var categoriesError = document.getElementById('synthos-saveCategoriesError');
|
|
224
|
+
|
|
225
|
+
// --- Greeting enable/disable based on title change ---
|
|
226
|
+
titleInput.addEventListener('input', function() {
|
|
227
|
+
var changed = titleInput.value.trim() !== originalTitle;
|
|
228
|
+
greetingInput.disabled = !changed;
|
|
229
|
+
if (changed) {
|
|
230
|
+
greetingInput.placeholder = 'Enter a custom greeting...';
|
|
231
|
+
greetingHint.textContent = 'Replaces the initial Synthos greeting and removes chat history.';
|
|
232
|
+
} else {
|
|
233
|
+
greetingInput.placeholder = 'Available when title changes';
|
|
234
|
+
greetingInput.value = '';
|
|
235
|
+
greetingHint.textContent = 'Change the title to enable a custom greeting.';
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// --- Open modal ---
|
|
240
|
+
function openSaveModal() {
|
|
241
|
+
// Pre-fill fields (blank for Builder pages)
|
|
242
|
+
titleInput.value = isBuilder ? '' : originalTitle;
|
|
243
|
+
categoriesInput.value = isBuilder ? '' : (
|
|
244
|
+
(window.pageInfo && Array.isArray(window.pageInfo.categories))
|
|
245
|
+
? window.pageInfo.categories.join(', ')
|
|
246
|
+
: ''
|
|
247
|
+
);
|
|
248
|
+
greetingInput.value = '';
|
|
249
|
+
greetingInput.disabled = true;
|
|
250
|
+
greetingInput.placeholder = 'Available when title changes';
|
|
251
|
+
greetingHint.textContent = 'Change the title to enable a custom greeting.';
|
|
252
|
+
titleError.style.display = 'none';
|
|
253
|
+
categoriesError.style.display = 'none';
|
|
254
|
+
modal.classList.add('show');
|
|
255
|
+
titleInput.focus();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function closeSaveModal() {
|
|
259
|
+
modal.classList.remove('show');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function showError(msg) {
|
|
263
|
+
document.getElementById('synthos-errorMessage').textContent = msg;
|
|
264
|
+
errorModal.classList.add('show');
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function closeError() {
|
|
268
|
+
errorModal.classList.remove('show');
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// --- Submit ---
|
|
272
|
+
function submitSave() {
|
|
273
|
+
var title = titleInput.value.trim();
|
|
274
|
+
var cats = categoriesInput.value.trim();
|
|
275
|
+
var greeting = greetingInput.value.trim();
|
|
276
|
+
var valid = true;
|
|
277
|
+
|
|
278
|
+
// Validate
|
|
279
|
+
if (!title) {
|
|
280
|
+
titleError.style.display = 'block';
|
|
281
|
+
valid = false;
|
|
282
|
+
} else {
|
|
283
|
+
titleError.style.display = 'none';
|
|
284
|
+
}
|
|
285
|
+
if (!cats) {
|
|
286
|
+
categoriesError.style.display = 'block';
|
|
287
|
+
valid = false;
|
|
288
|
+
} else {
|
|
289
|
+
categoriesError.style.display = 'none';
|
|
290
|
+
}
|
|
291
|
+
if (!valid) return;
|
|
292
|
+
|
|
293
|
+
// Parse categories
|
|
294
|
+
var categories = cats.split(',').map(function(c) { return c.trim(); }).filter(Boolean);
|
|
295
|
+
|
|
296
|
+
// Disable button during save
|
|
297
|
+
var confirmBtn = document.getElementById('synthos-saveConfirmBtn');
|
|
298
|
+
confirmBtn.disabled = true;
|
|
299
|
+
confirmBtn.textContent = 'Saving...';
|
|
300
|
+
|
|
301
|
+
var body = { title: title, categories: categories };
|
|
302
|
+
if (greeting && !greetingInput.disabled) {
|
|
303
|
+
body.greeting = greeting;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
fetch(window.location.pathname + '/save', {
|
|
307
|
+
method: 'POST',
|
|
308
|
+
headers: { 'Content-Type': 'application/json' },
|
|
309
|
+
body: JSON.stringify(body)
|
|
310
|
+
})
|
|
311
|
+
.then(function(res) {
|
|
312
|
+
return res.json().then(function(data) {
|
|
313
|
+
return { ok: res.ok, data: data };
|
|
314
|
+
});
|
|
315
|
+
})
|
|
316
|
+
.then(function(result) {
|
|
317
|
+
if (result.ok && result.data.redirect) {
|
|
318
|
+
window.__synthOSPageDirty = false;
|
|
319
|
+
window.location.href = result.data.redirect;
|
|
320
|
+
} else {
|
|
321
|
+
closeSaveModal();
|
|
322
|
+
showError(result.data.error || 'An unknown error occurred');
|
|
323
|
+
confirmBtn.disabled = false;
|
|
324
|
+
confirmBtn.textContent = 'Save';
|
|
325
|
+
}
|
|
326
|
+
})
|
|
327
|
+
.catch(function(err) {
|
|
328
|
+
closeSaveModal();
|
|
329
|
+
showError('Network error: ' + err.message);
|
|
330
|
+
confirmBtn.disabled = false;
|
|
331
|
+
confirmBtn.textContent = 'Save';
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Expose openSaveModal globally for toolbar button
|
|
336
|
+
window.__synthOSOpenSaveModal = openSaveModal;
|
|
337
|
+
|
|
338
|
+
// --- Event listeners ---
|
|
339
|
+
document.getElementById('synthos-saveCloseBtn').addEventListener('click', closeSaveModal);
|
|
340
|
+
document.getElementById('synthos-saveCancelBtn').addEventListener('click', closeSaveModal);
|
|
341
|
+
document.getElementById('synthos-saveConfirmBtn').addEventListener('click', submitSave);
|
|
342
|
+
document.getElementById('synthos-errorCloseBtn').addEventListener('click', closeError);
|
|
343
|
+
document.getElementById('synthos-errorOkBtn').addEventListener('click', closeError);
|
|
344
|
+
|
|
345
|
+
var saveModalMouseDownTarget = null;
|
|
346
|
+
modal.addEventListener('mousedown', function(e) { saveModalMouseDownTarget = e.target; });
|
|
347
|
+
modal.addEventListener('click', function(e) {
|
|
348
|
+
if (e.target === modal && saveModalMouseDownTarget === modal) closeSaveModal();
|
|
349
|
+
saveModalMouseDownTarget = null;
|
|
350
|
+
});
|
|
351
|
+
var errorModalMouseDownTarget = null;
|
|
352
|
+
errorModal.addEventListener('mousedown', function(e) { errorModalMouseDownTarget = e.target; });
|
|
353
|
+
errorModal.addEventListener('click', function(e) {
|
|
354
|
+
if (e.target === errorModal && errorModalMouseDownTarget === errorModal) closeError();
|
|
355
|
+
errorModalMouseDownTarget = null;
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
document.addEventListener('keydown', function(e) {
|
|
359
|
+
if (e.key === 'Escape') {
|
|
360
|
+
if (modal.classList.contains('show')) closeSaveModal();
|
|
361
|
+
if (errorModal.classList.contains('show')) closeError();
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
// Enter key in title/categories inputs triggers save
|
|
366
|
+
titleInput.addEventListener('keydown', function(e) {
|
|
367
|
+
if (e.key === 'Enter') { e.preventDefault(); submitSave(); }
|
|
368
|
+
});
|
|
369
|
+
categoriesInput.addEventListener('keydown', function(e) {
|
|
370
|
+
if (e.key === 'Enter') { e.preventDefault(); submitSave(); }
|
|
371
|
+
});
|
|
372
|
+
})();
|
|
373
|
+
|
|
374
|
+
// 4. Chat scroll to bottom
|
|
375
|
+
var chatMessages = document.getElementById('chatMessages');
|
|
376
|
+
if (chatMessages) {
|
|
377
|
+
chatMessages.scrollTo({
|
|
378
|
+
top: chatMessages.scrollHeight,
|
|
379
|
+
behavior: 'smooth'
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// 5. Shell toolbar button wiring
|
|
384
|
+
(function() {
|
|
385
|
+
var DB_NAME = 'synthos-ui';
|
|
386
|
+
var STORE_NAME = 'panel-state';
|
|
387
|
+
var pageName = window.location.pathname.replace(/^\//, '') || 'builder';
|
|
388
|
+
var isBuilderPage = pageName === 'builder';
|
|
389
|
+
|
|
390
|
+
// IndexedDB helpers
|
|
391
|
+
function openDB(cb) {
|
|
392
|
+
var req = indexedDB.open(DB_NAME, 1);
|
|
393
|
+
req.onupgradeneeded = function() {
|
|
394
|
+
var db = req.result;
|
|
395
|
+
if (!db.objectStoreNames.contains(STORE_NAME)) {
|
|
396
|
+
db.createObjectStore(STORE_NAME);
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
req.onsuccess = function() { cb(req.result); };
|
|
400
|
+
req.onerror = function() { cb(null); };
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function saveCollapsed(collapsed) {
|
|
404
|
+
openDB(function(db) {
|
|
405
|
+
if (!db) return;
|
|
406
|
+
var tx = db.transaction(STORE_NAME, 'readwrite');
|
|
407
|
+
tx.objectStore(STORE_NAME).put(collapsed, pageName);
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function loadCollapsed(cb) {
|
|
412
|
+
openDB(function(db) {
|
|
413
|
+
if (!db) { cb(null); return; }
|
|
414
|
+
var tx = db.transaction(STORE_NAME, 'readonly');
|
|
415
|
+
var req = tx.objectStore(STORE_NAME).get(pageName);
|
|
416
|
+
req.onsuccess = function() { cb(req.result); };
|
|
417
|
+
req.onerror = function() { cb(null); };
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function setCollapsed(collapsed) {
|
|
422
|
+
if (collapsed) {
|
|
423
|
+
document.body.classList.add('chat-collapsed');
|
|
424
|
+
} else {
|
|
425
|
+
document.body.classList.remove('chat-collapsed');
|
|
426
|
+
}
|
|
427
|
+
saveCollapsed(collapsed);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// Restore state — builder page always starts open
|
|
431
|
+
if (isBuilderPage) {
|
|
432
|
+
document.body.classList.remove('chat-collapsed');
|
|
433
|
+
} else {
|
|
434
|
+
loadCollapsed(function(val) {
|
|
435
|
+
if (val === true) {
|
|
436
|
+
document.body.classList.add('chat-collapsed');
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// Builder toggle — show/hide chat panel
|
|
442
|
+
var builderToggle = document.getElementById('builderToggle');
|
|
443
|
+
if (builderToggle) {
|
|
444
|
+
builderToggle.addEventListener('click', function() {
|
|
445
|
+
var collapsed = !document.body.classList.contains('chat-collapsed');
|
|
446
|
+
setCollapsed(collapsed);
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// Builder close button — same as collapse
|
|
451
|
+
var builderClose = document.getElementById('builderClose');
|
|
452
|
+
if (builderClose) {
|
|
453
|
+
builderClose.addEventListener('click', function() {
|
|
454
|
+
setCollapsed(true);
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// Pages button — navigate to pages gallery
|
|
459
|
+
var pagesBtn = document.getElementById('pagesBtn');
|
|
460
|
+
if (pagesBtn) {
|
|
461
|
+
pagesBtn.addEventListener('click', function() {
|
|
462
|
+
window.__synthOSNavigateTo('/pages');
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// Save button — open save modal
|
|
467
|
+
var saveBtn = document.getElementById('saveBtn');
|
|
468
|
+
if (saveBtn) {
|
|
469
|
+
saveBtn.addEventListener('click', function() {
|
|
470
|
+
if (window.__synthOSOpenSaveModal) window.__synthOSOpenSaveModal();
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// Settings button — navigate to settings page
|
|
475
|
+
var settingsBtn = document.getElementById('settingsBtn');
|
|
476
|
+
if (settingsBtn) {
|
|
477
|
+
settingsBtn.addEventListener('click', function() {
|
|
478
|
+
window.__synthOSNavigateTo('/settings');
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
})();
|
|
482
|
+
|
|
483
|
+
// 6. Focus management — prevent viewer content from stealing keystrokes
|
|
484
|
+
(function() {
|
|
485
|
+
var ci = document.getElementById('chatInput');
|
|
486
|
+
var vp = document.getElementById('viewerPanel');
|
|
487
|
+
if (!ci || !vp) return;
|
|
488
|
+
|
|
489
|
+
ci.addEventListener('mousedown', function(e) {
|
|
490
|
+
e.stopPropagation();
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
['keydown', 'keyup', 'keypress'].forEach(function(type) {
|
|
494
|
+
document.addEventListener(type, function(e) {
|
|
495
|
+
if (document.activeElement === ci) {
|
|
496
|
+
// Allow Enter (without Shift) to reach the submit handler
|
|
497
|
+
if (e.key === 'Enter' && !e.shiftKey) return;
|
|
498
|
+
e.stopImmediatePropagation();
|
|
499
|
+
}
|
|
500
|
+
}, true);
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
vp.setAttribute('tabindex', '-1');
|
|
504
|
+
ci.addEventListener('blur', function() {
|
|
505
|
+
vp.focus();
|
|
506
|
+
});
|
|
507
|
+
})();
|
|
508
|
+
|
|
509
|
+
// 7. Brainstorm — dynamic brainstorming UI (available on every v2 page)
|
|
510
|
+
(function() {
|
|
511
|
+
var chatInput = document.getElementById('chatInput');
|
|
512
|
+
if (!chatInput) return;
|
|
513
|
+
|
|
514
|
+
// --- Create icon row (.chat-input-wrapper) appended to #chatForm ---
|
|
515
|
+
var form = document.getElementById('chatForm');
|
|
516
|
+
var wrapper = document.querySelector('.chat-input-wrapper');
|
|
517
|
+
if (!wrapper) {
|
|
518
|
+
wrapper = document.createElement('div');
|
|
519
|
+
wrapper.className = 'chat-input-wrapper';
|
|
520
|
+
if (form) form.appendChild(wrapper);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// --- Create brainstorm icon button ---
|
|
524
|
+
var brainstormBtn = document.createElement('button');
|
|
525
|
+
brainstormBtn.type = 'button';
|
|
526
|
+
brainstormBtn.className = 'brainstorm-icon-btn';
|
|
527
|
+
if (window.__synthOSTooltip) window.__synthOSTooltip(brainstormBtn, 'Brainstorm ideas');
|
|
528
|
+
brainstormBtn.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">' +
|
|
529
|
+
'<circle cx="12" cy="12" r="3"></circle>' +
|
|
530
|
+
'<path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"></path>' +
|
|
531
|
+
'</svg>';
|
|
532
|
+
wrapper.appendChild(brainstormBtn);
|
|
533
|
+
|
|
534
|
+
// --- Create send button ---
|
|
535
|
+
var sendBtn = document.createElement('button');
|
|
536
|
+
sendBtn.type = 'submit';
|
|
537
|
+
sendBtn.className = 'chat-send-btn';
|
|
538
|
+
if (window.__synthOSTooltip) window.__synthOSTooltip(sendBtn, 'Send message');
|
|
539
|
+
sendBtn.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">' +
|
|
540
|
+
'<line x1="12" y1="19" x2="12" y2="5"></line>' +
|
|
541
|
+
'<polyline points="5 12 12 5 19 12"></polyline>' +
|
|
542
|
+
'</svg>';
|
|
543
|
+
wrapper.appendChild(sendBtn);
|
|
544
|
+
|
|
545
|
+
// --- Auto-grow textarea (capped) ---
|
|
546
|
+
chatInput.addEventListener('input', function() {
|
|
547
|
+
this.style.height = 'auto';
|
|
548
|
+
var maxH = parseFloat(getComputedStyle(this).maxHeight) || 120;
|
|
549
|
+
this.style.height = Math.min(this.scrollHeight, maxH) + 'px';
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
// --- Create brainstorm modal ---
|
|
553
|
+
var modal = document.createElement('div');
|
|
554
|
+
modal.id = 'synthos-brainstormModal';
|
|
555
|
+
modal.className = 'modal-overlay brainstorm-modal';
|
|
556
|
+
modal.innerHTML =
|
|
557
|
+
'<div class="modal-content">' +
|
|
558
|
+
'<div class="modal-header">' +
|
|
559
|
+
'<span>Brainstorm</span>' +
|
|
560
|
+
'<button type="button" class="brainstorm-close-btn" id="synthos-brainstormCloseBtn">×</button>' +
|
|
561
|
+
'</div>' +
|
|
562
|
+
'<div class="brainstorm-messages" id="synthos-brainstormMessages"></div>' +
|
|
563
|
+
'<div class="brainstorm-input-row">' +
|
|
564
|
+
'<input type="text" class="brainstorm-input" id="synthos-brainstormInput" placeholder="What\'s on your mind...">' +
|
|
565
|
+
'<button type="button" class="brainstorm-send-btn" id="synthos-brainstormSendBtn">Send</button>' +
|
|
566
|
+
'</div>' +
|
|
567
|
+
'</div>';
|
|
568
|
+
document.body.appendChild(modal);
|
|
569
|
+
|
|
570
|
+
// --- State ---
|
|
571
|
+
var brainstormHistory = [];
|
|
572
|
+
|
|
573
|
+
// --- Helpers ---
|
|
574
|
+
function openBrainstorm() {
|
|
575
|
+
modal.classList.add('show');
|
|
576
|
+
// Grab text from chat input as initial topic
|
|
577
|
+
var topic = chatInput.value.trim();
|
|
578
|
+
if (topic) {
|
|
579
|
+
chatInput.value = '';
|
|
580
|
+
sendBrainstormText(topic, true);
|
|
581
|
+
} else {
|
|
582
|
+
// No topic — send context-only opener so LLM starts the brainstorm
|
|
583
|
+
sendBrainstormText('', true);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function closeBrainstorm() {
|
|
588
|
+
modal.classList.remove('show');
|
|
589
|
+
brainstormHistory = [];
|
|
590
|
+
document.getElementById('synthos-brainstormMessages').innerHTML = '';
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
function scrollBrainstormToBottom() {
|
|
594
|
+
var el = document.getElementById('synthos-brainstormMessages');
|
|
595
|
+
el.scrollTo({ top: el.scrollHeight, behavior: 'smooth' });
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function escapeHtml(str) {
|
|
599
|
+
var div = document.createElement('div');
|
|
600
|
+
div.appendChild(document.createTextNode(str));
|
|
601
|
+
return div.innerHTML;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
function appendBrainstormMessage(role, text, prompt, suggestions, isOpener) {
|
|
605
|
+
var div = document.createElement('div');
|
|
606
|
+
div.className = 'brainstorm-message ' + (role === 'user' ? 'brainstorm-user' : 'brainstorm-assistant');
|
|
607
|
+
if (role === 'assistant') {
|
|
608
|
+
var html;
|
|
609
|
+
if (typeof marked !== 'undefined') {
|
|
610
|
+
html = marked.parse(text);
|
|
611
|
+
} else {
|
|
612
|
+
html = escapeHtml(text);
|
|
613
|
+
}
|
|
614
|
+
div.innerHTML = '<strong>' + pn + ':</strong> ' + html;
|
|
615
|
+
// Clickable suggestion chips
|
|
616
|
+
if (suggestions && suggestions.length > 0) {
|
|
617
|
+
var chips = document.createElement('div');
|
|
618
|
+
chips.className = 'brainstorm-suggestions';
|
|
619
|
+
suggestions.forEach(function(s) {
|
|
620
|
+
var chip = document.createElement('button');
|
|
621
|
+
chip.type = 'button';
|
|
622
|
+
chip.className = 'brainstorm-suggestion-chip';
|
|
623
|
+
chip.textContent = s;
|
|
624
|
+
chip.addEventListener('click', function() {
|
|
625
|
+
submitSuggestion(s);
|
|
626
|
+
});
|
|
627
|
+
chips.appendChild(chip);
|
|
628
|
+
});
|
|
629
|
+
div.appendChild(chips);
|
|
630
|
+
}
|
|
631
|
+
// "Build It" button — skip on the opener response
|
|
632
|
+
if (prompt && !isOpener) {
|
|
633
|
+
var btnRow = document.createElement('div');
|
|
634
|
+
btnRow.className = 'brainstorm-build-row';
|
|
635
|
+
var buildBtn = document.createElement('button');
|
|
636
|
+
buildBtn.type = 'button';
|
|
637
|
+
buildBtn.className = 'brainstorm-build-btn';
|
|
638
|
+
buildBtn.textContent = 'Build It';
|
|
639
|
+
buildBtn.setAttribute('data-prompt', prompt);
|
|
640
|
+
buildBtn.addEventListener('click', function() {
|
|
641
|
+
chatInput.value = this.getAttribute('data-prompt');
|
|
642
|
+
closeBrainstorm();
|
|
643
|
+
chatInput.focus();
|
|
644
|
+
});
|
|
645
|
+
btnRow.appendChild(buildBtn);
|
|
646
|
+
div.appendChild(btnRow);
|
|
647
|
+
}
|
|
648
|
+
} else {
|
|
649
|
+
div.textContent = text;
|
|
650
|
+
}
|
|
651
|
+
document.getElementById('synthos-brainstormMessages').appendChild(div);
|
|
652
|
+
scrollBrainstormToBottom();
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
function submitSuggestion(text) {
|
|
656
|
+
// Disable old suggestion chips so they can't be double-clicked
|
|
657
|
+
var oldChips = document.querySelectorAll('#synthos-brainstormMessages .brainstorm-suggestion-chip');
|
|
658
|
+
for (var i = 0; i < oldChips.length; i++) {
|
|
659
|
+
oldChips[i].disabled = true;
|
|
660
|
+
}
|
|
661
|
+
sendBrainstormText(text, false);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function getBrainstormContext() {
|
|
665
|
+
var chatEl = document.getElementById('chatMessages');
|
|
666
|
+
if (!chatEl) return '<CHAT_HISTORY>\n';
|
|
667
|
+
var msgs = chatEl.querySelectorAll('.chat-message');
|
|
668
|
+
var lines = [];
|
|
669
|
+
var started = false;
|
|
670
|
+
for (var i = 0; i < msgs.length; i++) {
|
|
671
|
+
var text = msgs[i].innerText;
|
|
672
|
+
if (!started && /^User:/i.test(text.trim())) started = true;
|
|
673
|
+
if (started) lines.push(text);
|
|
674
|
+
}
|
|
675
|
+
return '<CHAT_HISTORY>\n' + lines.join('\n');
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// Send from the input field
|
|
679
|
+
function sendBrainstormMessage() {
|
|
680
|
+
var input = document.getElementById('synthos-brainstormInput');
|
|
681
|
+
var text = input.value.trim();
|
|
682
|
+
if (!text) return;
|
|
683
|
+
input.value = '';
|
|
684
|
+
sendBrainstormText(text, false);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// Core fetch — isOpener=true means this is the initial call when brainstorm opens
|
|
688
|
+
function sendBrainstormText(text, isOpener) {
|
|
689
|
+
var input = document.getElementById('synthos-brainstormInput');
|
|
690
|
+
var userMsg = text || (isOpener ? 'Look at the conversation so far and suggest what we could build or improve.' : '');
|
|
691
|
+
if (!userMsg) return;
|
|
692
|
+
|
|
693
|
+
// Show user message in chat (skip for auto-generated opener)
|
|
694
|
+
if (text) {
|
|
695
|
+
appendBrainstormMessage('user', text);
|
|
696
|
+
}
|
|
697
|
+
brainstormHistory.push({ role: 'user', content: userMsg });
|
|
698
|
+
|
|
699
|
+
var thinking = document.createElement('div');
|
|
700
|
+
thinking.className = 'brainstorm-thinking';
|
|
701
|
+
thinking.id = 'synthos-brainstormThinking';
|
|
702
|
+
thinking.textContent = 'Thinking...';
|
|
703
|
+
document.getElementById('synthos-brainstormMessages').appendChild(thinking);
|
|
704
|
+
scrollBrainstormToBottom();
|
|
705
|
+
|
|
706
|
+
input.disabled = true;
|
|
707
|
+
document.getElementById('synthos-brainstormSendBtn').disabled = true;
|
|
708
|
+
|
|
709
|
+
fetch('/api/brainstorm', {
|
|
710
|
+
method: 'POST',
|
|
711
|
+
headers: { 'Content-Type': 'application/json' },
|
|
712
|
+
body: JSON.stringify({
|
|
713
|
+
context: getBrainstormContext(),
|
|
714
|
+
messages: brainstormHistory
|
|
715
|
+
})
|
|
716
|
+
})
|
|
717
|
+
.then(function(res) {
|
|
718
|
+
if (!res.ok) throw new Error('Brainstorm request failed');
|
|
719
|
+
return res.json();
|
|
720
|
+
})
|
|
721
|
+
.then(function(data) {
|
|
722
|
+
var thinkingEl = document.getElementById('synthos-brainstormThinking');
|
|
723
|
+
if (thinkingEl) thinkingEl.remove();
|
|
724
|
+
|
|
725
|
+
var response = data.response || 'Sorry, I didn\'t get a response.';
|
|
726
|
+
var prompt = data.prompt || '';
|
|
727
|
+
var suggestions = Array.isArray(data.suggestions) ? data.suggestions : [];
|
|
728
|
+
appendBrainstormMessage('assistant', response, prompt, suggestions, isOpener);
|
|
729
|
+
brainstormHistory.push({
|
|
730
|
+
role: 'assistant',
|
|
731
|
+
content: response + '\n\n[Suggested prompt: ' + prompt + ']'
|
|
732
|
+
});
|
|
733
|
+
})
|
|
734
|
+
.catch(function(err) {
|
|
735
|
+
var thinkingEl = document.getElementById('synthos-brainstormThinking');
|
|
736
|
+
if (thinkingEl) thinkingEl.remove();
|
|
737
|
+
appendBrainstormMessage('assistant', 'Something went wrong: ' + err.message);
|
|
738
|
+
})
|
|
739
|
+
.finally(function() {
|
|
740
|
+
input.disabled = false;
|
|
741
|
+
document.getElementById('synthos-brainstormSendBtn').disabled = false;
|
|
742
|
+
input.focus();
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
// --- Event listeners ---
|
|
747
|
+
brainstormBtn.addEventListener('click', openBrainstorm);
|
|
748
|
+
document.getElementById('synthos-brainstormCloseBtn').addEventListener('click', closeBrainstorm);
|
|
749
|
+
|
|
750
|
+
var brainstormMouseDownTarget = null;
|
|
751
|
+
modal.addEventListener('mousedown', function(e) { brainstormMouseDownTarget = e.target; });
|
|
752
|
+
modal.addEventListener('click', function(e) {
|
|
753
|
+
if (e.target === modal && brainstormMouseDownTarget === modal) closeBrainstorm();
|
|
754
|
+
brainstormMouseDownTarget = null;
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
document.addEventListener('keydown', function(e) {
|
|
758
|
+
if (e.key === 'Escape' && modal.classList.contains('show')) closeBrainstorm();
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
document.getElementById('synthos-brainstormSendBtn').addEventListener('click', sendBrainstormMessage);
|
|
762
|
+
document.getElementById('synthos-brainstormInput').addEventListener('keydown', function(e) {
|
|
763
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
764
|
+
e.preventDefault();
|
|
765
|
+
sendBrainstormMessage();
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
})();
|
|
769
|
+
|
|
770
|
+
// 8. Attach button — + menu, attachment pills, file picker, screenshot tool
|
|
771
|
+
(function() {
|
|
772
|
+
var chatInput = document.getElementById('chatInput');
|
|
773
|
+
if (!chatInput) return;
|
|
774
|
+
var chatForm = document.getElementById('chatForm');
|
|
775
|
+
var wrapper = chatForm ? chatForm.querySelector('.chat-input-wrapper') : null;
|
|
776
|
+
if (!wrapper) return;
|
|
777
|
+
|
|
778
|
+
// --- Attachments state ---
|
|
779
|
+
if (!window.__synthOSAttachments) window.__synthOSAttachments = [];
|
|
780
|
+
|
|
781
|
+
// --- Create pills container (inside #chatForm, before textarea) ---
|
|
782
|
+
var pillsContainer = document.createElement('div');
|
|
783
|
+
pillsContainer.className = 'attachment-pills';
|
|
784
|
+
if (chatForm) {
|
|
785
|
+
chatForm.insertBefore(pillsContainer, chatForm.firstChild);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
function renderPills() {
|
|
789
|
+
pillsContainer.innerHTML = '';
|
|
790
|
+
var attachments = window.__synthOSAttachments;
|
|
791
|
+
if (!attachments || attachments.length === 0) return;
|
|
792
|
+
for (var i = 0; i < attachments.length; i++) {
|
|
793
|
+
(function(idx) {
|
|
794
|
+
var att = attachments[idx];
|
|
795
|
+
var pill = document.createElement('div');
|
|
796
|
+
pill.className = 'attachment-pill';
|
|
797
|
+
|
|
798
|
+
var thumb = document.createElement('img');
|
|
799
|
+
thumb.src = 'data:' + att.mediaType + ';base64,' + att.data;
|
|
800
|
+
thumb.style.cssText = 'width:24px;height:24px;object-fit:cover;border-radius:3px;';
|
|
801
|
+
pill.appendChild(thumb);
|
|
802
|
+
|
|
803
|
+
var nameSpan = document.createElement('span');
|
|
804
|
+
nameSpan.textContent = att.name || 'image';
|
|
805
|
+
nameSpan.style.cssText = 'flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;';
|
|
806
|
+
pill.appendChild(nameSpan);
|
|
807
|
+
|
|
808
|
+
var removeBtn = document.createElement('button');
|
|
809
|
+
removeBtn.type = 'button';
|
|
810
|
+
removeBtn.className = 'attachment-pill-remove';
|
|
811
|
+
removeBtn.textContent = '\u00d7';
|
|
812
|
+
removeBtn.addEventListener('click', function() {
|
|
813
|
+
window.__synthOSAttachments.splice(idx, 1);
|
|
814
|
+
renderPills();
|
|
815
|
+
});
|
|
816
|
+
pill.appendChild(removeBtn);
|
|
817
|
+
|
|
818
|
+
pillsContainer.appendChild(pill);
|
|
819
|
+
})(i);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// Expose for debugging
|
|
824
|
+
window.__synthOSRenderPills = renderPills;
|
|
825
|
+
|
|
826
|
+
// --- Helper: add an image attachment from a data URL ---
|
|
827
|
+
function addImageFromDataUrl(dataUrl, name) {
|
|
828
|
+
var commaIdx = dataUrl.indexOf(',');
|
|
829
|
+
if (commaIdx === -1) return;
|
|
830
|
+
var meta = dataUrl.substring(0, commaIdx); // data:image/png;base64
|
|
831
|
+
var base64 = dataUrl.substring(commaIdx + 1);
|
|
832
|
+
var mediaType = meta.replace('data:', '').replace(';base64', '');
|
|
833
|
+
window.__synthOSAttachments.push({
|
|
834
|
+
mediaType: mediaType,
|
|
835
|
+
data: base64,
|
|
836
|
+
name: name || 'image'
|
|
837
|
+
});
|
|
838
|
+
renderPills();
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// --- Hidden file input ---
|
|
842
|
+
var fileInput = document.createElement('input');
|
|
843
|
+
fileInput.type = 'file';
|
|
844
|
+
fileInput.style.display = 'none';
|
|
845
|
+
document.body.appendChild(fileInput);
|
|
846
|
+
|
|
847
|
+
fileInput.addEventListener('change', function() {
|
|
848
|
+
var file = fileInput.files && fileInput.files[0];
|
|
849
|
+
if (!file) return;
|
|
850
|
+
var reader = new FileReader();
|
|
851
|
+
reader.onload = function() {
|
|
852
|
+
addImageFromDataUrl(reader.result, file.name);
|
|
853
|
+
};
|
|
854
|
+
reader.readAsDataURL(file);
|
|
855
|
+
fileInput.value = '';
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
// --- Paste image from clipboard (document-level to catch all pastes) ---
|
|
859
|
+
document.addEventListener('paste', function(e) {
|
|
860
|
+
// Only handle pastes when chat input is focused or no other editable is focused
|
|
861
|
+
var active = document.activeElement;
|
|
862
|
+
var isEditable = active && (active.isContentEditable ||
|
|
863
|
+
(active.tagName === 'TEXTAREA' && active !== chatInput) ||
|
|
864
|
+
(active.tagName === 'INPUT' && active !== chatInput));
|
|
865
|
+
if (isEditable) return;
|
|
866
|
+
|
|
867
|
+
var items = e.clipboardData && e.clipboardData.items;
|
|
868
|
+
if (!items) return;
|
|
869
|
+
for (var i = 0; i < items.length; i++) {
|
|
870
|
+
if (items[i].type.indexOf('image/') === 0) {
|
|
871
|
+
var blob = items[i].getAsFile();
|
|
872
|
+
if (!blob) continue;
|
|
873
|
+
e.preventDefault();
|
|
874
|
+
var reader = new FileReader();
|
|
875
|
+
reader.onload = function() {
|
|
876
|
+
addImageFromDataUrl(reader.result, 'pasted-image.png');
|
|
877
|
+
};
|
|
878
|
+
reader.readAsDataURL(blob);
|
|
879
|
+
return; // only handle the first image
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
});
|
|
883
|
+
|
|
884
|
+
// --- Drag-and-drop file attachment ---
|
|
885
|
+
var chatForm = document.getElementById('chatForm');
|
|
886
|
+
if (chatForm) {
|
|
887
|
+
chatForm.addEventListener('dragover', function(e) {
|
|
888
|
+
e.preventDefault();
|
|
889
|
+
e.stopPropagation();
|
|
890
|
+
});
|
|
891
|
+
chatForm.addEventListener('drop', function(e) {
|
|
892
|
+
e.preventDefault();
|
|
893
|
+
e.stopPropagation();
|
|
894
|
+
var files = e.dataTransfer && e.dataTransfer.files;
|
|
895
|
+
if (!files || !files.length) return;
|
|
896
|
+
for (var i = 0; i < files.length; i++) {
|
|
897
|
+
(function(file) {
|
|
898
|
+
var reader = new FileReader();
|
|
899
|
+
reader.onload = function() {
|
|
900
|
+
addImageFromDataUrl(reader.result, file.name);
|
|
901
|
+
};
|
|
902
|
+
reader.readAsDataURL(file);
|
|
903
|
+
})(files[i]);
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
// --- + button ---
|
|
909
|
+
var attachBtn = document.createElement('button');
|
|
910
|
+
attachBtn.type = 'button';
|
|
911
|
+
attachBtn.className = 'attach-btn';
|
|
912
|
+
if (window.__synthOSTooltip) window.__synthOSTooltip(attachBtn, 'Attach file or screenshot');
|
|
913
|
+
attachBtn.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>';
|
|
914
|
+
wrapper.insertBefore(attachBtn, wrapper.firstChild);
|
|
915
|
+
|
|
916
|
+
// --- Popup menu ---
|
|
917
|
+
var menu = document.createElement('div');
|
|
918
|
+
menu.className = 'attach-menu';
|
|
919
|
+
|
|
920
|
+
var menuAttachFile = document.createElement('div');
|
|
921
|
+
menuAttachFile.className = 'attach-menu-item';
|
|
922
|
+
menuAttachFile.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"></path></svg> Attach File';
|
|
923
|
+
menu.appendChild(menuAttachFile);
|
|
924
|
+
|
|
925
|
+
var menuScreenshot = document.createElement('div');
|
|
926
|
+
menuScreenshot.className = 'attach-menu-item';
|
|
927
|
+
menuScreenshot.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg> Screenshot';
|
|
928
|
+
menu.appendChild(menuScreenshot);
|
|
929
|
+
|
|
930
|
+
wrapper.appendChild(menu);
|
|
931
|
+
|
|
932
|
+
var menuOpen = false;
|
|
933
|
+
function toggleMenu() {
|
|
934
|
+
menuOpen = !menuOpen;
|
|
935
|
+
menu.style.display = menuOpen ? 'flex' : 'none';
|
|
936
|
+
}
|
|
937
|
+
function closeMenu() {
|
|
938
|
+
menuOpen = false;
|
|
939
|
+
menu.style.display = 'none';
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
attachBtn.addEventListener('click', function(e) {
|
|
943
|
+
e.stopPropagation();
|
|
944
|
+
toggleMenu();
|
|
945
|
+
});
|
|
946
|
+
|
|
947
|
+
document.addEventListener('click', function() {
|
|
948
|
+
if (menuOpen) closeMenu();
|
|
949
|
+
});
|
|
950
|
+
menu.addEventListener('click', function(e) { e.stopPropagation(); });
|
|
951
|
+
|
|
952
|
+
menuAttachFile.addEventListener('click', function() {
|
|
953
|
+
closeMenu();
|
|
954
|
+
fileInput.click();
|
|
955
|
+
});
|
|
956
|
+
|
|
957
|
+
// --- Screenshot annotation flow (multi-rectangle) ---
|
|
958
|
+
menuScreenshot.addEventListener('click', function() {
|
|
959
|
+
closeMenu();
|
|
960
|
+
startScreenshotAnnotation();
|
|
961
|
+
});
|
|
962
|
+
|
|
963
|
+
function startScreenshotAnnotation() {
|
|
964
|
+
var viewerPanel = document.getElementById('viewerPanel');
|
|
965
|
+
if (!viewerPanel) return;
|
|
966
|
+
|
|
967
|
+
// Create overlay
|
|
968
|
+
var overlay = document.createElement('div');
|
|
969
|
+
overlay.className = 'screenshot-overlay';
|
|
970
|
+
|
|
971
|
+
// Instructions bar
|
|
972
|
+
var instrBar = document.createElement('div');
|
|
973
|
+
instrBar.style.cssText = 'position:absolute;top:10px;left:50%;transform:translateX(-50%);background:rgba(0,0,0,0.7);color:white;padding:6px 14px;border-radius:6px;font-size:13px;z-index:10;pointer-events:none;';
|
|
974
|
+
instrBar.textContent = 'Draw rectangles to highlight areas, then click Capture';
|
|
975
|
+
overlay.appendChild(instrBar);
|
|
976
|
+
|
|
977
|
+
// Persistent action buttons (always visible)
|
|
978
|
+
var actions = document.createElement('div');
|
|
979
|
+
actions.className = 'screenshot-actions';
|
|
980
|
+
actions.style.cssText = 'position:absolute;bottom:16px;left:50%;transform:translateX(-50%);display:flex;gap:8px;z-index:10;';
|
|
981
|
+
|
|
982
|
+
var captureBtn = document.createElement('button');
|
|
983
|
+
captureBtn.type = 'button';
|
|
984
|
+
captureBtn.textContent = 'Capture';
|
|
985
|
+
captureBtn.className = 'brainstorm-send-btn';
|
|
986
|
+
captureBtn.style.cssText = 'padding:6px 16px;font-size:13px;';
|
|
987
|
+
|
|
988
|
+
var cancelBtn = document.createElement('button');
|
|
989
|
+
cancelBtn.type = 'button';
|
|
990
|
+
cancelBtn.textContent = 'Cancel';
|
|
991
|
+
cancelBtn.className = 'brainstorm-send-btn';
|
|
992
|
+
cancelBtn.style.cssText = 'padding:6px 16px;font-size:13px;background:transparent;border:1px solid rgba(255,255,255,0.3);color:white;';
|
|
993
|
+
|
|
994
|
+
actions.appendChild(captureBtn);
|
|
995
|
+
actions.appendChild(cancelBtn);
|
|
996
|
+
overlay.appendChild(actions);
|
|
997
|
+
|
|
998
|
+
// Drawing state
|
|
999
|
+
var currentRect = null;
|
|
1000
|
+
var startX, startY, isDrawing = false;
|
|
1001
|
+
var allRects = []; // Array of {el, x, y, w, h}
|
|
1002
|
+
|
|
1003
|
+
overlay.addEventListener('mousedown', function(e) {
|
|
1004
|
+
if (e.target.tagName === 'BUTTON') return;
|
|
1005
|
+
isDrawing = true;
|
|
1006
|
+
var overlayBounds = overlay.getBoundingClientRect();
|
|
1007
|
+
startX = e.clientX - overlayBounds.left;
|
|
1008
|
+
startY = e.clientY - overlayBounds.top;
|
|
1009
|
+
|
|
1010
|
+
// Create a new rectangle element
|
|
1011
|
+
currentRect = document.createElement('div');
|
|
1012
|
+
currentRect.className = 'screenshot-rect';
|
|
1013
|
+
currentRect.style.display = 'block';
|
|
1014
|
+
currentRect.style.left = startX + 'px';
|
|
1015
|
+
currentRect.style.top = startY + 'px';
|
|
1016
|
+
currentRect.style.width = '0';
|
|
1017
|
+
currentRect.style.height = '0';
|
|
1018
|
+
overlay.appendChild(currentRect);
|
|
1019
|
+
});
|
|
1020
|
+
|
|
1021
|
+
overlay.addEventListener('mousemove', function(e) {
|
|
1022
|
+
if (!isDrawing || !currentRect) return;
|
|
1023
|
+
var overlayBounds = overlay.getBoundingClientRect();
|
|
1024
|
+
var curX = e.clientX - overlayBounds.left;
|
|
1025
|
+
var curY = e.clientY - overlayBounds.top;
|
|
1026
|
+
var x = Math.min(startX, curX);
|
|
1027
|
+
var y = Math.min(startY, curY);
|
|
1028
|
+
var w = Math.abs(curX - startX);
|
|
1029
|
+
var h = Math.abs(curY - startY);
|
|
1030
|
+
currentRect.style.left = x + 'px';
|
|
1031
|
+
currentRect.style.top = y + 'px';
|
|
1032
|
+
currentRect.style.width = w + 'px';
|
|
1033
|
+
currentRect.style.height = h + 'px';
|
|
1034
|
+
});
|
|
1035
|
+
|
|
1036
|
+
overlay.addEventListener('mouseup', function() {
|
|
1037
|
+
if (!isDrawing || !currentRect) return;
|
|
1038
|
+
isDrawing = false;
|
|
1039
|
+
var w = parseInt(currentRect.style.width);
|
|
1040
|
+
var h = parseInt(currentRect.style.height);
|
|
1041
|
+
if (w < 10 || h < 10) {
|
|
1042
|
+
// Too small — discard
|
|
1043
|
+
currentRect.remove();
|
|
1044
|
+
currentRect = null;
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
allRects.push({
|
|
1048
|
+
el: currentRect,
|
|
1049
|
+
x: parseInt(currentRect.style.left),
|
|
1050
|
+
y: parseInt(currentRect.style.top),
|
|
1051
|
+
w: w,
|
|
1052
|
+
h: h
|
|
1053
|
+
});
|
|
1054
|
+
currentRect = null;
|
|
1055
|
+
});
|
|
1056
|
+
|
|
1057
|
+
captureBtn.addEventListener('click', function() {
|
|
1058
|
+
doCapture();
|
|
1059
|
+
});
|
|
1060
|
+
cancelBtn.addEventListener('click', function() {
|
|
1061
|
+
cleanup();
|
|
1062
|
+
});
|
|
1063
|
+
|
|
1064
|
+
function doCapture() {
|
|
1065
|
+
if (typeof html2canvas === 'undefined') {
|
|
1066
|
+
console.error('html2canvas not loaded');
|
|
1067
|
+
cleanup();
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
// Capture the full viewer panel without the overlay
|
|
1072
|
+
overlay.style.visibility = 'hidden';
|
|
1073
|
+
|
|
1074
|
+
html2canvas(viewerPanel, { useCORS: true, logging: false }).then(function(fullCanvas) {
|
|
1075
|
+
// Draw red rectangles onto the captured canvas
|
|
1076
|
+
var vpRect = viewerPanel.getBoundingClientRect();
|
|
1077
|
+
var scaleX = fullCanvas.width / vpRect.width;
|
|
1078
|
+
var scaleY = fullCanvas.height / vpRect.height;
|
|
1079
|
+
|
|
1080
|
+
var ctx = fullCanvas.getContext('2d');
|
|
1081
|
+
ctx.strokeStyle = 'red';
|
|
1082
|
+
ctx.lineWidth = 3 * Math.max(scaleX, scaleY);
|
|
1083
|
+
|
|
1084
|
+
for (var i = 0; i < allRects.length; i++) {
|
|
1085
|
+
var r = allRects[i];
|
|
1086
|
+
ctx.strokeRect(
|
|
1087
|
+
Math.round(r.x * scaleX),
|
|
1088
|
+
Math.round(r.y * scaleY),
|
|
1089
|
+
Math.round(r.w * scaleX),
|
|
1090
|
+
Math.round(r.h * scaleY)
|
|
1091
|
+
);
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
var dataUrl = fullCanvas.toDataURL('image/png');
|
|
1095
|
+
var base64 = dataUrl.split(',')[1];
|
|
1096
|
+
window.__synthOSAttachments.push({
|
|
1097
|
+
mediaType: 'image/png',
|
|
1098
|
+
data: base64,
|
|
1099
|
+
name: 'screenshot.png'
|
|
1100
|
+
});
|
|
1101
|
+
renderPills();
|
|
1102
|
+
cleanup();
|
|
1103
|
+
}).catch(function(err) {
|
|
1104
|
+
console.error('Screenshot capture failed:', err);
|
|
1105
|
+
cleanup();
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
function cleanup() {
|
|
1110
|
+
if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
|
|
1111
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
// Escape to cancel
|
|
1115
|
+
function onKeyDown(e) {
|
|
1116
|
+
if (e.key === 'Escape') {
|
|
1117
|
+
cleanup();
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
document.addEventListener('keydown', onKeyDown);
|
|
1121
|
+
|
|
1122
|
+
viewerPanel.style.position = 'relative';
|
|
1123
|
+
viewerPanel.appendChild(overlay);
|
|
1124
|
+
}
|
|
1125
|
+
})();
|
|
1126
|
+
|
|
1127
|
+
// 9. Undo link — shown after the last chat message when a version exists
|
|
1128
|
+
(function() {
|
|
1129
|
+
var meta = document.querySelector('meta[name="synthos-version"]');
|
|
1130
|
+
if (!meta) return;
|
|
1131
|
+
var version = parseInt(meta.getAttribute('content'), 10);
|
|
1132
|
+
if (!version || version <= 0) return;
|
|
1133
|
+
|
|
1134
|
+
var cm = document.getElementById('chatMessages');
|
|
1135
|
+
if (!cm) return;
|
|
1136
|
+
|
|
1137
|
+
// Remove any existing undo links
|
|
1138
|
+
var existing = cm.querySelectorAll('.synthos-undo-link');
|
|
1139
|
+
for (var i = 0; i < existing.length; i++) existing[i].remove();
|
|
1140
|
+
|
|
1141
|
+
// Create undo link div
|
|
1142
|
+
var undoDiv = document.createElement('div');
|
|
1143
|
+
undoDiv.className = 'synthos-undo-link';
|
|
1144
|
+
undoDiv.style.cssText = 'text-align:right;padding:4px 12px 2px;';
|
|
1145
|
+
|
|
1146
|
+
var link = document.createElement('a');
|
|
1147
|
+
link.href = '#';
|
|
1148
|
+
link.textContent = 'undo';
|
|
1149
|
+
link.style.cssText = 'color:var(--accent-primary,#a78bfa);font-size:12px;text-decoration:none;opacity:0.7;';
|
|
1150
|
+
link.addEventListener('mouseenter', function() { link.style.opacity = '1'; link.style.textDecoration = 'underline'; });
|
|
1151
|
+
link.addEventListener('mouseleave', function() { link.style.opacity = '0.7'; link.style.textDecoration = 'none'; });
|
|
1152
|
+
|
|
1153
|
+
link.addEventListener('click', function(e) {
|
|
1154
|
+
e.preventDefault();
|
|
1155
|
+
var overlay = document.getElementById('loadingOverlay');
|
|
1156
|
+
if (overlay) overlay.style.display = 'flex';
|
|
1157
|
+
|
|
1158
|
+
fetch(window.location.pathname + '/undo', {
|
|
1159
|
+
method: 'POST',
|
|
1160
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1161
|
+
body: '{}'
|
|
1162
|
+
})
|
|
1163
|
+
.then(function(res) { return res.text(); })
|
|
1164
|
+
.then(function(html) {
|
|
1165
|
+
window.__synthOSChatPanel = false;
|
|
1166
|
+
window.__synthOSPageDirty = false;
|
|
1167
|
+
window.__synthOSNavigateTo = null;
|
|
1168
|
+
document.open();
|
|
1169
|
+
document.write(html);
|
|
1170
|
+
document.close();
|
|
1171
|
+
})
|
|
1172
|
+
.catch(function(err) {
|
|
1173
|
+
console.error('Undo failed:', err);
|
|
1174
|
+
if (overlay) overlay.style.display = 'none';
|
|
1175
|
+
});
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1178
|
+
undoDiv.appendChild(link);
|
|
1179
|
+
|
|
1180
|
+
// "try again" link — re-submits the last user message against the previous page state
|
|
1181
|
+
var msgs = cm.querySelectorAll('.chat-message');
|
|
1182
|
+
var lastUserMsg = '';
|
|
1183
|
+
for (var j = msgs.length - 1; j >= 0; j--) {
|
|
1184
|
+
var strong = msgs[j].querySelector('strong');
|
|
1185
|
+
if (strong && strong.textContent.trim().replace(/:$/, '') === 'User') {
|
|
1186
|
+
// Get the text content after "User:" — everything in the <p> minus the strong
|
|
1187
|
+
var p = msgs[j].querySelector('p');
|
|
1188
|
+
if (p) {
|
|
1189
|
+
var clone = p.cloneNode(true);
|
|
1190
|
+
var s = clone.querySelector('strong');
|
|
1191
|
+
if (s) s.remove();
|
|
1192
|
+
lastUserMsg = clone.textContent.trim();
|
|
1193
|
+
}
|
|
1194
|
+
break;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
if (lastUserMsg) {
|
|
1199
|
+
var sep = document.createTextNode(' · ');
|
|
1200
|
+
undoDiv.appendChild(sep);
|
|
1201
|
+
|
|
1202
|
+
var tryLink = document.createElement('a');
|
|
1203
|
+
tryLink.href = '#';
|
|
1204
|
+
tryLink.textContent = 'try again';
|
|
1205
|
+
tryLink.style.cssText = 'color:var(--accent-primary,#a78bfa);font-size:12px;text-decoration:none;opacity:0.7;';
|
|
1206
|
+
tryLink.addEventListener('mouseenter', function() { tryLink.style.opacity = '1'; tryLink.style.textDecoration = 'underline'; });
|
|
1207
|
+
tryLink.addEventListener('mouseleave', function() { tryLink.style.opacity = '0.7'; tryLink.style.textDecoration = 'none'; });
|
|
1208
|
+
|
|
1209
|
+
tryLink.addEventListener('click', function(e) {
|
|
1210
|
+
e.preventDefault();
|
|
1211
|
+
var overlay = document.getElementById('loadingOverlay');
|
|
1212
|
+
if (overlay) overlay.style.display = 'flex';
|
|
1213
|
+
var ci = document.getElementById('chatInput');
|
|
1214
|
+
if (ci) ci.disabled = true;
|
|
1215
|
+
var sb = document.querySelector('.chat-send-btn');
|
|
1216
|
+
if (sb) sb.disabled = true;
|
|
1217
|
+
|
|
1218
|
+
fetch(window.location.pathname, {
|
|
1219
|
+
method: 'POST',
|
|
1220
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1221
|
+
body: JSON.stringify({ message: lastUserMsg, tryAgain: true })
|
|
1222
|
+
})
|
|
1223
|
+
.then(function(res) { return res.text(); })
|
|
1224
|
+
.then(function(html) {
|
|
1225
|
+
window.__synthOSPageDirty = true;
|
|
1226
|
+
window.__synthOSChatPanel = false;
|
|
1227
|
+
window.__synthOSNavigateTo = null;
|
|
1228
|
+
document.open();
|
|
1229
|
+
document.write(html);
|
|
1230
|
+
document.close();
|
|
1231
|
+
})
|
|
1232
|
+
.catch(function(err) {
|
|
1233
|
+
console.error('Try again failed:', err);
|
|
1234
|
+
if (overlay) overlay.style.display = 'none';
|
|
1235
|
+
if (ci) ci.disabled = false;
|
|
1236
|
+
if (sb) sb.disabled = false;
|
|
1237
|
+
});
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1240
|
+
undoDiv.appendChild(tryLink);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
cm.appendChild(undoDiv);
|
|
1244
|
+
})();
|
|
1245
|
+
|
|
1246
|
+
// 10. Unsaved-changes prompt for required pages (FluentLM dialog)
|
|
1247
|
+
(function() {
|
|
1248
|
+
// Create the unsaved-changes confirmation dialog
|
|
1249
|
+
var overlay = document.createElement('div');
|
|
1250
|
+
overlay.className = 'flm-dialog-overlay';
|
|
1251
|
+
overlay.id = 'synthos-unsavedDialog';
|
|
1252
|
+
overlay.innerHTML =
|
|
1253
|
+
'<div class="flm-dialog">' +
|
|
1254
|
+
'<div class="flm-dialog-header">' +
|
|
1255
|
+
'<h2 class="flm-dialog-title">Unsaved Changes</h2>' +
|
|
1256
|
+
'<button class="flm-dialog-close" data-icon="Cancel" aria-label="Close" data-dialog-close></button>' +
|
|
1257
|
+
'</div>' +
|
|
1258
|
+
'<div class="flm-dialog-body">You have unsaved changes that will be lost if you leave this page.</div>' +
|
|
1259
|
+
'<div class="flm-dialog-footer">' +
|
|
1260
|
+
'<button class="flm-button" data-dialog-close id="synthos-unsavedStay">Stay</button>' +
|
|
1261
|
+
'<button class="flm-button flm-button--primary" id="synthos-unsavedLeave">Leave</button>' +
|
|
1262
|
+
'</div>' +
|
|
1263
|
+
'</div>';
|
|
1264
|
+
document.body.appendChild(overlay);
|
|
1265
|
+
|
|
1266
|
+
var pendingUrl = null;
|
|
1267
|
+
|
|
1268
|
+
document.getElementById('synthos-unsavedLeave').addEventListener('click', function() {
|
|
1269
|
+
overlay.classList.remove('is-open');
|
|
1270
|
+
if (pendingUrl) {
|
|
1271
|
+
window.__synthOSPageDirty = false;
|
|
1272
|
+
window.location.href = pendingUrl;
|
|
1273
|
+
}
|
|
1274
|
+
});
|
|
1275
|
+
|
|
1276
|
+
// Navigate with unsaved-changes guard
|
|
1277
|
+
window.__synthOSNavigateTo = function(url) {
|
|
1278
|
+
if (window.__synthOSPageDirty && window.pageInfo && window.pageInfo.isRequiredPage) {
|
|
1279
|
+
pendingUrl = url;
|
|
1280
|
+
overlay.classList.add('is-open');
|
|
1281
|
+
} else {
|
|
1282
|
+
window.location.href = url;
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
})();
|
|
1286
|
+
|
|
1287
|
+
|
|
1288
|
+
// Initial focus — run after all setup (including chat-collapsed check)
|
|
1289
|
+
if (chatInput && !document.body.classList.contains('chat-collapsed')) {
|
|
1290
|
+
chatInput.focus();
|
|
1291
|
+
}
|
|
1292
|
+
})();
|