im_slider

one of the documented procedures in this installation of the ACS
Usage:
im_slider   field_name   pairs   { default "" }   { var_list_not_to_export "" }
What it does:
Takes in the name of the field in the current menu bar and a list where the ith item is the name of the form element and the i+1st element is the actual text to display. Returns an html string of the properly formatted slider bar
Defined in: /web/philip/tcl/intranet-defs.tcl

Source code:


    if { [llength $pairs] == 0 } {
	# Get out early as there's nothing to do
	return ""
    }
    if { [empty_string_p $default] } {
	set default [ad_partner_upvar $field_name 1]
    }
    set exclude_var_list [list $field_name]
    foreach var $var_list_not_to_export {
	lappend exclude_var_list $var
    }
    set url "[ns_conn url]?"
    set query_args [export_ns_set_vars url $exclude_var_list]
    if { ![empty_string_p $query_args] } {
	append url "$query_args&"
    }
    set menu_items_text [list]
    # Count up the number of characters we display to help us select either
    # text links or a select box
    set text_length 0
    foreach { value text } $pairs {
	set text_length [expr $text_length + [string length $text]]
	if { [string compare $value $default] == 0 } {
	    lappend menu_items_text "<b>$text</b>\n"
	    lappend menu_items_select "<option value=\"[ad_urlencode $value]\" selected>$text\n"
	} else {
	    lappend menu_items_text "<a href=\"$url$field_name=[ad_urlencode $value]\">$text</a>\n"
	    lappend menu_items_select "<option value=\"[ad_urlencode $value]\">$text\n"
	}
    }
    if { $text_length > [ad_parameter LengthBeforeSelectBar intranet 50] } {
	# We have enough text - switch to a select bar
	return "
<form method=get action=\"[ns_conn url]\">
[export_ns_set_vars form $exclude_var_list]
<select name=\"[philg_quote_double_quotes $field_name]\">
[join $menu_items_select ""]
</select>
<input type=submit value=\"Go\">
</form>
"
    } else {
	# Return simple text links
	return [join $menu_items_text " | "]
    }


philg@mit.edu