var names = ["Stavka-1", "Stavka-2", "Stavka-3"];
ion.sound({
sounds: [
{name: names[0]},
{name: names[1]},
{name: names[2]}
],
volume: 1,
path: "/sounds/",
preload: true
});
var rand = Math.round(Math.random() * (names.length - 1));
ion.sound.play(names[rand]);
while
тут не нужен. Нужно сделать так: jsfiddle.net/7m6waxLmvar hlt1 = 10,
hlt2 = 10;
function change() {
hlt1 -= 1;
hlt2 -= 1;
var inProgress = hlt1 > 0 && hlt2 > 0;
console.log(hlt1, hlt2, inProgress);
if (inProgress) {
setTimeout(change, 1000);
}
}
setTimeout(change, 1000);
<div class="fixed hidden">
Фиксированный блок
</div>
.fixed {
position: fixed;
bottom: 30px;
right: 30px;
width: 100px;
height: 50px;
background: #000;
}
.fixed.hidden {
display: none;
}
var $win = $(window),
$fixed = $(".fixed"),
limit = 300;
function tgl (state) {
$fixed.toggleClass("hidden", state);
}
$win.on("scroll", function () {
var top = $win.scrollTop();
if (top < limit) {
tgl(true);
} else {
tgl(false);
}
});
<img id='img' src='http://site.com/galleries/179606_08.jpg'/>
var img = document.getElementById('img'),
url = img.getAttribute('src');
function getNum (url) {
var parts = url.split('/'),
len = parts.length,
name = parts[len - 1],
num = name.split('_')[1].split('.')[0];
return num;
}
var num = getNum(url);
console.log(num); // 08