Skip to content

Instantly share code, notes, and snippets.

View wayferer's full-sized avatar
🧙‍♂️
Working from home

Abdullah Norozi Iranzad wayferer

🧙‍♂️
Working from home
View GitHub Profile
@wayferer
wayferer / js.js
Created February 3, 2014 21:16
catch window errors
window.onerror = function(a,b,c) {
alert(a + "; " + b + "; " + c);
}
@wayferer
wayferer / js.js
Created February 3, 2014 21:15
phonegap check if Android or iOS
function isAndroid(){
return navigator.userAgent.toLowerCase().indexOf("android") > -1;
}
isAndroid();
function isIOS(){
return navigator.userAgent.match(/(iPad|iPhone|iPod)/i) != null;
}
isIOS();
@wayferer
wayferer / html.html
Created January 31, 2014 15:41
In order to enable :hover / :active states in touch devices
<body ontouchstart="">
@wayferer
wayferer / helpers.js
Last active February 5, 2019 21:57
My default set of JS helpers
function zQ(selector){return document.querySelector(selector);}
function zQA(selector){return document.querySelectorAll(selector);}
function zAddClass(el,className){
if(el === null) { return; }
if(!((' '+el.className+' ').indexOf(' '+className+' ')>-1)){el.className+=' '+className;}
}
function zHasClass(el,className){
//if((' '+el.className+' ').indexOf(' '+className+' ')>-1){return true;}
//else{return false;}
return new RegExp(' '+className+' ').test(' '+el.className+' ');
@wayferer
wayferer / ellipsis.js
Created January 30, 2014 16:45
a way to add multi-line ellipsis
function zAddMulilineEllipsis(el,container,maxHeight){
var tag,tagHeight,tagContentHeight;
tag=el;
tagContentHeight=tag.scrollHeight;
if(maxHeight===undefined){tagHeight=tag.offsetHeight;}else{tagHeight=maxHeight;}
if(tagContentHeight>tagHeight){
if(container=='parent'){zAddClass(tag.parentNode,'applyEllipsis');}
else if(container=='self'){zAddClass(tag,'applyEllipsis');}
}
}
@wayferer
wayferer / 0_reuse_code.js
Created January 30, 2014 16:35
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console