add audio for order reservation
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -28,6 +28,7 @@ capybara-*.html
|
|||||||
/public/uploads/*
|
/public/uploads/*
|
||||||
/public/swf/*
|
/public/swf/*
|
||||||
/public/receipts/
|
/public/receipts/
|
||||||
|
/public/*.mp3
|
||||||
/coverage/
|
/coverage/
|
||||||
/spec/tmp/*
|
/spec/tmp/*
|
||||||
*.orig
|
*.orig
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel'
|
|||||||
if(data.from == "" || hostname == data.from){
|
if(data.from == "" || hostname == data.from){
|
||||||
var shop_code = data.shop_code;
|
var shop_code = data.shop_code;
|
||||||
var order = data.data;
|
var order = data.data;
|
||||||
|
var audio = data.audio;
|
||||||
if(order.length > 0){
|
if(order.length > 0){
|
||||||
$('.custom-table.'+shop_code+'_order_reserve_cable tbody').html("");
|
$('.custom-table.'+shop_code+'_order_reserve_cable tbody').html("");
|
||||||
$("."+shop_code+" > .nav-item.red > a > p.num").text(order.length);
|
$("."+shop_code+" > .nav-item.red > a > p.num").text(order.length);
|
||||||
@@ -16,7 +17,7 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel'
|
|||||||
if(key==0){
|
if(key==0){
|
||||||
active_class = "tr-active";
|
active_class = "tr-active";
|
||||||
if (typeof audioPlayBackground !== 'undefined' && $.isFunction(audioPlayBackground)) {
|
if (typeof audioPlayBackground !== 'undefined' && $.isFunction(audioPlayBackground)) {
|
||||||
audioPlayBackground(shop_code);
|
audioPlayBackground(shop_code,audio);
|
||||||
}
|
}
|
||||||
if (typeof showNewOrderAlert !== 'undefined' && $.isFunction(showNewOrderAlert)) {
|
if (typeof showNewOrderAlert !== 'undefined' && $.isFunction(showNewOrderAlert)) {
|
||||||
showNewOrderAlert(order[key],shop_code);
|
showNewOrderAlert(order[key],shop_code);
|
||||||
|
|||||||
@@ -159,10 +159,10 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* start order reservation function */
|
/* start order reservation function */
|
||||||
function audioPlayBackground(shop_code){
|
function audioPlayBackground(shop_code,audio){
|
||||||
console.log(shop_code);
|
// console.log(shop_code);
|
||||||
//audio play
|
//audio play
|
||||||
var audio = new Audio('/'+shop_code+'-beep.mp3'); // define your audio
|
var audio = new Audio('/'+audio); // define your audio
|
||||||
// setTimeout(function(){
|
// setTimeout(function(){
|
||||||
// audio.loop = true;
|
// audio.loop = true;
|
||||||
audio.play();
|
audio.play();
|
||||||
|
|||||||
@@ -65,10 +65,15 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
|
|||||||
|
|
||||||
if flag
|
if flag
|
||||||
shop = Shop.find_by_id(1)
|
shop = Shop.find_by_id(1)
|
||||||
if !shop.shop_code.nil?
|
if !shop.nil?
|
||||||
shop_code = shop.shop_code
|
shop_code = shop.shop_code
|
||||||
|
order_audio = DisplayImage.find_by_shop_id_and_name(shop.id, "order_audio")
|
||||||
|
if !order_audio.nil?
|
||||||
|
audio = order_audio.image
|
||||||
|
end
|
||||||
else
|
else
|
||||||
shop_code = ''
|
shop_code = ''
|
||||||
|
audio = ''
|
||||||
end
|
end
|
||||||
|
|
||||||
result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is successfully created!" }
|
result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is successfully created!" }
|
||||||
@@ -78,7 +83,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
|
|||||||
else
|
else
|
||||||
from = ""
|
from = ""
|
||||||
end
|
end
|
||||||
ActionCable.server.broadcast "order_reservation_channel",data: order_reservation,shop_code: shop_code,from:from
|
ActionCable.server.broadcast "order_reservation_channel",data: order_reservation,shop_code: shop_code,from:from,audio:audio
|
||||||
else
|
else
|
||||||
result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is already existed!" }
|
result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is already existed!" }
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user