Created
March 11, 2009 10:15
-
-
Save alexyoung/77400 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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