Skip to content

Instantly share code, notes, and snippets.

@mauropm
mauropm / app.js
Created July 3, 2014 20:13
Textfield with custom passwordMask
var win = Ti.UI.createWindow({
backgroundColor:'white',
});
var tf = Ti.UI.createTextField({
top:10,
left:10,
width:20,
content:'',
maxLength:'3',
@mauropm
mauropm / app.js
Created May 13, 2014 22:47
Password mask test for S3
var win = Ti.UI.createWindow({
backgroundColor:'white',
});
var pm = Ti.UI.createTextField({
color: '#336699',
top: 10,
left: 10,
width: 250,
height: 60,
@mauropm
mauropm / app.js
Last active August 29, 2015 13:56
Script showing how to clean a view inside a window (like a scrollview)
// INcluding memory management utils.
Ti.include('utils.js');
// root window.
var win = Ti.UI.createWindow({
backgroundColor : 'white',
exitOnclose : true,
});
if (Ti.UI.Android) {
@mauropm
mauropm / app.js
Created January 14, 2014 01:19
A sample of ciphering text using a modulus found in the PEM file, based on Tom Wu's code/sample: http://www-cs-students.stanford.edu/~tjw/jsbn/
// PEM encryption is possible! I found a JS work by Tom Wu, that you can see here:
// http://www-cs-students.stanford.edu/~tjw/jsbn/
// This code attempts to adapt his sample/test code and how to use it in Titanium Appcelerator.
Ti.include("jsbn.js");
Ti.include("prng4.js");
Ti.include("rng.js");
Ti.include("rsa.js");
Ti.include("base64.js");
@mauropm
mauropm / app.js
Created December 21, 2013 00:07
This app shows a vertical label, just like for a bookmark in a window.
var flip = Ti.UI.create2DMatrix();
flip = flip.rotate(-90);
var commonSideTextOne = Ti.UI.createWebView({
html: '<p style="color:#fff;font-size: 10pt; padding-top: 2pt; font-family: futura;">Engine and <br />Drive Train</p>',
transform: flip,
top: 100,
left: 100,
width: 180,
height: 120,
@mauropm
mauropm / app.js
Created December 20, 2013 23:52
This code emulates an app that will send it's geolocation once. You can easily modified it to make it send the user's location every time the app opens or the app resumes.
// We create global variables that will
// save the latest geolocation
myGeolocation = {};
myGeolocation.lon = 0;
myGeolocation.lat = 0;
// This is the call function of the getCurrentPosition
// Note that you are storing the current lat and long
// so you can use it anywhere else in the code.
// You can even throw another event within this function
@mauropm
mauropm / app.js
Created July 25, 2013 19:59
Adding a reference of the elements inside a row, so you can programmatically remember how to access a certain label or image. To use this app: create a new project in Ti Studio, using a classic titanium project, copy this to app.js and run it in emulator. Check the "try to print a custom value in the row". That's the way you will be able to acce…
var win = Ti.UI.createWindow({
backgroundColor:'white',
});
var tableData = [];
for (var i=1; i<=20; i++){
var row = Ti.UI.createTableViewRow({
className:'forumEvent', // used to improve table performance
selectedBackgroundColor:'white',
@mauropm
mauropm / app.js
Created July 6, 2013 16:28
Example about how to connect to facebook, syncing the fb username with your ACS Cloud, and looking for your friends using the same app. USAGE: Create a new mobile project, classic titanium, with cloud support. Paste this app.js into your project's app.js.
var Cloud = require('ti.cloud');
Cloud.debug = true;
// optional; if you add this line, set it to false for production
var fb = require('facebook');
// Check for your app id in developers.facebook.com
fb.appid = ADD_YOUR_APPID_HERE!;
fb.permissions = ['publish_stream'];
// Permissions your app needs
fb.forceDialogAuth = true;
fb.addEventListener('login', function(e) {
@mauropm
mauropm / app.js
Created July 4, 2013 05:40
Vertical automatic scrollableview. This will automatically add views in the end and remove views from the beginning of the views array. USE: Create a new mobile project in Ti Studio (classic titanium) and paste this to app.js. With some code from Dawson: https://gist.github.com/dawsontoth/839218 (to do the vertical part)
var win = Ti.UI.createWindow({
backgroundColor:'white',
});
// *** This is taken from Dawsontoth's https://gist.github.com/dawsontoth/839218
var rotate = Ti.UI.create2DMatrix().rotate(90);
var counterRotate = rotate.rotate(-180);
// *** end of the code taken from Dawsontoth's
function randomInt(min, max) {
@mauropm
mauropm / app.js
Last active December 19, 2015 08:19
This app.js will create a new scrollableview, then will be removing and adding views, it removes the beginning (HEAD) of the views array in the scrollableview and will add a new view at the end (TAIL). To use this, please add a new mobile project in Ti Studio (classic titanium) and then paste this code to app.js. If you do funny things with this…
var win = Ti.UI.createWindow({
backgroundColor:'white',
});
function randomInt(min, max) {
return Math.round(min + Math.random()*(max-min));
}
function getView(){
var rnd = randomInt(0,200) % 3;