Module: Kernel
- Defined in:
- opal/fron/core_ext/kernel.rb
Overview
Kernel
Instance Method Summary collapse
-
#alert(text) ⇒ Object
Shows an alert window with the given text.
-
#clear_timeout(id) ⇒ Object
Clears the timeout with the given ID.
-
#confirm(text) ⇒ Boolean
Shows an confirm window with the given text.
-
#logger ⇒ Fron::Logger
Returns the logger for the application.
- #open_window(url) ⇒ Object
-
#prompt(text, value) ⇒ String
Shows a prompt window with text and value.
-
#request_animation_frame ⇒ Object
Requests an animation frame from the browser and runs the givel block if given.
-
#timeout(ms = 0) ⇒ Object
Runs the given block after the given number of milliseconds.
-
#trace! ⇒ Object
Produces a JavaScript stack trace in the console.
Instance Method Details
#alert(text) ⇒ Object
Shows an alert window with the given text
31 32 33 |
# File 'opal/fron/core_ext/kernel.rb', line 31 def alert(text) `alert(#{text})` end |
#clear_timeout(id) ⇒ Object
Clears the timeout with the given ID
51 52 53 |
# File 'opal/fron/core_ext/kernel.rb', line 51 def clear_timeout(id) `clearTimeout(#{id})` end |
#confirm(text) ⇒ Boolean
Shows an confirm window with the given text
40 41 42 |
# File 'opal/fron/core_ext/kernel.rb', line 40 def confirm(text) `confirm(#{text})` end |
#logger ⇒ Fron::Logger
Returns the logger for the application
58 59 60 |
# File 'opal/fron/core_ext/kernel.rb', line 58 def logger @logger ||= Fron::Logger.new end |
#open_window(url) ⇒ Object
44 45 46 |
# File 'opal/fron/core_ext/kernel.rb', line 44 def open_window(url) `window.open(#{url})` end |
#prompt(text, value) ⇒ String
Shows a prompt window with text and value
24 25 26 |
# File 'opal/fron/core_ext/kernel.rb', line 24 def prompt(text, value) `prompt(#{text}, #{value}) || Opal.NIL` end |
#request_animation_frame ⇒ Object
Requests an animation frame from the browser and runs the givel block if given.
5 6 7 8 9 |
# File 'opal/fron/core_ext/kernel.rb', line 5 def request_animation_frame return unless block_given? return unless `!!window.requestAnimationFrame` `window.requestAnimationFrame(function(){ #{yield} })` end |
#timeout(ms = 0) ⇒ Object
Runs the given block after the given number of milliseconds.
14 15 16 |
# File 'opal/fron/core_ext/kernel.rb', line 14 def timeout(ms = 0) `setTimeout(function(){#{yield}},#{ms})` end |
#trace! ⇒ Object
Produces a JavaScript stack trace in the console
63 64 65 |
# File 'opal/fron/core_ext/kernel.rb', line 63 def trace! `console.trace()` end |