Skip to content

Instantly share code, notes, and snippets.

View ArtemSites's full-sized avatar

Artem Kuznecov ArtemSites

View GitHub Profile
@ArtemSites
ArtemSites / component_epilog.php
Created August 6, 2019 09:59
Bitrix убрать $_GET['success'] из url и скрыть popup с фразой об успехе.
<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();
// include_once('./phpHtmlWriter.php');
global $APPLICATION;
if ($_GET['success'] != null) {
echo '
<script>
$(function() {
$(".callback-form_success").find(".mf-ok-text").text("'.$arResult["OK_MESSAGE"]. '");
$(".callback-form_success").css("display", "flex").show();
@ArtemSites
ArtemSites / init.php
Last active August 9, 2019 11:27
Bitrix. Добавление своего макроса #PHONE# к шаблону письма.
// /local/php_interface/init.php
// или
// /bitrix/php_interface/init.php
//После этого появляется макрос #PHONE# в шаблоне письма.
// Регистрируем обработчик
AddEventHandler("sale", "OnOrderNewSendEmail", "bxModifySaleMails");
//-- Собственно обработчик события
function bxModifySaleMails($orderID, &$eventName, &$arFields) {
// получаем телефон (или еще что-нибудь)
@ArtemSites
ArtemSites / header.php
Created August 14, 2019 11:18
Birtix Подключение разных файлов в зависимости от пути.
<? if (CSite::InDir('/rent/')) { ?>
<? include $_SERVER['DOCUMENT_ROOT'] . '/include/phone_sale.php' ?>">
<? $APPLICATION->IncludeComponent(
"bitrix:main.include",
"",
Array(
"AREA_FILE_SHOW" => "file",
"AREA_FILE_SUFFIX" => "inc",
@ArtemSites
ArtemSites / script.php
Last active March 19, 2022 10:18
PHP преобразование числа к удобному формату (денежному).
<?
//https://www.php.net/manual/ru/function.number-format.php
$oldPrice = number_format($oldPrice, 0, '', ' '); 400999 -> 400 999
$oldPrice = number_format($oldPrice, 2, ',', ' '); 400999 -> 400 999,00
?>
@ArtemSites
ArtemSites / index.html
Created August 20, 2019 12:32
Ссылка "Вернуться назад"
<a href="www.mypage.com" onclick="window.history.go(-1); return false;"> Link </a>
@ArtemSites
ArtemSites / grid.css
Last active August 21, 2019 13:43
Grid для IE.
.block_product .block__body {
display: -ms-grid;
display: grid;
-ms-grid-columns: 100%; /* для малых разрешений */
grid-template-columns: 1fr;
grid-gap: 20px;
}
.productCard {
margin-bottom: 20px;/* вместно row gap для ie */
}
@ArtemSites
ArtemSites / script.php
Created August 27, 2019 10:00
PHP функция мультирасчленения строки в массив по любому набору вхождений подстрок.
function multiexplode ($delimiters,$string) {
$ready = str_replace($delimiters, $delimiters[0], $string);
$launch = explode($delimiters[0], $ready);
return $launch;
}
$text = "here is a sample: this text, and this will be exploded. this also | this one too :)";
$exploded = multiexplode(array(",",".","|",":"),$text);
@ArtemSites
ArtemSites / index.html
Last active June 11, 2021 13:28
Прелоадер с высчитыванием процента загрузки
<body>
<!-- Анимированный лоадер -->
<div id="preloaderWrapper">
<div id="preloader">
<video autoplay loop id="videoPlayer">
<source src='<?=SITE_TEMPLATE_PATH."/assets/preloader.mp4"?>' type="video/mp4">
<source src='<?=SITE_TEMPLATE_PATH."/assets/preloader.mov"?>' type="video/mp4">
</video>
@ArtemSites
ArtemSites / index.html
Created September 7, 2019 10:18
SVG_circle_progress_bar
<svg class="progress-bar" width="120" height="120">
<circle class="progress-bar__circle" stroke="#ff6e00" stroke-width="4" cx="60" cy="60" r="52" fill="transparent"/>
</svg>
<input type="number" id="inputPercent" value="0">
@ArtemSites
ArtemSites / script.js
Last active October 9, 2022 11:05
Счетчик - таймер с выводом на экран | Counter - timer with display
initTimer(0, sectionStats3End, 2000, sectionStats3, '', ' лет');
function initTimer(start, end, duration, objTarget, prefix = false, postfix = false) {
timer();
function timer() {
let interval = Math.round(duration / Math.abs(start-end));
let timerName = setInterval(function() {
if (start>end) {
if (start <= end) {
clearInterval(timerName);