commit 8ed526716fb534d8e35d43c913b2a1a832b3935d Author: Luke Barratt Date: Sun Mar 23 00:22:25 2014 +0000 Purged git history and removed sensitive information. diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..dd3e343 --- /dev/null +++ b/.env.sample @@ -0,0 +1,8 @@ +UNICORN_WORKERS=3 +UNICORN_PORT=5000 +UNICORN_SOCKET=/tmp/unicorn.ensl.sock + +APP_SECRET= + +MYSQL_USERNAME= +MYSQL_PASSWORD= diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66465ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,40 @@ +# Rails, etc +/coverage/ +/log/* +/tmp/* +/spec/tmp/* +.env +.tmp* +.rspec +.sass-cache +*.sassc +*.rbc +*.sassc + +# OS X +.DS_Store + +# Assets +/public/system/* +/public/files +/public/files/* +/public/local + +# RubyMine +/.idea + +# VIM +**.swp + +# Git junk +**.orig + +# Bundler +/.bundle +/vendor/bundle/ +.bundle + +# Misc +/index/* +rerun.txt +pickle-email-*.html diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..3e3c2f1 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.1.1 diff --git a/Capfile b/Capfile new file mode 100644 index 0000000..e429c17 --- /dev/null +++ b/Capfile @@ -0,0 +1,7 @@ +require 'capistrano/setup' +require 'capistrano/deploy' +require 'capistrano/rbenv' +require 'capistrano/bundler' +require 'capistrano/rails' + +Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r } diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..bc04c2c --- /dev/null +++ b/Gemfile @@ -0,0 +1,52 @@ +source 'http://rubygems.org' + +ruby '2.1.1' + +gem 'rails', '~> 3.2.16' +gem 'mysql2', '~> 0.3.15' + +# Deployment +gem 'foreman', '~> 0.63.0' +gem 'capistrano', '~> 3.1.0' +gem 'capistrano-rbenv', '~> 2.0.2' +gem 'capistrano-bundler', '~> 1.1.2' +gem 'capistrano-rails', '~> 1.1' + +# Libraries +gem 'jquery-rails' +gem 'sass-rails' +gem 'coffee-rails' +gem 'gruff' +gem 'nokogiri' +gem 'carrierwave' +gem 'rbbcode' +gem 'tinymce-rails' +gem 'bluecloth', '~> 2.2.0' +gem 'bb-ruby' +gem 'therubyracer' +gem 'acts_as_indexed' +gem 'rmagick', require: false +gem 'will_paginate', git: 'https://github.com/p7r/will_paginate.git', branch: 'rails3' +gem 'newrelic_rpm', '~> 3.7.2.195' + +group 'staging', 'production' do + gem 'unicorn', '~> 4.8.2' +end + +group 'development' do + gem 'annotate', '~> 2.6.2' +end + +group 'test' do + gem 'simplecov', '~> 0.7.1', require: false + gem 'rspec-rails', '~> 2.14.1' + gem 'rspec-given', '~> 3.5.4' + gem 'capybara', '~> 2.2.1' + gem 'poltergeist', '~> 1.5.0' + gem 'factory_girl_rails', '~> 4.4.1' +end + +group 'development', 'test' do + gem 'pry-debugger', '~> 0.2.2' + gem 'dotenv-rails', '~> 0.10.0' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..1958746 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,275 @@ +GIT + remote: https://github.com/p7r/will_paginate.git + revision: 53d1da6da003dc172ee054e4cc416d0723f00b88 + branch: rails3 + specs: + will_paginate (3.0.pre3) + +GEM + remote: http://rubygems.org/ + specs: + actionmailer (3.2.17) + actionpack (= 3.2.17) + mail (~> 2.5.4) + actionpack (3.2.17) + activemodel (= 3.2.17) + activesupport (= 3.2.17) + builder (~> 3.0.0) + erubis (~> 2.7.0) + journey (~> 1.0.4) + rack (~> 1.4.5) + rack-cache (~> 1.2) + rack-test (~> 0.6.1) + sprockets (~> 2.2.1) + activemodel (3.2.17) + activesupport (= 3.2.17) + builder (~> 3.0.0) + activerecord (3.2.17) + activemodel (= 3.2.17) + activesupport (= 3.2.17) + arel (~> 3.0.2) + tzinfo (~> 0.3.29) + activeresource (3.2.17) + activemodel (= 3.2.17) + activesupport (= 3.2.17) + activesupport (3.2.17) + i18n (~> 0.6, >= 0.6.4) + multi_json (~> 1.0) + acts_as_indexed (0.7.8) + annotate (2.6.2) + activerecord (>= 2.3.0) + rake (>= 0.8.7) + arel (3.0.3) + bb-ruby (0.9.5) + bluecloth (2.2.0) + builder (3.0.4) + capistrano (3.1.0) + i18n + rake (>= 10.0.0) + sshkit (~> 1.3) + capistrano-bundler (1.1.2) + capistrano (~> 3.0) + sshkit (~> 1.2) + capistrano-rails (1.1.1) + capistrano (~> 3.1) + capistrano-bundler (~> 1.1) + capistrano-rbenv (2.0.2) + capistrano (~> 3.1) + sshkit (~> 1.3) + capybara (2.2.1) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) + carrierwave (0.6.2) + activemodel (>= 3.2.0) + activesupport (>= 3.2.0) + cliver (0.3.2) + coderay (1.1.0) + coffee-rails (3.2.2) + coffee-script (>= 2.2.0) + railties (~> 3.2.0) + coffee-script (2.2.0) + coffee-script-source + execjs + coffee-script-source (1.3.3) + columnize (0.3.6) + debugger (1.6.6) + columnize (>= 0.3.1) + debugger-linecache (~> 1.2.0) + debugger-ruby_core_source (~> 1.3.2) + debugger-linecache (1.2.0) + debugger-ruby_core_source (1.3.2) + diff-lcs (1.2.5) + dotenv (0.10.0) + dotenv-rails (0.10.0) + dotenv (= 0.10.0) + erubis (2.7.0) + execjs (1.4.0) + multi_json (~> 1.0) + factory_girl (4.4.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.4.1) + factory_girl (~> 4.4.0) + railties (>= 3.0.0) + foreman (0.63.0) + dotenv (>= 0.7) + thor (>= 0.13.6) + foreman (0.63.0-x86-mingw32) + dotenv (>= 0.7) + thor (>= 0.13.6) + win32console (~> 1.3.0) + given_core (3.5.4) + sorcerer (>= 0.3.7) + gruff (0.3.6) + hike (1.2.3) + i18n (0.6.9) + journey (1.0.4) + jquery-rails (2.0.2) + railties (>= 3.2.0, < 5.0) + thor (~> 0.14) + json (1.8.1) + kgio (2.9.2) + libv8 (3.16.14.3) + mail (2.5.4) + mime-types (~> 1.16) + treetop (~> 1.4.8) + method_source (0.8.2) + mime-types (1.25.1) + multi_json (1.8.4) + mysql2 (0.3.15) + net-scp (1.1.2) + net-ssh (>= 2.6.5) + net-ssh (2.8.0) + newrelic_rpm (3.7.2.195) + nokogiri (1.5.5) + nokogiri (1.5.5-x86-mingw32) + poltergeist (1.5.0) + capybara (~> 2.1) + cliver (~> 0.3.1) + multi_json (~> 1.0) + websocket-driver (>= 0.2.0) + polyglot (0.3.4) + pry (0.9.12.6) + coderay (~> 1.0) + method_source (~> 0.8) + slop (~> 3.4) + pry (0.9.12.6-x86-mingw32) + coderay (~> 1.0) + method_source (~> 0.8) + slop (~> 3.4) + win32console (~> 1.3) + pry-debugger (0.2.2) + debugger (~> 1.3) + pry (~> 0.9.10) + rack (1.4.5) + rack-cache (1.2) + rack (>= 0.4) + rack-ssl (1.3.3) + rack + rack-test (0.6.2) + rack (>= 1.0) + rails (3.2.17) + actionmailer (= 3.2.17) + actionpack (= 3.2.17) + activerecord (= 3.2.17) + activeresource (= 3.2.17) + activesupport (= 3.2.17) + bundler (~> 1.0) + railties (= 3.2.17) + railties (3.2.17) + actionpack (= 3.2.17) + activesupport (= 3.2.17) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (>= 0.14.6, < 2.0) + raindrops (0.13.0) + rake (10.1.1) + rbbcode (0.1.11) + sanitize-url (>= 0.1.3) + rdoc (3.12.2) + json (~> 1.4) + ref (1.0.5) + rmagick (2.13.1) + rspec (2.14.1) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) + rspec-core (2.14.8) + rspec-expectations (2.14.5) + diff-lcs (>= 1.1.3, < 2.0) + rspec-given (3.5.4) + given_core (= 3.5.4) + rspec (>= 2.12) + rspec-mocks (2.14.6) + rspec-rails (2.14.1) + actionpack (>= 3.0) + activemodel (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) + sanitize-url (0.1.4) + sass (3.1.20) + sass-rails (3.2.5) + railties (~> 3.2.0) + sass (>= 3.1.10) + tilt (~> 1.3) + simplecov (0.7.1) + multi_json (~> 1.0) + simplecov-html (~> 0.7.1) + simplecov-html (0.7.1) + slop (3.4.7) + sorcerer (1.0.2) + sprockets (2.2.2) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sshkit (1.3.0) + net-scp (>= 1.1.2) + net-ssh + term-ansicolor + term-ansicolor (1.3.0) + tins (~> 1.0) + therubyracer (0.12.1) + libv8 (~> 3.16.14.0) + ref + thor (0.18.1) + tilt (1.4.1) + tins (1.0.1) + tinymce-rails (3.5.4.1) + railties (>= 3.1.1) + treetop (1.4.15) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.38) + unicorn (4.8.2) + kgio (~> 2.6) + rack + raindrops (~> 0.7) + websocket-driver (0.3.2) + win32console (1.3.2-x86-mingw32) + xpath (2.0.0) + nokogiri (~> 1.3) + +PLATFORMS + ruby + x86-mingw32 + +DEPENDENCIES + acts_as_indexed + annotate (~> 2.6.2) + bb-ruby + bluecloth (~> 2.2.0) + capistrano (~> 3.1.0) + capistrano-bundler (~> 1.1.2) + capistrano-rails (~> 1.1) + capistrano-rbenv (~> 2.0.2) + capybara (~> 2.2.1) + carrierwave + coffee-rails + dotenv-rails (~> 0.10.0) + factory_girl_rails (~> 4.4.1) + foreman (~> 0.63.0) + gruff + jquery-rails + mysql2 (~> 0.3.15) + newrelic_rpm (~> 3.7.2.195) + nokogiri + poltergeist (~> 1.5.0) + pry-debugger (~> 0.2.2) + rails (~> 3.2.16) + rbbcode + rmagick + rspec-given (~> 3.5.4) + rspec-rails (~> 2.14.1) + sass-rails + simplecov (~> 0.7.1) + therubyracer + tinymce-rails + unicorn (~> 4.8.2) + will_paginate! diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..d523066 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,51 @@ +# Ubuntu 13.10 x64 + +## Capistrano setup + +SSH as root, and install the basics + + sudo apt-get update + sudo apt-get upgrade + +Create a deploy user. Disable password authentication and add it to the www-data group. + + sudo adduser deploy + sudo passwd -l deploy + sudo usermod -a -G www-data deploy + +Add the following to `/etc/sudoers` to allow the `deploy` user to manage nginx and foreman via sudo without a password + + # /etc/sudoers + Cmnd_Alias START_FOREMAN = /sbin/start foreman + + deploy ALL=NOPASSWD:START_FOREMAN + deploy ALL=NOPASSWD:/etc/init.d/nginx + +## Install rbenv, ruby and bundler + +As root, install dependencies + + sudo apt-get install nginx git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libmysql-ruby libmysqlclient-dev + +Switch user to deploy, and install rbenv + + su deploy + cd ~ + git clone git://github.com/sstephenson/rbenv.git .rbenv + echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc + echo 'eval "$(rbenv init -)"' >> ~/.bashrc + exec $SHELL + + git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build + echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc + exec $SHELL + + rbenv install 2.1.1 + rbenv global 2.1.1 + + echo "gem: --no-ri --no-rdoc" > ~/.gemrc + gem install bundler + +## Install the ENSL site + + mkdir /var/www/virtual/ensl.org/deploy \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..15b018e --- /dev/null +++ b/LICENSE.md @@ -0,0 +1 @@ +Copyright 2014 ENSL.org \ No newline at end of file diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..02d328f --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: bundle exec unicorn -p $UNICORN_PORT -l $UNICORN_SOCKET -c ./config/unicorn.rb \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..476538e --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# ENSL Website + +This is the source code of ENSL website. Currently deployed on [European NS League](http://www.ensl.org). + +Features: + +- Articles +- Commenting feature for most objects +- Movie database +- File database +- ENSL Plugin API +- Forums, usual forum features and ACL +- Contest management + - Teams and team member management + - Brackets + - Tournaments + - Match database + - Challenging system +- Instant webchat (shoutbox) +- Private messages +- Issue management +- Very popular AJAX-based pick-up system +- Map database +- Votable polls +- Twitter feed +- Server database and RCON interface +- Log file parsing (partially complete) + +## Contributors + +- [Ari Timonen](https://github.com/jirikivaari) - Original author +- [Florent Latombe](https://github.com/flatombe) - Improvements +- [Luke Barratt](https://github.com/lbarratt) - Improvements diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..a77116d --- /dev/null +++ b/Rakefile @@ -0,0 +1,13 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + + + +require File.expand_path('../config/application', __FILE__) + +require 'rake/dsl_definition' +require 'rake' +require 'rake/testtask' +require 'rake/task' + +Ensl::Application.load_tasks \ No newline at end of file diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 0000000..4919a9c --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,15 @@ +// This is a manifest file that'll be compiled into including all the files listed below. +// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically +// be included in the compiled file accessible from http://example.com/assets/application.js +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +//= require jquery +//= require jquery_ujs +//= require jquery.periodicalupdater +//= require jquery.jplayer.min +//= require flowplayer +//= require tinymce-jquery +//= require yetii +//= require local + diff --git a/app/assets/javascripts/flowplayer.js b/app/assets/javascripts/flowplayer.js new file mode 100644 index 0000000..9d8b28a --- /dev/null +++ b/app/assets/javascripts/flowplayer.js @@ -0,0 +1,24 @@ +/* + * flowplayer.js 3.1.3. The Flowplayer API + * + * Copyright 2009 Flowplayer Oy + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see . + * + * Date: 2009-02-25 16:24:29 -0500 (Wed, 25 Feb 2009) + * Revision: 166 + */ +(function(){function g(o){console.log("$f.fireEvent",[].slice.call(o))}function k(q){if(!q||typeof q!="object"){return q}var o=new q.constructor();for(var p in q){if(q.hasOwnProperty(p)){o[p]=k(q[p])}}return o}function m(t,q){if(!t){return}var o,p=0,r=t.length;if(r===undefined){for(o in t){if(q.call(t[o],o,t[o])===false){break}}}else{for(var s=t[0];p1){var r=arguments[1];var q=(arguments.length==3)?arguments[2]:{};if(typeof o=="string"){if(o.indexOf(".")!=-1){var t=[];m(n(o),function(){t.push(new b(this,k(r),k(q)))});return new d(t)}else{var s=c(o);return new b(s!==null?s:o,r,q)}}else{if(o){return new b(o,r,q)}}}return null};i(window.$f,{fireEvent:function(){var o=[].slice.call(arguments);var q=$f(o[0]);return q?q._fireEvent(o.slice(1)):null},addPlugin:function(o,p){b.prototype[o]=p;return $f},each:m,extend:i});if(typeof jQuery=="function"){jQuery.prototype.flowplayer=function(q,p){if(!arguments.length||typeof arguments[0]=="number"){var o=[];this.each(function(){var r=$f(this);if(r){o.push(r)}});return arguments.length?o[arguments[0]]:new d(o)}return this.each(function(){$f(this,k(q),p?k(p):{})})}}})();(function(){var e=typeof jQuery=="function";var i={width:"100%",height:"100%",allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:null,onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(e){jQuery.tools=jQuery.tools||{};jQuery.tools.flashembed={version:"1.0.4",conf:i}}function j(){if(c.done){return false}var l=document;if(l&&l.getElementsByTagName&&l.getElementById&&l.body){clearInterval(c.timer);c.timer=null;for(var k=0;k'}q.width=q.height=q.id=q.w3c=q.src=null;for(var l in q){if(q[l]!==null){n+=''}}var o="";if(t){for(var m in t){if(t[m]!==null){o+=m+"="+(typeof t[m]=="object"?g(t[m]):t[m])+"&"}}o=o.substring(0,o.length-1);n+='"}n+="";return n}function d(m,p,l){var k=flashembed.getVersion();f(this,{getContainer:function(){return m},getConf:function(){return p},getVersion:function(){return k},getFlashvars:function(){return l},getApi:function(){return m.firstChild},getHTML:function(){return a(p,l)}});var q=p.version;var r=p.expressInstall;var o=!q||flashembed.isSupported(q);if(o){p.onFail=p.version=p.expressInstall=null;m.innerHTML=a(p,l)}else{if(q&&r&&flashembed.isSupported([6,65])){f(p,{src:r});l={MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title};m.innerHTML=a(p,l)}else{if(m.innerHTML.replace(/\s/g,"")!==""){}else{m.innerHTML="

