prev.addEventListener('click', ()=>{
// правильно current
if (curentMonth == 0) curentYear -= 1
curentMonth = (12 + curentMonth - 1) % 12
createCalendar(calendar, curentYear, curentMonth);
months.innerHTML = monthsName[curentMonth];
years.innerHTML = curentYear;
})
const validTelegramNickname = /^[A-Za-z\d_]{5,32}$/;
function initWebGL(canvas){
var ctx = null;
for (name of ["webgl", "experimental-webgl"]){
try {
ctx = canvas.getContext(name);
} catch(error) {
console.log(name + ' not supported');
}
if (ctx) break;
}
return ctx;
}
let canvas = document.createElement('canvas');
const webGL = initWebGL(canvas);
if (webGL) // supported
else // not supported
RewriteCond %{HTTP_HOST} ^site\.ru$
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.site\.ru$
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.site.ru/$1 [R=301,L]
const Controller = function(){
var busy = false;
return {
ready: () => busy === false,
do: (data) => new Promise((resolve,reject) => {
if (busy)
reject("I`m busy dude!")
busy = true;
// +100500 code rows
setTimeout(() => {
busy = false;
resolve("wow, its working fine!");
}, 1000);
})
}
}
let ctrl = new Controller();
ctrl.do("something")
.then(result => console.log("Job's done: " + result))
ctrl.do("fault")
.catch(err => console.log(`Houston, we have a problem: ${err}`));
setTimeout(() => ctrl.do("something again").then(result => console.log("It works again: " + result)), 1100)
function calculateResults(users,results){
let map = new Map();
let total = 0;
for (let result of results){
let exist = map.get(result.id);
if (exist) exist.counts += result.counts;
else map.set(result.id, result.counts);
total += result.counts;
}
for (let user of users){
user.result = (map.get(user.id) || 0) * 100 / total;
}
return users;
}
function ConvertMainFunc(folder_path) {
try{
console.log("f-path in func:"+folderpath.value);
let txtlisttosend;
if(fs.existsSync(path2)){
getdirectories(folder_path.value, function(err, content){return content});
// return куда?
console.log(content);
// где определена переменная content?
function getdirectories(path, callback) {
fs.readdir(path, function (err, content) {
if (err) return callback(err)
console.log(content);
callback(null, content)
})
}
function getValue(objectValues, valueString, defaultV = '') {
let current = objectValues;
for (let key of valueString.split('.')){
if (Object.prototype.toString.call(current) === '[object Object]' && key in current) {
current = current[key]
} else return defaultV
}
return current
}
const getValue = (objectValues, valueString = '', defaultV = '') => valueString.split('.').reduce((value, key) => value.hasOwnProperty(key) ? value[key] : defaultV, objectValues);
<html>
<head>
<script>
function main(){
a = b;
}
window.addEventListener('load', function(){
try {
main()
} catch (e){
proceedException(e)
}
})
</script>
<script src="file.js">
</script>
</head>
<body>
<div id="error">
</div>
</body>
</html>
function parseStackTrace(stacktrace){
let [_, functionName, fileName, row, __, column] = stacktrace.match(/at\s([^\s]+)\s\((.+?):(\d+)(:(\d+))?\)/)
return [functionName, fileName, row, column]
}
function proceedException(exception){
let [fn, file, row, column] = parseStackTrace(exception.stack),
node = document.createElement('p');
node.innerText = `Ошибка в файле: ${file}, функция <${fn}> на строке ${row}${column ? '(' + column + ' символ)' : ''} ${exception}`;
document.querySelector('#error').appendChild(node);
}
function helper(){
let c = 1, a = b;
}
function onload(){
helper();
}
window.addEventListener('load', function(){
try {
onload()
} catch (e){
proceedException(e)
}
})