This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SimplePage = function(url) { | |
var self = this; | |
function onSelect(event) { | |
var ele = event.target | |
var href = ele.getAttribute("href") | |
if(href) { | |
new SimplePage(href).load(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func appController(appController: TVApplicationController, evaluateAppJavaScriptInContext jsContext: JSContext) { | |
jsContext.evaluateScript("var console = {log: function() { var message = ''; for(var i = 0; i < arguments.length; i++) { message += arguments[i] + ' ' }; console.print(message) } };") | |
let logFunction: @convention(block) (NSString!) -> Void = { (message:NSString!) in | |
print("JS: \(message)") | |
} | |
jsContext.objectForKeyedSubscript("console").setObject(unsafeBitCast(logFunction, AnyObject.self), forKeyedSubscript:"print") | |
} |