Skip to content

Instantly share code, notes, and snippets.

💭
👾

Adrien Rahier aegiz

💭
👾
Block or report user

Report or block aegiz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Get data from a json with Jquery
$.getJSON( "./assets/json/tree.json")
.done(function( data ) {
// do something
// ...
})
.fail(function( data ) {
console.log(data.responseText);
});
@aegiz
aegiz / ajax request
Created Mar 31, 2017
Make AJAX request with Jquery
View ajax request
var callAjax = function(url, type, data, callback) {
$.ajax({
url: url,
type: type,
data: data,
success: function(result) {
if(callback) {
callback(result);
}
}, error: function(MLHttpRequest, textStatus, errorThrown) {
View Checking conditions
/*
* Check if the different fields are valid
* @param {Object} fields.onMailContainer.warningMsgContainer: container to display warning message
* @param {Object} fields.onMailContainer.mail: mail to check
* @param {Object} fields.onPhoneContainer.warningMsgContainer: container to display warning message
* @param {Object} fields.onPhoneContainer.maphoneil: phone to check
* @param {Object} fields.onCheckContainer.container: container to display warning message
* @param {Object} fields.onCheckContainer.check: checkbox to check (oh oh)
* ...
* @return {Boolean} passedCheck : return true if successfully passed tests. Else return false
View gist:04cd8f3a756082a479c784b46cfc7af4
var getQueryParams = function(param){
param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+param+"=([^&#]*)",
regex = new RegExp( regexS ),
results = regex.exec( window.location.href);
return results === null ? false : decodeURIComponent(results[1].replace(/\+/g, " "));
};
@aegiz
aegiz / countAngulatWatchers.js
Last active Nov 7, 2015
Count angular watchers (type this in your console)
View countAngulatWatchers.js
javascript:(function () { var root = angular.element(document.getElementsByTagName('body')[0]); var watchers = []; var f = function (element) { if (element.data().hasOwnProperty('$scope')) { angular.forEach(element.data().$scope.$$watchers, function (watcher) { watchers.push(watcher); }); } angular.forEach(element.children(), function (childElement) { f(angular.element(childElement)); }); }; f(root); alert(watchers.length);})();
@aegiz
aegiz / enableDisableScroll.js
Last active Oct 8, 2018
Enable disable scroll on mobile (in vanilla js).
View enableDisableScroll.js
var _playWithScroll = function(disableScroll) {
var xStart, yStart = 0;
if (disableScroll) {
$(document).bind('touchstart', function(e) {
xStart = e.originalEvent.touches[0].screenX;
yStart = e.originalEvent.touches[0].screenY;
});
$(document).bind('touchmove', function(e) {
var xMovement = Math.abs(e.originalEvent.touches[0].screenX - xStart);
var yMovement = Math.abs(e.originalEvent.touches[0].screenY - yStart);
You can’t perform that action at this time.