summaryrefslogtreecommitdiffstats
path: root/lib/class/ajax.class.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-08-06 04:22:19 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-08-06 04:22:19 +0000
commitfe077220bf08ac7ad466e6fdfe88197c6d4ed56e (patch)
tree1e8d8eab876246fc57a1e6c414fe763570690bf6 /lib/class/ajax.class.php
parentadd90bc902ce762626fe72d408f42d705d3f9de7 (diff)
downloadampache-fe077220bf08ac7ad466e6fdfe88197c6d4ed56e.tar.gz
ampache-fe077220bf08ac7ad466e6fdfe88197c6d4ed56e.tar.bz2
ampache-fe077220bf08ac7ad466e6fdfe88197c6d4ed56e.zip
broke a ton of stuff, but added some hotness... yes that is an excuse
Diffstat (limited to 'lib/class/ajax.class.php')
-rw-r--r--lib/class/ajax.class.php36
1 files changed, 33 insertions, 3 deletions
diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php
index 441d9a47..5185538a 100644
--- a/lib/class/ajax.class.php
+++ b/lib/class/ajax.class.php
@@ -42,8 +42,17 @@ class Ajax {
*/
public static function observe($source,$method,$action) {
+ $non_quoted = array('document','window');
+
+ if (in_array($source,$non_quoted)) {
+ $source_txt = $source;
+ }
+ else {
+ $source_txt = "'$source'";
+ }
+
$observe = "<script type=\"text/javascript\"><!--\n";
- $observe .= "\tEvent.observe('$source','$method',function(){" . $action . ";});\n";
+ $observe .= "\tEvent.observe($source_txt,'$method',function(){" . $action . ";});\n";
$observe .= "--></script>\n";
return $observe;
@@ -59,11 +68,20 @@ class Ajax {
$url = Config::get('ajax_url') . $action;
+ $non_quoted = array('document','window');
+
+ if (in_array($source,$non_quoted)) {
+ $source_txt = $source;
+ }
+ else {
+ $source_txt = "'$source'";
+ }
+
if ($post) {
- $ajax_string = "ajaxPost('$url','$post','$source')";
+ $ajax_string = "ajaxPost('$url','$post',$source_txt)";
}
else {
- $ajax_string = "ajaxPut('$url','$source')";
+ $ajax_string = "ajaxPut('$url',$source_txt)";
}
return $ajax_string;
@@ -112,5 +130,17 @@ class Ajax {
} // text
+ /**
+ * run
+ * This runs the specified action no questions asked
+ */
+ public static function run($action) {
+
+ echo "<script type=\"text/javascript\"><!--\n";
+ echo "$action";
+ echo "\n--></script>";
+
+ } // run
+
} // end Ajax class
?>