function getNoun(number, one, two, five) {
let n = Math.abs(number);
n %= 100;
if (n >= 5 && n <= 20) {
return five;
}
n %= 10;
if (n === 1) {
return one;
}
if (n >= 2 && n <= 4) {
return two;
}
return five;
}
alert("4 " + getNoun(4, 'слон', 'слона', 'слонов'));
Не пойму в чем дело, разъясните пожалуйста.
console.log
в определенном месте своего кода:document.querySelector('.list').addEventListener('click', (event) => {
const target = event.target
if (target.classList.contains('delete')) {
const task = document.querySelector(`[data-id="${target.dataset.delete}"]`)
// Посмотрим что будет выводиться в консоль?
console.log(target.dataset.id)
deleteTask(task)
}
})
const modal = document.querySelector(".modal");
const listbox = document.querySelector(".list");
const modalCancelButton = modal.querySelector(".cancel");
const modalConfirmButton = modal.querySelector(".confirm");
let currentTaskID = null;
listbox.addEventListener("click", ({ target: t }) => {
if (t.classList.contains("delete")) {
currentTaskID = t.dataset.delete;
modal.classList.remove("hidden");
}
});
modalCancelButton.addEventListener("click", () => {
modal.classList.add("hidden");
currentTaskID = null;
});
modalConfirmButton.addEventListener("click", () => {
modal.classList.add("hidden");
deleteTask(currentTaskID);
});
const deleteTask = id => id && listbox.querySelector(`[data-id="${id}"]`).remove();
const modal = document.querySelector('.modal')
document.querySelector('.list').addEventListener('click', (event) => {
const target = event.target
var task = document.querySelector(`[data-id="${target.dataset.delete}"]`)
if (target.classList.contains('delete')) {
modal.classList.remove('hidden')
modal.addEventListener('click', (event) => {
if (event.target.classList.contains('cancel')) {
modal.classList.add('hidden')
task = null
return false
} else if (event.target.classList.contains('confirm')) {
modal.classList.add('hidden')
if (task) {
task.remove()
}
}
})
}
})
if (confirm('Удалить элемент?') {
delete()
}
On Windows
Option 1
Install all the required tools and configurations using Microsoft's windows-build-tools using npm install --global --production windows-build-tools from an elevated PowerShell or CMD.exe (run as Administrator).
Option 2
Install tools and configuration manually:
Install Visual C++ Build Environment: Visual Studio Build Tools (using "Visual C++ build tools" workload) or Visual Studio 2017 Community (using the "Desktop development with C++" workload)
Install Python 2.7 (v3.x.x is not supported), and run npm config set python python2.7 (or see below for further instructions on specifying the proper Python version and path.)
Launch cmd, npm config set msvs_version 2017
const TabItemSelector = '.pageNav__tabItem';
const ContentItemSelector = '.pageNav__contentItem';
class TabsManager {
constructor(navNode){
this.tabs = [];
this.activeTab = null;
this.initFromHtml(navNode);
this.activateTab(this.tabs[0]);
}
initFromHtml (navNode) {
const headers = navNode.querySelectorAll(TabItemSelector);
const contents = navNode.querySelectorAll(ContentItemSelector);
for (var i = 0; i < headers.length; i++) {
this.registerTab(headers[i], contents[i]);
}
}
registerTab (header, content) {
const tab = new TabItem(header, content);
tab.onActivate(() => this.activateTab(tab));
this.tabs.push(tab);
}
activateTab (tabItem) {
if (this.activeTab) {
this.activeTab.setActive(false);
}
this.activeTab = tabItem;
this.activeTab.setActive(true);
}
}
const ActiveTabHeaderClass = 'pageNav__tabItem--active';
const ActiveTabContentClass = 'pageNav__contentItem--active';
class TabItem {
constructor (header, content) {
this.header = header;
this.content = content;
}
onActivate (action) {
this.header.addEventListener('click', () => action(this));
}
setActive(value) {
this.header.classList.toggle(ActiveTabHeaderClass, value);
this.content.classList.toggle(ActiveTabContentClass, value);
}
}
document.addEventListener('DOMContentLoaded', ()=>{
let tabs = new TabsManager(document.querySelector('.pageNav'));
})
Пример #2 Пример удаления cookie посредством setcookie()php.net/manual/ru/function.setcookie.php
Чтобы удалить cookie достаточно в качестве срока действия указать какое-либо время в прошлом. Это запустит механизм броузера, удаляющий истекшие cookie.
gulp.task('html:build', function() {
gulp.src('src/[^_]*.html')
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(gulp.dest('build/'));
});
@@include('./_includes/_module.html')
const SHOW_MORE = 3;
const itemSelector = '.item';
const hiddenClass = 'd-none';
const hiddenSelector = `.${hiddenClass}`;
const $show = $('.show');
const $hide = $('.hide');
const $items = $(itemSelector);
function updateButtons() {
$show.toggleClass(hiddenClass, $items.filter(hiddenSelector).length === 0);
$hide.toggleClass(hiddenClass, $items.not(hiddenSelector).length === SHOW_MORE);
}
$show.click(function() {
$items.filter(hiddenSelector).slice(0, SHOW_MORE).removeClass(hiddenClass);
updateButtons();
}).click();
$hide.click(function() {
$items.slice(SHOW_MORE).addClass(hiddenClass);
updateButtons();
});