Skip to content

Instantly share code, notes, and snippets.

@s2ar
s2ar / setInterval.js
Created December 13, 2016 22:20
setInterval.js
var btn = $('#set_filter_price');
var myVar = setInterval(function(){
checkBtnFilter();
}, 50);
function checkBtnFilter() {
if(!btn.prop('disabled')){
btn.click();
//console.log(btn)
@s2ar
s2ar / bitrix highloadblock all items.php
Last active November 11, 2016 07:11
bitrix highloadblock all items
<?php
// Взято с http://thisis-blog.ru/elementi-highload-bloka/#compl
// подключаем пространство имен класса HighloadBlockTable и даём ему псевдоним HLBT для удобной работы
use Bitrix\Highloadblock\HighloadBlockTable as HLBT;
//подключаем модуль highloadblock
CModule::IncludeModule('highloadblock');
//Напишем функцию получения экземпляра класса:
@s2ar
s2ar / prev_next.php
Last active September 29, 2016 07:45
bitrix. prev and next link
<?php
/*
$cp = $this->__component; // объект компонента
if (is_object($cp)) {
$cp->arResult['NAV_RESULT'] = $arResult['NAV_RESULT'];
$cp->SetResultCacheKeys(Array('NAV_RESULT'));
}
*/
@s2ar
s2ar / num2word.php
Created August 26, 2016 09:58
Преобразование количества "цифрой" в количество "словом"
<?php
/**
* Преобразование количества "цифрой" в количество "словом"
* Чтобы было удобнее формировать массивы со склонениями, запомните ряд чисел 1-2-5,
* а потом мысленно подставляйте их в массив: (один "рубль", два "рубля", пять "рублей")
* $num = 3;
* $words = array('новость', 'новости', 'новостей');
* echo $num . ' ' . num2word($num, $words); // сколько новостей
*
* @param $n
@s2ar
s2ar / .htaccess_index
Created July 28, 2016 06:11
Redirect from index.php to
# Redirect from index.php to /
RewriteCond %{THE_REQUEST} index.php [NC]
RewriteCond %{REQUEST_URI} !/bitrix/admin/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
@s2ar
s2ar / convertPHPSizeToBytes.php
Created June 21, 2016 11:09
Максимальный размер загружаемого файла
<?php
function convertPHPSizeToBytes($sSize)
{
if ( is_numeric( $sSize) ) {
return $sSize;
}
$sSuffix = substr($sSize, -1);
$iValue = substr($sSize, 0, -1);
switch(strtoupper($sSuffix)){
case 'P':
@s2ar
s2ar / file.info.php
Last active June 21, 2016 11:08
bitrix. Get file info
<?php
function formatBytes($bytes, $precision = 2)
{
$base = log($bytes, 1024);
$suffixes = array('', 'Кбайт', 'Мбайт', 'Гбайт', 'Тбайт');
return round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)];
}
if(is_numeric($aProps['cr_pdf']['VALUE'])){
@s2ar
s2ar / scroll.map.js
Created June 13, 2016 07:59
Disable scroll google maps
// Disable scroll zooming and bind back the click event
var onMapMouseleaveHandler = function (event) {
var that = $(this);
that.on('click', onMapClickHandler);
that.off('mouseleave', onMapMouseleaveHandler);
//that.find('iframe').css("pointer-events", "none");
that.find('#map-wrapper').css("pointer-events", "none");
}
@s2ar
s2ar / cluster.icon.add.js
Last active June 10, 2016 06:54
Оформление иконки кластера (markerclustererplus library)
/**
* Adding the cluster icon to the dom.
* @ignore
*/
ClusterIcon.prototype.onAdd = function() {
this.div_ = document.createElement('DIV');
if (this.visible_) {
var pos = this.getPosFromLatLng_(this.center_);
this.div_.style.cssText = this.createCss(pos);
@s2ar
s2ar / sort.php
Last active May 23, 2016 09:24
Множественная сортировка
<?php
/*
http://wp-kama.ru/question/php-usort-sortirovka-massiva-po-dvum-polyam
* Сортировка массива по двум параметрам с помощью usort()
*/
function _usort_object_by_time_ms($a, $b){
// поля по которым сортировать
$array = array( 'laps'=>'desc', 'time_ms'=>'asc' );