diff --git a/.gitignore b/.gitignore index 3538ffd3..9ebe940e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,22 @@ .codelite +.phing_targets +.sonar/ *.phprj *.workspace vendor -app/cache/* -app/logs/* +**/cache/** +**/logs/** +**/coverage/** +**/docs/** public/images/* -public/js/cache/* composer.lock *.sqlite *.db *.sqlite3 docs/* -coverage/* tests/test_data/sessions/* -build/coverage/* -build/logs/* -build/pdepend/* -build/phpdox/* cache.properties -tests/test_data/cache/* \ No newline at end of file +build/** +!build/*.txt +!build/*.xml +!build/*.php diff --git a/.htaccess b/.htaccess new file mode 100644 index 00000000..cca7887c --- /dev/null +++ b/.htaccess @@ -0,0 +1,7 @@ +#Rewrite index.php out of the app urls +RewriteEngine On +RewriteBase / +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond $1 !^(public) +RewriteRule ^(.*)$ index.php/$1 [L] \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index f5616fad..667029e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,9 +15,12 @@ script: - phpunit -c build after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover build/logs/coverage.clover + - CODECLIMATE_REPO_TOKEN=2cbddcebcb9256b3402867282e119dbe61de0b31039325356af3c7d72ed6d058 vendor/bin/test-reporter matrix: allow_failures: - - php: nightly \ No newline at end of file + - php: nightly + +addons: + code_climate: + repo_token: 2cbddcebcb9256b3402867282e119dbe61de0b31039325356af3c7d72ed6d058 \ No newline at end of file diff --git a/README.md b/README.md index 4d97aa44..a4e35429 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,36 @@ A self-hosted client that allows custom formatting of data from the hummingbird 2. Configure settings in `app/config/config.php` to your liking 3. Create the following directories if they don't exist, and make sure they are world writable * app/cache + * public/js/cache * public/images/manga * public/images/anime - * public/js/cache + +### Server Setup + +#### nginx +Basic nginx setup + +```nginx +server { + location / { + try_files $uri $uri/ /index.php$uri?$args; + } + + location ~ ^(.+\.php)($|/) { + fastcgi_split_path_info ^(.+\.php)(.*)$; + fastcgi_index index.php; + } + + location ^~ /vendor { + deny all; + } +} +``` + +#### Apache +Make sure to have `mod_rewrite` and `AllowOverride All` enabled in order to take +advantage of the included `.htaccess` file. If you don't wish to use an `.htaccess` file, +include the contents of the `.htaccess` file in your Apache configuration. #### Anime Collection Additional Installation * Run `php /vendor/bin/phinx migrate -e development` to create the database tables diff --git a/app/config/minify_config.php b/app/config/minify_config.php index 9fa30251..6e3d9cd0 100644 --- a/app/config/minify_config.php +++ b/app/config/minify_config.php @@ -4,56 +4,78 @@ * * An API client for Hummingbird to manage anime and manga watch lists * - * @package HummingbirdAnimeClient - * @author Timothy J. Warren + * @package HummingbirdAnimeClient + * @author Timothy J. Warren * @copyright Copyright (c) 2015 - 2016 - * @link https://github.com/timw4mail/HummingBirdAnimeClient - * @license MIT + * @link https://github.com/timw4mail/HummingBirdAnimeClient + * @license MIT */ // -------------------------------------------------------------------------- /* $config = */require 'config.php'; -// Should we use myth to preprocess? -$use_myth = FALSE; +return [ -/* -|-------------------------------------------------------------------------- -| CSS Folder -|-------------------------------------------------------------------------- -| -| The folder where css files exist, in relation to the document root -| -*/ -$css_root = $config['asset_dir'] . '/css/'; + /* + |-------------------------------------------------------------------------- + | CSS Folder + |-------------------------------------------------------------------------- + | + | The folder where css files exist, in relation to the document root + | + */ + 'css_root' => $config['asset_dir'] . '/css/', -/* -|-------------------------------------------------------------------------- -| Path from -|-------------------------------------------------------------------------- -| -| Path fragment to rewrite in css files -| -*/ -$path_from = ''; + /* + |-------------------------------------------------------------------------- + | Path from + |-------------------------------------------------------------------------- + | + | Path fragment to rewrite in css files + | + */ + 'path_from' => '', -/* -|-------------------------------------------------------------------------- -| Path to -|-------------------------------------------------------------------------- -| -| The path fragment replacement for the css files -| -*/ -$path_to = ''; + /* + |-------------------------------------------------------------------------- + | Path to + |-------------------------------------------------------------------------- + | + | The path fragment replacement for the css files + | + */ + 'path_to' => '', -/* -|-------------------------------------------------------------------------- -| JS Folder -|-------------------------------------------------------------------------- -| -| The folder where javascript files exist, in relation to the document root -| -*/ -$js_root = $config['asset_dir'] . '/js/'; \ No newline at end of file + /* + |-------------------------------------------------------------------------- + | CSS Groups file + |-------------------------------------------------------------------------- + | + | The file where the css groups are configured + | + */ + 'css_groups_file' => realpath(__DIR__ . '/minify_css_groups.php'), + + /* + |-------------------------------------------------------------------------- + | JS Folder + |-------------------------------------------------------------------------- + | + | The folder where javascript files exist, in relation to the document root + | + */ + 'js_root' => $config['asset_dir'] . '/js/', + + /* + |-------------------------------------------------------------------------- + | JS Groups file + |-------------------------------------------------------------------------- + | + | The file where the javascript groups are configured + | + */ + 'js_groups_file' => realpath(__DIR__ . '/minify_js_groups.php'), + +]; +// End of minify_config.php \ No newline at end of file diff --git a/app/config/minify_js_groups.php b/app/config/minify_js_groups.php index 1715795e..0b7e766e 100644 --- a/app/config/minify_js_groups.php +++ b/app/config/minify_js_groups.php @@ -17,45 +17,33 @@ * This is the config array for javascript files to concatenate and minify */ return [ - /* - For each group create an array like so - - 'my_group' => array( - 'path/to/js/file1.js', - 'path/to/js/file2.js' - ), - */ - 'table' => [ - 'lib/jquery.min.js', - 'lib/table_sorter/jquery.tablesorter.min.js', - 'sort_tables.js' + 'base' => [ + 'base/classList.js', + 'base/AnimeClient.js', ], - 'edit' => [ - 'lib/jquery.min.js', - 'show_message.js', - 'anime_edit.js', - 'manga_edit.js' + 'event' => [ + 'base/events.js', + ], + 'table' => [ + 'base/sort_tables.js', ], 'table_edit' => [ - 'lib/jquery.min.js', - 'lib/table_sorter/jquery.tablesorter.min.js', 'sort_tables.js', - 'show_message.js', 'anime_edit.js', - 'manga_edit.js' + 'manga_edit.js', + ], + 'edit' => [ + 'anime_edit.js', + 'manga_edit.js', ], 'anime_collection' => [ - 'lib/jquery.min.js', - 'lib/jquery.throttle-debounce.js', - 'lib/jsrender.js', - 'anime_collection.js' + 'lib/mustache.js', + 'anime_collection.js', ], 'manga_collection' => [ - 'lib/jquery.min.js', - 'lib/jquery.throttle-debounce.js', - 'lib/jsrender.js', - 'manga_collection.js' - ] + 'lib/mustache.js', + 'manga_collection.js', + ], ]; // End of js_groups.php \ No newline at end of file diff --git a/app/config/routes.php b/app/config/routes.php index 0e636722..06dd7056 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -20,9 +20,6 @@ return [ // Specify default paths and views // ------------------------------------------------------------------------- 'route_config' => [ - // Subfolder prefix for url, if in a subdirectory of the web root - 'subfolder_prefix' => '', - // Path to public directory, where images/css/javascript are located, // appended to the url 'asset_path' => '/public', @@ -56,6 +53,30 @@ return [ 'action' => 'add', 'verb' => 'post' ], + 'anime_detail' => [ + 'path' => '/anime/details/{id}', + 'action' => 'details', + 'tokens' => [ + 'id' => '[a-z0-9\-]+' + ] + ], + // --------------------------------------------------------------------- + // Manga Routes + // --------------------------------------------------------------------- + 'manga_search' => [ + 'path' => '/manga/search', + 'action' => 'search', + ], + 'manga_add_form' => [ + 'path' => '/manga/add', + 'action' => 'add_form', + 'verb' => 'get' + ], + 'manga_add' => [ + 'path' => '/manga/add', + 'action' => 'add', + 'verb' => 'post' + ], // --------------------------------------------------------------------- // Anime Collection Routes // --------------------------------------------------------------------- @@ -96,9 +117,10 @@ return [ // --------------------------------------------------------------------- // Default / Shared routes // --------------------------------------------------------------------- - 'login' => [ + 'login_form' => [ 'path' => '/{controller}/login', 'action' => 'login', + 'verb' => 'get' ], 'login_post' => [ 'path' => '/{controller}/login', @@ -130,7 +152,7 @@ return [ 'action' => 'edit', 'tokens' => [ 'id' => '[0-9a-z_]+', - 'status' => '[a-zA-z\- ]+', + 'status' => '([a-zA-Z\- ]|%20)+', ] ], 'list' => [ diff --git a/app/views/anime/add.php b/app/views/anime/add.php index 12e88ab3..9224905d 100644 --- a/app/views/anime/add.php +++ b/app/views/anime/add.php @@ -3,6 +3,11 @@

