View csp-generator.php
/** | |
* CSP Generator v0.2 (C) 2020-10-12 hnldesign.nl / Klaas Leussink | |
* @param array $rules | |
* Rules, specified as an array with rulesets (array) or rules (string). Note that 'hosts' are specified as an array inside the ruleset: | |
* note: it's easier to define hosts in the $domains array (see second param) | |
* array( | |
* 'default-src' => array ( | |
* 'self', | |
* 'data', | |
* 'unsafe-eval', |
View hnl.debounce.v4.js
/** | |
* JavaScript function prototype debouncer 4.1 - 2010-2020 hnldesign.nl - Klaas Leussink | |
* Demo: https://code.hnldesign.nl/demo/hnl.debounce.html | |
* | |
* Based on code by Paul Irish and the original debouncing function from John Hann | |
* http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ | |
* Register deBouncer as a function prototype. | |
* | |
* All debounced variants of the function (depending on the supplied debouncing parameters (see below) | |
* are stored inside a 'dbObj' Object inside the debounced function. |
View hnl.doubleClickTap.js
$(document).on('click', '#MyDoubleClickElement', function () { | |
var t = $(this), doubleClickInterval = 500; //set up base vars | |
var lastTouch = t.data('lastTouch') || 0, time = new Date().getTime(); //check when this element has been clicked last | |
t.data('lastTouch', time); //store this click time | |
if (time - lastTouch < doubleClickInterval && lastTouch !== 0) { //check if time between this and previous click exceeds the threshhold. If there is no last click registered, don't handle the callback | |
//do your stuff here (execute a callback) | |
alert("Double click!"); | |
} | |
}); |
View hnl.checkStuck.js
$.fn.checkStuck = function (className) { | |
$(this).each(function() { | |
var t = $(this); //preselect | |
t.toggleClass(className, (parseInt(t.css('top'), 10) === t[0].getBoundingClientRect().top)); | |
}); | |
} |
View hnl.debounce.v3.js
/** | |
* | |
* | |
* DEPRECATED, SEE NEW VERSION AT https://gist.github.com/c-kick/d359fce36257cf4c9fb5ea5f2c0033b6 | |
* | |
* | |
* JavaScript function prototype debouncer 3.0 - hnldesign.nl | |
* Based on code by Paul Irish and the original debouncing function from John Hann | |
* http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ | |
* Register deBouncer as a function prototype. |
View hnl.prime.js
/*! | |
* PRIME - Progressive-Responsive Image Enabler - v2.2.10 - 8/10/2020 | |
* http://code.hnldesign.nl/demo/hnl.prime.html | |
* | |
* Copyright (c) 2014-2020 HN Leussink | |
* Dual licensed under the MIT and GPL licenses. | |
* | |
* Example: http://code.hnldesign.nl/demo/hnl.prime.html | |
* | |
* Feature notes: |
View hnl.mobileConsole.js
/*! | |
* hnl.mobileConsole - javascript mobile console - v1.3.8 - 04/01/2021 | |
* Adds html console to webpage. Especially useful for debugging JS on mobile devices. | |
* Supports 'log', 'trace', 'info', 'warn', 'error', 'group', 'groupEnd', 'table', 'assert', 'clear' | |
* Inspired by code by Jakub Fiala (https://gist.github.com/jakubfiala/8fe3461ab6508f46003d) | |
* Licensed under the MIT license | |
* | |
* Changelog: | |
* 1.3.8 | |
* - fixed bug when logging numbers |
View hnl.isVisible.js
$.fn.isVisible = function() { | |
// Am I visible? | |
// Height and Width are not explicitly necessary in visibility detection, the bottom, right, top and left are the | |
// essential checks. If an image is 0x0, it is technically not visible, so it should not be marked as such. | |
// That is why either width or height have to be > 0. | |
var rect = this[0].getBoundingClientRect(); | |
return ( | |
(rect.height > 0 || rect.width > 0) && | |
rect.bottom > 0 && | |
rect.right > 0 && |
View hnl.taphover.js
//26-5-2020 update: possibly shorter, and better, since 'click' now fires on a tap, and is not prevented by the previous script. | |
//Also: more concatenation. | |
$(document).on('touchstart, click', 'a.taphover', function (e) { | |
if (!$(this).hasClass('hover')) { e.preventDefault(); } | |
$('.taphover').not($(this).toggleClass('hover')).removeClass('hover'); | |
}); | |
//the previous version: | |
//taphover - a solution to the lack of hover on touch devices. |
View hnl.collision.detection.js
/*! | |
* jQuery Collision Detection - v1.0 - 1/7/2014 | |
* http://www.hnldesign.nl/work/code/collision-prevention-using-jquery/ | |
* | |
* Copyright (c) 2014 HN Leussink | |
* Dual licensed under the MIT and GPL licenses. | |
* | |
* Example: http://code.hnldesign.nl/demo/hnl.collision.detection.html | |
*/ |
NewerOlder