--- loncom/homework/edit.pm 2001/05/31 22:37:56 1.8
+++ loncom/homework/edit.pm 2001/08/13 21:43:48 1.21
@@ -6,15 +6,24 @@ package Apache::edit;
use strict;
use Apache::lonnet;
+# Global Vars
+# default list of colors to use in editing
+@Apache::edit::colorlist=('#ffffff','#ff0000','#00ff00','#0000ff','#0ff000','#000ff0','#f0000f');
+# depth of nesting of edit
+$Apache::edit::colordepth=0;
+
+sub initialize_edit {
+ $Apache::edit::colordepth=0;
+}
+
sub tag_start {
- my ($target,$token) = @_;
+ my ($target,$token,$description) = @_;
my $result='';
if ($target eq "edit") {
my $tag=$token->[1];
-# my $color = sprintf("#%06lx",(hex("ffffff")) >> scalar(split(/_/,$Apache::lonxml::curdepth)));
- my $color = sprintf("#%02lxffff",33* scalar(split(/_/,$Apache::lonxml::curdepth)));
- $result.="
<$tag>
-
Delete:".
+ if (!$description) { $description="<$tag>"; }
+ $result.= &start_table($token)."
$description
+
Delete".
&deletelist($target,$token)
."
".
@@ -26,37 +35,87 @@ sub tag_start {
}
sub tag_end {
- my ($target,$token) = @_;
+ my ($target,$token,$description) = @_;
my $result='';
if ($target eq 'edit') {
my $tag=$token->[1];
- $result.="
</$tag>
\n";
+ if (!defined($description)) {
+ $result.="
</$tag>
";
+ } else {
+ if ($description ne '') { $result.="
$description
"; }
+ }
+ $result.="
".&end_table()."\n";
+ }
+ return $result;
+}
+
+sub start_table {
+ my ($token)=@_;
+ my $tag = $token->[1];
+ my $tagnum;
+ foreach my $namespace (reverse @Apache::lonxml::namespace) {
+ my $testtag=$Apache::lonxml::namespace['-1'].'::'.$tag;
+ $tagnum=$Apache::lonxml::insertlist{"$testtag.num"};
+ if (defined($tagnum)) { last; }
+ }
+ if (!defined ($tagnum)) { $tagnum=$Apache::lonxml::insertlist{"$tag.num"}; }
+ my $color = $Apache::lonxml::insertlist{"$tagnum.color"};
+ if (!defined($color)) {
+ $color = $Apache::edit::colorlist[$Apache::edit::colordepth];
}
+ $Apache::edit::colordepth++;
+ my $result="