rubyx-debugger/app/debugger.rb

39 lines
859 B
Ruby
Raw Normal View History

2015-07-22 15:17:25 +02:00
require 'opal'
require 'browser'
require 'opal-jquery'
require "json"
require 'opal-react'
2015-07-22 15:22:54 +02:00
require "class_view"
require "register_view"
require "source_view"
2015-07-22 15:17:25 +02:00
2015-07-22 15:22:54 +02:00
Document.ready? do # Document.ready? is a opal-jquery method.
2015-07-22 15:17:25 +02:00
React.render( React.create_element( Debugger), Element['#content'] )
end
class Debugger
include React::Component
# required_param :url
define_state sources: JSON.from_object(`window.initial_sources`)
# before_mount do
# HTTP.get(url) do |response|
# if response.ok?
# sources! JSON.parse(response.body)
# else
# puts "failed with status #{response.status_code}"
# end
# end
# end
def render
div class: "sourceBox" do
h1 { "Sources" }
ClassView sources: sources
RegisterView submit_source: lambda { |source| sources! << sourceAuthor}
end
end
end