--- loncom/interface/lonhtmlcommon.pm 2015/03/31 13:46:01 1.359 +++ loncom/interface/lonhtmlcommon.pm 2015/04/24 21:31:56 1.361 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.359 2015/03/31 13:46:01 damieng Exp $ +# $Id: lonhtmlcommon.pm,v 1.361 2015/04/24 21:31:56 musolffc Exp $ # # Copyright Michigan State University Board of Trustees # @@ -451,10 +451,12 @@ sub radio { &date_setter returns html and javascript for a compact date-setting form. To retrieve values from it, use &get_date_from_form. -Inputs - =over 4 +=item Inputs + +=over + =item $dname The name to prepend to the form elements. @@ -486,10 +488,12 @@ Defaults to empty, which indiciates the =back -Bugs +=item Bugs The method used to restrict user input will fail in the year 2400. +=back + =cut ############################################## @@ -703,7 +707,9 @@ sub build_url { get_date_from_form retrieves the date specified in an &date_setter form. -Inputs: +=over + +=item Inputs: =over 4 @@ -717,6 +723,8 @@ The unix time to use as the default in c =back +=back + Returns: Unix time represented in the form. =cut @@ -888,7 +896,9 @@ sub javascript_docopen { Returns html for a selection box which allows the user to choose the enrollment status of students. The selection box name is 'Status'. -Inputs: +=over + +=item Inputs: $status: the currently selected status. If undefined the value of $env{'form.Status'} is taken. If that is undefined, a value of 'Active' @@ -902,6 +912,8 @@ $size: the size (number of lines) of the $onchange: javascript to use when the value is changed. Enclosed in double quotes, ""s, not single quotes. +=back + Returns: a perl string as described. =cut @@ -949,7 +961,7 @@ sub StatusOptions { =pod -=item Progess Window Handling Routines +=item Progress Window Handling Routines These routines handle the creation, update, increment, and closure of progress windows. The progress window reports to the user the number @@ -963,9 +975,11 @@ of items completed and an estimate of th Writes javascript to the client to open a progress window and returns a data structure used for bookkeeping. -Inputs +=over -=over 4 +=item Inputs + +=over =item $r Apache request @@ -973,15 +987,18 @@ Inputs =back -Returns a hash containing the progress state data structure. +=back +Returns a hash containing the progress state data structure. =item &Update_PrgWin() Updates the text in the progress indicator. Does not increment the count. See &Increment_PrgWin. -Inputs: +=over + +=item Inputs: =over 4 @@ -993,25 +1010,38 @@ Inputs: =back +=back + Returns: none -=item Increment_PrgWin() +=item &Increment_PrgWin() Increment the count of items completed for the progress window by $step or 1 if no step is provided. -Inputs: +=over + +=item Inputs: =over 4 -=item $r Apache request +=item $r -=item $prog_state Pointer to the data structure returned by Create_PrgWin +Apache request + +=item $prog_state + +Pointer to the data structure returned by Create_PrgWin -=item $extraInfo A description of the items being iterated over. Typically -'student'. +=item $extraInfo -=item $step (optional) counter step. Will be set to default 1 if ommited. step must be greater than 0 or empty. +A description of the items being iterated over. Typically 'student'. + +=item $step + +(optional) counter step. Will be set to default 1 if ommited. step must be greater than 0 or empty. + +=back =back @@ -1022,7 +1052,9 @@ Returns: none Closes the progress window. -Inputs: +=over + +=item Inputs: =over 4 @@ -1032,6 +1064,8 @@ Inputs: =back +=back + Returns: none =back @@ -1308,6 +1342,7 @@ sub htmlareaselectactive { function startRichEditor(id) { // fix character entities inside // NOTE: this is not fixing characters inside + // NOTE: < and > inside should fix automatically because there should not be a letter after <. var ta = document.getElementById(id); var value = ta.value; var in_m = false; // in the m element @@ -1351,36 +1386,41 @@ sub htmlareaselectactive { function destroyRichEditor(id) { CKEDITOR.instances[id].destroy(); - // replace character entities < and > in + // replace character entities < and > in and // and "&fctname(" by "&fctname(" // and the quotes inside functions: "&fct(1, "a")" -> "&fct(1, "a")" var ta = document.getElementById(id); var value = ta.value; - var in_m = false; // in the m element - var in_text = false; // in the text inside the m element - var im = -1; // position of + var in_element = false; // in the m or chem element + var tagname = ""; // m or chem + var in_text = false; // in the text inside the element + var im = -1; // position of start tag var it = -1; // position of the text inside for (var i=0; i if found twice - in_m = true; + if (value.substr(i, 2) == "") { in_text = true; it = i+1; } - } else if (value.substr(i, 4) == "") { - in_m = false; + } else if (value.substr(i, 3+tagname.length) == "") { + in_element = false; var text = value.substr(it, i-it); var l1 = text.length; text = text.replace(/</g, "<"); text = text.replace(/>/g, ">"); var l2 = text.length; - value = value.substr(0, it) + text + "" + value.substr(i+4); + value = value.substr(0, it) + text + value.substr(i); i = i + (l2-l1); } } @@ -1714,13 +1754,38 @@ A link to help for the component will be All inputs can be undef without problems. -Inputs: $component (the text on the right side of the breadcrumbs trail), - $component_help - $menulink (boolean, controls whether to include a link to /adm/menu) - $helplink (if 'nohelp' don't include the orange help link) - $css_class (optional name for the class to apply to the table for CSS) - $no_mt (optional flag, 1 if &mt() is _not_ to be applied to $component - when including the text on the right. +=over + +=item Inputs: + +=over + +=item $component + +the text on the right side of the breadcrumbs trail + +=item $component_help + +=item $menulink + +boolean, controls whether to include a link to /adm/menu + +=item $helplink + +if 'nohelp' don't include the orange help link + +=item $css_class + +optional name for the class to apply to the table for CSS + +=item $no_mt + +optional flag, 1 if &mt() is _not_ to be applied to $component when including the text on the right + +=back + +=back + Returns a string containing breadcrumbs for the current page. =item &clear_breadcrumbs() @@ -1922,7 +1987,9 @@ Adds $html to $category of the breadcrum $html is usually a link to a page that invokes a function on the currently displayed data (e.g. print when viewing a problem) -Currently there are 3 possible values for $category: +=over + +=item Currently there are 3 possible values for $category: =over @@ -1936,7 +2003,9 @@ remaining items in right of breadcrumbs advanced tools shown in a separate box below breadcrumbs line =back - + +=back + returns: nothing =cut @@ -1975,8 +2044,17 @@ returns: nothing Creates html for breadcrumb tools (categories navigation and tools) and inserts \$breadcrumbs at the correct position. -input: \$breadcrumbs - a reference to the string containing prepared -breadcrumbs. +=over + +=item input: + +=over + +=item \$breadcrumbs - a reference to the string containing prepared breadcrumbs. + +=back + +=back returns: nothing @@ -2002,8 +2080,17 @@ returns: nothing Creates html for advanced tools (category advtools) and inserts \$breadcrumbs at the correct position. -input: \$breadcrumbs - a reference to the string containing prepared -breadcrumbs (after render_tools call). +=over + +=item input: + +=over + +=item \$breadcrumbs - a reference to the string containing prepared breadcrumbs (after render_tools call). + +=back + +=back returns: nothing @@ -3501,7 +3588,9 @@ sub scripttag { Constructs a XHTML list from \@array. -input: +=over + +=item input: =over @@ -3515,6 +3604,8 @@ Attributes for
    and
  • passed in a See htmltag() for more details. =back + +=back returns: XHTML list as String. @@ -3634,13 +3725,19 @@ should be included in this list. If the optional headline text is not provided, a default text will be used. +=over + +=item Related routines: -Related routines: =over 4 -add_item_funclist -end_funclist + +=item add_item_funclist + +=item end_funclist + =back +=back Inputs: (optional) headline text @@ -3667,10 +3764,18 @@ sub start_funclist { Adds an item to the list of available functions -Related routines: +=over + +=item Related routines: + =over 4 -start_funclist -end_funclist + +=item start_funclist + +=item end_funclist + +=back + =back Inputs: content item with text and link to function @@ -3693,10 +3798,15 @@ sub add_item_funclist { End list of available functions -Related routines: -=over 4 -start_funclist -add_item_funclist +=over + +=item Related routines: + + start_funclist + add_item_funclist + +=back + =back Inputs: ./. @@ -3708,7 +3818,7 @@ sub end_funclist { return "
\n"; } -=pod +=over =item &funclist_from_array( \@array, {legend => 'text for legend'} ) @@ -3743,7 +3853,7 @@ sub funclist_from_array { { listattr => {class => 'LC_funclist'} }); } -=pod +=over =item &actionbox( \@array )