<![CDATA[Teknotit Snipet Manager tarfst: Snippets: javascript]]>http://snipet.teknotit.com/index.php <![CDATA[javascript Header Auth]]> $.ajax({ type: 'GET', url: 'url', dataType: 'json', //whatever you need beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', make_base_auth(user, password)); }, success: function () {}); }); function make_base_auth(user, password) { var tok = user + ':' + password; var hash = btoa(tok); return 'Basic ' + hash; }]]> Sun, 04 Nov 2018 22:54:21 +0000 <![CDATA[npm install version specifique d'un package]]> npm install <package_name>@version --save npm install <package_name>@version --save-dev ]]> Wed, 14 Feb 2018 12:43:12 +0000 <![CDATA[Chargement css sans bloquer le rendu]]> <link rel="stylesheet" href="style.css" media="none" onload="if(media!='all')media='all'"> <noscript><link rel="stylesheet" href="style.css"></noscript>]]> Wed, 03 May 2017 17:14:46 +0000 <![CDATA[jQuery insertAt]]> Y.eq(i).after(X); inserer l'element X a la position i des fils de l'element Y]]> Mon, 03 Apr 2017 00:55:28 +0000 <![CDATA[Static en javascript]]> function counter() { var count = 0; return function() { alert(count++); } } var count = counter(); count(); count(); count(); ou bien ca var Counter = function(){ var count =0; return function(){ console.log(count++); } }();]]> Thu, 23 Mar 2017 17:39:14 +0000 <![CDATA[Jqeury draggable probleme zoom (scale sur le parent)]]> Jqeury draggable probleme zoom (scale sur le parent)]]> Wed, 22 Mar 2017 20:15:57 +0000 <![CDATA[Exempel de variable static , function dans le retour]]> // Pratique au lieu setTimout function throttle(fn, threshhold, scope) { threshhold || (threshhold = 250); var last, deferTimer; return function() { var context = scope || this; var now = +new Date, args = arguments; if (last && now < last + threshhold) { clearTimeout(deferTimer); deferTimer = setTimeout(function() { last = now; fn.apply(context, args); }, threshhold); } else { last = now; fn.apply(context, args); } }; } Usage avance avec Underscore: $("body").on('scroll', _.throttle(function() { }, 100)); $(window).on('resize', _.debounce(function() { }, 100));]]> Mon, 20 Mar 2017 04:58:14 +0000 <![CDATA[Convertir un parametre url en entier ]]> Number.isInteger(Number('1a')); //false; Number.isInteger(Number('1')); //true;]]> Sun, 26 Feb 2017 21:31:07 +0000 <![CDATA[Auto link JS]]> <script type="text/javascript"> (function(){ if($('presentation')==null) return; $('presentation').set('html',(function(str, attributes){ attributes = attributes || {}; var attrs = ""; for(name in attributes) attrs += " "+ name +'="'+ attributes[name] +'"'; var reg = new RegExp("(\\s?)((http|https|ftp)://[^\\s<]+[^\\s<\.)])", "gim"); str = str.toString().replace(reg, '$1<a href="$2"'+ attrs +'>$2</a>'); return str; }($('presentation').get('html'),{"target":"_blank","rel":"nofollow"}))); })(); </script>]]> Thu, 23 Feb 2017 18:58:44 +0000 <![CDATA[clickTag DFP]]> <html> <head> <meta name="ad.size" content="width=300,height=250"> <script type="text/javascript"> var clickTag = "http://www.google.com"; </script> </head> [The rest of your creative code goes here.] </html> Make sure your creative uses the click tag variable as the click-through URL: <a href="javascript:window.open(window.clickTag)"> <img src="images/dclk.png" border=0> </a>]]> Thu, 16 Feb 2017 02:55:15 +0000 <![CDATA[SWip]]> http://codepen.io/meganos/pen/YNGQRB]]> Mon, 16 Jan 2017 00:17:20 +0000 <![CDATA[removeParam query string js version]]> function removeParam(key, sourceURL) { var rtn = sourceURL.split("?")[0], param, params_arr = [], queryString = (sourceURL.indexOf("?") !== -1) ? sourceURL.split("?")[1] : ""; if (queryString !== "") { params_arr = queryString.split("&"); for (var i = params_arr.length - 1; i >= 0; i -= 1) { param = params_arr[i].split("=")[0]; if (param === key) { params_arr.splice(i, 1); } } rtn = rtn + "?" + params_arr.join("&"); } return rtn; }]]> Sat, 12 Mar 2016 10:22:42 +0000 <![CDATA[Effet Header sympa]]> Aussi la TYPO "Lato" @import url(http://fonts.googleapis.com/css?family=Lato:300,400,700);]]> Sun, 11 Oct 2015 09:41:01 +0000 <![CDATA[Simple Mobile detection]]> var isMobile = { Android: function() { return navigator.userAgent.match(/Android/i); }, BlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i); }, iOS: function() { return navigator.userAgent.match(/iPhone|iPad|iPod/i); }, Opera: function() { return navigator.userAgent.match(/Opera Mini/i); }, Windows: function() { return navigator.userAgent.match(/IEMobile/i); }, any: function() { return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()); } };]]> Mon, 22 Jun 2015 19:40:50 +0000 <![CDATA[Creates a new URL by appending or replacing the given query key and value]]> /** * Creates a new URL by appending or replacing the given query key and value. * Not supporting URL with username and password. * @param {Location} location The original URL. * @param {string} key The query parameter name. * @param {string} value The query parameter value. * @return {string} The constructed new URL. */ function setQueryParam(location, key, value) { var query = parseQueryParams(location); query[encodeURIComponent(key)] = encodeURIComponent(value); var newQuery = ''; for (var q in query) { newQuery += (newQuery ? '&' : '?') + q + '=' + query[q]; } return location.origin + location.pathname + newQuery + location.hash; }]]> Mon, 01 Jun 2015 05:40:08 +0000 <![CDATA[FitText sans jquery ]]> FitText makes font-sizes flexible. Use this plugin script on your fluid or responsive layout to achieve scalable headlines that fill the width of a parent element. <script> window.fitText( document.getElementById("responsive_headline") ); </script>]]> Thu, 23 Oct 2014 19:05:54 +0000 <![CDATA[Animé un SVG , Velocity]]> Velocity is an animation engine that re-implements jQuery's $.animate() for significantly greater performance (making Velocity also faster than CSS animation libraries) while including several new features]]> Wed, 22 Oct 2014 20:28:14 +0000