});
*/
-function get_value(value) {
- //if(typeof(jQuery(value).attr('value'))!="undefined"){
- if (/<span value=['"].*['"]>.*<\/span>/i.test(value)) {
- return jQuery(value).attr('value');
- } else {
- return value;
- }
-}
-
/*
From: http://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-clone-a-javascript-object
I want to note that the .clone() method in jQuery only clones DOM elements. In order to clone JavaScript objects, you would do:
return jQuery.extend(true, {}, obj);
}
-/* https://gist.github.com/661855 */
-(function(jQuery) {
-
- var o = jQuery({});
-
- jQuery.subscribe = function( types, selector, data, fn) {
- /* borrowed from jQuery */
- if ( data == null && fn == null ) {
- // ( types, fn )
- fn = selector;
- data = selector = undefined;
- } else if ( fn == null ) {
- if ( typeof selector === "string" ) {
- // ( types, selector, fn )
- fn = data;
- data = undefined;
- } else {
- // ( types, data, fn )
- fn = data;
- data = selector;
- selector = undefined;
- }
- }
- /* </ugly> */
-
- /* We use an indirection function that will clone the object passed in
- * parameter to the subscribe callback
- *
- * FIXME currently we only clone query objects which are the only ones
- * supported and editable, we might have the same issue with results but
- * the page load time will be severely affected...
- */
- o.on.apply(o, [types, selector, data, function() {
- for(i = 1; i < arguments.length; i++) {
- if ( arguments[i].constructor.name == 'Query' )
- arguments[i] = arguments[i].clone();
- }
- fn.apply(o, arguments);
- }]);
- };
-
- jQuery.unsubscribe = function() {
- o.off.apply(o, arguments);
- };
-
- jQuery.publish = function() {
- o.trigger.apply(o, arguments);
- };
-
-}(jQuery));
-
-
function executeFunctionByName(functionName, context /*, args */) {
var args = Array.prototype.slice.call(arguments).splice(2);
var namespaces = functionName.split(".");
// trigger a query asynchroneously
proxy_url : '/manifold/proxy/json/',
- asynchroneous_debug : true,
+ asynchroneous_debug : false,
// Executes all async. queries
// input queries are specified as a list of {'query_uuid': <query_uuid>, 'id': <possibly null>}
asynchroneous_exec : function (query_uuid_domids) {
// start spinners
- if (manifold.asynchroneous_exec) console.log("Turning spin on with " + jQuery(".need-spin").length + " matches for need-spin");
+ if (manifold.asynchroneous_debug) console.log("Turning on spin with " + jQuery(".need-spin").length + " matches for .need-spin");
jQuery('.need-spin').spin(spin_presets);
// We use js function closure to be able to pass the query (array) to the
(function($){
var debug=false;
- debug=true
+// debug=true
// routing calls
$.fn.Hazelnut = function( method ) {
// sScrollX: '100%', /* Horizontal scrolling */
bProcessing: true, /* Loading */
fnRowCallback: function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
- $(nRow).attr('id', get_value(aData[3]));
+ $(nRow).attr('id', unfold.get_value(aData[3]));
return nRow;
},
fnDrawCallback: function() { hazelnut_draw_callback.call(object, options); }
if (rows.length==0) {
if (debug) console.l ("empty result");
- this.table.html(errorDisplay("No Result"));
+ this.table.html(unfold.errorDisplay("No Result"));
return;
} else if (typeof(rows[0].error) != 'undefined') {
if (debug) console.log ("undefined result");
- this.table.html(errorDisplay(rows[0].error));
+ this.table.html(unfold.errorDisplay(rows[0].error));
return;
}
newlines = new Array();
this.checkbox = function (plugin_uuid, header, field, selected_str, disabled_str) {
var result="";
/* Prefix id with plugin_uuid */
- result += "<input class='hazelnut-checkbox-" + plugin_uuid + "' id='hazelnut-checkbox-" + plugin_uuid + "-" + get_value(header) + "'";
- result += " name='" + get_value(field) + "' type='checkbox' " + selected_str + disabled_str + " autocomplete='off' value='" + get_value(header) + "'";
+ result += "<input class='hazelnut-checkbox-" + plugin_uuid + "' id='hazelnut-checkbox-" + plugin_uuid + "-" + unfold.get_value(header) + "'";
+ result += " name='" + unfold.get_value(field) + "' type='checkbox' " + selected_str + disabled_str + " autocomplete='off' value='" + unfold.get_value(header) + "'";
result +="></input>";
return result;
};
if (typeof(col) == 'undefined')
return;
- col_value=get_value(aData[col]);
+ col_value=unfold.get_value(aData[col]);
/* Test whether current filter is compatible with the column */
if (op == '=' || op == '==') {
if ( col_value != value || col_value==null || col_value=="" || col_value=="n/a")
if(filterData.length<=100){
$.each(filterData, function(index, obj) {
var last=$(obj).last();
- var key_value=get_value(last[0]);
+ var key_value=unfold.get_value(last[0]);
if(typeof($(last[0]).attr('checked'))=="undefined"){
$.publish('selected', 'add/'+key_value);
}
# $subject_keys = Plugins::get_default_fields($query->subject, $is_unique);
# $fields = Plugins::metadata_get_fields($query->subject);
# for now I am hard-coding the ones from haze.py
- env['subject_fields']=[ 'hostname', 'hrn' ]
+ env['subject_fields']=[ 'network', 'type', 'hostname', 'hrn' ]
return env
def requirements (self):
reqs = {
'js_files' : [ "js/hazelnut.js",
- "js/manifold.js", "js/manifold-query.js", "js/manifold-core.js",
+ "js/manifold.js", "js/manifold-query.js",
"js/dataTables.js", "js/with-datatables.js",
"js/spin.presets.js", "js/spin.min.js", "js/jquery.spin.js",
"js/unfold-helper.js",
var availableTags={};
$.each (rows, function(index, obj) {
$.each(obj,function(key,value){
- value = get_value(value);
+ value = unfold.get_value(value);
if(!availableTags.hasOwnProperty(key)){availableTags[key]=new Array();}
//availableTags[key].push(value);
var currentArray=availableTags[key];
main_query = ManifoldQuery (action='get',
subject='resource',
timestamp='latest',
- fields=['hrn','hostname'],
+ fields=['network','type','hrn','hostname'],
filters= [ [ 'slice_hrn', '=', slicename, ] ],
- sort='slice_hrn',
+# sort='slice_hrn',
)
page.enqueue_query (main_query)
main_plugin = Stack (
page=page,
- title="global container",
+ title="Slice view for %s"%slicename,
domid='thestack',
# togglable=False,
sons=[Tabs (
return out;
},
+ get_value: function (value) {
+ //if(typeof(jQuery(value).attr('value'))!="undefined"){
+ if (/<span value=['"].*['"]>.*<\/span>/i.test(value)) {
+ return jQuery(value).attr('value');
+ } else {
+ return value;
+ }
+}
+
} // global unfold
// xxx tmp - until all plugins are ported
-errorDisplay = unfold.errorDisplay;
+errorDisplay = unfold.errorDisplay;
+get_value = unfold.get_value;