Skip to content

Instantly share code, notes, and snippets.

View kwhinnery's full-sized avatar

Kevin Whinnery kwhinnery

View GitHub Profile
<div set="control[panel,theme=dark,title=Words of Wisdom,footer=Nolan Wright]"
style="width:300px">
Just say no!
</div>
<div set="control[app:iterator]" type="bar" chartMode="mode"
on="l:load.barchart then execute"
property="rows" chartTitles="titles"
title="Happiness Meter" angle="30" color="#0D52D1,#2A0CD0,#8A0CCF"
thickness="10" height="300" width="600" legend="true">
</div>
<script style="display:none;">
$MQ('l:load.barchart',
{'rows':[
{'name':'Appcelerator', 'value':'10,10,10'},
<id>initial</id>
<url>index.html</url>
<backgroundColor>#000</backgroundColor>
<fullscreen>false</fullscreen>
<hideNavBar>true</hideNavBar>
<hideTabBar>true</hideTabBar>
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript" src="index.js"></script>
<script type="text/javascript" src="tiui/js/tiui.js"></script>
<link href="tiui/css/tiui.css" rel="stylesheet" type="text/css"></link>
<link href="index.css" rel="stylesheet" type="text/css"></link>
<center><img src="images/logo-m.png"></img></center>
<hr/>
<div id="options">
<h4>Upload a Picture</h4>
<input id="choose" type="button" value="Choose Picture"></input>
<input id="take" type="button" value="Take A Picture"></input>
<h5>Message (Optional - 110 Characters)</h5>
<textarea id="message"></textarea>
</div>
//Wire up buttons to save/recall
$("#store").click(function() {
storeLogin();
});
$("#recall").click(function() {
recallLogin();
});
//recall any saved login information and show UI
recallLogin();
//Handle storing and recalling username/password
function storeLogin() {
Titanium.App.Properties.setString('username',$("#username").val());
Titanium.App.Properties.setString('password',$("#password").val());
}
function recallLogin() {
$("#username").val(Titanium.App.Properties.getString('username'));
$("#password").val(Titanium.App.Properties.getString('password'));
}
//Make XHR request to post picture
function postPic(pic) {
var query = 'https://twitpic.com/api/uploadAndPost';
var xhr = Titanium.Network.createHTTPClient();
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
notify('Picture posted sucessfully!');
}
};
xhr.open('POST',query);
//display a notification message
function notify(msg) {
Titanium.API.debug(msg);
var n = Titanium.UI.createNotification();
n.setMessage(msg);
n.show();
}
Titanium.Media.openPhotoGallery({
success: function(image,details) {
postPic(image);
},
error: function(e) {
notify(e.message);
},
cancel: function() {
//no op
},