Skip to content

Instantly share code, notes, and snippets.

@qwersk
qwersk / on_close_print.js
Created June 6, 2017 02:09
AFTER CLOSE PRINT WINDOW #JS #JAVASCRIPT
function close_print(){
var beforePrint = function() {
console.log('Functionality to run before printing.');
};
var afterPrint = function() {
//console.log('Functionality to run after printing');
$("#animal_menu, .single-subnav, #footer-credits-wrap, #mainpage-header, #print_button, .legend").show();
$(".park_map_page").css("width", 1170);
};
@qwersk
qwersk / element_view_counter.php
Created May 31, 2017 05:26
GET ELEMENT VIEW COUNTER #BITRIX
$view_counter = 0;
if(CModule::IncludeModule("iblock")){
CIBlockElement::CounterInc($item["ID"]);
$res = CIBlockElement::GetByID($item["ID"]);
if($ar_res = $res->GetNext()){
$view_counter = $ar_res['SHOW_COUNTER'];
}
}
@qwersk
qwersk / element_prop.php
Created May 31, 2017 04:41
GET ELEMENT PROPERTIES #BITRIX
<?php
$db_props = CIBlockElement::GetProperty($item["IBLOCK_ID"], $item["ID"], "sort", "asc", array());
$PROPS = array();
while($ar_props = $db_props->Fetch()){
$PROPS[$ar_props['CODE']] = $ar_props['VALUE'];
echo $PROPS[$ar_props['CODE']] . "<br />";
}
?>
@qwersk
qwersk / trim_char.js
Created May 24, 2017 03:00
TRIM CHAR IN STRING #JS #JAVASCRIPT
var x = '|f|oo||';
var y = x.replace(/^\|+|\|+$/g, '');
document.write(x + '<br />' + y);
@qwersk
qwersk / theme_options.php
Created May 18, 2017 13:56
CREATE THEME SETTINGS PAGE #WP #WORDPRESS
// https://www.sitepoint.com/create-a-wordpress-theme-settings-page-with-the-settings-api/
function theme_settings_page()
{
?>
<div class="wrap">
<h1>Настройка темы</h1>
<form method="post" action="options.php">
<?php
settings_fields("section");
@qwersk
qwersk / active_menu.js
Last active May 18, 2017 02:53
ACTIVE MENU ITEM ON SCROLL #JS #JAVASCRIPT #JQUERY
var sections = $('.content section')
, nav = $('.header-top')
, nav_height = nav.outerHeight();
$(window).on('scroll', function () {
var cur_pos = $(this).scrollTop();
@qwersk
qwersk / gist:7f07150582fb522c0a2a1a89d00acf3c
Created May 16, 2017 10:45
GET URL GET JAVASCRIPT JS
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null;
}
myvar = getURLParameter('myvar');
echo "<pre>";
print_r($this->_item->getRelatedCategories(true));
echo "</pre>";
@qwersk
qwersk / gist:bac01b4b378dece9867842e69c82fde1
Created April 5, 2017 05:44
EMAIL VALIDATION JAVASCRIPT
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
}
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo 'This is the front page';
}