CATALOG TOTAL REBUILD + javascript masturbating + resolved #3

This commit is contained in:
Arsen Mirzaev Tatyano-Muradovich 2024-10-21 19:39:40 +03:00
parent 16be453b07
commit ac7694f716
44 changed files with 1742 additions and 996 deletions

View File

@ -16,6 +16,8 @@ use mirzaev\arangodb\document;
* Controller of account
*
* @package mirzaev\arming_bot\controllers
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class account extends core

View File

@ -6,6 +6,7 @@ namespace mirzaev\arming_bot\controllers;
// Files of the project
use mirzaev\arming_bot\controllers\core,
mirzaev\arming_bot\models\enumerations\language,
mirzaev\arming_bot\models\entry,
mirzaev\arming_bot\models\category,
mirzaev\arming_bot\models\product,
@ -18,6 +19,8 @@ use ArangoDBClient\Document as _document;
* Controller of catalog
*
* @package mirzaev\arming_bot\controllers
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class catalog extends core
@ -57,9 +60,10 @@ final class catalog extends core
// Search for categories that are descendants of $category
$entries = entry::search(
document: $category,
amount: 30,
amount: 50,
errors: $this->errors['catalog']
);
/* var_dump($entries); die; */
// Initialize buffers of entries (in singular, by parameter from ArangoDB)
$category = $product = [];
@ -72,10 +76,12 @@ final class catalog extends core
}
// Write to the buffer of global variables of view templater
$this->view->categories = $category;
$this->view->categories = $category ?? null;
// Write to the buffer of global variables of view templater
$this->view->products = $product;
$this->view->products = $product ?? null;
/* var_dump($this->view->products); die; */
// Delete buffers
unset($category, $product);
@ -84,16 +90,15 @@ final class catalog extends core
// Not received identifie of the category
// Search for root ascendants categories
$this->view->categories = entry::ascendants(descendant: new category, errors: $this->errors['catalog']);
$this->view->categories = entry::ascendants(descendant: new category, errors: $this->errors['catalog']) ?? null;
}
// Validating
if (!empty($parameters['product']) && preg_match('/[\d]+/', $parameters['product'], $matches)) $product = (int) $matches[0];
if (isset($product)) {
// Received and validated identifier of the product
// Search for product and write to the buffer of global variables of view templater
// Search for the product data and write to the buffer of global variables of view templater
$this->view->product = product::read(
filter: "d.identifier == @identifier && d.deleted != true && d.hidden != true",
sort: 'd.created DESC',
@ -105,18 +110,13 @@ final class catalog extends core
)[0]?->getAll() ?? null;
}
// Validating
if (!empty($parameters['text']) && preg_match('/[\w\s]+/u', $parameters['text'], $matches)) $text = $matches[0];
if (isset($text)) {
// Received and validated text for search
// Intialize buffer of query parameters
// Intializing buffer of query parameters
$_parameters = [];
// Initialize buffer of filters query (AQL)
// Initializing buffer of filters query (AQL)
$_filters = 'd.deleted != true && d.hidden != true';
// Search among products in the $category
if (isset($this->view->products) && count($this->view->products) > 0) {
// Amount of rendered products is more than 0
@ -125,44 +125,181 @@ final class catalog extends core
}
// Validating
if (!empty($parameters['brand']) && preg_match('/[\w]+/', $parameters['brand'], $matches)) $brand = $matches[0];
if (!empty($parameters['brand']) && preg_match('/[\w\s]+/u', urldecode($parameters['brand']), $matches)) $brand = $matches[0];
if (isset($brand)) {
// Received and validated filter by brand
// Write to the buffer of filters query (AQL)
// Writing to the account buffer
$this->account?->write(
[
'catalog' => [
'filters' => [
'brand' => $brand
]
]
]
);
// Writing to the session buffer
$this->session?->write(
[
'catalog' => [
'filters' => [
'brand' => $brand
]
]
]
);
// Writing to the buffer of filters query (AQL)
$_filters .= ' && d.brand.@language == @brand';
// Write to the buffer of query parameters
// Writing to the buffer of query parameters
$_parameters['brand'] = $brand;
} else {
// Not received or not validated filter by brand
// Writing to the account buffer
$this->account?->write(
[
'catalog' => [
'filters' => [
'brand' => null
]
]
]
);
// Writing to the session buffer
$this->session?->write(
[
'catalog' => [
'filters' => [
'brand' => null
]
]
]
);
}
// Initialize buffer of filters query (AQL)
$_sort = 'd.position ASC, d.name ASC, d.created DESC';
// Validating
if (!empty($parameters['sort']) && preg_match('/[\w]+/', $parameters['sort'], $matches)) $sort = $matches[0];
if (!empty($parameters['sort']) && preg_match('/[\w\s]+/u', $parameters['sort'], $matches)) $sort = $matches[0];
if (isset($sort)) {
// Received and validated sort
// Writing to the account buffer
$this->account?->write(
[
'catalog' => [
'sort' => $sort
]
]
);
// Writing to the session buffer
$this->session?->write(
[
'catalog' => [
'sort' => $sort
]
]
);
// Write to the buffer of sort query (AQL)
$_sort = "d.@sort DESC, $_sort";
// Write to the buffer of query parameters
$_parameters['sort'] = $sort;
} else {
// Not received or not validated filter by brand
// Writing to the account buffer
$this->account?->write(
[
'catalog' => [
'sort' => null
]
]
);
// Writing to the session buffer
$this->session?->write(
[
'catalog' => [
'sort' => null
]
]
);
}
// Validating @todo add throwing errors
if (!empty($parameters['text']) && preg_match('/[\w\s]+/u', urldecode($parameters['text']), $matches) && mb_strlen($matches[0]) > 2) $text = $matches[0];
if (isset($text)) {
// Received and validated text
// Writing to the account buffer
$this->account?->write(
[
'catalog' => [
'search' => [
'text' => $text
]
]
]
);
// Writing to the session buffer
$this->session?->write(
[
'catalog' => [
'search' => [
'text' => $text
]
]
]
);
// Search for products and write to the buffer of global variables of view templater
$this->view->products = product::read(
search: $text,
search: $text ?? null,
filter: $_filters,
sort: $_sort,
amount: 30,
amount: 50, // @todo pagination
language: $this->language,
parameters: $_parameters,
return: 'DISTINCT MERGE(d, {name: d.name.@language, description: d.description.@language, compatibility: d.compatibility.@language})',
errors: $this->errors['catalog']
);
} else {
// Not received or not validated filter by brand
// Writing to the account buffer
$this->account?->write(
[
'catalog' => [
'search' => [
'text' => null
]
]
]
);
// Writing to the session buffer
$this->session?->write(
[
'catalog' => [
'search' => [
'text' => null
]
]
]
);
}
if (isset($this->view->products) && count($this->view->products) > 0) {
@ -198,6 +335,17 @@ final class catalog extends core
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// GET request
if (!empty($this->view->product)) {
// Initialized the product data
// Writing javascript code that has been executed after core and damper has been loaded
$this->view->javascript = [<<<javascript
if (typeof _window === 'undefined') {
_window = setTimeout(() => core.catalog.product_system('$product'), 500);
}
javascript] + ($this->view->javascript ?? []);
}
// Exit (success)
return $this->view->render('catalog/page.html');
} else if ($_SERVER['REQUEST_METHOD'] === 'POST') {
@ -205,36 +353,35 @@ final class catalog extends core
// Initializing the buffer of response
$response = [
'title' => $title ?? null
'title' => $this->language === language::ru ? 'Каталог' : 'Catalog' // @see https://git.mirzaev.sexy/mirzaev/huesos/issues/1
];
if (isset($this->view->categories)) {
// Initialized categories
// Render HTML-code of categories and write to the response buffer
$response['html'] ??= [];
$response['html']['categories'] = $this->view->render('catalog/elements/categories.html');
$response['categories'] = $this->view->render('catalog/elements/categories.html');
}
if (isset($this->view->product)) {
// Initialized product
// Writing data of the product to the response buffer @todo GENERATE THIS ON THE SERVER
$response['product'] = $this->view->product;
}
if (isset($this->view->products)) {
// Initialized products
// Render HTML-code of products and write to the response buffer
$response['html'] ??= [];
$response['html']['products'] = $this->view->render('catalog/elements/products/2columns.html');
$response['products'] = $this->view->render('catalog/elements/products.html');
}
if (isset($this->view->filters)) {
// Initialized filters
// Render HTML-code of filters and write to the response buffer
$response['html'] ??= [];
$response['html']['filters'] = $this->view->render('catalog/elements/filters.html');
$response['filters'] = $this->view->render('catalog/elements/filters.html');
}
// Initializing a response headers

View File

@ -20,6 +20,8 @@ use mirzaev\minimal\controller;
* Core of controllers
*
* @package mirzaev\arming_bot\controllers
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
class core extends controller

View File

@ -12,6 +12,8 @@ use mirzaev\arming_bot\controllers\core,
* Index controller
*
* @package mirzaev\arming_bot\controllers
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class index extends core

View File

@ -16,6 +16,8 @@ use mirzaev\arangodb\document;
* Controller of session
*
* @package mirzaev\arming_bot\controllers
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class session extends core

View File

@ -8,6 +8,7 @@ namespace mirzaev\arming_bot\models;
use mirzaev\arming_bot\models\core,
mirzaev\arming_bot\models\traits\status,
mirzaev\arming_bot\models\traits\document as arangodb_document_trait,
mirzaev\arming_bot\models\traits\buffer,
mirzaev\arming_bot\models\interfaces\document as arangodb_document_interface,
mirzaev\arming_bot\models\enumerations\language;
@ -34,7 +35,9 @@ use exception;
*/
final class account extends core implements arangodb_document_interface
{
use status, arangodb_document_trait;
use status, arangodb_document_trait, buffer {
buffer::write as write;
}
/**
* Name of the collection in ArangoDB

View File

@ -4,17 +4,19 @@ declare(strict_types=1);
namespace mirzaev\arming_bot\models;
// Files of the project
use mirzaev\arming_bot\models\interfaces\collection as collection_interface;
// Framework for PHP
use mirzaev\minimal\model;
// Framework for ArangoDB
use mirzaev\arangodb\connection as arangodb,
mirzaev\arangodb\collection,
mirzaev\arangodb\enumerations\collection\type;
// Library for ArangoDB
use ArangoDBClient\Document as _document;
// Framework for ArangoDB
use mirzaev\arangodb\connection as arangodb,
mirzaev\arangodb\collection;
// Built-in libraries
use exception;
@ -26,7 +28,7 @@ use exception;
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
class core extends model
class core extends model implements collection_interface
{
/**
* Postfix for name of models files
@ -45,16 +47,6 @@ class core extends model
*/
protected static arangodb $arangodb;
/**
* Name of the collection in ArangoDB
*/
public const string COLLECTION = 'THIS_COLLECTION_SHOULD_NOT_EXIST';
/**
* Type of the collection in ArangoDB
*/
public const type TYPE = type::document;
/**
* Constructor of an instance
*
@ -158,6 +150,7 @@ class core extends model
return null;
}
/**
* Write
*

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace mirzaev\arming_bot\models\interfaces;
// Framework for ArangoDB
use mirzaev\arangodb\enumerations\collection\type;
/**
* Interface for implementing a collection from ArangoDB
*
* @package mirzaev\arming_bot\models\traits
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
interface collection
{
/**
* Name of the collection in ArangoDB
*/
public const string COLLECTION = 'THIS_COLLECTION_SHOULD_NOT_EXIST';
/**
* Type of the collection in ArangoDB
*/
public const type TYPE = type::document;
}

View File

@ -13,6 +13,8 @@ use ArangoDBClient\Document as _document;
* @param _document $document An instance of the ArangoDB document from ArangoDB (protected readonly)
*
* @package mirzaev\arming_bot\models\traits
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
interface document

View File

@ -122,7 +122,7 @@ final class product extends core
* @param array $parameters Binded parameters for placeholders ['placeholder' => parameter]
* @param array &$errors Registry of errors
*
* @return array Массив с найденными товарами (может быть пустым)
* @return array Found products (can be empty)
*/
public static function read(
?string $search = null,
@ -130,7 +130,7 @@ final class product extends core
?string $sort = 'd.position ASC, d.created DESC',
int $page = 1,
int $amount = 100,
?string $return = 'd',
?string $return = 'DISTINCT d',
language $language = language::en,
array $parameters = [],
array &$errors = []
@ -163,22 +163,22 @@ final class product extends core
1,
false
) OR
levenshtein_match(
LEVENSHTEIN_MATCH(
d.description.@language,
tokens(@search, @analyzer)[0],
TOKENS(@search, @analyzer)[0],
1,
false
) OR
levenshtein_match(
LEVENSHTEIN_MATCH(
d.compatibility.@language,
tokens(@search, @analyzer)[0],
TOKENS(@search, @analyzer)[0],
1,
false
)
AQL,
empty($filter) ? '' : "FILTER $filter",
empty($search) ? (empty($sort) ? '' : "SORT $sort") : (empty($sort) ? "SORT BM25(d) DESC" : "SORT BM25(d) DESC, $sort"),
empty($return) ? 'd' : $return
empty($return) ? 'DISTINCT d' : $return
),
[
'@collection' => empty($search) ? static::COLLECTION : static::COLLECTION . 's_search',

View File

@ -10,6 +10,7 @@ use mirzaev\arming_bot\models\account,
mirzaev\arming_bot\models\enumerations\session as verification,
mirzaev\arming_bot\models\traits\status,
mirzaev\arming_bot\models\traits\document as arangodb_document_trait,
mirzaev\arming_bot\models\traits\buffer,
mirzaev\arming_bot\models\interfaces\document as arangodb_document_interface,
mirzaev\arming_bot\models\enumerations\language;
@ -33,7 +34,9 @@ use exception;
*/
final class session extends core implements arangodb_document_interface
{
use status, arangodb_document_trait;
use status, arangodb_document_trait, buffer {
buffer::write as write;
}
/**
* Name of the collection in ArangoDB
@ -43,7 +46,7 @@ final class session extends core implements arangodb_document_interface
/**
* Type of sessions verification
*/
public const verification VERIFICATION = verification::hash_else_address;
final public const verification VERIFICATION = verification::hash_else_address;
/**
* Constructor of instance
@ -325,44 +328,4 @@ final class session extends core implements arangodb_document_interface
// Exit (fail)
return null;
}
/**
* Write to buffer of the session
*
* @param array $data Data for merging
* @param array &$errors Registry of errors
*
* @return bool Is data has written into the session document from ArangoDB?
*/
public function write(array $data, array &$errors = []): bool
{
try {
if (collection::initialize(static::COLLECTION, static::TYPE, errors: $errors)) {
// Initialized the collection
// The instance of the session document from ArangoDB is initialized?
isset($this->document) || throw new exception('The instance of the sessoin document from ArangoDB is not initialized');
// Writing data into buffer of the instance of the session document from ArangoDB
$this->document->buffer = array_replace_recursive(
$this->document->buffer ?? [],
[$_SERVER['INTERFACE'] => array_replace_recursive($this->document->buffer[$_SERVER['INTERFACE']] ?? [], $data)]
);
// Writing to ArangoDB and exit (success)
return document::update($this->document, errors: $errors);
} else throw new exception('Failed to initialize ' . static::TYPE . ' collection: ' . static::COLLECTION);
} catch (exception $e) {
// Writing to the registry of errors
$errors[] = [
'text' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'stack' => $e->getTrace()
];
}
// Exit (fail)
return false;
}
}

View File

@ -0,0 +1,71 @@
<?php
declare(strict_types=1);
namespace mirzaev\arming_bot\models\traits;
// Files of the project
use mirzaev\arming_bot\models\interfaces\collection as collection_interface;
// Library for ArangoDB
use ArangoDBClient\Document as _document;
// Framework for ArangoDB
use mirzaev\arangodb\collection,
mirzaev\arangodb\document;
// Built-in libraries
use exception;
/**
* Trait for buffer
*
* @uses collection_interface
*
* @param static COLLECTION Name of the collection in ArangoDB
* @param static TYPE Type of the collection in ArangoDB
*
* @package mirzaev\arming_bot\models\traits
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
trait buffer
{
/**
* Write to buffer of the session
*
* @param array $data Data for writing (merge)
* @param array &$errors Registry of errors
*
* @return bool Is data has written into the session document from ArangoDB?
*/
public function write(array $data, array &$errors = []): bool
{
try {
if (collection::initialize(static::COLLECTION, static::TYPE, errors: $errors)) {
// Initialized the collection
// The instance of the session document from ArangoDB is initialized?
isset($this->document) || throw new exception('The instance of the sessoin document from ArangoDB is not initialized');
// Writing data into buffer of the instance of the session document from ArangoDB
$this->document->buffer = array_replace_recursive($this->document->buffer ?? [], $data);
// Writing to ArangoDB and exit (success)
return document::update($this->document, errors: $errors);
} else throw new exception('Failed to initialize ' . static::TYPE . ' collection: ' . static::COLLECTION);
} catch (exception $e) {
// Writing to the registry of errors
$errors[] = [
'text' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'stack' => $e->getTrace()
];
}
// Exit (fail)
return false;
}
}

View File

@ -22,6 +22,8 @@ use exception;
* @var protected readonly _document|null $document An instance of the ArangoDB document
*
* @package mirzaev\arming_bot\models\traits
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
trait document

View File

@ -11,6 +11,8 @@ use exception;
* Trait for initialization of files handlers
*
* @package mirzaev\arming_bot\models\traits
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
trait files

View File

@ -11,6 +11,8 @@ use exception;
* Trait for initialization of a status
*
* @package mirzaev\arming_bot\models\traits
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
trait status

View File

@ -11,6 +11,8 @@ use exception;
* Trait for "Yandex Disk"
*
* @package mirzaev\arming_bot\models\traits\yandex
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
trait disk

View File

@ -24,7 +24,17 @@ import("/js/core.js").then(() =>
if (typeof core.account === "undefined") {
// Not initialized
// Write to the core
/**
* @name Account
*
* @description
* Implements actions with accounts
*
* @memberof core
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
core.account = class account {
// Wrap of indicator of the account
static wrap = document.getElementById("account");
@ -75,7 +85,7 @@ import("/js/core.js").then(() =>
core
.request(
"/session/connect/telegram",
core.telegram.api.initData
core.telegram.api.initData,
)
.then((json) => {
if (
@ -94,8 +104,9 @@ import("/js/core.js").then(() =>
const a =
core.status_account.getElementsByTagName("a")[0];
a.setAttribute("onclick", "core.account.profile()");
a.innerText =
json.domain.length > 0 ? "@" + json.domain : "ERROR";
a.innerText = json.domain.length > 0
? "@" + json.domain
: "ERROR";
}
if (
@ -132,7 +143,7 @@ import("/js/core.js").then(() =>
`${name}=${value}`,
"POST",
{},
null
null,
);
}
}

View File

@ -22,7 +22,17 @@ import("/js/core.js").then(() =>
if (typeof core.cart === "undefined") {
// Not initialized
// Write to the core
/**
* @name Cart
*
* @description
* Implements actions with cart
*
* @memberof core
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
core.cart = class cart {
/**
* Products in cart ["product/148181", "product/148181", "product/148181"...]

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,17 @@ import("/js/core.js").then(() =>
if (typeof core.connection === "undefined") {
// Not initialized
// Write to the core
/**
* @name Connection
*
* @description
* Implements actions with websocket connection
*
* @memberof core
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
core.connection = class connection {
// Wrap of indicator of the connection
static wrap = document.getElementById("connection");
@ -205,7 +215,6 @@ import("/js/core.js").then(() =>
};
}
core.connection.connect(
3000,
() =>

View File

@ -1,6 +1,14 @@
"use strict";
// Initialize of the class in global namespace
/**
* @name Core
*
* @description
* Core of the project
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
const core = class core {
// Domain
static domain = window.location.hostname;
@ -8,31 +16,34 @@ const core = class core {
// Language
static language = "ru";
// Label for the "loading" element
// Window
static window;
// The "loading" element
static status_loading = document.getElementById("loading");
// Label for the "account" element
// The "account" element
static status_account = document.getElementById("account");
// Label for the <header> element
// The <header> element
static header = document.body.getElementsByTagName("header")[0];
// Label for the <aside> element
// The <aside> element
static aside = document.body.getElementsByTagName("aside")[0];
// Label for the "menu" element
static menu = document.body.querySelector("section[data-section='menu']");
// The <menu> element
static menu = document.body.getElementsByTagName("menu")[0];
// Label for the <main> element
// The <main> element
static main = document.body.getElementsByTagName("main")[0];
// Label for the <footer> element
// The <footer> element
static footer = document.body.getElementsByTagName("footer")[0];
/**
* Request
*
* @param {string} address
* @param {string} uri
* @param {string} body
* @param {string} method POST, GET...
* @param {object} headers
@ -41,7 +52,7 @@ const core = class core {
* @return {Promise}
*/
static async request(
address = "/",
uri = "/",
body,
method = "POST",
headers = {
@ -50,7 +61,7 @@ const core = class core {
},
type = "json",
) {
return await fetch(encodeURI(address), { method, headers, body })
return await fetch(encodeURI(uri), { method, headers, body })
.then((response) => type === null || response[type]());
}

View File

@ -19,14 +19,19 @@ import("/js/core.js").then(() => {
// Not initialized
/**
* Damper
* @name Damper
*
* @description
* Execute multiple "function" calls in a "timeout" amount of time just once
*
* @param {function} function Function to execute after damping
* @param {number} timeout Timer in milliseconds (ms)
* @param {number} force Argument number storing the status of enforcement execution (see @example)
*
* @memberof core
*
* @example
* $a = damper(
* a = damper(
* async (
* a, // 0
* b, // 1
@ -40,9 +45,10 @@ import("/js/core.js").then(() => {
* 3, // 3 -> "force" argument
* );
*
* $a('for a', 'for b', 'for c', true, 'for d'); // Force execute is enabled
* a('for a', 'for b', 'for c', true, 'for d'); // Force execute is enabled
*
* @return {void}
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
core.damper = (func, timeout = 300, force) => {
// Initializing of the timer
@ -60,9 +66,7 @@ import("/js/core.js").then(() => {
// Normal execution
// Execute the handled function (entry into recursion)
timer = setTimeout(() => {
func.apply(this, args);
}, timeout);
timer = setTimeout(() => func.apply(this, args), timeout);
}
};
};

View File

@ -19,7 +19,7 @@ import("/js/core.js").then(() => {
// Not initialized
/**
* Бегущая строка
* @name Бегущая строка
*
* @description
* Простой, но мощный класс для создания бегущих строк. Поддерживает
@ -31,6 +31,8 @@ import("/js/core.js").then(() => {
* события при выбранных действиях для того, чтобы пользователь имел возможность
* дорабатывать функционал без изучения и изменения моего кода
*
* @memberof core
*
* @example
* сonst hotline = new hotline();
* hotline.step = '-5';
@ -41,7 +43,7 @@ import("/js/core.js").then(() => {
* Сейчас при БЫСТРОМ прокручивании можно заметит как элементы "появляются" в начале и конце строки.
* 2. "gap" and "padding" in wrap should be removed! or added here to the calculations
*
* @copyright WTFPL
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
core.hotline = class hotline {

View File

@ -0,0 +1,265 @@
"use strict";
// Import dependencies
import("/js/core.js").then(() =>
import("/js/damper.js").then(() => {
const dependencies = setInterval(() => {
if (typeof core === "function" && typeof core.damper === "function") {
clearInterval(dependencies);
clearTimeout(timeout);
initialization();
}
}, 10);
const timeout = setTimeout(() => {
clearInterval(dependencies);
initialization();
}, 5000);
function initialization() {
if (typeof core.loader === "undefined") {
// Not initialized
/**
* @name Loader
*
* @description
* Implements actions with loading and rendering content
*
* @memberof core
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
core.loader = class loader {
/**
* Load
*
* @param {string} uri
* @param {string} body
*
* @return {Promise}
*/
static async load(uri = "/", body) {
if (typeof uri === "string") {
// Received and validated uri
return await core
.request(
uri,
body,
"POST",
{
"Content-Type": "application/x-www-form-urlencoded",
Accept: "application/json",
},
"json"
)
.then((json) => {
if (
json.errors !== null &&
typeof json.errors === "object" &&
json.errors.length > 0
) {
// Fail (received errors)
} else {
// Success (not received errors)
// Writing to the browser history
history.pushState({}, json.title ?? uri, uri);
/**
* The <title>
*
* The title of the page
*/
if (
typeof json.title === "string" &&
json.title.length > 0
) {
// Received text for the <title> of the page
// Search for the <title> element (document.title)
const title = document.getElementsByTagName("title")[0];
if (title instanceof HTMLElement) {
// Found the <title> element
// Writing into the <title> element
title.innerText = json.title;
} else {
// Not found the <title> element
// Initialize the <title> element
const title = document.createElement("title");
// Inititalize the <head> element (document.head)
const head = document.getElementsByTagName("head")[0];
if (head instanceof HTMLElement) {
// Found the <head> element
// Writing the <title> element into the <head> element
head.appendChild(title);
}
// Writing title into the <title> element
title.innerText = json.title;
}
}
/**
* The <header> element
*/
if (
typeof json.header === "string" &&
json.header.length > 0
) {
// Received and validated the header HTML-code
if (core.header instanceof HTMLElement) {
// Found the <header> element
// Writing into the <header> element
core.header.outerHTML = json.header;
// Reinitializing the parameter with the <header> element
core.header =
document.getElementsByTagName("header")[0];
} else {
// Not found the <header> element
// Initialize the <header> element
core.header = document.createElement("header");
// Inititalize the <body> element (document.body)
const body = document.getElementsByTagName("body")[0];
if (body instanceof HTMLElement) {
// Found the <body> element
if (core.main instanceof HTMLElement) {
// Found the <main> element
// Writing the <header> element before the <main> element
body.insertBefore(core.header, core.main);
} else if (core.footer instanceof HTMLElement) {
// Fount the <footer> element
// Writing the <header> element before the <footer> element
body.insertBefore(core.header, core.footer);
} else {
// Not found the <main> element and the <footer> element
// Search for the last <section> element inside the <body> element
const section = document.body.querySelector(
"body > section:last-of-type"
);
if (section instanceof HTMLElement) {
// Found the last <section> element inside the <body> element
// Writing the <header> element after the last <section> element inside the <body> element
body.insertBefore(
core.header,
section.nextSibling
);
} else {
// Not found section elements <section> inside the <body> element
// Writing the <header> element into the <body> element
body.appendChild(core.header);
}
}
// Writing into the <header> element
core.header.outerHTML = json.header;
// Reinitializing the parameter with the <header> element
core.header =
document.getElementsByTagName("header")[0];
}
}
}
/**
* The <main> element
*
* The main content of the page
*/
if (typeof json.main === "string" && json.main.length > 0) {
// Received and validated the <main> HTML-code
if (core.main instanceof HTMLElement) {
// Found the <main> element
// Writing into the <main> element
core.main.outerHTML = json.main;
// Reinitializing the parameter with the <main> element
core.main = document.getElementsByTagName("main")[0];
} else {
// Not found the <main> element
// Initialize the <main> element
core.main = document.createElement("main");
// Inititalize the <body> element (document.body)
const body = document.getElementsByTagName("body")[0];
if (body instanceof HTMLElement) {
// Found the <body> element
if (core.header instanceof HTMLElement) {
// Found the <header> element
// Writing the <main> element after the <header> element
body.insertBefore(
core.main,
core.header.nextSibling
);
} else if (core.footer instanceof HTMLElement) {
// Fount the <footer> element
// Writing the <main> element before the <footer> element
body.insertBefore(core.main, core.footer);
} else {
// Not found the <header> element and the <footer> element
// Search for the last <section> element inside the <body> element
const section = document.body.querySelector(
"body > section:last-of-type"
);
if (section instanceof HTMLElement) {
// Found the last <section> element inside the <body> element
// Writing the <main> element after the last <section> element inside the <body> element
body.insertBefore(core.main, section.nextSibling);
} else {
// Not found section elements <section> inside the <body> element
// Writing the <main> element into the <body> element
body.appendChild(core.main);
}
}
// Writing into the <main> element
core.main.outerHTML = json.main;
// Reinitializing the parameter with the <main> element
core.main = document.getElementsByTagName("main")[0];
}
}
}
// Exit (success)
return json;
}
});
}
}
};
}
}
})
);

View File

@ -24,7 +24,17 @@ import("/js/core.js").then(() =>
if (typeof core.session === "undefined") {
// Not initialized
// Write to the core
/**
* @name Session
*
* @description
* Implements actions with sessions
*
* @memberof core
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
core.session = class session {
/**
* Buffer
@ -48,7 +58,7 @@ import("/js/core.js").then(() =>
`${name}=${value}`,
"POST",
{},
null
null,
);
}
}

View File

@ -22,10 +22,20 @@ import("/js/core.js").then(() =>
if (typeof core.telegram === "undefined") {
// Not initialized
// Write to the core
/**
* @name Telegram
*
* @description
* Implements actions with data of the telegram account
*
* @memberof core
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
core.telegram = class telegram {
/**
* Telegram WebApp API
* Telegram "WebApp" API
*
* @see {@link https://core.telegram.org/bots/webapps#initializing-mini-apps}
*/

View File

@ -0,0 +1,149 @@
@charset "UTF-8";
main>section:is(#products, #categories) {
width: var(--width);
display: flex;
flex-flow: row wrap;
gap: var(--gap, 5px);
}
main>section#categories>a.category[type="button"] {
--padding: 0.7rem;
position: relative;
height: 23px;
padding: var(--padding);
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
overflow: hidden;
border-radius: 0.75rem;
color: var(--tg-theme-button-text-color);
background-color: var(--tg-theme-button-color);
}
main>section#categories:last-child {
/* margin-bottom: unset; */
}
main>section#categories>a.category[type="button"]:has(>img) {
min-width: calc(50% - var(--padding) * 2);
height: 180px;
padding: unset;
}
main>section#categories>a.category[type="button"]>img {
position: absolute;
left: -5%;
top: -5%;
width: 110%;
height: 110%;
object-fit: cover;
/* filter: blur(1px); */
filter: brightness(60%);
}
main>section#categories>a.category[type="button"]:is(:hover, :focus)>img {
filter: unset;
}
main>section#categories>a.category[type="button"]:has(>img)>p {
position: absolute;
left: var(--padding);
bottom: var(--padding);
right: var(--padding);
margin: unset;
width: min-content;
border-radius: 0.75rem;
background: var(--tg-theme-secondary-bg-color);
}
main>section#categories>a.category[type="button"]>p {
z-index: 100;
padding: 8px 16px;
}
main>section#filters {
width: var(--width);
max-height: 2.5rem;
display: flex;
align-items: start;
}
main>section#products {
--column: calc((100% - var(--gap)) / 2);
width: var(--width);
display: grid;
grid-gap: var(--gap);
grid-template-columns: repeat(2, var(--column));
grid-auto-flow: row dense;
}
main>section#products>div.column {
width: 100%;
display: flex;
flex-direction: column;
gap: var(--gap);
}
main>section#products>div.column>article.product {
position: relative;
width: 100%;
display: flex;
flex-grow: 0;
flex-direction: column;
border-radius: 0.75rem;
overflow: clip;
backdrop-filter: brightness(0.7);
cursor: pointer;
}
main>section#products>div.column>article.product:is(:hover, :focus) {
/* flex-grow: 0.1; */
/* background-color: var(--tg-theme-secondary-bg-color); */
}
main>section#products>div.column>article.product:is(:hover, :focus)>* {
transition: 0s;
}
main>section#products>div.column>article.product:not(:is(:hover, :focus))>* {
transition: 0.2s ease-out;
}
main>section#products>div.column>article.product>a {
display: contents;
}
main>section#products>div.column>article.product>a>img:first-of-type {
width: 100%;
height: 100%;
}
main>section#products>div.column>article.product>a>img:first-of-type+* {
margin-top: auto;
}
main>section#products>div.column>article.product>a>p.title {
z-index: 50;
margin: unset;
padding: 4px 8px;
font-size: 0.9rem;
font-weight: bold;
overflow-wrap: anywhere;
hyphens: auto;
color: var(--tg-theme-text-color);
background-color: var(--tg-theme-secondary-bg-color);
}
main>section#products>div.column>article.product>button:last-of-type {
z-index: 100;
height: 33px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
color: var(--tg-theme-button-text-color);
background-color: var(--tg-theme-button-color);
}

