const startTimer = (){ ... }
function startTimer(){ ... }
for ( const key in _headers ) {
if ( {}.hasOwnProperty.call( _headers, key ) ) {
headers.append( key, _headers[ key ] );
}
}
if ( {}.hasOwnProperty.call( _headers, key ) )
if (_headers != null && !!_headers[key] )
.catch( console.error )
.catch( e => console.error(e) )
moment("20111031", "YYYYMMDD").fromNow(); // 5 лет назад
moment("20120620", "YYYYMMDD").fromNow(); // 5 лет назад
moment().startOf('day').fromNow(); // 10 часов назад
moment().endOf('day').fromNow(); // через 14 часов
moment().startOf('hour').fromNow(); // 12 минут назад
moment().subtract(10, 'days').calendar(); // 02.04.2017
moment().subtract(6, 'days').calendar(); // В прошлый четверг в 10:12
moment().subtract(3, 'days').calendar(); // В прошлое воскресенье в 10:12
moment().subtract(1, 'days').calendar(); // Вчера в 10:12
moment().calendar(); // Сегодня в 10:12
moment().add(1, 'days').calendar(); // Завтра в 10:12
moment().add(3, 'days').calendar(); // В субботу в 10:12
moment().add(10, 'days').calendar(); // 22.04.2017
doctype html
html
head
style.
html, body {background: white; background: #2c2c2c; }
body, div { margin: 0; padding: 0;}
html, body { width: 100%; height: 100% }
body { padding-top: 50px; }
nav { position: fixed; top: 0; height: 50px; width: 100%; background:#444444; border: 1px solid #313131; z-index: 1000; }
nav ul { text-align: center; }
nav ul li { display: inline-block; }
nav ul li a { color: #D07C40; display: inline-block; text-decoration:none; margin: 0 7px; font-family: Diskoteque; text-shadow: 0 0 0.5em #241600, 0 0 0.1em #000000; }
nav ul li a:hover { color: #94D040;}
nav ul li a:visited { color: #EFC75E; }
nav ul li a:focus { color: #94D040; }
nav ul li a:target { color: #94D040; }
nav ul li a:active { color: #94D040; }
.anchor { display: block; position:absolute; margin-top: -60px; }
.photo { object-fit: contain; margin: 0 auto; position: relative; padding: 10px; margin: 15px 10px; background: white; box-shadow: 2px 2px 5px black;}
.photo.hor { width: 640px; height: 480px; }
.photo.vert { width: 480px; height: 640px; }
.photo .num { position: absolute; z-index: 100; color: red; font-family: Tiza; width:2.5em; height: 2.1em; text-align: center; margin: .5em 0 0 .2em; }
.photo img { width: 100%; height: 100%; display: block; margin: 0 auto; position: relative; max-width: 100%; max-height: 100%; object-fit: contain; }
.photo .filename {position: absolute; z-index: 100; width:100%; height: 1.5em; margin-top: -2.1em; padding: .2em; }
.photo .filename span { display:inline-block; color: #96969c; text-shadow: 0 0 0.5em #101c5d, 0 0 0.1em #000000; font-family: ZOMBIFIED; padding: .4em .2em 0 .2em; }
script.
function scrollTop(to, duration) {
if (document.body.scrollTop == to) return;
var diff = to - document.body.scrollTop;
var scrollStep = Math.PI / (duration / 10);
var count = 0, currPos;
start = document.body.scrollTop;
scrollInterval = setInterval(function(){
if (document.body.scrollTop != to) {
count = count + 1;
currPos = start + diff * (0.5 - 0.5 * Math.cos(count * scrollStep));
document.body.scrollTop = currPos;
}
else { clearInterval(scrollInterval); }
},10);
}
function scrollTo(e)
{
e.preventDefault();
e.stopPropagation();
//var dest = document.getElementById(elID);
var destName = this.hash.substr(1);
if(destName.length> 0){
var dest = document.querySelector('a[name='+destName+']');
var destRect = dest.getBoundingClientRect();
var content = document.querySelector('.content');
var contentRect = content.getBoundingClientRect();
var bodyRect = document.body.getBoundingClientRect();
var contentHeight = contentRect.height + 120;
var bodyHeight = bodyRect.height;
var offsetTop = destRect.top - bodyRect.top;
if(offsetTop > contentHeight - bodyHeight)
offsetTop = contentHeight - bodyHeight;
scrollTop(offsetTop, 200);
} else {
scrollTop(0, 200);
}
}
body
nav: ul
each photo, idx in photoList
li.item: a.nav-link(href="#"+(idx > 0 ? photo.name : ''))= idx+1
script.
Array.from(document.querySelectorAll('a.nav-link'))
.forEach((a)=>a.addEventListener('click', scrollTo));
.content
each photo, idx in photoList
div(style='clear:both;')
a.anchor(name=photo.name)
div(class=photo.vertical?'photo vert': 'photo hor')
.num
span= idx+1
img(src='file://'+photo.path)
.filename
span= photo.name
"use strict";
var test={
blabla:function(){
console.log(fullTrace()[1].funcName);
},
blabla1:function(){
console.log(fullTrace()[1].funcName);
},
blabla2:function(){
console.log(JSON.stringify(fullTrace(), null, 4));
}
};
(function start(){
test.blabla();
test.blabla1();
test.blabla2();
})();
function fullTrace(){
let stack;
try{ throw Exception() }
catch(e) { stack = e.stack.split(/\n/g); }
/* exp msg */ stack.shift();
return stack.map(s => {
let row = s.replace(/^\s*at\s+/,''), m;
if(m = row.match(/([^\s\(]+) \(([^:]+):(\d+):(\d+)\)/))
return {funcName:m[1],filePath:m[2],strNum:m[3],colNum:m[4]}
else if(m = row.match(/([^:]+):(\d+):(\d+)/))
return {filePath:m[1],strNum:m[2],colNum:m[3]}
} )
}
Object.blabla
Object.blabla1
[
{
"funcName": "fullTrace",
"filePath": "<anonymous>",
"strNum": "22",
"colNum": "10"
},
{
"funcName": "Object.blabla2",
"filePath": "<anonymous>",
"strNum": "10",
"colNum": "32"
},
{
"funcName": "start",
"filePath": "<anonymous>",
"strNum": "17",
"colNum": "10"
},
{
"filePath": "<anonymous>",
"strNum": "18",
"colNum": "3"
}
]
document.addEventListener("DOMContentLoaded", function(event) {
var scroller = document.querySelector('#scroller');
var main = document.querySelector('.main');
var other = document.querySelector('.other');
var container = document.querySelector('.container');
scroller.onclick = function () {
var topPosition = getComputedStyle(container).marginTop;
container.style.marginLeft = parseInt(topPosition) - window.innerHeight + 'px';
}
});