Skip to content

Instantly share code, notes, and snippets.

View bob-sims's full-sized avatar

Bob Sims bob-sims

View GitHub Profile
win.add(createKraWebView({template: "templateexamaple.html",data:{name:"ole",role:"bass",presentation:"<p>Nice guy!</p>"}}));
@johnthethird
johnthethird / http_client_with_cache.coffee
Created September 1, 2010 03:38
HTTPClientWithCache for Titanium in CoffeeScript
###
------> HTTPClientWithCache <------
This class is a wrapper around the standard Titanium.Network.HTTPClient(), but it adds a
few nice features:
* A cache backed by a SQLite database. All HTTPClientWithCache instances use the same database table, with
the primary cache key being a hash of the full URL (and any data parameters in a POST)
* The cache is automatically pruned before each query
* A retry mechanism, so that you can retry a particular query a number of times before failing.
@mschmulen
mschmulen / myLocationOnAMap
Created January 4, 2011 06:36
show my location on a map
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
Ti.Geolocation.purpose = "FUN";
var win = Ti.UI.createWindow({
exitOnClose: true,
backgroundColor:'#336699',
title: 'Main Window',
navBarHidden: false
});
Titanium.UI.setBackgroundColor('#fff');
var tibh = {}; //create app namespace
Ti.include('ui.js','network.js','db.js');
tibh.tabGroup = tibh.ui.createApplicationTabGroup();
tibh.tabGroup.open();
@dawsontoth
dawsontoth / InfiniteScrollingTableView.js
Created February 3, 2011 22:49
Infinite loading table view for iOS and Android.
/**
* We're going to create an infinite loading table view. Whenever you get close to the bottom, we'll load more rows.
*/
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var isAndroid = Ti.Platform.osname === 'android';
/**
* Create our UI elements.
*/
var table = Ti.UI.createTableView({ top: 0, right: 0, bottom: 0, left: 0 });
@dawsontoth
dawsontoth / Geolocation.js
Created February 9, 2011 23:35
Constantly Updating Geolocation in Appcelerator Titanium
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
Titanium.Geolocation.distanceFilter = 0;
var win = Ti.UI.createWindow({backgroundColor: '#fff'});
var label = Ti.UI.createLabel();
win.add(label);
win.open();
function reportPosition(e) {
if (!e.success || e.error) {
@dawsontoth
dawsontoth / tweetView.js
Created February 10, 2011 04:07
Make tweets and links clickable in Titanium Mobile! Here I make a tweet look just like it does on Twitter, and interact the same too.
/**
* Define our parser class. It takes in some text, and then you can call "linkifyURLs", or one of the other methods,
* and then call "getHTML" to get the fully parsed text back as HTML!
* @param text that you want parsed
*/
function Parser(text) {
var html = text;
var urlRegex = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;
@dawsontoth
dawsontoth / LightweightClickableGrid.js
Created February 16, 2011 17:45
Lightweight clickable grids in Appcelerator Titanium; put this in an app.js!
/**
* Creates a grid that you can click on.
* @param options
*/
function createGrid(options) {
// default options
var defaultOptions = {
gridViewOptions: {
top: 0,
@dawsontoth
dawsontoth / AndroidEmails.js
Created February 17, 2011 17:15
How to send emails in Appcelerator Titanium using activities and intents.
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var button = Ti.UI.createButton({ title: 'Share' });
win.add(button);
win.open();
button.addEventListener('click', function() {
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_SEND,
type: 'text/plain'
});
@dawsontoth
dawsontoth / RecordingVideo.js
Created February 17, 2011 19:43
How to record video, then share or save it. Using Appcelerator Titanium!
/**
* This sample lets you record and share video with Appcelerator Titanium on Android.
* REQUIRES THE 1.6.0 RC OF TITANIUM MOBILE SDK
* http://developer.appcelerator.com/blog/2011/02/release-candidate-for-titanium-mobile-1-6-0.html
*/
/**
* First, create our UI. We'll have two buttons: record, and share.
*/
var win = Titanium.UI.createWindow({