Skip to content

Commit

Permalink
add amazing dom loading
Browse files Browse the repository at this point in the history
  • Loading branch information
defunkt committed Jun 26, 2009
1 parent 4b27131 commit 23e4635
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/lyndon/delegate.rb
@@ -0,0 +1,7 @@
module Lyndon
class Delegate
def webView(sender, didFinishLoadForFrame:frame)
NSApplication.sharedApplication.stop(self)
end
end
end
12 changes: 11 additions & 1 deletion lib/lyndon/runtime.rb
Expand Up @@ -2,10 +2,20 @@


module Lyndon module Lyndon
class Runtime class Runtime
def initialize def initialize(dom = nil)
@webView = WebView.new @webView = WebView.new
@webView.setFrameLoadDelegate(Delegate.new)

@scripter = @webView.windowScriptObject @scripter = @webView.windowScriptObject
@scripter.setValue(Ruby.new, forKey:"Ruby") @scripter.setValue(Ruby.new, forKey:"Ruby")

load_dom(dom) if dom
end

def load_dom(dom, base_url = nil)
dom = File.exists?(dom) ? File.read(dom) : dom
@webView.mainFrame.loadHTMLString(dom, baseURL:base_url)
NSApplication.sharedApplication.run
end end


def eval(js) def eval(js)
Expand Down

0 comments on commit 23e4635

Please sign in to comment.