var calculateQuantityPrice = function($action, $this) {
var $siblings = $this.closest('.input-row').find('input:text');
var $basketSum = $this.closest('.basket-row').find('.sum-container span');
var presentValue = parseInt($siblings.val());
var priceValue = parseInt($basketSum.attr('data-sum'));
var presentPriceValue = parseInt($basketSum.text());
if ($action == 'plus') {
$siblings.val(presentValue + 1);
$basketSum.text(priceValue + presentPriceValue + ' руб.');
} else if ($action == 'minus') {
$siblings.val(presentValue - 1);
$basketSum.text(presentPriceValue - priceValue + ' руб.');
}
};
$('.p-btn').click(function(e) {
e.preventDefault();
calculateQuantityPrice('plus', $( this ))
});
$('.m-btn').click(function(e) {
e.preventDefault();
calculateQuantityPrice('minus', $( this ));
});
function getRandom(num){
var my_num = Math.floor(Math.random()*num);
return my_num;
}
var ids =[];
function randomVideo(){
var randomID = getRandom(ids.length);
var src = 'https://player.vimeo.com/video/'+ ids[randomID] +'?api=1&player_id=player1';
$('#player1').attr('src', src);
}
$(function() {
var iframe = $('#player1')[0];
var player = $f(iframe);
// When the player is ready, add listeners for pause, finish, and playProgress
player.addEvent('ready', function() {
player.addEvent('finish', onFinish);
player.api("play");
});
function onFinish(id) {
randomVideo();
}
});
$.getJSON('https://vimeo.com/api/v2/user1666688/all_videos.json', function(data) {
$.each(data, function(index, el) {
id = el.id;
ids.push(id)
});
randomVideo();
});