resin 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +52 -0
- data/amber/css/amber.css +519 -0
- data/amber/css/documentation.css +84 -0
- data/amber/css/profstef.css +75 -0
- data/amber/css/style.css +313 -0
- data/amber/images/amber.png +0 -0
- data/amber/images/amber_small.png +0 -0
- data/amber/images/off.png +0 -0
- data/amber/images/offHover.png +0 -0
- data/amber/images/presentation.png +0 -0
- data/amber/images/profstef.png +0 -0
- data/amber/images/sprite.png +0 -0
- data/amber/images/tinylogo.png +0 -0
- data/amber/images/twitterwall.png +0 -0
- data/amber/js/Additional-Examples.deploy.js +15 -0
- data/amber/js/Additional-Examples.js +21 -0
- data/amber/js/Benchfib.deploy.js +132 -0
- data/amber/js/Benchfib.js +167 -0
- data/amber/js/Canvas.deploy.js +1304 -0
- data/amber/js/Canvas.js +1885 -0
- data/amber/js/Compiler.deploy.js +1871 -0
- data/amber/js/Compiler.js +2616 -0
- data/amber/js/Documentation.deploy.js +961 -0
- data/amber/js/Documentation.js +1376 -0
- data/amber/js/Examples.deploy.js +53 -0
- data/amber/js/Examples.js +73 -0
- data/amber/js/IDE.deploy.js +3468 -0
- data/amber/js/IDE.js +4883 -0
- data/amber/js/Kernel-Announcements.deploy.js +107 -0
- data/amber/js/Kernel-Announcements.js +152 -0
- data/amber/js/Kernel-Classes.deploy.js +675 -0
- data/amber/js/Kernel-Classes.js +956 -0
- data/amber/js/Kernel-Collections.deploy.js +3273 -0
- data/amber/js/Kernel-Collections.js +4644 -0
- data/amber/js/Kernel-Exceptions.deploy.js +244 -0
- data/amber/js/Kernel-Exceptions.js +349 -0
- data/amber/js/Kernel-Methods.deploy.js +510 -0
- data/amber/js/Kernel-Methods.js +739 -0
- data/amber/js/Kernel-Objects.deploy.js +2698 -0
- data/amber/js/Kernel-Objects.js +3858 -0
- data/amber/js/Kernel-Tests.deploy.js +1419 -0
- data/amber/js/Kernel-Tests.js +1929 -0
- data/amber/js/Kernel-Transcript.deploy.js +142 -0
- data/amber/js/Kernel-Transcript.js +202 -0
- data/amber/js/SUnit.deploy.js +351 -0
- data/amber/js/SUnit.js +501 -0
- data/amber/js/amber.js +250 -0
- data/amber/js/boot.js +587 -0
- data/amber/js/compat.js +22 -0
- data/amber/js/init.js +8 -0
- data/amber/js/lib/CodeMirror/LICENSE +19 -0
- data/amber/js/lib/CodeMirror/amber.css +21 -0
- data/amber/js/lib/CodeMirror/codemirror.css +67 -0
- data/amber/js/lib/CodeMirror/codemirror.js +2144 -0
- data/amber/js/lib/CodeMirror/smalltalk.js +134 -0
- data/amber/js/lib/jQuery/jquery-1.4.4.min.js +167 -0
- data/amber/js/lib/jQuery/jquery-1.6.4.min.js +4 -0
- data/amber/js/lib/jQuery/jquery-ui-1.8.16.custom.min.js +791 -0
- data/amber/js/lib/jQuery/jquery.textarea.js +267 -0
- data/amber/js/lib/peg-0.6.2.min.js +2 -0
- data/amber/js/lib/showdown.js +419 -0
- data/amber/js/parser.js +4005 -0
- data/amber/js/parser.pegjs +220 -0
- data/amber/st/Benchfib.st +124 -0
- data/amber/st/Canvas.st +556 -0
- data/amber/st/Compiler.st +1425 -0
- data/amber/st/Documentation.st +758 -0
- data/amber/st/Examples.st +38 -0
- data/amber/st/IDE.st +2336 -0
- data/amber/st/Kernel-Announcements.st +61 -0
- data/amber/st/Kernel-Classes.st +403 -0
- data/amber/st/Kernel-Collections.st +1673 -0
- data/amber/st/Kernel-Exceptions.st +124 -0
- data/amber/st/Kernel-Methods.st +287 -0
- data/amber/st/Kernel-Objects.st +1489 -0
- data/amber/st/Kernel-Tests.st +892 -0
- data/amber/st/Kernel-Transcript.st +70 -0
- data/amber/st/SUnit.st +172 -0
- data/bin/runresin +12 -0
- data/lib/resin.rb +0 -0
- data/lib/resin/app/app.rb +121 -0
- data/lib/resin/app/views/index.haml +10 -0
- metadata +216 -0
@@ -0,0 +1,220 @@
|
|
1
|
+
start = method
|
2
|
+
|
3
|
+
separator = [ \t\v\f\u00A0\uFEFF\n\r\u2028\u2029]+
|
4
|
+
comments = (["][^"]*["])+
|
5
|
+
ws = (separator / comments)*
|
6
|
+
identifier = first:[a-z] others:[a-zA-Z0-9]* {return first + others.join("")}
|
7
|
+
keyword = first:identifier last:[:] {return first + last}
|
8
|
+
className = first:[A-Z] others:[a-zA-Z0-9]* {return first + others.join("")}
|
9
|
+
string = ['] val:(("''" {return "'"} / [^'])*) ['] {
|
10
|
+
return smalltalk.ValueNode._new()
|
11
|
+
._value_(val.join("").replace(/\"/ig, '"'))
|
12
|
+
}
|
13
|
+
|
14
|
+
symbol = "#"val:[a-zA-Z0-9]* {
|
15
|
+
return smalltalk.ValueNode._new()
|
16
|
+
._value_('smalltalk.symbolFor(val.join("").replace(/\"/ig, '"')))
|
17
|
+
}
|
18
|
+
number = n:(float / integer) {
|
19
|
+
return smalltalk.ValueNode._new()
|
20
|
+
._value_(n)
|
21
|
+
}
|
22
|
+
float = neg:[-]?int:integer "." dec:integer {return parseFloat((neg+int+"."+dec), 10)}
|
23
|
+
integer = neg:[-]?digits:[0-9]+ {return (parseInt(neg+digits.join(""), 10))}
|
24
|
+
literalArray = "#(" ws lits:(lit:literal ws {return lit._value()})* ws ")" {
|
25
|
+
return smalltalk.ValueNode._new()
|
26
|
+
._value_(lits)
|
27
|
+
}
|
28
|
+
dynamicArray = "{" ws expressions:expressions? ws "}" {
|
29
|
+
return smalltalk.DynamicArrayNode._new()
|
30
|
+
._nodes_(expressions)
|
31
|
+
}
|
32
|
+
dynamicDictionary = "#{" ws expressions: expressions? ws "}" {
|
33
|
+
return smalltalk.DynamicDictionaryNode._new()
|
34
|
+
._nodes_(expressions)
|
35
|
+
}
|
36
|
+
pseudoVariable = val:(
|
37
|
+
'true' {return true}
|
38
|
+
/ 'false' {return false}
|
39
|
+
/ 'nil' {return nil}) {
|
40
|
+
return smalltalk.ValueNode._new()._value_(val)
|
41
|
+
}
|
42
|
+
literal = pseudoVariable / number / literalArray / dynamicDictionary / dynamicArray / string / symbol / block
|
43
|
+
|
44
|
+
|
45
|
+
variable = identifier:identifier {
|
46
|
+
return smalltalk.VariableNode._new()
|
47
|
+
._value_(identifier)
|
48
|
+
}
|
49
|
+
classReference = className:className {
|
50
|
+
return smalltalk.ClassReferenceNode._new()
|
51
|
+
._value_(className)
|
52
|
+
}
|
53
|
+
|
54
|
+
reference = variable / classReference
|
55
|
+
|
56
|
+
keywordPair = key:keyword ws arg:binarySend ws {return {key:key, arg: arg}}
|
57
|
+
|
58
|
+
binarySelector = bin:[\\+*/=><,@%~|&-]+ {return bin.join("").replace(/\\/g, '\\\\')}
|
59
|
+
unarySelector = identifier
|
60
|
+
|
61
|
+
keywordPattern = pairs:(ws key:keyword ws arg:identifier {return {key:key, arg: arg}})+ {
|
62
|
+
var keywords = [];
|
63
|
+
var params = [];
|
64
|
+
for(var i=0;i<pairs.length;i++){
|
65
|
+
keywords.push(pairs[i].key);
|
66
|
+
}
|
67
|
+
for(var i=0;i<pairs.length;i++){
|
68
|
+
params.push(pairs[i].arg);
|
69
|
+
}
|
70
|
+
return [keywords.join(""), params]
|
71
|
+
}
|
72
|
+
binaryPattern = ws selector:binarySelector ws arg:identifier {return [selector, [arg]]}
|
73
|
+
unaryPattern = ws selector:unarySelector {return [selector, []]}
|
74
|
+
|
75
|
+
expression = assignment / cascade / keywordSend / binarySend / jsStatement
|
76
|
+
|
77
|
+
expressionList = ws "." ws expression:expression {return expression}
|
78
|
+
expressions = first:expression others:expressionList* {
|
79
|
+
var result = [first];
|
80
|
+
for(var i=0;i<others.length;i++) {
|
81
|
+
result.push(others[i]);
|
82
|
+
}
|
83
|
+
return result;
|
84
|
+
}
|
85
|
+
|
86
|
+
assignment = variable:variable ws ':=' ws expression:expression {
|
87
|
+
return smalltalk.AssignmentNode._new()
|
88
|
+
._left_(variable)
|
89
|
+
._right_(expression)
|
90
|
+
}
|
91
|
+
|
92
|
+
ret = '^' ws expression:expression ws '.'? {
|
93
|
+
return smalltalk.ReturnNode._new()
|
94
|
+
._nodes_([expression])
|
95
|
+
}
|
96
|
+
|
97
|
+
temps = "|" vars:(ws variable:identifier ws {return variable})* "|" {return vars}
|
98
|
+
|
99
|
+
blockParamList = params:((ws ":" ws param:identifier {return param})+) ws "|" {return params}
|
100
|
+
|
101
|
+
subexpression = '(' ws expression:expression ws ')' {return expression}
|
102
|
+
|
103
|
+
statements = ret:ret [.]* {return [ret]}
|
104
|
+
/ exps:expressions ws [.]+ ws ret:ret [.]* {
|
105
|
+
var expressions = exps;
|
106
|
+
expressions.push(ret);
|
107
|
+
return expressions
|
108
|
+
}
|
109
|
+
/ expressions:expressions? [.]* {
|
110
|
+
return expressions || []
|
111
|
+
}
|
112
|
+
|
113
|
+
sequence = temps:temps? ws statements:statements? ws {
|
114
|
+
return smalltalk.SequenceNode._new()
|
115
|
+
._temps_(temps || [])
|
116
|
+
._nodes_(statements || [])
|
117
|
+
}
|
118
|
+
|
119
|
+
block = '[' ws params:blockParamList? ws sequence:sequence? ws ']' {
|
120
|
+
return smalltalk.BlockNode._new()
|
121
|
+
._parameters_(params || [])
|
122
|
+
._nodes_([sequence._asBlockSequenceNode()])
|
123
|
+
}
|
124
|
+
|
125
|
+
operand = literal / reference / subexpression
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
unaryMessage = ws selector:unarySelector ![:] {
|
130
|
+
return smalltalk.SendNode._new()
|
131
|
+
._selector_(selector)
|
132
|
+
}
|
133
|
+
|
134
|
+
unaryTail = message:unaryMessage ws tail:unaryTail? ws {
|
135
|
+
if(tail) {
|
136
|
+
return tail._valueForReceiver_(message);
|
137
|
+
}
|
138
|
+
else {
|
139
|
+
return message;
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
unarySend = receiver:operand ws tail:unaryTail? {
|
144
|
+
if(tail) {
|
145
|
+
return tail._valueForReceiver_(receiver);
|
146
|
+
}
|
147
|
+
else {
|
148
|
+
return receiver;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
binaryMessage = ws selector:binarySelector ws arg:(unarySend / operand) {
|
153
|
+
return smalltalk.SendNode._new()
|
154
|
+
._selector_(selector)
|
155
|
+
._arguments_([arg])
|
156
|
+
}
|
157
|
+
|
158
|
+
binaryTail = message:binaryMessage tail:binaryTail? {
|
159
|
+
if(tail) {
|
160
|
+
return tail._valueForReceiver_(message);
|
161
|
+
}
|
162
|
+
else {
|
163
|
+
return message;
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
binarySend = receiver:unarySend tail:binaryTail? {
|
168
|
+
if(tail) {
|
169
|
+
return tail._valueForReceiver_(receiver);
|
170
|
+
}
|
171
|
+
else {
|
172
|
+
return receiver;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
|
177
|
+
keywordMessage = ws pairs:(pair:keywordPair ws {return pair})+ {
|
178
|
+
var selector = [];
|
179
|
+
var args = [];
|
180
|
+
for(var i=0;i<pairs.length;i++) {
|
181
|
+
selector.push(pairs[i].key);
|
182
|
+
args.push(pairs[i].arg);
|
183
|
+
}
|
184
|
+
return smalltalk.SendNode._new()
|
185
|
+
._selector_(selector.join(""))
|
186
|
+
._arguments_(args)
|
187
|
+
}
|
188
|
+
|
189
|
+
keywordSend = receiver:binarySend tail:keywordMessage {
|
190
|
+
return tail._valueForReceiver_(receiver);
|
191
|
+
}
|
192
|
+
|
193
|
+
message = binaryMessage / unaryMessage / keywordMessage
|
194
|
+
|
195
|
+
cascade = ws send:(keywordSend / binarySend) messages:(ws ";" ws mess:message ws {return mess})+
|
196
|
+
{
|
197
|
+
var cascade = [];
|
198
|
+
cascade.push(send);
|
199
|
+
for(var i=0;i<messages.length;i++) {
|
200
|
+
cascade.push(messages[i]);
|
201
|
+
}
|
202
|
+
return smalltalk.CascadeNode._new()
|
203
|
+
._receiver_(send._receiver())
|
204
|
+
._nodes_(cascade)
|
205
|
+
}
|
206
|
+
|
207
|
+
jsStatement = "<" val:((">>" {return ">"} / [^>])*) ">"
|
208
|
+
{
|
209
|
+
return smalltalk.JSStatementNode._new()
|
210
|
+
._source_(val.join(""))
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
method = ws pattern:(keywordPattern / binaryPattern / unaryPattern) ws sequence:sequence? ws {
|
215
|
+
return smalltalk.MethodNode._new()
|
216
|
+
._selector_(pattern[0])
|
217
|
+
._arguments_(pattern[1])
|
218
|
+
._nodes_([sequence])
|
219
|
+
}
|
220
|
+
|
@@ -0,0 +1,124 @@
|
|
1
|
+
Smalltalk current createPackage: 'Benchfib' properties: #{}!
|
2
|
+
Object subclass: #Benchfib
|
3
|
+
instanceVariableNames: ''
|
4
|
+
category: 'Benchfib'!
|
5
|
+
|
6
|
+
!Benchfib class methodsFor: 'not yet classified'!
|
7
|
+
|
8
|
+
main
|
9
|
+
|
10
|
+
| result |
|
11
|
+
result := 0 tinyBenchmarks.
|
12
|
+
console log: '0 tinyBenchmarks => ' , result
|
13
|
+
! !
|
14
|
+
|
15
|
+
!Number methodsFor: '*Benchfib'!
|
16
|
+
|
17
|
+
benchFib
|
18
|
+
"Handy send-heavy benchmark"
|
19
|
+
"(result // seconds to run) = approx calls per second"
|
20
|
+
" | r t |
|
21
|
+
t := Time millisecondsToRun: [r := 26 benchFib].
|
22
|
+
(r * 1000) // t"
|
23
|
+
"138000 on a Mac 8100/100"
|
24
|
+
^ self < 2
|
25
|
+
ifTrue: [1]
|
26
|
+
ifFalse: [(self-1) benchFib + (self-2) benchFib + 1]
|
27
|
+
!
|
28
|
+
|
29
|
+
benchmark
|
30
|
+
"Handy bytecode-heavy benchmark"
|
31
|
+
"(500000 // time to run) = approx bytecodes per second"
|
32
|
+
"5000000 // (Time millisecondsToRun: [10 benchmark]) * 1000"
|
33
|
+
"3059000 on a Mac 8100/100"
|
34
|
+
| size flags prime k count |
|
35
|
+
size := 8190.
|
36
|
+
1 to: self do:
|
37
|
+
[:iter |
|
38
|
+
count := 0.
|
39
|
+
flags := Array new.
|
40
|
+
size timesRepeat: [ flags add: true].
|
41
|
+
1 to: size do:
|
42
|
+
[:i | (flags at: i) ifTrue:
|
43
|
+
[prime := i+1.
|
44
|
+
k := i + prime.
|
45
|
+
[k <= size] whileTrue:
|
46
|
+
[flags at: k put: false.
|
47
|
+
k := k + prime].
|
48
|
+
count := count + 1]]].
|
49
|
+
^ count
|
50
|
+
!
|
51
|
+
|
52
|
+
tinyBenchmarks
|
53
|
+
"Report the results of running the two tiny Squeak benchmarks.
|
54
|
+
ar 9/10/1999: Adjusted to run at least 1 sec to get more stable results"
|
55
|
+
"0 tinyBenchmarks"
|
56
|
+
"On a 292 MHz G3 Mac: 22727272 bytecodes/sec; 984169 sends/sec"
|
57
|
+
"On a 400 MHz PII/Win98: 18028169 bytecodes/sec; 1081272 sends/sec"
|
58
|
+
| t1 t2 r n1 n2 |
|
59
|
+
n1 := 1.
|
60
|
+
[t1 := Date millisecondsToRun: [n1 benchmark].
|
61
|
+
t1 < 1000] whileTrue:[n1 := n1 * 2]. "Note: #benchmark's runtime is about O(n)"
|
62
|
+
|
63
|
+
n2 := 16.
|
64
|
+
[t2 := Date millisecondsToRun: [r := n2 benchFib].
|
65
|
+
t2 < 1000] whileTrue:[n2 := n2 + 1].
|
66
|
+
"Note: #benchFib's runtime is about O(k^n),
|
67
|
+
where k is the golden number = (1 + 5 sqrt) / 2 = 1.618...."
|
68
|
+
|
69
|
+
^ ((n1 * 500000 * 1000) / t1) printString, ' bytecodes/sec; ',
|
70
|
+
((r * 1000) / t2) printString, ' sends/sec'
|
71
|
+
!
|
72
|
+
|
73
|
+
jsbenchFib
|
74
|
+
|
75
|
+
<if (this < 2) {
|
76
|
+
return 1;
|
77
|
+
} else {
|
78
|
+
return (this-1)._jsbenchFib() + (this-2)._jsbenchFib() + 1;}>
|
79
|
+
!
|
80
|
+
|
81
|
+
jsbenchmark
|
82
|
+
|
83
|
+
<
|
84
|
+
var size = 8190;
|
85
|
+
var count;
|
86
|
+
for (var z=0;z<this;z++) {
|
87
|
+
count = 0;
|
88
|
+
var flags = new Array();
|
89
|
+
for (var p=0; p<size; p++) {
|
90
|
+
flags[p] = true;
|
91
|
+
}
|
92
|
+
for (var i=1;i<=size;i++) {
|
93
|
+
if (flags[i-1]) {
|
94
|
+
var prime = i+1;
|
95
|
+
var k = i + prime;
|
96
|
+
while (k <= size) {
|
97
|
+
flags[k-1] = false;
|
98
|
+
k = k + prime;
|
99
|
+
}
|
100
|
+
count = count + 1;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
return count>
|
105
|
+
!
|
106
|
+
|
107
|
+
jstinyBenchmarks
|
108
|
+
"0 jstinyBenchmarks"
|
109
|
+
|
110
|
+
| t1 t2 r n1 n2 |
|
111
|
+
n1 := 1.
|
112
|
+
[t1 := Date millisecondsToRun: [n1 jsbenchmark].
|
113
|
+
t1 < 1000] whileTrue:[n1 := n1 * 2]. "Note: #benchmark's runtime is about O(n)"
|
114
|
+
|
115
|
+
n2 := 28.
|
116
|
+
[t2 := Date millisecondsToRun: [r := n2 jsbenchFib].
|
117
|
+
t2 < 1000] whileTrue:[n2 := n2 + 1].
|
118
|
+
"Note: #jsbenchFib's runtime is about O(k^n),
|
119
|
+
where k is the golden number = (1 + 5 sqrt) / 2 = 1.618...."
|
120
|
+
|
121
|
+
^ ((n1 * 500000 * 1000) / t1) printString, ' bytecodes/sec; ',
|
122
|
+
((r * 1000) / t2) printString, ' sends/sec'
|
123
|
+
! !
|
124
|
+
|
data/amber/st/Canvas.st
ADDED
@@ -0,0 +1,556 @@
|
|
1
|
+
Smalltalk current createPackage: 'Canvas' properties: #{}!
|
2
|
+
Object subclass: #HTMLCanvas
|
3
|
+
instanceVariableNames: 'root'
|
4
|
+
category: 'Canvas'!
|
5
|
+
|
6
|
+
!HTMLCanvas methodsFor: 'accessing'!
|
7
|
+
|
8
|
+
root: aTagBrush
|
9
|
+
root := aTagBrush
|
10
|
+
!
|
11
|
+
|
12
|
+
root
|
13
|
+
^root
|
14
|
+
! !
|
15
|
+
|
16
|
+
!HTMLCanvas methodsFor: 'adding'!
|
17
|
+
|
18
|
+
with: anObject
|
19
|
+
^self root with: anObject
|
20
|
+
! !
|
21
|
+
|
22
|
+
!HTMLCanvas methodsFor: 'initialization'!
|
23
|
+
|
24
|
+
initialize
|
25
|
+
super initialize.
|
26
|
+
root ifNil: [root := TagBrush fromString: 'div' canvas: self]
|
27
|
+
!
|
28
|
+
|
29
|
+
initializeFromJQuery: aJQuery
|
30
|
+
root := TagBrush fromJQuery: aJQuery canvas: self
|
31
|
+
! !
|
32
|
+
|
33
|
+
!HTMLCanvas methodsFor: 'tags'!
|
34
|
+
|
35
|
+
newTag: aString
|
36
|
+
^TagBrush fromString: aString canvas: self
|
37
|
+
!
|
38
|
+
|
39
|
+
tag: aString
|
40
|
+
^root addBrush: (self newTag: aString)
|
41
|
+
!
|
42
|
+
|
43
|
+
h1
|
44
|
+
^self tag: 'h1'
|
45
|
+
!
|
46
|
+
|
47
|
+
h2
|
48
|
+
^self tag: 'h2'
|
49
|
+
!
|
50
|
+
|
51
|
+
h3
|
52
|
+
^self tag: 'h3'
|
53
|
+
!
|
54
|
+
|
55
|
+
h4
|
56
|
+
^self tag: 'h4'
|
57
|
+
!
|
58
|
+
|
59
|
+
h5
|
60
|
+
^self tag: 'h5'
|
61
|
+
!
|
62
|
+
|
63
|
+
h6
|
64
|
+
^self tag: 'h6'
|
65
|
+
!
|
66
|
+
|
67
|
+
p
|
68
|
+
^self tag: 'p'
|
69
|
+
!
|
70
|
+
|
71
|
+
div
|
72
|
+
^self tag: 'div'
|
73
|
+
!
|
74
|
+
|
75
|
+
span
|
76
|
+
^self tag: 'span'
|
77
|
+
!
|
78
|
+
|
79
|
+
img
|
80
|
+
^self tag: 'img'
|
81
|
+
!
|
82
|
+
|
83
|
+
ul
|
84
|
+
^self tag: 'ul'
|
85
|
+
!
|
86
|
+
|
87
|
+
ol
|
88
|
+
^self tag: 'ol'
|
89
|
+
!
|
90
|
+
|
91
|
+
li
|
92
|
+
^self tag: 'li'
|
93
|
+
!
|
94
|
+
|
95
|
+
table
|
96
|
+
^self tag: 'table'
|
97
|
+
!
|
98
|
+
|
99
|
+
tr
|
100
|
+
^self tag: 'tr'
|
101
|
+
!
|
102
|
+
|
103
|
+
td
|
104
|
+
^self tag: 'td'
|
105
|
+
!
|
106
|
+
|
107
|
+
th
|
108
|
+
^self tag: 'th'
|
109
|
+
!
|
110
|
+
|
111
|
+
form
|
112
|
+
^self tag: 'form'
|
113
|
+
!
|
114
|
+
|
115
|
+
input
|
116
|
+
^self tag: 'input'
|
117
|
+
!
|
118
|
+
|
119
|
+
button
|
120
|
+
^self tag: 'button'
|
121
|
+
!
|
122
|
+
|
123
|
+
select
|
124
|
+
^self tag: 'select'
|
125
|
+
!
|
126
|
+
|
127
|
+
option
|
128
|
+
^self tag: 'option'
|
129
|
+
!
|
130
|
+
|
131
|
+
textarea
|
132
|
+
^self tag: 'textarea'
|
133
|
+
!
|
134
|
+
|
135
|
+
a
|
136
|
+
^self tag: 'a'
|
137
|
+
!
|
138
|
+
|
139
|
+
canvas
|
140
|
+
^self tag: 'canvas'
|
141
|
+
!
|
142
|
+
|
143
|
+
pre
|
144
|
+
^self tag: 'pre'
|
145
|
+
!
|
146
|
+
|
147
|
+
code
|
148
|
+
^self tag: 'code'
|
149
|
+
!
|
150
|
+
|
151
|
+
br
|
152
|
+
^self tag: 'br'
|
153
|
+
!
|
154
|
+
|
155
|
+
script
|
156
|
+
^self tag: 'script'
|
157
|
+
!
|
158
|
+
|
159
|
+
link
|
160
|
+
^self tag: 'link'
|
161
|
+
!
|
162
|
+
|
163
|
+
style
|
164
|
+
^ root addBrush: (StyleTag canvas: self)
|
165
|
+
!
|
166
|
+
|
167
|
+
p: anObject
|
168
|
+
^self p with: anObject
|
169
|
+
!
|
170
|
+
|
171
|
+
h1: anObject
|
172
|
+
^self h1 with: anObject
|
173
|
+
!
|
174
|
+
|
175
|
+
iframe
|
176
|
+
^self tag: 'iframe'
|
177
|
+
!
|
178
|
+
|
179
|
+
iframe: aString
|
180
|
+
^self iframe src: aString
|
181
|
+
!
|
182
|
+
|
183
|
+
h2: anObject
|
184
|
+
^ self h2 with: anObject
|
185
|
+
!
|
186
|
+
|
187
|
+
h3: anObject
|
188
|
+
^self h3 with: anObject
|
189
|
+
!
|
190
|
+
|
191
|
+
h4: anObject
|
192
|
+
^self h4 with: anObject
|
193
|
+
!
|
194
|
+
|
195
|
+
h5: anObject
|
196
|
+
^self h5 with: anObject
|
197
|
+
!
|
198
|
+
|
199
|
+
h6: anObject
|
200
|
+
^self h6 with: anObject
|
201
|
+
!
|
202
|
+
|
203
|
+
img: aString
|
204
|
+
^self img src: aString
|
205
|
+
!
|
206
|
+
|
207
|
+
ol: anObject
|
208
|
+
^self ol with: anObject
|
209
|
+
!
|
210
|
+
|
211
|
+
li: anObject
|
212
|
+
^self li with: anObject
|
213
|
+
!
|
214
|
+
|
215
|
+
ul: anObject
|
216
|
+
^self ul with: anObject
|
217
|
+
!
|
218
|
+
|
219
|
+
span: anObject
|
220
|
+
^self span with: anObject
|
221
|
+
!
|
222
|
+
|
223
|
+
style: aString
|
224
|
+
^ self style with: aString; yourself
|
225
|
+
!
|
226
|
+
|
227
|
+
articles
|
228
|
+
^self tag: 'articles'
|
229
|
+
!
|
230
|
+
|
231
|
+
audio
|
232
|
+
^self tag: 'audio'
|
233
|
+
!
|
234
|
+
|
235
|
+
fieldset
|
236
|
+
^self tag: 'fieldset'
|
237
|
+
!
|
238
|
+
|
239
|
+
footer
|
240
|
+
^self tag: 'footer'
|
241
|
+
!
|
242
|
+
|
243
|
+
header
|
244
|
+
^self tag: 'header'
|
245
|
+
!
|
246
|
+
|
247
|
+
hr
|
248
|
+
^self tag: 'hr'
|
249
|
+
!
|
250
|
+
|
251
|
+
section
|
252
|
+
^self tag: 'section'
|
253
|
+
!
|
254
|
+
|
255
|
+
tbody
|
256
|
+
^self tag: 'tbody'
|
257
|
+
!
|
258
|
+
|
259
|
+
tfoot
|
260
|
+
^self tag: 'tfoot'
|
261
|
+
!
|
262
|
+
|
263
|
+
thead
|
264
|
+
^self tag: 'thead'
|
265
|
+
!
|
266
|
+
|
267
|
+
video
|
268
|
+
^self tag: 'video'
|
269
|
+
! !
|
270
|
+
|
271
|
+
!HTMLCanvas class methodsFor: 'instance creation'!
|
272
|
+
|
273
|
+
onJQuery: aJQuery
|
274
|
+
^self basicNew
|
275
|
+
initializeFromJQuery: aJQuery;
|
276
|
+
initialize;
|
277
|
+
yourself
|
278
|
+
! !
|
279
|
+
|
280
|
+
Object subclass: #TagBrush
|
281
|
+
instanceVariableNames: 'canvas element'
|
282
|
+
category: 'Canvas'!
|
283
|
+
|
284
|
+
!TagBrush methodsFor: 'accessing'!
|
285
|
+
|
286
|
+
element
|
287
|
+
^element
|
288
|
+
! !
|
289
|
+
|
290
|
+
!TagBrush methodsFor: 'adding'!
|
291
|
+
|
292
|
+
contents: anObject
|
293
|
+
self
|
294
|
+
empty;
|
295
|
+
append: anObject
|
296
|
+
!
|
297
|
+
|
298
|
+
addBrush: aTagBrush
|
299
|
+
self appendChild: aTagBrush element.
|
300
|
+
^aTagBrush
|
301
|
+
!
|
302
|
+
|
303
|
+
with: anObject
|
304
|
+
self append: anObject
|
305
|
+
!
|
306
|
+
|
307
|
+
append: anObject
|
308
|
+
anObject appendToBrush: self
|
309
|
+
!
|
310
|
+
|
311
|
+
appendToBrush: aTagBrush
|
312
|
+
aTagBrush addBrush: self
|
313
|
+
!
|
314
|
+
|
315
|
+
appendBlock: aBlock
|
316
|
+
| root |
|
317
|
+
root := canvas root.
|
318
|
+
canvas root: self.
|
319
|
+
aBlock value: canvas.
|
320
|
+
canvas root: root
|
321
|
+
!
|
322
|
+
|
323
|
+
appendChild: anElement
|
324
|
+
"In IE7 and IE8 appendChild fails on several node types. So we need to check"
|
325
|
+
<var element=self['@element'];
|
326
|
+
if (null == element.canHaveChildren || element.canHaveChildren) {
|
327
|
+
element.appendChild(anElement);
|
328
|
+
} else {
|
329
|
+
element.text = String(element.text) + anElement.innerHTML;
|
330
|
+
} >
|
331
|
+
!
|
332
|
+
|
333
|
+
appendString: aString
|
334
|
+
self appendChild: (self createTextNodeFor: aString)
|
335
|
+
!
|
336
|
+
|
337
|
+
empty
|
338
|
+
self asJQuery empty
|
339
|
+
! !
|
340
|
+
|
341
|
+
!TagBrush methodsFor: 'attributes'!
|
342
|
+
|
343
|
+
at: aString put: aValue
|
344
|
+
<self['@element'].setAttribute(aString, aValue)>
|
345
|
+
!
|
346
|
+
|
347
|
+
removeAt: aString
|
348
|
+
<self['@element'].removeAttribute(aString)>
|
349
|
+
!
|
350
|
+
|
351
|
+
class: aString
|
352
|
+
<self['@element'].className = aString>
|
353
|
+
!
|
354
|
+
|
355
|
+
id: aString
|
356
|
+
self at: 'id' put: aString
|
357
|
+
!
|
358
|
+
|
359
|
+
src: aString
|
360
|
+
self at: 'src' put: aString
|
361
|
+
!
|
362
|
+
|
363
|
+
href: aString
|
364
|
+
self at: 'href' put: aString
|
365
|
+
!
|
366
|
+
|
367
|
+
title: aString
|
368
|
+
self at: 'title' put: aString
|
369
|
+
!
|
370
|
+
|
371
|
+
style: aString
|
372
|
+
self at: 'style' put: aString
|
373
|
+
!
|
374
|
+
|
375
|
+
type: aString
|
376
|
+
self at: 'type' put: aString
|
377
|
+
!
|
378
|
+
|
379
|
+
media: aString
|
380
|
+
self at: 'media' put: aString
|
381
|
+
!
|
382
|
+
|
383
|
+
rel: aString
|
384
|
+
self at: 'rel' put: aString
|
385
|
+
!
|
386
|
+
|
387
|
+
width: aString
|
388
|
+
self at: 'width' put: aString
|
389
|
+
!
|
390
|
+
|
391
|
+
height: aString
|
392
|
+
self at: 'height' put: aString
|
393
|
+
!
|
394
|
+
|
395
|
+
value: aString
|
396
|
+
self at: 'value' put: aString
|
397
|
+
! !
|
398
|
+
|
399
|
+
!TagBrush methodsFor: 'converting'!
|
400
|
+
|
401
|
+
asJQuery
|
402
|
+
^window jQuery: self element
|
403
|
+
! !
|
404
|
+
|
405
|
+
!TagBrush methodsFor: 'events'!
|
406
|
+
|
407
|
+
onKeyDown: aBlock
|
408
|
+
self asJQuery bind: 'keydown' do: aBlock
|
409
|
+
!
|
410
|
+
|
411
|
+
onKeyPress: aBlock
|
412
|
+
self asJQuery bind: 'keypress' do: aBlock
|
413
|
+
!
|
414
|
+
|
415
|
+
onKeyUp: aBlock
|
416
|
+
self asJQuery bind: 'keyup' do: aBlock
|
417
|
+
!
|
418
|
+
|
419
|
+
onFocus: aBlock
|
420
|
+
self asJQuery bind: 'focus' do: aBlock
|
421
|
+
!
|
422
|
+
|
423
|
+
onBlur: aBlock
|
424
|
+
self asJQuery bind: 'blur' do: aBlock
|
425
|
+
!
|
426
|
+
|
427
|
+
onChange: aBlock
|
428
|
+
self asJQuery bind: 'change' do: aBlock
|
429
|
+
!
|
430
|
+
|
431
|
+
onClick: aBlock
|
432
|
+
self asJQuery bind: 'click' do: aBlock
|
433
|
+
! !
|
434
|
+
|
435
|
+
!TagBrush methodsFor: 'initialization'!
|
436
|
+
|
437
|
+
initializeFromString: aString canvas: aCanvas
|
438
|
+
element := self createElementFor: aString.
|
439
|
+
canvas := aCanvas
|
440
|
+
!
|
441
|
+
|
442
|
+
initializeFromJQuery: aJQuery canvas: aCanvas
|
443
|
+
element := aJQuery get: 0.
|
444
|
+
canvas := aCanvas
|
445
|
+
! !
|
446
|
+
|
447
|
+
!TagBrush methodsFor: 'private'!
|
448
|
+
|
449
|
+
createElementFor: aString
|
450
|
+
<return document.createElement(String(aString))>
|
451
|
+
!
|
452
|
+
|
453
|
+
createTextNodeFor: aString
|
454
|
+
<return document.createTextNode(String(aString))>
|
455
|
+
! !
|
456
|
+
|
457
|
+
!TagBrush class methodsFor: 'instance creation'!
|
458
|
+
|
459
|
+
fromString: aString canvas: aCanvas
|
460
|
+
^self new
|
461
|
+
initializeFromString: aString canvas: aCanvas;
|
462
|
+
yourself
|
463
|
+
!
|
464
|
+
|
465
|
+
fromJQuery: aJQuery canvas: aCanvas
|
466
|
+
^self new
|
467
|
+
initializeFromJQuery: aJQuery canvas: aCanvas;
|
468
|
+
yourself
|
469
|
+
! !
|
470
|
+
|
471
|
+
Object subclass: #Widget
|
472
|
+
instanceVariableNames: ''
|
473
|
+
category: 'Canvas'!
|
474
|
+
|
475
|
+
!Widget methodsFor: 'adding'!
|
476
|
+
|
477
|
+
appendToBrush: aTagBrush
|
478
|
+
self appendToJQuery: aTagBrush asJQuery
|
479
|
+
!
|
480
|
+
|
481
|
+
appendToJQuery: aJQuery
|
482
|
+
self renderOn: (HTMLCanvas onJQuery: aJQuery)
|
483
|
+
! !
|
484
|
+
|
485
|
+
!Widget methodsFor: 'rendering'!
|
486
|
+
|
487
|
+
renderOn: html
|
488
|
+
self
|
489
|
+
! !
|
490
|
+
|
491
|
+
TagBrush subclass: #StyleTag
|
492
|
+
instanceVariableNames: 'canvas element'
|
493
|
+
category: 'Canvas'!
|
494
|
+
!StyleTag commentStamp!
|
495
|
+
I'm a <style> tag use to inline CSS or load a stylesheet.
|
496
|
+
|
497
|
+
For inlining handle IE compatibility problems.!
|
498
|
+
|
499
|
+
!StyleTag methodsFor: 'adding'!
|
500
|
+
|
501
|
+
with: aString
|
502
|
+
self isBrowserIE
|
503
|
+
ifTrue: [self element styleSheet cssText: aString ]
|
504
|
+
ifFalse: [super with: aString ].
|
505
|
+
! !
|
506
|
+
|
507
|
+
!StyleTag methodsFor: 'testing'!
|
508
|
+
|
509
|
+
isBrowserIE
|
510
|
+
|ie|
|
511
|
+
ie := <jQuery.browser.msie>.
|
512
|
+
^ ie notNil.
|
513
|
+
! !
|
514
|
+
|
515
|
+
!StyleTag class methodsFor: 'instance creation'!
|
516
|
+
|
517
|
+
canvas: aCanvas
|
518
|
+
^self new
|
519
|
+
initializeFromString: 'style' canvas: aCanvas;
|
520
|
+
yourself
|
521
|
+
! !
|
522
|
+
|
523
|
+
!Object methodsFor: '*Canvas'!
|
524
|
+
|
525
|
+
appendToJQuery: aJQuery
|
526
|
+
aJQuery append: self asString
|
527
|
+
!
|
528
|
+
|
529
|
+
appendToBrush: aTagBrush
|
530
|
+
aTagBrush append: self asString
|
531
|
+
! !
|
532
|
+
|
533
|
+
!BlockClosure methodsFor: '*Canvas'!
|
534
|
+
|
535
|
+
appendToJQuery: aJQuery
|
536
|
+
self value: (HTMLCanvas onJQuery: aJQuery)
|
537
|
+
!
|
538
|
+
|
539
|
+
appendToBrush: aTagBrush
|
540
|
+
aTagBrush appendBlock: self
|
541
|
+
! !
|
542
|
+
|
543
|
+
!String methodsFor: '*Canvas'!
|
544
|
+
|
545
|
+
asJQuery
|
546
|
+
<return jQuery(String(self))>
|
547
|
+
!
|
548
|
+
|
549
|
+
appendToJQuery: aJQuery
|
550
|
+
aJQuery append: self
|
551
|
+
!
|
552
|
+
|
553
|
+
appendToBrush: aTagBrush
|
554
|
+
aTagBrush appendString: self
|
555
|
+
! !
|
556
|
+
|