Flash version "+q+" or greater is required

"+(k[0]>0?"Your version is "+k:"You have no flash plugin installed")+"

"+(m.tagName=="A"?"

Click here to download latest version

":"

Download latest version from here

");if(m.tagName=="A"){m.onclick=function(){location.href="http://www.adobe.com/go/getflashplayer"}}}}}if(!o&&p.onFail){var n=p.onFail.call(this);if(typeof n=="string"){m.innerHTML=n}}if(document.all){window[p.id]=document.getElementById(p.id)}}window.flashembed=function(l,m,k){if(typeof l=="string"){var n=document.getElementById(l);if(n){l=n}else{c(function(){flashembed(l,m,k)});return}}if(!l){return}if(typeof m=="string"){m={src:m}}var o=f({},i);f(o,m);return new d(l,o,k)};f(window.flashembed,{getVersion:function(){var m=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var l=navigator.plugins["Shockwave Flash"].description;if(typeof l!="undefined"){l=l.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var n=parseInt(l.replace(/^(.*)\..*$/,"$1"),10);var r=/r/.test(l)?parseInt(l.replace(/^.*r(.*)$/,"$1"),10):0;m=[n,r]}}else{if(window.ActiveXObject){try{var p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(q){try{p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");m=[6,0];p.AllowScriptAccess="always"}catch(k){if(m[0]==6){return m}}try{p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(o){}}if(typeof p=="object"){l=p.GetVariable("$version");if(typeof l!="undefined"){l=l.replace(/^\S+\s+(.*)$/,"$1").split(",");m=[parseInt(l[0],10),parseInt(l[2],10)]}}}}return m},isSupported:function(k){var m=flashembed.getVersion();var l=(m[0]>k[0])||(m[0]==k[0]&&m[1]>=k[1]);return l},domReady:c,asString:g,getHTML:a});if(e){jQuery.fn.flashembed=function(l,k){var m=null;this.each(function(){m=flashembed(this,l,k)});return l.api===false?this:m}}})(); \ No newline at end of file diff --git a/app/assets/javascripts/jquery.jplayer.min.js b/app/assets/javascripts/jquery.jplayer.min.js new file mode 100644 index 0000000..bcf7901 --- /dev/null +++ b/app/assets/javascripts/jquery.jplayer.min.js @@ -0,0 +1,97 @@ +/* + * jPlayer Plugin for jQuery JavaScript Library + * http://www.jplayer.org + * + * Copyright (c) 2009 - 2011 Happyworm Ltd + * Dual licensed under the MIT and GPL licenses. + * - http://www.opensource.org/licenses/mit-license.php + * - http://www.gnu.org/copyleft/gpl.html + * + * Author: Mark J Panaghiston + * Version: 2.1.0 + * Date: 1st September 2011 + */ + +(function(b,f){b.fn.jPlayer=function(a){var c=typeof a==="string",d=Array.prototype.slice.call(arguments,1),e=this,a=!c&&d.length?b.extend.apply(null,[!0,a].concat(d)):a;if(c&&a.charAt(0)==="_")return e;c?this.each(function(){var c=b.data(this,"jPlayer"),h=c&&b.isFunction(c[a])?c[a].apply(c,d):c;if(h!==c&&h!==f)return e=h,!1}):this.each(function(){var c=b.data(this,"jPlayer");c?c.option(a||{}):b.data(this,"jPlayer",new b.jPlayer(a,this))});return e};b.jPlayer=function(a,c){if(arguments.length){this.element= +b(c);this.options=b.extend(!0,{},this.options,a);var d=this;this.element.bind("remove.jPlayer",function(){d.destroy()});this._init()}};b.jPlayer.emulateMethods="load play pause";b.jPlayer.emulateStatus="src readyState networkState currentTime duration paused ended playbackRate";b.jPlayer.emulateOptions="muted volume";b.jPlayer.reservedEvent="ready flashreset resize repeat error warning";b.jPlayer.event={ready:"jPlayer_ready",flashreset:"jPlayer_flashreset",resize:"jPlayer_resize",repeat:"jPlayer_repeat", +click:"jPlayer_click",error:"jPlayer_error",warning:"jPlayer_warning",loadstart:"jPlayer_loadstart",progress:"jPlayer_progress",suspend:"jPlayer_suspend",abort:"jPlayer_abort",emptied:"jPlayer_emptied",stalled:"jPlayer_stalled",play:"jPlayer_play",pause:"jPlayer_pause",loadedmetadata:"jPlayer_loadedmetadata",loadeddata:"jPlayer_loadeddata",waiting:"jPlayer_waiting",playing:"jPlayer_playing",canplay:"jPlayer_canplay",canplaythrough:"jPlayer_canplaythrough",seeking:"jPlayer_seeking",seeked:"jPlayer_seeked", +timeupdate:"jPlayer_timeupdate",ended:"jPlayer_ended",ratechange:"jPlayer_ratechange",durationchange:"jPlayer_durationchange",volumechange:"jPlayer_volumechange"};b.jPlayer.htmlEvent="loadstart,abort,emptied,stalled,loadedmetadata,loadeddata,canplay,canplaythrough,ratechange".split(",");b.jPlayer.pause=function(){b.each(b.jPlayer.prototype.instances,function(a,b){b.data("jPlayer").status.srcSet&&b.jPlayer("pause")})};b.jPlayer.timeFormat={showHour:!1,showMin:!0,showSec:!0,padHour:!1,padMin:!0,padSec:!0, +sepHour:":",sepMin:":",sepSec:""};b.jPlayer.convertTime=function(a){var c=new Date(a*1E3),d=c.getUTCHours(),a=c.getUTCMinutes(),c=c.getUTCSeconds(),d=b.jPlayer.timeFormat.padHour&&d<10?"0"+d:d,a=b.jPlayer.timeFormat.padMin&&a<10?"0"+a:a,c=b.jPlayer.timeFormat.padSec&&c<10?"0"+c:c;return(b.jPlayer.timeFormat.showHour?d+b.jPlayer.timeFormat.sepHour:"")+(b.jPlayer.timeFormat.showMin?a+b.jPlayer.timeFormat.sepMin:"")+(b.jPlayer.timeFormat.showSec?c+b.jPlayer.timeFormat.sepSec:"")};b.jPlayer.uaBrowser= +function(a){var a=a.toLowerCase(),b=/(opera)(?:.*version)?[ \/]([\w.]+)/,d=/(msie) ([\w.]+)/,e=/(mozilla)(?:.*? rv:([\w.]+))?/,a=/(webkit)[ \/]([\w.]+)/.exec(a)||b.exec(a)||d.exec(a)||a.indexOf("compatible")<0&&e.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}};b.jPlayer.uaPlatform=function(a){var b=a.toLowerCase(),d=/(android)/,e=/(mobile)/,a=/(ipad|iphone|ipod|android|blackberry|playbook|windows ce|webos)/.exec(b)||[],b=/(ipad|playbook)/.exec(b)||!e.exec(b)&&d.exec(b)||[];a[1]&&(a[1]=a[1].replace(/\s/g, +"_"));return{platform:a[1]||"",tablet:b[1]||""}};b.jPlayer.browser={};b.jPlayer.platform={};var i=b.jPlayer.uaBrowser(navigator.userAgent);if(i.browser)b.jPlayer.browser[i.browser]=!0,b.jPlayer.browser.version=i.version;i=b.jPlayer.uaPlatform(navigator.userAgent);if(i.platform)b.jPlayer.platform[i.platform]=!0,b.jPlayer.platform.mobile=!i.tablet,b.jPlayer.platform.tablet=!!i.tablet;b.jPlayer.prototype={count:0,version:{script:"2.1.0",needFlash:"2.1.0",flash:"unknown"},options:{swfPath:"js",solution:"html, flash", +supplied:"mp3",preload:"metadata",volume:0.8,muted:!1,wmode:"opaque",backgroundColor:"#000000",cssSelectorAncestor:"#jp_container_1",cssSelector:{videoPlay:".jp-video-play",play:".jp-play",pause:".jp-pause",stop:".jp-stop",seekBar:".jp-seek-bar",playBar:".jp-play-bar",mute:".jp-mute",unmute:".jp-unmute",volumeBar:".jp-volume-bar",volumeBarValue:".jp-volume-bar-value",volumeMax:".jp-volume-max",currentTime:".jp-current-time",duration:".jp-duration",fullScreen:".jp-full-screen",restoreScreen:".jp-restore-screen", +repeat:".jp-repeat",repeatOff:".jp-repeat-off",gui:".jp-gui",noSolution:".jp-no-solution"},fullScreen:!1,autohide:{restored:!1,full:!0,fadeIn:200,fadeOut:600,hold:1E3},loop:!1,repeat:function(a){a.jPlayer.options.loop?b(this).unbind(".jPlayerRepeat").bind(b.jPlayer.event.ended+".jPlayer.jPlayerRepeat",function(){b(this).jPlayer("play")}):b(this).unbind(".jPlayerRepeat")},nativeVideoControls:{},noFullScreen:{msie:/msie [0-6]/,ipad:/ipad.*?os [0-4]/,iphone:/iphone/,ipod:/ipod/,android_pad:/android [0-3](?!.*?mobile)/, +android_phone:/android.*?mobile/,blackberry:/blackberry/,windows_ce:/windows ce/,webos:/webos/},noVolume:{ipad:/ipad/,iphone:/iphone/,ipod:/ipod/,android_pad:/android(?!.*?mobile)/,android_phone:/android.*?mobile/,blackberry:/blackberry/,windows_ce:/windows ce/,webos:/webos/,playbook:/playbook/},verticalVolume:!1,idPrefix:"jp",noConflict:"jQuery",emulateHtml:!1,errorAlerts:!1,warningAlerts:!1},optionsAudio:{size:{width:"0px",height:"0px",cssClass:""},sizeFull:{width:"0px",height:"0px",cssClass:""}}, +optionsVideo:{size:{width:"480px",height:"270px",cssClass:"jp-video-270p"},sizeFull:{width:"100%",height:"100%",cssClass:"jp-video-full"}},instances:{},status:{src:"",media:{},paused:!0,format:{},formatType:"",waitForPlay:!0,waitForLoad:!0,srcSet:!1,video:!1,seekPercent:0,currentPercentRelative:0,currentPercentAbsolute:0,currentTime:0,duration:0,readyState:0,networkState:0,playbackRate:1,ended:0},internal:{ready:!1},solution:{html:!0,flash:!0},format:{mp3:{codec:'audio/mpeg; codecs="mp3"',flashCanPlay:!0, +media:"audio"},m4a:{codec:'audio/mp4; codecs="mp4a.40.2"',flashCanPlay:!0,media:"audio"},oga:{codec:'audio/ogg; codecs="vorbis"',flashCanPlay:!1,media:"audio"},wav:{codec:'audio/wav; codecs="1"',flashCanPlay:!1,media:"audio"},webma:{codec:'audio/webm; codecs="vorbis"',flashCanPlay:!1,media:"audio"},fla:{codec:"audio/x-flv",flashCanPlay:!0,media:"audio"},m4v:{codec:'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',flashCanPlay:!0,media:"video"},ogv:{codec:'video/ogg; codecs="theora, vorbis"',flashCanPlay:!1, +media:"video"},webmv:{codec:'video/webm; codecs="vorbis, vp8"',flashCanPlay:!1,media:"video"},flv:{codec:"video/x-flv",flashCanPlay:!0,media:"video"}},_init:function(){var a=this;this.element.empty();this.status=b.extend({},this.status);this.internal=b.extend({},this.internal);this.internal.domNode=this.element.get(0);this.formats=[];this.solutions=[];this.require={};this.htmlElement={};this.html={};this.html.audio={};this.html.video={};this.flash={};this.css={};this.css.cs={};this.css.jq={};this.ancestorJq= +[];this.options.volume=this._limitValue(this.options.volume,0,1);b.each(this.options.supplied.toLowerCase().split(","),function(c,d){var e=d.replace(/^\s+|\s+$/g,"");if(a.format[e]){var f=!1;b.each(a.formats,function(a,b){if(e===b)return f=!0,!1});f||a.formats.push(e)}});b.each(this.options.solution.toLowerCase().split(","),function(c,d){var e=d.replace(/^\s+|\s+$/g,"");if(a.solution[e]){var f=!1;b.each(a.solutions,function(a,b){if(e===b)return f=!0,!1});f||a.solutions.push(e)}});this.internal.instance= +"jp_"+this.count;this.instances[this.internal.instance]=this.element;this.element.attr("id")||this.element.attr("id",this.options.idPrefix+"_jplayer_"+this.count);this.internal.self=b.extend({},{id:this.element.attr("id"),jq:this.element});this.internal.audio=b.extend({},{id:this.options.idPrefix+"_audio_"+this.count,jq:f});this.internal.video=b.extend({},{id:this.options.idPrefix+"_video_"+this.count,jq:f});this.internal.flash=b.extend({},{id:this.options.idPrefix+"_flash_"+this.count,jq:f,swf:this.options.swfPath+ +(this.options.swfPath.toLowerCase().slice(-4)!==".swf"?(this.options.swfPath&&this.options.swfPath.slice(-1)!=="/"?"/":"")+"Jplayer.swf":"")});this.internal.poster=b.extend({},{id:this.options.idPrefix+"_poster_"+this.count,jq:f});b.each(b.jPlayer.event,function(b,c){a.options[b]!==f&&(a.element.bind(c+".jPlayer",a.options[b]),a.options[b]=f)});this.require.audio=!1;this.require.video=!1;b.each(this.formats,function(b,c){a.require[a.format[c].media]=!0});this.options=this.require.video?b.extend(!0, +{},this.optionsVideo,this.options):b.extend(!0,{},this.optionsAudio,this.options);this._setSize();this.status.nativeVideoControls=this._uaBlocklist(this.options.nativeVideoControls);this.status.noFullScreen=this._uaBlocklist(this.options.noFullScreen);this.status.noVolume=this._uaBlocklist(this.options.noVolume);this._restrictNativeVideoControls();this.htmlElement.poster=document.createElement("img");this.htmlElement.poster.id=this.internal.poster.id;this.htmlElement.poster.onload=function(){(!a.status.video|| +a.status.waitForPlay)&&a.internal.poster.jq.show()};this.element.append(this.htmlElement.poster);this.internal.poster.jq=b("#"+this.internal.poster.id);this.internal.poster.jq.css({width:this.status.width,height:this.status.height});this.internal.poster.jq.hide();this.internal.poster.jq.bind("click.jPlayer",function(){a._trigger(b.jPlayer.event.click)});this.html.audio.available=!1;if(this.require.audio)this.htmlElement.audio=document.createElement("audio"),this.htmlElement.audio.id=this.internal.audio.id, +this.html.audio.available=!!this.htmlElement.audio.canPlayType&&this._testCanPlayType(this.htmlElement.audio);this.html.video.available=!1;if(this.require.video)this.htmlElement.video=document.createElement("video"),this.htmlElement.video.id=this.internal.video.id,this.html.video.available=!!this.htmlElement.video.canPlayType&&this._testCanPlayType(this.htmlElement.video);this.flash.available=this._checkForFlash(10);this.html.canPlay={};this.flash.canPlay={};b.each(this.formats,function(b,c){a.html.canPlay[c]= +a.html[a.format[c].media].available&&""!==a.htmlElement[a.format[c].media].canPlayType(a.format[c].codec);a.flash.canPlay[c]=a.format[c].flashCanPlay&&a.flash.available});this.html.desired=!1;this.flash.desired=!1;b.each(this.solutions,function(c,d){if(c===0)a[d].desired=!0;else{var e=!1,f=!1;b.each(a.formats,function(b,c){a[a.solutions[0]].canPlay[c]&&(a.format[c].media==="video"?f=!0:e=!0)});a[d].desired=a.require.audio&&!e||a.require.video&&!f}});this.html.support={};this.flash.support={};b.each(this.formats, +function(b,c){a.html.support[c]=a.html.canPlay[c]&&a.html.desired;a.flash.support[c]=a.flash.canPlay[c]&&a.flash.desired});this.html.used=!1;this.flash.used=!1;b.each(this.solutions,function(c,d){b.each(a.formats,function(b,c){if(a[d].support[c])return a[d].used=!0,!1})});this._resetActive();this._resetGate();this._cssSelectorAncestor(this.options.cssSelectorAncestor);!this.html.used&&!this.flash.used?(this._error({type:b.jPlayer.error.NO_SOLUTION,context:"{solution:'"+this.options.solution+"', supplied:'"+ +this.options.supplied+"'}",message:b.jPlayer.errorMsg.NO_SOLUTION,hint:b.jPlayer.errorHint.NO_SOLUTION}),this.css.jq.noSolution.length&&this.css.jq.noSolution.show()):this.css.jq.noSolution.length&&this.css.jq.noSolution.hide();if(this.flash.used){var c,d="jQuery="+encodeURI(this.options.noConflict)+"&id="+encodeURI(this.internal.self.id)+"&vol="+this.options.volume+"&muted="+this.options.muted;if(b.browser.msie&&Number(b.browser.version)<=8){d=['','','','',''];c=document.createElement('');for(var e=0;e0?100*d/this.status.duration:0;typeof a.seekable==="object"&&a.seekable.length>0?(g=this.status.duration>0?100*a.seekable.end(a.seekable.length-1)/this.status.duration:100,f=100*a.currentTime/a.seekable.end(a.seekable.length-1)):(g=100,f=e);b&&(e=f=d=0);this.status.seekPercent=g;this.status.currentPercentRelative=f;this.status.currentPercentAbsolute=e;this.status.currentTime=d;this.status.readyState=a.readyState;this.status.networkState=a.networkState;this.status.playbackRate= +a.playbackRate;this.status.ended=a.ended},_resetStatus:function(){this.status=b.extend({},this.status,b.jPlayer.prototype.status)},_trigger:function(a,c,d){a=b.Event(a);a.jPlayer={};a.jPlayer.version=b.extend({},this.version);a.jPlayer.options=b.extend(!0,{},this.options);a.jPlayer.status=b.extend(!0,{},this.status);a.jPlayer.html=b.extend(!0,{},this.html);a.jPlayer.flash=b.extend(!0,{},this.flash);if(c)a.jPlayer.error=b.extend({},c);if(d)a.jPlayer.warning=b.extend({},d);this.element.trigger(a)}, +jPlayerFlashEvent:function(a,c){if(a===b.jPlayer.event.ready)if(this.internal.ready){if(this.flash.gate){if(this.status.srcSet){var d=this.status.currentTime,e=this.status.paused;this.setMedia(this.status.media);d>0&&(e?this.pause(d):this.play(d))}this._trigger(b.jPlayer.event.flashreset)}}else this.internal.ready=!0,this.internal.flash.jq.css({width:"0px",height:"0px"}),this.version.flash=c.version,this.version.needFlash!==this.version.flash&&this._error({type:b.jPlayer.error.VERSION,context:this.version.flash, +message:b.jPlayer.errorMsg.VERSION+this.version.flash,hint:b.jPlayer.errorHint.VERSION}),this._trigger(b.jPlayer.event.repeat),this._trigger(a);if(this.flash.gate)switch(a){case b.jPlayer.event.progress:this._getFlashStatus(c);this._updateInterface();this._trigger(a);break;case b.jPlayer.event.timeupdate:this._getFlashStatus(c);this._updateInterface();this._trigger(a);break;case b.jPlayer.event.play:this._seeked();this._updateButtons(!0);this._trigger(a);break;case b.jPlayer.event.pause:this._updateButtons(!1); +this._trigger(a);break;case b.jPlayer.event.ended:this._updateButtons(!1);this._trigger(a);break;case b.jPlayer.event.click:this._trigger(a);break;case b.jPlayer.event.error:this.status.waitForLoad=!0;this.status.waitForPlay=!0;this.status.video&&this.internal.flash.jq.css({width:"0px",height:"0px"});this._validString(this.status.media.poster)&&this.internal.poster.jq.show();this.css.jq.videoPlay.length&&this.status.video&&this.css.jq.videoPlay.show();this.status.video?this._flash_setVideo(this.status.media): +this._flash_setAudio(this.status.media);this._updateButtons(!1);this._error({type:b.jPlayer.error.URL,context:c.src,message:b.jPlayer.errorMsg.URL,hint:b.jPlayer.errorHint.URL});break;case b.jPlayer.event.seeking:this._seeking();this._trigger(a);break;case b.jPlayer.event.seeked:this._seeked();this._trigger(a);break;case b.jPlayer.event.ready:break;default:this._trigger(a)}return!1},_getFlashStatus:function(a){this.status.seekPercent=a.seekPercent;this.status.currentPercentRelative=a.currentPercentRelative; +this.status.currentPercentAbsolute=a.currentPercentAbsolute;this.status.currentTime=a.currentTime;this.status.duration=a.duration;this.status.readyState=4;this.status.networkState=0;this.status.playbackRate=1;this.status.ended=!1},_updateButtons:function(a){if(a!==f)this.status.paused=!a,this.css.jq.play.length&&this.css.jq.pause.length&&(a?(this.css.jq.play.hide(),this.css.jq.pause.show()):(this.css.jq.play.show(),this.css.jq.pause.hide()));this.css.jq.restoreScreen.length&&this.css.jq.fullScreen.length&& +(this.status.noFullScreen?(this.css.jq.fullScreen.hide(),this.css.jq.restoreScreen.hide()):this.options.fullScreen?(this.css.jq.fullScreen.hide(),this.css.jq.restoreScreen.show()):(this.css.jq.fullScreen.show(),this.css.jq.restoreScreen.hide()));this.css.jq.repeat.length&&this.css.jq.repeatOff.length&&(this.options.loop?(this.css.jq.repeat.hide(),this.css.jq.repeatOff.show()):(this.css.jq.repeat.show(),this.css.jq.repeatOff.hide()))},_updateInterface:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.width(this.status.seekPercent+ +"%");this.css.jq.playBar.length&&this.css.jq.playBar.width(this.status.currentPercentRelative+"%");this.css.jq.currentTime.length&&this.css.jq.currentTime.text(b.jPlayer.convertTime(this.status.currentTime));this.css.jq.duration.length&&this.css.jq.duration.text(b.jPlayer.convertTime(this.status.duration))},_seeking:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.addClass("jp-seeking-bg")},_seeked:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.removeClass("jp-seeking-bg")}, +_resetGate:function(){this.html.audio.gate=!1;this.html.video.gate=!1;this.flash.gate=!1},_resetActive:function(){this.html.active=!1;this.flash.active=!1},setMedia:function(a){var c=this,d=!1,e=this.status.media.poster!==a.poster;this._resetMedia();this._resetGate();this._resetActive();b.each(this.formats,function(e,f){var i=c.format[f].media==="video";b.each(c.solutions,function(b,e){if(c[e].support[f]&&c._validString(a[f])){var g=e==="html";i?(g?(c.html.video.gate=!0,c._html_setVideo(a),c.html.active= +!0):(c.flash.gate=!0,c._flash_setVideo(a),c.flash.active=!0),c.css.jq.videoPlay.length&&c.css.jq.videoPlay.show(),c.status.video=!0):(g?(c.html.audio.gate=!0,c._html_setAudio(a),c.html.active=!0):(c.flash.gate=!0,c._flash_setAudio(a),c.flash.active=!0),c.css.jq.videoPlay.length&&c.css.jq.videoPlay.hide(),c.status.video=!1);d=!0;return!1}});if(d)return!1});if(d){if((!this.status.nativeVideoControls||!this.html.video.gate)&&this._validString(a.poster))e?this.htmlElement.poster.src=a.poster:this.internal.poster.jq.show(); +this.status.srcSet=!0;this.status.media=b.extend({},a);this._updateButtons(!1);this._updateInterface()}else this._error({type:b.jPlayer.error.NO_SUPPORT,context:"{supplied:'"+this.options.supplied+"'}",message:b.jPlayer.errorMsg.NO_SUPPORT,hint:b.jPlayer.errorHint.NO_SUPPORT})},_resetMedia:function(){this._resetStatus();this._updateButtons(!1);this._updateInterface();this._seeked();this.internal.poster.jq.hide();clearTimeout(this.internal.htmlDlyCmdId);this.html.active?this._html_resetMedia():this.flash.active&& +this._flash_resetMedia()},clearMedia:function(){this._resetMedia();this.html.active?this._html_clearMedia():this.flash.active&&this._flash_clearMedia();this._resetGate();this._resetActive()},load:function(){this.status.srcSet?this.html.active?this._html_load():this.flash.active&&this._flash_load():this._urlNotSetError("load")},play:function(a){a=typeof a==="number"?a:NaN;this.status.srcSet?this.html.active?this._html_play(a):this.flash.active&&this._flash_play(a):this._urlNotSetError("play")},videoPlay:function(){this.play()}, +pause:function(a){a=typeof a==="number"?a:NaN;this.status.srcSet?this.html.active?this._html_pause(a):this.flash.active&&this._flash_pause(a):this._urlNotSetError("pause")},pauseOthers:function(){var a=this;b.each(this.instances,function(b,d){a.element!==d&&d.data("jPlayer").status.srcSet&&d.jPlayer("pause")})},stop:function(){this.status.srcSet?this.html.active?this._html_pause(0):this.flash.active&&this._flash_pause(0):this._urlNotSetError("stop")},playHead:function(a){a=this._limitValue(a,0,100); +this.status.srcSet?this.html.active?this._html_playHead(a):this.flash.active&&this._flash_playHead(a):this._urlNotSetError("playHead")},_muted:function(a){this.options.muted=a;this.html.used&&this._html_mute(a);this.flash.used&&this._flash_mute(a);!this.html.video.gate&&!this.html.audio.gate&&(this._updateMute(a),this._updateVolume(this.options.volume),this._trigger(b.jPlayer.event.volumechange))},mute:function(a){a=a===f?!0:!!a;this._muted(a)},unmute:function(a){a=a===f?!0:!!a;this._muted(!a)},_updateMute:function(a){if(a=== +f)a=this.options.muted;this.css.jq.mute.length&&this.css.jq.unmute.length&&(this.status.noVolume?(this.css.jq.mute.hide(),this.css.jq.unmute.hide()):a?(this.css.jq.mute.hide(),this.css.jq.unmute.show()):(this.css.jq.mute.show(),this.css.jq.unmute.hide()))},volume:function(a){a=this._limitValue(a,0,1);this.options.volume=a;this.html.used&&this._html_volume(a);this.flash.used&&this._flash_volume(a);!this.html.video.gate&&!this.html.audio.gate&&(this._updateVolume(a),this._trigger(b.jPlayer.event.volumechange))}, +volumeBar:function(a){if(this.css.jq.volumeBar.length){var b=this.css.jq.volumeBar.offset(),d=a.pageX-b.left,e=this.css.jq.volumeBar.width(),a=this.css.jq.volumeBar.height()-a.pageY+b.top,b=this.css.jq.volumeBar.height();this.options.verticalVolume?this.volume(a/b):this.volume(d/e)}this.options.muted&&this._muted(!1)},volumeBarValue:function(a){this.volumeBar(a)},_updateVolume:function(a){if(a===f)a=this.options.volume;a=this.options.muted?0:a;this.status.noVolume?(this.css.jq.volumeBar.length&&this.css.jq.volumeBar.hide(), +this.css.jq.volumeBarValue.length&&this.css.jq.volumeBarValue.hide(),this.css.jq.volumeMax.length&&this.css.jq.volumeMax.hide()):(this.css.jq.volumeBar.length&&this.css.jq.volumeBar.show(),this.css.jq.volumeBarValue.length&&(this.css.jq.volumeBarValue.show(),this.css.jq.volumeBarValue[this.options.verticalVolume?"height":"width"](a*100+"%")),this.css.jq.volumeMax.length&&this.css.jq.volumeMax.show())},volumeMax:function(){this.volume(1);this.options.muted&&this._muted(!1)},_cssSelectorAncestor:function(a){var c= +this;this.options.cssSelectorAncestor=a;this._removeUiClass();this.ancestorJq=a?b(a):[];a&&this.ancestorJq.length!==1&&this._warning({type:b.jPlayer.warning.CSS_SELECTOR_COUNT,context:a,message:b.jPlayer.warningMsg.CSS_SELECTOR_COUNT+this.ancestorJq.length+" found for cssSelectorAncestor.",hint:b.jPlayer.warningHint.CSS_SELECTOR_COUNT});this._addUiClass();b.each(this.options.cssSelector,function(a,b){c._cssSelector(a,b)})},_cssSelector:function(a,c){var d=this;typeof c==="string"?b.jPlayer.prototype.options.cssSelector[a]? +(this.css.jq[a]&&this.css.jq[a].length&&this.css.jq[a].unbind(".jPlayer"),this.options.cssSelector[a]=c,this.css.cs[a]=this.options.cssSelectorAncestor+" "+c,this.css.jq[a]=c?b(this.css.cs[a]):[],this.css.jq[a].length&&this.css.jq[a].bind("click.jPlayer",function(c){d[a](c);b(this).blur();return!1}),c&&this.css.jq[a].length!==1&&this._warning({type:b.jPlayer.warning.CSS_SELECTOR_COUNT,context:this.css.cs[a],message:b.jPlayer.warningMsg.CSS_SELECTOR_COUNT+this.css.jq[a].length+" found for "+a+" method.", +hint:b.jPlayer.warningHint.CSS_SELECTOR_COUNT})):this._warning({type:b.jPlayer.warning.CSS_SELECTOR_METHOD,context:a,message:b.jPlayer.warningMsg.CSS_SELECTOR_METHOD,hint:b.jPlayer.warningHint.CSS_SELECTOR_METHOD}):this._warning({type:b.jPlayer.warning.CSS_SELECTOR_STRING,context:c,message:b.jPlayer.warningMsg.CSS_SELECTOR_STRING,hint:b.jPlayer.warningHint.CSS_SELECTOR_STRING})},seekBar:function(a){if(this.css.jq.seekBar){var b=this.css.jq.seekBar.offset(),a=a.pageX-b.left,b=this.css.jq.seekBar.width(); +this.playHead(100*a/b)}},playBar:function(a){this.seekBar(a)},repeat:function(){this._loop(!0)},repeatOff:function(){this._loop(!1)},_loop:function(a){if(this.options.loop!==a)this.options.loop=a,this._updateButtons(),this._trigger(b.jPlayer.event.repeat)},currentTime:function(){},duration:function(){},gui:function(){},noSolution:function(){},option:function(a,c){var d=a;if(arguments.length===0)return b.extend(!0,{},this.options);if(typeof a==="string"){var e=a.split(".");if(c===f){for(var d=b.extend(!0, +{},this.options),g=0;g0?this._html_load():clearTimeout(this.internal.htmlDlyCmdId);this.htmlElement.media.pause();if(!isNaN(a))try{this.htmlElement.media.currentTime=a}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.pause(a)},100);return}a>0&&this._html_checkWaitForPlay()},_html_playHead:function(a){var b=this;this._html_load();try{if(typeof this.htmlElement.media.seekable==="object"&&this.htmlElement.media.seekable.length>0)this.htmlElement.media.currentTime= +a*this.htmlElement.media.seekable.end(this.htmlElement.media.seekable.length-1)/100;else if(this.htmlElement.media.duration>0&&!isNaN(this.htmlElement.media.duration))this.htmlElement.media.currentTime=a*this.htmlElement.media.duration/100;else throw"e";}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.playHead(a)},100);return}this.status.waitForLoad||this._html_checkWaitForPlay()},_html_checkWaitForPlay:function(){if(this.status.waitForPlay)this.status.waitForPlay=!1,this.css.jq.videoPlay.length&& +this.css.jq.videoPlay.hide(),this.status.video&&(this.internal.poster.jq.hide(),this.internal.video.jq.css({width:this.status.width,height:this.status.height}))},_html_volume:function(a){if(this.html.audio.available)this.htmlElement.audio.volume=a;if(this.html.video.available)this.htmlElement.video.volume=a},_html_mute:function(a){if(this.html.audio.available)this.htmlElement.audio.muted=a;if(this.html.video.available)this.htmlElement.video.muted=a},_flash_setAudio:function(a){var c=this;try{if(b.each(this.formats, +function(b,d){if(c.flash.support[d]&&a[d]){switch(d){case "m4a":case "fla":c._getMovie().fl_setAudio_m4a(a[d]);break;case "mp3":c._getMovie().fl_setAudio_mp3(a[d])}c.status.src=a[d];c.status.format[d]=!0;c.status.formatType=d;return!1}}),this.options.preload==="auto")this._flash_load(),this.status.waitForLoad=!1}catch(d){this._flashError(d)}},_flash_setVideo:function(a){var c=this;try{if(b.each(this.formats,function(b,d){if(c.flash.support[d]&&a[d]){switch(d){case "m4v":case "flv":c._getMovie().fl_setVideo_m4v(a[d])}c.status.src= +a[d];c.status.format[d]=!0;c.status.formatType=d;return!1}}),this.options.preload==="auto")this._flash_load(),this.status.waitForLoad=!1}catch(d){this._flashError(d)}},_flash_resetMedia:function(){this.internal.flash.jq.css({width:"0px",height:"0px"});this._flash_pause(NaN)},_flash_clearMedia:function(){try{this._getMovie().fl_clearMedia()}catch(a){this._flashError(a)}},_flash_load:function(){try{this._getMovie().fl_load()}catch(a){this._flashError(a)}this.status.waitForLoad=!1},_flash_play:function(a){try{this._getMovie().fl_play(a)}catch(b){this._flashError(b)}this.status.waitForLoad= +!1;this._flash_checkWaitForPlay()},_flash_pause:function(a){try{this._getMovie().fl_pause(a)}catch(b){this._flashError(b)}if(a>0)this.status.waitForLoad=!1,this._flash_checkWaitForPlay()},_flash_playHead:function(a){try{this._getMovie().fl_play_head(a)}catch(b){this._flashError(b)}this.status.waitForLoad||this._flash_checkWaitForPlay()},_flash_checkWaitForPlay:function(){if(this.status.waitForPlay)this.status.waitForPlay=!1,this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide(),this.status.video&& +(this.internal.poster.jq.hide(),this.internal.flash.jq.css({width:this.status.width,height:this.status.height}))},_flash_volume:function(a){try{this._getMovie().fl_volume(a)}catch(b){this._flashError(b)}},_flash_mute:function(a){try{this._getMovie().fl_mute(a)}catch(b){this._flashError(b)}},_getMovie:function(){return document[this.internal.flash.id]},_checkForFlash:function(a){var b=!1,d;if(window.ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+a),b=!0}catch(e){}else navigator.plugins&& +navigator.mimeTypes.length>0&&(d=navigator.plugins["Shockwave Flash"])&&navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/,"$1")>=a&&(b=!0);return b},_validString:function(a){return a&&typeof a==="string"},_limitValue:function(a,b,d){return ad?d:a},_urlNotSetError:function(a){this._error({type:b.jPlayer.error.URL_NOT_SET,context:a,message:b.jPlayer.errorMsg.URL_NOT_SET,hint:b.jPlayer.errorHint.URL_NOT_SET})},_flashError:function(a){var c;c=this.internal.ready?"FLASH_DISABLED": +"FLASH";this._error({type:b.jPlayer.error[c],context:this.internal.flash.swf,message:b.jPlayer.errorMsg[c]+a.message,hint:b.jPlayer.errorHint[c]});this.internal.flash.jq.css({width:"1px",height:"1px"})},_error:function(a){this._trigger(b.jPlayer.event.error,a);this.options.errorAlerts&&this._alert("Error!"+(a.message?"\n\n"+a.message:"")+(a.hint?"\n\n"+a.hint:"")+"\n\nContext: "+a.context)},_warning:function(a){this._trigger(b.jPlayer.event.warning,f,a);this.options.warningAlerts&&this._alert("Warning!"+ +(a.message?"\n\n"+a.message:"")+(a.hint?"\n\n"+a.hint:"")+"\n\nContext: "+a.context)},_alert:function(a){alert("jPlayer "+this.version.script+" : id='"+this.internal.self.id+"' : "+a)},_emulateHtmlBridge:function(){var a=this;b.each(b.jPlayer.emulateMethods.split(/\s+/g),function(b,d){a.internal.domNode[d]=function(b){a[d](b)}});b.each(b.jPlayer.event,function(c,d){var e=!0;b.each(b.jPlayer.reservedEvent.split(/\s+/g),function(a,b){if(b===c)return e=!1});e&&a.element.bind(d+".jPlayer.jPlayerHtml", +function(){a._emulateHtmlUpdate();var b=document.createEvent("Event");b.initEvent(c,!1,!0);a.internal.domNode.dispatchEvent(b)})})},_emulateHtmlUpdate:function(){var a=this;b.each(b.jPlayer.emulateStatus.split(/\s+/g),function(b,d){a.internal.domNode[d]=a.status[d]});b.each(b.jPlayer.emulateOptions.split(/\s+/g),function(b,d){a.internal.domNode[d]=a.options[d]})},_destroyHtmlBridge:function(){var a=this;this.element.unbind(".jPlayerHtml");b.each((b.jPlayer.emulateMethods+" "+b.jPlayer.emulateStatus+ +" "+b.jPlayer.emulateOptions).split(/\s+/g),function(b,d){delete a.internal.domNode[d]})}};b.jPlayer.error={FLASH:"e_flash",FLASH_DISABLED:"e_flash_disabled",NO_SOLUTION:"e_no_solution",NO_SUPPORT:"e_no_support",URL:"e_url",URL_NOT_SET:"e_url_not_set",VERSION:"e_version"};b.jPlayer.errorMsg={FLASH:"jPlayer's Flash fallback is not configured correctly, or a command was issued before the jPlayer Ready event. Details: ",FLASH_DISABLED:"jPlayer's Flash fallback has been disabled by the browser due to the CSS rules you have used. Details: ", +NO_SOLUTION:"No solution can be found by jPlayer in this browser. Neither HTML nor Flash can be used.",NO_SUPPORT:"It is not possible to play any media format provided in setMedia() on this browser using your current options.",URL:"Media URL could not be loaded.",URL_NOT_SET:"Attempt to issue media playback commands, while no media url is set.",VERSION:"jPlayer "+b.jPlayer.prototype.version.script+" needs Jplayer.swf version "+b.jPlayer.prototype.version.needFlash+" but found "};b.jPlayer.errorHint= +{FLASH:"Check your swfPath option and that Jplayer.swf is there.",FLASH_DISABLED:"Check that you have not display:none; the jPlayer entity or any ancestor.",NO_SOLUTION:"Review the jPlayer options: support and supplied.",NO_SUPPORT:"Video or audio formats defined in the supplied option are missing.",URL:"Check media URL is valid.",URL_NOT_SET:"Use setMedia() to set the media URL.",VERSION:"Update jPlayer files."};b.jPlayer.warning={CSS_SELECTOR_COUNT:"e_css_selector_count",CSS_SELECTOR_METHOD:"e_css_selector_method", +CSS_SELECTOR_STRING:"e_css_selector_string",OPTION_KEY:"e_option_key"};b.jPlayer.warningMsg={CSS_SELECTOR_COUNT:"The number of css selectors found did not equal one: ",CSS_SELECTOR_METHOD:"The methodName given in jPlayer('cssSelector') is not a valid jPlayer method.",CSS_SELECTOR_STRING:"The methodCssSelector given in jPlayer('cssSelector') is not a String or is empty.",OPTION_KEY:"The option requested in jPlayer('option') is undefined."};b.jPlayer.warningHint={CSS_SELECTOR_COUNT:"Check your css selector and the ancestor.", +CSS_SELECTOR_METHOD:"Check your method name.",CSS_SELECTOR_STRING:"Check your css selector is a string.",OPTION_KEY:"Check your option name."}})(jQuery); \ No newline at end of file diff --git a/app/assets/javascripts/jquery.periodicalupdater.js b/app/assets/javascripts/jquery.periodicalupdater.js new file mode 100644 index 0000000..20f7ca5 --- /dev/null +++ b/app/assets/javascripts/jquery.periodicalupdater.js @@ -0,0 +1,175 @@ +/** + * PeriodicalUpdater - jQuery plugin for timed, decaying ajax calls + * + * http://www.360innovate.co.uk/blog/2009/03/periodicalupdater-for-jquery/ + * http://enfranchisedmind.com/blog/posts/jquery-periodicalupdater-ajax-polling/ + * + * Copyright (c) 2009 by the following: + * Frank White (http://customcode.info) + * Robert Fischer (http://smokejumperit.com) + * 360innovate (http://www.360innovate.co.uk) + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + */ + +(function($) { + var pu_log = function(msg) { + try { + console.log(msg); + } catch(err) {} + } + + // Now back to our regularly scheduled work + $.PeriodicalUpdater = function(url, options, callback, autoStopCallback){ + var settings = jQuery.extend(true, { + url: url, // URL of ajax request + cache: false, // By default, don't allow caching + method: 'GET', // method; get or post + data: '', // array of values to be passed to the page - e.g. {name: "John", greeting: "hello"} + minTimeout: 1000, // starting value for the timeout in milliseconds + maxTimeout: 8000, // maximum length of time between requests + multiplier: 2, // if set to 2, timerInterval will double each time the response hasn't changed (up to maxTimeout) + maxCalls: 0, // maximum number of calls. 0 = no limit. + autoStop: 0 // automatically stop requests after this many returns of the same data. 0 = disabled + }, options); + + // set some initial values, then begin + var timer = null; + var timerInterval = settings.minTimeout; + var maxCalls = settings.maxCalls; + var autoStop = settings.autoStop; + var calls = 0; + var noChange = 0; + var originalMaxCalls = maxCalls; + + var reset_timer = function(interval) { + if (timer != null) { + clearTimeout(timer); + } + timerInterval = interval; + pu_log('resetting timer to '+ timerInterval +'.'); + timer = setTimeout(getdata, timerInterval); + } + + // Function to boost the timer + var boostPeriod = function() { + if(settings.multiplier >= 1) { + before = timerInterval; + timerInterval = timerInterval * settings.multiplier; + + if(timerInterval > settings.maxTimeout) { + timerInterval = settings.maxTimeout; + } + after = timerInterval; + pu_log('adjusting timer from '+ before +' to '+ after +'.'); + reset_timer(timerInterval); + } + }; + + // Construct the settings for $.ajax based on settings + var ajaxSettings = jQuery.extend(true, {}, settings); + if(settings.type && !ajaxSettings.dataType) ajaxSettings.dataType = settings.type; + if(settings.sendData) ajaxSettings.data = settings.sendData; + ajaxSettings.type = settings.method; // 'type' is used internally for jQuery. Who knew? + ajaxSettings.ifModified = true; + + var handle = { + restart: function() { + maxCalls = originalMaxCalls; + calls = 0; + reset_timer(timerInterval); + return; + }, + stop: function() { + maxCalls = -1; + return; + } + }; + + // Create the function to get data + // TODO It'd be nice to do the options.data check once (a la boostPeriod) + function getdata() { + var toSend = jQuery.extend(true, {}, ajaxSettings); // jQuery screws with what you pass in + if(typeof(options.data) == 'function') { + toSend.data = options.data(); + if(toSend.data) { + // Handle transformations (only strings and objects are understood) + if(typeof(toSend.data) == "number") { + toSend.data = toSend.data.toString(); + } + } + } + + if(maxCalls == 0) { + $.ajax(toSend); + } else if(maxCalls > 0 && calls < maxCalls) { + $.ajax(toSend); + calls++; + } + } + + // Implement the tricky behind logic + var remoteData = null; + var prevData = null; + + ajaxSettings.success = function(data) { + pu_log("Successful run! (In 'success')"); + remoteData = data; + // timerInterval = settings.minTimeout; + }; + + ajaxSettings.complete = function(xhr, success) { + //pu_log("Status of call: " + success + " (In 'complete')"); + if(maxCalls == -1) return; + if(success == "success" || success == "notmodified") { + var rawData = $.trim(xhr.responseText); + if(rawData == 'STOP_AJAX_CALLS') { + handle.stop(); + return; + } + if(prevData == rawData) { + if(autoStop > 0) { + noChange++; + if(noChange == autoStop) { + handle.stop(); + if(autoStopCallback) autoStopCallback(noChange); + return; + } + } + boostPeriod(); + } else { + noChange = 0; + reset_timer(settings.minTimeout); + prevData = rawData; + if(remoteData == null) remoteData = rawData; + // jQuery 1.4+ $.ajax() automatically converts "data" into a JS Object for "type:json" requests now + // For compatibility with 1.4+ and pre1.4 jQuery only try to parse actual strings, skip when remoteData is already an Object + if((ajaxSettings.dataType === 'json') && (typeof(remoteData) === 'string') && (success == "success")) { + remoteData = JSON.parse(remoteData); + } + if(settings.success) { settings.success(remoteData, success, xhr, handle); } + if(callback) callback(remoteData, success, xhr, handle); + } + } + remoteData = null; + } + + + ajaxSettings.error = function (xhr, textStatus) { + //pu_log("Error message: " + textStatus + " (In 'error')"); + if(textStatus != "notmodified") { + prevData = null; + reset_timer(settings.minTimeout); + } + if(settings.error) { settings.error(xhr, textStatus); } + }; + + // Make the first call + $(function() { reset_timer(timerInterval); }); + + return handle; + }; +})(jQuery); \ No newline at end of file diff --git a/app/assets/javascripts/local.js b/app/assets/javascripts/local.js new file mode 100644 index 0000000..f862df9 --- /dev/null +++ b/app/assets/javascripts/local.js @@ -0,0 +1,290 @@ +$(document).ready(function(){ + // + //function showNews(source, cat, content){ + // new Ajax.Updater(content, '/categories/' + cat, { + // method: 'get' + // }); + // var thisChild = source.parentNode.firstChild; + // while (thisChild != source.parentNode.lastChild) { + // if (thisChild.nodeType == 1 && thisChild.getAttribute("class") != "unread") { + // thisChild.setAttribute("class", ""); + // } + // thisChild = thisChild.nextSibling; + // } + // source.setAttribute("class", "active"); + //} + + //function goToTheEnd(){ + // var ed = tinyMCE.activeEditor; + // // This gets the root node of the editor window + // var root = ed.dom.getRoot(); + // // And this gets the last node inside of it, so the last

