-
-
Save donayama/846092 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Test Runner - Online Code Debuging Framework for Titanium Mobile(iOS) | |
| var tabGroup = Titanium.UI.createTabGroup(); | |
| tabGroup.addTab(Titanium.UI.createTab({ | |
| icon:'KS_nav_views.png', | |
| title:'Test Runner', | |
| window: Titanium.UI.createWindow({ | |
| title:'Test Runner', | |
| backgroundColor:'#fff', | |
| url: 'testrunner.js' | |
| }) | |
| })); | |
| tabGroup.open(); |
This file contains hidden or 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 button = Ti.UI.createButton({title: 'hoge', top:150, width:100, height:50}); | |
| Ti.UI.currentWindow.add(button); | |
| button.addEventListener('click', function(){ | |
| Ti.Media.showCamera({ | |
| success:function(e){ | |
| var f = Ti.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,'camera_photo.png'); | |
| f.write(e.media); | |
| Titanium.UI.currentWindow.backgroundImage = f.nativePath; | |
| } | |
| }); | |
| }); |
This file contains hidden or 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
| { | |
| "data":[ | |
| {"title":"buttons", "url":"buttons.js"}, | |
| {"title":"fork test", "url":"camera.js"} | |
| ] | |
| } |
This file contains hidden or 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 baseURL = 'https://gist.github.com/raw/846009/'; | |
| var tv = Ti.UI.createTableView(); | |
| tv.addEventListener('click', function(e){ | |
| if(e.rowData && e.rowData.url){ | |
| var xhr = Titanium.Network.createHTTPClient({ | |
| onload: function(){ | |
| var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'test.js'); | |
| f.write(this.responseData); | |
| var w = Ti.UI.createWindow({title: e.rowData.title, url:f.resolve()}); | |
| Ti.UI.currentTab.open(w); | |
| } | |
| }); | |
| xhr.open('GET', baseURL + e.rowData.url); | |
| xhr.send(); | |
| } | |
| }); | |
| Ti.UI.currentWindow.add(tv); | |
| var loadJson = function(){ | |
| var xhr = Titanium.Network.createHTTPClient({ | |
| onload: function(){ | |
| var json = JSON.parse(xhr.responseText); | |
| tv.data = json.data; | |
| } | |
| }); | |
| xhr.open('GET', baseURL + 'test.json'); | |
| xhr.send(); | |
| }; | |
| Ti.UI.currentWindow.rightNavButton = ((function(){ | |
| var b = Titanium.UI.createButton({systemButton: Titanium.UI.iPhone.SystemButton.REFRESH}); | |
| b.addEventListener('click', function(){ | |
| loadJson(); | |
| }); | |
| return b; | |
| })()); | |
| loadJson(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment