Appcelerator Titanium vsdoc for Visual Studio (update)

Just a quick post to give you some of the updates I’ve made to the vsdoc since the last post.

New File: Ti-vsdoc (master – 5/14/11)


Added some VS intellisense hints — All titanium modules will now show up as namespaces. Titanium objects will now show up as classes.

New vsdoc now returns the titanium type. For example Ti.UI.createWindow() actually returns a Ti.UI.Window so you’ll get intellisense for the Ti window instead of a plain object.

A few fixes for invalid datatypes in the tdocs.

‘Aliased’ Titanium with Ti

Ti.UI.currentWindow returns null — due to the way VS intellisense works and when Ti.UI.Window is defined the type can’t be returned. Kinda screws things up.

That’s all. I haven’t created a pull request to get these fixes in the master. Hopefully I’ll get to that sometime next week.

Submitted a pull request.

Code merged into main project


Adding Content URI support to your Titanium App (Android)

A while back I finally got a chance to dive into making an app with Appcelerator’s Titanium framework. Part of that task was trying to figure out how to add content uri support to the app. What that means is making your application aware of a certain content scheme. For example, a url. This of course could be expanded out to supporting your own content uri such as somethingawesome://do-something, mime types and few other methods.

I searched for quite awhile on this and found bits and pieces that helped in getting this accomplished but nothing from start to end. I tried a bunch of ways to get this done but nothing worked like I wanted. So here’s my attempt to make it easier for someone else.

For this example I’ll keep it simple by listening to a url of

First things first, open your tiapp.xml file.

In the android section of the file you’ll add an ‘activities’ section:

<android xmlns:android="">
     <activity url="app.js">
          <action android:name="android.intent.action.VIEW"/>
          <category android:name="android.intent.category.DEFAULT"/>
          <category android:name="android.intent.category.BROWSABLE"/>
          <data android:host="" android:scheme="http"/>

A few quick points here. Notice the url=”app.js” in the activity element. This could be any .js file you want to launch when the activity is started. For this example I wanted to launch the main app and parse the query string of the url.

The second point is the data element. This is letting Android know that we can handle a http link for using our activity(app.js). As mentioned earlier, there’s more you can do with the data element. I’ll leave that up to your investigation.

At this point when you click on a link to you will get an intent chooser popup asking if you want to use the browser or your app to open the link. If you choose your app…it will open your app.

Now, you’ll probably want to actually DO something when this happens. A very simple example we’ll grab the data of the intent, parse a querystring, then load a blog post by the post id in the url querystring.

In app.js (or whatever file you used for the activity url):

var activity = Ti.Android.currentActivity;
var intentData = activity.getIntent().getData();
getPost(intentData ? queryString(intentData, 'postID') : null);

To test this you’d click a link; You’d be prompted if you’d like to open this in the browser or your app. Click your app. The data from the getIntent().getData() call will contain

I grabbed a querystring function to parse out the querystring and voilà. We now have the postID of the link and can load a specific blog post.

And that’s it. Pretty simple to implement but potentially very powerful for your app.


The querystring function (original):

this.queryString = function (url, key)
    var results = new RegExp('[\\?&]' + key + '=([^&#]*)').exec(url);
    if (!results) return 0;
    return results[1] || null;

Validating Taiwan Personal IDs

I Recently had to write some simple client side validation for validating Taiwan (Republic of China) Personal/Government IDs. Pretty simple, really. But, I couldn’t find anything with a few simple searches. So, I reverted back to what documentation I had – a document…in Chinese. So I fired up google translate and whipped up some javascript.

Grab the uncompressed (1.36KB) or minified (0.664 KB)


ValidTaiwanPersonalID('F121899987')  ?  'Valid'  :  'Invalid'

Nothing spectacular — hopefully it will save someone else some trouble.

Appcelerator Titanium vsdoc for Visual Studio

Click here to get the updated file, otherwise read on 🙂

If you just want the vsdoc, here you go: Titanium-vsdoc.js

This weekend, I finally broke down and [re]learned Python. Got acquainted with Git (which I am really starting to dig). And for the trifecta, signed up for github. Why? Well, I had a sudden burst of inspiration while trying to write a walk through on how to generate a vsdoc using my C# app. About half way through I realized this was just too much work; not to mention really lame. So I buckled down for a few hours and got something that is good enough to throw out to the world. This time…it’s open source (David Caruso stole my keyboard…I swear!).

Changes from v1:

Code to generate the vsdoc is released
Includes Titanium objects
Added module events
Types now return the correct type. (ie. Function returns an array, VS will treat it as an array)

Unfortunately, Visual Studio doesn’t support comments for objects. Which, of course, a large portion of the vsdoc is made up of objects.

Anyway, if you’re interested you can view my forked project here: JeremyMelton/titanium_mobile

This has now been merged into the titanium mobile master:

How to use the vsdoc

  1. Download the vsdoc
  2. Add the Titanium.vsdoc.js to your project
  3. In the [js] file you want to use Titanium add the following line to the first line of the file.
    ///<reference path=”~/path/to/Titanium.vsdoc.js”/>
  4. Use it!


Any feedback is welcome.

Appcelerator Titanium vsdoc for Visual Studio

Updated: See part 2

I’ve been playing around with Appcelerator’s Titanium framework lately. It’s really an awesome framework for creating native mobile apps using JS (I freaking love JS :)). However, I miss Visual Studio. TextMate is great. subtleGradient (Thomas Aylott) even created some TextMate+Titanium+intellisense lovin’. But I use Visual Studio every day. We have a [love, hate] history.

The only thing that held me back from using Visual Studio was the lack of intellisense for the Titanium API. Naturally, I procrastinated. Hoping someone would do work for me. It didn’t happen. So I broke down and actually did some *gasp* work.

With Visual Studio getting your JavaScript intellisense with comments is as easy as creating a vsdoc. So…that’s exactly what I generated. I’ll spare you the gory details.The vsdoc I generated is really just a simple doc generated from the API JSON doc.

It’s missing a few object properties that had invalid syntax. The comments could be expanded on as well. Right now if the function takes in an object there’s no info on what params the object should have. Another niggly detail is that Visual Studio will not show the comments on an object property. It works for what I’m doing with it right now. Which means I can actually start developing a mobile app now!

How to use the vsdoc

  1. Download the vsdoc
  2. Add the Titanium-vsdoc.js to your project
  3. In the [js] file you want to use Titanium add the following line to the first line of the file.
    ///<reference path=”~/path/to/Titanium-vsdoc.js”/>
  4. Use it!

Next Page »