diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3bf3418
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+tmp/
+log/
diff --git a/app/controllers/artist_controller.rb b/app/controllers/artist_controller.rb
index 547b086..94fba43 100644
--- a/app/controllers/artist_controller.rb
+++ b/app/controllers/artist_controller.rb
@@ -3,15 +3,15 @@ class ArtistController < ApplicationController
require 'open-uri'
def view
# Dirty auth block START
- unless request.session['session_id'].nil? or MainController.logged_in request.session['session_id']
- redirect_to '/login'
- return
- else
- if request.session['session_id'].nil?
- redirect_to '/login'
- return
- end
- end
+ # unless request.session['session_id'].nil? or MainController.logged_in request.session['session_id']
+ # redirect_to '/login'
+ # return
+ # else
+ # if request.session['session_id'].nil?
+ # redirect_to '/login'
+ # return
+ # end
+ # end
# Dirty auth block END
if params[:name].nil?
name = ''
diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb
index 3e3d473..948a6ec 100644
--- a/app/controllers/main_controller.rb
+++ b/app/controllers/main_controller.rb
@@ -1,23 +1,7 @@
class MainController < ApplicationController
def index
- # Dirty auth block START
- unless request.session['session_id'].nil? or MainController.logged_in request.session['session_id']
- redirect_to '/login'
- else
- if request.session['session_id'].nil?
- redirect_to '/login'
- end
- end
- # Dirty auth block END
- end
- def self.logged_in session_id
- user_data = User.collection.find({session_key: Digest::SHA256.hexdigest(session_id)}).first
- unless user_data.nil?
- user_data['lastvisit'] = Time.now()
- User.collection.update({_id: user_data._id}, user_data.attributes)
- return true
- else
- return false
- end
+ # unless User.logged_in
+ # redirect_to '/login'
+ # end
end
end
\ No newline at end of file
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb
index da74a75..4d5b17f 100644
--- a/app/controllers/track_controller.rb
+++ b/app/controllers/track_controller.rb
@@ -3,18 +3,14 @@ class TrackController < ApplicationController
require 'uri'
def listen
pp track = Track.where(:id => params[:id].to_i).first
- pp release = Release.where(:id => track.release_id).first
- pp album = Album.where(:id => release.album_id).first
- pp artist = Artist.where(:id => album.artist_id).first
- data = Vkontakte.get(artist.name, track.name, (track.length / 1000).round)
-
+ data = Vkontakte.get(track.artist_name, track.name, (track.length / 1000).round)
+ # data = Vkontakte.get(1, 1, 1)
url = URI.parse(data['url'])
nginx_url = '/proxy-stream/no-token/' << data['remixsid'] << '/' << '5' << '/' << url.host << url.path
- #render :inline => nginx_url
+
headers['Content-Type'] = 'audio/mpeg'
headers['X-Accel-Redirect'] = nginx_url
- headers['Connection'] = 'close'
render :nothing => true
end
end
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index b28b18c..782c5c9 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -1,4 +1,8 @@
class UserController < ApplicationController
+
+ @@invite_salt = 'Gouranga gives a fuck?!'
+ @@email_regex = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/
+
def login
@hide_player = 1
unless params[:email].nil? or params[:password].nil?
@@ -28,7 +32,7 @@ class UserController < ApplicationController
@hide_player = 1
data = Invite.where(:email => params[:invite_email], :code => params[:invite_code]).first
unless data.nil?
- if params[:email].match(/\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\z/).nil? or
+ if params[:email].match(@@email_regex).nil? or
params[:password].length < 6 or
params[:password] != params[:password_c]
redirect_to '/'
@@ -49,4 +53,40 @@ class UserController < ApplicationController
redirect_to '/login'
end
end
+
+ def update
+ @data = User.collection.find({session_key: Digest::SHA256.hexdigest(request.session['session_id'])}).first
+ unless @data.nil?
+ if request.request_method == 'POST'
+ if params[:name]
+ @data.name = params[:name]
+ end
+ User.collection.update({_id: @data._id}, @data.attributes)
+ end
+ else
+ render :json => 'wtf?'
+ end
+ end
+
+ def invite
+ @data = User.collection.find({session_key: Digest::SHA256.hexdigest(request.session['session_id'])}).first
+ unless @data.nil?
+ if @data.invites > 0
+ pp 1
+ if request.request_method == 'POST'
+ unless params[:email].nil?
+ if params[:email].match(@@email_regex)
+ Invite.collection.insert({email: params[:email], code: Digest::SHA256.hexdigest(params[:email] << @@invite_salt), referer: @data._id})
+ @data.invites -= 1
+ User.collection.update({_id: @data._id}, @data.attributes)
+ @ok = true
+ end
+ end
+ end
+ pp 2
+ else
+ render :json => 'wtf?'
+ end
+ end
+ end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a5d2739..32a0bfe 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,4 +1,7 @@
module ApplicationHelper
+ def navigation
+
+ end
end
class Numeric
diff --git a/app/helpers/vkontakte.rb b/app/helpers/vkontakte.rb
index a462a58..700ed6f 100644
--- a/app/helpers/vkontakte.rb
+++ b/app/helpers/vkontakte.rb
@@ -2,38 +2,34 @@ module Vkontakte
require 'uri'
require 'net/http'
require 'erb'
+ require 'pp'
#require 'nokogiri'
@@accounts = YAML.load_file("#{Rails.root.to_s}/config/vk_accounts.yml")
@@bot = nil
- def self.get artist, track, length
- self.randomBot
+ def self.get(artist, track, length)
+ self.randomBot()
html = self.getHtml(artist << ' - ' << track).force_encoding("WINDOWS-1251").encode("UTF-8")
- #pp html.encoding
- #File.open('/Users/chez/Sites/beathaven/tmp/vkres1.html', 'w') {|f| f.write(html) }
- #html = open('/Users/chez/Sites/beathaven/tmp/vkres1.html').read
files = self.parseHtml(html)
- files = self.calcWeight(files, artist, track, length)
- #self.stream files.first['url']
-
+ files = self.calcWeight(files, artist, track, length)
return {
- 'url' => files.first['url'],
- 'remixsid' => @@bot['remixsid'],
- 'remixchk' => @@bot['remixchk']
+ 'url' => files.first['url'],
+ 'remixsid' => @@bot['remixsid'],
+ 'remixchk' => @@bot['remixchk']
}
end
private
- def self.randomBot
+ def self.randomBot()
botname = @@accounts.keys[rand(@@accounts.keys.length - 1)]
@@bot = @@accounts[botname]
pp 'Using bot ' << botname
end
- def self.getHtml q
+ def self.getHtml(q)
headers = {
'Cookie' => 'remixsid='+ @@bot['remixsid'] + ';remixchk='+ @@bot['remixchk'].to_s,
'Referer' => 'http://vkontakte.ru/audio?album_id=0',
@@ -60,7 +56,7 @@ module Vkontakte
data
end
- def self.parseHtml html
+ def self.parseHtml(html)
files = []
html
.scan(/
.*?(.*?)<\/div>.*?
.*?selectPerformer\(event\,\s\'(.*?)\'\).*?
(.*?)<\/span><\/div>.*?<\/table>/mi)
@@ -76,7 +72,7 @@ module Vkontakte
files
end
- def self.calcWeight files, artist, track, length
+ def self.calcWeight(files, artist, track, length)
files.each do |file|
weight = 0
@@ -99,18 +95,4 @@ module Vkontakte
files.sort_by{|file| file['weight']}.reverse
end
-
- def self.stream url
- headers = {
- 'Cookie' => 'remixsid='+ @@bot['remixsid'] + ';remixchk='+ @@bot['remixchk'].to_s,
- 'Referer' => 'http://vkontakte.ru/audio?album_id=0',
- 'User-Agent' => @@bot['user_agent'],
- }
-
- uri = URI.parse(url)
- http = Net::HTTP.new(uri.host, 80)
- resp, data = http.get2(uri.path, headers)
-
- data
- end
end
diff --git a/app/models/artist.rb b/app/models/artist.rb
index ba3292e..c972e5d 100644
--- a/app/models/artist.rb
+++ b/app/models/artist.rb
@@ -10,10 +10,10 @@ class Artist < ActiveRecord::Base
return nil if query.nil? or query.strip.empty?
json = ActiveSupport::JSON.decode(open(
- 'http://www.last.fm/search/autocomplete' <<
- '?q=' << URI.escape(query)
- ).read)
- return nil if json.empty? else return json
+ 'http://www.last.fm/search/autocomplete' <<
+ '?q=' << URI.escape(query)
+ ).read)
+ return json.empty? ? nil : json
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 5ec3bb8..7789a16 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -9,4 +9,16 @@ class User
key :invites, Integer
key :referer, Integer
key :active, Integer
+
+ def logged_in
+ unless request.session['session_id'].nil? or MainController.logged_in session['session_id']
+ redirect_to '/login'
+ return
+ else
+ if request.session['session_id'].nil?
+ redirect_to '/login'
+ return
+ end
+ end
+ end
end
\ No newline at end of file
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 1457fec..00a6e36 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -9,36 +9,47 @@
<%= csrf_meta_tag %>
+
+
+
+ <% if @hide_player.nil? -%>
+
+
+
+
+
+
+
0:00
+
+
0:00
+
+
+
+
+
0
+
+
+
+
+
+ <%- end %>
- <% if @hide_player.nil? -%>
-
-
-
-
-
-
-
0:00
-
-
0:00
-
-
-
-
-
0
-
-
-
- <%- end %>
<%= yield %>
diff --git a/app/views/main/navigation.html.erb b/app/views/main/navigation.html.erb
new file mode 100644
index 0000000..716afed
--- /dev/null
+++ b/app/views/main/navigation.html.erb
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/app/views/user/invite.erb b/app/views/user/invite.erb
new file mode 100644
index 0000000..2ad90a3
--- /dev/null
+++ b/app/views/user/invite.erb
@@ -0,0 +1,23 @@
+
+
Help BeatHaven dominate those lousy humans!
+ <%= form_tag('/reg/complete', :method => 'post') do -%>
+ <%= label_tag 'email', 'E-mail' %><%= email_field_tag 'email', @email %>
+
+ <%= submit_tag 'I wanna get this guy in!' %>
+
+ <% end -%>
+
+
\ No newline at end of file
diff --git a/app/views/user/update.erb b/app/views/user/update.erb
new file mode 100644
index 0000000..dadb5c4
--- /dev/null
+++ b/app/views/user/update.erb
@@ -0,0 +1,31 @@
+
+
Update ur profile!
+ <%= form_tag('/user/profile', :method => 'post') do -%>
+ <%= label_tag 'email', 'E-mail' %><%= email_field_tag 'email', @data.email %>
+ <%= label_tag 'name', 'Name' %><%= text_field_tag 'name', @data.name %>
+ <%= label_tag 'password', 'Password' %><%= password_field_tag 'password', nil %>
+ <%= label_tag 'password_c', 'Confirm' %><%= password_field_tag 'password_c', nil %>
+
+ <%= submit_tag 'I\'m done!' %>
+
+ <% end -%>
+
+
+
\ No newline at end of file
diff --git a/config/database.yml b/config/database.yml
index 15e28ff..7eb1fe2 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -1,10 +1,14 @@
-# PostgreSQL version 9.0
-# gem install pg
-development:
+defaults: &defaults
adapter: postgresql
database: beathaven
host: 192.168.0.128
username: postgres
password: password
pool: 5
- timeout: 5000
\ No newline at end of file
+ timeout: 5000
+
+development:
+ <<: *defaults
+
+production:
+ <<: *defaults
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 5ad0a82..d88fa6a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -20,6 +20,8 @@ Beathaven::Application.routes.draw do
match 'reg/:email/:code' => 'user#register', :constraints => { :email => /[-a-z0-9\._@]+/i, :code => /[a-f0-9]{64}/ }
match 'reg/complete' => 'user#complete'
match 'login' => 'user#login'
+ match 'user/profile' => 'user#update'
+ match 'user/invite' => 'user#invite'
match '*a', :to => 'errors#routing'
end
diff --git a/public/images/player/playlist.svg b/public/images/player/playlist.svg
index 696f99a..aee908f 100644
--- a/public/images/player/playlist.svg
+++ b/public/images/player/playlist.svg
@@ -1,10 +1,9 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/public/images/player/repeat.svg b/public/images/player/repeat.svg
new file mode 100644
index 0000000..a9a3db3
--- /dev/null
+++ b/public/images/player/repeat.svg
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/public/images/player/shuffle.svg b/public/images/player/shuffle.svg
index 4f1e016..4d00bca 100644
--- a/public/images/player/shuffle.svg
+++ b/public/images/player/shuffle.svg
@@ -14,7 +14,7 @@
450 150
500 150
- L600 150
+ L560 150
M100 150
@@ -31,11 +31,11 @@
450 400
500 400
- L600 400
+ L560 400
" style="stroke:rgb(200,200,200);stroke-width:70;" />
-
-
+
+
\ No newline at end of file
diff --git a/public/javascripts/jquery.carousel.min.js b/public/javascripts/jquery.carousel.min.js
new file mode 100644
index 0000000..cad7235
--- /dev/null
+++ b/public/javascripts/jquery.carousel.min.js
@@ -0,0 +1,5 @@
+/* jQuery Carousel 0.9.8
+Copyright 2010 Thomas Lanciaux and Pierre Bertet.
+This software is licensed under the CC-GNU LGPL
+*/
+(function(g){g.fn.carousel=function(q){var q=g.extend({direction:"horizontal",loop:false,dispItems:1,pagination:false,paginationPosition:"inside",nextBtn:' ',prevBtn:' ',btnsPosition:"inside",nextBtnInsert:"insertAfter",prevBtnInsert:"insertBefore",nextBtnInsertFn:false,prevBtnInsertFn:false,autoSlide:false,autoSlideInterval:3000,delayAutoSlide:false,combinedClasses:false,effect:"slide",slideEasing:"swing",animSpeed:300,equalWidths:"true",verticalMargin:0,callback:function(){},useAddress:false,adressIdentifier:"carousel",tabLabel:function(r){return r},showEmptyItems:true,ajaxMode:false,ajaxUrl:"",stopSlideBtn:false,stopSlideTextPause:"Pause",stopSlideTextPlay:"Play"},q);if(q.btnsPosition=="outside"){q.prevBtnInsert="insertBefore";q.nextBtnInsert="insertAfter"}q.delayAutoSlide=0+q.delayAutoSlide;return this.each(function(){var r={$elts:{},params:q,launchOnLoad:[]};r.$elts.carousel=g(this).addClass("js");r.$elts.content=g(this).children().css({position:"absolute",top:0});r.$elts.wrap=r.$elts.content.wrap('
').parent().css({overflow:"hidden",position:"relative"});r.steps={first:0,count:r.$elts.content.children().length};r.$elts.loader=g('
').css({position:"absolute"});r.steps.last=r.steps.count-1;if(r.params.pagination){o(r)}if(g.isFunction(r.params.prevBtnInsertFn)){r.$elts.prevBtn=r.params.prevBtnInsertFn(r.$elts)}else{if(q.btnsPosition=="outside"){r.$elts.prevBtn=g(q.prevBtn)[q.prevBtnInsert](r.$elts.carousel)}else{r.$elts.prevBtn=g(q.prevBtn)[q.prevBtnInsert](r.$elts.wrap)}}if(g.isFunction(r.params.nextBtnInsertFn)){r.$elts.nextBtn=r.params.nextBtnInsertFn(r.$elts)}else{if(q.btnsPosition=="outside"){r.$elts.nextBtn=g(q.nextBtn)[q.nextBtnInsert](r.$elts.carousel)}else{r.$elts.nextBtn=g(q.nextBtn)[q.nextBtnInsert](r.$elts.wrap)}}r.$elts.nextBtn.addClass("carousel-control next carousel-next");r.$elts.prevBtn.addClass("carousel-control previous carousel-previous");r.lastItemsToLoad;d(r);r.$elts.carousel.attr("tabindex",0).add(r.$elts.carousel.children()).bind({focus:function(s){g(document).bind("keypress",function(t){switch(t.keyCode){case 39:r.$elts.nextBtn.click();break;case 37:r.$elts.prevBtn.click();break}switch(t.charCode){case 110:r.$elts.nextBtn.click();break;case 112:r.$elts.prevBtn.click();break}})},blur:function(){g(document).unbind("keypress")}});n(r);g(function(){c(r);g.each(r.launchOnLoad,function(s,t){t()});if(r.params.autoSlide){f(r)}if(q.stopSlideBtn==true){r.$elts.stopSlideBtn=g(''+q.stopSlideTextPause+" ");a(r)}})})};function c(s){var t=s.$elts.content.children();var r=0;t.each(function(){$item=g(this);$itemHeight=$item.outerHeight();if($itemHeight>r){r=$itemHeight}});if(s.params.verticalMargin>0){r=r+s.params.verticalMargin}t.height(r);var q=s.$elts.content.children(":first");s.itemWidth=q.outerWidth();if(s.params.direction=="vertical"){s.contentWidth=s.itemWidth}else{if(s.params.equalWidths){s.contentWidth=s.itemWidth*s.steps.count}else{s.contentWidth=(function(){var u=0;s.$elts.content.children().each(function(){u+=g(this).outerWidth()});return u})()}}s.$elts.content.width(s.contentWidth);s.itemHeight=r;if(s.params.direction=="vertical"){s.$elts.content.css({height:s.itemHeight*s.steps.count+"px"});s.$elts.content.parent().css({height:s.itemHeight*s.params.dispItems+"px"})}else{s.$elts.content.parent().css({height:s.itemHeight+"px"})}i(s)}function d(q){q.$elts.nextBtn.add(q.$elts.prevBtn).bind("enable",function(){var r=g(this).unbind("click").bind("click",function(){if(q.params.ajaxMode&&r.is(".next")&&b(q)==(p(q)-1)&&!q.lastItemsToLoad){h(q);q.$elts.content.ajaxSuccess(function(){})}else{e(q,j(q,(r.is(".next")?"next":"prev")));if(q.params.stopSlideBtn==true){q.$elts.stopSlideBtn.trigger("pause")}else{m(q)}}}).removeClass("disabled").removeAttr("disabled");if(q.params.combinedClasses){r.removeClass("next-disabled previous-disabled").removeAttr("disabled")}}).bind("disable",function(){var r=g(this).unbind("click").addClass("disabled").attr("disabled","disabled");if(q.params.combinedClasses){if(r.is(".next")){r.addClass("next-disabled")}else{if(r.is(".previous")){r.addClass("previous-disabled")}}}}).hover(function(){g(this).toggleClass("hover")})}function o(q){q.$elts.pagination=g('
')[((q.params.paginationPosition=="outside")?"insertAfter":"appendTo")](q.$elts.carousel).find("p");q.$elts.paginationBtns=g([]);q.$elts.content.find("li").each(function(r){if(r%q.params.dispItems==0){k(q,r)}})}function k(r,q){if(r.params.pagination){r.$elts.paginationBtns=r.$elts.paginationBtns.add(g(''+r.params.tabLabel(r.$elts.paginationBtns.length+1)+" ").data("firstStep",q)).appendTo(r.$elts.pagination);r.$elts.paginationBtns.slice(0,1).addClass("active");r.$elts.paginationBtns.click(function(s){e(r,g(this).data("firstStep"));if(r.params.stopSlideBtn==true){r.$elts.stopSlideBtn.trigger("pause")}else{m(r)}})}}function n(q){if(q.params.useAddress&&g.isFunction(g.fn.address)){g.address.init(function(s){var r=g.address.pathNames();if(r[0]===q.params.adressIdentifier&&!!r[1]){e(q,r[1]-1)}else{g.address.value("/"+q.params.adressIdentifier+"/1")}}).change(function(s){var r=g.address.pathNames();if(r[0]===q.params.adressIdentifier&&!!r[1]){e(q,r[1]-1)}})}else{q.params.useAddress=false}}function e(q,r){q.params.callback(r);l(q,r);q.steps.first=r;i(q);if(q.params.useAddress){g.address.value("/"+q.params.adressIdentifier+"/"+(r+1))}}function j(r,q){if(q=="prev"){if(!r.params.showEmptyItems){if(r.steps.first==0){return((r.params.loop)?(r.steps.count-r.params.dispItems):false)}else{return Math.max(0,r.steps.first-r.params.dispItems)}}else{if((r.steps.first-r.params.dispItems)>=0){return r.steps.first-r.params.dispItems}else{return((r.params.loop)?(r.steps.count-r.params.dispItems):false)}}}else{if(q=="next"){if((r.steps.first+r.params.dispItems) ",buttonPrevHTML:"
",buttonNextEvent:"click",buttonPrevEvent:"click", buttonNextCallback:null,buttonPrevCallback:null,itemFallbackDimension:null},m=!1;g(window).bind("load.jcarousel",function(){m=!0});g.jcarousel=function(a,c){this.options=g.extend({},q,c||{});this.autoStopped=this.locked=!1;this.buttonPrevState=this.buttonNextState=this.buttonPrev=this.buttonNext=this.list=this.clip=this.container=null;if(!c||c.rtl===void 0)this.options.rtl=(g(a).attr("dir")||g("html").attr("dir")||"").toLowerCase()=="rtl";this.wh=!this.options.vertical?"width":"height";this.lt=!this.options.vertical? this.options.rtl?"right":"left":"top";for(var b="",d=a.className.split(" "),f=0;f
").parent();if(this.container.size()===0)this.container=this.clip.wrap("
").parent();b!==""&&this.container.parent()[0].className.indexOf("jcarousel-skin")==-1&&this.container.wrap('
');this.buttonPrev=g(".jcarousel-prev",this.container);if(this.buttonPrev.size()===0&&this.options.buttonPrevHTML!==null)this.buttonPrev=g(this.options.buttonPrevHTML).appendTo(this.container);this.buttonPrev.addClass(this.className("jcarousel-prev"));this.buttonNext= g(".jcarousel-next",this.container);if(this.buttonNext.size()===0&&this.options.buttonNextHTML!==null)this.buttonNext=g(this.options.buttonNextHTML).appendTo(this.container);this.buttonNext.addClass(this.className("jcarousel-next"));this.clip.addClass(this.className("jcarousel-clip")).css({position:"relative"});this.list.addClass(this.className("jcarousel-list")).css({overflow:"hidden",position:"relative",top:0,margin:0,padding:0}).css(this.options.rtl?"right":"left",0);this.container.addClass(this.className("jcarousel-container")).css({position:"relative"}); !this.options.vertical&&this.options.rtl&&this.container.addClass("jcarousel-direction-rtl").attr("dir","rtl");var j=this.options.visible!==null?Math.ceil(this.clipping()/this.options.visible):null,b=this.list.children("li"),e=this;if(b.size()>0){var h=0,i=this.options.offset;b.each(function(){e.format(this,i++);h+=e.dimension(this,j)});this.list.css(this.wh,h+100+"px");if(!c||c.size===void 0)this.options.size=b.size()}this.container.css("display","block");this.buttonNext.css("display","block");this.buttonPrev.css("display", "block");this.funcNext=function(){e.next()};this.funcPrev=function(){e.prev()};this.funcResize=function(){e.resizeTimer&&clearTimeout(e.resizeTimer);e.resizeTimer=setTimeout(function(){e.reload()},100)};this.options.initCallback!==null&&this.options.initCallback(this,"init");!m&&g.browser.safari?(this.buttons(!1,!1),g(window).bind("load.jcarousel",function(){e.setup()})):this.setup()};var f=g.jcarousel;f.fn=f.prototype={jcarousel:"0.2.8"};f.fn.extend=f.extend=g.extend;f.fn.extend({setup:function(){this.prevLast= this.prevFirst=this.last=this.first=null;this.animating=!1;this.tail=this.resizeTimer=this.timer=null;this.inTail=!1;if(!this.locked){this.list.css(this.lt,this.pos(this.options.offset)+"px");var a=this.pos(this.options.start,!0);this.prevFirst=this.prevLast=null;this.animate(a,!1);g(window).unbind("resize.jcarousel",this.funcResize).bind("resize.jcarousel",this.funcResize);this.options.setupCallback!==null&&this.options.setupCallback(this)}},reset:function(){this.list.empty();this.list.css(this.lt, "0px");this.list.css(this.wh,"10px");this.options.initCallback!==null&&this.options.initCallback(this,"reset");this.setup()},reload:function(){this.tail!==null&&this.inTail&&this.list.css(this.lt,f.intval(this.list.css(this.lt))+this.tail);this.tail=null;this.inTail=!1;this.options.reloadCallback!==null&&this.options.reloadCallback(this);if(this.options.visible!==null){var a=this,c=Math.ceil(this.clipping()/this.options.visible),b=0,d=0;this.list.children("li").each(function(f){b+=a.dimension(this, c);f+1this.options.size)c=this.options.size;for(var b=a;b<=c;b++){var d=this.get(b);if(!d.length||d.hasClass("jcarousel-item-placeholder"))return!1}return!0}, get:function(a){return g(">.jcarousel-item-"+a,this.list)},add:function(a,c){var b=this.get(a),d=0,p=g(c);if(b.length===0)for(var j,e=f.intval(a),b=this.create(a);;){if(j=this.get(--e),e<=0||j.length){e<=0?this.list.prepend(b):j.after(b);break}}else d=this.dimension(b);p.get(0).nodeName.toUpperCase()=="LI"?(b.replaceWith(p),b=p):b.empty().append(c);this.format(b.removeClass(this.className("jcarousel-item-placeholder")),a);p=this.options.visible!==null?Math.ceil(this.clipping()/this.options.visible): null;d=this.dimension(b,p)-d;a>0&&a=this.first&&a<=this.last)){var b=this.dimension(c);athis.options.size?this.options.size:a);for(var d=this.first>a,g=this.options.wrap!="circular"&&this.first<=1?1:this.first,j=d?this.get(g): this.get(this.last),e=d?g:g-1,h=null,i=0,k=!1,l=0;d?--e>=a:++ethis.options.size)))j=this.get(this.index(e)),j.length&&(h=this.add(e,j.clone(!0)));j=h;l=this.dimension(h);k&&(i+=l);if(this.first!==null&&(this.options.wrap=="circular"||e>=1&&(this.options.size===null||e<= this.options.size)))b=d?b+l:b-l}for(var g=this.clipping(),m=[],o=0,n=0,j=this.get(a-1),e=a;++o;){h=this.get(e);k=!h.length;if(h.length===0){h=this.create(e).addClass(this.className("jcarousel-item-placeholder"));if(j.length===0)this.list.prepend(h);else j[d?"before":"after"](h);if(this.first!==null&&this.options.wrap=="circular"&&this.options.size!==null&&(e<=0||e>this.options.size))j=this.get(this.index(e)),j.length&&(h=this.add(e,j.clone(!0)))}j=h;l=this.dimension(h);if(l===0)throw Error("jCarousel: No width/height set for items. This will cause an infinite loop. Aborting..."); this.options.wrap!="circular"&&this.options.size!==null&&e>this.options.size?m.push(h):k&&(i+=l);n+=l;if(n>=g)break;e++}for(h=0;h0&&(this.list.css(this.wh,this.dimension(this.list)+i+"px"),d&&(b-=i,this.list.css(this.lt,f.intval(this.list.css(this.lt))-i+"px")));i=a+o-1;if(this.options.wrap!="circular"&&this.options.size&&i>this.options.size)i=this.options.size;if(e>i){o=0;e=i;for(n=0;++o;){h=this.get(e--);if(!h.length)break;n+=this.dimension(h);if(n>=g)break}}e=i-o+ 1;this.options.wrap!="circular"&&e<1&&(e=1);if(this.inTail&&d)b+=this.tail,this.inTail=!1;this.tail=null;if(this.options.wrap!="circular"&&i==this.options.size&&i-o+1>=1&&(d=f.intval(this.get(i).css(!this.options.vertical?"marginRight":"marginBottom")),n-d>g))this.tail=n-g-d;if(c&&a===this.options.size&&this.tail)b-=this.tail,this.inTail=!0;for(;a-- >e;)b+=this.dimension(this.get(a));this.prevFirst=this.first;this.prevLast=this.last;this.first=e;this.last=i;return b},animate:function(a,c){if(!this.locked&& !this.animating){this.animating=!0;var b=this,d=function(){b.animating=!1;a===0&&b.list.css(b.lt,0);!b.autoStopped&&(b.options.wrap=="circular"||b.options.wrap=="both"||b.options.wrap=="last"||b.options.size===null||b.last=b.first&&c<=b.last)&&(c<1||c>b.options.size)&&b.remove(c)}; this.notify("onBeforeAnimation");if(!this.options.animation||c===!1)this.list.css(this.lt,a+"px"),d();else{var f=!this.options.vertical?this.options.rtl?{right:a}:{left:a}:{top:a},d={duration:this.options.animation,easing:this.options.easing,complete:d};if(g.isFunction(this.options.animationStepCallback))d.step=this.options.animationStepCallback;this.list.animate(f,d)}}},startAuto:function(a){if(a!==void 0)this.options.auto=a;if(this.options.auto===0)return this.stopAuto();if(this.timer===null){this.autoStopped= !1;var c=this;this.timer=window.setTimeout(function(){c.next()},this.options.auto*1E3)}},stopAuto:function(){this.pauseAuto();this.autoStopped=!0},pauseAuto:function(){if(this.timer!==null)window.clearTimeout(this.timer),this.timer=null},buttons:function(a,c){if(a==null&&(a=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="first"||this.options.size===null||this.last=this.options.size))a=this.tail!==null&&!this.inTail;if(c==null&&(c=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="last"||this.first>1),!this.locked&&(!this.options.wrap||this.options.wrap=="last")&&this.options.size!==null&&this.first==1))c=this.tail!==null&&this.inTail;var b=this;this.buttonNext.size()>0?(this.buttonNext.unbind(this.options.buttonNextEvent+".jcarousel",this.funcNext),a&&this.buttonNext.bind(this.options.buttonNextEvent+".jcarousel",this.funcNext), this.buttonNext[a?"removeClass":"addClass"](this.className("jcarousel-next-disabled")).attr("disabled",a?!1:!0),this.options.buttonNextCallback!==null&&this.buttonNext.data("jcarouselstate")!=a&&this.buttonNext.each(function(){b.options.buttonNextCallback(b,this,a)}).data("jcarouselstate",a)):this.options.buttonNextCallback!==null&&this.buttonNextState!=a&&this.options.buttonNextCallback(b,null,a);this.buttonPrev.size()>0?(this.buttonPrev.unbind(this.options.buttonPrevEvent+".jcarousel",this.funcPrev), c&&this.buttonPrev.bind(this.options.buttonPrevEvent+".jcarousel",this.funcPrev),this.buttonPrev[c?"removeClass":"addClass"](this.className("jcarousel-prev-disabled")).attr("disabled",c?!1:!0),this.options.buttonPrevCallback!==null&&this.buttonPrev.data("jcarouselstate")!=c&&this.buttonPrev.each(function(){b.options.buttonPrevCallback(b,this,c)}).data("jcarouselstate",c)):this.options.buttonPrevCallback!==null&&this.buttonPrevState!=c&&this.options.buttonPrevCallback(b,null,c);this.buttonNextState= a;this.buttonPrevState=c},notify:function(a){var c=this.prevFirst===null?"init":this.prevFirst=j&&k<=e)&&a(k)}}},create:function(a){return this.format(" ",a)},format:function(a,c){for(var a=g(a),b=a.get(0).className.split(" "),d=0;d 0 && cur_time == duration) {
+ playNext();
}
loaded = 0;
if ((audio.buffered != undefined) && (audio.buffered.length != 0)) {
@@ -68,7 +76,12 @@ function updatePlayer() {
$('#player .time-left').html(formatTime(duration - cur_time));
progress = Math.round((cur_time / duration) * 390);
$('#player .progress-loaded').css('width', loaded +'px')
- $('#player .progress-point').css('margin-left', progress +'px')
+ $('#player .progress-point').css('margin-left', progress - $('#player .progress-point').width() +'px')
+
+ /* Starting buffering next track */
+ if (Math.round(cur_time / duration * 100) > 10) {
+ addAudio(next_audio);
+ }
}
utid = window.setTimeout(updatePlayer, 100);
}
@@ -79,35 +92,40 @@ function formatTime(sec) {
return m +':'+ (s < 10 ? '0' : '') +s;
}
function playTrack(artist, track, id) {
- $(audio).attr('src', '/listen/'+ id +'.mp3');
+ switchAudio(id);
+ setNext();
$('#player .track-title').html(artist +' — '+ track);
$('#player .time-played').html('0:00');
$('#player .time-left').html('0:00');
- $('#player .progress-loaded').css('width', 0 +'px')
- $('#player .progress-point').css('margin-left', 0 +'px')
+ $('#player .progress-loaded').css('width', '0px')
+ $('#player .progress-point').css('margin-left', '-6px')
$('#player .play').trigger('click');
}
-function playPrev() {
+function setPrev() {
if ($('#playlist ul.list li').length == 0) return false;
- if ($('#playlist ul.list li.now-playing').prev().length == 0) {
- $('#playlist ul.list li:last').dblclick();
- } else {
- $('#playlist ul.list li.now-playing').prev().dblclick();
+ if (!audio) {
+ prev_audio = $(audio).attr('data-id');
}
}
-function playNext(auto) {
+function setNext() {
if ($('#playlist ul.list li').length == 0) return false;
if ($('#player .shuffle').hasClass('on')) {
- $('#playlist ul.list li').rand().dblclick();
+ next_audio = $('#playlist ul.list li').rand().attr('data-id');
}
if ($('#playlist ul.list li.now-playing').next().length == 0) {
- if ((auto && $('#player .repeat').hasClass('on')) || !auto) {
- $('#playlist ul.list li:first').dblclick();
+ if ($('#player .repeat').hasClass('on')) {
+ next_audio = $('#playlist ul.list li:first').attr('data-id');
}
} else {
- $('#playlist ul.list li.now-playing').next().dblclick();
+ next_audio = $('#playlist ul.list li.now-playing').next().attr('data-id');
}
}
+function playPrev() {
+ return false;
+}
+function playNext() {
+ $('#playlist ul.list li[data-id="'+ next_audio +'"]').dblclick();
+}
function addToPlaylist(artist, track, length, id) {
$('#playlist ul.list').append($(
''+
@@ -121,6 +139,7 @@ function addToPlaylist(artist, track, length, id) {
playTrack(artist, track, id);
$('#playlist li').removeClass('now-playing');
$(this).addClass('now-playing');
+ setNext();
})
if ($('#playlist ul.list li').length == 1) {
$('#playlist ul.list li:first').dblclick();
@@ -129,4 +148,22 @@ function addToPlaylist(artist, track, length, id) {
$('#playlist').jScrollPane();
}
$('#player .playlist .count').html($('#playlist ul.list li').length);
+ setNext();
}
+function addAudio(id) {
+ if ($('#audio_'+ id).length == 0) {
+ $('#audiobox').append(' ');
+ $('#audio_'+ id).attr('src', '/listen/'+ id +'.mp3');
+ }
+}
+function switchAudio(id) {
+ if (typeof(audio) != 'undefined' && audio.buffered.length != 0) {
+ console.log(audio, audio.buffered.length);
+ audio.pause();
+ audio.currentTime = 0;
+ }
+ if ($('#audio_'+ id).length == 0) {
+ addAudio(id);
+ }
+ audio = document.getElementById('audio_'+ id);
+}
\ No newline at end of file
diff --git a/public/stylesheets/beathaven.css b/public/stylesheets/beathaven.css
index cdbb7db..3523f86 100644
--- a/public/stylesheets/beathaven.css
+++ b/public/stylesheets/beathaven.css
@@ -132,3 +132,53 @@ h1.artist > span > span.play {
padding: 0.2em;
}
+
+#nav {
+ position: fixed;
+ z-index: 6;
+ top: 0;
+ left: 50%;
+ margin-left: -375px;
+ width: 750px;
+ height: 25px;
+ background-color: #000;
+ border-bottom: #222 1px solid;
+}
+ #nav ul {
+ margin: 0 5px;
+ padding: 0;
+ list-style: none;
+ }
+ #nav ul li {
+ display: inline-block;
+ width: auto;
+ margin: 0 5px;
+ }
+ #nav ul li a {
+ color: #CCC;
+ line-height: 25px;
+ font-size: 12px;
+ text-decoration: none;
+ font-weight: bold;
+ }
+ #nav ul li a:hover {
+ color: #DDD;
+ }
+
+.corner-fix {
+ position: fixed;
+ z-index: 4;
+ width: 8px;
+ height: 8px;
+ background-color: #000;
+ top: 25px;
+ left: 50%;
+}
+
+.corner-fix.left {
+ margin-left: -375px;
+}
+
+.corner-fix.right {
+ margin-left: 367px;
+}
\ No newline at end of file
diff --git a/public/stylesheets/player.css b/public/stylesheets/player.css
index 2fbf50d..2171890 100644
--- a/public/stylesheets/player.css
+++ b/public/stylesheets/player.css
@@ -1,12 +1,21 @@
+audio {
+ width: 0;
+ height: 0;
+ position: absolute;
+ top: -1000px;
+ left: -1000px;
+}
#player {
position: fixed;
+ z-index: 5;
width: 750px;
height: 50px;
left: 50%;
- top: 0;
+ top: 25px;
margin-left: -375px;
background-color: #000;
font-size: 12px;
+ border-radius: 8px;
}
#player .prev, #player .next, #player .play, #player .pause {
float: left;
@@ -83,6 +92,9 @@
width: 390px;
height: 3px;
}
+ #player .progress-bar:hover {
+ cursor: pointer;
+ }
#player .progress-loaded {
float: left;
width: 0;
@@ -95,7 +107,7 @@
height: 6px;
background-color: #013;
margin-top: -4px;
- margin-left: 0;
+ margin-left: -6px;
border: #FFF 3px solid;
border-radius: 6px;
cursor: pointer;
@@ -145,10 +157,11 @@
}
#playlist {
position: fixed;
- top: 50px;
+ z-index: 5;
+ top: 75px;
left: 50%;
- width: 750px;
- margin-left: -375px;
+ width: 734px;
+ margin-left: -367px;
background-color: #000;
opacity: 0.9;
-moz-opacity: 0.9;
@@ -178,6 +191,7 @@
}
#playlist ul li.now-playing {
background-color: #013;
+ font-weight: bold;
}
#playlist ul li .length {
margin: 0 0.5em;
diff --git a/public/stylesheets/register.css b/public/stylesheets/register.css
index dbe78a5..fc32198 100644
--- a/public/stylesheets/register.css
+++ b/public/stylesheets/register.css
@@ -23,7 +23,7 @@
font-size: 20px;
line-height: 35px;
}
- #registration input[type="email"], input[type="password"] {
+ #registration input[type="email"], input[type="password"], input[type="text"] {
width: 230px;
font-size: 20px;
border: #EAEAEA 1px solid;