ReportsKit.Table = (function(options) { var self = this; self.initialize = function(options) { self.options = options; self.report = options.report; self.el = self.report.el; self.loadingIndicatorEl = $('
').appendTo(self.report.visualizationEl).hide(); self.table = $('', { 'class': 'table table-striped table-hover' }).appendTo(self.report.visualizationEl); }; self.render = function() { var path = self.el.data('path'); var separator = path.indexOf('?') === -1 ? '?' : '&'; path += separator + 'properties=' + encodeURIComponent(JSON.stringify(self.report.properties())); self.loadingIndicatorEl.fadeIn(100); $.getJSON(path, function(response) { var data = response.data; var tableData = data.table_data; self.loadingIndicatorEl.stop(true, true).hide(); var html = ''; for(var i = 0; i < tableData.length; i++) { if (i == 0) { html += ''; } else if (i == 1) { html += ''; } else { html += ''; } for(var j = 0; j < tableData[i].length; j++) { if (i == 0 || j == 0) { html += ''; } else { html += ''; } } if (i == 0) { html += ''; } else if (i == tableData.length) { html += ''; } else { html += ''; } } self.table.html(html); self.table.tablesorter(); }); }; self.initialize(options); return self; });
' + (tableData[i][j] || '') + '' + tableData[i][j] + '