version 1.97, 2005/12/01 18:46:31
|
version 1.103, 2006/07/27 20:47:02
|
Line 32 use strict;
|
Line 32 use strict;
|
use Apache::lonnet; |
use Apache::lonnet; |
use HTML::Entities(); |
use HTML::Entities(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
use lib '/home/httpd/lib/perl/'; |
|
use LONCAPA; |
|
|
|
|
# Global Vars |
# Global Vars |
# default list of colors to use in editing |
# default list of colors to use in editing |
Line 498 sub insert_script {
|
Line 501 sub insert_script {
|
return "\n<script type=\"loncapa/perl\"></script>"; |
return "\n<script type=\"loncapa/perl\"></script>"; |
} |
} |
|
|
|
sub js_change_detection { |
|
my $unsaved=&mt("There are unsaved changes"); |
|
return (<<SCRIPT); |
|
<script type="text/javascript"> |
|
var clean = true; |
|
var is_submit = false; |
|
var still_ask = false; |
|
function compareForm(event_) { |
|
if (!event_ && window.event) { |
|
event_ = window.event; |
|
} |
|
if ((!is_submit || (is_submit && still_ask)) && !clean) { |
|
still_ask = false; |
|
is_submit = false; |
|
event_.returnValue = "$unsaved"; |
|
return "$unsaved"; |
|
} |
|
} |
|
function unClean() { |
|
clean=false; |
|
} |
|
window.onbeforeunload = compareForm; |
|
</script> |
|
SCRIPT |
|
} |
|
|
|
sub form_change_detection { |
|
return ' onsubmit="is_submit=true;" '; |
|
} |
|
|
|
sub element_change_detection { |
|
return ' onchange="unClean();" '; |
|
} |
|
|
|
sub submit_ask_anyway { |
|
return ' onclick="still_ask=true;" '; |
|
} |
|
|
sub textarea_sizes { |
sub textarea_sizes { |
my ($data)=@_; |
my ($data)=@_; |
my $count=0; |
my $count=0; |
Line 516 sub editline {
|
Line 557 sub editline {
|
my ($tag,$data,$description,$size)=@_; |
my ($tag,$data,$description,$size)=@_; |
$data=&HTML::Entities::encode($data,'<>&"'); |
$data=&HTML::Entities::encode($data,'<>&"'); |
if ($description) { $description="<br />".$description."<br />"; } |
if ($description) { $description="<br />".$description."<br />"; } |
|
my $change_code = &element_change_detection(); |
my $result = <<"END"; |
my $result = <<"END"; |
$description |
$description |
<input type="text" name="homework_edit_$Apache::lonxml::curdepth" |
<input type="text" name="homework_edit_$Apache::lonxml::curdepth" |
value="$data" size="$size" /> |
value="$data" size="$size" $change_code /> |
END |
END |
return $result; |
return $result; |
} |
} |
Line 538 sub editfield {
|
Line 580 sub editfield {
|
if ($rows < $minheight) { $rows = $minheight; } |
if ($rows < $minheight) { $rows = $minheight; } |
if ($description) { $description="<br />".$description."<br />"; } |
if ($description) { $description="<br />".$description."<br />"; } |
if ($usehtmlarea) { |
if ($usehtmlarea) { |
push @Apache::lonxml::htmlareafields,'homework_edit_'. |
&Apache::lonhtmlcommon::add_htmlareafields('homework_edit_'. |
$Apache::lonxml::curdepth; |
$Apache::lonxml::curdepth); |
} |
} |
return $description."\n".' <textarea style="width:100%" rows="'.$rows. |
return $description."\n".'<textarea style="width:100%" rows="'.$rows. |
'" cols="'.$cols.'" name="homework_edit_'. |
'" cols="'.$cols.'" name="homework_edit_'. |
$Apache::lonxml::curdepth.'" id="homework_edit_'. |
$Apache::lonxml::curdepth.'" id="homework_edit_'. |
$Apache::lonxml::curdepth.'">'. |
$Apache::lonxml::curdepth.'" '.&element_change_detection().'>'. |
&HTML::Entities::encode($data,'<>&"').'</textarea>'. |
&HTML::Entities::encode($data,'<>&"').'</textarea>'. |
($usehtmlarea?&Apache::lonhtmlcommon::spelllink('lonhomework', |
($usehtmlarea?&Apache::lonhtmlcommon::spelllink('lonhomework', |
'homework_edit_'.$Apache::lonxml::curdepth):'')."\n"; |
'homework_edit_'.$Apache::lonxml::curdepth):'')."\n"; |
Line 644 sub checked_arg {
|
Line 686 sub checked_arg {
|
$text=$option; |
$text=$option; |
$value='value="'.$option.'"'; |
$value='value="'.$option.'"'; |
} |
} |
$result.="<nobr><input type='checkbox' $value name='". |
$result.="<nobr><label><input type='checkbox' $value name='". |
&html_element_name($name)."'"; |
&html_element_name($name)."'"; |
foreach my $selected (split(/,/,$allselected)) { |
foreach my $selected (split(/,/,$allselected)) { |
if ( $selected eq $option ) { |
if ( $selected eq $option ) { |
Line 652 sub checked_arg {
|
Line 694 sub checked_arg {
|
last; |
last; |
} |
} |
} |
} |
$result.=" />$text</nobr>\n"; |
$result.=&element_change_detection()." />$text</label></nobr>\n"; |
} |
} |
return $result; |
return $result; |
} |
} |
Line 663 sub text_arg {
|
Line 705 sub text_arg {
|
if (!defined $size) { $size=20; } |
if (!defined $size) { $size=20; } |
my $arg=$token->[2]{$name}; |
my $arg=$token->[2]{$name}; |
$result=&mt($description).' <input name="'.&html_element_name($name). |
$result=&mt($description).' <input name="'.&html_element_name($name). |
'" type="text" value="'.$arg.'" size="'.$size.'" />'; |
'" type="text" value="'.$arg.'" size="'.$size.'" '. |
|
&element_change_detection().'/>'; |
return '<nobr>'.$result.'</nobr>'; |
return '<nobr>'.$result.'</nobr>'; |
} |
} |
|
|
Line 689 sub select_arg {
|
Line 732 sub select_arg {
|
} |
} |
} |
} |
$result.='<nobr>'.$description.' <select name="'. |
$result.='<nobr>'.$description.' <select name="'. |
&html_element_name($name).'"> |
&html_element_name($name).'" '.&element_change_detection().' > |
'.$optionlist.' |
'.$optionlist.' |
</select></nobr>'; |
</select></nobr>'; |
return $result; |
return $result; |
Line 722 sub select_or_text_arg {
|
Line 765 sub select_or_text_arg {
|
((!$found)?' selected="selected"':''). |
((!$found)?' selected="selected"':''). |
">".&mt('Type-in value')."</option>\n"; |
">".&mt('Type-in value')."</option>\n"; |
# |
# |
|
my $change_code=&element_change_detection(); |
my $element=&html_element_name($name); |
my $element=&html_element_name($name); |
my $selectelement='select_list_'.$element; |
my $selectelement='select_list_'.$element; |
my $typeinelement='type_in_'.$element; |
my $typeinelement='type_in_'.$element; |
Line 746 $optionlist
|
Line 790 $optionlist
|
value="$typeinvalue" |
value="$typeinvalue" |
onChange="$hiddenvalue=$typedinvalue;" |
onChange="$hiddenvalue=$typedinvalue;" |
onFocus="$selectedindex=$selecttypeinindex-1;" /> |
onFocus="$selectedindex=$selecttypeinindex-1;" /> |
<input type="hidden" name="$element" value="$selected" /> |
<input type="hidden" name="$element" value="$selected" $change_code /> |
</nobr> |
</nobr> |
ENDSELECTORTYPE |
ENDSELECTORTYPE |
} |
} |
Line 758 sub entercoords {
|
Line 802 sub entercoords {
|
unless ($Apache::edit::bgimgsrc) { return ''; } |
unless ($Apache::edit::bgimgsrc) { return ''; } |
if ($idx) { $idx.='_'; } |
if ($idx) { $idx.='_'; } |
if ($idy) { $idy.='_'; } |
if ($idy) { $idy.='_'; } |
my $bgfile=&Apache::lonnet::escape(&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$Apache::edit::bgimgsrc)); |
my $bgfile=&escape(&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$Apache::edit::bgimgsrc)); |
my $form = 'lonhomework'; |
my $form = 'lonhomework'; |
my $element; |
my $element; |
if (! defined($mode) || $mode eq 'attribute') { |
if (! defined($mode) || $mode eq 'attribute') { |
$element = &Apache::lonnet::escape("$Apache::lonxml::curdepth"); |
$element = &escape("$Apache::lonxml::curdepth"); |
} elsif ($mode eq 'textnode') { # for data between <tag> ... </tag> |
} elsif ($mode eq 'textnode') { # for data between <tag> ... </tag> |
$element = &Apache::lonnet::escape('homework_edit_'. |
$element = &escape('homework_edit_'. |
$Apache::lonxml::curdepth); |
$Apache::lonxml::curdepth); |
} |
} |
my $id=$Apache::lonxml::curdepth; |
my $id=$Apache::lonxml::curdepth; |
Line 793 sub entercoords {
|
Line 837 sub entercoords {
|
sub entercoord { |
sub entercoord { |
my ($idx,$mode,$width,$height,$type) = @_; |
my ($idx,$mode,$width,$height,$type) = @_; |
unless ($Apache::edit::bgimgsrc) { return ''; } |
unless ($Apache::edit::bgimgsrc) { return ''; } |
my $bgfile=&Apache::lonnet::escape(&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$Apache::edit::bgimgsrc)); |
my $bgfile=&escape(&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$Apache::edit::bgimgsrc)); |
my $form = 'lonhomework'; |
my $form = 'lonhomework'; |
my $element; |
my $element; |
if (! defined($mode) || $mode eq 'attribute') { |
if (! defined($mode) || $mode eq 'attribute') { |
$element = &Apache::lonnet::escape("$idx\_$Apache::lonxml::curdepth"); |
$element = &escape("$idx\_$Apache::lonxml::curdepth"); |
} elsif ($mode eq 'textnode') { # for data between <tag> ... </tag> |
} elsif ($mode eq 'textnode') { # for data between <tag> ... </tag> |
$element = &Apache::lonnet::escape('homework_edit_'. |
$element = &escape('homework_edit_'. |
$Apache::lonxml::curdepth); |
$Apache::lonxml::curdepth); |
} |
} |
my $id=$Apache::lonxml::curdepth; |
my $id=$Apache::lonxml::curdepth; |
Line 833 sub browse {
|
Line 877 sub browse {
|
my $form = 'lonhomework'; |
my $form = 'lonhomework'; |
my $element; |
my $element; |
if (! defined($mode) || $mode eq 'attribute') { |
if (! defined($mode) || $mode eq 'attribute') { |
$element = &Apache::lonnet::escape("$id\_$Apache::lonxml::curdepth"); |
$element = &escape("$id\_$Apache::lonxml::curdepth"); |
} elsif ($mode eq 'textnode') { # for data between <tag> ... </tag> |
} elsif ($mode eq 'textnode') { # for data between <tag> ... </tag> |
$element = &Apache::lonnet::escape('homework_edit_'. |
$element = &escape('homework_edit_'. |
$Apache::lonxml::curdepth); |
$Apache::lonxml::curdepth); |
} |
} |
my $titleelement; |
my $titleelement; |
if ($titleid) { |
if ($titleid) { |
$titleelement=",'','','".&Apache::lonnet::escape("$titleid\_$Apache::lonxml::curdepth")."'"; |
$titleelement=",'','','".&escape("$titleid\_$Apache::lonxml::curdepth")."'"; |
} |
} |
my $result = <<"ENDBUTTON"; |
my $result = <<"ENDBUTTON"; |
<a href=\"javascript:openbrowser('$form','$element'$titleelement)\"\>Select</a> |
<a href=\"javascript:openbrowser('$form','$element'$titleelement)\"\>Select</a> |
Line 855 sub search {
|
Line 899 sub search {
|
my $form = 'lonhomework'; |
my $form = 'lonhomework'; |
my $element; |
my $element; |
if (! defined($mode) || $mode eq 'attribute') { |
if (! defined($mode) || $mode eq 'attribute') { |
$element = &Apache::lonnet::escape("$id\_$Apache::lonxml::curdepth"); |
$element = &escape("$id\_$Apache::lonxml::curdepth"); |
} elsif ($mode eq 'textnode') { # for data between <tag> ... </tag> |
} elsif ($mode eq 'textnode') { # for data between <tag> ... </tag> |
$element = &Apache::lonnet::escape('homework_edit_'. |
$element = &escape('homework_edit_'. |
$Apache::lonxml::curdepth); |
$Apache::lonxml::curdepth); |
} |
} |
my $titleelement; |
my $titleelement; |
if ($titleid) { |
if ($titleid) { |
$titleelement=",'".&Apache::lonnet::escape("$titleid\_$Apache::lonxml::curdepth")."'"; |
$titleelement=",'".&escape("$titleid\_$Apache::lonxml::curdepth")."'"; |
} |
} |
my $result = <<"ENDBUTTON"; |
my $result = <<"ENDBUTTON"; |
<a href=\"javascript:opensearcher('$form','$element'$titleelement)\"\>Search</a> |
<a href=\"javascript:opensearcher('$form','$element'$titleelement)\"\>Search</a> |