Skip to content

Instantly share code, notes, and snippets.

View termi's full-sized avatar

Егор Халимоненко termi

View GitHub Profile
@termi
termi / index.js
Created November 1, 2012 14:33
getElementsByClassName-like function for all browsers (IE6+ / w3c)
var
/** @type {RegExp} @const */
RE__getElementsByClassName = /\s*(\S+)\s*/g
/** @type {string} @const */
, STRING_FOR_RE__getElementsByClassName = '(?=(^|.*\\s)$1(\\s|$))'
/** @type {boolean} @const */
, IS_IELT9 = !/\[native\s+code\]/i.test(document.getElementsByClass + "")
/** @type {RegExp} @const */
, RE__querySelector__dottes = /\./g
;
@termi
termi / index.js
Created November 6, 2012 08:36
Add/Remove listeners
void function(exports) {
var _browser_msie = window["eval"] && window["eval"]("/*@cc_on 1;@*/") && +((/msie (\d+)/i.exec(navigator.userAgent) || [])[1] || 0) || void 0
, _document_documentElement = document.documentElement
, _document_body = document.body
, _append = function(obj, extention) {
for(var key in extention)
@termi
termi / index.js
Created November 7, 2012 12:15
offset[Left/Top]
var getScrollX
, getScrollX
, _document_documentElement = document.documentElement
;
document.compatMode === "CSS1Compat" ?
((_getScrollX = function(){return _document_documentElement.scrollLeft}), (_getScrollY = function(){return _document_documentElement.scrollTop}))
:
((_getScrollX = function(){return document.body.scrollTop}), (_getScrollY = function(){return document.body.scrollLeft}))
;
@termi
termi / build.js
Created November 19, 2012 09:32
JS GCC compile or remove GCC globals
#!/usr/bin/env node
if (process.argv.length < 3) {
console.error('No enough parameters');
process.exit();
}
const fs = require('fs')
, path = require('path')
;
@termi
termi / IElt9_getComputedStyle.js
Last active December 12, 2015 01:28
getComputedStyle for IE < 9
void function() {
var global = this
/** @const */
, _Array_slice = Array.prototype.slice
/** @const */
, _Function_apply = Function.prototype.apply
@termi
termi / index.js
Last active December 12, 2015 05:39
IE8 Array.prototype.splice.apply test
(function() {
var _Array_slice_ = Array.prototype['slice'];
var _Array_splice_ = Array.prototype.splice;
if( Function.prototype.bind === void 0 ) Function.prototype.bind = function (context) {
var args = _Array_slice_.call(arguments, 1), self = this;
return function (){ return self.apply(context, args.concat(_Array_slice_.call(arguments, 0))); };
};
function makeArray(l) {
void function() {
"use strict";
var global = this;
//Mini alternative https://gist.github.com/2428561
//Uses
//https://gist.github.com/1384398
//https://gist.github.com/1235332
@termi
termi / CSS.supports.js
Last active December 17, 2015 11:39
CSS.supports
/** github.com/termi/CSS.supports */
if( !global.CSS || !global.CSS.supports ) {
if( !global.CSS ) {
/**
* @expose
*/
global.CSS = {};
}
if( !global.CSS.supports && global["supportsCSS"] ) {// Opera 12.10 impl
@termi
termi / findMicrodataProperties.js
Last active December 20, 2015 04:18
Find Microdata properties Note: Without itemref support
function findMicrodataProperties(itemScopeNode, itemPropName) {
if( !itemScopeNode.hasAttribute("itemscope") ) {
return[];
}
var pending = []
, tmp
, currentNode
, k = -1
, el
@termi
termi / css3SelectorsPolyfill.js
Created May 5, 2012 19:05
getElementsByClassName/querySelector/querySelectorAll/matchesSelector Polyfill
/** @license MIT License (c) copyright Egor Halimonenko (termi1uc1@gmail.com) */
// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @warning_level VERBOSE
// @jscomp_warning missingProperties
// @output_file_name a.js.querySelector.min.js
// @check_types
// ==/ClosureCompiler==