Add Anime to your List

+
@@ -30,11 +35,5 @@ - - + \ No newline at end of file diff --git a/app/views/anime/cover.php b/app/views/anime/cover.php index 92577322..8140430b 100644 --- a/app/views/anime/cover.php +++ b/app/views/anime/cover.php @@ -65,5 +65,5 @@ is_authenticated()): ?> - + diff --git a/app/views/anime/details.php b/app/views/anime/details.php new file mode 100644 index 00000000..94ab30fe --- /dev/null +++ b/app/views/anime/details.php @@ -0,0 +1,11 @@ +
+

+ +

+ + + <?= $data['title'] ?> cover image + +

+
+
\ No newline at end of file diff --git a/app/views/anime/edit.php b/app/views/anime/edit.php index 3c44d7b3..6b1f7015 100644 --- a/app/views/anime/edit.php +++ b/app/views/anime/edit.php @@ -85,5 +85,5 @@ - + \ No newline at end of file diff --git a/app/views/anime/list.php b/app/views/anime/list.php index 030c74e1..055f2b29 100644 --- a/app/views/anime/list.php +++ b/app/views/anime/list.php @@ -11,7 +11,7 @@ is_authenticated()): ?> -   +   Title Airing Status @@ -33,7 +33,7 @@ ">Edit - + @@ -42,7 +42,7 @@ / 10 - + Episodes:
 /  @@ -74,4 +74,4 @@ is_authenticated()) ? 'table_edit' : 'table' ?> - + diff --git a/app/views/collection/add.php b/app/views/collection/add.php index d8fb65f2..61c3a7e1 100644 --- a/app/views/collection/add.php +++ b/app/views/collection/add.php @@ -3,6 +3,11 @@

Add Anime to your Collection

+
@@ -34,11 +39,5 @@ - - + \ No newline at end of file diff --git a/app/views/collection/edit.php b/app/views/collection/edit.php index 8afecb81..17bcd1cd 100644 --- a/app/views/collection/edit.php +++ b/app/views/collection/edit.php @@ -52,5 +52,5 @@ {{:title}} - + \ No newline at end of file diff --git a/app/views/collection/list.php b/app/views/collection/list.php index 934468c5..77f61bca 100644 --- a/app/views/collection/list.php +++ b/app/views/collection/list.php @@ -49,4 +49,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/app/views/footer.php b/app/views/footer.php index 691287b6..ca4c3ba4 100644 --- a/app/views/footer.php +++ b/app/views/footer.php @@ -1,2 +1,3 @@ + \ No newline at end of file diff --git a/app/views/header.php b/app/views/header.php index cd740d71..0dd2ee52 100644 --- a/app/views/header.php +++ b/app/views/header.php @@ -4,11 +4,10 @@ <?= $title ?> - - + + + +
@@ -48,11 +47,8 @@ -
- -
- - html($message['message']) ?> - x -
- + + \ No newline at end of file diff --git a/app/views/manga/add.php b/app/views/manga/add.php index e69de29b..33609c55 100644 --- a/app/views/manga/add.php +++ b/app/views/manga/add.php @@ -0,0 +1,39 @@ +is_authenticated()): ?> +
+

Add Manga to your List

+
+
+ + +
+
+
+
+ + + + + + + + + + + +
+ +
  + +
+
+
+ + \ No newline at end of file diff --git a/app/views/manga/cover.php b/app/views/manga/cover.php index f732f5fe..0677ff34 100644 --- a/app/views/manga/cover.php +++ b/app/views/manga/cover.php @@ -1,4 +1,7 @@
+is_authenticated()): ?> +Add Item +

There's nothing here!

@@ -53,5 +56,5 @@
is_authenticated()): ?> - + diff --git a/app/views/manga/edit.php b/app/views/manga/edit.php index 71bef259..b281bb0e 100644 --- a/app/views/manga/edit.php +++ b/app/views/manga/edit.php @@ -85,5 +85,4 @@ - \ No newline at end of file diff --git a/app/views/manga/list.php b/app/views/manga/list.php index c5da6164..92593abe 100644 --- a/app/views/manga/list.php +++ b/app/views/manga/list.php @@ -1,4 +1,7 @@
+is_authenticated()): ?> +Add Item +

There's nothing here!

