document.getElementById('el').style.backgroundImage='url(/img/'+img+')';
function playVideo(){
document.getElementById('pl').innerHTML="<div id='pl></div>";
var music = window.IDvideo;
var volume = player.getVolume();
player.loadVideoByUrl(music);
player.playVideo();
document.getElementById('range').value=volume;
$('#range').on('change', function ()
{player.setVolume($(this).val());});
$('#mute-toggle').on('click', function()
{var mute_toggle = $(this);
if(player.isMuted()){
player.unMute();
mute_toggle.text('volume_up');
} else{player.mute();
mute_toggle.text('volume_off');}});
function stopPlay() {
var play = player.getPlayerState();
if (play === 0) {
$.ajax({
url: "roomUser/selectplay.php",
type: "POST",
data: {playadd: window.t},
dataType: "JSON",
success: function send(audiolist) {
if (!Array.isArray(audiolist) || !audiolist.length) {
document.getElementById('pl').innerHTML = "<div id='pl' style='width: 260px;height: 150px;position: absolute;margin-left: 741px;background: black'>" +
"<input id='add' type='button' value='Добавить видео' name='addTrack' OnClick='addTrack();'>" +
"</div>";document.getElementById('ok').innerHTML = '<div>' +
'</div>';
}else{
var selectdata = audiolist[0];window.IDvideo = "https://www.youtube.com/v/"+selectdata.url+"?version=3";playVideo()
}}});
setTimeout(function() {
clearInterval(timerPlayV);
}, 100);}}
var timerPlayV = setInterval(function() {
stopPlay();
}, 1000);}
и в чём проблема поместить всё это в setInterval?
Клёвая пунктуация. Головой бился об стенку, небось?
let times = 1000;
let timet = null;
function resetTi() {
if (!timet) {
let slee = {
nosleep: window.t,
usid:window.id,
};
websocket.send(JSON.stringify(slee));
}
clearTimeout(timet);
timet = setTimeout(sleep, times);
}
function sleep() {
timet = null;
let slees = {
sleep: window.t,
usid:window.id,
};
websocket.send(JSON.stringify(slees));
}
document.addEventListener('mousemove', resetTi);
var mydata ="1.19.1983";
var myday = mydata.substring(5);
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return number+" "+titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
function birthDateToAge(b) {
var n = new Date(), b = new Date(b),
age = n.getFullYear() - b.getFullYear();
return n.setFullYear(myday) < b.setFullYear(myday) ? age - 1 : age;
}
document.write( declOfNum(birthDateToAge(mydata), ['год', 'года', 'лет']) );