<span id="total">0</span> <button id="action">+1</button>
const action = document.querySelector('#action');
const total = document.querySelector('#total');
let counter = readCounterFromStorage();
updateStorageAndElement();
action.addEventListener('click', () => {
counter++;
updateStorageAndElement();
})
function readCounterFromStorage() {
return parseInt(localStorage.getItem('counter')) || 0;
}
function updateStorageAndElement() {
total.innerText = counter;
localStorage.setItem('counter', counter);
}
<div class="wrapper">
<div class="button">
<div class="button__circle">
<div class="button__circle-shadow"></div>
</div>
<div class="button__body">Button</div>
</div>
</div>
$circle-size: 50px;
$transition: 0.3s;
$base-shift: translateX(-$circle-size * 0.25);
$hover-shift: translateX(-$circle-size * 0.75);
$circle-color: #F79854;
$button-color: linear-gradient(90deg, #427C33 0%, #6EBC5A 100%);
$blend-color: mix(#F79854, #427C33);
.wrapper {
width: 500px;
height: 500px;
display: flex;
align-content: center;
justify-content: center;
}
.button {
$block: &;
height: $circle-size;
display: flex;
cursor: pointer;
&__circle,
&__circle-shadow {
height: $circle-size;
width: $circle-size;
border-radius: 50%;
}
&__circle {
position: relative;
z-index: 2;
background: $circle-color;
overflow: hidden;
}
&__circle-shadow {
position: absolute;
left: 100%;
background: $blend-color;
transition: $transition;
transform: $base-shift;
#{$block}:hover & {
transform: $hover-shift;
}
}
&__body {
height: $circle-size;
width: $circle-size * 6;
display: flex;
align-items: center;
justify-content: center;
color: white;
background: $button-color;
border-radius: $circle-size;
transition: $transition;
transform: $base-shift;
#{$block}:hover & {
transform: $hover-shift;
}
}
}
const data = {
"index.js": ["foo.js"],
"foo.js": ["baz.js", "lol.js"],
"baz.js": ["bar.js", "lem.js"],
"bar.js": ["baz.js", "k.js"]
};
function searchCircularDepengency(entry = "index.js", path = []) {
const branch = data[entry];
const newPath = [...path, entry];
console.log("Path", newPath);
// Если есть вложенные элементы,
if (branch) {
// проверить каждый
branch.forEach((nextEntry) => {
// на предмет прохожения ранее,
if (path.includes(nextEntry)) {
console.warn(
"Found Circular Depengency " + nextEntry + " in " + entry,
path
);
// если нет идти глубже
} else {
searchCircularDepengency(nextEntry, newPath);
}
});
} else {
console.log("Branch complite. All OK!");
}
}
console.log(searchCircularDepengency());
$(function() {
const worksSlider = $('[data-slider="slick"]');
/* Filter
=====================*/
let filter = $("[data-filter]");
filter.on("click", function(event) {
event.preventDefault();
changeBlocksVisibility($(this).data('filter'))
});
});
$().ready(() => changeBlocksVisibility("female"));
function changeBlocksVisibility(cat = 'all') {
if(cat == 'all') {
$("[data-cat]").removeClass("hide");
} else {
$("[data-cat]").each(function() {
let workCat = $(this).data('cat');
if(workCat != cat) {
$(this).addClass('hide');
} else {
$(this).removeClass('hide');
}
});
}
}
[
"*".repeat(18),
...textArray
.map(words => words.join(" "))
.map(line => {
const pad = (line.length > 16)?''.padStart:''.padEnd;
const lines = [];
let restLine = line;
while(restLine.length > 16) {
const spaceIndex = restLine.lastIndexOf(" ", 16);
lines.push(pad.call(restLine.slice(0, spaceIndex), 16));
restLine = restLine.slice(spaceIndex + 1);
}
lines.push(pad.call(restLine, 16));
return lines;
})
.flat()
.map(line => "*" + line + "*"),
"*".repeat(18)
]
function formatTextArray(textArray, maxLineLength = 16) {
const formatedTextArray = [];
textArray
.forEach(words => {
const line = words.join(" ");
if(line.length > maxLineLength) {
splitLine(line)
.forEach(item => formatedTextArray.push(align(item, false)) );
} else {
formatedTextArray.push(align(line));
}
}, []);
return addBorders(formatedTextArray);
function align(line = "", isLeft = true) {
let newLine;
if(isLeft) {
newLine = line.padEnd(maxLineLength);
} else {
newLine = line.padStart(maxLineLength);
}
return newLine;
}
function splitLine(line) {
if(line.length > maxLineLength) {
const spaceIndex = line.lastIndexOf(" ", maxLineLength);
const lineStartPart = line.slice(0, spaceIndex);
const restLine = line.slice(spaceIndex + 1);
return ([lineStartPart]).concat(splitLine(restLine));
} else {
return [line]
}
}
function addBorders(formatedTextArray, symbol = "*") {
const borderedTextArray = [
symbol.repeat(maxLineLength),
...formatedTextArray,
symbol.repeat(maxLineLength)
];
return borderedTextArray.map(addHorizontalBorders);
function addHorizontalBorders(line) {
return symbol + line + symbol;
}
}
}
document.getElementById("reset").onclick = function ...
html,
body {
height: 100%;
}