Skip to content

Instantly share code, notes, and snippets.

View haroldao's full-sized avatar
🎯
Design + Dev

Harold AO haroldao

🎯
Design + Dev
View GitHub Profile
<!-- /snippets/schema-markup.liquid -->
<script type="application/ld+json">
{%- if template == 'index' -%}
{
"@context": "http://schema.org",
"@type": "WebSite",
"name": "{{ shop.name }}",
"alternateName": "{{ shop.description }}",
"url": "{{ shop.url }}"
@haroldao
haroldao / Schema Product Page - Shopify (product.liquid)
Last active December 19, 2020 16:59
Schema Product Page - Shopify (product.liquid)
{% assign current_variant = product.selected_or_first_available_variant %}
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": {{ product.title | json }},
"url": {{ shop.url | append: product.url | json }},
{%- if product.featured_media -%}
{%- assign media_size = product.featured_media.preview_image.width | append: 'x' -%}
<!-- Disable keyboard keys -->
<script>
document.onkeydown = function(e) {
return false;
}
</script>
<!-- Disable images drag -->
<script>
window.ondragstart = function() {
function checkBrowserVersion() {
var objappVersion = navigator.appVersion;
var objAgent = navigator.userAgent;
var objbrowserName = navigator.appName;
var objfullVersion = ''+parseFloat(navigator.appVersion);
var objBrMajorVersion = parseInt(navigator.appVersion,10);
var objOffsetName,objOffsetVersion,ix;
// In Chrome
if ((objOffsetVersion=objAgent.indexOf("Chrome"))!=-1) {
<HTML>
<HEAD>
<!-- anti-flicker snippet (recommended) -->
<style>.async-hide { opacity: 0 !important} </style>
<script>(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date;
h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
(a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;
})(window,document.documentElement,'async-hide','dataLayer',4000,
{'CONTAINER_ID':true});</script>
@haroldao
haroldao / functions.scss
Created July 9, 2021 16:02
px to em/rem | SCSS
// Source: https://css-tricks.com/snippets/sass/px-to-em-functions/
@function rem($pixels, $context: 16) {
@return (math.div($pixels, $context)) * 1rem;
}
@haroldao
haroldao / is_touch_device.js
Created November 9, 2021 12:32
Check if is touch device
function is_touch_device() {
return 'ontouchstart' in window // works on most browsers
|| 'onmsgesturechange' in window; // works on ie10
};
// check device
let isMobile = false;
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
isMobile = true;
document.body.classList.add('is-mobile');
}
@haroldao
haroldao / external-link.liquid
Created September 11, 2022 01:45
Shopify liquid - Know if a link is an external link