View File

@ -1,160 +0,0 @@
@charset "UTF-8";
main>section[data-section="catalog"] {
width: var(--width);
height: 100%;
display: flex;
flex-flow: row wrap;
gap: var(--gap, 5px);
/* justify-content: space-between; */
/* justify-content: space-evenly; */
/* background-color: var(--tg-theme-secondary-bg-color); */
}
main>section[data-section="catalog"]:last-child {
margin-bottom: unset;
}
main>section[data-section="catalog"]>a.category[type="button"] {
height: 23px;
padding: 8px 16px;
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
border-radius: 0.75rem;
color: var(--tg-theme-button-text-color);
background-color: var(--tg-theme-button-color);
}
main>section[data-section="catalog"]>article.product {
/* --product-height: 200px; */
--product-height: 220px;
--title-font-size: 0.9rem;
--title-height: 1.5rem;
--button-height: 33px;
position: relative;
/* width: calc((100% - var(--gap) * 2) / 3); */
width: calc((100% - var(--gap)) / 2);
height: var(--product-height);
display: flex;
flex-grow: 0;
flex-direction: column;
white-space: nowrap;
border-radius: 0.75rem;
overflow: clip;
backdrop-filter: brightness(0.7);
cursor: pointer;
}
main>section[data-section="catalog"]>article.product:hover {
/* flex-grow: 0.1; */
/* background-color: var(--tg-theme-secondary-bg-color); */
}
main>section[data-section="catalog"]>article.product:hover>* {
transition: 0s;
}
main>section[data-section="catalog"]>article.product:not(:hover)>* {
transition: 0.2s ease-out;
}
main>section[data-section="catalog"]>article.product>img:first-of-type {
z-index: -50;
position: absolute;
bottom: var(--button-height);
/* bottom: calc(var(--button-height) + var(--title-height)); */
width: 100%;
/* height: 100%; */
height: calc(var(--product-height) - var(--button-height));
object-fit: cover;
}
main>section[data-section="catalog"]>article.product>img:first-of-type+* {
margin-top: auto;
}
main>section[data-section="catalog"]>article.product>a {
padding: 4px 8px 4px 8px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: bold;
backdrop-filter: brightness(0.4) contrast(1.2);
color: var(--text-light, var(--tg-theme-text-color));
}
main>section[data-section="catalog"]>article.product>a.title {
padding: 0 8px 0 8px;
height: var(--title-height);
min-height: var(--title-height);
line-height: var(--title-height);
font-size: var(--title-font-size);
}
main>section[data-section="catalog"]>article.product:hover>a.title {
backdrop-filter: brightness(0.35) contrast(1.2);
}
main>section[data-section="catalog"]>article.product>a+ :is(a, small) {
padding: 0px 8px 0 8px;
}
main>section[data-section="catalog"]>article.product>small {
padding: 3px 8px 0 8px;
white-space: normal;
word-break: break-all;
font-size: 0.7rem;
backdrop-filter: brightness(0.4) contrast(1.2);
color: var(--text-light, var(--tg-theme-text-color));
}
main>section[data-section="catalog"]>article.product>small.description {
overflow: hidden;
}
main>section[data-section="catalog"]>article.product:hover>small.description {
height: calc(var(--product-height) - var(--title-height) - var(--button-height) - 6px);
}
main>section[data-section="catalog"]>article.product:not(:hover)>small.description {
height: 0;
padding: 0 8px 0px 8px !important;
}
main>section[data-section="catalog"]>article.product>*:has(+ button:last-of-type) {
--offset-before-button: 9px;
padding: 4px 8px 13px 8px;
}
main>section[data-section="catalog"]>article.product>button:last-of-type {
height: var(--button-height);
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
color: var(--tg-theme-button-text-color);
background-color: var(--tg-theme-button-color);
}
main>section[data-section="cart"] {
--diameter: 4rem;
z-index: 999;
right: 5vw;
bottom: 5vw;
position: fixed;
width: var(--diameter);
height: var(--diameter);
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
border-radius: 100%;
background-color: var(--tg-theme-button-color);
}
main>section[data-section="cart"]>i.icon.shopping.cart {
top: -1px;
color: var(--tg-theme-button-text-color);
}

