var orig = [2, 2, 5, 6, 5]; // значения которые выпали
var sorted = orig.sort(); // отсортированные значения
// ищем кол-во одинаковых цыфр начиная с переданной позиции
function detect(i, array)
{
var count = 1;
for (; i < array.length - 1; i++)
{
if (array[i] != array[i + 1])
{
break;
}
count++;
}
return count;
}
var index = 0;
var count = 0;
// поиск кол-ва каждой цыфры
while(index < sorted.length - 1)
{
index += count;
count = detect(index, sorted);
console.log(sorted[index] + ": " + count);
}
<center>
<div id="countdown"></div>
<span id="span">remain</span>
</center>
CountDownTimer('<?php echo date("m/d/Y H:i A", time()); ?>', 'countdown');
function CountDownTimer(dt, id)
{
var end = new Date(dt);
var _second = 1000;
var _minute = _second * 60;
var _hour = _minute * 60;
var _day = _hour * 24;
var timer;
function showRemaining() {
var now = new Date();
var distance = end - now;
if (distance < 0) {
clearInterval(timer);
document.getElementById(id).innerHTML = 'EXPIRED!';
return;
}
var days = Math.floor(distance / _day);
var hours = Math.floor((distance % _day) / _hour);
var minutes = Math.floor((distance % _hour) / _minute);
var seconds = Math.floor((distance % _minute) / _second);
document.getElementById(id).innerHTML = days + 'days ';
document.getElementById(id).innerHTML += hours + 'hrs ';
document.getElementById(id).innerHTML += minutes + 'mins ';
document.getElementById(id).innerHTML += seconds + 'secs';
}
timer = setInterval(showRemaining, 1000);
}
angular.forEach(ProductsList, function(value, key) {
}
var counter = 4;
var inter = setInterval(function() {
a.innerHTML = counter--;
if (!counter) clearInterval(inter);
}, 2000);
function fix(e, value) {
e = $(e);
e.find("option").each(function(id, e) {
if (e.value == value) {
e.selected = true;
retunr;
}
});
}
fix("#chooser", "20px");
var element = document.querySelector("#menu");
document.onscroll = function() {
if (document.body.scrollTop > 200 && document.body.scrollTop < (document.body.scrollHeight - 500))
{
element.style.display = "block";
}
else
{
element.style.display = "none";
}
};
var element = document.querySelector("#menu");
document.onscroll = function() {
if (document.body.scrollTop > 200 && document.body.scrollTop < (document.body.scrollHeight - 500))
{
element.style.display = "block";
}
else
{
element.style.display = "none";
}
};
$("#filename")[0].files
$("#filename")[0].value = "";
<input type="file" name="filename" id="filename">
function step(i)
{
console.log(i);
setTimeout(function() {
step(++i);
}, 1000);
}
step(0);