Skip to content

Instantly share code, notes, and snippets.

@thinktainer
Created June 18, 2013 15:52
Show Gist options
  • Save thinktainer/5806527 to your computer and use it in GitHub Desktop.
Save thinktainer/5806527 to your computer and use it in GitHub Desktop.
var Page = window.Page || {};
Page.DataParser = function (tableId, rowFormat) {
self.tableId = tableId;
self.rowFormat = rowFormat;
};
// rowformat = [""]
Page.DataParser.prototype = (function () {
var parseTableRow = function (row) {
var thRowFormat = ["Date", "Successful", "TimeOut", "Failed"];
var result = {};
for (var i = 0; i < thRowFormat.length; i++) {
result[thRowFormat[i]] = row.find('td').eq(i).text();
}
return result;
};
var parseTableRows = function () {
var result = [];
$(tableId).find('tr').next().each(function (index, element) {
result.push(parseTableRow($(element)));
});
return result;
};
// public
return {
parseTableRows: parseTableRows
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment