Skip to content

Instantly share code, notes, and snippets.

@collegeman
Created February 14, 2011 03:19
Show Gist options
  • Save collegeman/825437 to your computer and use it in GitHub Desktop.
Save collegeman/825437 to your computer and use it in GitHub Desktop.
I found this log() function very useful for exploring the Titanium API. The WebKit console is simply the best way to explore JavaScript objects. This implementation of a global log() function makes it easy to use the WebKit logger to inspect any object, i
(function(T, api) {
function log() {
if (window.console) {
window.console.log.apply(null, Array.prototype.slice.call(arguments));
} else {
api.prototype.log.apply(null, Array.prototype.slice.call(arguments));
}
}
T.UI.getMainWindow().showInspector(true);
// listen for open requests (drag and drop on the desktop icon)
T.addEventListener(T.ALL, function(evt) {
if (evt.getType() == 'open.request' && evt.files.length) {
T.Platform.openApplication(evt.files[0]);
}
log(evt.getType(), evt, evt.getTarget());
});
})(Titanium, Titanium.API);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment