Skip to content

Instantly share code, notes, and snippets.

@kopiro
Created May 20, 2015 15:15
Show Gist options
  • Save kopiro/bda566a16113636f39ba to your computer and use it in GitHub Desktop.
Save kopiro/bda566a16113636f39ba to your computer and use it in GitHub Desktop.
devtools.js
exports.show = function() {
var win = Ti.UI.createWindow({
title: 'Developer Tools',
layout: 'vertical'
});
win.leftNavButton = Ti.UI.createButton({ title: 'Chiudi' });
win.leftNavButton.addEventListener('click', function() {
(nav || win).close();
});
win.add(Ti.UI.createLabel({
top: 20,
font: { fontWeight: 'bold' },
text: Ti.App.name + ' ' + Ti.App.version + ' on ' + Ti.App.deployType
}));
var $inputJS = Ti.UI.createTextArea({
top: 20,
left: 10,
right: 10,
height: 250,
backgroundColor: '#111',
color: '#fff',
borderRadius: 4,
font: { fontFamily: 'Menlo', fontSize: 10 },
});
win.add($inputJS);
var $outputJS = Ti.UI.createTextArea({
top: 5,
left: 10,
right: 10,
height: 100,
backgroundColor: '#eee',
color: '#111',
borderRadius: 4,
font: { fontFamily: 'Menlo', fontSize: 10 },
})
win.add($outputJS);
var $evalJS = Ti.UI.createButton({
top: 5,
width: 200,
title: 'Run'
});
$evalJS.addEventListener('click', function(e) {
try {
$outputJS.value = eval($inputJS.value) || '';
} catch (err) {
$outputJS.value = err;
}
});
win.add($evalJS);
win.add(Ti.UI.createView({
left: 10,
right: 10,
height: 1,
top: 10,
backgroundColor: '#ddd'
}));
win.add(Ti.UI.createLabel({
top: 10,
left: 10,
right: 10,
font: { fontFamily: 'Menlo', fontSize: 10 },
text: JSON.stringify(Alloy.CFG, null, 2)
}));
if (OS_IOS) {
var nav = Ti.UI.iOS.createNavigationWindow({
window: win,
modal: true
});
nav.open();
} else {
win.open();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment