Skip to content

Instantly share code, notes, and snippets.

View brentonhouse's full-sized avatar
🚀
Busy being awesome!

Brenton House brentonhouse

🚀
Busy being awesome!
View GitHub Profile
/**
* Module exports.
*/
/**
* Check if `obj` is an array.
*/
function isArray(obj) {
return '[object Array]' == {}.toString.call(obj);
//
// blog.clearlyionnovative.com
// twitter: @aaronksaunders
//
// Model file for integration Appcelerator Titanium Alloy with Wordpress JSON Plugin
//
exports.definition = {
config : {
"columns" : {},
// implements a reusable countdown timer
// arguments:
// upper : upper limit to start countdown at
// onStart : function to execute when the timer starts
// onInterval : function to execute every second, like update screen
// onComplete : function to execute when the timer reaches 0
// onKill : function to execute when the timer is manually killed
function countdownTimer(upper,onStart,onInterval,onComplete,onKill){
var interval;
/*! Socket.IO.js build:0.9.6, development. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
/**
* Originally Ported to titanium by Jordi Domenech <jordi@iamyellow.net>
* source: https://github.com/iamyellow/socket.io-client
*/
this.io = {};
module.exports = this.io;
/**
// Save event handler with breadcrumb
$('#saveButton').click(function() {
savePlayerInfo();
Crittercism.leaveBreadcrumb("Save button clicked");
});
# We have a function that loads some resource. It might get called multiple times by our application, for example a web server.
# We use a stored promise to serve as both a cache and a hook for multiple callers to get the same result
# JavaScript version at the bottom
Q = require 'q'
loadPromise = null
doLoad = ->
if not loadPromise
# get a fresh result
loadPromise = Q.delay(1000).then -> Date.now()
# after 1 second clear cache
/**
* Handle Item Swipe
* @param {Object} _event
*/
$.handleItemSwipe = function(_event) {
var row = _event.source;
var id = row.id;
var controls = Alloy.createController("rowControls");
row.add(controls.wrapper);
/**
* Helper for opening / animating sidebar
*/
$.openSidebar = function() {
if(isOpen) {
var animateRight = Ti.UI.createAnimation({
left : 0,
curve : Ti.UI.ANIMATION_CURVE_EASE_OUT,
duration : 200
});
var RedLaser = require('ti.redlaser');
var win = Ti.UI.createWindow({
backgroundColor: "#eee"
});
var startScanningBtn = Ti.UI.createButton({
width: "50%",
height: 50,
title: "Start Scanning"
Alloy.createWidget = function(id, name, args) {
Ti.Analytics.featureEvent("widget." + id, args);
return new (require("alloy/widgets/" + id + "/controllers/" + (name || "widget")))(args);
};
Alloy.createController = function(name, args) {
Ti.Analytics.featureEvent("controller." + name, args);
return new (require("alloy/controllers/" + name))(args);
};