View File

@ -1,169 +0,0 @@
@charset "UTF-8";
main>section[data-section="catalog"] {
width: var(--width);
display: flex;
flex-flow: row wrap;
gap: var(--gap, 5px);
}
main>section[data-section="catalog"][data-catalog-type="categories"]>a.category[type="button"] {
--padding: 0.7rem;
position: relative;
height: 23px;
padding: var(--padding);
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
overflow: hidden;
border-radius: 0.75rem;
color: var(--tg-theme-button-text-color);
background-color: var(--tg-theme-button-color);
}
main>section[data-section="catalog"][data-catalog-type="categories"]:last-child {
/* margin-bottom: unset; */
}
main>section[data-section="catalog"][data-catalog-type="categories"]>a.category[type="button"]:has(>img) {
min-width: calc(50% - var(--padding) * 2);
height: 180px;
padding: unset;
}
main>section[data-section="catalog"][data-catalog-type="categories"]>a.category[type="button"]>img {
position: absolute;
left: -5%;
top: -5%;
width: 110%;
height: 110%;
object-fit: cover;
/* filter: blur(1px); */
filter: brightness(60%);
}
main>section[data-section="catalog"][data-catalog-type="categories"]>a.category[type="button"]:is(:hover, :focus)>img {
filter: unset;
}
main>section[data-section="catalog"][data-catalog-type="categories"]>a.category[type="button"]:has(>img)>p {
position: absolute;
left: var(--padding);
bottom: var(--padding);
right: var(--padding);
margin: unset;
width: min-content;
border-radius: 0.75rem;
background: var(--tg-theme-secondary-bg-color);
}
main>section[data-section="catalog"][data-catalog-type="categories"]>a.category[type="button"]>p {
z-index: 100;
padding: 8px 16px;
}
main>section[data-section="catalog"][data-catalog-type="products"] {
--column: calc((100% - var(--gap)) / 2);
width: var(--width);
display: grid;
grid-gap: var(--gap);
grid-template-columns: repeat(2, var(--column));
grid-auto-flow: row dense;
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column {
width: 100%;
display: flex;
flex-direction: column;
gap: var(--gap);
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product {
position: relative;
width: 100%;
display: flex;
flex-grow: 0;
flex-direction: column;
border-radius: 0.75rem;
overflow: clip;
backdrop-filter: brightness(0.7);
cursor: pointer;
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product:is(:hover, :focus) {
/* flex-grow: 0.1; */
/* background-color: var(--tg-theme-secondary-bg-color); */
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product:is(:hover, :focus)>* {
transition: 0s;
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product:not(:is(:hover, :focus))>* {
transition: 0.2s ease-out;
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product>a {
display: contents;
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product>a>img:first-of-type {
width: 100%;
height: 100%;
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product>a>img:first-of-type+* {
margin-top: auto;
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product>a>p.title {
z-index: 50;
margin: unset;
padding: 4px 8px;
font-size: 0.9rem;
font-weight: bold;
overflow-wrap: anywhere;
hyphens: auto;
color: var(--tg-theme-text-color);
background-color: var(--tg-theme-secondary-bg-color);
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product>button:last-of-type {
z-index: 100;
height: 33px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
color: var(--tg-theme-button-text-color);
background-color: var(--tg-theme-button-color);
}
main>section[data-section="cart"] {
--diameter: 4rem;
z-index: 999;
right: 5vw;
bottom: 5vw;
position: fixed;
width: var(--diameter);
height: var(--diameter);
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
border-radius: 100%;
background-color: var(--tg-theme-button-color);
}
main>section[data-section="cart"]>i.icon.shopping.cart {
top: -1px;
color: var(--tg-theme-button-text-color);
}
main>section[data-section="filters"] {
max-height: 2.5rem;
display: flex;
align-items: start;
}

View File

@ -1,117 +0,0 @@
@charset "UTF-8";
main>section[data-section="catalog"] {
width: var(--width);
display: flex;
flex-flow: row wrap;
gap: var(--gap, 5px);
}
main>section[data-section="catalog"][data-catalog-type="categories"]>a.category[type="button"] {
height: 23px;
padding: 8px 16px;
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
border-radius: 0.75rem;
color: var(--tg-theme-button-text-color);
background-color: var(--tg-theme-button-color);
}
main>section[data-section="catalog"][data-catalog-type="categories"]:last-child {
/* margin-bottom: unset; */
}
main>section[data-section="catalog"][data-catalog-type="products"] {
--column: calc((100% - var(--gap) * 2) / 3);
width: var(--width);
display: grid;
grid-gap: var(--gap);
grid-template-columns: repeat(3, var(--column));
grid-auto-flow: row dense;
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column {
width: 100%;
display: flex;
flex-direction: column;
gap: var(--gap);
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product {
position: relative;
width: 100%;
display: flex;
flex-grow: 0;
flex-direction: column;
border-radius: 0.75rem;
overflow: clip;
backdrop-filter: brightness(0.7);
cursor: pointer;
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product:hover {
/* flex-grow: 0.1; */
/* background-color: var(--tg-theme-secondary-bg-color); */
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product:hover>* {
transition: 0s;
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product:not(:hover)>* {
transition: 0.2s ease-out;
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product>img:first-of-type {
z-index: -50;
width: 100%;
max-height: 120px;
object-fit: cover;
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product>img:first-of-type+* {
margin-top: auto;
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product>a.title {
padding: 4px 8px;
font-size: 0.9rem;
font-weight: bold;
word-break: break-word;
hyphens: auto;
color: var(--tg-theme-text-color);
background-color: var(--tg-theme-secondary-bg-color);
}
main>section[data-section="catalog"][data-catalog-type="products"]>div.column>article.product>button:last-of-type {
height: 33px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
color: var(--tg-theme-button-text-color);
background-color: var(--tg-theme-button-color);
}
main>section[data-section="cart"] {
--diameter: 4rem;
z-index: 999;
right: 5vw;
bottom: 5vw;
position: fixed;
width: var(--diameter);
height: var(--diameter);
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
border-radius: 100%;
background-color: var(--tg-theme-button-color);
}
main>section[data-section="cart"]>i.icon.shopping.cart {
top: -1px;
color: var(--tg-theme-button-text-color);
}

View File

@ -67,7 +67,6 @@ final class templater extends controller implements ArrayAccess
if (!empty($account?->status())) $this->twig->addGlobal('account', $account);
$this->twig->addGlobal('language', $account?->language->name ?? $settings?->language->name ?? 'en');
// Initialize function of dimensions formattinx
$this->twig->addFunction(
new TwigFunction(

View File

@ -19,5 +19,5 @@
{% endblock %}
{% block js %}
<script type="text/javascript" src="/js/account.js"></script>
<script src="/js/account.js"></script>
{% endblock %}

View File

@ -1,3 +0,0 @@
<section data-section="cart">
<i class="icon shopping cart"></i>
</section>

View File

@ -1,10 +1,9 @@
{% if categories is not empty %}
<section class="unselectable" data-section="catalog" data-catalog-type="categories"
data-catalog-level="{{ level ?? 0 }}">
<section id="categories" class="unselectable">
{% for category in categories %}
<a id="{{ category.getId() }}" class="category" type="button"
onclick="core.catalog.parameters.set('category', {{ category.identifier }}); core.catalog.search()"
onkeydown="event.keyCode === 13 && (core.catalog.parameters.set('category', {{ category.identifier }}), core.catalog.search())"
<a id="{{ category.getId() }}" class="category" type="button" href="?category={{ category.identifier }}"
onclick="core.catalog.parameters.set('category', {{ category.identifier }}); return core.catalog.search(event);"
onkeydown="event.keyCode === 13 && (core.catalog.parameters.set('category', {{ category.identifier }}), core.catalog.search(event))"
tabindex="3">
{% if category.images %}
<img src="{{ category.images.0.storage }}" alt="{{ category.name[language] }}" ondrugstart="return false;">

View File

@ -1,16 +1,21 @@
{% if filters is not empty %}
<section class="unselectble" data-section="filters">
<section class="unselectable" data-type="select" data-filter="brand" tabindex="4">
{% set cheked_brand = account.buffer.filters.brand ?? session.buffer.filters.brand %}
<input name="brand" type="radio" id="brand_title" onclick="core.catalog.parameters.set('brand', null); core.catalog.search()" {% if checked_brand
is empty %} checked{% endif %}>
<label for="brand_title" type="button">{{ language == 'ru' ? 'Бренд' : 'Brand' }}</label>
<input name="brand" type="radio" id="brand_all" onclick="core.catalog.parameters.set('brand', null); core.catalog.search()">
<label for="brand_all" type="button">{{ language == 'ru' ? 'Все бренды' : 'All brands' }}</label>
<section id="filters" class="unselectble">
<section class="unselectable" data-type="select" tabindex="4">
{% set buffer_brand = account.buffer.catalog.filters.brand ?? session.buffer.catalog.filters.brand %}
<input name="brand" type="radio" id="brand_title" {% if buffer_brand is empty %} checked{% endif %}>
<label for="brand_title" type="button" onclick="core.catalog.parameters.set('brand', null); core.catalog.search(event)">
{{ language == 'ru' ? 'Бренд' : 'Brand' }}
</label>
<input name="brand" type="radio" id="brand_all">
<label for="brand_all" type="button" onclick="core.catalog.parameters.set('brand', null); core.catalog.search(event)">
{{ language == 'ru' ? 'Все бренды' : 'All brands' }}
</label>
{% for brand in filters.brands %}
<input name="brand" type="radio" id="brand_{{ loop.index }}" onclick="core.catalog.parameters.set('brand', '{{ brand }}'); core.catalog.search()" {%
if brand==checked_brand %} checked{% endif %}>
<label for="brand_{{ loop.index }}" type="button">{{ brand }}</label>
<input name="brand" type="radio" id="brand_{{ loop.index }}" {% if brand == buffer_brand %} checked{% endif %}>
<label for="brand_{{ loop.index }}" type="button"
onclick="core.catalog.parameters.set('brand', '{{ brand }}'); core.catalog.search(event)">
{{ brand }}
</label>
{% endfor %}
</section>
</section>

View File

@ -1,7 +1,7 @@
{% macro card(product) %}
{% set title = product.name[language] ~ ' ' ~ product.brand[language] ~ format_dimensions(product.dimensions.x, product.dimensions.y, product.dimensions.z, ' ') ~ ' ' ~ product.weight ~ 'г' %}
<article id="{{ product.getId() }}" class="product unselectable">
<a data-product-identifier="{{ product.identifier }}" onclick="core.catalog.product(this)" onkeydown="event.keyCode === 13 && core.catalog.product(this)" tabindex="10">
<a data-product-identifier="{{ product.identifier }}" href="?product={{ product.identifier }}" onclick="return core.catalog.product(this);" onkeydown="event.keyCode === 13 && core.catalog.product(this)" tabindex="10">
<img src="{{ product.images.0.storage }}" alt="{{ product.name[language] }}" ondrugstart="return false;">
<p class="title" title="{{ product.name[language] }}">
{{ title | length > 45 ? title | slice(0, 45) ~ '...' : title }}
@ -13,14 +13,7 @@
</article>
{% endmacro %}
{% if products is not empty %}
<section class="unselectable" data-section="catalog" data-catalog-type="products" data-catalog-level="{{ level ?? 0 }}">
<div class="column">
{% for product in products %}
{% if loop.index % 2 == 0 %}
{{ _self.card(product) }}
{% endif %}
{% endfor %}
</div>
<section id="products" class="unselectable">
<div class="column">
{% for product in products %}
{% if loop.index % 2 == 1 %}
@ -28,5 +21,12 @@
{% endif %}
{% endfor %}
</div>
<div class="column">
{% for product in products %}
{% if loop.index % 2 == 0 %}
{{ _self.card(product) }}
{% endif %}
{% endfor %}
</div>
</section>
{% endif %}

View File

@ -1,13 +0,0 @@
{% if products is not empty %}
<section class="unselectable" data-section="catalog" data-catalog-type="products" data-catalog-level="{{ level ?? 0 }}">
{% for product in products %}
<article id="{{ product.getId() }}" class="product unselectable">
<img src="/images/{{ product.getKey() }}/1.jpg" alt="{{ product.title.ru }}" ondrugstart="return false;" onclick="return core.catalog.product({{ product.getKey() }});">
<a class="title" title="{{ product.title.ru }}" onclick="return core.catalog.product({{ product.getKey() }});">{{ product.title.ru }}</a>
<small class="description" title="{{ product.description.ru }}" onclick="return core.catalog.product({{ product.getKey() }});">{{ product.description.ru | length > 160 ? product.description.ru | slice(0, 160) ~
'...' : product.description.ru }}</small>
<button title="Добавить в корзину" onclick="return core.catalog.cart.add({{ product.getKey() }})">{{ product.cost }}р</button>
</article>
{% endfor %}
</section>
{% endif %}

View File

@ -1,36 +0,0 @@
{% macro card(product) %}
<article id="{{ product.getId() }}" class="product unselectable">
<img src="/images/{{ product.getKey() }}/1.jpg" alt="{{ product.title.ru }}" ondrugstart="return false;"
onclick="return core.catalog.product({{ product.getKey() }});">
<a class="title" title="{{ product.title.ru }}" onclick="return core.catalog.product({{ product.getKey() }});">{{
product.title.ru | length > 35 ? product.title.ru | slice(0, 35) ~ '...' : product.title.ru }}</a>
<button title="Добавить в корзину" onclick="return core.catalog.cart.add({{ product.getKey() }})">{{ product.cost
}}р</button>
</article>
{% endmacro %}
{% if products is not empty %}
<section class="unselectable" data-section="catalog" data-catalog-type="products" data-catalog-level="{{ level ?? 0 }}">
<div class="column">
{% for product in products %}
{% if loop.index0 % 3 == 0 %}
{{ _self.card(product) }}
{% endif %}
{% endfor %}
</div>
<div class="column">
{% for product in products %}
{% if loop.index0 % 3 == 1 %}
{{ _self.card(product) }}
{% endif %}
{% endfor %}
</div>
<div class="column">
{% for product in products %}
{% if loop.index0 % 3 == 2 %}
{{ _self.card(product) }}
{% endif %}
{% endfor %}
</div>
</section>
{% endif %}

View File

@ -1,6 +1,7 @@
<search data-section="search">
<label><i class="icon search"></i></label>
{% set search = account.buffer.search ?? session.buffer.search %}
<input id="search" placeholder="Поиск по каталогу" type="search" tabindex="1"
onkeyup="event.keyCode === 9 || core.catalog.parameters.set('text', this.value); core.catalog.search(event, this)"{% if search is not empty %} value="{{ search }}"{% endif %} />
<search id="search">
<label class="unselectable"><i class="icon search"></i></label>
{% set buffer_search = account.buffer.catalog.search.text ?? session.buffer.catalog.search.text %}
<input placeholder="Поиск по каталогу" type="search" tabindex="1"
onkeyup="event.keyCode === 9 || core.catalog.parameters.set('text', this.value); core.catalog.search(event, this)"
{% if buffer_search is not empty %} value="{{ buffer_search }}" {% endif %} />
</search>

View File

@ -2,7 +2,7 @@
{% block css %}
{{ parent() }}
<link type="text/css" rel="stylesheet" href="/themes/{{ theme }}/css/catalog/2columns.css" />
<link type="text/css" rel="stylesheet" href="/themes/{{ theme }}/css/catalog.css" />
<link type="text/css" rel="stylesheet" href="/themes/{{ theme }}/css/interface/select.css" />
<link type="text/css" rel="stylesheet" href="/themes/{{ theme }}/css/icons/search.css" />
<link type="text/css" rel="stylesheet" href="/themes/{{ theme }}/css/icons/shopping_cart.css" />
@ -10,13 +10,11 @@
{% endblock %}
{% block main %}
<h2 class="unselectable">Каталог</h2>
<h2 class="unselectable">{{ h2 }}</h2>
{% include "/themes/default/catalog/elements/search.html" %}
{% include "/themes/default/catalog/elements/categories.html" %}
{% include "/themes/default/catalog/elements/filters.html" %}
{% include "/themes/default/catalog/elements/products/2columns.html" %}
<!-- {% include "/themes/default/catalog/elements/cart.html" %} -->
{% include "/themes/default/catalog/elements/products.html" %}
{% endblock %}
{% block js %}

View File

@ -10,5 +10,5 @@
{% endblock %}
{% block js %}
<script type="text/javascript" src="/js/connection.js"></script>
<script src="/js/connection.js"></script>
{% endblock %}

View File

@ -1,17 +1,16 @@
{% block title %}
<title>{% if head.title != empty %}{{head.title}}{% else %}ARMING{% endif %}</title>
<title>{% if head.title is not empty %}{{ head.title }}{% else %}{{ settings.project.name }}{% endif %}</title>
{% endblock %}
{% block meta %}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{% for meta in head.metas %}
<meta {% for name, value in meta.attributes %}{{name}}="{{value}}" {% endfor %}>
<meta {% for name, value in meta.attributes %}{{ name }}="{{ value }}" {% endfor %}>
{% endfor %}
{% endblock %}
{% block css %}
<!-- <link type="text/css" rel="stylesheet" href="/themes/{{ theme }}/css/initialization.css" /> -->
<link type="text/css" rel="stylesheet" href="/themes/{{ theme }}/css/main.css" />
<link type="text/css" rel="stylesheet" href="/themes/{{ theme }}/css/icons/loading_spinner.css" />
<link type="text/css" rel="stylesheet" href="/themes/{{ theme }}/css/loading.css" />

View File

@ -1,8 +1,38 @@
{% block js %}
<script src="https://telegram.org/js/telegram-web-app.js" defer></script>
<script src="/js/core.js" defer></script>
<script src="https://telegram.org/js/telegram-web-app.js"></script>
<script src="/js/core.js"></script>
<script src="/js/damper.js"></script>
<script src="/js/loader.js"></script>
<script src="/js/telegram.js"></script>
<script src="/js/session.js"></script>
<script src="/js/authentication.js"></script>
{% if javascript is not empty %}
<script>
import("/js/core.js").then(() =>
import("/js/damper.js").then(() => {
const dependencies = setInterval(() => {
if (
typeof core === "function" &&
typeof core.damper === "function"
) {
clearInterval(dependencies);
clearTimeout(timeout);
initialization();
}
}, 10);
const timeout = setTimeout(() => {
clearInterval(dependencies);
initialization();
}, 5000);
function initialization() {
let _window;
{% for code in javascript %}
{{ code|raw }}
{% endfor %}
}
})
);
</script>
{% endif %}
{% endblock %}

View File

@ -26,5 +26,5 @@
{% endblock %}
{% block js %}
<script type="text/javascript" src="/js/menu.js"></script>
<script src="/js/menu.js"></script>
{% endblock %}