Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>keycode scaner</title>
<meta name="keywords" content="jbasis, keycode ,javascript, tool, tools">
<meta name="description" content="jbasis keycode scaner">
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
// known issues:
// 1) not cross frame (_fn.toString === Function.prototype.toString)
var _isFunction = function(_fn)
{
return typeof(_fn) == 'function' ||
(
typeof(_fn) != 'string' &&
!(_fn instanceof String) &&
String(_fn).replace(/^\s+/, '').slice(0, 8) == 'function' &&
(
(function($G)
{
var _lengthGetter = function()
{
var b = -1;
var i;
for( ;; )
{
i = 1;
// (C) new BSD license
// fix FF bug (delay pass to function) and add support of arguments
(function($G)
{
var fnCache = {};
var _fixNoArgs = function(_origFn, _arraySlice)
{
return function(/*_fn, delay*/) // .length === 0
{
"use strict";
(function()
{
var _warmUp = function()
{
var d = Date.now();
while(Date.now() - d < 4000)
{
/*
Traditionally in js we separate arrays and hashes(maps, Object, dictionary, ...)
Test shows that modern engines havent array optimization - it just hash with automatic <.length> property and sugar array like methods :(
*/
var m = 1000;
var _fill = function(a)
{
/*
Goal of this test is find best data structure for store matrices, vectors and quaternions
In C/C++ we have ability to store same data different ways ie
union
{
float m[9];
struct
{
float
m00, m01, m02
/*
Basic idea - measure cost of simplest operation of js in cpu cycles
asm
//var i = n;
mov EAX, n
// while(i--);
a: dec EAX
/**
@hint
@see https://wiki.mozilla.org/Audio_Data_API
@see http://www.opensource.apple.com/source/WebCore/WebCore-737.5/html/canvas/
@see https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/TypedArray-spec.html
Array.U32 = $G.Uint32Array || $G.WebGLUnsignedIntArray || $G.CanvasUnsignedIntArray || Array;
Array.U16 = $G.Uint16Array || $G.WebGLUnsignedShortArray || $G.CanvasUnsignedShortArray || Array;
Array.U8 = $G.Uint8Array || $G.WebGLUnsignedByteArray || $G.CanvasUnsignedByteArray || Array;
(function($G)
{
var cache = {};
var XHR = $G.XMLHttpRequest || function(){ return new $G.ActiveXObject('Microsoft.XMLHTTP') };
$G.require = function(url)
{
if(!(url in cache))
{
var xhr = new XHR();