Permalink
Browse files

Add a "弾いたよ" button. (in process)

  • Loading branch information...
1 parent 26364e0 commit 295d70da253c82d1c551367873b821f4dd78ff31 @volpe28v committed Apr 15, 2012
@@ -8,6 +8,15 @@
//= require jquery_ujs
//= require FeedEk
+function updateElem(id, html){
+ if ( $(id).html() == html ){return}
+
+ $(id).hide();
+ $(id).empty();
+ $(id).html(html);
+ $(id).fadeIn();
+}
+
var progress_default_option = {
steps : 0,
stepDuration : 0,
@@ -29,16 +38,31 @@ var progress_default_option = {
var progress_controller = {
step : 10,
option : { steps : 20, stepDuration : 20 },
+
up : function (user_id, tune_id){
this.move_bar(user_id, tune_id, function (current_val, step){
return current_val + step;
});
},
+
down : function (user_id, tune_id){
this.move_bar(user_id, tune_id, function (current_val, step){
return current_val - step;
});
},
+
+ play : function (user_id, tune_id){
+ this.move_bar(user_id, tune_id, function (current_val, step){
+ return current_val + 1;
+ });
+ },
+
+ touch_bar : function ( user_id, tune_id ){
+ var current_val = Number($('#progress_' + tune_id + '_pbText').html().replace("%",""))
+ this.update_remote(user_id, tune_id,current_val);
+ },
+
+
move_bar : function ( user_id, tune_id, move_callback ){
var current_val = Number($('#progress_' + tune_id + '_pbText').html().replace("%",""))
var next_val = move_callback(current_val, this.step);
@@ -51,6 +75,7 @@ var progress_controller = {
this.update_remote(user_id, tune_id,next_val);
},
+
update_remote : function(user_id, tune_id, val){
$.ajax({
type: "GET",
@@ -77,7 +77,7 @@ def selected_status
def set_tune_counts(user)
@base_tunes = session[:current_album_id] ? Album.find(session[:current_album_id]).tunes : Tune
- tuning = session[:current_tuning_id] ? Tuning.find(session[:current_tuning_id]).name : ""
+ tuning = session[:current_tuning_id] ? Tuning.find(session[:current_tuning_id]).name : ""
@touched_count = @base_tunes.by_status_and_user(@@statuses_def[1][0],user).all_or_filter_by_tuning(tuning).count
@doing_count = @base_tunes.by_status_and_user(@@statuses_def[2][0],user).all_or_filter_by_tuning(tuning).count
View
@@ -49,6 +49,10 @@ def update_progress(user,val)
return 0 if !user
progress = self.progresses.find_or_initialize_by_user_id(user.id)
+ #TODO: どんな値でも updated_at を更新したいので一旦 0 で保存している
+ # もっと良い方法があれば変更する。
+ progress.percent = 0
+ progress.save
progress.percent = val
progress.save
end
@@ -24,15 +24,6 @@
$("#my_comment").click();
});
- function updateElem(id, html){
- if ( $(id).html() == html ){return}
-
- $(id).hide();
- $(id).empty();
- $(id).html(html);
- $(id).fadeIn();
- }
-
function loadTunes(){
$('#update_tunes').click();
$('#tune-list').hide();
@@ -84,9 +84,12 @@ $(document).ready(function(){
<% if current_user == @user %>
<button class="btn" onclick="progress_controller.down('<%= @user.id %>','<%= @tune.id %>')"><font style="font-size: 14pt;"><%= "<" %></font></button>
<button class="btn" onclick="progress_controller.up('<%= @user.id %>','<%= @tune.id %>')"><font style="font-size: 14pt;"><%= ">" %></font></button>
- <button class="btn btn-success" onclick="progress_controller.up('<%= @user.id %>','<%= @tune.id %>')"><i class="icon-music icon-white"></i> 弾いたよ</font></button>
<% end %>
</p>
+ <% if current_user == @user %>
+ <button class="btn btn-success" onclick="progress_controller.play('<%= @user.id %>','<%= @tune.id %>')"><i class="icon-music icon-white"></i> 弾いたよ</font></button>
+ <% end %>
+
<div id="last-played-label">
<%= last_played_at(@tune.progress_updated_at(@user)) %>
</div>

0 comments on commit 295d70d

Please sign in to comment.