Skip to content

Instantly share code, notes, and snippets.

jQuery.fn.hasBind = function(type, _fn)
{
var data, eventsMap, events;
if(!((data = this._data()) && (eventsMap = data.events) && (events = eventsMap[type])))
return false;
var event, i = -1; while((event = events[++i]) && event.handler !== _fn)
;
(function()
{
var _fnMap = {};
$.fn.addClass = function(classes)
{
var vs = this;
if(!(classes > '') || vs.length == 0)
return this;
if(!console)
console = {};
if(!console.log)
console.log = $jb._log;
console.time = $jb._timerBegin;
console.timeEnd = $jb._timerEnd;
var i, n = 3000000;
window._bounce1 = function(p){
var value;
for (var a = 0, b = 1; 1; a += b, b /= 2){
if (p >= (7 - 4 * a) / 11){
value = b * b - Math.pow((11 - 6 * a - 11 * p) / 4, 2);
break;
}
}
console.log('n = ', Math.log(b)/Math.log(0.5), 'a = ', a, 'b = ', b);
/* No regexp. indexOf only */
window._queryToJSON = function(query)
{
if(query == null || query.length < 2)
return {};
var p = 0;
if(query.charAt(p) == '?')
++p;
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!-- code has grubbed from http://msdn.microsoft.com/en-us/library/ms532990(VS.85).aspx -->
<html>
<head>
<title></title>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<SCRIPT>
/**
@fn call function with <this> = <that> and <arguments> matched from <argMap> by names
@param that {Any} <this> for function call
@param argMap {Object} map argName -> argValue
@example
var _fn = function(a, b, c)
{
console.log('a = ', a, 'b = ', b, 'с = ', c);
};
window._gzip = (function()
{
var _matchCount = function(s, word)
{
var n = 0, wordLen = word.length, p = -wordLen;
while((p = s.indexOf(word, p + wordLen)) > -1)
++n;
return n;
window.onunload = function()
{
var _check = function(lbl)
{
var a;
if(window.document && document.body)
a = 'body';
else if(window.document && document.documentElement)
a = 'documentElement';
/**
@file
@author Fyodorov "bga" Alexander <[email protected]>
@section LICENSE
Copyright (c) 2009-2010, Fyodorov "Bga" Alexander <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without