function onContextMenu(e) {
e.preventDefault();
elementOnClick = e.target;
if(elementOnClick.tagName.toLowerCase() === 'div') {
if(elementOnClick.classList.contains('folder')) {
elementOnClick.setAttribute('contenteditable', 'true');
var range = document.createRange();
var sel = window.getSelection();
const pos = elementOnClick.childNodes[0].textContent.length
range.setStart(elementOnClick.childNodes[0], pos);
range.collapse(true);
sel.removeAllRanges();
sel.addRange(range);
elementOnClick.focus();
console.log('Elem FOLDER');
} else if(elementOnClick.classList.contains('file')) {
elementOnClick.setAttribute('contenteditable', 'true');
var range = document.createRange();
var sel = window.getSelection();
const pos = elementOnClick.childNodes[0].textContent.lastIndexOf('.')
range.setStart(elementOnClick.childNodes[0], pos);
range.collapse(true);
sel.removeAllRanges();
sel.addRange(range);
elementOnClick.focus();
console.log('Elem FILE');
}
} else {
console.log('EMPTY');
}
document.addEventListener('click', onMouseClick, false);
}
function addStyleToHead(c) {
var css = `${c} .blanks a:before,
${c} .zakoni a:before,
${c} .sud_arbitr a:before,
${c} .sud_msk a:before,
${c} .mfc a:before,
${c} .zags_msk a:before,
${c} .notary_msk a:before,
${c} .notary_mo a:before,
${c} .court_practice a:before{
content: none;
}`,
head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
head.appendChild(style);
style.type = 'text/css';
if (style.styleSheet){
// This is required for IE8 and below.
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
}
addStyleToHead('.bbb')
num = Number(copyString.match(/\((.*)\)/)[1] || undefined)
if(!isNaN(num)) { console.log('это число!') }
copyString = 'print ("hello world"); //строка'
// undefined
copyString = 'print (56); '
// это число!
User.updateOne({
{ _id: 1 },
{ $pull: { items: { _id: '24123123dsfasdf32' } } }
})
User.updateOne({
{ _id: 1 },
{ $pull: { items: { _id: { $eq: '24123123dsfasdf32' } } }
})
$(document).on("keydown", (e) => {
console.log('holding shift:', e.shiftKey)
});