12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- Smalltalk createPackage: 'Platform-Browser'!
- Object subclass: #BrowserPlatform
- instanceVariableNames: ''
- package: 'Platform-Browser'!
- !BrowserPlatform commentStamp!
- I am `Platform` service implementation for browser.!
- !BrowserPlatform methodsFor: 'accessing'!
- globals
- ^ window
- !
- newXhr
- XMLHttpRequest
- ifNotNil: [ ^ NativeFunction constructorOf: XMLHttpRequest ]
- ifNil: [ self error: 'XMLHttpRequest not available.' ]
- ! !
- !BrowserPlatform class methodsFor: 'testing'!
- initialize
- self isFeasible ifTrue: [ Platform registerIfNone: self new ]
- !
- isFeasible
- <inlineJS: 'return typeof window !!== "undefined"'>
- ! !
- Object subclass: #BrowserTerminal
- instanceVariableNames: ''
- package: 'Platform-Browser'!
- !BrowserTerminal commentStamp!
- I am `Terminal` service implementation for browser.!
- !BrowserTerminal methodsFor: 'actions'!
- alert: aString
- ^ window alert: aString
- !
- confirm: aString
- ^ window confirm: aString
- !
- prompt: aString
- ^ window prompt: aString
- !
- prompt: aString default: defaultString
- ^ window prompt: aString default: defaultString
- ! !
- !BrowserTerminal class methodsFor: 'testing'!
- initialize
- self isFeasible ifTrue: [ Terminal registerIfNone: self new ]
- !
- isFeasible
- <inlineJS: 'return typeof window !!== "undefined"'>
- ! !
- !Object methodsFor: '*Platform-Browser'!
- postMessageTo: aFrame
- ^ self postMessageTo: aFrame origin: '*'
- !
- postMessageTo: aFrame origin: aString
- <inlineJS: 'return aFrame.postMessage(self, aString)'>
- ! !
|