javascript/lib/amigo/ui/interactive.js
function _render_option(){

	var buf = new Array();

	// Sort the items in the mdata array.
	// Also keep a lookup for a "special" entry.
	// var default_on_p = false;
	var mdata_keys = bbop.core.get_keys(anchor.mdata);
	function _data_comp(a, b){

	    // Get the associated data.
	    var a_data = anchor.mdata[a];
	    var b_data = anchor.mdata[b];

	    // if( (a_data['special'] == true && a_data['selected'] == true) ||
	    // 	(b_data['special'] == true && b_data['selected'] == true) ){
	    // 	default_on_p = true;
	    // }

	    //
	    var retval = 0;
	    if( a_data['special'] != b_data['special'] ){
		if( a_data['count'] == true ){
		    retval = 1;
		}else{
		    retval = -1;
		}
	    }else if( a_data['count'] != b_data['count'] ){
		if( a_data['count'] > b_data['count'] ){
		    retval = -1;
		}else{
		    retval = 1;
		}
	    }else if( a_data['label'] != b_data['label'] ){
		if( a_data['label'] > b_data['label'] ){
		    retval = 1;
		}else{
		    retval = -1;
		}
	    }

	    return retval;
	}
	mdata_keys.sort(_data_comp); // inplace sort

	//
	for( var mski = 0; mski < mdata_keys.length; mski++ ){

	    var write_data = anchor.mdata[mdata_keys[mski]];
	    
	    // Write out option if:
	    // 1) the default is selected (so we want to see everything)
	    // 2) the selection is special
	    // 3) if the default is not selected, either the item is selected or
	    // 4) it has a count (and is thus interesting)
	    if( // default_on_p == true ||
	    	write_data['selected'] == true ||
	    	write_data['special'] == true ||
	    	( write_data['count'] && write_data['count'] > 0 ) ){
		    
		    buf.push('<option');
		    // Title.
		    buf.push(' title="');
		    buf.push(write_data['value']);
		    buf.push('"');		
		    // Value.
		    buf.push(' value="');
		    buf.push(write_data['value']);
		    buf.push('"');		
		    if( write_data['selected'] ){
			buf.push(' selected="selected"');
		    }
		    buf.push('>');
		    //buf.push(bbop.core.crop(write_data['label']));
		    buf.push(bbop.core.crop(write_data['label'], 40, '...'));
		    
		    if( write_data['count'] && write_data['count'] > 0 ){
			buf.push(' (' + write_data['count'] + ')');
		    }
		    
		    buf.push('</option>');
		}
		
	}
	return buf.join('');
    }
function _render_option(){

	var buf = new Array();

	// Sort the items in the mdata array.
	// Also keep a lookup for a "special" entry.
	// var default_on_p = false;
	var mdata_keys = bbop.core.get_keys(anchor.mdata);
	function _data_comp(a, b){

	    // Get the associated data.
	    var a_data = anchor.mdata[a];
	    var b_data = anchor.mdata[b];

	    // if( (a_data['special'] == true && a_data['selected'] == true) ||
	    // 	(b_data['special'] == true && b_data['selected'] == true) ){
	    // 	default_on_p = true;
	    // }

	    //
	    var retval = 0;
	    if( a_data['special'] != b_data['special'] ){
		if( a_data['count'] == true ){
		    retval = 1;
		}else{
		    retval = -1;
		}
	    }else if( a_data['count'] != b_data['count'] ){
		if( a_data['count'] > b_data['count'] ){
		    retval = -1;
		}else{
		    retval = 1;
		}
	    }else if( a_data['label'] != b_data['label'] ){
		if( a_data['label'] > b_data['label'] ){
		    retval = 1;
		}else{
		    retval = -1;
		}
	    }

	    return retval;
	}
	mdata_keys.sort(_data_comp); // inplace sort

	//
	for( var mski = 0; mski < mdata_keys.length; mski++ ){

	    var write_data = anchor.mdata[mdata_keys[mski]];
	    
	    // Write out option if:
	    // 1) the default is selected (so we want to see everything)
	    // 2) the selection is special
	    // 3) if the default is not selected, either the item is selected or
	    // 4) it has a count (and is thus interesting)
	    if( // default_on_p == true ||
	    	write_data['selected'] == true ||
	    	write_data['special'] == true ||
	    	( write_data['count'] && write_data['count'] > 0 ) ){
		    
		    buf.push('<option');
		    // Title.
		    buf.push(' title="');
		    buf.push(write_data['value']);
		    buf.push('"');		
		    // Value.
		    buf.push(' value="');
		    buf.push(write_data['value']);
		    buf.push('"');		
		    if( write_data['selected'] ){
			buf.push(' selected="selected"');
		    }
		    buf.push('>');
		    //buf.push(bbop.core.crop(write_data['label']));
		    buf.push(bbop.core.crop(write_data['label'], 40, '...'));
		    
		    if( write_data['count'] && write_data['count'] > 0 ){
			buf.push(' (' + write_data['count'] + ')');
		    }
		    
		    buf.push('</option>');
		}
		
	}
	return buf.join('');
    }
