- /**
- * @brief Determine index of key in the table columns
- * @param key
- * @param cols
- */
- getColIndex: function(key, cols) {
- var tabIndex = $.map(cols, function(x, i) { if (x.sTitle == key) return i; });
- return (tabIndex.length > 0) ? tabIndex[0] : -1;
- }, // getColIndex
-
- checkbox_html : function (key, value)
- {
-// if (debug) messages.debug("checkbox_html, value="+value);
- var result="";
- // Prefix id with plugin_uuid
- result += "<input";
- result += " class='querytable-checkbox'";
- result += " id='" + this.flat_id(this.id('checkbox', value)) + "'";
- result += " name='" + key + "'";
- result += " type='checkbox'";
- result += " autocomplete='off'";
- if (value === undefined) {
- messages.warning("querytable.checkbox_html - undefined value");
- } else {
- result += " value='" + value + "'";
- }
- result += "></input>";
- return result;
- },
-
-
- new_record: function(record)
- {
- // this models a line in dataTables, each element in the line describes a cell
- line = new Array();
-
- // go through table headers to get column names we want
- // in order (we have temporarily hack some adjustments in names)
- var cols = this.table.fnSettings().aoColumns;
- var colnames = cols.map(function(x) {return x.sTitle})
- var nb_col = cols.length;
- /* if we've requested checkboxes, then forget about the checkbox column for now */
- if (this.options.checkboxes) nb_col -= 1;
-
- /* fill in stuff depending on the column name */
- for (var j = 0; j < nb_col; j++) {
- if (typeof colnames[j] == 'undefined') {
- line.push('...');
- } else if (colnames[j] == 'hostname') {
- if (record['type'] == 'resource,link')
- //TODO: we need to add source/destination for links
- line.push('');
- else
- line.push(record['hostname']);
-
- } else if (colnames[j] == 'hrn' && typeof(record) != 'undefined') {
- line.push('<a href="../resource/'+record['urn']+'"><span class="glyphicon glyphicon-search"></span></a> '+record['hrn']);
- } else {
- if (record[colnames[j]])
- line.push(record[colnames[j]]);
- else
- line.push('');
- }
- }
-
- // catch up with the last column if checkboxes were requested
- if (this.options.checkboxes) {
- // Use a key instead of hostname (hard coded...)
- line.push(this.checkbox_html(this.key, record[this.key]));
- }
-
- // adding an array in one call is *much* more efficient
- // this.table.fnAddData(line);
- this.buffered_lines.push(line);