Skip to content

Instantly share code, notes, and snippets.

View kernusr's full-sized avatar
🏠
Working from home

Artem Vasilev kernusr

🏠
Working from home
View GitHub Profile
@kernusr
kernusr / index.js
Last active July 7, 2019 12:02
Analogue of functions htmlspecialchars() and htmlspecialchars_decode() for JavaScript
function escapeHtml(text, decode = false) {
var map = decode ? {
'&' : '&',
'&lt;' : '<',
'&gt;' : '>',
'&quot;' : '"',
'&#039;' : "'"
} : {
'&': '&amp;',
'<': '&lt;',
@kernusr
kernusr / breadcrumbs.html
Created June 1, 2019 15:09
Breadcrumbs template for bitrix with schema org and use bootstrap 4
<nav class="breadcrumb px-0" aria-label="breadcrumb" itemprop="http://schema.org/breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList">
<div class="breadcrumb-item" id="breadcrumb_0" itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<a href="https://my.site/" content="https://my.site/" title="SITE NAME" itemprop="item">
<span itemprop="name">SITE NAME</span>
</a>
<meta itemprop="position" content="1">
</div>
<div class="breadcrumb-item" id="breadcrumb_1" itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<a href="https://my.site/root-section/" content="https://my.site/catalog/" title="ROOT SECTION NAME" itemprop="item">
<span itemprop="name">ROOT SECTION NAME</span>
@kernusr
kernusr / createMenuItem.php
Last active July 5, 2019 07:59
Programmatically add menu item in Joomla!
<?php
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Response\JsonResponse;
use Joomla\CMS\Table\Table;
protected function addMenuItem($data){
$app = Factory::getApplication();