diff options
author | Paul 'flowerysong' Arthur <flowerysong00@yahoo.com> | 2010-06-24 02:52:01 +0000 |
---|---|---|
committer | Paul 'flowerysong' Arthur <flowerysong00@yahoo.com> | 2010-06-24 02:52:01 +0000 |
commit | 62774923211c2e391534d83e6c7d97acae086766 (patch) | |
tree | a43d0ce9345df18b0f67b61e044636114ce56aba /lib/class | |
parent | 7549180515107d924610a22c5acf1a0e44b4b9f5 (diff) | |
download | ampache-62774923211c2e391534d83e6c7d97acae086766.tar.gz ampache-62774923211c2e391534d83e6c7d97acae086766.tar.bz2 ampache-62774923211c2e391534d83e6c7d97acae086766.zip |
JavaScript cleanup. Consistently use camelCase for naming JS functions. Use
Prototype functionality where possible (particularly for Ajax). Move our JS
into lib/javascript (I dropped kajax as an external module since the new
ajax.js is completely different apart from function headers.) Remove unused
JS functions from base.js.
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/ajax.class.php | 28 | ||||
-rw-r--r-- | lib/class/catalog.class.php | 52 | ||||
-rw-r--r-- | lib/class/stream.class.php | 3 | ||||
-rw-r--r-- | lib/class/vauth.class.php | 2 |
4 files changed, 34 insertions, 51 deletions
diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php index b1e9997a..1b69e17a 100644 --- a/lib/class/ajax.class.php +++ b/lib/class/ajax.class.php @@ -22,8 +22,9 @@ /** * Ajax class - * This class is specifically for setuping/printing out ajax related - * elements onto a page it takes care of the observing and all that raz-a-ma-taz + * This class is specifically for setting up/printing out ajax related + * elements onto a page. It takes care of the observing and all that + * raz-a-ma-taz. */ class Ajax { @@ -41,7 +42,8 @@ class Ajax { /** * observe - * This returns a string with the correct and full ajax 'observe' stuff from prototype + * This returns a string with the correct and full ajax 'observe' stuff + * from prototype */ public static function observe($source,$method,$action,$post='') { @@ -69,8 +71,8 @@ class Ajax { /** * action - * This takes the action, the source and the post (if passed) and generated the full - * ajax link + * This takes the action, the source and the post (if passed) and + * generates the full ajax link */ public static function action($action,$source,$post='') { @@ -98,8 +100,8 @@ class Ajax { /** * button - * This prints out an img of the specified icon with the specified alt text - * and then sets up the required ajax for it + * This prints out an img of the specified icon with the specified alt + * text and then sets up the required ajax for it. */ public static function button($action,$icon,$alt,$source='',$post='',$class='') { @@ -113,8 +115,9 @@ class Ajax { $string = get_user_icon($icon,$alt); - // Generate a <a> so that it's more compliant with older browsers - // (ie :hover actions) and also to unify linkbuttons (w/o ajax) display + // Generate an <a> so that it's more compliant with older + // browsers (ie :hover actions) and also to unify linkbuttons + // (w/o ajax) display $string = "<a href=\"javascript:void(0);\" id=\"$source\" $class>".$string."</a>\n"; $string .= self::observe($source,'click',$ajax_string); @@ -161,7 +164,8 @@ class Ajax { /** * set_include_override - * This sets the cinlduing div override, used only one place kind of a hack + * This sets the including div override, used only one place. Kind of a + * hack. */ public static function set_include_override($value) { @@ -171,8 +175,8 @@ class Ajax { /** * start_container - * This checks to see if we're AJAX'in if we aren't then it echos out the - * html needed to start a container that can be replaced by Ajax + * This checks to see if we're AJAXin'. If we aren't then it echoes out + * the html needed to start a container that can be replaced by Ajax. */ public static function start_container($name) { diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 694ad523..425bfe22 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -596,10 +596,8 @@ class Catalog extends database_object { $this->count++; if ( (time() > $ticker+1)) { $file = str_replace(array('(',')','\''),'',$full_file); - echo "<script type=\"text/javascript\">\n"; - echo "update_txt('" . $this->count ."','add_count_" . $this->id . "');"; - echo "update_txt('" . scrub_out($file) . "','add_dir_" . $this->id . "');"; - echo "\n</script>\n"; + update_text('add_count_' . $this->id, $this->count); + update_text('add_dir_' . $this->id, scrub_out($file)); flush(); $ticker = time(); } // update our current state @@ -617,10 +615,8 @@ class Catalog extends database_object { // This should only happen on the last run if ($path == $this->path) { - echo "<script type=\"text/javascript\">\n"; - echo "update_txt('" . $this->count ."','add_count_" . $this->id . "');"; - echo "update_txt('" . scrub_out($file) . "','add_dir_" . $this->id . "');"; - echo "\n</script>\n"; + update_text('add_count_' . $this->id, $this->count); + update_text('add_dir_' . $this->id, scrub_out($file)); flush(); } @@ -722,10 +718,8 @@ class Catalog extends database_object { /* Stupid little cutesie thing */ $search_count++; if ( time() > $ticker+1) { - echo "<script type=\"text/javascript\">\n"; - echo "update_txt('" . $search_count ."','count_art_" . $this->id . "');"; - echo "update_txt('" . addslashes($album->name) . "','read_art_" . $this->id . "');"; - echo "\n</script>\n"; + update_text('count_art_' . $this->id, $search_count); + update_text('read_art_' . $this->id, scrub_out($album->name)); flush(); $ticker = time(); } //echos song count @@ -734,10 +728,8 @@ class Catalog extends database_object { } // foreach albums // One last time for good measure - echo "<script type=\"text/javascript\">\n"; - echo "update_txt('" . $search_count ."','count_art_" . $this->id . "');"; - echo "update_txt('" . addslashes($album->name) . "','read_art_" . $this->id . "');"; - echo "\n</script>\n"; + update_text('count_art_' . $this->id, $search_count); + update_text('read_art_' . $this->id, scrub_out($album->name)); flush(); self::$_art_albums = array(); @@ -765,18 +757,14 @@ class Catalog extends database_object { /* Stupid little cutesie thing */ $thumb_count++; if ( time() > $ticker+1) { - echo "<script type=\"text/javascript\">\n"; - echo "update_txt('" . $search_count ."','count_thumb_" . $this->id . "');"; - echo "\n</script>\n"; + update_text('count_thumb_' . $this->id, $search_count); flush(); $ticker = time(); } //echos thumb count } // end foreach albums - echo "<script type=\"text/javascript\">\n"; - echo "update_txt('" . $search_count ."','count_thumb_" . $this->id . "');"; - echo "\n</script>\n"; + update_text('count_thumb_' . $this->id, $search_count); flush(); } // generate_thumbnails @@ -1603,10 +1591,8 @@ class Catalog extends database_object { $count++; if (time() > $ticker+1) { $file = str_replace(array('(',')','\''),'',$results['file']); - echo "<script type=\"text/javascript\">\n"; - echo "update_txt('" . $count ."','clean_count_" . $this->id . "');"; - echo "update_txt('" . scrub_out($file) . "','clean_dir_" . $this->id . "');"; - echo "\n</script>\n"; + update_text('clean_count_' . $this->id, $count); + update_text('clean_dir_' . $this->id, scrub_out($file)); flush(); $ticker = time(); } //echos song count @@ -1684,9 +1670,7 @@ class Catalog extends database_object { self::clean($catalog_id); /* Return dead files, so they can be listed */ - echo "<script type=\"text/javascript\">\n"; - echo "update_txt('" . $count ."','clean_count_" . $this->id . "');"; - echo "\n</script>\n"; + update_text('clean_count_' . $this->id, $count); show_box_top(); echo "<strong>"; printf (ngettext('Catalog Clean Done. %d file removed.','Catalog Clean Done. %d files removed.',$dead_files), $dead_files); @@ -1976,10 +1960,8 @@ class Catalog extends database_object { $count++; if (time() > $ticker+1) { $file = str_replace(array('(',')','\''),'',$media->file); - echo "<script type=\"text/javascript\">\n"; - echo "update_txt('" . $count . "','verify_count_" . $catalog_id . "');"; - echo "update_txt('" . scrub_out($file) . "','verify_dir_" . $catalog_id . "');"; - echo "\n</script>\n"; + update_text('verify_count_' . $catalog_id, $count); + update_text('verify_dir_' . $catalog_id, scrub_out($file)); flush(); $ticker = time(); } //echos song count @@ -2004,9 +1986,7 @@ class Catalog extends database_object { $this->update_last_update(); // One final time! - echo "<script type=\"text/javascript\">\n"; - echo "update_txt('" . $this->count . "','count_verify_" . $this->id . "');"; - echo "\n</script>\n"; + update_text('count_verify_' . $this->id, $this->count); flush(); show_box_top(); diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php index 35f0f4a3..a36e547e 100644 --- a/lib/class/stream.class.php +++ b/lib/class/stream.class.php @@ -857,8 +857,7 @@ class Stream { // Load our javascript echo "<script type=\"text/javascript\">"; - //echo "reload_util();"; - echo "reload_util('".$_SESSION['iframe']['target']."');"; + echo "reloadUtil('".$_SESSION['iframe']['target']."');"; echo "</script>"; } // run_playlist_method diff --git a/lib/class/vauth.class.php b/lib/class/vauth.class.php index 761e4dc7..3e034f55 100644 --- a/lib/class/vauth.class.php +++ b/lib/class/vauth.class.php @@ -180,7 +180,7 @@ class vauth { header("Cache-Control: no-store, no-cache, must-revalidate"); header("Pragma: no-cache"); - $results['rfc3514'] = '<script type="text/javascript">reload_logout("'.$target.'")</script>'; + $results['rfc3514'] = '<script type="text/javascript">reloadRedirect("' . $target . '")</script>'; echo xml_from_array($results); } else { |