Skip to content

Instantly share code, notes, and snippets.

View dfjdejulio's full-sized avatar
💽
I haz a status now.

Doug DeJulio dfjdejulio

💽
I haz a status now.
View GitHub Profile
@rayh
rayh / example.js
Last active March 2, 2016 03:26
Example page loader for TVJS/TVML
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();
}
@rayh
rayh / Example.swift
Created September 21, 2015 03:38
Setup console.log() for TVJS apps
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")
}