@@ -42,4 +45,4 @@
- \ No newline at end of file + \ No newline at end of file diff --git a/app/views/message.ms b/app/views/message.ms new file mode 100644 index 00000000..99b2b568 --- /dev/null +++ b/app/views/message.ms @@ -0,0 +1,5 @@ +
+ + {{message}} + x +
\ No newline at end of file diff --git a/app/views/message.php b/app/views/message.php index f34b205c..f20323bf 100644 --- a/app/views/message.php +++ b/app/views/message.php @@ -1,5 +1,5 @@
html($message) ?> - x +
\ No newline at end of file diff --git a/build.xml b/build.xml index 0c096451..b8554ad5 100644 --- a/build.xml +++ b/build.xml @@ -13,10 +13,6 @@ depends="prepare,static-analysis,phpunit,phpdox,sonar" description="Performs static analysis, runs the tests, and generates project documentation" /> - - - - - - - - - - - - - @@ -57,23 +41,38 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -83,50 +82,61 @@ - - - - - - - - - + + + + + + + + + + + + + + - - - - - - + + + + + + + + - - - + + + + + + - - - - - + + + + + + - + @@ -135,7 +145,7 @@ - + @@ -145,13 +155,13 @@ - + - + diff --git a/composer.json b/composer.json index 3d318004..f2379f22 100644 --- a/composer.json +++ b/composer.json @@ -17,5 +17,8 @@ "psr/log": "~1.0", "robmorgan/phinx": "0.4.*", "yosymfony/toml": "0.3.*" + }, + "require-dev": { + "codeclimate/php-test-reporter": "dev-master" } } \ No newline at end of file diff --git a/src/Aviat/Ion/Enum/MessageType.php b/public/cache/.gitkeep similarity index 100% rename from src/Aviat/Ion/Enum/MessageType.php rename to public/cache/.gitkeep diff --git a/public/css.php b/public/css.php index 15aa615f..46bc1915 100644 --- a/public/css.php +++ b/public/css.php @@ -4,134 +4,174 @@ * * An API client for Hummingbird to manage anime and manga watch lists * - * @package HummingbirdAnimeClient - * @author Timothy J. Warren + * @package HummingbirdAnimeClient + * @author Timothy J. Warren * @copyright Copyright (c) 2015 - 2016 - * @link https://github.com/timw4mail/HummingBirdAnimeClient - * @license MIT + * @link https://github.com/timw4mail/HummingBirdAnimeClient + * @license MIT */ +namespace Aviat\EasyMin; + +require_once('./min.php'); + +/** + * Simple CSS Minifier + */ +class CSSMin extends BaseMin { + + protected $css_root; + protected $path_from; + protected $path_to; + protected $group; + protected $last_modified; + protected $requested_time; + + public function __construct(array $config, array $groups) + { + $group = $_GET['g']; + $this->css_root = $config['css_root']; + $this->path_from = $config['path_from']; + $this->path_to = $config['path_to']; + $this->group = $groups[$group]; + $this->last_modified = $this->get_last_modified(); + + $this->send(); + } + + /** + * Send the CSS + * + * @return void + */ + protected function send() + { + if($this->last_modified >= $this->get_if_modified() && $this->is_not_debug()) + { + throw new FileNotChangedException(); + } + + $css = ( ! array_key_exists('debug', $_GET)) + ? $this->compress($this->get_css()) + : $this->get_css(); + + $this->output($css); + } + + /** + * Function for compressing the CSS as tightly as possible + * + * @param string $buffer + * @return string + */ + protected function compress($buffer) + { + //Remove CSS comments + $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); + + //Remove tabs, spaces, newlines, etc. + $buffer = preg_replace('`\s+`', ' ', $buffer); + $replace = array( + ' )' => ')', + ') ' => ')', + ' }' => '}', + '} ' => '}', + ' {' => '{', + '{ ' => '{', + ', ' => ',', + ': ' => ':', + '; ' => ';', + ); + + //Eradicate every last space! + $buffer = trim(strtr($buffer, $replace)); + $buffer = str_replace('{ ', '{', $buffer); + $buffer = str_replace('} ', '}', $buffer); + + return $buffer; + } + + /** + * Get the most recent file modification date + * + * @return int + */ + protected function get_last_modified() + { + $modified = array(); + + // Get all the css files, and concatenate them together + if(isset($this->group)) + { + foreach($this->group as $file) + { + $new_file = realpath("{$this->css_root}{$file}"); + $modified[] = filemtime($new_file); + } + } + + //Add this page for last modified check + $modified[] = filemtime(__FILE__); + + //Get the latest modified date + rsort($modified); + + return array_shift($modified); + } + + /** + * Get the css to display + * + * @return string + */ + protected function get_css() + { + $css = ''; + + foreach($this->group as $file) + { + $new_file = realpath("{$this->css_root}{$file}"); + $css .= file_get_contents($new_file); + } + + // Correct paths that have changed due to concatenation + // based on rules in the config file + $css = str_replace($this->path_from, $this->path_to, $css); + + return $css; + } + + /** + * Output the CSS + * + * @return void + */ + protected function output($css) + { + $this->send_final_output($css, 'text/css', $this->last_modified); + } +} + +// -------------------------------------------------------------------------- +// ! Start Minifying // -------------------------------------------------------------------------- //Get config files -require('../app/config/minify_config.php'); +$config = require('../app/config/minify_config.php'); +$groups = require($config['css_groups_file']); -//Include the css groups -$groups = require("../app/config/minify_css_groups.php"); - -//Function for compressing the CSS as tightly as possible -/** - * @param string $buffer - */ -function compress($buffer) { - - //Remove CSS comments - $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); - - //Remove tabs, spaces, newlines, etc. - $buffer = preg_replace('`\s+`', ' ', $buffer); - $replace = array( - ' )' => ')', - ') ' => ')', - ' }' => '}', - '} ' => '}', - ' {' => '{', - '{ ' => '{', - ', ' => ',', - ': ' => ':', - '; ' => ';', - ); - - //Eradicate every last space! - $buffer = trim(strtr($buffer, $replace)); - $buffer = str_replace('{ ', '{', $buffer); - $buffer = str_replace('} ', '}', $buffer); - - return $buffer; -} - -function get_last_modifed() +if ( ! array_key_exists($_GET['g'], $groups)) { - global $groups, $css_root; - - $modified = array(); - - // Get all the css files, and concatenate them together - if(isset($groups[$_GET['g']])) - { - foreach($groups[$_GET['g']] as $file) - { - $new_file = realpath($css_root.$file); - $modified[] = filemtime($new_file); - } - } - - //Add myth css file for last modified check - $modified[] = filemtime(realpath("css/base.myth.css")); - - //Add this page for last modified check - $modified[] = filemtime(__FILE__); - - //Get the latest modified date - rsort($modified); - $last_modified = $modified[0]; - - return $last_modified; + throw new InvalidArgumentException('You must specify a css group that exists'); } -function get_css() +try { - global $groups, $path_from, $path_to, $css_root; - - $css = ''; - - if(isset($groups[$_GET['g']])) - { - foreach($groups[$_GET['g']] as $file) - { - $new_file = realpath($css_root.$file); - $css .= file_get_contents($new_file); - $modified[] = filemtime($new_file); - } - } - - // If not in debug mode, minify the css - if( ! isset($_GET['debug'])) - { - $css = compress($css); - } - - // Correct paths that have changed due to concatenation - // based on rules in the config file - $css = strtr($css, $path_from, $path_to); - - return $css; + new CSSMin($config, $groups); } - -// -------------------------------------------------------------------------- -$last_modified = get_last_modifed(); - -$requested_time=(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) - ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) - : 0; - -// Send 304 when not modified for faster response -if($last_modified === $requested_time) +catch (FileNotChangedException $e) { - header("HTTP/1.1 304 Not Modified"); - exit(); + BaseMin::send304(); } -//This GZIPs the CSS for transmission to the user -//making file size smaller and transfer rate quicker -ob_start("ob_gzhandler"); - -header("Content-Type: text/css; charset=utf8"); -header("Cache-control: public, max-age=691200, must-revalidate"); -header("Last-Modified: ".gmdate('D, d M Y H:i:s', $last_modified)." GMT"); -header("Expires: ".gmdate('D, d M Y H:i:s', (filemtime(basename(__FILE__)) + 691200))." GMT"); - -echo get_css(); - -ob_end_flush(); //End of css.php \ No newline at end of file diff --git a/public/css/base.css b/public/css/base.css index 0d7c0f00..356b8453 100644 --- a/public/css/base.css +++ b/public/css/base.css @@ -6,53 +6,46 @@ body { margin: 0.5em; } -a:hover, -a:active { - color: #7d12db; +button { + background: rgba(255,255,255,0.65); + margin: 0; } table { - width: 85%; + min-width: 85%; margin: 0 auto; } -tbody > tr:nth-child(odd) { - background: #ddd; +td { + padding: 1em; + padding: 1rem; +} + +thead td, +thead th { + padding: 0.5em; + padding: 0.5rem; } input[type=number] { width: 4em; } -.form { - width: 100%; +tbody > tr:nth-child(odd) { + background: #ddd; } -.form tr > td:nth-child(odd) { - text-align: right; - min-width: 25px; - max-width: 30%; +a:hover, +a:active { + color: #7d12db; } -.form tr > td:nth-child(even) { - text-align: left; - min-width: 70%; -} +/* ----------------------------------------------------------------------------- + Utility classes +------------------------------------------------------------------------------*/ -.form thead th, -.form thead tr { - background: inherit; - border: 0; -} - -.form.invisible tr:nth-child(odd) { - background: inherit; -} - -.form.invisible tr, -.form.invisible td, -.form.invisible th { - border: 0; +.bracketed { + color: #12db18; } .bracketed, @@ -68,10 +61,6 @@ h1 a { content: '\00a0]'; } -.bracketed { - color: #12db18; -} - .bracketed:hover, .bracketed:active { color: #db7d12; @@ -132,6 +121,10 @@ h1 a { font-size: 1.6rem; } +.justify { + text-align: justify; +} + .align_center { text-align: center; } @@ -144,11 +137,257 @@ h1 a { text-align: right; } +.no_border { + border: none; +} + .media-wrap { text-align: center; margin: 0 auto; } +/* ----------------------------------------------------------------------------- + CSS loading icon +------------------------------------------------------------------------------*/ + +.cssload-loader { + position: relative; + left: calc(50% - 31px); + width: 62px; + height: 62px; + border-radius: 50%; + -webkit-perspective: 780px; + perspective: 780px; +} + +.cssload-inner { + position: absolute; + width: 100%; + height: 100%; + box-sizing: border-box; + border-radius: 50%; +} + +.cssload-inner.cssload-one { + left: 0%; + top: 0%; + -webkit-animation: cssload-rotate-one 1.15s linear infinite; + animation: cssload-rotate-one 1.15s linear infinite; + border-bottom: 3px solid rgb(0,0,0); +} + +.cssload-inner.cssload-two { + right: 0%; + top: 0%; + -webkit-animation: cssload-rotate-two 1.15s linear infinite; + animation: cssload-rotate-two 1.15s linear infinite; + border-right: 3px solid rgb(0,0,0); +} + +.cssload-inner.cssload-three { + right: 0%; + bottom: 0%; + -webkit-animation: cssload-rotate-three 1.15s linear infinite; + animation: cssload-rotate-three 1.15s linear infinite; + border-top: 3px solid rgb(0,0,0); +} + +@-webkit-keyframes cssload-rotate-one { + 0% { + -webkit-transform: rotateX(35deg) rotateY(-45deg) rotateZ(0deg); + transform: rotateX(35deg) rotateY(-45deg) rotateZ(0deg); + } + + 100% { + -webkit-transform: rotateX(35deg) rotateY(-45deg) rotateZ(360deg); + transform: rotateX(35deg) rotateY(-45deg) rotateZ(360deg); + } +} + +@keyframes cssload-rotate-one { + 0% { + -webkit-transform: rotateX(35deg) rotateY(-45deg) rotateZ(0deg); + transform: rotateX(35deg) rotateY(-45deg) rotateZ(0deg); + } + + 100% { + -webkit-transform: rotateX(35deg) rotateY(-45deg) rotateZ(360deg); + transform: rotateX(35deg) rotateY(-45deg) rotateZ(360deg); + } +} + +@-webkit-keyframes cssload-rotate-two { + 0% { + -webkit-transform: rotateX(50deg) rotateY(10deg) rotateZ(0deg); + transform: rotateX(50deg) rotateY(10deg) rotateZ(0deg); + } + + 100% { + -webkit-transform: rotateX(50deg) rotateY(10deg) rotateZ(360deg); + transform: rotateX(50deg) rotateY(10deg) rotateZ(360deg); + } +} + +@keyframes cssload-rotate-two { + 0% { + -webkit-transform: rotateX(50deg) rotateY(10deg) rotateZ(0deg); + transform: rotateX(50deg) rotateY(10deg) rotateZ(0deg); + } + + 100% { + -webkit-transform: rotateX(50deg) rotateY(10deg) rotateZ(360deg); + transform: rotateX(50deg) rotateY(10deg) rotateZ(360deg); + } +} + +@-webkit-keyframes cssload-rotate-three { + 0% { + -webkit-transform: rotateX(35deg) rotateY(55deg) rotateZ(0deg); + transform: rotateX(35deg) rotateY(55deg) rotateZ(0deg); + } + + 100% { + -webkit-transform: rotateX(35deg) rotateY(55deg) rotateZ(360deg); + transform: rotateX(35deg) rotateY(55deg) rotateZ(360deg); + } +} + +@keyframes cssload-rotate-three { + 0% { + -webkit-transform: rotateX(35deg) rotateY(55deg) rotateZ(0deg); + transform: rotateX(35deg) rotateY(55deg) rotateZ(0deg); + } + + 100% { + -webkit-transform: rotateX(35deg) rotateY(55deg) rotateZ(360deg); + transform: rotateX(35deg) rotateY(55deg) rotateZ(360deg); + } +} + +/* ----------------------------------------------------------------------------- + Table sorting and form styles +------------------------------------------------------------------------------*/ + +.sorting, +.sorting_asc, +.sorting_desc { + vertical-align: text-bottom; +} + +.sorting::before { + content: " ↕\00a0"; +} + +.sorting_asc::before { + content: " ↑\00a0"; +} + +.sorting_desc::before { + content: " ↓\00a0"; +} + +.form { + width: 100%; +} + +.form thead th, +.form thead tr { + background: inherit; + border: 0; +} + +.form tr > td:nth-child(odd) { + text-align: right; + min-width: 25px; + max-width: 30%; +} + +.form tr > td:nth-child(even) { + text-align: left; + min-width: 70%; +} + +.form.invisible tr:nth-child(odd) { + background: inherit; +} + +.form.invisible tr, +.form.invisible td, +.form.invisible th { + border: 0; +} + +/* ----------------------------------------------------------------------------- + Message boxes +------------------------------------------------------------------------------*/ + +.message { + position: relative; + margin: 0.5em auto; + padding: 0.5em; + width: 95%; +} + +.message .close { + width: 1em; + height: 1em; + position: absolute; + right: 0.5em; + top: 0.5em; + text-align: center; + vertical-align: middle; + line-height: 1em; +} + +/*.message .close:after { + content: '☐'; +}*/ + +.message:hover .close:after { + content: '☒'; +} + +.message:hover { + cursor: pointer; +} + +.message .icon { + left: 0.5em; + top: 0.5em; + margin-right: 1em; +} + +.message.error { + border: 1px solid #924949; + background: #f3e6e6; +} + +.message.error .icon::after { + content: '✘'; +} + +.message.success { + border: 1px solid #1f8454; + background: #70dda9; +} + +.message.success .icon::after { + content: '✔'; +} + +.message.info { + border: 1px solid #bfbe3a; + background: #FFFFCC; +} + +.message.info .icon::after { + content: '⚠'; +} + +/* ----------------------------------------------------------------------------- + Base list styles +------------------------------------------------------------------------------*/ + .media { position: relative; vertical-align: top; @@ -159,11 +398,6 @@ h1 a { margin: 0.25em; } -button { - background: rgba(255,255,255,0.65); - margin: 0; -} - .media .edit_buttons > button { margin: 0.5em auto; } @@ -224,53 +458,6 @@ button { text-shadow: 1px 2px 1px rgba(0, 0, 0, 0.85); } -/* ----------------------------------------------------------------------------- - Message boxes -------------------------------------------------------------------------------*/ - -.message { - position: relative; - margin: 0.5em auto; - padding: 0.5em; - width: 95%; -} - -.message .close { - width: 1em; - height: 1em; - position: absolute; - right: 0.5em; - top: 0.5em; - text-align: center; - vertical-align: middle; - line-height: 1em; -} - -.message .close:hover { - cursor: pointer; -} - -.message .icon { - left: 0.5em; - top: 0.5em; - margin-right: 1em; -} - -.message.error { - border: 1px solid #924949; - background: #f3e6e6; -} - -.message.success { - border: 1px solid #1f8454; - background: #70dda9; -} - -.message.info { - border: 1px solid #bfbe3a; - background: #FFFFCC; -} - /* ----------------------------------------------------------------------------- Anime-list-specific styles ------------------------------------------------------------------------------*/ @@ -370,4 +557,53 @@ button { top: calc(50% - 58.5px); left: 5px; left: calc(50% - 95px); +} + +/* ----------------------------------------------------------------------------- + Page-specific styles +------------------------------------------------------------------------------*/ + +.media.search > .name { + background-color: #555; + background-color: rgba(000,000,000,0.35); + background-size: cover; + background-size: contain; + background-repeat: no-repeat; +} + +.big-check { + display: none; +} + +.big-check:checked + label { + -webkit-transition: .25s ease; + transition: .25s ease; + background: rgba(0,0,0,0.75); +} + +.big-check:checked + label:after { + content: '✓'; + font-size: 15em; + font-size: 15rem; + text-align: center; + color: greenyellow; + position: absolute; + top: 5px; + left: 0; + height: 100%; + width: 100%; +} + +#series_list article.media { + position: relative; +} + +#series_list .name, +#series_list .name label { + position: absolute; + display: block; + top: 0; + height: 100%; + width: 100%; + vertical-align: middle; } \ No newline at end of file diff --git a/public/css/base.myth.css b/public/css/base.myth.css index da36ef17..95dc85b9 100644 --- a/public/css/base.myth.css +++ b/public/css/base.myth.css @@ -13,54 +13,50 @@ template {display:none} body {margin: 0.5em;} -a:hover, a:active { - color: var(--link-hover-color) +button { + background:rgba(255,255,255,0.65); + margin: 0; } table { - width:85%; + min-width:85%; margin: 0 auto; } -tbody > tr:nth-child(odd) { - background: #ddd; +td { + padding:1em; + padding:1rem; +} + +thead td, thead th { + padding:0.5em; + padding:0.5rem; } input[type=number] { width: 4em; } -.form { width:100%; } -.form tr > td:nth-child(odd) { - text-align:right; - min-width:25px; - max-width:30%; -} -.form tr > td:nth-child(even) { - text-align:left; - min-width:70%; +tbody > tr:nth-child(odd) { + background: #ddd; } -.form thead th, .form thead tr { - background: inherit; - border:0; +a:hover, a:active { + color: var(--link-hover-color) } -.form.invisible tr:nth-child(odd) { - background: inherit; -} -.form.invisible tr, .form.invisible td, .form.invisible th { - border:0; -} +/* ----------------------------------------------------------------------------- + Utility classes +------------------------------------------------------------------------------*/ +.bracketed { + color: var(--edit-link-color); +} .bracketed, h1 a { text-shadow: var(--link-shadow); } .bracketed:before {content: '[\00a0'} .bracketed:after {content: '\00a0]'} -.bracketed { - color: var(--edit-link-color); -} .bracketed:hover, .bracketed:active { color: var(--edit-link-hover-color) } @@ -78,15 +74,202 @@ input[type=number] { font-size:1.6rem; } +.justify {text-align:justify} .align_center {text-align:center} -.align_left {text-align:left;} -.align_right {text-align:right;} +.align_left {text-align:left} +.align_right {text-align:right} + +.no_border {border:none} .media-wrap { text-align:center; margin:0 auto; } +/* ----------------------------------------------------------------------------- + CSS loading icon +------------------------------------------------------------------------------*/ + +.cssload-loader { + position: relative; + left: calc(50% - 31px); + width: 62px; + height: 62px; + border-radius: 50%; + perspective: 780px; +} + +.cssload-inner { + position: absolute; + width: 100%; + height: 100%; + box-sizing: border-box; + border-radius: 50%; +} + +.cssload-inner.cssload-one { + left: 0%; + top: 0%; + animation: cssload-rotate-one 1.15s linear infinite; + border-bottom: 3px solid rgb(0,0,0); +} + +.cssload-inner.cssload-two { + right: 0%; + top: 0%; + animation: cssload-rotate-two 1.15s linear infinite; + border-right: 3px solid rgb(0,0,0); +} + +.cssload-inner.cssload-three { + right: 0%; + bottom: 0%; + animation: cssload-rotate-three 1.15s linear infinite; + border-top: 3px solid rgb(0,0,0); +} + +@keyframes cssload-rotate-one { + 0% { + transform: rotateX(35deg) rotateY(-45deg) rotateZ(0deg); + } + 100% { + transform: rotateX(35deg) rotateY(-45deg) rotateZ(360deg); + } +} + +@keyframes cssload-rotate-two { + 0% { + transform: rotateX(50deg) rotateY(10deg) rotateZ(0deg); + } + 100% { + transform: rotateX(50deg) rotateY(10deg) rotateZ(360deg); + } +} + +@keyframes cssload-rotate-three { + 0% { + transform: rotateX(35deg) rotateY(55deg) rotateZ(0deg); + } + 100% { + transform: rotateX(35deg) rotateY(55deg) rotateZ(360deg); + } +} + +/* ----------------------------------------------------------------------------- + Table sorting and form styles +------------------------------------------------------------------------------*/ +.sorting, +/*.sorting::before,*/ +.sorting_asc, +/*.sorting_asc::before,*/ +.sorting_desc +/*.sorting_desc::before*/ { + vertical-align:text-bottom; +} +.sorting::before { + content: " ↕\00a0"; +} +.sorting_asc::before { + content: " ↑\00a0"; +} +.sorting_desc::before { + content: " ↓\00a0"; +} + +.form { width:100%; } + +.form thead th, .form thead tr { + background: inherit; + border:0; +} + +.form tr > td:nth-child(odd) { + text-align:right; + min-width:25px; + max-width:30%; +} +.form tr > td:nth-child(even) { + text-align:left; + min-width:70%; +} + +.form.invisible tr:nth-child(odd) { + background: inherit; +} +.form.invisible tr, .form.invisible td, .form.invisible th { + border:0; +} + +/* ----------------------------------------------------------------------------- + Message boxes +------------------------------------------------------------------------------*/ + +.message{ + position:relative; + margin:0.5em auto; + padding:0.5em; + width:95%; +} + +.message .close{ + width:1em; + height:1em; + position:absolute; + right:0.5em; + top:0.5em; + text-align:center; + vertical-align:middle; + line-height:1em; +} + +/*.message .close:after { + content: '☐'; +}*/ + +.message:hover .close:after { + content: '☒'; +} + +.message:hover { + cursor:pointer; +} + +.message .icon{ + left:0.5em; + top:0.5em; + margin-right:1em; +} + +.message.error{ + border:1px solid #924949; + background: #f3e6e6; +} + + .message.error .icon::after { + content: '✘'; + } + +.message.success{ + border:1px solid #1f8454; + background: #70dda9; +} + .message.success .icon::after { + content: '✔' + } + +.message.info{ + border:1px solid #bfbe3a; + background: #FFFFCC; +} + + .message.info .icon::after { + content: '⚠'; + } + +/* ----------------------------------------------------------------------------- + Base list styles +------------------------------------------------------------------------------*/ + .media { position:relative; vertical-align:top; @@ -97,11 +280,6 @@ input[type=number] { margin: var(--normal-padding); } -button { - background:rgba(255,255,255,0.65); - margin: 0; -} - .media .edit_buttons > button { margin:0.5em auto; } @@ -161,52 +339,7 @@ button { text-shadow: var(--shadow); } -/* ----------------------------------------------------------------------------- - Message boxes -------------------------------------------------------------------------------*/ -.message{ - position:relative; - margin:0.5em auto; - padding:0.5em; - width:95%; -} - -.message .close{ - width:1em; - height:1em; - position:absolute; - right:0.5em; - top:0.5em; - text-align:center; - vertical-align:middle; - line-height:1em; -} - -.message .close:hover { - cursor:pointer; -} - -.message .icon{ - left:0.5em; - top:0.5em; - margin-right:1em; -} - -.message.error{ - border:1px solid #924949; - background: #f3e6e6; -} - -.message.success{ - border:1px solid #1f8454; - background: #70dda9; -} - -.message.info{ - border:1px solid #bfbe3a; - background: #FFFFCC; -} /* ----------------------------------------------------------------------------- Anime-list-specific styles @@ -293,3 +426,52 @@ button { left: 5px; left: calc(50% - 95px); } + + +/* ----------------------------------------------------------------------------- + Page-specific styles +------------------------------------------------------------------------------*/ +.media.search > .name { + background-color:#555; + background-color: rgba(000,000,000,0.35); + background-size: cover; + background-size: contain; + background-repeat: no-repeat; +} + +.big-check { + display:none; +} + +.big-check:checked + label { + transition: .25s ease; + background:rgba(0,0,0,0.75); +} + +.big-check:checked + label:after { + content: '✓'; + font-size: 15em; + font-size: 15rem; + text-align:center; + color: greenyellow; + position:absolute; + top:5px; + left:0; + height:100%; + width:100%; +} + +#series_list article.media { + position:relative; +} +#series_list .name, #series_list .name label { + position:absolute; + display:block; + top:0; + height:100%; + width:100%; + vertical-align:middle; +} + + + diff --git a/public/css/marx.css b/public/css/marx.css index f5696df9..c1616f66 100644 --- a/public/css/marx.css +++ b/public/css/marx.css @@ -111,7 +111,6 @@ button, input, select, textarea { - /*background-color: transparent;*/ border: .1rem solid #ccc; color: inherit; font-family: inherit; @@ -507,7 +506,7 @@ textarea { input[type=submit], button { - background-color: transparent; + /*background-color: transparent;*/ border: .2rem solid #444; border-radius: 0; color: #444; diff --git a/public/css/marx.myth.css b/public/css/marx.myth.css index 07038a6b..d42cd5b4 100644 --- a/public/css/marx.myth.css +++ b/public/css/marx.myth.css @@ -78,7 +78,6 @@ audio, canvas, iframe, img, svg, video { vertical-align: middle; } button, input, select, textarea { - /*background-color: transparent;*/ border: .1rem solid #ccc; color: inherit; font-family: inherit; @@ -342,7 +341,7 @@ textarea { vertical-align: middle; } input[type=submit], button { - background-color: transparent; + /*background-color: transparent;*/ border: .2rem solid #444; border-radius: 0; color: #444; diff --git a/public/js.php b/public/js.php index 88890bf4..5926b46c 100644 --- a/public/js.php +++ b/public/js.php @@ -4,223 +4,243 @@ * * An API client for Hummingbird to manage anime and manga watch lists * - * @package HummingbirdAnimeClient - * @author Timothy J. Warren + * @package HummingbirdAnimeClient + * @author Timothy J. Warren * @copyright Copyright (c) 2015 - 2016 - * @link https://github.com/timw4mail/HummingBirdAnimeClient - * @license MIT + * @link https://github.com/timw4mail/HummingBirdAnimeClient + * @license MIT */ -// -------------------------------------------------------------------------- +namespace Aviat\EasyMin; + use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request; -//Get config files -require_once('../app/config/minify_config.php'); - -//Include the js groups -$groups_file = "../app/config/minify_js_groups.php"; -$groups = require_once($groups_file); - // Include guzzle require_once('../vendor/autoload.php'); - -//The name of this file -$this_file = __FILE__; - -// -------------------------------------------------------------------------- +require_once('./min.php'); /** - * Get Files - * - * Concatenates the javascript files for the current - * group as a string - * @return string + * Simple Javascript minfier, using google closure compiler */ -function get_files() -{ - global $groups, $js_root; +class JSMin extends BaseMin { - $js = ''; + protected $js_root; + protected $js_group; + protected $js_groups_file; + protected $cache_file; - foreach($groups[$_GET['g']] as $file) + protected $last_modified; + protected $requested_time; + protected $cache_modified; + + public function __construct(array $config, array $groups) { - $new_file = realpath($js_root.$file); - $js .= file_get_contents($new_file) . "\n\n"; + $group = $_GET['g']; + + $this->js_root = $config['js_root']; + $this->js_group = $groups[$group]; + $this->js_groups_file = $config['js_groups_file']; + $this->cache_file = "{$this->js_root}cache/{$group}"; + $this->last_modified = $this->get_last_modified(); + + $this->cache_modified = (is_file($this->cache_file)) + ? filemtime($this->cache_file) + : 0; + + // Output some JS! + $this->send(); } - return $js; -} - -// -------------------------------------------------------------------------- - -/** - * Google Min - * - * Minifies javascript using google's closure compiler - * @param string $new_file - * @return string - */ -function google_min($new_file) -{ - $options = [ - 'output_info' => 'errors', - 'output_format' => 'json', - 'compilation_level' => 'SIMPLE_OPTIMIZATIONS', - 'js_code' => $new_file, - 'language' => 'ECMASCRIPT5', - 'language_out' => 'ECMASCRIPT5_STRICT' - ]; - - // First check for errors - $error_client = new Client(); - $error_res = $error_client->post('http://closure-compiler.appspot.com/compile', [ - 'headers' => [ - 'Accept-Encoding' => 'gzip', - "Content-type" => "application/x-www-form-urlencoded" - ], - 'form_params' => $options - ]); - - $error_json = $error_res->getBody(); - $error_obj = json_decode($error_json); - - if ( ! empty($error_obj->errors)) + protected function send() { - ?>
is_debug_call()) + { + return $this->output($this->get_files()); + } + + // If the browser's cached version is up to date, + // don't resend the file + if($this->last_modified == $this->get_if_modified() && $this->is_not_debug()) + { + throw new FileNotChangedException(); + } + + if($this->cache_modified < $this->last_modified) + { + $js = $this->minify($this->get_files()); + + //Make sure cache file gets created/updated + if (file_put_contents($this->cache_file, $js) === FALSE) + { + echo 'Cache file was not created. Make sure you have the correct folder permissions.'; + return; + } + + return $this->output($js); + } + else + { + return $this->output(file_get_contents($this->cache_file)); + } } - // Now actually retrieve the compiled code - $options['output_info'] = 'compiled_code'; - $client = new Client(); - $res = $client->post('http://closure-compiler.appspot.com/compile', [ - 'headers' => [ - 'Accept-Encoding' => 'gzip', - "Content-type" => "application/x-www-form-urlencoded" - ], - 'form_params' => $options - ]); - - $json = $res->getBody(); - $obj = json_decode($json); - - return $obj->compiledCode; -} - -// -------------------------------------------------------------------------- - -//Creative rewriting of /g/groupname to ?g=groupname -$pi = $_SERVER['PATH_INFO']; -$pia = explode('/', $pi); - -$pia_len = count($pia); -$i = 1; - -while($i < $pia_len) -{ - $j = $i+1; - $j = (isset($pia[$j])) ? $j : $i; - - $_GET[$pia[$i]] = $pia[$j]; - - $i = $j + 1; -}; - -// -------------------------------------------------------------------------- - -$js = ''; -$modified = array(); - -// -------------------------------------------------------------------------- - -//Aggregate the last modified times of the files -if(isset($groups[$_GET['g']])) -{ - if ( ! is_dir($js_root . 'cache')) + /** + * Makes a call to google closure compiler service + * + * @param array $options - Form parameters + * @return object + */ + protected function closure_call(array $options) { - mkdir($js_root . 'cache'); - } - $cache_file = $js_root.'cache/'.$_GET['g']; + $client = new Client(); + $response = $client->post('http://closure-compiler.appspot.com/compile', [ + 'headers' => [ + 'Accept-Encoding' => 'gzip', + 'Content-type' => 'application/x-www-form-urlencoded' + ], + 'form_params' => $options + ]); - foreach($groups[$_GET['g']] as $file) - { - $new_file = realpath($js_root.$file); - $modified[] = filemtime($new_file); + return $response; } - //Add this page too, as well as the groups file - $modified[] = filemtime($this_file); - $modified[] = filemtime($groups_file); - - $cache_modified = 0; - - //Add the cache file - if(is_file($cache_file)) + /** + * Do a call to the closure compiler to check for compilation errors + * + * @param array $options + * @return void + */ + protected function check_minify_errors($options) { - $cache_modified = filemtime($cache_file); + $error_res = $this->closure_call($options); + $error_json = $error_res->getBody(); + $error_obj = json_decode($error_json) ?: (object)[]; + + // Show error if exists + if ( ! empty($error_obj->errors) || ! empty($error_obj->serverErrors)) + { + $error_json = json_encode($error_obj, JSON_PRETTY_PRINT); + header('Content-type: application/javascript'); + echo "console.error(${error_json});"; + die(); + } + } + + /** + * Get Files + * + * Concatenates the javascript files for the current + * group as a string + * + * @return string + */ + protected function get_files() + { + $js = ''; + + foreach($this->js_group as $file) + { + $new_file = realpath("{$this->js_root}{$file}"); + $js .= file_get_contents($new_file) . "\n\n"; + } + + return $js; + } + + /** + * Get the most recent modified date + * + * @return int + */ + protected function get_last_modified() + { + $modified = array(); + + foreach($this->js_group as $file) + { + $new_file = realpath("{$this->js_root}{$file}"); + $modified[] = filemtime($new_file); + } + + //Add this page too, as well as the groups file + $modified[] = filemtime(__FILE__); + $modified[] = filemtime($this->js_groups_file); + + rsort($modified); + $last_modified = $modified[0]; + + return $last_modified; + } + + /** + * Minifies javascript using google's closure compiler + * + * @param string $js + * @return string + */ + protected function minify($js) + { + $options = [ + 'output_info' => 'errors', + 'output_format' => 'json', + 'compilation_level' => 'SIMPLE_OPTIMIZATIONS', + //'compilation_level' => 'ADVANCED_OPTIMIZATIONS', + 'js_code' => $js, + 'language' => 'ECMASCRIPT6_STRICT', + 'language_out' => 'ECMASCRIPT5_STRICT' + ]; + + // Check for errors + $this->check_minify_errors($options); + + // Now actually retrieve the compiled code + $options['output_info'] = 'compiled_code'; + $res = $this->closure_call($options); + $json = $res->getBody(); + $obj = json_decode($json); + + return $obj->compiledCode; + } + + /** + * Output the minified javascript + * + * @param string $js + * @return void + */ + protected function output($js) + { + $this->send_final_output($js, 'application/javascript', $this->last_modified); } } -else //Nothing to display? Just exit -{ - die("You must specify a group that exists"); -} // -------------------------------------------------------------------------- - -//Get the latest modified date -rsort($modified); -$last_modified = $modified[0]; - -$requested_time=(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) - ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) - : time(); - -// If the browser's cached version is up to date, -// don't resend the file -if($last_modified === $requested_time) -{ - header("HTTP/1.1 304 Not Modified"); - exit(); -} - +// ! Start Minifying // -------------------------------------------------------------------------- -//Determine what to do: rebuild cache, send files as is, or send cache. -// If debug is set, just concatenate -if(isset($_GET['debug'])) -{ - $js = get_files(); -} -else if($cache_modified < $last_modified) -{ - $js = google_min(get_files()); +$config = require_once('../app/config/minify_config.php'); +$groups = require_once($config['js_groups_file']); +$cache_dir = "{$config['js_root']}cache"; - //Make sure cache file gets created/updated - if(file_put_contents($cache_file, $js) === FALSE) - { - die("Cache file was not created. Make sure you have the correct folder permissions."); - } -} -// Otherwise, send the cached file -else +if ( ! is_dir($cache_dir)) { - $js = file_get_contents($cache_file); + mkdir($cache_dir); } -// -------------------------------------------------------------------------- +if ( ! array_key_exists($_GET['g'], $groups)) +{ + throw new InvalidArgumentException('You must specify a js group that exists'); +} -//This GZIPs the js for transmission to the user -//making file size smaller and transfer rate quicker -ob_start("ob_gzhandler"); +try +{ + new JSMin($config, $groups); +} +catch (FileNotChangedException $e) +{ + BaseMin::send304(); +} -// Set important caching headers -header("Content-Type: application/javascript; charset=utf8"); -header("Cache-control: public, max-age=691200, must-revalidate"); -header("Last-Modified: ".gmdate('D, d M Y H:i:s', $last_modified)." GMT"); -header("Expires: ".gmdate('D, d M Y H:i:s', (filemtime($this_file) + 691200))." GMT"); - -echo $js; - -ob_end_flush(); //end of js.php \ No newline at end of file diff --git a/public/js/anime_collection.js b/public/js/anime_collection.js index db9c06d0..7132b136 100755 --- a/public/js/anime_collection.js +++ b/public/js/anime_collection.js @@ -1,17 +1,32 @@ -(function($, undefined) { +((_) => { - function search(query, callback) - { - $.get(BASE_URL + 'collection/search', {'query':query}, callback); - } + 'use strict'; - $("#search").on('keypress', $.throttle(750, function(e) { - var query = encodeURIComponent($(this).val()); - search(query, function(res) { - var template = $.templates("#show_list"); - var html = template.render(res); - $('#series_list').html(html); + const search = (tempHtml, query) => { + _.$('.cssload-loader')[0].removeAttribute('hidden'); + _.get(_.url('/collection/search'), {'query':query}, (searchResults, status) => { + searchResults = JSON.parse(searchResults); + _.$('.cssload-loader')[0].setAttribute('hidden', 'hidden'); + + // Give mustache a key to iterate over + searchResults = { + anime: searchResults + }; + + Mustache.parse(tempHtml); + _.$('#series_list')[0].innerHTML = Mustache.render(tempHtml, searchResults); }); - })); + }; -}(jQuery)); \ No newline at end of file + _.get('/public/templates/anime-ajax-search-results.html', tempHtml => { + _.on('#search', 'keyup', _.throttle(250, function(e) { + let query = encodeURIComponent(this.value); + if (query === '') { + return; + } + + search(tempHtml, query); + })); + }); + +})(AnimeClient); \ No newline at end of file diff --git a/public/js/anime_edit.js b/public/js/anime_edit.js index abf82705..c35e930e 100755 --- a/public/js/anime_edit.js +++ b/public/js/anime_edit.js @@ -1,62 +1,58 @@ /** * Javascript for editing anime, if logged in */ -(function($){ +((_) => { - "use strict"; - - if (CONTROLLER !== "anime") return; + 'use strict'; // Action to increment episode count - $(".plus_one").on("click", function(e) { - e.stopPropagation(); + _.on('body.anime.list', 'click', '.plus_one', function(e) { + let this_sel = this; + let parent_sel = _.closestParent(this, 'article'); - var self = this; - var this_sel = $(this); - var parent_sel = $(this).closest("article, td"); - - var watched_count = parseInt(parent_sel.find('.completed_number').text(), 10); - var total_count = parseInt(parent_sel.find('.total_number').text(), 10); - var title = parent_sel.find('.name a').text(); + let watched_count = parseInt(_.$('.completed_number', parent_sel)[0].textContent, 10); + let total_count = parseInt(_.$('.total_number', parent_sel)[0].textContent, 10); + let title = _.$('.name a', parent_sel)[0].textContent; // Setup the update data - var data = { - id: this_sel.parent('article, td').attr('id'), + let data = { + id: parent_sel.id, increment_episodes: true }; // If the episode count is 0, and incremented, // change status to currently watching - if (isNaN(watched_count) || watched_count === 0) - { - data.status = "currently-watching"; + if (isNaN(watched_count) || watched_count === 0) { + data.status = 'currently-watching'; } // If you increment at the last episode, mark as completed - if (( ! isNaN(watched_count)) && (watched_count + 1) === total_count) - { + if (( ! isNaN(watched_count)) && (watched_count + 1) === total_count) { delete data.increment_episodes; - data.status = "completed"; + data.status = 'completed'; } // okay, lets actually make some changes! - $.ajax({ + _.ajax(_.url('/anime/update'), { data: data, dataType: 'json', - method: 'POST', + type: 'POST', mimeType: 'application/json', - url: BASE_URL + CONTROLLER + '/update' - }).done(function(res) { - if (res.status === 'completed') - { - $(self).closest('article, tr').hide(); - } + success: (res) => { + if (res.status === 'completed') { + this.parentElement.addAttribute('hidden', 'hidden'); + } - add_message('success', "Sucessfully updated " + title); - parent_sel.find('.completed_number').text(++watched_count); - }).fail(function() { - add_message('error', "Failed to updated " + title); + _.showMessage('success', `Sucessfully updated ${title}`); + _.$('.completed_number', parent_sel)[0].textContent = ++watched_count; + _.scrollToTop(); + }, + error: (xhr, errorType, error) => { + console.error(error); + _.showMessage('error', `Failed to updated ${title}. `); + _.scrollToTop(); + } }); }); -}(jQuery)); \ No newline at end of file +})(AnimeClient); \ No newline at end of file diff --git a/public/js/base/AnimeClient.js b/public/js/base/AnimeClient.js new file mode 100644 index 00000000..51d84158 --- /dev/null +++ b/public/js/base/AnimeClient.js @@ -0,0 +1,274 @@ +var AnimeClient = (function(w) { + + 'use strict'; + + const slice = Array.prototype.slice; + + // ------------------------------------------------------------------------- + // ! Base + // ------------------------------------------------------------------------- + + function matches(elm, selector) { + let matches = (elm.document || elm.ownerDocument).querySelectorAll(selector), + i = matches.length; + while (--i >= 0 && matches.item(i) !== elm); + return i > -1; + } + + const _ = { + /** + * Placeholder function + */ + noop: () => {}, + /** + * DOM selector + * + * @param {string} selector - The dom selector string + * @param {object} context + * @return {array} - array of dom elements + */ + $(selector, context) { + if (typeof selector != "string" || selector === undefined) { + return selector; + } + + context = (context != null && context.nodeType === 1) + ? context + : document; + + let elements = []; + if (selector.match(/^#([\w]+$)/)) { + elements.push(document.getElementById(selector.split('#')[1])); + } else { + elements = slice.apply(context.querySelectorAll(selector)); + } + + return elements; + }, + /** + * Scroll to the top of the Page + * + * @return {void} + */ + scrollToTop() { + w.scroll(0,0); + }, + /** + * Display a message box + * + * @param {String} type - message type: info, error, success + * @param {String} message - the message itself + * @return {void} + */ + showMessage(type, message) { + let template = + `
+ + ${message} + +
`; + + let sel = AnimeClient.$('.message')[0]; + if (sel !== undefined) { + sel.innerHTML = template; + sel.removeAttribute('hidden'); + } else { + _.$('header')[0].insertAdjacentHTML('beforeend', template); + } + }, + /** + * Finds the closest parent element matching the passed selector + * + * @param {DOMElement} current - the current DOMElement + * @param {string} parentSelector - selector for the parent element + * @return {DOMElement|null} - the parent element + */ + closestParent(current, parentSelector) { + if (Element.prototype.closest !== undefined) { + return current.closest(parentSelector); + } + + while (current !== document.documentElement) { + if (matches(current, parentSelector)) { + return current; + } + + current = current.parentElement; + } + + return null; + }, + /** + * Generate a full url from a relative path + * + * @param {String} path - url path + * @return {String} - full url + */ + url(path) { + let uri = `//${document.location.host}`; + uri += (path.charAt(0) === '/') ? path : `/${path}`; + + return uri; + }, + /** + * Throttle execution of a function + * + * @see https://remysharp.com/2010/07/21/throttling-function-calls + * @see https://jsfiddle.net/jonathansampson/m7G64/ + * @param {Number} interval - the minimum throttle time in ms + * @param {Function} fn - the function to throttle + * @param {Object} scope - the 'this' object for the function + * @return {void} + */ + throttle(interval, fn, scope) { + var wait = false; + return function () { + var context = scope || this; + var args = arguments; + + if ( ! wait) { + fn.apply(context, args); + wait = true; + setTimeout(function() { + wait = false; + }, interval); + } + }; + }, + }; + + // ------------------------------------------------------------------------- + // ! Events + // ------------------------------------------------------------------------- + + function addEvent(sel, event, listener) { + // Recurse! + if (! event.match(/^([\w\-]+)$/)) { + event.split(' ').forEach((evt) => { + addEvent(sel, evt, listener); + }); + } + + sel.addEventListener(event, listener, false); + } + + function delegateEvent(sel, target, event, listener) { + // Attach the listener to the parent + addEvent(sel, event, (e) => { + // Get live version of the target selector + _.$(target, sel).forEach((element) => { + if(e.target == element) { + listener.call(element, e); + e.stopPropagation(); + } + }); + }); + } + + _.on = function (sel, event, target, listener) { + if (arguments.length === 3) { + listener = target; + _.$(sel).forEach((el) => { + addEvent(el, event, listener); + }); + } else { + _.$(sel).forEach((el) => { + delegateEvent(el, target, event, listener); + }); + } + } + + // ------------------------------------------------------------------------- + // ! Ajax + // ------------------------------------------------------------------------- + + /** + * Url encoding for non-get requests + * + * @param data + * @returns {string} + * @private + */ + function ajaxSerialize(data) { + let pairs = []; + + Object.keys(data).forEach((name) => { + let value = data[name].toString(); + + name = encodeURIComponent(name); + value = encodeURIComponent(value); + + pairs.push(`${name}=${value}`); + }); + + return pairs.join("&"); + }; + + _.ajax = function(url, config) { + // Set some sane defaults + config = config || {}; + config.data = config.data || {}; + config.type = config.type || 'GET'; + config.dataType = config.dataType || ''; + config.success = config.success || _.noop; + config.error = config.error || _.noop; + + let request = new XMLHttpRequest(); + let method = String(config.type).toUpperCase(); + + if (method === "GET") { + url += (url.match(/\?/)) + ? ajaxSerialize(config.data) + : `?${ajaxSerialize(config.data)}`; + } + + request.open(method, url); + + request.onreadystatechange = () => { + if (request.readyState === 4) { + let responseText = ''; + + if (request.responseType == 'json') { + responseText = JSON.parse(request.responseText); + } else { + responseText = request.responseText; + } + + if (request.status > 400) { + config.error.call(null, request.status, responseText, request.response); + } else { + config.success.call(null, responseText, request.status); + } + } + }; + + switch (method) { + case "GET": + request.send(null); + break; + + default: + request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + request.send(ajaxSerialize(config.data)); + break; + } + }; + + _.get = function(url, data, callback) { + if (arguments.length === 2) { + callback = data; + data = {}; + } + + return _.ajax(url, { + data: data, + success: callback + }); + }; + + // ------------------------------------------------------------------------- + // Export + // ------------------------------------------------------------------------- + + return _; +})(window); \ No newline at end of file diff --git a/public/js/base/classList.js b/public/js/base/classList.js new file mode 100644 index 00000000..86875d12 --- /dev/null +++ b/public/js/base/classList.js @@ -0,0 +1,227 @@ +/* + * classList.js: Cross-browser full element.classList implementation. + * 2014-07-23 + * + * By Eli Grey, http://eligrey.com + * Public Domain. + * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. + */ + +/*global self, document, DOMException */ + +/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/ + +if ("document" in self) { + + // Full polyfill for browsers with no classList support + if (!("classList" in document.createElement("_"))) { + + (function(view) { + + "use strict"; + + if (!('Element' in view)) return; + + var + classListProp = "classList", + protoProp = "prototype", + elemCtrProto = view.Element[protoProp], + objCtr = Object, + strTrim = String[protoProp].trim || function() { + return this.replace(/^\s+|\s+$/g, ""); + }, + arrIndexOf = Array[protoProp].indexOf || function(item) { + var + i = 0, + len = this.length; + for (; i < len; i++) { + if (i in this && this[i] === item) { + return i; + } + } + return -1; + } + // Vendors: please allow content code to instantiate DOMExceptions + , + DOMEx = function(type, message) { + this.name = type; + this.code = DOMException[type]; + this.message = message; + }, + checkTokenAndGetIndex = function(classList, token) { + if (token === "") { + throw new DOMEx( + "SYNTAX_ERR", "An invalid or illegal string was specified" + ); + } + if (/\s/.test(token)) { + throw new DOMEx( + "INVALID_CHARACTER_ERR", "String contains an invalid character" + ); + } + return arrIndexOf.call(classList, token); + }, + ClassList = function(elem) { + var + trimmedClasses = strTrim.call(elem.getAttribute("class") || ""), + classes = trimmedClasses ? trimmedClasses.split(/\s+/) : [], + i = 0, + len = classes.length; + for (; i < len; i++) { + this.push(classes[i]); + } + this._updateClassName = function() { + elem.setAttribute("class", this.toString()); + }; + }, + classListProto = ClassList[protoProp] = [], + classListGetter = function() { + return new ClassList(this); + }; + // Most DOMException implementations don't allow calling DOMException's toString() + // on non-DOMExceptions. Error's toString() is sufficient here. + DOMEx[protoProp] = Error[protoProp]; + classListProto.item = function(i) { + return this[i] || null; + }; + classListProto.contains = function(token) { + token += ""; + return checkTokenAndGetIndex(this, token) !== -1; + }; + classListProto.add = function() { + var + tokens = arguments, + i = 0, + l = tokens.length, + token, updated = false; + do { + token = tokens[i] + ""; + if (checkTokenAndGetIndex(this, token) === -1) { + this.push(token); + updated = true; + } + } + while (++i < l); + + if (updated) { + this._updateClassName(); + } + }; + classListProto.remove = function() { + var + tokens = arguments, + i = 0, + l = tokens.length, + token, updated = false, + index; + do { + token = tokens[i] + ""; + index = checkTokenAndGetIndex(this, token); + while (index !== -1) { + this.splice(index, 1); + updated = true; + index = checkTokenAndGetIndex(this, token); + } + } + while (++i < l); + + if (updated) { + this._updateClassName(); + } + }; + classListProto.toggle = function(token, force) { + token += ""; + + var + result = this.contains(token), + method = result ? + force !== true && "remove" : + force !== false && "add"; + + if (method) { + this[method](token); + } + + if (force === true || force === false) { + return force; + } else { + return !result; + } + }; + classListProto.toString = function() { + return this.join(" "); + }; + + if (objCtr.defineProperty) { + var classListPropDesc = { + get: classListGetter, + enumerable: true, + configurable: true + }; + try { + objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); + } catch (ex) { // IE 8 doesn't support enumerable:true + if (ex.number === -0x7FF5EC54) { + classListPropDesc.enumerable = false; + objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); + } + } + } else if (objCtr[protoProp].__defineGetter__) { + elemCtrProto.__defineGetter__(classListProp, classListGetter); + } + + }(self)); + + } else { + // There is full or partial native classList support, so just check if we need + // to normalize the add/remove and toggle APIs. + + (function() { + "use strict"; + + var testElement = document.createElement("_"); + + testElement.classList.add("c1", "c2"); + + // Polyfill for IE 10/11 and Firefox <26, where classList.add and + // classList.remove exist but support only one argument at a time. + if (!testElement.classList.contains("c2")) { + var createMethod = function(method) { + var original = DOMTokenList.prototype[method]; + + DOMTokenList.prototype[method] = function(token) { + var i, len = arguments.length; + + for (i = 0; i < len; i++) { + token = arguments[i]; + original.call(this, token); + } + }; + }; + createMethod('add'); + createMethod('remove'); + } + + testElement.classList.toggle("c3", false); + + // Polyfill for IE 10 and Firefox <24, where classList.toggle does not + // support the second argument. + if (testElement.classList.contains("c3")) { + var _toggle = DOMTokenList.prototype.toggle; + + DOMTokenList.prototype.toggle = function(token, force) { + if (1 in arguments && !this.contains(token) === !force) { + return force; + } else { + return _toggle.call(this, token); + } + }; + + } + + testElement = null; + }()); + + } + +} \ No newline at end of file diff --git a/public/js/base/events.js b/public/js/base/events.js new file mode 100644 index 00000000..22fc3715 --- /dev/null +++ b/public/js/base/events.js @@ -0,0 +1,13 @@ +/** + * Event handlers + */ +((ac) => { + + 'use strict'; + + // Close event for messages + ac.on('header', 'click', '.message', function () { + this.setAttribute('hidden', 'hidden'); + }); + +})(AnimeClient); \ No newline at end of file diff --git a/public/js/base/sort_tables.js b/public/js/base/sort_tables.js new file mode 100644 index 00000000..2251d265 --- /dev/null +++ b/public/js/base/sort_tables.js @@ -0,0 +1,75 @@ +const LightTableSorter = (function() { + let _cellIndex, _onClickEvent, _order, _reset, _sort, _text, _th, _toggle; + _th = null; + _cellIndex = null; + _order = ''; + _text = function(row) { + return row.cells.item(_cellIndex).textContent.toLowerCase(); + }; + _sort = function(a, b) { + let n, textA, textB; + textA = _text(a); + textB = _text(b); + n = parseInt(textA, 10); + if (n) { + textA = n; + textB = parseInt(textB, 10); + } + if (textA > textB) { + return 1; + } + if (textA < textB) { + return -1; + } + return 0; + }; + _toggle = function() { + let c; + c = _order !== 'sorting_asc' ? 'sorting_asc' : 'sorting_desc'; + _th.className = (_th.className.replace(_order, '') + ' ' + c).trim(); + return _order = c; + }; + _reset = function() { + _th.className = _th.className.replace('sorting_asc', 'sorting').replace('sorting_desc', 'sorting'); + return _order = ''; + }; + _onClickEvent = function(e) { + let row, rows, tbody, _i, _len; + if (_th && (_cellIndex !== e.target.cellIndex)) { + _reset(); + } + _th = e.target; + if (_th.nodeName.toLowerCase() === 'th') { + _cellIndex = _th.cellIndex; + tbody = _th.offsetParent.getElementsByTagName('tbody')[0]; + rows = tbody.rows; + if (rows) { + rows = Array.prototype.slice.call(rows, 0); + rows = Array.prototype.sort.call(rows, _sort); + if (_order === 'sorting_asc') { + Array.prototype.reverse.call(rows); + } + _toggle(); + tbody.innerHtml = ''; + for (_i = 0, _len = rows.length; _i < _len; _i++) { + row = rows[_i]; + tbody.appendChild(row); + } + } + } + }; + return { + init: function() { + let ths = document.getElementsByTagName('th'); + let _results = []; + for (let _i = 0, _len = ths.length; _i < _len; _i++) { + let th = ths[_i]; + th.className = 'sorting'; + _results.push(th.onclick = _onClickEvent); + } + return _results; + } + }; +})(); + +LightTableSorter.init(); \ No newline at end of file diff --git a/public/js/lib/jquery.min.js b/public/js/lib/jquery.min.js deleted file mode 100644 index 0531951b..00000000 --- a/public/js/lib/jquery.min.js +++ /dev/null @@ -1 +0,0 @@ - /*! jQuery v2.1.4 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */ !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.4",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b="length"in a&&a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,aa=/[+~]/,ba=/'|\\/g,ca=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),da=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ea=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fa){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(ba,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+ra(o[l]);w=aa.test(a)&&pa(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",ea,!1):e.attachEvent&&e.attachEvent("onunload",ea)),p=!f(g),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?la(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ca,da),a[3]=(a[3]||a[4]||a[5]||"").replace(ca,da),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ca,da).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(ca,da),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return W.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(ca,da).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:oa(function(){return[0]}),last:oa(function(a,b){return[b-1]}),eq:oa(function(a,b,c){return[0>c?c+b:c]}),even:oa(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:oa(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:oa(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:oa(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function sa(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function ta(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ua(a,b,c){for(var d=0,e=b.length;e>d;d++)ga(a,b[d],c);return c}function va(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wa(a,b,c,d,e,f){return d&&!d[u]&&(d=wa(d)),e&&!e[u]&&(e=wa(e,f)),ia(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ua(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:va(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=va(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=va(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sa(function(a){return a===b},h,!0),l=sa(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sa(ta(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wa(i>1&&ta(m),i>1&&ra(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xa(a.slice(i,e)),f>e&&xa(a=a.slice(e)),f>e&&ra(a))}m.push(c)}return ta(m)}function ya(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=va(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&ga.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xa(b[c]),f[u]?d.push(f):e.push(f);f=A(a,ya(e,d)),f.selector=a}return f},i=ga.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(ca,da),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(ca,da),aa.test(j[0].type)&&pa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&ra(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,aa.test(a)&&pa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ja(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+K.uid++}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){ return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthx",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,ba=/<([\w:]+)/,ca=/<|&#?\w+;/,da=/<(?:script|style|link)/i,ea=/checked\s*(?:[^=]|=\s*.checked.)/i,fa=/^$|\/(?:java|ecma)script/i,ga=/^true\/(.*)/,ha=/^\s*\s*$/g,ia={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ia.optgroup=ia.option,ia.tbody=ia.tfoot=ia.colgroup=ia.caption=ia.thead,ia.th=ia.td;function ja(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function ka(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function la(a){var b=ga.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function ma(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function na(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function oa(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pa(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=oa(h),f=oa(a),d=0,e=f.length;e>d;d++)pa(f[d],g[d]);if(b)if(c)for(f=f||oa(a),g=g||oa(h),d=0,e=f.length;e>d;d++)na(f[d],g[d]);else na(a,h);return g=oa(h,"script"),g.length>0&&ma(g,!i&&oa(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(ca.test(e)){f=f||k.appendChild(b.createElement("div")),g=(ba.exec(e)||["",""])[1].toLowerCase(),h=ia[g]||ia._default,f.innerHTML=h[1]+e.replace(aa,"<$1>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=oa(k.appendChild(e),"script"),i&&ma(f),c)){j=0;while(e=f[j++])fa.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=ja(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=ja(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(oa(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&ma(oa(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(oa(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!da.test(a)&&!ia[(ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(aa,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(oa(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(oa(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&ea.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(oa(c,"script"),ka),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,oa(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,la),j=0;g>j;j++)h=f[j],fa.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(ha,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qa,ra={};function sa(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function ta(a){var b=l,c=ra[a];return c||(c=sa(a,b),"none"!==c&&c||(qa=(qa||n("