the-admin 7 maanden geleden

Aatventure Useful Javascript Snippets | 2020 | Enjoy!

Some useful javascripts snippets from around the web! Enjoy!

If you want to target all links with href that point to a different domain to open in a new tab, try this jQuery code snippet:

Code
$('a[href^="https://"]').not('a[href*=wp-mix]').attr('target','_blank');

Native Sharing

Code
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; }

On Orientation Change

Code
window.addEventListener("orientationchange", function() { console.log("The orientation of the screen is: " + screen.orientation); });

Prototype Functions

Code
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); }
Admin
the-admin
0

Click for Web App Demo's!

Aat van Rees over 1 maand
0
# Progressive Web Apps

Aatventure | The Timetraveller ►Travel back in time...

The Time Traveler 1 week geleden
0
# Amazing

aatventure.news | scifi special

Must Watch 3 weken geleden
0
# Amazing

aatventure.news | espionage special

Must Watch 1 maand geleden
0

Aatventure MustWatch Top 25

Must Watch 1 maand geleden
0
# Web Development

Here We Code! | The GitHub Top 25

GitHub 1 maand geleden
0
# Progressive Web Apps

aatventure.news

Het Bandenhuis 9 maanden geleden
0
# Webtools

Aatventure Bench

The Editor 1 jaar geleden
0
# Music Madness

Depeche Mode | Enjoy the Silence (1990)

Music Video 30 jaar geleden