version 1.8, 2010/10/08 23:26:04
|
version 1.9, 2010/10/09 00:00:04
|
Line 125 sub update_script {
|
Line 125 sub update_script {
|
function updatePointCoordinates_$id(coordinateName) { |
function updatePointCoordinates_$id(coordinateName) { |
var x = document.ggbApplet_$id.getXcoord(coordinateName); |
var x = document.ggbApplet_$id.getXcoord(coordinateName); |
var y = document.ggbApplet_$id.getYcoord(coordinateName); |
var y = document.ggbApplet_$id.getYcoord(coordinateName); |
coordinateMap_$id\[coordinateName + ".x"] = x; |
document.lonhomework.elements["HWVAL_$id\_" + coordinateName + "_x"].value = x; |
coordinateMap_$id\[coordinateName + ".y"] = y; |
document.lonhomework.elements["HWVAL_$id\_" + coordinateName + "_y"].value = y; |
} |
} |
// ]]> |
// ]]> |
</script> |
</script> |
Line 148 sub update_register {
|
Line 148 sub update_register {
|
sub set_coordinate { |
sub set_coordinate { |
my ($id,$variable,$x,$y)=@_; |
my ($id,$variable,$x,$y)=@_; |
return (<<ENDSETVARIABLE); |
return (<<ENDSETVARIABLE); |
coordinateMap_$id\['$variable.x'] = $x; |
document.ggbApplet_$id.evalCommand("$variable=($x,$y)"); |
coordinateMap_$id\['$variable.y'] = $y; |
|
document.ggbApplet_$id.evalCommand("$variable=("+coordinateMap_$id\["$variable.x"]+","+coordinateMap_$id\["$variable.y"]+")"); |
|
ENDSETVARIABLE |
ENDSETVARIABLE |
} |
} |
|
|
# |
# |
|
# Input field name for a coordinate variable |
|
# |
|
|
|
sub field_name { |
|
my ($id,$variable,$name)=@_; |
|
return "HWVAL_$id\_$variable\_$name"; |
|
} |
|
|
|
# |
|
# Generate an input field for a coordinate variable |
|
# |
|
|
|
sub generate_input_field { |
|
my ($id,$variable,$x,$y)=@_; |
|
$Apache::functionplotresponse::inputfields.= |
|
"<input type='hidden' name='".&field_name($id,$variable,'x')."' value='$x' />\n". |
|
"<input type='hidden' name='".&field_name($id,$variable,'y')."' value='$y' />\n"; |
|
} |
|
|
|
# |
# Initialize a new coordinate variable at set a listener on it |
# Initialize a new coordinate variable at set a listener on it |
# |
# |
sub new_coordinate { |
sub new_coordinate { |
my ($id,$variable,$x,$y)=@_; |
my ($id,$variable,$x,$y)=@_; |
|
&generate_input_field($id,$variable,$x,$y); |
return &set_coordinate($id,$variable,$x,$y).&update_register($id,$variable); |
return &set_coordinate($id,$variable,$x,$y).&update_register($id,$variable); |
} |
} |
|
|
Line 313 sub start_functionplotresponse {
|
Line 332 sub start_functionplotresponse {
|
undef %Apache::functionplotresponse::splineinity; |
undef %Apache::functionplotresponse::splineinity; |
undef %Apache::functionplotresponse::splinescalex; |
undef %Apache::functionplotresponse::splinescalex; |
undef %Apache::functionplotresponse::splinescaley; |
undef %Apache::functionplotresponse::splinescaley; |
|
$Apache::functionplotresponse::inputfields=''; |
$Apache::functionplotresponse::counter=0; |
$Apache::functionplotresponse::counter=0; |
# Internal ID to mark the applet and its coordinates |
# Internal ID to mark the applet and its coordinates |
my $internalid = $Apache::inputtags::part.'_'.&Apache::response::start_response($parstack,$safeeval); |
my $internalid = $Apache::inputtags::part.'_'.&Apache::response::start_response($parstack,$safeeval); |
Line 356 sub end_functionplotresponse {
|
Line 376 sub end_functionplotresponse {
|
} |
} |
# close the init script |
# close the init script |
$result.=&end_init_script(); |
$result.=&end_init_script(); |
|
# generate the input fields |
|
$result.=$Apache::functionplotresponse::inputfields; |
# actually start the <applet>-tag |
# actually start the <applet>-tag |
$result.=&geogebra_startcode($internalid); |
$result.=&geogebra_startcode($internalid); |
# load the spline bytecode |
# load the spline bytecode |