...

tag + // var lastnode = root.childNodes[root.childNodes.length - 1]; + // + // if (tinymce.isGecko) { + // // But firefox places the selection outside of that tag, so we need to go one level deeper: + // lastnode = lastnode.childNodes[lastnode.childNodes.length - 1]; + // } + // // Now, we select the node + // ed.selection.select(lastnode); + // // And collapse the selection to the end to put the caret there: + // ed.selection.collapse(false); + //} + // + //var myrules = { + // '.remove': function(e){ + // el = Event.findElement(e); + // target = el.href.replace(/.*#/, '.') + // el.up(target).hide(); + // if (hidden_input = el.previous("input[type=hidden]")) { + // hidden_input.value = '1' + // } + // } + //}; + // + //Event.observe(window, 'load', function(){ + // $('container').delegate('click', myrules); + //}); + // + //function changeCssClass(id, newclass){ + // var obj = document.getElementById(id) + // obj.setAttribute("class", newclass); + // obj.setAttribute("className", newclass); + // obj.className = newclass; + //}; + // + //function changeTab(container, tab){ + // $(tab).style.visibility = 'hidden'; + //}; + // + //function Trash(source){ + // var input = document.createElement("input"); + // input.name = "deleted[reason]"; + // input.type = "hidden"; + // input.value = prompt('Enter reason', 'Violation of rule #'); + // if (input.value == null) { + // return + // } + // source.appendChild(input); + // source.submit(); + //} + + + // User popup + var userInfoTimeout; + + function ShowUserPopup(source, user){ + clearInterval(userInfoTimeout); + + hp = document.getElementById("userPopup"); + hp.style.top = source.offsetTop + "px"; + hp.style.left = source.offsetLeft - 170 + "px"; + hp.style.visibility = "Visible"; + + $.ajax({ + type: "GET", + url: "/users/popup/" + user + ".js", + dataType: "script" + }); + } + + function HideUserPopup(){ + userInfoTimeout = setTimeout("HideUserPopupRunner();", 1000); + } + + function HideUserPopupRunner(){ + document.getElementById("userPopup").style.visibility = "Hidden"; + } + + // Shoutbox + $.PeriodicalUpdater("/shoutmsgs/index.js", { + method: "GET", + type: "script", + minTimeout: 10000, + multiplier: 2 + }); +}); + +$( function() { + var menuContests; + var menuGather; + var menuMaterial; + var menuForums; + + $( function() { + $('div#indexMenu div.contests').hover(function(){ + }); + }); + + $("div#shoutbox").bind("mousewheel",function(ev, delta) { + var scrollTop = $(this).scrollTop(); + $(this).scrollTop(scrollTop-Math.round(delta)); + }); + + // Contests + $("div#indexMenu div.contests").mouseenter(function(){ + $("div#indexItems div.contests").fadeIn(100); + }); + + $("div#indexMenu div.contests").mouseout(function(){ + menuContests = setTimeout(function(){ + $("div#indexItems div.contests").fadeOut(100); + }, 100); + }); + + $("div#indexItems div.contests").mouseenter(function(){ + clearTimeout(menuContests); + }); + + $("div#indexItems div.contests").mouseleave(function(){ + $("div#indexItems div.contests").fadeOut(100); + }); + + // Gather + + $("div#indexMenu div.gather").mouseenter(function(){ + $("div#indexItems div.gather").fadeIn(100); + }); + + $("div#indexMenu div.gather").mouseout(function(){ + menuGather = setTimeout(function(){ + $("div#indexItems div.gather").fadeOut(100); + }, 100); + }); + + $("div#indexItems div.gather").mouseenter(function(){ + clearTimeout(menuGather); + }); + + $("div#indexItems div.gather").mouseleave(function(){ + $("div#indexItems div.gather").fadeOut(100); + }); + + // Forums + + $("div#indexMenu div.material").mouseenter(function(){ + $("div#indexItems div.material").fadeIn(100); + }); + + $("div#indexMenu div.material").mouseout(function(){ + menuMaterial = setTimeout(function(){ + $("div#indexItems div.material").fadeOut(100); + }, 100); + }); + + $("div#indexItems div.material").mouseenter(function(){ + clearTimeout(menuMaterial); + }); + + $("div#indexItems div.material").mouseleave(function(){ + $("div#indexItems div.material").fadeOut(100); + }); + + // Forums + + $("div#indexMenu div.forums").mouseenter(function(){ + $("div#indexItems div.forums").fadeIn(100); + }); + + $("div#indexMenu div.forums").mouseout(function(){ + menuForums = setTimeout(function(){ + $("div#indexItems div.forums").fadeOut(100); + }, 100); + }); + + $("div#indexItems div.forums").mouseenter(function(){ + clearTimeout(menuForums); + }); + + $("div#indexItems div.forums").mouseleave(function(){ + $("div#indexItems div.forums").fadeOut(100); + }); + + // Gather stuff + + $("a#gatherInfoHide").live('click', function() { + $("div#gatherInfo").fadeOut('slow', 0); + }); + + $("a#gatherJoinBtn").live('click', function() { + $('form#new_gatherer').submit(); + }); + + // Submit TODO + + $("a.submit").live('click', function() { + $(this).closest('form').submit() + }); + + $('form.new_shoutmsg').submit(function(){ + $('input[type=submit]', this).attr('disabled', 'disabled'); + }); + + $('form.new_shoutmsg').submit(function(){ + $('input[type=submit]', this).attr('disabled', 'disabled'); + }); + + $('form.new_shoutmsg').live("ajax:complete", function(event,xhr,status){ + $(this)[0].reset(); + }); + + // User page + $("td#userNavi > div > a").click(function(){ + $("td#userData").fadeOut("fast"); + $.ajax({ + type: "GET", + url: window.location.protocol + "//" + window.location.host + "/" + window.location.pathname + ".js?page=" + $(this).attr('id'), + dataType: "script" + }); + }); + + // Users page + $("#users th a, #users .pagination a").live("click", function() { + $.getScript(this.href); + return false; + }); + + $("#users_search input").keyup(function() { + $.get($("#users_search").attr("action"), $("#users_search").serialize(), null, "script"); + return false; + }); + + // Poll page + $("a#option").click(function() { + }); +}); + +// User search +var findUserWindow = ""; + +function findUser(source) { + findUserWindow = window.open("/users/find?source=" + source, 'findUser', 'height=400,width=400,menubar=false'); + if (window.focus) { + findUserWindow.focus(); + } + if (findUserWindow.opener == null) { + childWindow.opener = self; + } + return false; +} + +function QuoteText(id) { + $.ajax({ + type: "GET", + url: "/posts/quote/" + id + ".js", + dataType: "script" + }); +} + +// Fields removing and adding dynamically + +function remove_fields(link) { + $(link).prev("input[type=hidden]").val("1"); + $(link).closest(".fields").hide(); +} + +function add_fields(link, association, content) { + var new_id = new Date().getTime(); + var regexp = new RegExp("new_" + association, "g") + $(link).parent().before(content.replace(regexp, new_id)); +} \ No newline at end of file diff --git a/app/assets/javascripts/yetii.js b/app/assets/javascripts/yetii.js new file mode 100644 index 0000000..076a017 --- /dev/null +++ b/app/assets/javascripts/yetii.js @@ -0,0 +1,198 @@ +/* +Yetii - Yet (E)Another Tab Interface Implementation +version 1.5 +http://www.kminek.pl/lab/yetii/ +Copyright (c) 2007-2008 Grzegorz Wojcik +Code licensed under the BSD License: +http://www.kminek.pl/bsdlicense.txt +*/ + +function Yetii() { + + this.defaults = { + + id: null, + active: 1, + interval: null, + wait: null, + persist: null, + tabclass: 'tab', + activeclass: 'active', + callback: null, + leavecallback: null + + }; + + this.activebackup = null; + + for (var n in arguments[0]) { this.defaults[n]=arguments[0][n]; }; + + this.getTabs = function() { + + var retnode = []; + var elem = document.getElementById(this.defaults.id).getElementsByTagName('*'); + + var regexp = new RegExp("(^|\\s)" + this.defaults.tabclass.replace(/\-/g, "\\-") + "(\\s|$)"); + + for (var i = 0; i < elem.length; i++) { + if (regexp.test(elem[i].className)) retnode.push(elem[i]); + } + + return retnode; + + }; + + this.links = document.getElementById(this.defaults.id + '-nav').getElementsByTagName('a'); + this.listitems = document.getElementById(this.defaults.id + '-nav').getElementsByTagName('li'); + + this.show = function(number) { + + for (var i = 0; i < this.tabs.length; i++) { + + this.tabs[i].style.display = ((i+1)==number) ? 'block' : 'none'; + + if ((i+1)==number) { + this.addClass(this.links[i], this.defaults.activeclass); + this.addClass(this.listitems[i], this.defaults.activeclass + 'li'); + } else { + this.removeClass(this.links[i], this.defaults.activeclass); + this.removeClass(this.listitems[i], this.defaults.activeclass + 'li'); + } + + } + + + if (this.defaults.leavecallback && (number != this.activebackup)) this.defaults.leavecallback(this.defaults.active); + + this.activebackup = number; + + + this.defaults.active = number; + + if (this.defaults.callback) this.defaults.callback(number); + + + }; + + this.rotate = function(interval) { + + this.show(this.defaults.active); + this.defaults.active++; + + if (this.defaults.active > this.tabs.length) this.defaults.active = 1; + + + var self = this; + + if (this.defaults.wait) clearTimeout(this.timer2); + + this.timer1 = setTimeout(function(){self.rotate(interval);}, interval*1000); + + }; + + this.next = function() { + + this.defaults.active++; + if(this.defaults.active > this.tabs.length) this.defaults.active = 1; + this.show(this.defaults.active); + + }; + + this.previous = function() { + + this.defaults.active--; + if(!this.defaults.active) this.defaults.active = this.tabs.length; + this.show(this.defaults.active); + + }; + + this.gup = function(name) { + name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); + var regexS = "[\\?&]"+name+"=([^&#]*)"; + var regex = new RegExp( regexS ); + var results = regex.exec( window.location.href ); + if (results == null) return null; + else return results[1]; + }; + + this.parseurl = function(tabinterfaceid) { + + var result = this.gup(tabinterfaceid); + + if (result==null) return null; + if (parseInt(result)) return parseInt(result); + if (document.getElementById(result)) { + for (var i=0;i