Skip to content

Instantly share code, notes, and snippets.

View nicordev's full-sized avatar

Nicolas Renvoisé nicordev

View GitHub Profile
@nicordev
nicordev / domKiller.js
Last active May 20, 2019 06:31
Hide or remove DOM elements of a page by clicking on it (left click: hide, middle + left button: remove)
var domKiller = {
hiddenElements: [],
activated: false,
/**
* Initialize and activate the remove action when clicking simultaneously on left and middle mouse button and the hide action when clicking on the left mouse button
*/
init: function () {
@nicordev
nicordev / basic_animator.js
Created May 17, 2019 13:16
Basic javascript object to animate DOM elements
/**
* Object containing methods to animate DOM elements
*
* @type {{rotate: animator.rotate, moveY: animator.moveY, moveX: animator.moveX}}
*/
var animator = {
/**
* Rotate a DOM element using CSS property transform and the deg unit
*
@nicordev
nicordev / calculateAzimuth
Created December 24, 2018 17:05
Calculate heading between 2 points knowing their longitude and latitude
/**
* Calcul l'azimut entre 2 points de coordonnées géographiques connues
* @param lat1 la latitude du point 1
* @param lng1 la longitude du point 1
* @param lat2 la latitude du point 2
* @param lng2 la longitude du point 2
* @return l'azimut en degrés (en anglais azimuth)
*/
function calculateAzimuth(lat1, lng1, lat2, lng2) {
@nicordev
nicordev / calculateDistanceLatLng
Created December 24, 2018 17:04
Calculate the distance between 2 points knowing their longitude and latitude
/**
* Retourne la distance entre 2 points avec des coordonnées géographiques en mètres ou kilomètres
* @param lat1 la latitude du point 1
* @param lng1 la longitude du point 1
* @param lat2 la latitude du point 2
* @param lng2 la longitude du point 2
* @param [unit] 'k' pour un résultat en kilomètre
* @return la distance en mètres ou kilomètres
*/
function calculateDistanceLatLng(lat1, lng1, lat2, lng2, unit = 'm') {
@nicordev
nicordev / create_or_get_element_by_id
Last active December 24, 2018 17:05
Create a DOM element if it does not exist already
/**
* Create a DOM element if it does not exist already
*
* @param {String} id the id of the element
* @param {String} eltTag HTML tag of the element
* @param {String} txtContent = '' the content of the element
* @return {DOM element} the DOM element
*/
function createOrGetElementById(id, eltTag, txtContent = '') {