$(document).ready(function () {
nomeraciq();
_buton_proverka();
$(document).on('click', '.buton', function () {
if ($(this).css('cursor') != 'not-allowed') {
chPic($(this).attr('id'));
}
});
interval = null;
$(document).on('click', '#play', function () {
if ($(this).css('cursor') != 'not-allowed') {
$(this).html('[]').attr({
id: 'stop',
title: 'Спри превъртане'
});
interval = window.setInterval(function () {
chPic('napred');
}, 5000);
}
});
$(document).on('click', '#stop', function () {
stop();
});
$('#tablo button').click(function () {
var input = '',
top = '
Копирайте пътя с [ctrl]+[c]
', bottom = 'и го поставете където ви е нужно с [ctrl]+[v],
' +
'или просто плъзнете текста.
';
djam(top + input + bottom, '#444');
$('.djam1 div').css('text-align', 'center');
$('input[name=share]').select().attr('readonly', true).css('cursor', 'copy');
});
$(document).on('click', 'input[name=share]', function () {
$(this).select();
});
});
var da = function (id) {
$(id).css({
color: '#555',
cursor: 'pointer'
});
}, ne = function (id) {
$(id).css({
color: 'red',
cursor: 'not-allowed'
});
}, chPic = function (buton) {
var sega = $('#snimki').attr('title'), img = document.createElement('img');
img.src = '../view/resource/pic/loading.gif';
img.id = 'loader';
$('#ekran img').after(img);
$.ajax({
type: 'POST',
url: './click/',
data: {
click: 1,
buton: buton,
sega: sega
}
}).done(function (data) {
if (IsJson(data)) {
var danni = JSON.parse(data);
$('#loader').remove();
$('#ekran img').attr('src', danni.src);
$('#ekran img').attr('alt', danni.alt);
$('#snimki').attr('title', danni.sega);
$('#snimki').attr('class'), danni.broj;
nomeraciq();
_buton_proverka();
if (danni.sega == danni.broj) {
stop();
}
}
});
}, _buton_proverka = function () {
if ($('#snimki').attr('title') == 0) {
ne('#nazad,#na4alo');
} else {
da('#nazad,#na4alo');
}
if ($('#snimki').attr('title') == $('#snimki').attr('class') - 1) {
ne('#napred,#kraj,#play');
} else {
da('#napred,#kraj,#play');
}
}, nomeraciq = function () {
$('#teku6ta_snimka').html(parseInt($('#snimki').attr('title')) + 1);
$('#broj_snimki').html(parseInt($('#snimki').attr('class')));
}, stop = function () {
$('#stop').html('>').attr({
id: 'play',
title: 'Започни превъртане'
});
window.clearInterval(interval);
_buton_proverka();
};