Some useful javascripts snippets from around the web...
$('a[href^="https://"]').not('a[href*=wp-mix]').attr('target','_blank');
function nativeShare() { shareURL = window.location.href; if (navigator.share) { navigator.share({ title: 'aatventure', text: 'Check this out!', url: shareURL, }) .then(() => console.log('Successful share')) .catch((error) => console.log('Error sharing', error)); } else // try sharing with whatsapp... currenturl = encodeURIComponent(window.location.href); url = "https://wa.me/?text="+currenturl; window.open(url,'_blank'); return false; }
window.addEventListener("orientationchange", function() { console.log("The orientation of the screen is: " + screen.orientation); });
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1) } Array.prototype.contains = function(v) { for(var i = 0; i < this.length; i++) {if(this[i] === v) return true} return false } Array.prototype.unique = function() { var arr = []; for(var i = 0; i < this.length; i++) {if(!arr.contains(this[i])) {arr.push(this[i])}} return arr } Number.prototype.pad = function (len) { return (new Array(len+1).join("0") + this).slice(-len); }