legacy site deprication

This commit is contained in:
=
2026-03-27 14:30:00 +10:00
parent 2869d51a52
commit b5760c5b3f
55 changed files with 0 additions and 0 deletions

6692
old/current_site/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
{
"name": "template_pug",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack --mode production",
"serve": "webpack serve --open --mode development",
"dev": "webpack --mode development",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"chokidar": "^4.0.3",
"css-loader": "^6.8.1",
"filemanager-webpack-plugin": "^8.0.0",
"glob": "^11.0.3",
"html-webpack-plugin": "^5.5.3",
"pug": "^2.0.4",
"pug-loader": "^2.4.0",
"style-loader": "^3.3.3",
"stylus": "^0.61.0",
"stylus-loader": "^7.1.3",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
}
}

View File

@@ -0,0 +1,85 @@
block variables
-
var navbarItems = {
Home: './index.html',
Embedded: './embeded_details.html',
OpenCV: './opencv_details.html',
Photography: './photography-details.html',
Table: './table.html',
Institute: './images/institute.png',
"SVG Playground": './svg_playground.html',
"Graph": './graph.html'
};
var smallCards = [
{
header: 'Заголовок',
text: '3D printers are versatile tools used for creating prototypes, custom parts, and artistic designs. They work by layering materials.',
image: require('../images/16x10/3d-printer.jpeg'),
imageAlt: '3D Printer',
link: '#',
},
{
header: 'BLHeli ESCs',
text: 'BLHeli ESCs are electronic speed controllers designed for drones, offering smooth and precise motor control.',
image: require('../images/16x10/blheli-esc.jpeg'),
imageAlt: 'BLHeli ESC',
link: '#',
},
{
header: 'Raspberry Pi Nano',
text: 'Raspberry Pi Nano is a compact computer ideal for learning, prototyping, and IoT projects. It is highly energy-efficient.',
image: require('../images/16x10/rpi-nano.jpeg'),
imageAlt: 'Raspberry Pi Nano',
link: '#',
},
{
header: 'Smart Thermostats',
text: 'Smart thermostats help regulate home temperatures efficiently, saving energy and enhancing comfort with automation.',
image: require('../images/16x10/thermostat.jpeg'),
imageAlt: 'Smart Thermostat',
link: '#',
}
];
var galleryImages= [
{ src: require('../images/sqarucos.png'), alt: 'ESP32'},
{ src: require('../images/sqstm32.png'), alt: 'Arduino'},
{ src: require('../images/sqesp32.png'), alt: 'STM32'}
];
var locationFilters = [
{ id: 'loc_kitchen', value: 'Kitchen', label: 'Kitchen' },
{ id: 'loc_living', value: 'Living Room', label: 'Living Room' },
{ id: 'loc_balcony', value: 'Balcony', label: 'Balcony' },
{ id: 'loc_bedroom', value: 'Bedroom', label: 'Bedroom' }
];
var sensorTypeFilters = [
{ id: 'type_xiaomi', value: 'Xiaomi', label: 'Xiaomi' },
{ id: 'type_bmp220', value: 'Bmp220', label: 'Bmp220' },
{ id: 'type_scd30', value: 'Scd30(Internal)', label: 'Scd30(Internal)' },
{ id: 'type_bmp280', value: 'Bmp280', label: 'Bmp280' }
];
var sortOptions = [
{ value: '', label: '-- None --' },
{ value: 'SensorID', label: 'SensorID' },
{ value: 'Timestamp', label: 'Time' },
{ value: 'BatteryLevel', label: 'BatteryLevel' },
{ value: 'Temperature', label: 'Temperature' },
{ value: 'Humidity', label: 'Humidity' }
];
var axisOptions = [
{ id: 'x_time', value: 'Time', label: 'Time', checked: true },
{ id: 'x_battery', value: 'BatteryLevel', label: 'BatteryLevel', checked: false },
{ id: 'x_temperature', value: 'Temperature', label: 'Temperature', checked: false },
{ id: 'x_humidity', value: 'Humidity', label: 'Humidity', checked: false }
];
var valueOptions = [
{ id: 'val_temperature', value: 'AverageTemperature', label: 'Average Temperature', checked: true },
{ id: 'val_humidity', value: 'Humidity', label: 'Average Humidity', checked: false },
{ id: 'val_battery', value: 'BatteryLevel', label: 'Average BatteryLevel', checked: false }
]

View File

@@ -0,0 +1,24 @@
include mixins.pug
html
head
meta(charset="UTF-8")
block title
title Details Page
body
block navbar
+navbarMixin("")
.details
header.details__header
block header
h1 Default Header
.details__content
.details__text
block text
p Default text content
.details__gallery
block gallery
p No images available

View File

@@ -0,0 +1,112 @@
include data.pug
mixin navbarMixin(selectedItem)
.navbar
each navbarUrl,navbarName in navbarItems
if navbarName == selectedItem
a.navbar__link-wrapper(href=navbarUrl)
.navbar__item.navbar__item_selected #{navbarName}
else
a.navbar__link-wrapper(href=navbarUrl)
.navbar__item #{navbarName}
mixin infoCardsMinxin()
each cardData in smallCards
.small-card
.small-card__content
h3.small-card__header #{cardData.header}
p.small-card__text #{cardData.text}
a.small-card__link(href=cardData.link) Подробнее»
.small-card__image
img(src=cardData.image alt=cardData.imageAlt)
mixin galleryMixin()
each img in galleryImages
img.gallery__image(src=img.src alt=img.alt)
mixin filtersMixin()
details.filters
summary.filters__summary Filters
form(id='filters').filters__form
p
label(for='type') Type:
input(type='text' id='type')
p
label(for='name') Name:
input(type='text' id='name')
p
label(for='manufacturer') Manufacturer name:
input(type='text' id='manufacturer')
p
label(for='sizeFrom') Size:
| from
input(type='number' id='sizeFrom')
| to
input(type='number' id='sizeTo')
p
label(for='releaseDateFrom') Release Date:
| from
input(type='number' id='releaseDateFrom')
| to
input(type='number' id='releaseDateTo')
p
label(for='priceFrom') Release Date:
| from
input(type='number' id='priceFrom')
| to
input(type='number' id='priceTo')
input.filter-group__button--apply(type='button' id='applyFiltersButton' value="Apply Filters")
input.filter-group__button--reset(type='button' id='clearFiltersButton' value="Reset Filters")
mixin sortLevel(level)
p
select.sort-level__select(id=`sort_${level}`)
| ascending?
input(type="checkbox", id=`sort_${level}Desc`)
mixin sortingMixin()
- const sortLevels = ['1', '2', '3'];
details.sorting
summary.sorting__summary Sort
form(id='sorting')
each level in sortLevels
+sortLevel(level)
input.sort-group__button--apply(type='button' id='applySortButton' value="Apply Sort")
input.sort-group__button--reset(type='button' id='resetSortButton' value="Reset Sort")
mixin graphXOption(option)
if option.checked
input.axis-group__radio(type="radio" id=option.id name="x_axis" value=option.value checked)
else
input.axis-group__radio(type="radio" id=option.id name="x_axis" value=option.value)
label.axis-group__option-label(for=option.id) #{option.label}
br
mixin graphYOption(option)
if option.checked
input.values-group__checkbox(type="checkbox" id=option.id name="values" value=option.value checked)
else
input.values-group__checkbox(type="checkbox" id=option.id name="values" value=option.value)
label.values-group__option-label(for=option.id) #{option.label}
br
mixin graphMixin()
details.graph
summary.graph__summary Graph
form.graph__form
fieldset.graph__fieldset
.axis-group
i.axis-group__label
b X axis
br
.axis-group__options
each option in axisOptions
+graphXOption(option)
.values-group
i.values-group__label
b Values
br
.values-group__options
each option in valueOptions
+graphYOption(option)
button.values-group__button(type="submit" id="build_graph" name="build_graph") Build

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

