@@ -12,6 +12,15 @@ function getPrefix(url) {
12
12
return prefix ;
13
13
}
14
14
15
+ const lessonHelperScriptRE = / < s c r i p t s r c = " [ ^ " ] + l e s s o n s - h e l p e r \. j s " > < \/ s c r i p t > / ;
16
+ const webglDebugHelperScriptRE = / < s c r i p t s r c = " [ ^ " ] + w e b g l - d e b u g - h e l p e r \. j s " > < \/ s c r i p t > / ;
17
+
18
+ function fixHTMLForCodeSite ( html ) {
19
+ html = html . replace ( lessonHelperScriptRE , '' ) ;
20
+ html = html . replace ( webglDebugHelperScriptRE , '' ) ;
21
+ return html ;
22
+ }
23
+
15
24
/**
16
25
* Fix any local URLs into fully qualified urls.
17
26
*
@@ -141,14 +150,36 @@ function requestCORSIfNotSameOrigin(img, url) {
141
150
return js ;
142
151
}
143
152
153
+ function prepHTML ( source , prefix ) {
154
+ source = source . replace ( '<head>' , `<head>
155
+ <link rel="stylesheet" href="${ prefix } /resources/lesson-helper.css" type="text/css">
156
+ <script match="false">self.lessonSettings = ${ JSON . stringify ( lessonSettings ) } </script>` ) ;
157
+
158
+ source = source . replace ( '</head>' , `<script src="${ prefix } /resources/webgl-debug-helper.js"></script>
159
+ <script src="${ prefix } /resources/lessons-helper.js"></script>
160
+ </head>` ) ;
161
+ return source ;
162
+ }
163
+
164
+ function getWorkerPreamble ( scriptInfo ) {
165
+ return `self.lessonSettings = ${ JSON . stringify ( lessonSettings ) } ;
166
+ import '${ dirname ( scriptInfo . fqURL ) } /resources/webgl-debug-helper.js';
167
+ import '${ dirname ( scriptInfo . fqURL ) } /resources/lessons-worker-helper.js';` ;
168
+ }
169
+
170
+ const lessonSettings = {
171
+ glDebug : true ,
172
+ } ;
173
+
144
174
window . lessonEditorSettings = {
145
175
extraHTMLParsing,
146
176
fixSourceLinks,
147
177
fixJSForCodeSite,
178
+ fixHTMLForCodeSite,
148
179
runOnResize : true ,
149
- lessonSettings : {
150
- glDebug : true ,
151
- } ,
180
+ lessonSettings,
181
+ prepHTML ,
182
+ getWorkerPreamble ,
152
183
tags : [ 'webgl' , 'webglfundamentals.org' ] ,
153
184
name : 'WebGLFundamentals' ,
154
185
icon : '/webgl/lessons/resources/webglfundamentals-icon-256.png' ,
0 commit comments