fs.open(fname, 'a', (err, file_handle) => {
if (!err)
this.file_handle = file_handle;
this.dataCalendar.curMonth++
this.dataCalendar.curYear--
curMonth < 11
, curMonth > 0
... Изменился месяц - надо поменять день (или не надо?), надо поменять год (или не надо - по-всякому бывает), поменять ещё чёрт знает что. Увеличили день - надо менять месяц, если это 30/31 число, иногда год - если было 31 декабря. Ну и т.д. и т.п.curMonth++
будет что-то вродеcurDate = new Date(curDate.setMonth(curDate.getMonth() + 1))
computed: {
calendarData() {
return {
year: this.curDate.getFullYear(),
month: this.curDate.getMonth(),
// ...
};
}
}
$('#given1').on('change', 'select', function(){
addNewSelect();
});
$('#given1').on('change', 'select', addNewSelect);
.on('change blur',
. $checkValue = function($arrPostKey, $value) use(&$errors) {
function checkValue($arrPostKey, $value, &$errors) {
function checkValue($arrPostKey, $value) {
global $errors;
Часть начального кода с v-for я пропустил.
types.id == date.activities[i].type_id
date.activities.every(n => n.type_id == types.id)
data: () => ({
items: [
{ buttonText: '+', className: 'container' },
{ buttonText: '-', className: 'container-fluid' },
],
...
}),
<button
v-for="n in items"
v-text="n.buttonText"
:class="{ active : active === n.className }"
@click="active = n.className"
></button>
items.slice...
надо было унести в computed):<div v-for="item in items.slice((page - 1) * perPage, page * perPage)">
{{ item }}
</div>
computed: {
numPages() {
return Math.ceil(this.items.length / this.perPage);
},
},
methods: {
next(change) {
this.page = Math.max(1, Math.min(this.numPages, this.page + change));
},
},
<button @click="next(-1)" :disabled="page <= 1">prev</button>
<button @click="next(+1)" :disabled="page >= numPages">next</button>
{ path: '/city', component: City, props: () => ({ cityid: app.cityid }) }
<router-view :cityid="cityid"></router-view>
validate = true;
if (/* проверка введённых данных */) {
validate = false;
}
validate = /* проверка введённых данных */
arr.sort(({ date: a }, { date: b }) => !a ? 1 : !b ? -1 : a - b);
// или
arr.sort((a, b) => (a.date || Infinity) - (b.date || Infinity));
const sortedArr = arr
.map(n => [ n, n.hasOwnProperty('date') ? n.date : Infinity ])
.sort((a, b) => a[1] - b[1])
.map(n => n[0]);
function toggleWithInterval(selector, delay) {
let index = -1;
return setInterval(function($items) {
$items.eq(index).hide();
index = (index + 1) % $items.length;
$items.eq(index).show();
}, delay, $(selector).hide());
}
toggleWithInterval('.container1 > .good', 1000);
toggleWithInterval('.container2 > .good', 300);
/что-то\d+/
.$arr = explode(', ', explode('какой-то текст: ', $str)[1]);
preg_match_all('/[^ ,:]+(?!.*:)/', $str, $matches);
$arr = $matches[0];
const id = '2'; // а нормальный id придумать было - нет, никак?
const el = document.getElementById(id);
// или
const el = document.querySelector(`[id="${id}"]`);
// или (нет, это если бы id нормальный был)
const el = document.querySelector('#' + id);
const parent = el.parentNode;
.parent.prepend(el);
// или
parent.children[0].before(el);
// или
parent.insertAdjacentElement('afterbegin', el);
// или
parent.insertBefore(el, parent.firstElementChild);