diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 00000000..413e6da1
Binary files /dev/null and b/.DS_Store differ
diff --git a/Gemfile b/Gemfile
index e87fad5f..5967d3fb 100644
--- a/Gemfile
+++ b/Gemfile
@@ -4,7 +4,7 @@ source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.7'
# Use sqlite3 as the database for Active Record
-gem 'sqlite3'
+
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
@@ -23,6 +23,7 @@ gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
+gem 'graphviz'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
@@ -35,13 +36,24 @@ gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
+ gem 'sqlite3'
end
group :development do
+ gem 'better_errors'
+ gem 'binding_of_caller'
+ gem 'pry-rails'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
+
+ gem 'rails-erd'
end
+
+group :production do
+ gem 'pg'
+ gem 'rails_12factor'
+end
diff --git a/Gemfile.lock b/Gemfile.lock
index 6c97c19f..13c36d9c 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -37,10 +37,16 @@ GEM
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
+ better_errors (2.1.1)
+ coderay (>= 1.0.0)
+ erubis (>= 2.6.6)
+ rack (>= 0.9.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (9.0.6)
+ choice (0.2.0)
+ coderay (1.1.1)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
@@ -54,6 +60,7 @@ GEM
execjs (2.7.0)
globalid (0.3.7)
activesupport (>= 4.1.0)
+ graphviz (0.3.0)
i18n (0.7.0)
jbuilder (2.6.0)
activesupport (>= 3.0.0, < 5.1)
@@ -67,6 +74,7 @@ GEM
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
+ method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
@@ -76,7 +84,14 @@ GEM
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
+ pg (0.19.0)
pkg-config (1.1.7)
+ pry (0.10.4)
+ coderay (~> 1.1.0)
+ method_source (~> 0.8.1)
+ slop (~> 3.4)
+ pry-rails (0.3.4)
+ pry (>= 0.9.10)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
@@ -97,8 +112,18 @@ GEM
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
+ rails-erd (1.5.0)
+ activerecord (>= 3.2)
+ activesupport (>= 3.2)
+ choice (~> 0.2.0)
+ ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
+ rails_12factor (0.0.3)
+ rails_serve_static_assets
+ rails_stdout_logging
+ rails_serve_static_assets (0.0.5)
+ rails_stdout_logging (0.0.5)
railties (4.2.7)
actionpack (= 4.2.7)
activesupport (= 4.2.7)
@@ -107,6 +132,7 @@ GEM
rake (11.3.0)
rdoc (4.2.2)
json (~> 1.4)
+ ruby-graphviz (1.2.2)
sass (3.4.22)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
@@ -117,6 +143,7 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
+ slop (3.6.0)
spring (2.0.0)
activesupport (>= 4.2)
sprockets (3.7.0)
@@ -147,11 +174,18 @@ PLATFORMS
ruby
DEPENDENCIES
+ better_errors
+ binding_of_caller
byebug
coffee-rails (~> 4.1.0)
+ graphviz
jbuilder (~> 2.0)
jquery-rails
+ pg
+ pry-rails
rails (= 4.2.7)
+ rails-erd
+ rails_12factor
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
diff --git a/app/.DS_Store b/app/.DS_Store
new file mode 100644
index 00000000..305847b5
Binary files /dev/null and b/app/.DS_Store differ
diff --git a/app/assets/images/tomatoes.jpeg b/app/assets/images/tomatoes.jpeg
new file mode 100644
index 00000000..2b6cfe79
Binary files /dev/null and b/app/assets/images/tomatoes.jpeg differ
diff --git a/app/assets/javascripts/markets.coffee b/app/assets/javascripts/markets.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/markets.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/products.coffee b/app/assets/javascripts/products.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/products.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/sales.coffee b/app/assets/javascripts/sales.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/sales.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/vendors.coffee b/app/assets/javascripts/vendors.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/vendors.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index f9cd5b34..ed0c2e46 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -1,15 +1,81 @@
-/*
- * This is a manifest file that'll be compiled into application.css, which will include all the files
- * listed below.
- *
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
- *
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
- * compiled file so the styles you add here take precedence over styles defined in any styles
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
- * file per style scope.
- *
- *= require_tree .
- *= require_self
- */
+body {
+ margin: 0;
+ }
+
+ header {
+ background-image: url(/assets/tomatoes.jpeg);
+ height: 15vh;
+ width: 100vw;
+ background-size: cover;
+ margin: 0;
+ background-position: center center;
+ text-align: center;
+ color: white;
+ font-family: "Special Elite", cursive;
+ font-size: 2em;
+ }
+
+ header h1 {
+ margin: 0;
+ position: relative;
+ top: 4vh;
+ }
+
+ header h1 a {
+ text-decoration: none;
+ color: white;
+ }
+
+#main {
+ background-image: url(/assets/tomatoes.jpeg);
+ height: 100vh;
+ width: 100vw;
+ background-size: cover;
+ margin: 0;
+ position: absolute;
+ top: 0;
+ overflow: hidden;
+}
+
+#main h1 {
+ text-align: center;
+ font-size: 3em;
+ position: relative;
+ top: 35vh;
+ font-family: "Special Elite", cursive;
+ color: white;
+}
+
+#menu {
+ text-align: center;
+ margin: 40vh auto;
+ font-size: 1.5em;
+}
+
+#menu a {
+ text-decoration: none;
+ color: white;
+ font-family: "Molengo";
+}
+
+h2.section-heading {
+ margin-top: 6vh;
+}
+
+.centered-list {
+ list-style: none;
+ font-family: "Molengo";
+ text-align: center;
+ padding-left: 0;
+}
+
+.add-vendor-edit-market li {
+ font-family: "Molengo";
+ margin-left: 470px;
+ list-style-type: none;
+}
+.market-address {
+ font-family: "Molengo";
+ text-align: center;
+ list-style-type: none;
+}
diff --git a/app/assets/stylesheets/markets.scss b/app/assets/stylesheets/markets.scss
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/app/assets/stylesheets/markets.scss
@@ -0,0 +1 @@
+
diff --git a/app/assets/stylesheets/products.scss b/app/assets/stylesheets/products.scss
new file mode 100644
index 00000000..bff386e5
--- /dev/null
+++ b/app/assets/stylesheets/products.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Products controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/sales.scss b/app/assets/stylesheets/sales.scss
new file mode 100644
index 00000000..5126e4bf
--- /dev/null
+++ b/app/assets/stylesheets/sales.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Sales controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/vendors.scss b/app/assets/stylesheets/vendors.scss
new file mode 100644
index 00000000..e77b0e5a
--- /dev/null
+++ b/app/assets/stylesheets/vendors.scss
@@ -0,0 +1,46 @@
+// Place all the styles related to the Vendors controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
+
+
+
+.page-title {
+ text-align: center;
+ font-family: "Special Elite", cursive;
+ font-size: 2em;
+ margin: 12vh 0 6vh;
+}
+
+h1.page-title {
+ margin-bottom: 3vh;
+}
+
+.vendor-market, .section-heading {
+ font-family: "Special Elite", cursive;
+ font-size: 1.5em;
+ text-align: center;
+}
+
+.add-product {
+ list-style: none;
+ font-family: "Molengo";
+ text-align: center;
+ padding-left: 0;
+}
+
+p.vendor-details, p.market-address {
+ font-family: "Molengo";
+ text-align: center;
+}
+
+table, tr, td {
+ border: 1px solid black;
+ width: 80vw;
+ text-align: center;
+}
+
+.sales_tables {
+ margin: 5vh auto;
+ width: 80vw;
+ font-family: "Molengo", sans-serif;
+}
diff --git a/app/controllers/markets_controller.rb b/app/controllers/markets_controller.rb
new file mode 100644
index 00000000..91de9729
--- /dev/null
+++ b/app/controllers/markets_controller.rb
@@ -0,0 +1,67 @@
+class MarketsController < ApplicationController
+
+ def mainpage
+ end
+
+ def index
+ @markets = Market.all
+ @link = "market"
+ end
+
+ def new
+ @market = Market.new
+ end
+
+ def create
+ @new_market_create = Market.new(market_params)
+ if @new_market_create.save
+ redirect_to market_path
+ else
+ render :new
+ end
+ end
+
+ def user_all
+ @markets = Market.all
+ @link = "user"
+ render "index"
+ end
+
+ def show
+ id = params[:id]
+ @market = Market.find(id)
+ @vendors = @market.vendors
+ @link = "market"
+ end
+
+ def user_show
+ id = params[:id]
+ @market = Market.find(id)
+ @vendors = @market.vendors
+ @link = "user"
+ render "show"
+ end
+
+ def destroy
+ Market.find(params[:id]).destroy
+ redirect_to markets_path
+ end
+
+ def edit
+ @market = Market.find(params[:id])
+ end
+
+ def update
+ @market = Market.find(params[:id])
+ if @market.update(market_params)
+ redirect_to market_path(@market.id)
+ else
+ render :edit
+ end
+ end
+
+ private
+ def market_params
+ params.require(:market).permit(:name, :address, :city, :county, :state, :zip)
+ end
+end
diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb
new file mode 100644
index 00000000..4239406a
--- /dev/null
+++ b/app/controllers/products_controller.rb
@@ -0,0 +1,62 @@
+class ProductsController < ApplicationController
+ def new
+ vendor_id = params[:vendor_id]
+ @vendor = Vendor.find(vendor_id)
+ @vendor_product = @vendor.products.build
+ end
+
+ def create
+ vendor_id = params[:vendor_id]
+ vendor = Vendor.find(vendor_id)
+ @vendor_product = vendor.products.create(vendor_product_params)
+
+ redirect_to vendor_path(vendor_id)
+ end
+
+ def show
+ id = params[:id]
+ @vendor_product = Product.find(id)
+ end
+
+ def edit
+ id = params[:id]
+ @vendor_product = Product.find(id)
+=begin
+ @vendor = Vendor.find(params[:vendor_id])
+ @product = Product.find(params[:id])
+=end
+
+ end
+
+ def update
+ @vendor_product = Product.find(params[:id])
+ if @vendor_product.update(vendor_product_params)
+ redirect_to vendor_path(params[:vendor_id])
+ else
+ render :edit
+ end
+=begin
+ @product = Product.find(params[:id])
+ @vendor = Vendor.find(params[:vendor_id])
+ @product.vendor_id = @vendor.id
+ if @vendor_product.update(vendor_product_params)
+ redirect_to vendor_path(params[@vendor.id])
+ else
+ render :edit
+ end
+=end
+ end
+
+ def destroy
+ @vendor_product = Product.find(params[:id])
+ if @vendor_product.destroy
+ redirect_to vendor_path(params[:vendor_id])
+ end
+ end
+
+ private
+
+ def vendor_product_params
+ params.require(:product).permit(:name, :vendor_id)
+ end
+end
diff --git a/app/controllers/sales_controller.rb b/app/controllers/sales_controller.rb
new file mode 100644
index 00000000..4b038a6b
--- /dev/null
+++ b/app/controllers/sales_controller.rb
@@ -0,0 +1,22 @@
+class SalesController < ApplicationController
+ def new
+ # vendor_id = params[:vendor_id]
+ # @vendor = Vendor.find(vendor_id)
+ product_id = params[:product_id]
+ @product = Product.find(product_id)
+ @sale = @product.sales.build
+ end
+
+ def create
+ product_id = params[:product_id]
+ @product = Product.find(product_id)
+ @sale = @product.sales.create(sales_params)
+ redirect_to vendor_path(params[:vendor_id])
+ end
+
+ private
+
+ def sales_params
+ params.require(:sale).permit(:amount, :purchase_time)
+ end
+end
diff --git a/app/controllers/vendors_controller.rb b/app/controllers/vendors_controller.rb
new file mode 100644
index 00000000..23b296a8
--- /dev/null
+++ b/app/controllers/vendors_controller.rb
@@ -0,0 +1,68 @@
+class VendorsController < ApplicationController
+
+ def index
+ @vendors_all = Vendor.all.order(:name)
+ # a_e = ["a", "b", "c", "d", "e"]
+ # @vendors_a_e = Vendor.by_letter(a_e)
+ end
+
+ def show
+ id = params[:id]
+ @vendor = Vendor.find(id)
+ @products = @vendor.products
+ @sales = @vendor.sales #sales(@products)
+ @vendor_market_object = Market.find(@vendor.market_id)
+ @vendor_market = @vendor_market_object.name
+ @full_address = @vendor_market_object.full_address
+ @sales_total = @vendor.sales_total(@sales)
+ @month_sales = @vendor.sales_current_month
+ @current_month_total = @vendor.current_month_total
+
+ if !(@sales.empty?)
+ @attribute_keys = @sales.first.attributes.keys #doesn't work if no sales
+ end
+ end
+
+ def destroy
+ @market = Market.find(params[:market_id])
+ @vendor = Vendor.find(params[:id])
+ @vendor.destroy
+ redirect_to market_path(@market.id)
+ end
+
+ def new
+ @market = Market.find(params[:market_id])
+ @vendor = @market.vendors.new
+ end
+
+ def create
+ @market = Market.find(params[:market_id])
+ @vendor = @market.vendors.new(vendor_params)
+ if @vendor.save
+ redirect_to market_path(@market.id)
+ else
+ render :new
+ end
+ end
+
+ def edit
+ @vendor = Vendor.find(params[:id])
+ @market = Market.find(params[:market_id])
+ end
+
+ def update
+ @market = Market.find(params[:market_id])
+ @vendor = Vendor.find(params[:id])
+ if @vendor.update(vendor_params)
+ redirect_to market_path(@market.id)
+ else
+ render :edit
+ end
+ end
+
+ private
+ def vendor_params
+ params.require(:vendor).permit(:name, :number_of_employees,
+ :markets => [:name, :address, :city, :county, :state, :zip])
+ end
+end
diff --git a/app/helpers/markets_helper.rb b/app/helpers/markets_helper.rb
new file mode 100644
index 00000000..655b79b7
--- /dev/null
+++ b/app/helpers/markets_helper.rb
@@ -0,0 +1,2 @@
+module MarketsHelper
+end
diff --git a/app/helpers/products_helper.rb b/app/helpers/products_helper.rb
new file mode 100644
index 00000000..ab5c42b3
--- /dev/null
+++ b/app/helpers/products_helper.rb
@@ -0,0 +1,2 @@
+module ProductsHelper
+end
diff --git a/app/helpers/sales_helper.rb b/app/helpers/sales_helper.rb
new file mode 100644
index 00000000..8611c4a0
--- /dev/null
+++ b/app/helpers/sales_helper.rb
@@ -0,0 +1,2 @@
+module SalesHelper
+end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
new file mode 100644
index 00000000..2310a240
--- /dev/null
+++ b/app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
+module UsersHelper
+end
diff --git a/app/helpers/vendors_helper.rb b/app/helpers/vendors_helper.rb
new file mode 100644
index 00000000..5429ffa4
--- /dev/null
+++ b/app/helpers/vendors_helper.rb
@@ -0,0 +1,2 @@
+module VendorsHelper
+end
diff --git a/app/models/market.rb b/app/models/market.rb
new file mode 100644
index 00000000..f8d67d89
--- /dev/null
+++ b/app/models/market.rb
@@ -0,0 +1,7 @@
+class Market < ActiveRecord::Base
+ has_many :vendors
+
+ def full_address
+ "#{address}, #{city}, #{county}, #{state} #{zip}"
+ end
+end
diff --git a/app/models/product.rb b/app/models/product.rb
new file mode 100644
index 00000000..86f8d94b
--- /dev/null
+++ b/app/models/product.rb
@@ -0,0 +1,4 @@
+class Product < ActiveRecord::Base
+ belongs_to :vendor
+ has_many :sales
+end
diff --git a/app/models/sale.rb b/app/models/sale.rb
new file mode 100644
index 00000000..e9af9364
--- /dev/null
+++ b/app/models/sale.rb
@@ -0,0 +1,3 @@
+class Sale < ActiveRecord::Base
+ belongs_to :product
+end
diff --git a/app/models/vendor.rb b/app/models/vendor.rb
new file mode 100644
index 00000000..6d5651e9
--- /dev/null
+++ b/app/models/vendor.rb
@@ -0,0 +1,45 @@
+class Vendor < ActiveRecord::Base
+ belongs_to :market
+ has_many :products
+
+ def sales
+ sales = []
+ products.each do |product|
+ sales += product.sales
+ end
+ return sales
+ end
+
+ def sales_total(sales)
+ total_amount = 0
+ sales.each do |sale|
+ total_amount += sale.amount
+ end
+ total_amount = total_amount/100.0
+ return sprintf "%.2f", total_amount
+ end
+
+ def sales_current_month
+ current_sales = []
+ current_month = DateTime.now
+ sales.each do |sale|
+ if ((sale.purchase_time.year == current_month.year) && (sale.purchase_time.month == current_month.month))
+ current_sales << sale
+ end
+ end
+ return current_sales
+ end
+
+ def current_month_total
+ sales_total(sales_current_month)
+ end
+
+ # def self.by_letter(array_of_letters)
+ # results = []
+ # array_of_letters.each do |letter|
+ # letter.upcase!
+ # results += self.where.("name like?", "#{letter}%").order(:name)
+ # end
+ # return results
+ # end
+end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 443f3152..227ed444 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -5,8 +5,13 @@
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
+
+
+
+ <%= link_to "Farmers Markets", root_path %>
+
<%= yield %>
diff --git a/app/views/markets/edit.html.erb b/app/views/markets/edit.html.erb
new file mode 100644
index 00000000..a0907853
--- /dev/null
+++ b/app/views/markets/edit.html.erb
@@ -0,0 +1,17 @@
+
+<%= form_for @market, method: :patch do |f| %>
+ <%= f.label :Name %>:
+ <%= f.text_field :name %>
+ <%= f.label :Address %>:
+ <%= f.text_field :address %>
+ <%= f.label :City %>:
+ <%= f.text_field :city %>
+ <%= f.label :County %>:
+ <%= f.text_field :county %>
+ <%= f.label :State %>:
+ <%= f.text_field :state %>
+ <%= f.label :Zip %>:
+ <%= f.text_field :zip %>
+ <%= f.submit "Submit" %>
+<% end %>
+
diff --git a/app/views/markets/index.html.erb b/app/views/markets/index.html.erb
new file mode 100644
index 00000000..3984ca89
--- /dev/null
+++ b/app/views/markets/index.html.erb
@@ -0,0 +1,14 @@
+Pick Your Market
+
+
+ <% if @link == 'market' %>
+ - <%= link_to "Create a Market", new_market_path %>
+ <% @markets.each do |market| %>
+ - <%=link_to market.name, market_path(market.id) %>
+ <% end %>
+ <% elsif @link == "user"%>
+ <% @markets.each do |market| %>
+ - <%= link_to market.name, user_show_path(market.id) %>
+ <% end %>
+ <% end %>
+
diff --git a/app/views/markets/mainpage.html.erb b/app/views/markets/mainpage.html.erb
new file mode 100644
index 00000000..8007b551
--- /dev/null
+++ b/app/views/markets/mainpage.html.erb
@@ -0,0 +1,8 @@
+
diff --git a/app/views/markets/new.html.erb b/app/views/markets/new.html.erb
new file mode 100644
index 00000000..fa7785ba
--- /dev/null
+++ b/app/views/markets/new.html.erb
@@ -0,0 +1,17 @@
+
+<%= form_for @market do |f| %>
+ <%= f.label :Name %>:
+ <%= f.text_field :name %>
+ <%= f.label :Address %>:
+ <%= f.text_field :address %>
+ <%= f.label :City %>:
+ <%= f.text_field :city %>
+ <%= f.label :County %>:
+ <%= f.text_field :county %>
+ <%= f.label :State %>:
+ <%= f.text_field :state %>
+ <%= f.label :Zip %>:
+ <%= f.text_field :zip %>
+ <%= f.submit "Submit" %>
+<% end %>
+
diff --git a/app/views/markets/show.html.erb b/app/views/markets/show.html.erb
new file mode 100644
index 00000000..6d433648
--- /dev/null
+++ b/app/views/markets/show.html.erb
@@ -0,0 +1,42 @@
+
+
+ <%= @market.name %>
+ <% if @link == "market" %>
+ - <%= link_to "Edit Market", edit_market_path %>
+ <% end %>
+
+ -
+ <%= @market.address %>,
+ <%= @market.city %>,
+ <%= @market.state %>,
+ <%= @market.zip %>
+
+
+
+
+
+
+ List of Vendors
+
+ <% if @link == "market" %>
+ - <%= link_to "Add Vendor", new_market_vendor_path(@market.id) %>
+ <% end %>
+
+
+ <% @vendors.each do |vendor| %>
+ -
+ <%= vendor.name %>
+
+ -
+ <% if @link == "market" %>
+ <%= link_to "Edit", edit_market_vendor_path(vendor.market, vendor) %> |
+ <%= link_to "Delete", market_vendor_path(@market, vendor), method: :delete, data: {confirm: "Are you sure?"} %>
+ <% end %>
+ <% if vendor != nil %>
+ <% else %>
+ <%= @msg %>
+ <% end %>
+
+ <% end %>
+
+
diff --git a/app/views/products/_form.html.erb b/app/views/products/_form.html.erb
new file mode 100644
index 00000000..d4240a36
--- /dev/null
+++ b/app/views/products/_form.html.erb
@@ -0,0 +1,5 @@
+<%= form_for product, method: http_method do |f| %>
+ <%= f.label :Name %>:
+ <%= f.text_field :name %>
+ <%= f.submit "Submit" %>
+<% end %>
diff --git a/app/views/products/edit.html.erb b/app/views/products/edit.html.erb
new file mode 100644
index 00000000..3d199668
--- /dev/null
+++ b/app/views/products/edit.html.erb
@@ -0,0 +1,14 @@
+<%# form_for vendor_product_path(params[:vendor_id], params[:id]), method: :patch do |f| %>
+
+<%# form_for @vendor, url: {action: "create"} do, was only using second param? %>
+<%# form_for [@market, @vendor] do %>
+
+
+ <%= @vendor_product.name %>
+ Edit Product
+ <%= form_for @vendor_product, url: {action: "update"} do |f| %>
+
<%= f.label :Name %>:
+ <%= f.text_field :name %>
+ <%= f.submit "Submit" %>
+ <% end %>
+
diff --git a/app/views/products/new.html.erb b/app/views/products/new.html.erb
new file mode 100644
index 00000000..d812f9e4
--- /dev/null
+++ b/app/views/products/new.html.erb
@@ -0,0 +1,5 @@
+
+ <%= @vendor.name %>
+ Add New Product
+ <%= render partial: "form", locals: { product: [:vendor, @vendor_product], http_method: :post } %>
+
diff --git a/app/views/products/show.html.erb b/app/views/products/show.html.erb
new file mode 100644
index 00000000..d73402f1
--- /dev/null
+++ b/app/views/products/show.html.erb
@@ -0,0 +1,6 @@
+<%= @vendor_product.name %>
+
+Product Details
+
+ - Product ID: <%= @vendor_product.id.to_s %>
+
diff --git a/app/views/sales/new.html.erb b/app/views/sales/new.html.erb
new file mode 100644
index 00000000..30abb54b
--- /dev/null
+++ b/app/views/sales/new.html.erb
@@ -0,0 +1,14 @@
+
+
+ <%= @product.name %>
+ Add New Sale
+ <%= form_for @sale, url: {action: "create"} do |f| %>
+
<%= f.label :Amount %>:
+ <%= f.number_field :amount, required: true %>
+
+ <%= f.label :Purchase_Time %>:
+ <%= f.datetime_local_field :purchase_time, required: true %>
+
+ <%= f.submit "Submit" %>
+ <% end %>
+
diff --git a/app/views/vendors/_form.html.erb b/app/views/vendors/_form.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/vendors/_sales_table.html.erb b/app/views/vendors/_sales_table.html.erb
new file mode 100644
index 00000000..8b24a6f5
--- /dev/null
+++ b/app/views/vendors/_sales_table.html.erb
@@ -0,0 +1,21 @@
+
+
+
+ <% @attribute_keys.each do |a| %>
+ <%= a.to_s %> |
+ <% end %>
+
+
+
+ <% sales.each do |sale| %>
+
+ <% sale.attributes.each do |k, v| %>
+
+ <%= v %>
+ |
+ <% end %>
+
+ <% end %>
+
+
+<%= "TOTAL: $#{sales_total}" %>
diff --git a/app/views/vendors/edit.html.erb b/app/views/vendors/edit.html.erb
new file mode 100644
index 00000000..a5b615e7
--- /dev/null
+++ b/app/views/vendors/edit.html.erb
@@ -0,0 +1,9 @@
+
+<%= form_for([@market, @vendor]) do |f| %>
+ <%= f.label :Name %>:
+ <%= f.text_field :name %>
+ <%= f.label :Number_of_employees %>:
+ <%= f.text_field :number_of_employees %>
+ <%= f.submit "Submit" %>
+<% end %>
+
diff --git a/app/views/vendors/index.html.erb b/app/views/vendors/index.html.erb
new file mode 100644
index 00000000..c8b63bf5
--- /dev/null
+++ b/app/views/vendors/index.html.erb
@@ -0,0 +1,9 @@
+
+Pick Your Vendor
+
+ <% @vendors_all.each do |vendor| %>
+ -
+ <%= link_to vendor.name, vendor_path(vendor.id) %>
+
+ <% end %>
+
diff --git a/app/views/vendors/new.html.erb b/app/views/vendors/new.html.erb
new file mode 100644
index 00000000..1ac4fd55
--- /dev/null
+++ b/app/views/vendors/new.html.erb
@@ -0,0 +1,11 @@
+
+
+
+<%= form_for @vendor, url: {action: "create"} do |f| %>
+ <%= f.label :Name %>:
+ <%= f.text_field :name %>
+ <%= f.label :Number_of_employees %>:
+ <%= f.text_field :number_of_employees %>
+ <%= f.submit "Submit" %>
+<% end %>
+
diff --git a/app/views/vendors/show.html.erb b/app/views/vendors/show.html.erb
new file mode 100644
index 00000000..ad627c60
--- /dev/null
+++ b/app/views/vendors/show.html.erb
@@ -0,0 +1,30 @@
+
+<%= @vendor.name %>
+ Vendor ID: <%= @vendor.id %> | Number of Employees: <%= @vendor.number_of_employees %>
+<%= @vendor_market %>
+ <%= @full_address %>
+
+Products
+ <%= link_to "Add Product", new_vendor_product_path(params[:id]) %>
+
+ <% @products.each do |product| %>
+ -
+ <%= product.name %>
+
+ - <%= link_to "Edit", edit_vendor_product_path(params[:id], product.id) %> | <%= link_to "Delete", vendor_product_path(params[:id], product.id), method: :delete, data: { confirm: "Are you sure?"} %> | <%= link_to "Add Sale", new_vendor_product_sale_path(params[:id], product.id) %>
+ <% end %>
+
+
+
+ Sales
+ <% if @sales.empty? %>
+
+ <%= @vendor.name %> has no sales to date.
+
+ <% else %>
+ ALL SALES
+ <%= render partial: "sales_table", locals: { sales: @sales, sales_total: @sales_total } %>
+ CURRENT MONTH SALES
+ <%= render partial: "sales_table", locals: { sales: @month_sales, sales_total: @current_month_total } %>
+ <% end %>
+
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 5c1b32e4..4484854c 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -23,13 +23,13 @@
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
-
+ config.serve_static_assets = true
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
- config.assets.compile = false
+ config.assets.compile = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
@@ -38,8 +38,8 @@
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
- # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
+ config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
diff --git a/config/routes.rb b/config/routes.rb
index 3f66539d..3765e8e2 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,4 +1,23 @@
Rails.application.routes.draw do
+ root 'markets#mainpage'
+
+ # get '/markets' => 'markets#mainpage'
+
+ get 'markets/user_all' => 'markets#user_all'
+
+ get 'markets/:id/user_show' => 'markets#user_show', as: :user_show
+
+ resources :markets, except: [:destroy] do
+ resources :vendors, except: [:show]
+ end
+
+ resources :vendors do
+ resources :products, except: [:index, :show] do
+ resources :sales, except: [:index, :show, :destroy]
+ end
+ end
+
+
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
diff --git a/data-diagram.jpg b/data-diagram.jpg
new file mode 100644
index 00000000..fb27647e
Binary files /dev/null and b/data-diagram.jpg differ
diff --git a/db/migrate/20161004215954_create_markets.rb b/db/migrate/20161004215954_create_markets.rb
new file mode 100644
index 00000000..92ba65a0
--- /dev/null
+++ b/db/migrate/20161004215954_create_markets.rb
@@ -0,0 +1,15 @@
+class CreateMarkets < ActiveRecord::Migration
+ def change
+ create_table :markets do |t|
+ t.string :name
+ t.string :address
+ t.string :city
+ t.string :county
+ t.string :state
+ t.string :zip
+
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20161004220007_create_vendors.rb b/db/migrate/20161004220007_create_vendors.rb
new file mode 100644
index 00000000..0b42335b
--- /dev/null
+++ b/db/migrate/20161004220007_create_vendors.rb
@@ -0,0 +1,10 @@
+class CreateVendors < ActiveRecord::Migration
+ def change
+ create_table :vendors do |t|
+ t.belongs_to :market, index: true
+ t.string :name
+ t.integer :number_of_employees
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20161004220016_create_products.rb b/db/migrate/20161004220016_create_products.rb
new file mode 100644
index 00000000..68776730
--- /dev/null
+++ b/db/migrate/20161004220016_create_products.rb
@@ -0,0 +1,9 @@
+class CreateProducts < ActiveRecord::Migration
+ def change
+ create_table :products do |t|
+ t.belongs_to :vendor, index: true
+ t.string :name
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20161004220021_create_sales.rb b/db/migrate/20161004220021_create_sales.rb
new file mode 100644
index 00000000..bffdaa23
--- /dev/null
+++ b/db/migrate/20161004220021_create_sales.rb
@@ -0,0 +1,11 @@
+class CreateSales < ActiveRecord::Migration
+ def change
+ create_table :sales do |t|
+ t.belongs_to :product, index: true
+ t.integer :amount
+ t.datetime :purchase_time
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 00000000..064ce002
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,56 @@
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema.define(version: 20161004220021) do
+
+ create_table "markets", force: :cascade do |t|
+ t.string "name"
+ t.string "address"
+ t.string "city"
+ t.string "county"
+ t.string "state"
+ t.string "zip"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "products", force: :cascade do |t|
+ t.integer "vendor_id"
+ t.string "name"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ add_index "products", ["vendor_id"], name: "index_products_on_vendor_id"
+
+ create_table "sales", force: :cascade do |t|
+ t.integer "product_id"
+ t.integer "amount"
+ t.datetime "purchase_time"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ add_index "sales", ["product_id"], name: "index_sales_on_product_id"
+
+ create_table "vendors", force: :cascade do |t|
+ t.integer "market_id"
+ t.string "name"
+ t.integer "number_of_employees"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ add_index "vendors", ["market_id"], name: "index_vendors_on_market_id"
+
+end
diff --git a/db/seeds.rb b/db/seeds.rb
index 4edb1e85..255037e9 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -5,3 +5,40 @@
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
+
+require 'csv'
+
+CSV.read('./seed_csvs/markets.csv').each do |line|
+ Market.create(
+ id: line[0].to_i,
+ name: line[1],
+ address: line[2],
+ city: line[3],
+ county: line[4],
+ state: line[5],
+ zip: line[6])
+ # info << Market.new(id, name, address, city, county, state, zip)
+end
+
+CSV.read('./seed_csvs/vendors.csv').each do |line|
+ Vendor.create(
+ id: line[0].to_i,
+ name: line[1],
+ number_of_employees: line[2].to_i,
+ market_id: line[3].to_i)
+end
+
+CSV.read('./seed_csvs/products.csv').each do |line|
+ Product.create(
+ id: line[0].to_i,
+ name: line[1],
+ vendor_id: line[2].to_i)
+end
+
+CSV.read('./seed_csvs/sales.csv').each do |line|
+ Sale.create(
+ id: line[0].to_i,
+ amount: line[1].to_i,
+ purchase_time: DateTime.parse(line[2]),
+ product_id: line[4].to_i)
+end
diff --git a/erd.pdf b/erd.pdf
new file mode 100644
index 00000000..5fab8423
Binary files /dev/null and b/erd.pdf differ
diff --git a/public/assets/.sprockets-manifest-a00561ca05a1585ddae2acbaf6f1a92f.json b/public/assets/.sprockets-manifest-a00561ca05a1585ddae2acbaf6f1a92f.json
new file mode 100644
index 00000000..f868ea7e
--- /dev/null
+++ b/public/assets/.sprockets-manifest-a00561ca05a1585ddae2acbaf6f1a92f.json
@@ -0,0 +1 @@
+{"files":{"tomatoes-8e4ba6baf2c68b4f0e874edc19506e2965848893d57a3b837daa3b1abe140c26.jpg":{"logical_path":"tomatoes.jpg","mtime":"2016-10-07T12:33:37-07:00","size":1268619,"digest":"8e4ba6baf2c68b4f0e874edc19506e2965848893d57a3b837daa3b1abe140c26","integrity":"sha256-jkumuvLGi08Oh07cGVBuKWWEiJPVejuDfao7Gr4UDCY="},"application-65b06790c910bd8b6e026af00c16cb539012b9dcab62fc2b7effa7d9b2655b44.js":{"logical_path":"application.js","mtime":"2016-10-07T15:55:22-07:00","size":141159,"digest":"65b06790c910bd8b6e026af00c16cb539012b9dcab62fc2b7effa7d9b2655b44","integrity":"sha256-ZbBnkMkQvYtuAmrwDBbLU5ASudyrYvwrfv+n2bJlW0Q="},"application-fb025b2607ad5a7ca969a2bc30eeec01c3b9a7156609245e41b010f7161c50a8.css":{"logical_path":"application.css","mtime":"2016-10-07T17:25:03-07:00","size":1504,"digest":"fb025b2607ad5a7ca969a2bc30eeec01c3b9a7156609245e41b010f7161c50a8","integrity":"sha256-+wJbJgetWnypaaK8MO7sAcO5pxVmCSReQbAQ9xYcUKg="},"application-a7d29684701f6d7c82f9614038c707529599049919dcd2be8367962fd7e3d5d3.css":{"logical_path":"application.css","mtime":"2016-10-08T15:32:08-07:00","size":1525,"digest":"a7d29684701f6d7c82f9614038c707529599049919dcd2be8367962fd7e3d5d3","integrity":"sha256-p9KWhHAfbXyC+WFAOMcHUpWZBJkZ3NK+g2eWL9fj1dM="}},"assets":{"tomatoes.jpg":"tomatoes-8e4ba6baf2c68b4f0e874edc19506e2965848893d57a3b837daa3b1abe140c26.jpg","application.js":"application-65b06790c910bd8b6e026af00c16cb539012b9dcab62fc2b7effa7d9b2655b44.js","application.css":"application-a7d29684701f6d7c82f9614038c707529599049919dcd2be8367962fd7e3d5d3.css"}}
\ No newline at end of file
diff --git a/public/assets/application-65b06790c910bd8b6e026af00c16cb539012b9dcab62fc2b7effa7d9b2655b44.js b/public/assets/application-65b06790c910bd8b6e026af00c16cb539012b9dcab62fc2b7effa7d9b2655b44.js
new file mode 100644
index 00000000..b9881ee4
--- /dev/null
+++ b/public/assets/application-65b06790c910bd8b6e026af00c16cb539012b9dcab62fc2b7effa7d9b2655b44.js
@@ -0,0 +1,5 @@
+!function(t,e){"object"==typeof module&&"object"==typeof module.exports?module.exports=t.document?e(t,!0):function(t){if(!t.document)throw new Error("jQuery requires a window with a document");return e(t)}:e(t)}("undefined"!=typeof window?window:this,function(t,e){function n(t){var e=!!t&&"length"in t&&t.length,n=ft.type(t);return"function"!==n&&!ft.isWindow(t)&&("array"===n||0===e||"number"==typeof e&&e>0&&e-1 in t)}function r(t,e,n){if(ft.isFunction(e))return ft.grep(t,function(t,r){return!!e.call(t,r,t)!==n});if(e.nodeType)return ft.grep(t,function(t){return t===e!==n});if("string"==typeof e){if(Tt.test(e))return ft.filter(e,t,n);e=ft.filter(e,t)}return ft.grep(t,function(t){return ft.inArray(t,e)>-1!==n})}function i(t,e){do t=t[e];while(t&&1!==t.nodeType);return t}function o(t){var e={};return ft.each(t.match(At)||[],function(t,n){e[n]=!0}),e}function a(){rt.addEventListener?(rt.removeEventListener("DOMContentLoaded",s),t.removeEventListener("load",s)):(rt.detachEvent("onreadystatechange",s),t.detachEvent("onload",s))}function s(){(rt.addEventListener||"load"===t.event.type||"complete"===rt.readyState)&&(a(),ft.ready())}function u(t,e,n){if(void 0===n&&1===t.nodeType){var r="data-"+e.replace(Ht,"-$1").toLowerCase();if(n=t.getAttribute(r),"string"==typeof n){try{n="true"===n||"false"!==n&&("null"===n?null:+n+""===n?+n:jt.test(n)?ft.parseJSON(n):n)}catch(t){}ft.data(t,e,n)}else n=void 0}return n}function l(t){var e;for(e in t)if(("data"!==e||!ft.isEmptyObject(t[e]))&&"toJSON"!==e)return!1;return!0}function c(t,e,n,r){if(Dt(t)){var i,o,a=ft.expando,s=t.nodeType,u=s?ft.cache:t,l=s?t[a]:t[a]&&a;if(l&&u[l]&&(r||u[l].data)||void 0!==n||"string"!=typeof e)return l||(l=s?t[a]=nt.pop()||ft.guid++:a),u[l]||(u[l]=s?{}:{toJSON:ft.noop}),"object"!=typeof e&&"function"!=typeof e||(r?u[l]=ft.extend(u[l],e):u[l].data=ft.extend(u[l].data,e)),o=u[l],r||(o.data||(o.data={}),o=o.data),void 0!==n&&(o[ft.camelCase(e)]=n),"string"==typeof e?(i=o[e],null==i&&(i=o[ft.camelCase(e)])):i=o,i}}function d(t,e,n){if(Dt(t)){var r,i,o=t.nodeType,a=o?ft.cache:t,s=o?t[ft.expando]:ft.expando;if(a[s]){if(e&&(r=n?a[s]:a[s].data)){ft.isArray(e)?e=e.concat(ft.map(e,ft.camelCase)):e in r?e=[e]:(e=ft.camelCase(e),e=e in r?[e]:e.split(" ")),i=e.length;for(;i--;)delete r[e[i]];if(n?!l(r):!ft.isEmptyObject(r))return}(n||(delete a[s].data,l(a[s])))&&(o?ft.cleanData([t],!0):dt.deleteExpando||a!=a.window?delete a[s]:a[s]=void 0)}}}function p(t,e,n,r){var i,o=1,a=20,s=r?function(){return r.cur()}:function(){return ft.css(t,e,"")},u=s(),l=n&&n[3]||(ft.cssNumber[e]?"":"px"),c=(ft.cssNumber[e]||"px"!==l&&+u)&&Ft.exec(ft.css(t,e));if(c&&c[3]!==l){l=l||c[3],n=n||[],c=+u||1;do o=o||".5",c/=o,ft.style(t,e,c+l);while(o!==(o=s()/u)&&1!==o&&--a)}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}function f(t){var e=Vt.split("|"),n=t.createDocumentFragment();if(n.createElement)for(;e.length;)n.createElement(e.pop());return n}function h(t,e){var n,r,i=0,o="undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e||"*"):"undefined"!=typeof t.querySelectorAll?t.querySelectorAll(e||"*"):void 0;if(!o)for(o=[],n=t.childNodes||t;null!=(r=n[i]);i++)!e||ft.nodeName(r,e)?o.push(r):ft.merge(o,h(r,e));return void 0===e||e&&ft.nodeName(t,e)?ft.merge([t],o):o}function m(t,e){for(var n,r=0;null!=(n=t[r]);r++)ft._data(n,"globalEval",!e||ft._data(e[r],"globalEval"))}function y(t){Ot.test(t.type)&&(t.defaultChecked=t.checked)}function g(t,e,n,r,i){for(var o,a,s,u,l,c,d,p=t.length,g=f(e),v=[],b=0;b"!==d[1]||Xt.test(a)?0:u:u.firstChild,o=a&&a.childNodes.length;o--;)ft.nodeName(c=a.childNodes[o],"tbody")&&!c.childNodes.length&&a.removeChild(c);for(ft.merge(v,u.childNodes),u.textContent="";u.firstChild;)u.removeChild(u.firstChild);u=g.lastChild}else v.push(e.createTextNode(a));for(u&&g.removeChild(u),dt.appendChecked||ft.grep(h(v,"input"),y),b=0;a=v[b++];)if(r&&ft.inArray(a,r)>-1)i&&i.push(a);else if(s=ft.contains(a.ownerDocument,a),u=h(g.appendChild(a),"script"),s&&m(u),n)for(o=0;a=u[o++];)Wt.test(a.type||"")&&n.push(a);return u=null,g}function v(){return!0}function b(){return!1}function x(){try{return rt.activeElement}catch(t){}}function w(t,e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=void 0);for(s in e)w(t,s,n,r,e[s],o);return t}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),i===!1)i=b;else if(!i)return t;return 1===o&&(a=i,i=function(t){return ft().off(t),a.apply(this,arguments)},i.guid=a.guid||(a.guid=ft.guid++)),t.each(function(){ft.event.add(this,e,i,r,n)})}function E(t,e){return ft.nodeName(t,"table")&&ft.nodeName(11!==e.nodeType?e:e.firstChild,"tr")?t.getElementsByTagName("tbody")[0]||t.appendChild(t.ownerDocument.createElement("tbody")):t}function T(t){return t.type=(null!==ft.find.attr(t,"type"))+"/"+t.type,t}function S(t){var e=ie.exec(t.type);return e?t.type=e[1]:t.removeAttribute("type"),t}function C(t,e){if(1===e.nodeType&&ft.hasData(t)){var n,r,i,o=ft._data(t),a=ft._data(e,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;r1&&"string"==typeof f&&!dt.checkClone&&re.test(f))return t.each(function(i){var o=t.eq(i);m&&(e[0]=f.call(this,i,o.html())),L(o,e,n,r)});if(d&&(l=g(e,t[0].ownerDocument,!1,t,r),i=l.firstChild,1===l.childNodes.length&&(l=i),i||r)){for(s=ft.map(h(l,"script"),T),a=s.length;c")).appendTo(e.documentElement),e=(ue[0].contentWindow||ue[0].contentDocument).document,e.write(),e.close(),n=A(t,e),ue.detach()),le[t]=n),n}function R(t,e){return{get:function(){return t()?void delete this.get:(this.get=e).apply(this,arguments)}}}function D(t){if(t in Se)return t;for(var e=t.charAt(0).toUpperCase()+t.slice(1),n=Te.length;n--;)if(t=Te[n]+e,t in Se)return t}function j(t,e){for(var n,r,i,o=[],a=0,s=t.length;a=0&&n=0},isEmptyObject:function(t){var e;for(e in t)return!1;return!0},isPlainObject:function(t){var e;if(!t||"object"!==ft.type(t)||t.nodeType||ft.isWindow(t))return!1;try{if(t.constructor&&!ct.call(t,"constructor")&&!ct.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}if(!dt.ownFirst)for(e in t)return ct.call(t,e);for(e in t);return void 0===e||ct.call(t,e)},type:function(t){return null==t?t+"":"object"==typeof t||"function"==typeof t?ut[lt.call(t)]||"object":typeof t},globalEval:function(e){e&&ft.trim(e)&&(t.execScript||function(e){t.eval.call(t,e)})(e)},camelCase:function(t){return t.replace(mt,"ms-").replace(yt,gt)},nodeName:function(t,e){return t.nodeName&&t.nodeName.toLowerCase()===e.toLowerCase()},each:function(t,e){var r,i=0;if(n(t))for(r=t.length;iE.cacheLength&&delete t[e.shift()],t[n+" "]=r}var e=[];return t}function r(t){return t[M]=!0,t}function i(t){var e=D.createElement("div");try{return!!t(e)}catch(t){return!1}finally{e.parentNode&&e.parentNode.removeChild(e),e=null}}function o(t,e){for(var n=t.split("|"),r=n.length;r--;)E.attrHandle[n[r]]=e}function a(t,e){var n=e&&t,r=n&&1===t.nodeType&&1===e.nodeType&&(~e.sourceIndex||X)-(~t.sourceIndex||X);if(r)return r;if(n)for(;n=n.nextSibling;)if(n===e)return-1;return t?1:-1}function s(t){return function(e){var n=e.nodeName.toLowerCase();return"input"===n&&e.type===t}}function u(t){return function(e){var n=e.nodeName.toLowerCase();return("input"===n||"button"===n)&&e.type===t}}function l(t){return r(function(e){return e=+e,r(function(n,r){for(var i,o=t([],n.length,e),a=o.length;a--;)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function c(t){return t&&"undefined"!=typeof t.getElementsByTagName&&t}function d(){}function p(t){for(var e=0,n=t.length,r="";e1?function(e,n,r){for(var i=t.length;i--;)if(!t[i](e,n,r))return!1;return!0}:t[0]}function m(t,n,r){for(var i=0,o=n.length;i-1&&(r[l]=!(a[l]=d))}}else b=y(b===a?b.splice(h,b.length):b),o?o(null,a,b,u):Q.apply(a,b)})}function v(t){for(var e,n,r,i=t.length,o=E.relative[t[0].type],a=o||E.relative[" "],s=o?1:0,u=f(function(t){return t===e},a,!0),l=f(function(t){return tt(e,t)>-1},a,!0),c=[function(t,n,r){var i=!o&&(r||n!==N)||((e=n).nodeType?u(t,n,r):l(t,n,r));return e=null,i}];s1&&h(c),s>1&&p(t.slice(0,s-1).concat({value:" "===t[s-2].type?"*":""})).replace(st,"$1"),n,s0,o=t.length>0,a=function(r,a,s,u,l){var c,d,p,f=0,h="0",m=r&&[],g=[],v=N,b=r||o&&E.find.TAG("*",l),x=_+=null==v?1:Math.random()||.1,w=b.length;for(l&&(N=a===D||a||l);h!==w&&null!=(c=b[h]);h++){if(o&&c){for(d=0,a||c.ownerDocument===D||(R(c),s=!H);p=t[d++];)if(p(c,a||D,s)){u.push(c);break}l&&(_=x)}i&&((c=!p&&c)&&f--,r&&m.push(c))}if(f+=h,i&&h!==f){for(d=0;p=n[d++];)p(m,g,a,s);if(r){if(f>0)for(;h--;)m[h]||g[h]||(g[h]=Y.call(u));g=y(g)}Q.apply(u,g),l&&!r&&g.length>0&&f+n.length>1&&e.uniqueSort(u)}return l&&(_=x,N=v),m};return i?r(a):a}var x,w,E,T,S,C,k,L,N,A,q,R,D,j,H,P,F,I,B,M="sizzle"+1*new Date,O=t.document,_=0,W=0,z=n(),V=n(),$=n(),U=function(t,e){return t===e&&(q=!0),0},X=1<<31,K={}.hasOwnProperty,G=[],Y=G.pop,J=G.push,Q=G.push,Z=G.slice,tt=function(t,e){for(var n=0,r=t.length;n+~]|"+nt+")"+nt+"*"),ct=new RegExp("="+nt+"*([^\\]'\"]*?)"+nt+"*\\]","g"),dt=new RegExp(ot),pt=new RegExp("^"+rt+"$"),ft={ID:new RegExp("^#("+rt+")"),CLASS:new RegExp("^\\.("+rt+")"),TAG:new RegExp("^("+rt+"|[*])"),ATTR:new RegExp("^"+it),PSEUDO:new RegExp("^"+ot),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+nt+"*(even|odd|(([+-]|)(\\d*)n|)"+nt+"*(?:([+-]|)"+nt+"*(\\d+)|))"+nt+"*\\)|)","i"),bool:new RegExp("^(?:"+et+")$","i"),needsContext:new RegExp("^"+nt+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+nt+"*((?:-\\d)?\\d*)"+nt+"*\\)|)(?=[^-]|$)","i")},ht=/^(?:input|select|textarea|button)$/i,mt=/^h\d$/i,yt=/^[^{]+\{\s*\[native \w/,gt=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,vt=/[+~]/,bt=/'|\\/g,xt=new RegExp("\\\\([\\da-f]{1,6}"+nt+"?|("+nt+")|.)","ig"),wt=function(t,e,n){var r="0x"+e-65536;return r!==r||n?e:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},Et=function(){R()};try{Q.apply(G=Z.call(O.childNodes),O.childNodes),G[O.childNodes.length].nodeType}catch(t){Q={apply:G.length?function(t,e){J.apply(t,Z.call(e))}:function(t,e){for(var n=t.length,r=0;t[n++]=e[r++];);t.length=n-1}}}w=e.support={},S=e.isXML=function(t){var e=t&&(t.ownerDocument||t).documentElement;return!!e&&"HTML"!==e.nodeName},R=e.setDocument=function(t){var e,n,r=t?t.ownerDocument||t:O;return r!==D&&9===r.nodeType&&r.documentElement?(D=r,j=D.documentElement,H=!S(D),(n=D.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",Et,!1):n.attachEvent&&n.attachEvent("onunload",Et)),w.attributes=i(function(t){return t.className="i",!t.getAttribute("className")}),w.getElementsByTagName=i(function(t){return t.appendChild(D.createComment("")),!t.getElementsByTagName("*").length}),w.getElementsByClassName=yt.test(D.getElementsByClassName),w.getById=i(function(t){return j.appendChild(t).id=M,!D.getElementsByName||!D.getElementsByName(M).length}),w.getById?(E.find.ID=function(t,e){if("undefined"!=typeof e.getElementById&&H){var n=e.getElementById(t);return n?[n]:[]}},E.filter.ID=function(t){var e=t.replace(xt,wt);return function(t){return t.getAttribute("id")===e}}):(delete E.find.ID,E.filter.ID=function(t){var e=t.replace(xt,wt);return function(t){var n="undefined"!=typeof t.getAttributeNode&&t.getAttributeNode("id");return n&&n.value===e}}),E.find.TAG=w.getElementsByTagName?function(t,e){return"undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t):w.qsa?e.querySelectorAll(t):void 0}:function(t,e){var n,r=[],i=0,o=e.getElementsByTagName(t);if("*"===t){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},E.find.CLASS=w.getElementsByClassName&&function(t,e){if("undefined"!=typeof e.getElementsByClassName&&H)return e.getElementsByClassName(t)},F=[],P=[],(w.qsa=yt.test(D.querySelectorAll))&&(i(function(t){j.appendChild(t).innerHTML="",t.querySelectorAll("[msallowcapture^='']").length&&P.push("[*^$]="+nt+"*(?:''|\"\")"),t.querySelectorAll("[selected]").length||P.push("\\["+nt+"*(?:value|"+et+")"),t.querySelectorAll("[id~="+M+"-]").length||P.push("~="),t.querySelectorAll(":checked").length||P.push(":checked"),t.querySelectorAll("a#"+M+"+*").length||P.push(".#.+[+~]")}),i(function(t){var e=D.createElement("input");e.setAttribute("type","hidden"),t.appendChild(e).setAttribute("name","D"),t.querySelectorAll("[name=d]").length&&P.push("name"+nt+"*[*^$|!~]?="),t.querySelectorAll(":enabled").length||P.push(":enabled",":disabled"),t.querySelectorAll("*,:x"),P.push(",.*:")})),(w.matchesSelector=yt.test(I=j.matches||j.webkitMatchesSelector||j.mozMatchesSelector||j.oMatchesSelector||j.msMatchesSelector))&&i(function(t){w.disconnectedMatch=I.call(t,"div"),I.call(t,"[s!='']:x"),F.push("!=",ot)}),P=P.length&&new RegExp(P.join("|")),F=F.length&&new RegExp(F.join("|")),e=yt.test(j.compareDocumentPosition),B=e||yt.test(j.contains)?function(t,e){var n=9===t.nodeType?t.documentElement:t,r=e&&e.parentNode;return t===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):t.compareDocumentPosition&&16&t.compareDocumentPosition(r)))}:function(t,e){if(e)for(;e=e.parentNode;)if(e===t)return!0;return!1},U=e?function(t,e){if(t===e)return q=!0,0;var n=!t.compareDocumentPosition-!e.compareDocumentPosition;return n?n:(n=(t.ownerDocument||t)===(e.ownerDocument||e)?t.compareDocumentPosition(e):1,1&n||!w.sortDetached&&e.compareDocumentPosition(t)===n?t===D||t.ownerDocument===O&&B(O,t)?-1:e===D||e.ownerDocument===O&&B(O,e)?1:A?tt(A,t)-tt(A,e):0:4&n?-1:1)}:function(t,e){if(t===e)return q=!0,0;var n,r=0,i=t.parentNode,o=e.parentNode,s=[t],u=[e];if(!i||!o)return t===D?-1:e===D?1:i?-1:o?1:A?tt(A,t)-tt(A,e):0;if(i===o)return a(t,e);for(n=t;n=n.parentNode;)s.unshift(n);for(n=e;n=n.parentNode;)u.unshift(n);for(;s[r]===u[r];)r++;return r?a(s[r],u[r]):s[r]===O?-1:u[r]===O?1:0},D):D},e.matches=function(t,n){return e(t,null,null,n)},e.matchesSelector=function(t,n){if((t.ownerDocument||t)!==D&&R(t),n=n.replace(ct,"='$1']"),w.matchesSelector&&H&&!$[n+" "]&&(!F||!F.test(n))&&(!P||!P.test(n)))try{var r=I.call(t,n);if(r||w.disconnectedMatch||t.document&&11!==t.document.nodeType)return r}catch(t){}return e(n,D,null,[t]).length>0},e.contains=function(t,e){return(t.ownerDocument||t)!==D&&R(t),B(t,e)},e.attr=function(t,e){(t.ownerDocument||t)!==D&&R(t);var n=E.attrHandle[e.toLowerCase()],r=n&&K.call(E.attrHandle,e.toLowerCase())?n(t,e,!H):void 0;return void 0!==r?r:w.attributes||!H?t.getAttribute(e):(r=t.getAttributeNode(e))&&r.specified?r.value:null},e.error=function(t){throw new Error("Syntax error, unrecognized expression: "+t)},e.uniqueSort=function(t){var e,n=[],r=0,i=0;if(q=!w.detectDuplicates,A=!w.sortStable&&t.slice(0),t.sort(U),q){for(;e=t[i++];)e===t[i]&&(r=n.push(i));for(;r--;)t.splice(n[r],1)}return A=null,t},T=e.getText=function(t){var e,n="",r=0,i=t.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof t.textContent)return t.textContent;for(t=t.firstChild;t;t=t.nextSibling)n+=T(t)}else if(3===i||4===i)return t.nodeValue}else for(;e=t[r++];)n+=T(e);return n},E=e.selectors={cacheLength:50,createPseudo:r,match:ft,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(t){return t[1]=t[1].replace(xt,wt),t[3]=(t[3]||t[4]||t[5]||"").replace(xt,wt),"~="===t[2]&&(t[3]=" "+t[3]+" "),t.slice(0,4)},CHILD:function(t){return t[1]=t[1].toLowerCase(),"nth"===t[1].slice(0,3)?(t[3]||e.error(t[0]),t[4]=+(t[4]?t[5]+(t[6]||1):2*("even"===t[3]||"odd"===t[3])),t[5]=+(t[7]+t[8]||"odd"===t[3])):t[3]&&e.error(t[0]),t},PSEUDO:function(t){var e,n=!t[6]&&t[2];return ft.CHILD.test(t[0])?null:(t[3]?t[2]=t[4]||t[5]||"":n&&dt.test(n)&&(e=C(n,!0))&&(e=n.indexOf(")",n.length-e)-n.length)&&(t[0]=t[0].slice(0,e),t[2]=n.slice(0,e)),t.slice(0,3))}},filter:{TAG:function(t){var e=t.replace(xt,wt).toLowerCase();return"*"===t?function(){return!0}:function(t){return t.nodeName&&t.nodeName.toLowerCase()===e}},CLASS:function(t){var e=z[t+" "];return e||(e=new RegExp("(^|"+nt+")"+t+"("+nt+"|$)"))&&z(t,function(t){return e.test("string"==typeof t.className&&t.className||"undefined"!=typeof t.getAttribute&&t.getAttribute("class")||"")})},ATTR:function(t,n,r){return function(i){var o=e.attr(i,t);return null==o?"!="===n:!n||(o+="","="===n?o===r:"!="===n?o!==r:"^="===n?r&&0===o.indexOf(r):"*="===n?r&&o.indexOf(r)>-1:"$="===n?r&&o.slice(-r.length)===r:"~="===n?(" "+o.replace(at," ")+" ").indexOf(r)>-1:"|="===n&&(o===r||o.slice(0,r.length+1)===r+"-"))}},CHILD:function(t,e,n,r,i){var o="nth"!==t.slice(0,3),a="last"!==t.slice(-4),s="of-type"===e;return 1===r&&0===i?function(t){return!!t.parentNode}:function(e,n,u){var l,c,d,p,f,h,m=o!==a?"nextSibling":"previousSibling",y=e.parentNode,g=s&&e.nodeName.toLowerCase(),v=!u&&!s,b=!1;if(y){if(o){for(;m;){for(p=e;p=p[m];)if(s?p.nodeName.toLowerCase()===g:1===p.nodeType)return!1;h=m="only"===t&&!h&&"nextSibling"}return!0}if(h=[a?y.firstChild:y.lastChild],a&&v){for(p=y,d=p[M]||(p[M]={}),c=d[p.uniqueID]||(d[p.uniqueID]={}),l=c[t]||[],f=l[0]===_&&l[1],b=f&&l[2],p=f&&y.childNodes[f];p=++f&&p&&p[m]||(b=f=0)||h.pop();)if(1===p.nodeType&&++b&&p===e){c[t]=[_,f,b];break}}else if(v&&(p=e,d=p[M]||(p[M]={}),c=d[p.uniqueID]||(d[p.uniqueID]={}),l=c[t]||[],f=l[0]===_&&l[1],b=f),b===!1)for(;(p=++f&&p&&p[m]||(b=f=0)||h.pop())&&((s?p.nodeName.toLowerCase()!==g:1!==p.nodeType)||!++b||(v&&(d=p[M]||(p[M]={}),c=d[p.uniqueID]||(d[p.uniqueID]={}),c[t]=[_,b]),p!==e)););return b-=i,b===r||b%r===0&&b/r>=0}}},PSEUDO:function(t,n){var i,o=E.pseudos[t]||E.setFilters[t.toLowerCase()]||e.error("unsupported pseudo: "+t);return o[M]?o(n):o.length>1?(i=[t,t,"",n],E.setFilters.hasOwnProperty(t.toLowerCase())?r(function(t,e){for(var r,i=o(t,n),a=i.length;a--;)r=tt(t,i[a]),t[r]=!(e[r]=i[a])}):function(t){return o(t,0,i)}):o}},pseudos:{not:r(function(t){
+var e=[],n=[],i=k(t.replace(st,"$1"));return i[M]?r(function(t,e,n,r){for(var o,a=i(t,null,r,[]),s=t.length;s--;)(o=a[s])&&(t[s]=!(e[s]=o))}):function(t,r,o){return e[0]=t,i(e,null,o,n),e[0]=null,!n.pop()}}),has:r(function(t){return function(n){return e(t,n).length>0}}),contains:r(function(t){return t=t.replace(xt,wt),function(e){return(e.textContent||e.innerText||T(e)).indexOf(t)>-1}}),lang:r(function(t){return pt.test(t||"")||e.error("unsupported lang: "+t),t=t.replace(xt,wt).toLowerCase(),function(e){var n;do if(n=H?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return n=n.toLowerCase(),n===t||0===n.indexOf(t+"-");while((e=e.parentNode)&&1===e.nodeType);return!1}}),target:function(e){var n=t.location&&t.location.hash;return n&&n.slice(1)===e.id},root:function(t){return t===j},focus:function(t){return t===D.activeElement&&(!D.hasFocus||D.hasFocus())&&!!(t.type||t.href||~t.tabIndex)},enabled:function(t){return t.disabled===!1},disabled:function(t){return t.disabled===!0},checked:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&!!t.checked||"option"===e&&!!t.selected},selected:function(t){return t.parentNode&&t.parentNode.selectedIndex,t.selected===!0},empty:function(t){for(t=t.firstChild;t;t=t.nextSibling)if(t.nodeType<6)return!1;return!0},parent:function(t){return!E.pseudos.empty(t)},header:function(t){return mt.test(t.nodeName)},input:function(t){return ht.test(t.nodeName)},button:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&"button"===t.type||"button"===e},text:function(t){var e;return"input"===t.nodeName.toLowerCase()&&"text"===t.type&&(null==(e=t.getAttribute("type"))||"text"===e.toLowerCase())},first:l(function(){return[0]}),last:l(function(t,e){return[e-1]}),eq:l(function(t,e,n){return[n<0?n+e:n]}),even:l(function(t,e){for(var n=0;n=0;)t.push(r);return t}),gt:l(function(t,e,n){for(var r=n<0?n+e:n;++r2&&"ID"===(a=o[0]).type&&w.getById&&9===e.nodeType&&H&&E.relative[o[1].type]){if(e=(E.find.ID(a.matches[0].replace(xt,wt),e)||[])[0],!e)return n;l&&(e=e.parentNode),t=t.slice(o.shift().value.length)}for(i=ft.needsContext.test(t)?0:o.length;i--&&(a=o[i],!E.relative[s=a.type]);)if((u=E.find[s])&&(r=u(a.matches[0].replace(xt,wt),vt.test(o[0].type)&&c(e.parentNode)||e))){if(o.splice(i,1),t=r.length&&p(o),!t)return Q.apply(n,r),n;break}}return(l||k(t,d))(r,e,!H,n,!e||vt.test(t)&&c(e.parentNode)||e),n},w.sortStable=M.split("").sort(U).join("")===M,w.detectDuplicates=!!q,R(),w.sortDetached=i(function(t){return 1&t.compareDocumentPosition(D.createElement("div"))}),i(function(t){return t.innerHTML="","#"===t.firstChild.getAttribute("href")})||o("type|href|height|width",function(t,e,n){if(!n)return t.getAttribute(e,"type"===e.toLowerCase()?1:2)}),w.attributes&&i(function(t){return t.innerHTML="",t.firstChild.setAttribute("value",""),""===t.firstChild.getAttribute("value")})||o("value",function(t,e,n){if(!n&&"input"===t.nodeName.toLowerCase())return t.defaultValue}),i(function(t){return null==t.getAttribute("disabled")})||o(et,function(t,e,n){var r;if(!n)return t[e]===!0?e.toLowerCase():(r=t.getAttributeNode(e))&&r.specified?r.value:null}),e}(t);ft.find=vt,ft.expr=vt.selectors,ft.expr[":"]=ft.expr.pseudos,ft.uniqueSort=ft.unique=vt.uniqueSort,ft.text=vt.getText,ft.isXMLDoc=vt.isXML,ft.contains=vt.contains;var bt=function(t,e,n){for(var r=[],i=void 0!==n;(t=t[e])&&9!==t.nodeType;)if(1===t.nodeType){if(i&&ft(t).is(n))break;r.push(t)}return r},xt=function(t,e){for(var n=[];t;t=t.nextSibling)1===t.nodeType&&t!==e&&n.push(t);return n},wt=ft.expr.match.needsContext,Et=/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/,Tt=/^.[^:#\[\.,]*$/;ft.filter=function(t,e,n){var r=e[0];return n&&(t=":not("+t+")"),1===e.length&&1===r.nodeType?ft.find.matchesSelector(r,t)?[r]:[]:ft.find.matches(t,ft.grep(e,function(t){return 1===t.nodeType}))},ft.fn.extend({find:function(t){var e,n=[],r=this,i=r.length;if("string"!=typeof t)return this.pushStack(ft(t).filter(function(){for(e=0;e1?ft.unique(n):n),n.selector=this.selector?this.selector+" "+t:t,n},filter:function(t){return this.pushStack(r(this,t||[],!1))},not:function(t){return this.pushStack(r(this,t||[],!0))},is:function(t){return!!r(this,"string"==typeof t&&wt.test(t)?ft(t):t||[],!1).length}});var St,Ct=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,kt=ft.fn.init=function(t,e,n){var r,i;if(!t)return this;if(n=n||St,"string"==typeof t){if(r="<"===t.charAt(0)&&">"===t.charAt(t.length-1)&&t.length>=3?[null,t,null]:Ct.exec(t),!r||!r[1]&&e)return!e||e.jquery?(e||n).find(t):this.constructor(e).find(t);if(r[1]){if(e=e instanceof ft?e[0]:e,ft.merge(this,ft.parseHTML(r[1],e&&e.nodeType?e.ownerDocument||e:rt,!0)),Et.test(r[1])&&ft.isPlainObject(e))for(r in e)ft.isFunction(this[r])?this[r](e[r]):this.attr(r,e[r]);return this}if(i=rt.getElementById(r[2]),i&&i.parentNode){if(i.id!==r[2])return St.find(t);this.length=1,this[0]=i}return this.context=rt,this.selector=t,this}return t.nodeType?(this.context=this[0]=t,this.length=1,this):ft.isFunction(t)?"undefined"!=typeof n.ready?n.ready(t):t(ft):(void 0!==t.selector&&(this.selector=t.selector,this.context=t.context),ft.makeArray(t,this))};kt.prototype=ft.fn,St=ft(rt);var Lt=/^(?:parents|prev(?:Until|All))/,Nt={children:!0,contents:!0,next:!0,prev:!0};ft.fn.extend({has:function(t){var e,n=ft(t,this),r=n.length;return this.filter(function(){for(e=0;e-1:1===n.nodeType&&ft.find.matchesSelector(n,t))){o.push(n);break}return this.pushStack(o.length>1?ft.uniqueSort(o):o)},index:function(t){return t?"string"==typeof t?ft.inArray(this[0],ft(t)):ft.inArray(t.jquery?t[0]:t,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(t,e){return this.pushStack(ft.uniqueSort(ft.merge(this.get(),ft(t,e))))},addBack:function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}}),ft.each({parent:function(t){var e=t.parentNode;return e&&11!==e.nodeType?e:null},parents:function(t){return bt(t,"parentNode")},parentsUntil:function(t,e,n){return bt(t,"parentNode",n)},next:function(t){return i(t,"nextSibling")},prev:function(t){return i(t,"previousSibling")},nextAll:function(t){return bt(t,"nextSibling")},prevAll:function(t){return bt(t,"previousSibling")},nextUntil:function(t,e,n){return bt(t,"nextSibling",n)},prevUntil:function(t,e,n){return bt(t,"previousSibling",n)},siblings:function(t){return xt((t.parentNode||{}).firstChild,t)},children:function(t){return xt(t.firstChild)},contents:function(t){return ft.nodeName(t,"iframe")?t.contentDocument||t.contentWindow.document:ft.merge([],t.childNodes)}},function(t,e){ft.fn[t]=function(n,r){var i=ft.map(this,e,n);return"Until"!==t.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=ft.filter(r,i)),this.length>1&&(Nt[t]||(i=ft.uniqueSort(i)),Lt.test(t)&&(i=i.reverse())),this.pushStack(i)}});var At=/\S+/g;ft.Callbacks=function(t){t="string"==typeof t?o(t):ft.extend({},t);var e,n,r,i,a=[],s=[],u=-1,l=function(){for(i=t.once,r=e=!0;s.length;u=-1)for(n=s.shift();++u-1;)a.splice(n,1),n<=u&&u--}),this},has:function(t){return t?ft.inArray(t,a)>-1:a.length>0},empty:function(){return a&&(a=[]),this},disable:function(){return i=s=[],a=n="",this},disabled:function(){return!a},lock:function(){return i=!0,n||c.disable(),this},locked:function(){return!!i},fireWith:function(t,n){return i||(n=n||[],n=[t,n.slice?n.slice():n],s.push(n),e||l()),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!r}};return c},ft.extend({Deferred:function(t){var e=[["resolve","done",ft.Callbacks("once memory"),"resolved"],["reject","fail",ft.Callbacks("once memory"),"rejected"],["notify","progress",ft.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var t=arguments;return ft.Deferred(function(n){ft.each(e,function(e,o){var a=ft.isFunction(t[e])&&t[e];i[o[1]](function(){var t=a&&a.apply(this,arguments);t&&ft.isFunction(t.promise)?t.promise().progress(n.notify).done(n.resolve).fail(n.reject):n[o[0]+"With"](this===r?n.promise():this,a?[t]:arguments)})}),t=null}).promise()},promise:function(t){return null!=t?ft.extend(t,r):r}},i={};return r.pipe=r.then,ft.each(e,function(t,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},e[1^t][2].disable,e[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),t&&t.call(i,i),i},when:function(t){var e,n,r,i=0,o=it.call(arguments),a=o.length,s=1!==a||t&&ft.isFunction(t.promise)?a:0,u=1===s?t:ft.Deferred(),l=function(t,n,r){return function(i){n[t]=this,r[t]=arguments.length>1?it.call(arguments):i,r===e?u.notifyWith(n,r):--s||u.resolveWith(n,r)}};if(a>1)for(e=new Array(a),n=new Array(a),r=new Array(a);i0||(qt.resolveWith(rt,[ft]),ft.fn.triggerHandler&&(ft(rt).triggerHandler("ready"),ft(rt).off("ready"))))}}),ft.ready.promise=function(e){if(!qt)if(qt=ft.Deferred(),"complete"===rt.readyState||"loading"!==rt.readyState&&!rt.documentElement.doScroll)t.setTimeout(ft.ready);else if(rt.addEventListener)rt.addEventListener("DOMContentLoaded",s),t.addEventListener("load",s);else{rt.attachEvent("onreadystatechange",s),t.attachEvent("onload",s);var n=!1;try{n=null==t.frameElement&&rt.documentElement}catch(t){}n&&n.doScroll&&!function e(){if(!ft.isReady){try{n.doScroll("left")}catch(n){return t.setTimeout(e,50)}a(),ft.ready()}}()}return qt.promise(e)},ft.ready.promise();var Rt;for(Rt in ft(dt))break;dt.ownFirst="0"===Rt,dt.inlineBlockNeedsLayout=!1,ft(function(){var t,e,n,r;n=rt.getElementsByTagName("body")[0],n&&n.style&&(e=rt.createElement("div"),r=rt.createElement("div"),r.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",n.appendChild(r).appendChild(e),"undefined"!=typeof e.style.zoom&&(e.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",dt.inlineBlockNeedsLayout=t=3===e.offsetWidth,t&&(n.style.zoom=1)),n.removeChild(r))}),function(){var t=rt.createElement("div");dt.deleteExpando=!0;try{delete t.test}catch(t){dt.deleteExpando=!1}t=null}();var Dt=function(t){var e=ft.noData[(t.nodeName+" ").toLowerCase()],n=+t.nodeType||1;return(1===n||9===n)&&(!e||e!==!0&&t.getAttribute("classid")===e)},jt=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Ht=/([A-Z])/g;ft.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(t){return t=t.nodeType?ft.cache[t[ft.expando]]:t[ft.expando],!!t&&!l(t)},data:function(t,e,n){return c(t,e,n)},removeData:function(t,e){return d(t,e)},_data:function(t,e,n){return c(t,e,n,!0)},_removeData:function(t,e){return d(t,e,!0)}}),ft.fn.extend({data:function(t,e){var n,r,i,o=this[0],a=o&&o.attributes;if(void 0===t){if(this.length&&(i=ft.data(o),1===o.nodeType&&!ft._data(o,"parsedAttrs"))){for(n=a.length;n--;)a[n]&&(r=a[n].name,0===r.indexOf("data-")&&(r=ft.camelCase(r.slice(5)),u(o,r,i[r])));ft._data(o,"parsedAttrs",!0)}return i}return"object"==typeof t?this.each(function(){ft.data(this,t)}):arguments.length>1?this.each(function(){ft.data(this,t,e)}):o?u(o,t,ft.data(o,t)):void 0},removeData:function(t){return this.each(function(){ft.removeData(this,t)})}}),ft.extend({queue:function(t,e,n){var r;if(t)return e=(e||"fx")+"queue",r=ft._data(t,e),n&&(!r||ft.isArray(n)?r=ft._data(t,e,ft.makeArray(n)):r.push(n)),r||[]},dequeue:function(t,e){e=e||"fx";var n=ft.queue(t,e),r=n.length,i=n.shift(),o=ft._queueHooks(t,e),a=function(){ft.dequeue(t,e)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===e&&n.unshift("inprogress"),delete o.stop,i.call(t,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(t,e){var n=e+"queueHooks";return ft._data(t,n)||ft._data(t,n,{empty:ft.Callbacks("once memory").add(function(){ft._removeData(t,e+"queue"),ft._removeData(t,n)})})}}),ft.fn.extend({queue:function(t,e){var n=2;return"string"!=typeof t&&(e=t,t="fx",n--),arguments.lengtha",dt.leadingWhitespace=3===t.firstChild.nodeType,dt.tbody=!t.getElementsByTagName("tbody").length,dt.htmlSerialize=!!t.getElementsByTagName("link").length,dt.html5Clone="<:nav>"!==rt.createElement("nav").cloneNode(!0).outerHTML,n.type="checkbox",n.checked=!0,e.appendChild(n),dt.appendChecked=n.checked,t.innerHTML="",dt.noCloneChecked=!!t.cloneNode(!0).lastChild.defaultValue,e.appendChild(t),n=rt.createElement("input"),n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),t.appendChild(n),dt.checkClone=t.cloneNode(!0).cloneNode(!0).lastChild.checked,dt.noCloneEvent=!!t.addEventListener,t[ft.expando]=1,dt.attributes=!t.getAttribute(ft.expando)}();var $t={option:[1,""],legend:[1,""],area:[1,""],param:[1,""],thead:[1,""],tr:[2,""],col:[2,""],td:[3,""],_default:dt.htmlSerialize?[0,"",""]:[1,"X","
"]};$t.optgroup=$t.option,$t.tbody=$t.tfoot=$t.colgroup=$t.caption=$t.thead,$t.th=$t.td;var Ut=/<|?\w+;/,Xt=/-1&&(h=f.split("."),f=h.shift(),h.sort()),a=f.indexOf(":")<0&&"on"+f,e=e[ft.expando]?e:new ft.Event(f,"object"==typeof e&&e),e.isTrigger=i?2:3,e.namespace=h.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=r),n=null==n?[e]:ft.makeArray(n,[e]),l=ft.event.special[f]||{},i||!l.trigger||l.trigger.apply(r,n)!==!1)){if(!i&&!l.noBubble&&!ft.isWindow(r)){for(u=l.delegateType||f,Jt.test(u+f)||(s=s.parentNode);s;s=s.parentNode)p.push(s),c=s;c===(r.ownerDocument||rt)&&p.push(c.defaultView||c.parentWindow||t)}for(d=0;(s=p[d++])&&!e.isPropagationStopped();)e.type=d>1?u:l.bindType||f,o=(ft._data(s,"events")||{})[e.type]&&ft._data(s,"handle"),o&&o.apply(s,n),o=a&&s[a],o&&o.apply&&Dt(s)&&(e.result=o.apply(s,n),e.result===!1&&e.preventDefault());if(e.type=f,!i&&!e.isDefaultPrevented()&&(!l._default||l._default.apply(p.pop(),n)===!1)&&Dt(r)&&a&&r[f]&&!ft.isWindow(r)){c=r[a],c&&(r[a]=null),ft.event.triggered=f;try{r[f]()}catch(t){}ft.event.triggered=void 0,c&&(r[a]=c)}return e.result}},dispatch:function(t){t=ft.event.fix(t);var e,n,r,i,o,a=[],s=it.call(arguments),u=(ft._data(this,"events")||{})[t.type]||[],l=ft.event.special[t.type]||{};if(s[0]=t,t.delegateTarget=this,!l.preDispatch||l.preDispatch.call(this,t)!==!1){for(a=ft.event.handlers.call(this,t,u),e=0;(i=a[e++])&&!t.isPropagationStopped();)for(t.currentTarget=i.elem,n=0;(o=i.handlers[n++])&&!t.isImmediatePropagationStopped();)t.rnamespace&&!t.rnamespace.test(o.namespace)||(t.handleObj=o,t.data=o.data,r=((ft.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,s),void 0!==r&&(t.result=r)===!1&&(t.preventDefault(),t.stopPropagation()));return l.postDispatch&&l.postDispatch.call(this,t),t.result}},handlers:function(t,e){var n,r,i,o,a=[],s=e.delegateCount,u=t.target;if(s&&u.nodeType&&("click"!==t.type||isNaN(t.button)||t.button<1))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==t.type)){for(r=[],n=0;n-1:ft.find(i,this,null,[u]).length),r[i]&&r.push(o);r.length&&a.push({elem:u,handlers:r})}return s]","i"),ee=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,ne=/