version 1.230, 2009/08/10 16:27:39
|
version 1.231, 2009/08/11 13:01:10
|
Line 2109 sub inittags {
|
Line 2109 sub inittags {
|
} |
} |
|
|
|
|
# USAGE: scripttag(scriptcode, true/false); |
# USAGE: scripttag(scriptcode, [start|end|both]); |
# |
# |
# EXAMPLES: |
# EXAMPLES: |
# - scripttag("alert('Hello World!')") |
# - scripttag("alert('Hello World!')", 'both') |
|
# returns: |
|
# <script type="text/javascript"> |
|
# // BEGIN LON-CAPA Internal |
|
# alert(Hello World!') |
|
# // END LON-CAPA Internal |
|
# </script> |
# |
# |
# NOTES: |
# NOTES: |
# - works currently only for javascripts |
# - works currently only for javascripts |
# |
# |
# OUTPUT: Scriptcode properly enclosed in <script> and CDATA tags (and LC |
# OUTPUT: |
# Internal markers if 2nd argument evaluates to true) |
# Scriptcode properly enclosed in <script> and CDATA tags (and LC |
|
# Internal markers if 2nd argument is given) |
sub scripttag { |
sub scripttag { |
my ($content, $internal) = @_; |
my ( $content, $marker ) = @_; |
$content = "// BEGIN LON-CAPA Internal\n$content\n// END LON-CAPA Internal" if $internal; |
return unless defined $content; |
|
|
|
my $begin = "\n// BEGIN LON-CAPA Internal\n"; |
|
my $end = "\n// END LON-CAPA Internal\n"; |
|
|
|
if ($marker) { |
|
$content = $begin . $content if $marker eq 'start' or $marker eq 'both'; |
|
$content .= $end if $marker eq 'end' or $marker eq 'both'; |
|
} |
|
|
$content = "\n// <![CDATA[\n$content\n// ]]>\n"; |
$content = "\n// <![CDATA[\n$content\n// ]]>\n"; |
htmltag("script", $content, {type => "text/javascript"}); |
|
return htmltag("script", $content, {type => "text/javascript"}); |
return htmltag('script', $content, {type => 'text/javascript'}); |
}; |
}; |
|
|
|
|