+
+ };
+
+ this.checkbox = function (plugin_uuid, header, field, selected_str, disabled_str)
+ {
+ var result="";
+ // Prefix id with plugin_uuid
+ result += "<input";
+ result += " class='hazelnut-checkbox-" + plugin_uuid + "'";
+ result += " id='hazelnut-checkbox-" + plugin_uuid + "-" + unfold.get_value(header) + "'";
+ result += " name='" + unfold.get_value(field) + "'";
+ result += " type='checkbox'";
+ result += selected_str;
+ result += disabled_str;
+ result += " autocomplete='off'";
+ result += " value='" + unfold.get_value(header) + "'";
+ result += "></input>";
+ return result;
+ };
+
+ ////////////////////////////////////////////////////////////////////////
+ // New plugin API (in tests)
+
+ // TODO : signal empty/non empty table
+
+ this.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 = object.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 (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 (record[colnames[j]])
+ line.push(record[colnames[j]]);
+ else
+ line.push('');
+ }
+ }
+
+ /* catch up with the last column if checkboxes were requested */
+ if (options.checkboxes) {
+ var checked = '';
+ // xxx problem is, we don't get this 'sliver' thing set apparently
+ if (typeof(record['sliver']) != 'undefined') { /* It is equal to null when <sliver/> is present */
+ checked = 'checked ';
+ hazelnut.current_resources.push(record['urn']);
+ }
+ // Use a key instead of hostname (hard coded...)
+ line.push(object.checkbox(options.plugin_uuid, record['urn'], record['type'], checked, false));
+ }