fetch("https://jsonplaceholder.typicode.com/users")
.then(response => response.json())
.then(json => console.log(json));
$(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;
}
[
{
"key": "ctrl+shift+g",
"command":"editor.emmet.action.wrapWithAbbreviation",
"when": "editorTextFocus && !editorReadonly"
}
]
ext install htmltagwrap
.image{
width: 200px;
height: 200px;
border: 4px solid transparent;
border-radius: 50%;
background-image: linear-gradient(white, white), radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%,#d6249f 60%,#285AEB 90%);
background-origin: border-box;
background-clip: content-box, border-box;
}
driver = webdriver.Firefox()
driver.get("http://www.google.ca")
element = driver.find_element_by_link_text("Gmail")
element.click()
this.$store.commit('setData', data);
import { mapGetters } from 'vuex';
// code...
computed: {
...mapGetters({
data: 'getData',
}),
},
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();
li{
border: 2px solid #ddd;
}
li:after {
content: "";
display: table;
clear: both;
}
<li class="selected">
<a href="javascript:void(0)" class="wr-tooltip" data-value="s-37%d0%bb">S<br>37Л</a>
</li>
span{
display: inline-block
}
Event.preventDefault();
// this is the id of the form
$("#idForm").submit(function(e) {
var form = $(this);
var url = form.attr('action');
$.ajax({
type: "POST",
url: url,
data: form.serialize(), // serializes the form's elements.
success: function(data)
{
alert(data); // show response from the django.
}
});
e.preventDefault(); // avoid to execute the actual submit of the form.
});
var http = new XMLHttpRequest();
http.open('POST', url, true);
http.onreadystatechange = function() {
if(http.readyState == 4 && http.status == 200) {
console.log(http.responseText);
}
}
http.send(params);
$.ajax({
type: "POST",
url: url,
data: data,
success: success,
dataType: dataType
});
// ...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}}
find /folder/with/images/ -name '*' -exec file {} \; | grep -o -P '^.+: \w+ image' | cut -d':' -f1 | xargs -I{} cp -v {} /destination/folder/
cp -r /folder/with/files/*.jpeg /destination/folder
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
}
function mark_menu_item_as_active($classes, $item) {
if( in_array('my-custom-class',$classes) && ( is_category('my-category') /* OR ...*/ ) ) {
$classes[] = 'current-menu-item';
}
return $classes;
}
add_filter('nav_menu_css_class', 'mark_menu_item_as_active', 10, 2);
if(window.location.href.indexOf("/blog/") > -1) {
$('#menu-item-339').addClass('current-menu-item');
}
if(window.location.href.indexOf("/articles/") > -1) {
$('#menu-item-241').addClass('current-menu-item');
}
if(window.location.href.indexOf("/forum/") > -1) {
$('#menu-item-437').addClass('current-menu-item');
}
<div class="siema">
<div>Hi, I'm slide 1</div>
<div>Hi, I'm slide 2</div>
<div>Hi, I'm slide 3</div>
<div>Hi, I'm slide 4</div>
</div>
position: absolute
и прижата к верху top: 0
.<header>
<section class="slider">
<div class="slider__slide"> <!-- тут текст и картинка--> </div>
<div class="slider__slide"> <!-- тут текст и картинка--> </div>
<div class="slider__slide"> <!-- тут текст и картинка--> </div>
....
</section>
<nav> <!-- тут меню --> </nav>
</header>
header{
position: relative;
width: 100%;
height: 100vh;
}
.slider{
width: 100%;
height: 100%;
}
.slider__slide{
width: 100%;
height: 100%;
background: url() cover;
.....
}
nav{
position: absolute;
top: 0;
}
// Пример с плагинов https://github.com/camwiegert/in-view
// Строки 10 - 14 в примере выше
inView('.newComment')
.on('enter', function(){
setTimeout(function() {
newComment.classList.remove('new');
}, 3000);
})
});