View File

@@ -0,0 +1,4 @@
import './styles/index.styl'
import './styles/graph.styl'
import './styles/details.styl'
import './styles/table.styl'

View File

@@ -0,0 +1,43 @@
include ../components/mixins.pug
doctype html
html(lang="ru")
head
meta(charset="utf-8")
script(src="graph/d3.v7.min.js")
script(src="graph/data.js")
script(src="graph/main.js")
script(src="graph/table.js")
script(src="graph/chart.js")
body
+navbarMixin("Graph")
h3 Цена на оперативную память
svg
p Значение по оси OX
input(type="radio" value="0" name="OX" checked)
span Maker
br
input(type="radio" value="1" name="OX")
span Release Year
p Значение по оси OY
p#errorDisplay(hidden) Выберете хотя бы одно
input(type="checkbox" value="0" name="OY" checked)
span Min
br
input(type="checkbox" value="1" name="OY")
span Max
br
select#graphType
option(value="0" selected) Точечная
option(value="1") Гистограма
option(value="2") График
button#drawButton Рисовать
br
button#tableVisibilityButton Скрыть Таблицу
table#build

View File

@@ -0,0 +1,135 @@
// Входные данные:
// data - исходный массив (например, buildings)
// key - поле, по которому осуществляется группировка
function createArrGraph(data, key) {
const groupObj = d3.group(data, d => d[key]);
let arrGraph = [];
for (let entry of groupObj) {
const minMax = d3.extent(entry[1].map(d => d['price']));
arrGraph.push({ labelX: entry[0], values: minMax });
}
return arrGraph;
}
function drawGraph(data, keyX, drawMin, drawMax, graphtype) {
// значения по оси ОХ
// создаем массив для построения графика
let arrGraph = createArrGraph(data, keyX);
if (keyX == "release") {
arrGraph = d3.sort(arrGraph, (x, y) => Number(x["labelX"]) - Number(y["labelX"]));
}
const svg = d3.select("svg")
svg.selectAll('*').remove();
// создаем словарь с атрибутами области вывода графика
const attr_area = {
width: parseFloat(svg.style('width')),
height: parseFloat(svg.style('height')),
marginX: 50,
marginY: 50
}
const scaleYDomain = [ d3.min(arrGraph.map(d => d.values[drawMin? 0:1])) , d3.max(arrGraph.map(d => d.values[drawMax?1:0]))];
// создаем шкалы преобразования и выводим оси
const [scX, scY] = createAxis(svg, arrGraph, attr_area,scaleYDomain);
// рисуем график
if (drawMin && drawMax) {
createChart(svg, arrGraph, scX, scY, attr_area, "blue", 0, graphtype, 0, scaleYDomain)
createChart(svg, arrGraph, scX, scY, attr_area, "red", 1, graphtype, 0, scaleYDomain)
}
else if (drawMin) {
createChart(svg, arrGraph, scX, scY, attr_area, "blue", 0, graphtype, 1, scaleYDomain)
}
else if (drawMax) {
createChart(svg, arrGraph, scX, scY, attr_area, "red", 1, graphtype, 1, scaleYDomain)
}
}
function createAxis(svg, data, attr_area,scaleYDomain) {
// находим интервал значений, которые нужно отложить по оси OY
// максимальное и минимальное значение и максимальных высот по каждой стране
const [min, max] = scaleYDomain;
// функция интерполяции значений на оси
// по оси ОХ текстовые значения
const scaleX = d3.scaleBand()
.domain(data.map(d => d.labelX))
.range([0, attr_area.width - 2 * attr_area.marginX]);
const scaleY = d3.scaleLinear()
.domain([min * 0.85, max * 1.1])
.range([attr_area.height - 2 * attr_area.marginY, 0]);
// создание осей
const axisX = d3.axisBottom(scaleX); // горизонтальная
const axisY = d3.axisLeft(scaleY); // вертикальная
// отрисовка осей в SVG-элементе
svg.append("g")
.attr("transform", `translate(${attr_area.marginX},
${attr_area.height - attr_area.marginY})`)
.call(axisX)
.selectAll("text") // подписи на оси - наклонные
.style("text-anchor", "end")
.attr("dx", "-.8em")
.attr("dy", ".15em")
.attr("transform", d => "rotate(-45)");
svg.append("g")
.attr("transform", `translate(${attr_area.marginX}, ${attr_area.marginY})`)
.call(axisY);
return [scaleX, scaleY]
}
function createChart(svg, data, scaleX, scaleY, attr_area, color, valueIdx, graphType, horisontalScale, scaleYDomain) {
if (graphType == 1) {
svg.selectAll(".dot")
.data(data)
.enter()
.append("rect")
.attr("x", d => scaleX(d.labelX) + valueIdx * 6)
.attr("y", d => scaleY(d.values[valueIdx]))
.attr("width", 6 * (horisontalScale + 1))
.attr("height", d => scaleY(scaleYDomain[0] * 0.85) - scaleY(d.values[valueIdx]))
.attr("transform", `translate(${attr_area.marginX}, ${attr_area.marginY})`)
.style("fill", color)
}
else if (graphType == 2) {
const line = d3.line()
.x(d => scaleX(d.labelX) + scaleX.bandwidth() / 2 + valueIdx * 4)
.y(d => scaleY(d.values[valueIdx]));
svg.append('path')
.datum(data)
.attr('d', line.curve(d3.curveBasis))
.attr('stroke-width',2)
.attr('fill', 'none')
.attr("transform", `translate(${attr_area.marginX}, ${attr_area.marginY})`)
.attr('stroke', color);
}
else if (graphType == 0) {
const r = 4;
svg.selectAll(".dot")
.data(data)
.enter()
.append("circle")
.attr("r", r)
.attr("cx", d => scaleX(d.labelX) + scaleX.bandwidth() / 2 + valueIdx * 4)
.attr("cy", d => scaleY(d.values[valueIdx]))
.attr("transform", `translate(${attr_area.marginX}, ${attr_area.marginY})`)
.style("fill", color)
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,68 @@
let ram_sticks = [
{ "type": "DDR3", "name": "DDR3-1600-4GB-A1", "size": 4, "maker": "Kingston", "release": "2014-03", "price": 18, },
{ "type": "DDR3", "name": "DDR3-1600-8GB-A2", "size": 8, "maker": "Corsair", "release": "2015-06", "price": 26, },
{ "type": "DDR3", "name": "DDR3-1866-8GB-A3", "size": 8, "maker": "G.Skill", "release": "2016-02", "price": 29, },
{ "type": "DDR4", "name": "DDR4-2133-8GB-B1", "size": 8, "maker": "Crucial", "release": "2017-01", "price": 24, },
{ "type": "DDR4", "name": "DDR4-2400-8GB-B2", "size": 8, "maker": "Kingston", "release": "2017-09", "price": 27, },
{ "type": "DDR4", "name": "DDR4-2666-16GB-B3", "size": 16, "maker": "Corsair", "release": "2018-04", "price": 48, },
{ "type": "DDR4", "name": "DDR4-3000-16GB-B4", "size": 16, "maker": "G.Skill", "release": "2018-11", "price": 52, },
{ "type": "DDR4", "name": "DDR4-3200-16GB-B5", "size": 16, "maker": "HyperX", "release": "2019-03", "price": 55, },
{ "type": "DDR4", "name": "DDR4-3200-32GB-B6", "size": 32, "maker": "Crucial", "release": "2019-08", "price": 92, },
{ "type": "DDR4", "name": "DDR4-3600-32GB-B7", "size": 32, "maker": "Corsair", "release": "2020-02", "price": 99, },
{ "type": "DDR5", "name": "DDR5-4800-16GB-C1", "size": 16, "maker": "Kingston", "release": "2021-01", "price": 78, },
{ "type": "DDR5", "name": "DDR5-5200-16GB-C2", "size": 16, "maker": "Corsair", "release": "2021-06", "price": 84, },
{ "type": "DDR5", "name": "DDR5-5600-32GB-C3", "size": 32, "maker": "G.Skill", "release": "2022-02", "price": 145, },
{ "type": "DDR5", "name": "DDR5-6000-32GB-C4", "size": 32, "maker": "Crucial", "release": "2022-07", "price": 158, },
{ "type": "DDR5", "name": "DDR5-6400-32GB-C5", "size": 32, "maker": "Corsair", "release": "2023-01", "price": 172, },
{ "type": "DDR5", "name": "DDR5-6600-64GB-C6", "size": 64, "maker": "Kingston", "release": "2023-05", "price": 310, },
{ "type": "DDR5", "name": "DDR5-6800-64GB-C7", "size": 64, "maker": "G.Skill", "release": "2023-09", "price": 329, },
{ "type": "DDR5", "name": "DDR5-7200-64GB-C8", "size": 64, "maker": "Corsair", "release": "2024-02", "price": 355, },
{ "type": "DDR5", "name": "DDR5-7600-96GB-C9", "size": 96, "maker": "Crucial", "release": "2024-06", "price": 520, },
{ "type": "DDR5", "name": "DDR5-8000-96GB-C10", "size": 96, "maker": "Kingston", "release": "2024-10", "price": 560, },
{ "type": "LPDDR4", "name": "LP4-3200-8GB-D1", "size": 8, "maker": "Samsung", "release": "2019-01", "price": 34, },
{ "type": "LPDDR4", "name": "LP4-4266-8GB-D2", "size": 8, "maker": "Micron", "release": "2019-07", "price": 39, },
{ "type": "LPDDR5", "name": "LP5-5500-12GB-D3", "size": 12, "maker": "Samsung", "release": "2020-03", "price": 58, },
{ "type": "LPDDR5", "name": "LP5-6400-16GB-D4", "size": 16, "maker": "SKHynix", "release": "2021-01", "price": 74, },
{ "type": "LPDDR5X", "name": "LP5X-7500-24GB-D5", "size": 24, "maker": "Micron", "release": "2022-05", "price": 118, },
{ "type": "DDR4", "name": "DDR4-2666-8GB-E1", "size": 8, "maker": "Patriot", "release": "2018-05", "price": 25, },
{ "type": "DDR4", "name": "DDR4-3000-8GB-E2", "size": 8, "maker": "ADATA", "release": "2018-09", "price": 28, },
{ "type": "DDR4", "name": "DDR4-3200-8GB-E3", "size": 8, "maker": "TeamGroup", "release": "2019-04", "price": 30, },
{ "type": "DDR4", "name": "DDR4-3600-16GB-E4", "size": 16, "maker": "ADATA", "release": "2020-01", "price": 53, },
{ "type": "DDR4", "name": "DDR4-4000-16GB-E5", "size": 16, "maker": "Patriot", "release": "2020-06", "price": 61, },
{ "type": "DDR5", "name": "DDR5-5200-8GB-F1", "size": 8, "maker": "TeamGroup", "release": "2021-03", "price": 52, },
{ "type": "DDR5", "name": "DDR5-5600-16GB-F2", "size": 16, "maker": "ADATA", "release": "2021-10", "price": 88, },
{ "type": "DDR5", "name": "DDR5-6000-16GB-F3", "size": 16, "maker": "Patriot", "release": "2022-03", "price": 95, },
{ "type": "DDR5", "name": "DDR5-6400-32GB-F4", "size": 32, "maker": "TeamGroup", "release": "2022-09", "price": 168, },
{ "type": "DDR5", "name": "DDR5-7200-32GB-F5", "size": 32, "maker": "ADATA", "release": "2023-04", "price": 185, },
{ "type": "DDR3", "name": "DDR3-1333-4GB-G1", "size": 4, "maker": "Samsung", "release": "2013-02", "price": 15, },
{ "type": "DDR3", "name": "DDR3-1600-4GB-G2", "size": 4, "maker": "Micron", "release": "2014-08", "price": 17, },
{ "type": "DDR3", "name": "DDR3-1866-8GB-G3", "size": 8, "maker": "Samsung", "release": "2015-11", "price": 28, },
{ "type": "DDR5", "name": "DDR5-8400-128GB-H1", "size": 128, "maker": "Corsair", "release": "2025-01", "price": 890, },
{ "type": "DDR5", "name": "DDR5-8800-128GB-H2", "size": 128, "maker": "G.Skill", "release": "2025-03", "price": 940, },
{ "type": "DDR5", "name": "DDR5-9200-128GB-H3", "size": 128, "maker": "Kingston", "release": "2025-06", "price": 990, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X1", "size": 48, "maker": "Corsair", "release": "2024-01", "price": 210, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X2", "size": 48, "maker": "Kingston", "release": "2024-02", "price": 215, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X3", "size": 48, "maker": "G.Skill", "release": "2024-03", "price": 218, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X4", "size": 48, "maker": "ADATA", "release": "2024-04", "price": 222, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X5", "size": 48, "maker": "Patriot", "release": "2024-05", "price": 225, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X6", "size": 48, "maker": "TeamGroup", "release": "2024-06", "price": 228, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X7", "size": 48, "maker": "Crucial", "release": "2024-07", "price": 230, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X8", "size": 48, "maker": "Samsung", "release": "2024-08", "price": 235, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X9", "size": 48, "maker": "Micron", "release": "2024-09", "price": 238, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X10", "size": 48, "maker": "SKHynix", "release": "2024-10", "price": 240, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y1", "size": 64, "maker": "Corsair", "release": "2021-01", "price": 180, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y2", "size": 64, "maker": "Kingston", "release": "2021-02", "price": 182, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y3", "size": 64, "maker": "G.Skill", "release": "2021-03", "price": 185, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y4", "size": 64, "maker": "ADATA", "release": "2021-04", "price": 188, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y5", "size": 64, "maker": "Patriot", "release": "2021-05", "price": 190, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y6", "size": 64, "maker": "TeamGroup", "release": "2021-06", "price": 192, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y7", "size": 64, "maker": "Crucial", "release": "2021-07", "price": 195, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y8", "size": 64, "maker": "Samsung", "release": "2021-08", "price": 198, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y9", "size": 64, "maker": "Micron", "release": "2021-09", "price": 200, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y10", "size": 64, "maker": "SKHynix", "release": "2021-10", "price": 205, }
]
ram_sticks = ram_sticks.map((x) => ({
...x,
release: Number(x.release.split("-")[0]),
}))

View File

@@ -0,0 +1,50 @@
document.addEventListener("DOMContentLoaded", function () {
showTable('build', ram_sticks);
let tableIsDisplayed = true;
tableVisibilityButton.addEventListener("click", () => {
if (tableIsDisplayed) {
clearTable('build')
tableVisibilityButton.innerHTML = "Показать таблицу";
} else {
showTable('build', ram_sticks);
tableVisibilityButton.innerHTML = "Скрыть таблицу";
}
tableIsDisplayed = !tableIsDisplayed;
})
updateGraph();
drawButton.addEventListener("click", () => {
clearGraph();
updateGraph();
});
document.querySelectorAll("[name=\"OY\"]").forEach((x) => {
x.addEventListener("click", () => { d3.select("#drawButton").attr("class", getOY().length == 0 ? "error" : ""); })
})
});
function updateGraph() {
const keyX = ["maker", "release"][getOX()];
const yAxis = getOY();
d3.select("#drawButton").attr("class", yAxis.length == 0 ? "error" : "");
drawGraph(ram_sticks, keyX, yAxis.includes(0), yAxis.includes(1), getGraphType());
}
function getOX() {
return Number(document.querySelector("input[name=\"OX\"]:checked").value);
}
function getOY() {
return d3.map(document.querySelectorAll("input[name=\"OY\"]:checked"),
(x) => Number(x.value));
}
function clearGraph() {
d3.select("svg").selectAll('*').remove();
}
function getGraphType() {
return Number(graphType.value);
}

View File

@@ -0,0 +1,36 @@
// создание таблицы
const showTable = (idTable, data) => {
const table = d3.select("#" + idTable);
// создание строк таблицы (столько, сколько элементов в массиве)
const rows = table
.selectAll("tr")
.data(data)
.enter()
.append('tr')
.style("display", "");
// создание ячеек каждой строки на основе каждого элемента массива
const cells = rows
.selectAll("td")
.data(d => Object.values(d))
.enter()
.append("td")
.text(d => d);
// создание шапки таблицы
const head = table
.insert("tr", "tr")
.selectAll("th")
.data(d => Object.keys(data[0]))
.enter()
.append("th")
.text(d => d);
}
const clearTable = (idTable) => {
const table = document.getElementById(idTable);
while (table.children.length > 0) {
table.removeChild(table.children[0]);
}
}

View File

@@ -0,0 +1,51 @@
include ../components/mixins.pug
-
const infoBlockA = {
header: "Embedded Systems",
text: "Had a serval projects with different MCUs and wrote firmware for them. My main stack consists of Platformio+EspIdf or Arduino, also tried STM32 asdadas",
description: "I love embeded development beceuse of autonomity of produced devices, the redices are not dependant on any other hardware and can work autunomously",
img: require('../images/AQ_monitor.png'),
imgAlt: "ESP32"
}
const infoBlockB = {
header: "Embedded Systems",
text: "Had a serval projects with different MCUs and wrote firmware for them. My main stack consists of Platformio+EspIdf or Arduino, also tried STM32",
description: "I love embeded development device because of autonomity of produced devices, the devices are not dependant on any other hardware and can work autunomously or off the grid",
img: require('../images/remote.jpeg'),
imgAlt: "ESP32"
}
html(lang="en")
head
meta(charset="UTF-8")
title Portfolio
body
+navbarMixin("Home")
.gallery
+galleryMixin()
.main-container
.main-container__content
article.info-block
h2.info-block__header #{infoBlockA.header}
.info-block__container.info-block__container_layout-a
p.info-block__text #{infoBlockA.text}
.info-block__details
p.info-block__description #{infoBlockA.description}
a.info-block__link(href="#") More info
img.info-block__image(src=infoBlockA.img alt=infoBlockA.imgAlt)
article.info-block
h2.info-block__header #{infoBlockB.header}
.info-block__container.info-block__container_layout-b
p.info-block__text #{infoBlockB.text}
img.info-block__image(src=infoBlockB.img alt=infoBlockB.imgAlt)
.info-block__details
p.info-block__description #{infoBlockB.description}
a.info-block__link(href="./photography-details.html") More info
.sidebar
+infoCardsMinxin()

View File

@@ -0,0 +1,22 @@
extends ../components/details-template.pug
block title
title Photography Portfolio - Details
block navbar
+navbarMixin("Photography")
block header
h1.details__title Photography
p.details__description I prefer landscape photography.
block text
p.details__text-content D3100 -> SLT A58.
block gallery
.details__gallery-item
img.details__gallery-image(src=require('../images/photos/image0.png') alt="Photography 1")
.details__gallery-item
img.details__gallery-image(src=require('../images/photos/image1.png') alt="Photography 2")
.details__gallery-item
img.details__gallery-image(src=require('../images/photos/image2.png') alt="Photography 3")

View File

@@ -0,0 +1,82 @@
include ../components/mixins.pug
doctype html
html(lang="ru")
head
meta(charset="utf-8")
title Трансформация и анимация
script(src="svg_playground/d3.v7.min.js")
script(src="svg_playground/main.js")
script(src="svg_playground/image.js")
script(src="svg_playground/path.js")
body
+navbarMixin("SVG Playground")
form#setting
p.path-anim-related-inverse
| Координаты рисунка
br
label(for="cx") x:
input#cx(type="number", value="300", max="600", min="0")
label.anim-related(for="cx_finish") до:
input#cx_finish.anim-related(type="number", value="300", max="600", min="0")
br
label(for="cy") y:
input#cy(type="number", value="300", max="600", min="0")
label.anim-related(for="cy_finish") до:
input.anim-related#cy_finish(type="number", value="300", max="600", min="0")
p.path-anim-related
| Пути перемещения
br
select#pathSelect
option(value="0") Буквой "Г"
option(value="1") По кругу
option(value="2") Спиралью
p
| Масштаб
br
label(for="sx") по x:
input#sx(type="number", value="1", max="100", min="-100")
label.anim-related(for="sx_finish") до:
input#sx_finish.anim-related(type="number", value="1.5", max="100", min="-100")
br
label(for="sy") по y:
input#sy(type="number", value="1", max="100", min="-100")
label.anim-related(for="sy_finish") до:
input#sy_finish.anim-related(type="number", value="1.5", max="100", min="-100")
p
| Поворот
br
label(for="r") x:
input#r(type="number", value="0", max="360", min="-360")
label.anim-related(for="r_finish") до:
input#r_finish.anim-related(type="number", value="360", max="360", min="-360")
p.anim-related
| Время анамации (мс)
br
label(for="duration") x:
input#duration(type="number", value="2000", max="10000", min="1")
p
input#applyButton.anim-related-inverse(type="button", value="Нарисовать")
input#clearButton(type="button", value="Отчистить")
p
| Включить Анимацию?
input#enableAnimCheckbox(type="checkbox")
br
label.anim-related(for="animAlongPathCheckbox") Перемещение вдоль пути?
input#animAlongPathCheckbox.anim-related(type="checkbox")
select#animTypeSelect.anim-related
option(value="0") linear
option(value="1") elastic
option(value="2") bounce
br
input#startAnimButton.anim-related(type="button", value="Анимировать")
svg

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,33 @@
// создаем изображение смайлик
// рисуем его относительно точки (0, 0)
function drawSmile(svg) {
let smile = svg.append("g")
.style("stroke", "brown")
.style("stroke-width", 0)
.style("fill", "brown");
for (let t = 0; t <= Math.PI * 6; t += .8) {
let cords = {
x: 50 / 3 * (1 - (t / (Math.PI * 6))) * -Math.sin(t),
y: 50 / 3 * (1 - (t / (Math.PI * 6))) * Math.cos(t)
}
smile.append("circle")
.attr("cx", cords["x"])
.attr("cy", cords["y"])
.attr("r", (1 - (t / (Math.PI * 6))))
.style("fill", "red");
}
for (let t = .4; t <= Math.PI * 6; t += .8) {
let cords = {
x: 50 / 3 * (1 - (t / (Math.PI * 6))) * -Math.sin(t),
y: 50 / 3 * (1 - (t / (Math.PI * 6))) *Math.cos(t)
}
smile.append("circle")
.attr("cx", cords["x"])
.attr("cy", cords["y"])
.attr("r", (1 - (t / (Math.PI * 6))))
.style("fill", "green");
}
return smile
}

View File

@@ -0,0 +1,93 @@
document.addEventListener("DOMContentLoaded", function () {
const width = 600;
const height = 600;
const svg = d3.select("svg")
.attr("width", width)
.attr("height", height);
// let pict1 = drawSmile(svg);
// pict1.attr("transform", `translate(400, 400) scale(1.5, 1.5) rotate(180)`);
// let pict = drawSmile(svg);
// pict.attr("transform", "translate(200, 200)");
setting.applyButton.addEventListener("click", () => {
draw(setting);
})
setting.clearButton.addEventListener("click", () => {
svg.selectAll('*').remove()
})
updateAnimationControllsDisplay();
enableAnimCheckbox.addEventListener("change", updateAnimationControllsDisplay);
animAlongPathCheckbox.addEventListener("change", updateAnimationControllsDisplay);
startAnimButton.addEventListener("click", () => {
animRouter(setting)
})
})
const updateAnimationControllsDisplay = () => {
let isChecked = enableAnimCheckbox.checked;
let isPathAnim = animAlongPathCheckbox.checked;
// console.log(isChecked);
document.querySelectorAll(".anim-related").forEach((elem) => { elem.hidden = !isChecked });
document.querySelectorAll(".anim-related-inverse").forEach((elem) => { elem.hidden = isChecked });
document.querySelectorAll(".path-anim-related").forEach((elem) => { elem.hidden = !(isPathAnim && isChecked) });
document.querySelectorAll(".path-anim-related-inverse").forEach((elem) => { elem.hidden = (isPathAnim && isChecked) });
}
const draw = (dataForm) => {
const svg = d3.select("svg")
let pict = drawSmile(svg);
pict.attr("transform", `
translate(${dataForm.cx.value},
${dataForm.cy.value})
scale(${dataForm.sx.value},
${dataForm.sy.value})
rotate(${dataForm.r.value})`);
}
const animRouter = (dataForm) => {
if (dataForm.animAlongPathCheckbox.checked) {
let path = drawPath(Number(dataForm.pathSelect.value));
const svg = d3.select("svg")
let pict = drawSmile(svg);
const parameters = {
sx:[Number(dataForm.sx.value),Number(dataForm.sx_finish.value)],
sy:[Number(dataForm.sy.value),Number(dataForm.sy_finish.value)],
r:[Number(dataForm.r.value),Number(dataForm.r_finish.value)],
};
pict.transition()
.ease([d3.easeLinear, d3.easeElastic, d3.easeBounce][Number(animTypeSelect.value)])
.duration(Number(duration.value))
.attrTween('transform', translateAlong(path.node(),parameters));
}
else {
runAnimation(dataForm)
}
}
const runAnimation = (dataForm) => {
const svg = d3.select("svg")
let pict = drawSmile(svg);
pict.attr("transform", `
translate(${dataForm.cx.value},
${dataForm.cy.value})
scale(${dataForm.sx.value},
${dataForm.sy.value})
rotate(${dataForm.r.value})`)
.transition()
.duration(Number(duration.value))
.ease([d3.easeLinear, d3.easeElastic, d3.easeBounce][Number(animTypeSelect.value)])
.attr("transform", `
translate(${dataForm.cx_finish.value},
${dataForm.cy_finish.value})
scale(${dataForm.sx_finish.value},
${dataForm.sy_finish.value})
rotate(${dataForm.r_finish.value})`);
}

View File

@@ -0,0 +1,99 @@
/* массив точек пути будет иметь следующий вид:
[
{x: координата, y: координата},
{x: координата, y: координата},
...
]
*/
// создаем массив точек, расположенных буквой "Г"
function createPathG() {
const svg = d3.select("svg")
const width = svg.attr("width")
const height = svg.attr("height")
let data = [];
const padding = 100;
//начальное положение рисунка
let posX = padding;
let posY = height - padding;
const h = 5;
// координаты y - уменьшаются, x - постоянны
while (posY > padding) {
data.push({ x: posX, y: posY });
posY -= h;
}
// координаты y - постоянны, x - увеличиваются
while (posX < width - padding) {
data.push({ x: posX, y: posY });
posX += h;
}
return data
}
// создаем массив точек, расположенных по кругу
function createPathCircle() {
const svg = d3.select("svg")
const width = svg.attr("width")
const height = svg.attr("height")
let data = [];
// используем параметрическую форму описания круга
// центр расположен в центре svg-элемента, а радиус равен трети высоты/ширины
for (let t = 0; t <= Math.PI * 2; t += 0.1) {
data.push(
{
x: width / 2 + width / 3 * Math.sin(t),
y: height / 2 + height / 3 * Math.cos(t)
}
);
}
return data
}
function createPathSpiral() {
const svg = d3.select("svg")
const width = svg.attr("width")
const height = svg.attr("height")
let data = [];
// используем параметрическую форму описания круга
// центр расположен в центре svg-элемента, а радиус равен трети высоты/ширины
for (let t = 0; t <= Math.PI * 6; t += 0.1) {
data.push(
{
x: width / 2 + width / 3 * (1 - (t / (Math.PI * 6))) * -Math.sin(t),
y: height / 2 + height / 3 * (1 - (t / (Math.PI * 6))) * Math.cos(t)
}
);
}
return data
}
const drawPath = (typePath) => {
// создаем массив точек
const dataPoints = [createPathG, createPathCircle, createPathSpiral][Number(typePath)]()
const line = d3.line()
.x((d) => d.x)
.y((d) => d.y);
const svg = d3.select("svg")
// создаем путь на основе массива точек
const path = svg.append('path')
.attr('d', line(dataPoints))
.attr('stroke', 'black')
.attr('fill', 'none');
return path;
}
function translateAlong(path, params) {
const length = path.getTotalLength();
return function () {
return function (t) {
const { x, y } = path.getPointAtLength(t * length);
return `
translate(${x},${y})
scale(${params.sx[0] +(params.sx[1] - params.sx[0])*t},
${params.sy[0] +(params.sy[1] - params.sy[0])*t})
rotate(${params.r[0] +(params.r[1] - params.r[0])*t})
`;
}
}
}

View File

@@ -0,0 +1,19 @@
include ../components/mixins.pug
head
title table
script(src='./table/data.js')
script(src='./table/filter.js')
script(src='./table/main.js')
script(src='./table/sort.js')
script(src='./table/table.js')
body
+navbarMixin("Table")
.table-controls
+filtersMixin()
+sortingMixin()
+graphMixin()
table(id='list')

View File

@@ -0,0 +1,68 @@
let ram_sticks = [
{ "type": "DDR3", "name": "DDR3-1600-4GB-A1", "size": 4, "maker": "Kingston", "release": "2014-03", "price": 18, },
{ "type": "DDR3", "name": "DDR3-1600-8GB-A2", "size": 8, "maker": "Corsair", "release": "2015-06", "price": 26, },
{ "type": "DDR3", "name": "DDR3-1866-8GB-A3", "size": 8, "maker": "G.Skill", "release": "2016-02", "price": 29, },
{ "type": "DDR4", "name": "DDR4-2133-8GB-B1", "size": 8, "maker": "Crucial", "release": "2017-01", "price": 24, },
{ "type": "DDR4", "name": "DDR4-2400-8GB-B2", "size": 8, "maker": "Kingston", "release": "2017-09", "price": 27, },
{ "type": "DDR4", "name": "DDR4-2666-16GB-B3", "size": 16, "maker": "Corsair", "release": "2018-04", "price": 48, },
{ "type": "DDR4", "name": "DDR4-3000-16GB-B4", "size": 16, "maker": "G.Skill", "release": "2018-11", "price": 52, },
{ "type": "DDR4", "name": "DDR4-3200-16GB-B5", "size": 16, "maker": "HyperX", "release": "2019-03", "price": 55, },
{ "type": "DDR4", "name": "DDR4-3200-32GB-B6", "size": 32, "maker": "Crucial", "release": "2019-08", "price": 92, },
{ "type": "DDR4", "name": "DDR4-3600-32GB-B7", "size": 32, "maker": "Corsair", "release": "2020-02", "price": 99, },
{ "type": "DDR5", "name": "DDR5-4800-16GB-C1", "size": 16, "maker": "Kingston", "release": "2021-01", "price": 78, },
{ "type": "DDR5", "name": "DDR5-5200-16GB-C2", "size": 16, "maker": "Corsair", "release": "2021-06", "price": 84, },
{ "type": "DDR5", "name": "DDR5-5600-32GB-C3", "size": 32, "maker": "G.Skill", "release": "2022-02", "price": 145, },
{ "type": "DDR5", "name": "DDR5-6000-32GB-C4", "size": 32, "maker": "Crucial", "release": "2022-07", "price": 158, },
{ "type": "DDR5", "name": "DDR5-6400-32GB-C5", "size": 32, "maker": "Corsair", "release": "2023-01", "price": 172, },
{ "type": "DDR5", "name": "DDR5-6600-64GB-C6", "size": 64, "maker": "Kingston", "release": "2023-05", "price": 310, },
{ "type": "DDR5", "name": "DDR5-6800-64GB-C7", "size": 64, "maker": "G.Skill", "release": "2023-09", "price": 329, },
{ "type": "DDR5", "name": "DDR5-7200-64GB-C8", "size": 64, "maker": "Corsair", "release": "2024-02", "price": 355, },
{ "type": "DDR5", "name": "DDR5-7600-96GB-C9", "size": 96, "maker": "Crucial", "release": "2024-06", "price": 520, },
{ "type": "DDR5", "name": "DDR5-8000-96GB-C10", "size": 96, "maker": "Kingston", "release": "2024-10", "price": 560, },
{ "type": "LPDDR4", "name": "LP4-3200-8GB-D1", "size": 8, "maker": "Samsung", "release": "2019-01", "price": 34, },
{ "type": "LPDDR4", "name": "LP4-4266-8GB-D2", "size": 8, "maker": "Micron", "release": "2019-07", "price": 39, },
{ "type": "LPDDR5", "name": "LP5-5500-12GB-D3", "size": 12, "maker": "Samsung", "release": "2020-03", "price": 58, },
{ "type": "LPDDR5", "name": "LP5-6400-16GB-D4", "size": 16, "maker": "SKHynix", "release": "2021-01", "price": 74, },
{ "type": "LPDDR5X", "name": "LP5X-7500-24GB-D5", "size": 24, "maker": "Micron", "release": "2022-05", "price": 118, },
{ "type": "DDR4", "name": "DDR4-2666-8GB-E1", "size": 8, "maker": "Patriot", "release": "2018-05", "price": 25, },
{ "type": "DDR4", "name": "DDR4-3000-8GB-E2", "size": 8, "maker": "ADATA", "release": "2018-09", "price": 28, },
{ "type": "DDR4", "name": "DDR4-3200-8GB-E3", "size": 8, "maker": "TeamGroup", "release": "2019-04", "price": 30, },
{ "type": "DDR4", "name": "DDR4-3600-16GB-E4", "size": 16, "maker": "ADATA", "release": "2020-01", "price": 53, },
{ "type": "DDR4", "name": "DDR4-4000-16GB-E5", "size": 16, "maker": "Patriot", "release": "2020-06", "price": 61, },
{ "type": "DDR5", "name": "DDR5-5200-8GB-F1", "size": 8, "maker": "TeamGroup", "release": "2021-03", "price": 52, },
{ "type": "DDR5", "name": "DDR5-5600-16GB-F2", "size": 16, "maker": "ADATA", "release": "2021-10", "price": 88, },
{ "type": "DDR5", "name": "DDR5-6000-16GB-F3", "size": 16, "maker": "Patriot", "release": "2022-03", "price": 95, },
{ "type": "DDR5", "name": "DDR5-6400-32GB-F4", "size": 32, "maker": "TeamGroup", "release": "2022-09", "price": 168, },
{ "type": "DDR5", "name": "DDR5-7200-32GB-F5", "size": 32, "maker": "ADATA", "release": "2023-04", "price": 185, },
{ "type": "DDR3", "name": "DDR3-1333-4GB-G1", "size": 4, "maker": "Samsung", "release": "2013-02", "price": 15, },
{ "type": "DDR3", "name": "DDR3-1600-4GB-G2", "size": 4, "maker": "Micron", "release": "2014-08", "price": 17, },
{ "type": "DDR3", "name": "DDR3-1866-8GB-G3", "size": 8, "maker": "Samsung", "release": "2015-11", "price": 28, },
{ "type": "DDR5", "name": "DDR5-8400-128GB-H1", "size": 128, "maker": "Corsair", "release": "2025-01", "price": 890, },
{ "type": "DDR5", "name": "DDR5-8800-128GB-H2", "size": 128, "maker": "G.Skill", "release": "2025-03", "price": 940, },
{ "type": "DDR5", "name": "DDR5-9200-128GB-H3", "size": 128, "maker": "Kingston", "release": "2025-06", "price": 990, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X1", "size": 48, "maker": "Corsair", "release": "2024-01", "price": 210, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X2", "size": 48, "maker": "Kingston", "release": "2024-02", "price": 215, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X3", "size": 48, "maker": "G.Skill", "release": "2024-03", "price": 218, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X4", "size": 48, "maker": "ADATA", "release": "2024-04", "price": 222, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X5", "size": 48, "maker": "Patriot", "release": "2024-05", "price": 225, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X6", "size": 48, "maker": "TeamGroup", "release": "2024-06", "price": 228, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X7", "size": 48, "maker": "Crucial", "release": "2024-07", "price": 230, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X8", "size": 48, "maker": "Samsung", "release": "2024-08", "price": 235, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X9", "size": 48, "maker": "Micron", "release": "2024-09", "price": 238, },
{ "type": "DDR5", "name": "DDR5-6000-48GB-X10", "size": 48, "maker": "SKHynix", "release": "2024-10", "price": 240, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y1", "size": 64, "maker": "Corsair", "release": "2021-01", "price": 180, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y2", "size": 64, "maker": "Kingston", "release": "2021-02", "price": 182, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y3", "size": 64, "maker": "G.Skill", "release": "2021-03", "price": 185, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y4", "size": 64, "maker": "ADATA", "release": "2021-04", "price": 188, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y5", "size": 64, "maker": "Patriot", "release": "2021-05", "price": 190, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y6", "size": 64, "maker": "TeamGroup", "release": "2021-06", "price": 192, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y7", "size": 64, "maker": "Crucial", "release": "2021-07", "price": 195, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y8", "size": 64, "maker": "Samsung", "release": "2021-08", "price": 198, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y9", "size": 64, "maker": "Micron", "release": "2021-09", "price": 200, },
{ "type": "DDR4", "name": "DDR4-3200-64GB-Y10", "size": 64, "maker": "SKHynix", "release": "2021-10", "price": 205, }
]
ram_sticks = ram_sticks.map((x) => ({
...x,
release: Number(x.release.split("-")[0]),
}))

View File

@@ -0,0 +1,92 @@
const correspond = {
"type": "type",
"name": "name",
"maker": "manufacturer",
"size": ["sizeFrom", "sizeTo"],
"release": ["releaseDateFrom", "releaseDateTo"],
"price": ["priceFrom", "priceTo"]
}
/* Структура возвращаемого ассоциативного массива:
{
input_id: input_value,
...
}
*/
const dataFilter = (dataForm) => {
let dictFilter = {};
// перебираем все элементы формы с фильтрами
for (const item of dataForm.elements) {
// получаем значение элемента
let valInput = item.value;
// если поле типа text - приводим его значение к нижнему регистру
if (item.type === "text") {
valInput = valInput.toLowerCase();
}
if (item.type === "number") {
if (valInput === "") {
if (item.id.includes("From")) {
valInput = -Infinity;
}
else {
valInput = Infinity;
}
}
else {
valInput = Number(valInput);
}
}
// формируем очередной элемент ассоциативного массива
dictFilter[item.id] = valInput;
}
return dictFilter;
}
// фильтрация таблицы
const filterTable = (data, idTable, dataForm) => {
// получаем данные из полей формы
const datafilter = dataFilter(dataForm);
// выбираем данные соответствующие фильтру и формируем таблицу из них
let tableFilter = data.filter(item => {
/* в этой переменной будут "накапливаться" результаты сравнения данных
с параметрами фильтра */
let result = true;
// строка соответствует фильтру, если сравнение всех значения из input
// со значением ячейки очередной строки - истина
Object.entries(item).map(([key, val]) => {
// текстовые поля проверяем на вхождение
if (typeof val == 'string') {
result &&= val.toLowerCase().includes(datafilter[correspond[key]])
}
// САМОСТОЯТЕЛЬНО проверить числовые поля на принадлежность интервалу
if (typeof val == 'number') {
result &&= datafilter[correspond[key][0]] <= Number(val) && datafilter[correspond[key][1]] >= Number(val)
}
// console.log(result, key, )
});
return result;
});
// САМОСТОЯТЕЛЬНО вызвать функцию, которая удаляет все строки таблицы с id=idTable
clearTable(idTable);
// показать на странице таблицу с отфильтрованными строками
createTable(tableFilter, idTable);
}
const clearFilters = (form) => {
form.querySelectorAll(`& input[type="text"],& input[type="number"]`).forEach((elem) => elem.value = null)
}

View File

@@ -0,0 +1,122 @@
document.addEventListener("DOMContentLoaded", function () {
doInit()
})
function doInit() {
createTable(ram_sticks, 'list');
const clearFiltersButton = document.getElementById("clearFiltersButton");
clearFiltersButton.addEventListener("click", (event) => {
clearFilters(filters);
createTable(ram_sticks, 'list');
sortTable('list', sorting)
})
const applyFiltersButton = document.getElementById("applyFiltersButton");
applyFiltersButton.addEventListener("click", (event) => {
filterTable(ram_sticks, 'list', filters)
sortTable('list', sorting)
})
setSortSelects(ram_sticks[0], sorting)
let i = 0;
for (const elem of sorting.querySelectorAll(`& select`)) {
const counter = i;
elem.addEventListener("change", () => {
updateOptions(counter, sorting)
})
i+=1;
}
sorting.applySortButton.addEventListener("click", () => {
clearTable('list');
filterTable(ram_sticks, 'list', filters)
sortTable('list', sorting)
});
sorting.resetSortButton.addEventListener("click", () => {
resetSort(sorting);
clearTable('list');
filterTable(ram_sticks, 'list', filters)
});
}
const createOption = (str, val) => {
let item = document.createElement('option');
item.text = str;
item.value = val;
return item;
}
const resetSortSelect = (sortSelect) => {
sortSelect.querySelectorAll(`& option`).forEach((elem) => {
elem.parentElement.removeChild(elem)
})
}
const all_fields = Object.keys(ram_sticks[0]);
const setSortSelect = (arr, sortSelect) => {
// создаем OPTION Нет и добавляем ее в SELECT
sortSelect.append(createOption('none', 0));
// перебираем массив со значениями опций
arr.forEach((item, index) => {
sortSelect.append(createOption(item, all_fields.indexOf(item) + 1));
});
}
const updateOptions = (current_index, sort_form) => {
const elem_collection = sort_form.querySelectorAll(`& select`);
let used_options_list = []
let i = 0;
for (let elem_ of elem_collection) {
if (i++ < current_index) {
used_options_list.push(all_fields[elem_.value-1])
}
}
if (current_index >= elem_collection.length) {
return;
}
const elem = elem_collection[current_index]
const available_options = all_fields.filter((x) => !used_options_list.includes(x));
elem.disabled = available_options.length == 0;
if(current_index>0){
elem.disabled |= elem_collection[current_index-1].value==0;
}
if(elem.disabled){
elem.value = 0;
}
save_val = 0;
if (!used_options_list.includes(all_fields[elem.value - 1])) {
save_val = elem.value;
}
resetSortSelect(elem)
setSortSelect(available_options, elem)
elem.value = save_val;
updateOptions(current_index + 1, sort_form)
}
// формируем поля со списком для многоуровневой сортировки
const setSortSelects = (data, dataForm) => {
const head = Object.keys(data);
const allSelect = dataForm.getElementsByTagName('select');
for (const item of dataForm.elements) {
setSortSelect(head, item);
}
let skipped = false
for (const elem of allSelect) {
if (!skipped) {
skipped = true;
continue;
}
elem.disabled = true;
}
}
const resetSort = (form) => {
form.querySelectorAll(`& select`).forEach((curSelect, index) => { if (index != 0) { curSelect.disabled = true } curSelect.value = 0 })
}

View File

@@ -0,0 +1,87 @@
/*формируем массив для сортировки по двум уровням вида
[
{column: номер столбца, по которому осуществляется сортировка,
direction: порядок сортировки (true по убыванию, false по возрастанию)
},
...
]
*/
const createSortArr = (data) => {
let sortArr = [];
const sortSelects = data.getElementsByTagName('select');
for (const item of sortSelects) {
// получаем номер выбранной опции
const keySort = item.value;
// в случае, если выбрана опция Нет, заканчиваем формировать массив
if (keySort == 0) {
break;
}
// получаем порядок сортировки очередного уровня
// имя флажка сформировано как имя поля SELECT и слова Desc
const desc = document.getElementById(item.id + 'Desc').checked;
// очередной элемент массива - по какому столбцу и в каком порядке сортировать
sortArr.push(
{
column: keySort - 1,
direction: desc
}
);
}
return sortArr;
};
const numberColumns = [2, 4, 5]
const sortTable = (idTable, formData) => {
// формируем управляющий массив для сортировки
const sortArr = createSortArr(formData);
// сортировать таблицу не нужно, во всех полях выбрана опция Нет
if (sortArr.length === 0) {
// clearTable(idTable)
return false;
}
//находим нужную таблицу
let table = document.getElementById(idTable);
// преобразуем строки таблицы в массив
let rowData = Array.from(table.rows);
// удаляем элемент с заголовками таблицы
const headerRow = rowData.shift();
//сортируем данные по всем уровням сортировки
rowData.sort((first, second) => {
for (let { column, direction } of sortArr) {
const firstCell = first.cells[column].innerHTML;
const secondCell = second.cells[column].innerHTML;
// используем localeCompare для корректного сравнения
let comparison = null;
if (numberColumns.includes(column)) {
comparison = Number(firstCell) - Number(secondCell);
}
else {
comparison = firstCell.localeCompare(secondCell);
}
// учитываем направление сортировки
if (comparison !== 0) {
return (direction ? -comparison : comparison);
}
}
return 0;
});
clearTable(idTable)
//выводим отсортированную таблицу на страницу
let tbody = document.createElement('tbody');
rowData.forEach(item => {
tbody.append(item);
});
table.append(tbody);
return true;
}

View File

@@ -0,0 +1,51 @@
const createTable = (data, idTable) => {
const table = document.getElementById(idTable);
if (data.length == 0) {
return;
}
const header = Object.keys(data[0]);
/* создание шапки таблицы */
if (!table.firstElementChild) {
const headerRow = createHeaderRow(header);
table.append(headerRow);
}
/* создание тела таблицы */
const bodyRows = createBodyRows(data);
table.append(bodyRows);
};
const clearTable = (idTable) => {
const table = document.getElementById(idTable);
if (table.children.length > 1) {
table.removeChild(table.children[1]);
}
}
const createHeaderRow = (headers) => {
const tr = document.createElement('tr');
headers.forEach(header => {
const th = document.createElement('th');
th.innerHTML = header.slice(0,1).toUpperCase()+header.slice(1);
tr.append(th);
});
const thead = document.createElement('thead')
thead.appendChild(tr)
return thead;
};
const createBodyRows = (rows) => {
const body = document.createElement('tbody');
rows.forEach(row => {
const rowElement = document.createElement('tr');
for (let key in row) {
const td = document.createElement('td');
td.innerHTML = row[key];
rowElement.appendChild(td);
}
body.appendChild(rowElement);
})
return body;
}

View File

@@ -0,0 +1,58 @@
.details
margin 0 auto
padding 20px
.details__header
margin-bottom 20px
text-align center
.details__title
margin-bottom 5px
.details__description
margin auto
.details__content
display flex
gap 40px
align-items flex-start
.details__text
flex 1
text-align justify
.details__text-content
margin auto 30px
.details__gallery
display flex
flex-direction column
gap 20px
margin auto
.details__gallery-item
overflow hidden
border-radius 8px
box-shadow 0 4px 12px rgba(0, 0, 0, 0.1)
transition transform 0.3s ease, box-shadow 0.3s ease
&:hover
transform translateY(-5px)
box-shadow 0 8px 20px rgba(0, 0, 0, 0.15)
.details__gallery-image
width 100%
height 250px
object-fit cover
display block
@media screen and (max-width: 700px)
.details__content
flex-direction column
.details__gallery
order -1 // Move gallery above text
.details__gallery-image
height 300px

View File

@@ -0,0 +1,16 @@
svg
width: 800px
height: 400px
text
font: 8px Verdana
path,
line
fill: none
.error
color: red
background-color: black
font-weight: bolder
width: min-content

View File

@@ -0,0 +1,166 @@
item_h=3em;
double-border()
border-top double thick silver
border-bottom double thick silver
flex-center()
display flex
align-items center
justify-content center
text-center-bold()
text-align center
font-weight bold
display block
grid-responsive(columns)
display grid
grid-template-columns columns
grid-template-rows 1fr
.navbar
double-border()
font-size 0
grid-responsive(repeat(8, min-content))
justify-items start
&__link-wrapper
color black
text-decoration none
&__item
display inline-block
width max-content
height item_h
line-height item_h
text-align center
vertical-align middle
padding 0 10px
margin @padding
overflow hidden
text-overflow ellipsis
font-size medium
&_selected
color green
font-weight bold
border-left double thin silver
border-right double thin silver
.gallery
display flex
flex-direction row
width 90%
margin auto
&__image
margin auto
width 100%
border thin solid black
&:nth-child(2n+1)
margin-top 10px
.main-container
grid-responsive(3fr 1fr)
.info-block
border solid thin black
padding 2vw
margin 1vw 0
&__header
text-center-bold()
&__container
&_layout-a
grid-responsive(3fr 3fr 2fr)
&_layout-b
grid-responsive(4fr 7fr 4fr)
& > *
margin 2vw
&__text, &__description
text-align justify
&__image
margin auto
width 100%
&__link
color inherit
.sidebar
border-left thin solid black
margin 30px 0 0 50px
.small-card
margin 20px 10px 0
grid-responsive(1fr 1fr)
&__content
text-align justify
&__header
text-center-bold()
text-align right
&__link
display block
text-align right
color inherit
&__image
& img
width 100%
margin-left:10px
@media screen and (max-width: 1000px)
.small-card
display flex
flex-direction column
.sidebar
margin 0
width:100%
@media screen and (max-width: 800px)
.navbar
grid-responsive(1fr 1fr)
grid-template-rows 1fr 1fr 1fr
justify-items center
&__item
&_selected
border-bottom double thick silver
border-left none
border-right none
.gallery
display inline-flex
flex-direction column
width 100%
&__image
width 100%
height 100%
&:nth-child(2n+1)
margin-top 0px
.main-container
display flex
flex-direction column
.info-block
&__container
&_layout-a, &_layout-b
display flex
flex-direction column

View File

@@ -0,0 +1,6 @@
.table, .table-content *, .table-content
border: 1px solid black;
border-collapse: collapse;
.table-content__table-row:nth-child(2n)
background: #F0FFF0;

View File

@@ -0,0 +1,82 @@
const HtmlWebpackPlugin = require("html-webpack-plugin");
const FileManagerPlugin = require("filemanager-webpack-plugin");
const path = require("path");
const fs = require("fs");
const pagesDir = path.join(__dirname, "src", "pages");
const pages = fs.readdirSync(pagesDir).filter(file => file.endsWith(".pug"));
module.exports = {
output: {
path: path.join(__dirname, "dist"),
filename: "index.[contenthash].js",
assetModuleFilename: path.join("images", "[name].[contenthash][ext]"),
},
entry: path.join(__dirname, "src", "index.js"),
module: {
rules: [
{
test: /\.pug$/,
loader: "pug-loader",
},
{
test: /\.(png|jpg|jpeg|gif)$/i,
type: "asset/resource",
},
{
test: /\.svg$/,
type: "asset/resource",
generator: {
filename: path.join("icons", "[name].[contenthash][ext]"),
},
},
{
test: /\.styl$/,
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
},
{
loader: "stylus-loader",
},
],
},
],
},
plugins: [
...pages.map(
(page) =>
new HtmlWebpackPlugin({
template: path.join(pagesDir, page),
filename: page.replace(".pug", ".html"),
})
),
new FileManagerPlugin({
events: {
onStart: {
delete: ["dist"],
},
onEnd: {
copy: [
{
source: path.join(__dirname, "src", "pages", "table", "*.js"),
destination: path.join(__dirname, "dist", "table"),
},
],
},
},
}),
],
devServer: {
watchFiles: path.join(__dirname, "src"),
port: 9000,
static: {
directory: path.join(__dirname, "src", "pages"),
publicPath: "/",
watch: true,
},
},
};