console.log(eval(jsonPlayers));
const jsonPlayers = {
"name": "John",
"age": 30,
"isAdmin": false,
"courses": ["html", "css", "js"],
"wife": null
};
const outputMembers = (jsonPlayers) => {
let keys = [];
for(let parse in jsonPlayers) {
console.log(parse, jsonPlayers[parse])
}
};
outputMembers(jsonPlayers);
const object = '{
"time": 25526,
"duration": 369,
"url": "/maps/AintMy/pictos/picto-1.png",
"isLineEnding": 0
}';
console.log( JSON.parse(object.url));
const selectPlace = document.querySelectorAll('.place div'),
selectLink = document.querySelectorAll('.link div'),
selectPower = document.querySelectorAll('.power div')
let place = '',
link = '',
power = ''
let sum = 0;
function selectionActive(e) {
console.log(this);
this.select.forEach(r => {
r.classList.remove('value-active')
})
this.select.forEach(item => {
if (item === e.target) {
item.classList.add('value-active')
place = item.textContent
}
})
sum = `${place} + ${link} + ${power}`;
console.log(sum);
}
selectPlace.forEach(e => {
e.addEventListener('click', {handleEvent: selectionActive, e, select:selectPlace})
})
selectLink.forEach(e => {
e.addEventListener('click', {handleEvent: selectionActive, e, select:selectLink})
})
selectPower.forEach(e => {
e.addEventListener('click', {handleEvent: selectionActive, e, select:selectPower})
})
const foundMovies = [
{title: 'IronMan', year: '2010', id: '1234', status: false},
{title: 'Text Me If You Can', year: '2014', id: '2345', status: false},
{title: 'Wrong Way', year: '2012', id: '3456', status: false},
{title: 'Blizzard', year: '2011', id: '4567', status: false},
];
const nominates = [
{title: 'Text Me If You Can', year: '2014', id: '2345'},
{title: 'Wrong Way', year: '2012', id: '3456'},
];
for (let elMovies in foundMovies) {
for (let elNominates in nominates) {
if (foundMovies[elMovies].title === nominates[elNominates].title &&
foundMovies[elMovies].year === nominates[elNominates].year &&
foundMovies[elMovies].id === nominates[elNominates].id) {
foundMovies[elMovies].status = true;
}
}
}
console.log(foundMovies);
const items = [
{
id: "1",
status: 100,
event: "Открытие двери",
user: 'Константин',
user_pic: '../img/user.png',
created_at: '2020-09-01T12:31',
},
{
id: "2",
status: 200,
event: "Вызов в домофон",
user: 'Константин',
user_pic: '../img/user.png',
created_at: '2020-09-01T12:30',
},
{
id: "3",
status: 300,
event: "Звонок",
user: 'Антонина',
user_pic: '../img/user.png',
created_at: '2020-08-03T18:30',
},
{
id: "4",
status: 400,
event: "Срабатывание сигнализации",
user: 'Олег',
user_pic: '../img/user.png',
created_at: '2020-07-28T10:40',
},
{
id: "5",
status: 100,
event: "Срабатывание сигнализации",
user: 'Олег',
user_pic: '../img/user.png',
created_at: '2020-07-28T10:40',
},
{
id: "6",
status: 100,
event: "Срабатывание сигнализации",
user: 'Олег',
user_pic: '../img/user.png',
created_at: '2020-07-28T10:40',
},
{
id: "7",
status: 300,
event: "Срабатывание сигнализации",
user: 'Олег',
user_pic: '../img/user.png',
created_at: '2020-07-28T10:40',
},
];
let filterid = [];
items.forEach(el => {
if (el.id > 4) {
filterid.push(el);
}
});
let filterStatus = [];
filterid.forEach(el => {
if (el.status === 100) {
filterStatus.push(el);
}
});
console.log(...filterStatus);
<div class="steam-box">
<h2>Login</h2>
<form>
<div class="input-box">
<input type="text" name="login" id="login" required>
<label>Username</label>
</div>
<div class="input-box">
<input type="password" name="password1" id="password" required>
<label>Password</label>
<div id="toggle" onclick=" showHide();"></div>
</div>
<input type="submit" value="Sign in">
</form>
</div>
<script>
const form = document.forms[0];
const text = form.querySelectorAll(`.input-box`);
let textLogin = text[0].querySelector(`label`);
let textPass = text[1].querySelector(`label`);
form.addEventListener(`submit`, (evt) => {
evt.preventDefault();
if (form.elements.login.value === '') {
textLogin.textContent = `Заполните поле`;
} else if (form.elements.password.value === '' ) {
textPass.textContent = `Заполните поле`;
} else {
document.location.href = "НТТР: // сайт . ру /";
}
});