|
Ok!
|
|
|
Ok!
|
---|---|---|---|---|
264 | <script src="https://cdn.jsdelivr.net/npm/@fancyapps/[email protected]/dist/fancybox/fancybox.umd.js"></script> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/[email protected]/dist/fancybox/fancybox.css" /> <script type="text/javascript"> Fancybox.bind("a.fancybox", { // Your custom options }); </script> | fancybox | 0 | New fancybox 5 |
4 | Character Meaning Example . Matches any single character – c.t will match cat, cot, cut, etc. + Repeats the previous match one or more times – a+ matches a, aa, aaa, etc * Repeats the previous match zero or more times. – a* matches all the same things a+ matches, but will also match an empty string. ? Makes the match optional. colou?r will match color and colour. ^ Called an anchor, matches the beginning of the string ^a matches a string that begins with a $ The other anchor, this matches the end of the string. a$ matches a string that ends with a. ( ) Groups several characters into a single unit, and captures a match for use in a backreference. (ab)+ matches ababab - that is, the + applies to the group. For more on backreferences see below. [ ] A character class - matches one of the characters c[uoa]t matches cut, cot or cat. [^ ] Negative character class - matches any character not specified c[^/]t matches cat or c=t but not c/t | регулярные выражения, regexp | 10 | Значения символов регулярного выражения |
1 | function rus2translit($string) { $converter = array( 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'e', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'y', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sch', 'ь' => 'j', 'ы' => 'y', 'ъ' => 'j', 'э' => 'e', 'ю' => 'yu', 'я' => 'ya', 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'E', 'Ж' => 'Zh', 'З' => 'Z', 'И' => 'I', 'Й' => 'Y', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sch', 'Ь' => 'j', 'Ы' => 'Y', 'Ъ' => 'j', 'Э' => 'E', 'Ю' => 'Yu', 'Я' => 'Ya', ' ' => '_', '№' => 'No' ); return strtr($string, $converter); } function str2url($str) { $str = rus2translit($str); $str = strtolower($str); $str = preg_replace('~[^-a-z0-9_]+~u', '-', $str); $str = trim($str, "-"); return $str; } | translit, транслит, php | 15 | Транслит |
20 | :root { font-size: calc(1vw + 1vh + .5vmin); } Now you can utilize the root em unit based on the value calculated by :root: body { font: 1rem/1.6 sans-serif; } | css, шрифт, адаптивно | 20 | Установка размера шрифта в CSS адаптивно изменяющегося к любой ширине экрана |
9 | CModule::IncludeModule("iblock"); $res = CIBlockElement::GetByID(273); if($obRes = $res->GetNextElement()) { $ar_mir = $obRes->GetProperty("href_mir"); $ar_gil = $obRes->GetProperty('href_gil'); echo $ar_mir['VALUE']['TEXT']; echo $ar_gil['VALUE']['TEXT']; } | битрикс, свойство блока, свойство инфоблока, свойство, инфоблок | 29 | Получить свойство инфоблока по ID элемента |
5 | function cmp($a,$b){ return strtotime($a['PROPERTY_DATER_VALUE'])<strtotime($b['PROPERTY_DATER_VALUE']); } usort($item_happ,"cmp"); | функция, сравнение дат, даты, php | 30 | Пример функции сравнения в php |
6 | foreach($quest['METRO'] as $n => $station) echo ($n > 0 ? ', ' : '').$station['VALUE_ENUM']; | через запятую, массив, элементы | 40 | Элементы массива, выводимые через запятую. Очень элегантное решение |
28 | function mail_utf8($to, $from_user, $from_email, $subject = '(No subject)', $message = '') { $from_user = "=?UTF-8?B?".base64_encode($from_user)."?="; $subject = "=?UTF-8?B?".base64_encode($subject)."?="; $headers = "From: $from_user <$from_email> ". "MIME-Version: 1.0" . " " . "Content-type: text/plain; charset=UTF-8" . " "; return mail($to, $subject, $message, $headers); } | utf-8, mail, php | 90 | Функция mail utf-8 |
56 | time = new Date().getHours() + ":" + new Date().getMinutes() | время, яваскрипт, время сейчас, js, time now, time | 90 | Время сейчас — часы : минуты |
68 | <img src="fake.jpg" data-src="real.jpg"/> <script> function init() { var imgDefer = document.getElementsByTagName('img'); for (var i=0; i<imgDefer.length; i++) { if(imgDefer[i].getAttribute('data-src')) { imgDefer[i].setAttribute('src',imgDefer[i].getAttribute('data-src')); } } } window.onload = init; </script> | defer, images | 90 | Отложенная загрузка изображений после загрузки страницы |
131 | <? $APPLICATION->IncludeFile( SITE_TEMPLATE_PATH . "/bespl_kons.php", Array(), Array( "MODE" => "html" ) ); ?> | include, bitrix, включаемая область | 90 | Вставка включаемой области из html файла в Битрикс |
165 | <link rel="canonical" href="<?= substr(strtolower($_SERVER['REQUEST_URI']), 0, strrpos($_SERVER['REQUEST_URI'], '/') + 1) ?>"/> | каноникал, canoncal | 90 | Сделать rel каноникал в php |
3 | setlocale( LC_ALL, "ru_RU.UTF-8" ); strftime("%A %e %B %Y", mktime(0, 0, 0, 1, 1, 2016)); | дата по-русски, php дата | 100 | Вывод даты в php в русской локали |
12 | $items_sel = (new CIBlockElement())->GetList([], $filter, 0, 0, ['ID']); $arResult['ITEMS_SELECTED'] = $items_sel->SelectedRowsCount(); if(!$arResult['ITEMS_SELECTED']) $ids = []; else while($item = $items_sel->Fetch()) $ids[] = $item['ID']; | select, iblock, bitrix | 100 | Выбор айблоков в Битрикс |
19 | К картинкам <img src="/img/eyes-l.jpg" srcset="/img/eyes-m.jpg 1x, /img/eyes.jpg 2x" alt="Глаза" height="375" width="500" data-p="/img/eyes.jpg"> <a href="#" rel="prefetch">Ссылка</a> | srcset, prefetch | 100 | srcset для изображений, предпросмотр для ссылок |
31 | $rsUser = CUser::GetByID($arPost["AUTHOR_ID"]); $arUser = $rsUser->Fetch(); echo CFile::ShowImage($arUser['PERSONAL_PHOTO'], 98, 98, 'border=0', '', true); | фото пользователя, битрикс | 100 | Вывод фотки пользователя Битрикс |
39 | var docWidth = document.documentElement.offsetWidth; [].forEach.call( document.querySelectorAll('*'), function(el) { if (el.offsetWidth > docWidth) { console.log(el); } } ); | консоль, выступающих, horizontal scroll, поиск в консоли | 100 | Функция поиска выступающих за пределы ширины элементов в консоли Хром |
64 | function ProductsFilter(a) { var products = $('.catalog-item'); $.each(products, function () { if($(this).find('.catalog-item-name').text().indexOf(a) > -1){ $(this).prependTo($(".catalog-items-container")); } else{ $(this).remove() } }); } | товары, фильтр, jquery | 100 | jQuery фильтр по товарам |
70 | <div><a href="https://api.whatsapp.com/send?phone=79096414345" class="whatsapp"><img src="https://upload.wikimedia.org/wikipedia/commons/6/6b/WhatsApp.svg" width="20"></a></div> <div><a href="viber://contact?number=%2B79096414345" class="viber"><img src="https://seeklogo.com/images/V/viber-logo-02B562CBA7-seeklogo.com.png" width="18"></a></div> | viber, whatsapp | 100 | Вацбер и Вотсап ссылки для сайта |
72 | .modal { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } | absmiddle,center screen, center position | 100 | Центрировать блок по середине экрана по высоте и ширине |