summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/Javascripts')
-rw-r--r--framework/Web/Javascripts/TJavaScript.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/framework/Web/Javascripts/TJavaScript.php b/framework/Web/Javascripts/TJavaScript.php
index f1efb5b3..02dfdd6a 100644
--- a/framework/Web/Javascripts/TJavaScript.php
+++ b/framework/Web/Javascripts/TJavaScript.php
@@ -24,6 +24,54 @@
*/
class TJavaScript
{
+ public static function renderScriptFiles($files)
+ {
+ $str='';
+ foreach($files as $file)
+ $str.='<script type="text/javascript" src="'.THttpUtility::htmlEncode($file)."\"></script>\n";
+ return $str;
+ }
+
+ public static function renderScriptFile($file)
+ {
+ return '<script type="text/javascript" src="'.THttpUtility::htmlEncode($file)."\"></script>\n";
+ }
+
+ public static function renderScriptBlocks($scripts)
+ {
+ if(count($scripts))
+ return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n".implode("\n",$scripts)."\n/*]]>*/\n</script>\n";
+ else
+ return '';
+ }
+
+ public static function renderScriptBlock($script)
+ {
+ return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n{$script}\n/*]]>*/\n</script>\n";
+ }
+
+ public static function renderArrayDeclarations($arrays)
+ {
+ if(count($arrays))
+ {
+ $str="<script type=\"text/javascript\">\n/*<![CDATA[*/\n";
+ foreach($arrays as $name=>$array)
+ $str.="var $name=new Array(".implode(',',$array).");\n";
+ $str.="\n/*]]>*/\n</script>\n";
+ return $str;
+ }
+ else
+ return '';
+ }
+
+ public static function renderArrayDeclaration($array)
+ {
+ $str="<script type=\"text/javascript\">\n/*<![CDATA[*/\n";
+ $str.="var $name=new Array(".implode(',',$array).");\n";
+ $str.="\n/*]]>*/\n</script>\n";
+ return $str;
+ }
+
public static function quoteJavaScriptString($js,$forUrl=false)
{
if($forUrl)