Skip to content

Instantly share code, notes, and snippets.

View rblalock's full-sized avatar
🚀

Rick Blalock rblalock

🚀
View GitHub Profile
@pec1985
pec1985 / TableViewIndex.js
Last active September 25, 2015 11:08
Get the right column of letters on a table view
/* Ever wondered how to get the nice column of letters in the right side
* of the table view?
*
* Here is an example:
* 1. We take a list of names from a json file
* 2. We need to sort them by either first name or last name
* 3. We need to create a row header once in a while, when the first letter changes
* 4. We need to create a table index
*
*/
@pec1985
pec1985 / ColorClock.js
Created April 19, 2011 03:56
Change background color as time passes by
// inspired on http://www.joelpeterson.com/clock/
// and most of the code taken from there as well
var win = Ti.UI.createWindow({
orientationModes: [3, 4]
});
var clock_bg = Ti.UI.createView({
backgroundColor: '#444444',
top: 20,
left: 20,
@pec1985
pec1985 / webViewZoom.js
Created April 21, 2011 01:23
Increase zoom level in WebView
var win = Titanium.UI.createWindow({
backgroundColor:'#fff'
});
var webView = Ti.UI.createWebView({ url:'http://www.appcelerator.com', scalesPageToFit:true,setZoomScale:2, top:0, left:0});
win.add(webView);
var firstTime = true;
var htmlHack = '';
htmlHack += 'var element = document.createElement("meta");';
htmlHack += 'element.name = "viewport";';
@dawsontoth
dawsontoth / app.js
Created April 23, 2011 02:14
Simple remote on demand image caching.
var iconStore = Ti.Filesystem.applicationDataDirectory + '/CachedRemoteImages';
var dir = Ti.Filesystem.getFile(iconStore);
if (!dir.exists()) {
dir.createDirectory();
}
function cacheRemoteURL(image, imageURL) {
if (imageURL) {
var hashedSource = Ti.Utils.md5HexDigest(imageURL + '') + '.' + imageURL.split('.').pop();
var localIcon = Ti.Filesystem.getFile(iconStore, hashedSource);
if (localIcon.exists()) {
@dawsontoth
dawsontoth / app.js
Created May 10, 2011 14:05
Loading images in @appcelerator #Titanium
/* The images for this example can be downloaded from http://j.mp/loadingimagesforti */
var win = Ti.UI.createWindow({ backgroundColor: '#f00'});
var loading = Ti.UI.createImageView({
images: [
'images/loading/00.png', 'images/loading/01.png', 'images/loading/02.png',
'images/loading/03.png', 'images/loading/04.png', 'images/loading/05.png',
'images/loading/06.png', 'images/loading/08.png', 'images/loading/09.png',
'images/loading/10.png', 'images/loading/11.png'
],
width: 33, height: 33
@pec1985
pec1985 / customRowEdit.js
Created May 13, 2011 10:27
Swipe on a row to add custom elements
var win = Titanium.UI.createWindow({
title:'table',
});
var table = Ti.UI.createTableView({});
win.add(table);
var oldRow = {};
function swipe(a,b,c){
// a = view
@pec1985
pec1985 / deleterow.js
Created June 10, 2011 01:35
delete a row in a table view in android
var win = Ti.UI.createWindow({
backgroundColor:'#ccc'
});
// create the table view
var tableView = Ti.UI.createTableView({});
// create an empty array
var data = [];
// this is the alert message + deleting the row from the array
function confirmDel(rowId,rowName) {
@pec1985
pec1985 / scrollablaZoom.js
Created June 10, 2011 18:52
Zoom-in in a scrollable view - iOS
var win = Ti.UI.createWindow();
function view(img){
var image = Ti.UI.createImageView({
url:img
});
return image;
}
var scrollable = Ti.UI.createScrollableView({
@rblalock
rblalock / test2.js
Created June 17, 2011 20:57
Simple JS test of the prototype vs. module pattern in TI.
var timetest = new Date();
// TEST ONE WITH PROTOTYPE
// function User() {}
// for(var i = 0; i < 50000; i++) {
// User.prototype[i] = {};
// }
// TEST TWO Module Pattern
@pec1985
pec1985 / customnav.js
Created June 22, 2011 15:24
Custom Navigation Controller, compatible with Android and iPhone
// Flags, is this for Android or iPhone?
var iPhone = false;
var Android = false;
if(Ti.Platform.osname == 'iphone'){
iPhone = true
};
if(Ti.Platform.osname == 'android'){
Android = true
};