author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 24 Sep 2013 23:18:24 +0200 | |
branch | initialV |
changeset 1180 | 01c6be61f29c |
parent 521 | 2479b00a29eb |
child 716 | 753bf6548028 |
permissions | -rw-r--r-- |
30 | 1 |
" |
2 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
40 | 3 |
All Rights Reserved |
30 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
38 | 12 |
"{ Package: 'stx:libjavascript' }" |
30 | 13 |
|
4 | 14 |
Object subclass:#JavaScriptEnvironment |
178
447d73ac248d
nstance var _receiver makes problem with stc
Stefan Vogel <sv@exept.de>
parents:
89
diff
changeset
|
15 |
instanceVariableNames:'_theReceiver _functions _variables _outerEnvironment |
293 | 16 |
_isHTMLEnvironment _fallBackReceiver _outStream' |
4 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
47 | 19 |
category:'Languages-JavaScript-Framework' |
4 | 20 |
! |
21 |
||
70 | 22 |
Object subclass:#AppletObject |
23 |
instanceVariableNames:'window element view' |
|
24 |
classVariableNames:'' |
|
25 |
poolDictionaries:'' |
|
26 |
privateIn:JavaScriptEnvironment |
|
27 |
! |
|
28 |
||
29 |
Object subclass:#AppletsObject |
|
30 |
instanceVariableNames:'window' |
|
31 |
classVariableNames:'' |
|
32 |
poolDictionaries:'' |
|
33 |
privateIn:JavaScriptEnvironment |
|
34 |
! |
|
35 |
||
194 | 36 |
Smalltalk::Array variableSubclass:#Array |
43 | 37 |
instanceVariableNames:'' |
38 | 38 |
classVariableNames:'' |
39 |
poolDictionaries:'' |
|
40 |
privateIn:JavaScriptEnvironment |
|
41 |
! |
|
42 |
||
189 | 43 |
Timestamp subclass:#Date |
38 | 44 |
instanceVariableNames:'' |
45 |
classVariableNames:'' |
|
46 |
poolDictionaries:'' |
|
47 |
privateIn:JavaScriptEnvironment |
|
48 |
! |
|
49 |
||
30 | 50 |
Object subclass:#Document |
51 |
instanceVariableNames:'forms link anchor applets' |
|
52 |
classVariableNames:'' |
|
53 |
poolDictionaries:'' |
|
54 |
privateIn:JavaScriptEnvironment |
|
55 |
! |
|
56 |
||
70 | 57 |
Object subclass:#DocumentObject |
58 |
instanceVariableNames:'images applets forms links anchors' |
|
59 |
classVariableNames:'' |
|
60 |
poolDictionaries:'' |
|
61 |
privateIn:JavaScriptEnvironment |
|
62 |
! |
|
63 |
||
64 |
Object subclass:#FormFieldObject |
|
65 |
instanceVariableNames:'window element widget' |
|
66 |
classVariableNames:'' |
|
67 |
poolDictionaries:'' |
|
68 |
privateIn:JavaScriptEnvironment |
|
69 |
! |
|
70 |
||
71 |
Object subclass:#FormObject |
|
72 |
instanceVariableNames:'window element' |
|
73 |
classVariableNames:'' |
|
74 |
poolDictionaries:'' |
|
75 |
privateIn:JavaScriptEnvironment |
|
76 |
! |
|
77 |
||
78 |
Object subclass:#FormsObject |
|
79 |
instanceVariableNames:'window' |
|
80 |
classVariableNames:'' |
|
81 |
poolDictionaries:'' |
|
82 |
privateIn:JavaScriptEnvironment |
|
83 |
! |
|
84 |
||
43 | 85 |
Object subclass:#HistoryObject |
86 |
instanceVariableNames:'historyItems window' |
|
87 |
classVariableNames:'' |
|
88 |
poolDictionaries:'' |
|
89 |
privateIn:JavaScriptEnvironment |
|
90 |
! |
|
91 |
||
92 |
Object subclass:#Math |
|
93 |
instanceVariableNames:'' |
|
94 |
classVariableNames:'' |
|
95 |
poolDictionaries:'' |
|
96 |
privateIn:JavaScriptEnvironment |
|
97 |
! |
|
98 |
||
194 | 99 |
Smalltalk::String variableByteSubclass:#String |
17 | 100 |
instanceVariableNames:'' |
101 |
classVariableNames:'' |
|
102 |
poolDictionaries:'' |
|
103 |
privateIn:JavaScriptEnvironment |
|
104 |
! |
|
105 |
||
62 | 106 |
Object subclass:#WindowObject |
107 |
instanceVariableNames:'view history location document frames' |
|
23 | 108 |
classVariableNames:'' |
109 |
poolDictionaries:'' |
|
110 |
privateIn:JavaScriptEnvironment |
|
111 |
! |
|
112 |
||
30 | 113 |
!JavaScriptEnvironment class methodsFor:'documentation'! |
114 |
||
115 |
copyright |
|
116 |
" |
|
117 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
40 | 118 |
All Rights Reserved |
30 | 119 |
|
120 |
This software is furnished under a license and may be used |
|
121 |
only in accordance with the terms of that license and with the |
|
122 |
inclusion of the above copyright notice. This software may not |
|
123 |
be provided or otherwise made available to, or used by, any |
|
124 |
other person. No title to or ownership of the software is |
|
125 |
hereby transferred. |
|
126 |
" |
|
127 |
! ! |
|
10
cd104909f31a
special JavaString (different protocol)
Claus Gittinger <cg@exept.de>
parents:
4
diff
changeset
|
128 |
|
22 | 129 |
!JavaScriptEnvironment class methodsFor:'queries'! |
130 |
||
131 |
scriptingNamespace |
|
132 |
"return a namespace, in which the scripts global variables |
|
133 |
are searched. Returning myself here, will make Math and Date |
|
134 |
visible (maybe more in the future)" |
|
135 |
||
136 |
^ self |
|
137 |
||
138 |
"Created: / 17.5.1998 / 20:52:17 / cg" |
|
139 |
! ! |
|
140 |
||
18 | 141 |
!JavaScriptEnvironment methodsFor:'accessing'! |
142 |
||
38 | 143 |
_argVariables |
144 |
^ nil |
|
145 |
! |
|
146 |
||
62 | 147 |
_beHTMLEnvironment |
148 |
_isHTMLEnvironment := true |
|
149 |
! |
|
150 |
||
18 | 151 |
_defineFunction:aFunction as:selector |
23 | 152 |
_functions isNil ifTrue:[ |
40 | 153 |
_functions := IdentityDictionary new |
18 | 154 |
]. |
23 | 155 |
_functions at:selector put:aFunction |
18 | 156 |
|
157 |
"Created: / 17.5.1998 / 00:34:41 / cg" |
|
23 | 158 |
"Modified: / 17.5.1998 / 21:28:13 / cg" |
18 | 159 |
! |
160 |
||
399 | 161 |
_defineVariable:name value:initialValue |
162 |
_variables isNil ifTrue:[ |
|
163 |
_variables := IdentityDictionary new. |
|
164 |
]. |
|
165 |
_variables at:name asSymbol put:initialValue. |
|
166 |
! |
|
167 |
||
18 | 168 |
_functions |
23 | 169 |
^ _functions |
18 | 170 |
|
171 |
"Created: / 17.5.1998 / 00:02:36 / cg" |
|
23 | 172 |
"Modified: / 17.5.1998 / 21:28:17 / cg" |
18 | 173 |
! |
174 |
||
175 |
_functions:aDictionary |
|
23 | 176 |
_functions := aDictionary |
18 | 177 |
|
178 |
"Created: / 17.5.1998 / 00:02:43 / cg" |
|
23 | 179 |
"Modified: / 17.5.1998 / 21:28:20 / cg" |
18 | 180 |
! |
181 |
||
62 | 182 |
_isHTMLEnvironment |
183 |
^ _isHTMLEnvironment ? false |
|
184 |
! |
|
185 |
||
38 | 186 |
_localVariables |
187 |
^ _variables |
|
188 |
! |
|
189 |
||
190 |
_localVariables:aDictionary |
|
191 |
_variables := aDictionary |
|
192 |
||
193 |
"Created: / 17.5.1998 / 00:04:16 / cg" |
|
194 |
"Modified: / 17.5.1998 / 21:28:33 / cg" |
|
195 |
! |
|
196 |
||
293 | 197 |
_outStream |
198 |
^ _outStream |
|
199 |
! |
|
200 |
||
201 |
_outStream:aStream |
|
202 |
_outStream := aStream |
|
203 |
! |
|
204 |
||
18 | 205 |
_outerEnvironment |
23 | 206 |
^ _outerEnvironment |
18 | 207 |
|
208 |
"Created: / 17.5.1998 / 00:02:49 / cg" |
|
23 | 209 |
"Modified: / 17.5.1998 / 21:28:23 / cg" |
18 | 210 |
! |
211 |
||
212 |
_outerEnvironment:anEnvironment |
|
23 | 213 |
_outerEnvironment := anEnvironment |
18 | 214 |
|
215 |
"Created: / 17.5.1998 / 00:02:52 / cg" |
|
23 | 216 |
"Modified: / 17.5.1998 / 21:28:27 / cg" |
62 | 217 |
! |
218 |
||
219 |
_topEnvironment |
|
220 |
^ _outerEnvironment isNil ifTrue:self ifFalse:[_outerEnvironment _topEnvironment] |
|
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
221 |
! |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
222 |
|
309 | 223 |
isReturnedFrom:something |
224 |
"/ isReturnedFrom := something. |
|
225 |
! |
|
226 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
227 |
receiver |
178
447d73ac248d
nstance var _receiver makes problem with stc
Stefan Vogel <sv@exept.de>
parents:
89
diff
changeset
|
228 |
^ _theReceiver ? self |
18 | 229 |
! ! |
230 |
||
231 |
!JavaScriptEnvironment methodsFor:'builtin functions'! |
|
17 | 232 |
|
233 |
alert:msg |
|
446 | 234 |
self warn:('JavaScript alert:\\' withCRs , msg) |
17 | 235 |
|
446 | 236 |
"Created: / 16-05-1998 / 23:47:12 / cg" |
237 |
"Modified: / 19-05-2010 / 13:59:00 / cg" |
|
25 | 238 |
! |
239 |
||
240 |
confirm:msg |
|
241 |
^ Dialog confirm:('JavaScript confirmation:\\' , msg) withCRs |
|
242 |
||
243 |
"Created: / 17.5.1998 / 23:39:59 / cg" |
|
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
244 |
! |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
245 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
246 |
js_alert:msg |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
247 |
Dialog warn:('JavaScript alert:\\' , msg) withCRs |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
248 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
249 |
"Created: / 16.5.1998 / 23:47:12 / cg" |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
250 |
"Modified: / 17.5.1998 / 23:40:10 / cg" |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
251 |
! |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
252 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
253 |
js_confirm:msg |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
254 |
^ Dialog confirm:('JavaScript confirmation:\\' , msg) withCRs |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
255 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
256 |
"Created: / 17.5.1998 / 23:39:59 / cg" |
194 | 257 |
! |
258 |
||
259 |
print:msg |
|
293 | 260 |
(_outStream ? Transcript) show:msg |
194 | 261 |
! |
262 |
||
263 |
println:msg |
|
293 | 264 |
(_outStream ? Transcript) showCR:msg |
18 | 265 |
! ! |
266 |
||
267 |
!JavaScriptEnvironment methodsFor:'error handling'! |
|
268 |
||
269 |
doesNotUnderstand:aMessage |
|
270 |
|f| |
|
271 |
||
30 | 272 |
_functions notNil ifTrue:[ |
521
2479b00a29eb
comment/format in: #doesNotUnderstand:
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
273 |
f := _functions at:aMessage selector ifAbsent:nil. |
2479b00a29eb
comment/format in: #doesNotUnderstand:
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
274 |
f notNil ifTrue:[ |
2479b00a29eb
comment/format in: #doesNotUnderstand:
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
275 |
"/ ^ f. |
2479b00a29eb
comment/format in: #doesNotUnderstand:
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
276 |
^ f valueWithReceiver:self arguments:(aMessage arguments) |
2479b00a29eb
comment/format in: #doesNotUnderstand:
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
277 |
] |
18 | 278 |
]. |
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
279 |
_fallBackReceiver notNil ifTrue:[ |
521
2479b00a29eb
comment/format in: #doesNotUnderstand:
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
280 |
^ aMessage sendTo:_fallBackReceiver |
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
281 |
]. |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
282 |
|
18 | 283 |
^ super doesNotUnderstand:aMessage |
284 |
||
521
2479b00a29eb
comment/format in: #doesNotUnderstand:
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
285 |
"Created: / 17-05-1998 / 00:48:43 / cg" |
2479b00a29eb
comment/format in: #doesNotUnderstand:
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
286 |
"Modified: / 06-12-2011 / 01:48:59 / cg" |
23 | 287 |
! ! |
288 |
||
289 |
!JavaScriptEnvironment methodsFor:'expression evaluation'! |
|
290 |
||
291 |
_evaluateAction:aString with:aComponentName |
|
292 |
"invoked when some HTML-element (such as a button) with an ONCLICK |
|
293 |
action is pressed. This is supposed to parse the passed string as |
|
294 |
an expression in my language (i.e. javaScript) and invoke that |
|
295 |
function." |
|
296 |
||
297 |
ErrorSignal handle:[:ex | |
|
187 | 298 |
Transcript showCR:('error in script: ' , ex description). |
80 | 299 |
"/ self warn:'error in script: ' , ex description |
187 | 300 |
ex reject. |
23 | 301 |
] do:[ |
187 | 302 |
"/ |
303 |
"/ here, we parse the string and evaluate it as an expression. |
|
304 |
"/ |
|
305 |
||
306 |
JavaScriptParser evaluate:aString receiver:self in:self. |
|
23 | 307 |
]. |
308 |
||
309 |
"Modified: / 17.5.1998 / 21:24:35 / cg" |
|
200 | 310 |
! |
311 |
||
201 | 312 |
_readEvalFrom:inputStream to:outputStream errorTo:errorStream |
200 | 313 |
self _readEvalFrom:inputStream to:outputStream errorTo:errorStream print:false. |
314 |
||
201 | 315 |
"Created: / 13-07-2006 / 12:25:29 / cg" |
200 | 316 |
! |
317 |
||
318 |
_readEvalFrom:inputStream to:outputStream errorTo:errorStream print:doPrint |
|
319 |
[true] whileTrue:[ |
|
320 |
ErrorSignal handle:[:ex | |
|
321 |
errorStream showCR:('error in script: ' , ex description). |
|
322 |
"/ self warn:'error in script: ' , ex description |
|
323 |
ex reject. |
|
324 |
] do:[ |
|
325 |
|line result| |
|
326 |
||
327 |
"/ |
|
328 |
"/ here, we parse the string and evaluate it as an expression. |
|
329 |
"/ |
|
330 |
outputStream nextPutAll:'js>'. |
|
204 | 331 |
inputStream atEnd ifTrue:[^ self]. |
332 |
||
333 |
result := JavaScriptParser evaluate:inputStream receiver:self in:self. |
|
334 |
"/ line := inputStream nextLine. |
|
335 |
"/ result := JavaScriptParser evaluate:line receiver:self in:self. |
|
200 | 336 |
doPrint ifTrue:[ |
337 |
outputStream nextPutAll:result printString; cr. |
|
338 |
] |
|
339 |
]. |
|
340 |
] |
|
341 |
||
342 |
"Created: / 13-07-2006 / 12:22:47 / cg" |
|
343 |
! |
|
344 |
||
345 |
_readEvalPrintFrom:inputStream to:outputStream errorTo:errorStream |
|
346 |
self _readEvalFrom:inputStream to:outputStream errorTo:errorStream print:true. |
|
347 |
||
348 |
"Modified: / 13-07-2006 / 12:23:09 / cg" |
|
357 | 349 |
! |
350 |
||
351 |
exitWith:val |
|
352 |
^ val |
|
18 | 353 |
! ! |
354 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
355 |
!JavaScriptEnvironment methodsFor:'html-browser interaction'! |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
356 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
357 |
_start |
70 | 358 |
|f| |
359 |
||
360 |
"/ cannot do: |
|
361 |
"/ self perform:#js_start ifNotUnderstood:[]. |
|
362 |
"/ because the ifNotUnderstood-part does not handle delegated notUnderstood |
|
363 |
||
364 |
_functions notNil ifTrue:[ |
|
187 | 365 |
f := _functions at:#js_start ifAbsent:nil. |
366 |
f notNil ifTrue:[ |
|
367 |
f valueWithReceiver:self arguments:#() |
|
368 |
] |
|
70 | 369 |
]. |
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
370 |
! |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
371 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
372 |
_stop |
70 | 373 |
|f| |
374 |
||
375 |
"/ cannot do: |
|
376 |
"/ self perform:#js_stop ifNotUnderstood:[]. |
|
377 |
"/ because the ifNotUnderstood-part does not handle delegated notUnderstood |
|
378 |
||
379 |
_functions notNil ifTrue:[ |
|
187 | 380 |
f := _functions at:#js_stop ifAbsent:nil. |
381 |
f notNil ifTrue:[ |
|
382 |
f valueWithReceiver:self arguments:#() |
|
383 |
] |
|
70 | 384 |
]. |
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
385 |
! ! |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
386 |
|
38 | 387 |
!JavaScriptEnvironment methodsFor:'queries'! |
388 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
389 |
_isFunctionEnvironment |
38 | 390 |
^ false |
291 | 391 |
! |
392 |
||
393 |
isInnerJavaScriptBlock |
|
394 |
^ false |
|
38 | 395 |
! ! |
396 |
||
18 | 397 |
!JavaScriptEnvironment methodsFor:'setup'! |
398 |
||
399 |
_setupForWindow:aWindow |
|
30 | 400 |
|painter window history |
18 | 401 |
document formElements realForms formNames appletElements appletViews appletNames index| |
402 |
||
403 |
painter := aWindow painter. |
|
70 | 404 |
"/ painter notNil ifTrue:[ |
405 |
"/ formElements := painter forms. |
|
406 |
"/ index := 1. |
|
187 | 407 |
"/ formNames := |
70 | 408 |
"/ formElements |
187 | 409 |
"/ collect:[:aFormElement | |
70 | 410 |
"/ |nm| |
411 |
"/ |
|
412 |
"/ nm := aFormElement nameString. |
|
413 |
"/ nm isNil ifTrue:[ |
|
414 |
"/ nm := 'form' , index printString |
|
415 |
"/ ]. |
|
416 |
"/ index := index + 1. |
|
417 |
"/ nm |
|
418 |
"/ ]. |
|
187 | 419 |
"/ realForms := |
420 |
"/ formElements |
|
70 | 421 |
"/ collect:[:aFormElement | |
422 |
"/ |widgets widgetNames widgetViews| |
|
423 |
"/ |
|
424 |
"/ widgets := aFormElement widgets select:[:wE | wE nameString notNil]. |
|
425 |
"/ widgetNames := widgets collect:[:aWidgetElement | |nm| |
|
426 |
"/ nm := aWidgetElement nameString. |
|
427 |
"/ nm |
|
187 | 428 |
"/ ]. |
70 | 429 |
"/ widgetViews := widgets collect:[:aWidgetElement | aWidgetElement view]. |
430 |
"/ Structure newWith:widgetNames values:widgetViews. |
|
431 |
"/ ]. |
|
18 | 432 |
|
70 | 433 |
"/ appletElements := aWindow painter applets. |
434 |
"/ index := 1. |
|
187 | 435 |
"/ appletNames := |
70 | 436 |
"/ appletElements |
437 |
"/ collect:[:anAppletElement | |nm| |
|
438 |
"/ |
|
439 |
"/ nm := anAppletElement nameString. |
|
440 |
"/ nm isNil ifTrue:[ |
|
441 |
"/ nm := 'form' , index printString |
|
442 |
"/ ]. |
|
443 |
"/ index := index + 1. |
|
444 |
"/ nm |
|
445 |
"/ ]. |
|
446 |
"/ appletViews := appletElements collect:[:anAppletElement | anAppletElement view]. |
|
447 |
"/ ]. |
|
18 | 448 |
|
70 | 449 |
document := DocumentObject new. |
450 |
document forms:(FormsObject new window:aWindow). |
|
451 |
document applets:(AppletsObject new window:aWindow). |
|
18 | 452 |
|
70 | 453 |
"/ formNames notNil ifTrue:[ |
454 |
"/ formNames := formNames , (formNames collect:[:nm | 'js_' , nm]). |
|
455 |
"/ realForms := realForms , realForms. |
|
456 |
"/ document forms:(Structure newWith:formNames values:realForms). |
|
457 |
"/ ]. |
|
458 |
"/ appletNames notNil ifTrue:[ |
|
459 |
"/ appletNames := appletNames , (appletNames collect:[:nm | 'js_' , nm]). |
|
460 |
"/ appletViews := appletViews , appletViews. |
|
461 |
"/ document applets:(Structure newWith:appletNames values:appletViews). |
|
462 |
"/ ]. |
|
18 | 463 |
|
62 | 464 |
window := WindowObject new. |
18 | 465 |
window location:(aWindow currentURL). |
466 |
window document:document. |
|
467 |
window view:aWindow. |
|
468 |
||
30 | 469 |
history := HistoryObject new. |
470 |
history window:window. |
|
471 |
history historyItems:(aWindow history). |
|
472 |
"/ window history:(aWindow history). |
|
473 |
window history:history. |
|
474 |
||
399 | 475 |
self _defineVariable:#window value:((JavaScriptVariable name:#window) value:window). |
18 | 476 |
|
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
477 |
_fallBackReceiver := window. |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
478 |
|
18 | 479 |
"Created: / 21.9.1996 / 12:44:55 / cg" |
23 | 480 |
"Modified: / 17.5.1998 / 21:35:19 / cg" |
17 | 481 |
! ! |
482 |
||
70 | 483 |
!JavaScriptEnvironment::AppletObject methodsFor:'accessing'! |
484 |
||
187 | 485 |
window:windowArg element:elementArg view:viewArg |
70 | 486 |
"set instance variables (automatically generated)" |
487 |
||
488 |
window := windowArg. |
|
489 |
element := elementArg. |
|
490 |
view := viewArg. |
|
491 |
! ! |
|
492 |
||
493 |
!JavaScriptEnvironment::AppletsObject methodsFor:'accessing'! |
|
494 |
||
495 |
js_at:idx |
|
496 |
^ self appletNamed:(idx + 1) |
|
497 |
! |
|
498 |
||
499 |
window:something |
|
500 |
window := something. |
|
501 |
! ! |
|
502 |
||
503 |
!JavaScriptEnvironment::AppletsObject methodsFor:'cought accessors'! |
|
504 |
||
505 |
appletNamed:anAppletNameOrIndex |
|
506 |
|appletElements index el| |
|
507 |
||
508 |
appletElements := window applets. |
|
509 |
||
510 |
anAppletNameOrIndex isNumber ifTrue:[ |
|
187 | 511 |
index := anAppletNameOrIndex. |
70 | 512 |
] ifFalse:[ |
187 | 513 |
index := appletElements findFirst:[:el | el nameString = anAppletNameOrIndex]. |
514 |
index == 0 ifTrue:[ |
|
515 |
Transcript show:'no applet named: '; showCR:anAppletNameOrIndex. |
|
516 |
self halt. |
|
517 |
^ nil |
|
518 |
]. |
|
70 | 519 |
]. |
520 |
el := appletElements at:index ifAbsent:nil. |
|
521 |
el isNil ifTrue:[ |
|
187 | 522 |
Transcript showCR:'bad applet index'. |
523 |
self halt. |
|
524 |
^ nil |
|
70 | 525 |
]. |
526 |
||
527 |
^ JavaScriptEnvironment::AppletObject new |
|
187 | 528 |
window:window |
529 |
element:el |
|
530 |
widget:(el view) |
|
70 | 531 |
! |
532 |
||
533 |
doesNotUnderstand:aMessage |
|
534 |
|sel nm applet| |
|
535 |
||
536 |
sel := aMessage selector. |
|
537 |
(sel startsWith:'js_') ifTrue:[ |
|
187 | 538 |
"/ JS-access |
539 |
nm := sel copyFrom:4. |
|
70 | 540 |
] ifFalse:[ |
187 | 541 |
"/ ST-access |
542 |
nm := sel |
|
70 | 543 |
]. |
544 |
(applet := self appletNamed:nm) notNil ifTrue:[ |
|
187 | 545 |
^ applet |
70 | 546 |
]. |
547 |
^ super doesNotUnderstand:aMessage |
|
548 |
! ! |
|
549 |
||
38 | 550 |
!JavaScriptEnvironment::Array methodsFor:'accessing'! |
551 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
552 |
js_at:index |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
553 |
"JS uses 0-based indexing" |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
554 |
|
38 | 555 |
^ super at:index+1 |
556 |
||
557 |
"Created: / 7.11.1998 / 12:17:34 / cg" |
|
558 |
! |
|
559 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
560 |
js_at:index put:something |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
561 |
"JS uses 0-based indexing" |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
562 |
|
38 | 563 |
^ super at:index+1 put:something |
564 |
||
565 |
"Created: / 7.11.1998 / 12:17:47 / cg" |
|
566 |
! ! |
|
567 |
||
568 |
!JavaScriptEnvironment::Date methodsFor:'accessing'! |
|
569 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
570 |
js_getDate |
490 | 571 |
"get the day of month" |
572 |
||
38 | 573 |
^ self day |
574 |
||
575 |
"Modified: / 16.5.1998 / 20:32:25 / cg" |
|
576 |
"Created: / 16.5.1998 / 20:39:47 / cg" |
|
577 |
! |
|
578 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
579 |
js_getDay |
490 | 580 |
"get the day of week" |
581 |
||
38 | 582 |
^ self dayInWeek |
583 |
||
584 |
"Modified: / 16.5.1998 / 20:32:25 / cg" |
|
585 |
! |
|
586 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
587 |
js_getHours |
38 | 588 |
^ self hours |
589 |
||
590 |
"Created: / 16.5.1998 / 20:32:40 / cg" |
|
591 |
! |
|
592 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
593 |
js_getMinutes |
38 | 594 |
^ self minutes |
595 |
||
596 |
"Created: / 16.5.1998 / 20:32:57 / cg" |
|
597 |
! |
|
598 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
599 |
js_getMonth |
38 | 600 |
^ self month |
601 |
||
602 |
"Created: / 16.5.1998 / 20:31:57 / cg" |
|
603 |
! |
|
604 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
605 |
js_getSeconds |
38 | 606 |
^ self seconds |
607 |
||
608 |
"Created: / 16.5.1998 / 20:33:08 / cg" |
|
609 |
! |
|
610 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
611 |
js_getTime |
89 | 612 |
^ (Timestamp day:1 month:1 year:1970 hour:0 minutes:0 seconds:0) millisecondDeltaFrom:self |
38 | 613 |
|
614 |
"Created: / 16.5.1998 / 20:32:57 / cg" |
|
615 |
"Modified: / 16.5.1998 / 20:35:36 / cg" |
|
616 |
! |
|
617 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
618 |
js_getTimezoneOffset |
38 | 619 |
^ self utcOffset |
620 |
||
621 |
"Modified: / 16.5.1998 / 20:42:05 / cg" |
|
622 |
! |
|
623 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
624 |
js_getYear |
38 | 625 |
^ self year |
626 |
||
627 |
"Created: / 16.5.1998 / 20:31:32 / cg" |
|
628 |
! |
|
629 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
630 |
js_setDay:newDay |
490 | 631 |
|timeInfo| |
632 |
||
633 |
timeInfo := self timeInfo. |
|
634 |
self |
|
635 |
year:timeInfo year month:timeInfo month day:newDay |
|
636 |
hour:timeInfo hours minute:timeInfo minutes second:timeInfo seconds |
|
637 |
millisecond:timeInfo milliseconds |
|
638 |
||
639 |
" |
|
640 |
self now js_setDay:1 |
|
641 |
" |
|
38 | 642 |
|
643 |
"Modified: / 16.5.1998 / 20:39:24 / cg" |
|
644 |
! |
|
645 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
646 |
js_setHour:newHour |
490 | 647 |
|timeInfo| |
648 |
||
649 |
timeInfo := self timeInfo. |
|
650 |
self |
|
651 |
year:timeInfo year month:timeInfo month day:timeInfo day |
|
652 |
hour:newHour minute:timeInfo minutes second:timeInfo seconds |
|
653 |
millisecond:timeInfo milliseconds |
|
654 |
||
655 |
" |
|
656 |
self now js_setHour:0 |
|
657 |
" |
|
38 | 658 |
|
659 |
"Modified: / 16.5.1998 / 20:39:24 / cg" |
|
660 |
"Created: / 16.5.1998 / 20:40:11 / cg" |
|
661 |
! |
|
662 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
663 |
js_setMinutes:newMin |
490 | 664 |
|timeInfo| |
665 |
||
666 |
timeInfo := self timeInfo. |
|
667 |
self |
|
668 |
year:timeInfo year month:timeInfo month day:timeInfo day |
|
669 |
hour:timeInfo hours minute:newMin second:timeInfo seconds |
|
670 |
millisecond:timeInfo milliseconds |
|
671 |
||
672 |
" |
|
673 |
self now js_setMinutes:0 |
|
674 |
" |
|
38 | 675 |
|
676 |
"Modified: / 16.5.1998 / 20:39:24 / cg" |
|
677 |
"Created: / 16.5.1998 / 20:40:33 / cg" |
|
678 |
! |
|
679 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
680 |
js_setMonth:newMonth |
490 | 681 |
|timeInfo| |
682 |
||
683 |
timeInfo := self timeInfo. |
|
684 |
self |
|
685 |
year:timeInfo year month:newMonth day:timeInfo day |
|
686 |
hour:timeInfo hours minute:timeInfo minutes second:timeInfo seconds |
|
687 |
millisecond:timeInfo milliseconds |
|
688 |
||
689 |
" |
|
690 |
self now js_setMonth:7 |
|
691 |
" |
|
38 | 692 |
|
693 |
"Modified: / 16.5.1998 / 20:32:25 / cg" |
|
694 |
"Created: / 16.5.1998 / 20:39:04 / cg" |
|
695 |
! |
|
696 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
697 |
js_setSeconds:newSecs |
490 | 698 |
|timeInfo| |
699 |
||
700 |
timeInfo := self timeInfo. |
|
701 |
self |
|
702 |
year:timeInfo year month:timeInfo month day:timeInfo day |
|
703 |
hour:timeInfo hours minute:timeInfo minutes second:newSecs |
|
704 |
millisecond:timeInfo milliseconds |
|
705 |
||
706 |
" |
|
707 |
self now js_setSeconds:0 |
|
708 |
" |
|
38 | 709 |
|
710 |
"Modified: / 16.5.1998 / 20:39:24 / cg" |
|
711 |
"Created: / 16.5.1998 / 20:40:55 / cg" |
|
712 |
! |
|
713 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
714 |
js_setYear:newYear |
490 | 715 |
|timeInfo| |
716 |
||
717 |
timeInfo := self timeInfo. |
|
718 |
self |
|
719 |
year:newYear month:timeInfo month day:timeInfo day |
|
720 |
hour:timeInfo hours minute:timeInfo minutes second:timeInfo seconds |
|
721 |
millisecond:timeInfo milliseconds |
|
722 |
||
723 |
" |
|
724 |
self now js_setYear:2000 |
|
725 |
" |
|
38 | 726 |
|
727 |
"Modified: / 16.5.1998 / 20:38:39 / cg" |
|
728 |
! ! |
|
729 |
||
70 | 730 |
!JavaScriptEnvironment::DocumentObject methodsFor:'accessing'! |
731 |
||
732 |
anchors |
|
733 |
^ anchors |
|
734 |
! |
|
735 |
||
736 |
anchors:something |
|
737 |
anchors := something. |
|
738 |
! |
|
739 |
||
740 |
applets |
|
741 |
^ applets |
|
742 |
! |
|
743 |
||
744 |
applets:something |
|
745 |
applets := something. |
|
746 |
! |
|
747 |
||
748 |
forms |
|
749 |
^ forms |
|
750 |
! |
|
751 |
||
752 |
forms:something |
|
753 |
forms := something. |
|
754 |
! |
|
755 |
||
756 |
images |
|
757 |
^ images |
|
758 |
! |
|
759 |
||
760 |
images:something |
|
761 |
images := something. |
|
762 |
! |
|
763 |
||
764 |
js_anchors |
|
765 |
^ anchors |
|
766 |
! |
|
767 |
||
768 |
js_applets |
|
769 |
^ applets |
|
770 |
! |
|
771 |
||
772 |
js_forms |
|
773 |
^ forms |
|
774 |
! |
|
775 |
||
776 |
js_images |
|
777 |
^ images |
|
778 |
! |
|
779 |
||
780 |
js_links |
|
781 |
^ links |
|
782 |
! |
|
783 |
||
784 |
links |
|
785 |
^ links |
|
786 |
! |
|
787 |
||
788 |
links:something |
|
789 |
links := something. |
|
790 |
! ! |
|
791 |
||
792 |
!JavaScriptEnvironment::FormFieldObject methodsFor:'accessing'! |
|
793 |
||
794 |
js_value |
|
795 |
"my fields value" |
|
796 |
||
797 |
^ widget model value |
|
798 |
! |
|
799 |
||
800 |
js_value:newValue |
|
801 |
"change my fields value" |
|
802 |
||
803 |
^ widget model value:newValue |
|
804 |
! |
|
805 |
||
806 |
value |
|
807 |
self halt. |
|
808 |
! |
|
809 |
||
810 |
value:newValue |
|
811 |
self halt. |
|
812 |
! |
|
813 |
||
187 | 814 |
window:windowArg element:elementArg widget:widgetArg |
70 | 815 |
"set instance variables (automatically generated)" |
816 |
||
817 |
window := windowArg. |
|
818 |
element := elementArg. |
|
819 |
widget := widgetArg. |
|
820 |
! ! |
|
821 |
||
822 |
!JavaScriptEnvironment::FormObject methodsFor:'accessing'! |
|
823 |
||
187 | 824 |
window:windowArg element:elementArg |
70 | 825 |
"set instance variables (automatically generated)" |
826 |
||
827 |
window := windowArg. |
|
828 |
element := elementArg. |
|
829 |
! ! |
|
830 |
||
831 |
!JavaScriptEnvironment::FormObject methodsFor:'cought accessors'! |
|
832 |
||
833 |
doesNotUnderstand:aMessage |
|
834 |
|sel nm form| |
|
835 |
||
836 |
sel := aMessage selector. |
|
837 |
(sel startsWith:'js_') ifTrue:[ |
|
187 | 838 |
"/ JS-access |
839 |
nm := sel copyFrom:4. |
|
70 | 840 |
] ifFalse:[ |
187 | 841 |
"/ ST-access |
842 |
nm := sel |
|
70 | 843 |
]. |
844 |
(form := self fieldNamed:nm) notNil ifTrue:[ |
|
187 | 845 |
^ form |
70 | 846 |
]. |
847 |
||
848 |
^ super doesNotUnderstand:aMessage |
|
849 |
! |
|
850 |
||
851 |
fieldNamed:aFieldNameOrIndex |
|
852 |
|fieldElements index el| |
|
853 |
||
854 |
fieldElements := element widgets. |
|
855 |
fieldElements isNil ifTrue:[^ nil]. |
|
856 |
||
857 |
aFieldNameOrIndex isNumber ifTrue:[ |
|
187 | 858 |
index := aFieldNameOrIndex. |
70 | 859 |
] ifFalse:[ |
187 | 860 |
index := fieldElements findFirst:[:el | el nameString = aFieldNameOrIndex]. |
861 |
index == 0 ifTrue:[ |
|
862 |
Transcript show:'no field named: '; showCR:aFieldNameOrIndex. |
|
863 |
self halt. |
|
864 |
^ nil |
|
865 |
]. |
|
70 | 866 |
]. |
867 |
||
868 |
el := fieldElements at:index ifAbsent:nil. |
|
869 |
el isNil ifTrue:[ |
|
187 | 870 |
Transcript showCR:'bad field index'. |
871 |
self halt. |
|
872 |
^ nil |
|
70 | 873 |
]. |
874 |
||
875 |
^ JavaScriptEnvironment::FormFieldObject new |
|
187 | 876 |
window:window |
877 |
element:el |
|
878 |
widget:(el view) |
|
70 | 879 |
! ! |
880 |
||
881 |
!JavaScriptEnvironment::FormsObject methodsFor:'accessing'! |
|
882 |
||
883 |
js_at:idx |
|
884 |
^ self formNamed:(idx + 1) |
|
885 |
! |
|
886 |
||
887 |
window:something |
|
888 |
window := something. |
|
889 |
! ! |
|
890 |
||
891 |
!JavaScriptEnvironment::FormsObject methodsFor:'cought accessors'! |
|
892 |
||
893 |
doesNotUnderstand:aMessage |
|
894 |
|sel nm form| |
|
895 |
||
896 |
sel := aMessage selector. |
|
897 |
(sel startsWith:'js_') ifTrue:[ |
|
187 | 898 |
"/ JS-access |
899 |
nm := sel copyFrom:4. |
|
70 | 900 |
] ifFalse:[ |
187 | 901 |
"/ ST-access |
902 |
nm := sel |
|
70 | 903 |
]. |
904 |
(form := self formNamed:nm) notNil ifTrue:[ |
|
187 | 905 |
^ form |
70 | 906 |
]. |
907 |
||
908 |
^ super doesNotUnderstand:aMessage |
|
909 |
! |
|
910 |
||
911 |
formNamed:aFormNameOrIndex |
|
912 |
|formElements index el| |
|
913 |
||
914 |
formElements := window forms. |
|
915 |
formElements isNil ifTrue:[^ nil]. |
|
916 |
||
917 |
aFormNameOrIndex isNumber ifTrue:[ |
|
187 | 918 |
index := aFormNameOrIndex. |
70 | 919 |
] ifFalse:[ |
187 | 920 |
index := formElements findFirst:[:el | el nameString = aFormNameOrIndex]. |
921 |
index == 0 ifTrue:[ |
|
922 |
Transcript show:'no form named: '; showCR:aFormNameOrIndex. |
|
923 |
self halt. |
|
924 |
^ nil |
|
925 |
]. |
|
70 | 926 |
]. |
927 |
el := formElements at:index ifAbsent:nil. |
|
928 |
el isNil ifTrue:[ |
|
187 | 929 |
Transcript showCR:'bad form index'. |
930 |
self halt. |
|
931 |
^ nil |
|
70 | 932 |
]. |
933 |
||
934 |
^ JavaScriptEnvironment::FormObject new |
|
187 | 935 |
window:window |
936 |
element:el |
|
70 | 937 |
! ! |
938 |
||
43 | 939 |
!JavaScriptEnvironment::HistoryObject methodsFor:'accessing'! |
940 |
||
941 |
historyItems |
|
942 |
"return the value of the instance variable 'historyItems' (automatically generated)" |
|
943 |
||
944 |
^ historyItems |
|
945 |
! |
|
946 |
||
947 |
historyItems:something |
|
948 |
"set the value of the instance variable 'historyItems' (automatically generated)" |
|
949 |
||
950 |
historyItems := something. |
|
951 |
! |
|
952 |
||
953 |
window |
|
954 |
"return the value of the instance variable 'window' (automatically generated)" |
|
955 |
||
956 |
^ window |
|
957 |
! |
|
958 |
||
959 |
window:something |
|
960 |
"set the value of the instance variable 'window' (automatically generated)" |
|
961 |
||
962 |
window := something. |
|
963 |
! ! |
|
964 |
||
965 |
!JavaScriptEnvironment::HistoryObject methodsFor:'actions'! |
|
966 |
||
967 |
back |
|
968 |
window view menu_back |
|
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
969 |
! |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
970 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
971 |
js_back |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
972 |
window view menu_back |
43 | 973 |
! ! |
974 |
||
4 | 975 |
!JavaScriptEnvironment::Math class methodsFor:'constants'! |
976 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
977 |
js_E |
4 | 978 |
^ 2.7182818284590452354 |
979 |
||
980 |
"Modified: / 16.5.1998 / 17:05:49 / cg" |
|
981 |
! |
|
982 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
983 |
js_LN10 |
4 | 984 |
"lng e10" |
985 |
||
986 |
^ 2.30258509299404568402 |
|
987 |
||
988 |
"Created: / 16.5.1998 / 17:06:21 / cg" |
|
989 |
"Modified: / 16.5.1998 / 17:08:43 / cg" |
|
990 |
! |
|
991 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
992 |
js_LN2 |
4 | 993 |
"lng e2" |
994 |
||
995 |
^ 0.69314718055994530942 |
|
996 |
||
997 |
"Created: / 16.5.1998 / 17:06:02 / cg" |
|
998 |
"Modified: / 16.5.1998 / 17:08:46 / cg" |
|
999 |
! |
|
1000 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1001 |
js_LOG10E |
4 | 1002 |
"log e10" |
1003 |
||
1004 |
^ 0.43429448190325182765 |
|
1005 |
||
1006 |
"Created: / 16.5.1998 / 17:06:40 / cg" |
|
1007 |
"Modified: / 16.5.1998 / 17:08:26 / cg" |
|
1008 |
! |
|
1009 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1010 |
js_LOG2E |
4 | 1011 |
"log e2" |
1012 |
||
1013 |
^ 1.4426950408889634074 |
|
1014 |
||
1015 |
"Created: / 16.5.1998 / 17:06:33 / cg" |
|
1016 |
"Modified: / 16.5.1998 / 17:08:36 / cg" |
|
1017 |
! |
|
1018 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1019 |
js_PI |
4 | 1020 |
"pi" |
1021 |
||
1022 |
^ 3.14159265358979323846 |
|
1023 |
||
1024 |
"Created: / 16.5.1998 / 17:06:49 / cg" |
|
1025 |
"Modified: / 16.5.1998 / 17:08:55 / cg" |
|
1026 |
! |
|
1027 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1028 |
js_SQRT1_2 |
4 | 1029 |
"1/sqrt(2)" |
1030 |
||
1031 |
^ 0.70710678118654752440 |
|
1032 |
||
1033 |
"Modified: / 16.5.1998 / 17:07:55 / cg" |
|
1034 |
! |
|
1035 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1036 |
js_SQRT2 |
4 | 1037 |
"sqrt(2)" |
1038 |
||
1039 |
^ 1.41421356237309504880 |
|
1040 |
||
1041 |
"Created: / 16.5.1998 / 17:07:00 / cg" |
|
1042 |
"Modified: / 16.5.1998 / 17:09:07 / cg" |
|
1043 |
! ! |
|
1044 |
||
1045 |
!JavaScriptEnvironment::Math class methodsFor:'misc functions'! |
|
1046 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1047 |
js_abs:aFloat |
4 | 1048 |
^ aFloat abs |
1049 |
||
1050 |
"Created: / 16.5.1998 / 17:09:28 / cg" |
|
1051 |
! |
|
1052 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1053 |
js_exp:aFloat |
4 | 1054 |
^ aFloat exp |
1055 |
||
1056 |
"Created: / 16.5.1998 / 17:09:54 / cg" |
|
1057 |
! |
|
1058 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1059 |
js_round:aFloat |
17 | 1060 |
^ aFloat rounded |
1061 |
||
1062 |
"Created: / 16.5.1998 / 20:29:51 / cg" |
|
1063 |
! |
|
1064 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1065 |
js_sqrt:aFloat |
4 | 1066 |
^ aFloat sqrt |
1067 |
||
1068 |
"Created: / 16.5.1998 / 17:10:03 / cg" |
|
1069 |
! ! |
|
1070 |
||
1071 |
!JavaScriptEnvironment::Math class methodsFor:'trigonometric functions'! |
|
1072 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1073 |
js_acos:aFloat |
4 | 1074 |
^ aFloat arcCos |
1075 |
||
1076 |
"Created: / 16.5.1998 / 17:09:37 / cg" |
|
1077 |
! |
|
1078 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1079 |
js_asin:aFloat |
4 | 1080 |
^ aFloat arcSin |
1081 |
||
1082 |
"Created: / 16.5.1998 / 17:09:43 / cg" |
|
1083 |
! |
|
1084 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1085 |
js_atan:aFloat |
4 | 1086 |
^ aFloat arcTan |
1087 |
||
1088 |
"Created: / 16.5.1998 / 17:04:13 / cg" |
|
1089 |
! |
|
1090 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1091 |
js_cos:aFloat |
4 | 1092 |
^ aFloat cos |
1093 |
||
1094 |
"Created: / 16.5.1998 / 17:04:01 / cg" |
|
1095 |
! |
|
1096 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1097 |
js_sin:aFloat |
4 | 1098 |
^ aFloat sin |
1099 |
||
1100 |
"Created: / 16.5.1998 / 17:03:58 / cg" |
|
1101 |
! |
|
1102 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1103 |
js_tan:aFloat |
4 | 1104 |
^ aFloat tan |
1105 |
||
1106 |
"Created: / 16.5.1998 / 17:04:03 / cg" |
|
1107 |
! ! |
|
1108 |
||
43 | 1109 |
!JavaScriptEnvironment::String methodsFor:'accessing'! |
1110 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1111 |
js_at:index |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1112 |
"JS returns chars as strings and uses 0-based indexing" |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1113 |
|
43 | 1114 |
|newJS| |
1115 |
||
1116 |
newJS := self class basicNew:1. |
|
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1117 |
newJS at:1 put:(self at:index+1). |
187 | 1118 |
^ newJS |
43 | 1119 |
|
1120 |
"Created: / 16.5.1998 / 20:04:36 / cg" |
|
1121 |
"Modified: / 16.5.1998 / 20:26:45 / cg" |
|
1122 |
! |
|
1123 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1124 |
js_at:index put:aCharacterOrString |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1125 |
"JS returns chars as strings and uses 0-based indexing" |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1126 |
|
43 | 1127 |
aCharacterOrString isString ifTrue:[ |
187 | 1128 |
aCharacterOrString size == 1 ifTrue:[ |
1129 |
self at:index+1 put:(aCharacterOrString at:1). |
|
1130 |
^ aCharacterOrString |
|
1131 |
] |
|
43 | 1132 |
]. |
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1133 |
^ self at:index+1 put:aCharacterOrString |
43 | 1134 |
|
1135 |
"Created: / 16.5.1998 / 20:04:41 / cg" |
|
1136 |
"Modified: / 16.5.1998 / 20:26:56 / cg" |
|
1137 |
! |
|
1138 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1139 |
js_charAt:index |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1140 |
" JS returns chars as strings and uses 0-based indexing" |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1141 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1142 |
|newJS| |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1143 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1144 |
newJS := self class basicNew:1. |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1145 |
newJS at:1 put:(self at:index+1). |
187 | 1146 |
^ newJS |
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1147 |
! |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1148 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1149 |
js_substring:idx1 _:idx2 |
43 | 1150 |
^ self copyFrom:idx1+1 to:idx2+1 |
1151 |
||
1152 |
"Created: / 16.5.1998 / 20:27:59 / cg" |
|
1153 |
! ! |
|
1154 |
||
1155 |
!JavaScriptEnvironment::String methodsFor:'concatenation'! |
|
1156 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1157 |
js_plus: aString "/ thats #+ |
43 | 1158 |
^ self , aString printString |
1159 |
||
1160 |
"Created: / 16.5.1998 / 18:47:08 / cg" |
|
1161 |
"Modified: / 16.5.1998 / 19:01:42 / cg" |
|
1162 |
! ! |
|
1163 |
||
1164 |
!JavaScriptEnvironment::String methodsFor:'conversion'! |
|
1165 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1166 |
js_toLowerCase |
43 | 1167 |
^ self asLowercase |
1168 |
||
1169 |
"Created: / 16.5.1998 / 19:03:43 / cg" |
|
1170 |
! |
|
1171 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1172 |
js_toUpperCase |
43 | 1173 |
^ self asUppercase |
1174 |
||
1175 |
"Created: / 16.5.1998 / 19:03:20 / cg" |
|
1176 |
! ! |
|
1177 |
||
1178 |
!JavaScriptEnvironment::String methodsFor:'queries'! |
|
1179 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1180 |
js_length |
43 | 1181 |
^ self size |
1182 |
||
1183 |
"Created: / 16.5.1998 / 19:06:17 / cg" |
|
1184 |
! ! |
|
1185 |
||
1186 |
!JavaScriptEnvironment::String methodsFor:'searching'! |
|
1187 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1188 |
js_indexOf:searchString |
43 | 1189 |
^ (self indexOfSubCollection:searchString) - 1 "/ JS indexing is 0-based |
1190 |
||
1191 |
"Created: / 16.5.1998 / 19:04:13 / cg" |
|
1192 |
"Modified: / 16.5.1998 / 20:24:08 / cg" |
|
1193 |
! |
|
1194 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1195 |
js_indexOf:searchString _:startIndex |
43 | 1196 |
^ (self indexOfSubCollection:searchString startingAt:startIndex+1) - 1 "/ JS indexing is 0-based |
1197 |
||
1198 |
"Created: / 16.5.1998 / 19:04:22 / cg" |
|
1199 |
"Modified: / 16.5.1998 / 20:25:10 / cg" |
|
1200 |
! |
|
1201 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1202 |
js_lastIndexOf:searchString |
43 | 1203 |
^ (self lastIndexOfSubCollection:searchString) - 1 "/ JS indexing is 0-based |
1204 |
||
1205 |
"Modified: / 16.5.1998 / 19:20:19 / cg" |
|
1206 |
"Created: / 16.5.1998 / 20:23:38 / cg" |
|
1207 |
! |
|
1208 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1209 |
js_lastIndexOf:searchString _:startIndex |
43 | 1210 |
^ (self lastIndexOfSubCollection:searchString startingAt:startIndex+1) - 1 "/ JS indexing is 0-based |
1211 |
||
1212 |
"Created: / 16.5.1998 / 20:23:52 / cg" |
|
1213 |
"Modified: / 16.5.1998 / 20:25:16 / cg" |
|
1214 |
! ! |
|
1215 |
||
62 | 1216 |
!JavaScriptEnvironment::WindowObject methodsFor:'accessing'! |
1217 |
||
1218 |
document |
|
1219 |
"return the value of the instance variable 'document' (automatically generated)" |
|
1220 |
||
1221 |
^ document |
|
1222 |
! |
|
1223 |
||
1224 |
document:something |
|
1225 |
"set the value of the instance variable 'document' (automatically generated)" |
|
1226 |
||
1227 |
document := something. |
|
1228 |
! |
|
1229 |
||
1230 |
frames |
|
1231 |
"return the value of the instance variable 'frames' (automatically generated)" |
|
1232 |
||
1233 |
^ frames |
|
1234 |
! |
|
1235 |
||
1236 |
frames:something |
|
1237 |
"set the value of the instance variable 'frames' (automatically generated)" |
|
1238 |
||
1239 |
frames := something. |
|
1240 |
! |
|
1241 |
||
1242 |
history |
|
1243 |
"return the value of the instance variable 'history' (automatically generated)" |
|
1244 |
||
1245 |
^ history |
|
1246 |
! |
|
1247 |
||
1248 |
history:something |
|
1249 |
"set the value of the instance variable 'history' (automatically generated)" |
|
1250 |
||
1251 |
history := something. |
|
1252 |
! |
|
1253 |
||
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1254 |
js_document |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1255 |
"return the value of the instance variable 'document' (automatically generated)" |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1256 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1257 |
^ document |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1258 |
! |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1259 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1260 |
js_frames |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1261 |
"return the value of the instance variable 'frames' (automatically generated)" |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1262 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1263 |
^ frames |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1264 |
! |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1265 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1266 |
js_history |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1267 |
"return the value of the instance variable 'history' (automatically generated)" |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1268 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1269 |
^ history |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1270 |
! |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1271 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1272 |
js_location |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1273 |
"return the value of the instance variable 'location' (automatically generated)" |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1274 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1275 |
^ location |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1276 |
! |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1277 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1278 |
js_view |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1279 |
"return the value of the instance variable 'view' (automatically generated)" |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1280 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1281 |
^ view |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1282 |
! |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1283 |
|
62 | 1284 |
location |
1285 |
"return the value of the instance variable 'location' (automatically generated)" |
|
1286 |
||
1287 |
^ location |
|
1288 |
! |
|
1289 |
||
1290 |
location:something |
|
1291 |
"set the value of the instance variable 'location' (automatically generated)" |
|
1292 |
||
1293 |
location := something. |
|
1294 |
! |
|
1295 |
||
1296 |
view |
|
1297 |
"return the value of the instance variable 'view' (automatically generated)" |
|
1298 |
||
1299 |
^ view |
|
1300 |
! |
|
1301 |
||
1302 |
view:something |
|
1303 |
"set the value of the instance variable 'view' (automatically generated)" |
|
1304 |
||
1305 |
view := something. |
|
1306 |
! ! |
|
1307 |
||
1308 |
!JavaScriptEnvironment::WindowObject methodsFor:'information'! |
|
1309 |
||
1310 |
info:aMessage |
|
1311 |
view showInfo:aMessage |
|
67
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1312 |
! |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1313 |
|
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1314 |
js_info:aMessage |
058fd3dad518
js-plain vs. js-in-html handling
Claus Gittinger <cg@exept.de>
parents:
66
diff
changeset
|
1315 |
view showInfo:aMessage |
62 | 1316 |
! ! |
1317 |
||
4 | 1318 |
!JavaScriptEnvironment class methodsFor:'documentation'! |
1319 |
||
1320 |
version |
|
1321 |
^ '$Header$' |
|
399 | 1322 |
! |
1323 |
||
1324 |
version_CVS |
|
1325 |
^ '$Header$' |
|
4 | 1326 |
! ! |