function _render_option ( ) { var buf = new Array ( ) ; // Sort the items in the mdata array. // Also keep a lookup for a "special" entry. // var default_on_p = false; var mdata_keys = bbop . core . get_keys ( anchor . mdata ) ; function _data_comp ( a , b ) { // Get the associated data. var a_data = anchor . mdata [ a ] ; var b_data = anchor . mdata [ b ] ; // if( (a_data['special'] == true && a_data['selected'] == true) || // 	(b_data['special'] == true && b_data['selected'] == true) ){ // 	default_on_p = true; // } // var retval = 0 ; if ( a_data [ 'special' ] != b_data [ 'special' ] ) { if ( a_data [ 'count' ] == true ) { retval = 1 ; } else { retval = - 1 ; } } else if ( a_data [ 'count' ] != b_data [ 'count' ] ) { if ( a_data [ 'count' ] > b_data [ 'count' ] ) { retval = - 1 ; } else { retval = 1 ; } } else if ( a_data [ 'label' ] != b_data [ 'label' ] ) { if ( a_data [ 'label' ] > b_data [ 'label' ] ) { retval = 1 ; } else { retval = - 1 ; } } return retval ; } mdata_keys . sort ( _data_comp ) ; // inplace sort // for ( var mski = 0 ; mski < mdata_keys . length ; mski ++ ) { var write_data = anchor . mdata [ mdata_keys [ mski ] ] ; // Write out option if: // 1) the default is selected (so we want to see everything) // 2) the selection is special // 3) if the default is not selected, either the item is selected or // 4) it has a count (and is thus interesting) if ( // default_on_p == true || write_data [ 'selected' ] == true || write_data [ 'special' ] == true || ( write_data [ 'count' ] && write_data [ 'count' ] > 0 ) ) { buf . push ( '<option' ) ; // Title. buf . push ( ' title="' ) ; buf . push ( write_data [ 'value' ] ) ; buf . push ( '"' ) ; // Value. buf . push ( ' value="' ) ; buf . push ( write_data [ 'value' ] ) ; buf . push ( '"' ) ; if ( write_data [ 'selected' ] ) { buf . push ( ' selected="selected"' ) ; } buf . push ( '>' ) ; //buf.push(bbop.core.crop(write_data['label'])); buf . push ( bbop . core . crop ( write_data [ 'label' ] , 40 , '...' ) ) ; if ( write_data [ 'count' ] && write_data [ 'count' ] > 0 ) { buf . push ( ' (' + write_data [ 'count' ] + ')' ) ; } buf . push ( '</option>' ) ; } } return buf . join ( '' ) ; }
Render the options to an HTML string.
Render the options to an HTML string .