const getFirstDateofMonth = date => new Date(date.getFullYear(), date.getMonth(), 1).getDay();
const getDaysInMonth = date => new Date(date.getFullYear(), date.getMonth()+1, 0).getDate();
const createMonth = (date, el) => {
const startFrom = getFirstDateofMonth(date); // Return the number of the first day
const daysAmount = getDaysInMonth(date); // Return the number of days in the month
for (let i = 1; i < startFrom+daysAmount; i++) {
const li = document.createElement('li');
// Colorize cells
if (i < startFrom) {
li.classList.add('past');
} else {
li.classList.add('current')
}
el.appendChild(li);
}
}
const calendar = document.getElementById('calendar'); // Container
const date = new Date(Date.now()); // Date
/*
date - some date in format:
- new Date('November 17, 1995 03:24:00')
- new Date(Date.now())
- new Date('1995-12-17T03:24:00')
- ....
calendar - DOM element
*/
createMonth(date, calendar);
<div class="js-courses-type" data-loop="4"></div>
<div class="js-courses-type" data-loop="2"></div>
<div class="js-courses-type" data-loop="1"></div>
<div class="js-courses-type" data-loop="3"></div>
<div class="js-courses-type" data-loop="5"></div>
const courses = [...document.querySelectorAll('.js-courses-type')].sort((a, b) => a.getAttribute('data-loop') - b.getAttribute('data-loop'));
courses.forEach( course => window.console.log(course));
<path class="path-2" d="M0,400 L 1000,400 1000,445 S 500,420 0,480 Z" fill="#2b81bf"></path>
<path class="path-2" d="M0,400 L 1000,400 1000,500 S 500,500 0,500 Z" fill="#2b81bf"></path>
let i = 0;
(function loop() {
i++;
path.setAttribute('d', `M0,400 L 1000,400 1000,445 S ${i},420 0,480 Z`);
if (i === 500) return
window.requestAnimationFrame(loop);
})();
При быстром движении мыши события mouseover, mousemove, mouseout могут пропускать промежуточные элементы.связано с Вашей задачей и кодом? Вот вам пример "лупы" link. Есть какие-то "скачки"? Код по ссылке предоставлен - исправляйте свой.
document.getElementById('overlay').style='visibility:hidden;opacity:0;transition:all 0.7s ease-out 0s';
th.trigger("reset");
на код выше....
$('#thanks').fadeIn(500);
setTimeout(function() {
// Done Functions
// th.trigger("reset");
document.getElementById('overlay').style='visibility:hidden;opacity:0;transition:all 0.7s ease-out 0s';
}, 1000);
const countInt = parseInt(count);
// or
const count = parseInt($( "#add_favorite_video_lbl" ).text());
arguments is an Array-like object accessible inside functions that contains the values of the arguments passed to that function.
// Glitch Header /////////////////////////////////////////////////////////////////////
$(function(){
var imgContainerEl = $('#img-container');
var imagePath = template_directory_uri + '/images/' + imgContainerEl.attr('bg-glitch');
function loadImage(src) {
var imageEl = new Image();
imageEl.onload = function () {
changeGlitch(imageEl);
};
imageEl.src = src;
}
function changeGlitch(img) {
var params = glitches[getRandomInt(0, glitches.length - 1)];
glitch(params)
.fromImage(img)
.toDataURL()
.then(function(dataURL) {
var imageEl = new Image();
imageEl.src = dataURL;
imgContainerEl.css('background-image', 'url(' + imageEl.src + ')');
imgContainerEl.css('background-size', 'cover');
setTimeout(function(){
imgContainerEl.css('background-image', 'none');
}, 1000);
setTimeout(function(){
imgContainerEl.css('background-image', 'url(' + imageEl.src + ')');
imgContainerEl.css('background-size', 'cover');
}, 1050);
setTimeout(function(){
imgContainerEl.css('background-image', 'none');
}, 1100);
setTimeout(function(){
loadImage(imagePath);
}, getRandomInt(2000, 10000));
});
}
loadImage(imagePath);
});
<input
type="text"
class="form-control text-center"
value="0"
data-max="200"
data-min="0"
data-step="1">
quantity: { min: 0, max: 999, step: 1, precision:0 },
$(document).on('ready', function() {
var winHeight = $(window).height(),
docHeight = $(document).height(),
progressBar = $('progress'),
max, value;
/* Set the max scrollable area */
max = docHeight - winHeight;
progressBar.attr('max', max);
$(document).on('scroll', function(){
value = $(window).scrollTop();
progressBar.attr('value', value);
});
});
progress {
/* Positioning */
position: fixed;
left: 0;
top: 0;
/* Dimensions */
width: 100%;
height: 5px;
/* Reset the appearance */
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
/* Get rid of the default border in Firefox/Opera. */
border: none;
/* Progress bar container for Firefox/IE10+ */
background-color: transparent;
/* Progress bar value for IE10+ */
color: red;
}
progress::-webkit-progress-bar {
background-color: transparent;
}
progress::-webkit-progress-value {
background-color: red;
}
progress::-moz-progress-bar {
background-color: red;
}
const video = document.getElementById('video');
video.ontimeupdate = function() {
window.console.log(video.currentTime);
};
9.643231
9.893151
10.143168
10.393094
10.643828
10.893123
11.1771
11.39276
function update(t) {
window.console.log(t);
window.requestAnimationFrame(update);
};
update();
// ...rest of the initial code omitted for simplicity.
const { check, validationResult } = require('express-validator/check');
app.post('/user', [
// username must be an email
check('username').isEmail(),
// password must be at least 5 chars long
check('password').isLength({ min: 5 })
], (req, res) => {
// Finds the validation errors in this request and wraps them in an object with handy functions
const errors = validationResult(req);
if (!errors.isEmpty()) {
return res.status(422).json({ errors: errors.array() });
}
User.create({
username: req.body.username,
password: req.body.password
}).then(user => res.json(user));
});
{
"errors": [{
"location": "body",
"msg": "Invalid value",
"param": "username"
}]
}
res.render('home', {errors: errors.array()});
{{# if errors }}
{{# each errors }}
<p class="alert alert-danger">{{ this.msg }}</p>
{{/each}}
{{/if}}
let uno = new Date("Sat Aug 18 2018 00:00:00 GMT+0300").getTime();
let dos = new Date("Mon Aug 20 2018 00:00:00 GMT+0300").getTime();
let tres = new Date("Sun Aug 19 2018 00:00:00 GMT+0300").getTime();
if ( tres > uno && tres < dos) {
// do something
}
let uno = new Date("Sat Aug 18 2018 00:00:00 GMT+0300");
let dos = new Date("Mon Aug 20 2018 00:00:00 GMT+0300");
let tres = new Date("Sun Aug 19 2018 00:00:00 GMT+0300");
if ( tres > uno && tres < dos) {
// do something
}