Class: OpalWebConsole

Inherits:
Object
  • Object
show all
Defined in:
app/assets/javascripts/setup_opal_irb_jqconsole.js.rb

Class Method Summary collapse

Class Method Details

.hideObject



28
29
30
31
# File 'app/assets/javascripts/setup_opal_irb_jqconsole.js.rb', line 28

def hide
  OpalIrbJqconsole.hide_panel
  show_tips if !@show_tips
end

.hide_tipsObject



43
44
45
46
47
48
49
50
51
# File 'app/assets/javascripts/setup_opal_irb_jqconsole.js.rb', line 43

def hide_tips
  hide_cmd = if defined? Opal.eval
      'Opal.eval("OpalWebConsole.hide")'
    else
      'Opal.OpalWebConsole.$hide()'
    end

  puts "OpalWebConsole Tips: run `#{hide_cmd}` in browser console to hide web console"
end

.initObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/assets/javascripts/setup_opal_irb_jqconsole.js.rb', line 3

def init
  return false if @inited # make sure `init` can be run once only

  # creates a panel at the bottom
  OpalIrbJqconsole.create_bottom_panel(hidden=false)

  # add topbar title
  Element.id("opal-irb-console-topbar").prepend(
    %{<span id="opal-irb-console-topbar-title">Web console for Opal #{Opal::VERSION} on ruby #{RUBY_VERSION}</span>}
  )

  # show how to open web console when closed the web console
  Element.id("collapse-opal-irb-console").on(:click) {
    show_tips if !@show_tips
  }

  hide_tips

  @inited = true
end

.showObject



24
25
26
# File 'app/assets/javascripts/setup_opal_irb_jqconsole.js.rb', line 24

def show
  OpalIrbJqconsole.show_panel
end

.show_tipsObject



33
34
35
36
37
38
39
40
41
# File 'app/assets/javascripts/setup_opal_irb_jqconsole.js.rb', line 33

def show_tips
  @show_tips = true
  show_cmd = if defined? Opal.eval
    'Opal.eval("OpalWebConsole.show")'
  else
    'Opal.OpalWebConsole.$show()'
  end
  puts "OpalWebConsole Tips: run `#{show_cmd}` in browser console to show web console"
end