This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable import/prefer-default-export */ | |
/** | |
* Create a setTimeout on demand | |
* See: https://www.joshwcomeau.com/snippets/react-hooks/use-timeout/ | |
*/ | |
import { MutableRefObject, useEffect, useRef } from 'react'; | |
export const useTimeout = (callback: () => void, delay: number): MutableRefObject<number> => { | |
const timeoutRef = useRef<number>(0); // not sure about this one 🙃 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, " ")); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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);})(); |