Skip to content

Instantly share code, notes, and snippets.

@alexyoung
Created March 11, 2009 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexyoung/77400 to your computer and use it in GitHub Desktop.
Save alexyoung/77400 to your computer and use it in GitHub Desktop.
var listDataSource = {
_rowData: [],
// The List calls this method to find out how many rows should be in the list.
numberOfRows: function() {
return this._rowData.length;
},
// The List calls this method once for every row
prepareRow: function(rowElement, rowIndex, templateElements) {
if (templateElements.label) {
templateElements.label.innerText = this._rowData[rowIndex];
}
// Assign a click event handler for the row
rowElement.onclick = function(event) {
};
}
};
function showTubeUpdates() {
var apiURL = "http://api.tubeupdates.com/?method=get.status&lines=all&format=json";
new Ajax.Request(apiURL, { method: 'get', onComplete: function(response) {
var json = response.responseText.evalJSON();
json['response']['lines'].each(function(line) {
var name = line['name'].substring(0, 8);
name = line['name'].length > 8 ? name + '...' : name
listDataSource['_rowData'].push(name + ': ' + line['status']);
});
$('list').object.reloadData()
} });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment