Skip to content

Instantly share code, notes, and snippets.

View Witiko's full-sized avatar

Vít Starý Novotný Witiko

  • Brno, Czech Republic
View GitHub Profile
@Witiko
Witiko / SexyDollar+.js
Created September 6, 2013 11:03
A simple DOM query library with some added complexity
/*
SexyDollar Extended library by Witiko
Function $()
1st argument: "tagName", "#id", ".className", "tagName.className", "@name", "tagName@name"
2nd argument: Array / NodeList / Element parentElement (optional)
*/
@Witiko
Witiko / SexyDollar.js
Created September 6, 2013 11:02
A simple DOM query library
/*
SexyDollar library by Witiko
Function $()
1st argument: "tagName", "#id", ".className", "tagName.className", "@name", "tagName@name"
2nd argument: parentElement (optional)
*/
@Witiko
Witiko / Comp.js
Created September 6, 2013 11:01
A set of useful functions I've created over the years of my javascript programming
/*
Compatible Now! ~ Vít Novotný 2009 - 2011
Requires:
* Ecma5.js
*/
(function(Array, String, undefined) {
@Witiko
Witiko / Screen.js
Created September 6, 2013 11:00
An event-based screen dimensions library
/*
Screen library
Copyright (C) 2010 Vít Novotný
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@Witiko
Witiko / DayTime.js
Created September 6, 2013 10:59
An event-based library calculating the sunrise and sunset times.
var DayTime; (function() {
var DAWN = 0, // Function flags
DUSK = 1,
DAY = 0, // Status flags
NIGHT = 1;
DayTime = function(latitude, longitude) {
if(latitude === undefined ||
longitude === undefined)
throw new Error("Define both the latitude and longitude!");
@Witiko
Witiko / Object2.js
Last active December 22, 2015 10:59
A user-defined Object2 object adding the support of multiple prototypal inheritance.
function Object2() {
this.prototypes = arguments;
this.attributes = {};
}; Object2.prototype.get = function(key) {
return this.attributes[key] || (function(array) {
for(var i = 0, l = array.length, result; !result && i < l; i++)
result = array[i].get(key); return result;
})(this.prototypes);
}; Object2.prototype.set = function(key, value) {
this.attributes[key] = value;
@Witiko
Witiko / Points.js
Created September 6, 2013 10:50
A function that calculates the distance, gradient and bearing of a path between two points on the Earth. Requires the Math.js library because of the Number.prototype.* calls.
function Points(lat1, lon1, alt1,
lat2, lon2, alt2) {
alt1 = alt1 / 1000 || 0;
alt2 = alt2 / 1000 || 0;
var dLat = (lat2 - lat1).degToRad(),
dLon = (lon2 - lon1).degToRad(),
dAlt = alt2 - alt1;
lat1 = lat1.degToRad();
lat2 = lat2.degToRad();
lon1 = lon1.degToRad();
@Witiko
Witiko / Gotten.js
Created September 6, 2013 10:47
An interfacing library for the ecma5 or mozilla getter and setter support - whichever is implemented
var Accessors = (function($, undefined) {
var ECMA5Support =
Object.getOwnPropertyDescriptor instanceof Function &&
Object.defineProperty instanceof Function && (function() {
var o = {}, f = function() {return true};
try {
Object.defineProperty(o, "o", {get: f});
return o.o && Object.getOwnPropertyDescriptor(o, "o").get === f;
} catch(e) {
return false;
@Witiko
Witiko / Ecma5.js
Created September 6, 2013 10:44
A library adding support of various ecma5 functions to an ecma3-compliant interpreter
(function(global, isNaN, undefined) {
var arrLikeString = !!"1"[0], has, get;
if(!arrLikeString) {
has = function(arr, item, isStr) {
return isStr?item < arr.length:
item in arr;
};
get = function(arr, item, isStr) {
return isStr?arr.charAt(item):arr[item];
@Witiko
Witiko / Overload.js
Created September 6, 2013 10:33
A simple library adding the function overloading capability to javascript
Function.overload = function(f) {
if(!(f instanceof Function)) return;
var _$ = function() {
var $ = [arguments, , this, _$._overloads],
_ = function(type, index) {
if(type instanceof Array) return type.some(function(type) {
return _(type, index);
});
if(!($[0][index] instanceof Object))
$[0][index] = Object($[0][index]);