Skip to content

Instantly share code, notes, and snippets.

View dzenkovich's full-sized avatar

Denis Zenkovich dzenkovich

  • Minsk, Belarus
View GitHub Profile
@dzenkovich
dzenkovich / queue.js
Created October 21, 2013 07:43
JS Core: Task 5. Requests Queue.
/**
* This self-invoking anonymous function consists of:
* - onload finction, which cotains functions that are responsible for the logic of click event handling on the Switch button
* - the helper function for adding event listeners;
* - the RequestsQueue constructor: impelements the dymanic queue
*
* It encloses variables and functions in it's scope and helps us keep them out of Global
* This is the most simple scenario of Module pattern.
*
* Working process: by clicking the button on the page, the requests start generating. The amount of requests in the bunch is a random number (from 1 to 3).
@dzenkovich
dzenkovich / dom_sniffer.js
Created October 21, 2013 07:41
JS Core: Task 4. Objects Session
/**
* This self-invoking anonymous function consists of:
* - DOM_Sniffer which inspects the DOM of the page;
* - the helper function for adding event listeners;
* - the InfoBlock constructor: the element which contains data of sniffed object
*
* It encloses variables and functions in it's scope and helps us keep them out of Global
* This is the most simple scenario of Module pattern.
*
*/
@dzenkovich
dzenkovich / currency_converter.js
Created October 21, 2013 07:39
JS Core: Task 3. Currency Converter
/**
* This self-invoking anonymous function consists of:
* - the object currencyConverterTool, which is responsible for conversion of usd values into euro values and displaying the result in the tooltip;
* - the helper function for adding event listeners;
* - the Tooltip constructor.
* It encloses variables and functions in it's scope and helps us keep them out of Global
* This is the most simple scenario of Module pattern.
*/
(function(){
@dzenkovich
dzenkovich / set_session_obj.js
Created October 21, 2013 07:37
JS Core: Task 2. Objects Session
(function () {
//initializing an object to add to session storage or cookies
var person = {
name: 'Anastasia',
lastname: 'Tayanovskaya',
birth: {
day: 10,
month: 'September',
year: 1989
}
@dzenkovich
dzenkovich / get_session_obj.js
Created October 21, 2013 07:35
JS Core: Task 2. Objects Session
(function () {
/**
* Gets the object value from the session storage or cookies and displays the result
*/
window.onload = function() {
var resultBox = document.getElementById('result'), //gets the DOM element where results are stored
key = 'person', // the key name of the object
result = sessionDataManager.getObject(key); //gets the value of the object from session storage or from cookies
// appends the reult to the resultBox element
@dzenkovich
dzenkovich / gist:7079765
Created October 21, 2013 07:10
JS Core: Task 1. Autocomplete.
/**
* This self-invoking anonymous function contains the json object with attendees' names,
* the helper function for adding event listeners and the Autocomplete constructor.
* It encloses variables and functions in it's scope and helps us keep them out of Global
* This is the most simple scenario of Module pattern.
*/
(function(){
//json object
var attendeesJSON = {
@dzenkovich
dzenkovich / slider.js
Created June 19, 2013 11:38
Very simple upgrade to very simple basic 'slider' bar in JavaScript and CSS :) originating from this gist https://gist.github.com/kosso/1118840
var Slider = function(options){
var bar,
slider,
toggle,
percent,
that = this;
function _init(options){
_construct();
@dzenkovich
dzenkovich / blur-ranges.js
Created June 11, 2013 10:41
Canvas Animation - Ranges
Blur.prototype.burn_ = function () {
var time = (new Date()).getTime();
var width = this.image.width;
var height = this.image.height;
if (!this.lastTime) this.lastTime = time;
//Light up
if (this.dragging) {
var centerX = this.drag.coords.x - this.element_.offsetLeft;
var centerY = this.drag.coords.y - this.element_.offsetTop;
@dzenkovich
dzenkovich / blur-array.js
Created June 11, 2013 10:40
Canvas Animation - Arrays
Blur.prototype.burn_ = function () {
var time = (new Date()).getTime();
var width = this.image.width;
var height = this.image.height;
if (!this.lastTime) this.lastTime = time;
if (this.dragging) {
var points = this.getAndProcessAffected();
//var edgePoints = [];
@dzenkovich
dzenkovich / blur-run-through.js
Created June 11, 2013 10:37
Canvas Animation - Run Through
Blur.prototype.burn_ = function () {
var time = (new Date()).getTime();
var width = this.image.width;
var height = this.image.height;
if (!this.lastTime) this.lastTime = time;
if (this.dragging) {
var points = this.getAndProcessAffected();
//var edgePoints = [];