.
javascript
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;
}
javascript
<iframe width="100%" height="470" src="http://snipet.teknotit.com/index.php?embed=5bdf788df1935" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 04/11/2018
npm install version specifique d'un package
npm install <package_name>@version --save
npm install <package_name>@version --save-dev
javascript
https://docs.npmjs.com/getting-started/using-a-package.json
<iframe width="100%" height="254" src="http://snipet.teknotit.com/index.php?embed=5a842c7e684d7" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 14/02/2018
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>
css html javascript
<iframe width="100%" height="218" src="http://snipet.teknotit.com/index.php?embed=590a0fc01cf81" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 03/05/2017
jQuery insertAt
Y.eq(i).after(X);
inserer l'element X a la position i des fils de l'element Y
javascript
<iframe width="100%" height="236" src="http://snipet.teknotit.com/index.php?embed=58e19cf991749" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 03/04/2017
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++);
}
}();
javascript
<iframe width="100%" height="542" src="http://snipet.teknotit.com/index.php?embed=58d407e5d30a2" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 23/03/2017
Jqeury draggable probleme zoom (scale sur le parent)
Jqeury draggable probleme zoom (scale sur le parent)
javascript
http://jsfiddle.net/txvfgd99/
<iframe width="100%" height="200" src="http://snipet.teknotit.com/index.php?embed=58d2db5388f13" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 22/03/2017
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));
javascript
https://css-tricks.com/the-difference-between-throttling-and-debouncing/
<iframe width="100%" height="776" src="http://snipet.teknotit.com/index.php?embed=58cf6004af522" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 20/03/2017
Convertir un parametre url en entier
Number.isInteger(Number('1a')); //false;
Number.isInteger(Number('1')); //true;
javascript
<iframe width="100%" height="236" src="http://snipet.teknotit.com/index.php?embed=58b348e1668b9" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 26/02/2017
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>
javascript
https://www.espacevoiture.com/
<iframe width="100%" height="488" src="http://snipet.teknotit.com/index.php?embed=58af30a4c7fd4" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 23/02/2017
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>
html javascript
https://support.google.com/dcm/partner/answer/3145300?hl=en
<iframe width="100%" height="398" src="http://snipet.teknotit.com/index.php?embed=58a5145b776de" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 16/02/2017
SWip
http://codepen.io/meganos/pen/YNGQRB
css html javascript
http://codepen.io/meganos/pen/YNGQRB
<iframe width="100%" height="200" src="http://snipet.teknotit.com/index.php?embed=587c10d60a3a9" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 16/01/2017
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;
}
javascript
<iframe width="100%" height="488" src="http://snipet.teknotit.com/index.php?embed=56e3edccab3ac" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 12/03/2016
Effet Header sympa
Aussi la TYPO "Lato"
@import url(http://fonts.googleapis.com/css?family=Lato:300,400,700);
css inspiration javascript
http://tympanus.net/Development/HeaderEffects/
<iframe width="100%" height="254" src="http://snipet.teknotit.com/index.php?embed=561a2e3960efd" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 11/10/2015
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());
}
};
javascript
http://www.abeautifulsite.net/detecting-mobile-devices-with-javascript/
<iframe width="100%" height="542" src="http://snipet.teknotit.com/index.php?embed=55886445b8dda" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 22/06/2015
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;
}
javascript
chrome://resources/js/util.js
<iframe width="100%" height="524" src="http://snipet.teknotit.com/index.php?embed=556bf01fcef33" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 01/06/2015
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>
javascript
https://github.com/adactio/FitText.js
<iframe width="100%" height="290" src="http://snipet.teknotit.com/index.php?embed=544950465e2d8" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 23/10/2014
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
animation javascript
http://julian.com/research/velocity/#svg
<iframe width="100%" height="236" src="http://snipet.teknotit.com/index.php?embed=544812b5c291f" type="text/html"></iframe>
Texte seul - Permalink - Snippet public posté le 22/10/2014