This file contains 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
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<script> | |
(function(g,f,j,i,h){$(window).on("load",function(){i=0;$("["+g+"]").each(function(){function a(b){h=b.attr(f);if(b.attr(g)=="style"){b.css("background-image","url("+h+")")}else{b[0].src=h}}setTimeout(a,++i*j,$(this))})})})( | |
"data-lazyLoading", // attribute for type | |
"data-src", // attribute for src | |
100 // delay in milliseconds | |
); | |
</script> | |
<img data-lazyLoading data-src="https://frydlewicz.pl/photo/Warszawa/DSC07655.jpg" alt> | |
<div data-lazyLoading="style" data-src="https://frydlewicz.pl/photo/Warszawa/DSC07644.jpg"></div> |
This file contains 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
(function(g,e,c){if(typeof g!="function"){return}var d=false;var f=0;var b=function(){var h=(new Date).getTime();if(d&&(f==0||e&&h-f>c)){document.removeEventListener("mouseleave",b);f=h;g()}};var a=function(j){var h=innerHeight/10;var i=j.movementY;var k=j.clientY;if(i<0&&k<h){d=true;document.addEventListener("mouseleave",b)}else{document.removeEventListener("mouseleave",b);d=false}};document.addEventListener("mousemove",a)})( | |
function () { // callback function | |
alert("Do not leave!") | |
}, | |
true, // repeat calling | |
5000 // interval in milliseconds | |
); |
This file contains 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
export default class Queue<T> { | |
private readonly maxSize: number; | |
private readonly loop: boolean; | |
private readonly data: T[]; | |
private size!: number; | |
private toProduce!: number; | |
private toConsume!: number; | |
constructor(maxSize: number, loop: boolean = false) { |
This file contains 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
export default class Stack<T> { | |
private readonly maxSize: number; | |
private readonly loop: boolean; | |
private readonly data: T[]; | |
private pos!: number; | |
constructor(maxSize: number, loop: boolean = false) { | |
if (!Number.isInteger(maxSize) || maxSize < 1) { | |
throw new Error('Invalid parameter'); |
This file contains 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
export interface IObject { | |
[key: string]: any; | |
} | |
export function cloneObject(source: IObject, maxDeep: number = Infinity): IObject { | |
if (typeof source !== 'object') { | |
throw new Error('Argument must be an object'); | |
} | |
const refs = new WeakMap<IObject, IObject>(); | |
const dest: IObject = {}; |