Skip to content

Instantly share code, notes, and snippets.

/*! $.ajaxCache | RubaXa <trash@rubaxa.org> | MIT */
(function ($){
var _cache = {};
var _cacheKey = function (options){
return options.url + $.param(options.data || {});
};
/**
* Get cache storage
/**
* jQuery event "tap" (Based on https://developers.google.com/mobile/articles/fast_buttons)
*
* @author RubaXa <trash@rubaxa.org>
* @license MIT
*/
(function (window, $){
var
support = window.TapSupportEnabled && ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch
(new UISequence)
.on('click', '.js-cbx') // начало цепочки
.choose() // любое следующее действие
.group() // группа действий
.choose() // опять выбор любого
.scrollDY(-200) // либо scrollUp на 200px
.group() // либо группа из
.scrollDY(100) // scrollDown на 100px
.endPage() // и достигли конца страницы
.end() // закрываем группу
@RubaXa
RubaXa / Promise.js
Last active September 16, 2017 18:17
«Promise.js» — is supported as a native interface and $.Deferred.
/**
* @author RubaXa <trash@rubaxa.org>
* @license MIT
*/
(function () {
"use strict";
function _then(promise, method, callback) {
return function () {
@RubaXa
RubaXa / EventEmitter.js
Created January 19, 2014 06:56
EventEmitter.js
/**
* @author RubaXa <trash@rubaxa.org>
* @license MIT
*/
(function (){
"use strict";
var _rspace = /\s+/;
@RubaXa
RubaXa / jQuery.fn.dataset.js
Last active January 4, 2016 09:09
jQuery.fn.dataset
/**
* Set/get dataset
*
* @param {String|Object} [data]
* @param {Mixed} [value]
* @retuns {Mixed}
*/
jQuery.fn.dataset = function (data, value){
var
argsNum = arguments.length
/**
* User Timing polyfill (http://www.w3.org/TR/user-timing/)
* @author RubaXa <trash@rubaxa.org>
*/
(function (window){
var
startOffset = Date.now ? Date.now() : +(new Date)
, performance = window.performance || {}
, _entries = []
// ==UserScript==
// @name lepratranslate
// @author RubaXa <trash@rubaxa.org>
// @license MIT
// @version 0.0.1
// @include http://leprosorium.ru/*
// ==/UserScript==
/*global unsafeWindow*/
/**
* OOP
* @author RubaXa <trash@rubaxa.org>
*/
(function (){
/**
* Создание «родительского» метода
* @param {*} fn
* @param {*} parent
@RubaXa
RubaXa / AbsudTpl.js
Last active August 29, 2015 14:02
AbsurdTpl — JavaScript micro-micro-templating, v0.3.1
(function () { 'use strict';
var indent = 0, tags = [], close, begin, rshort = /^(img|input|hr|br)$/;
window['absurdTpl'] = function _(name, template) {
return _[name] = Function('ctx', ('var buf = "";\n' + (template || name).toString().split('\n').slice(1, -1).map(function (line, idx, lines) {
return line.replace(/\/\/.+|\/\*.*?\*\//g, '')
.replace(/~([\w+_-]+)/i, 'buf += absurdTpl["$1"]')
.replace(/^(\s*)(?:([a-z]+[0-9]*)((?:\.[a-z_-]+[\w_-]+)*)((?:\[.*?\])*)(?:\s+\|\s+(.*?))?($|;)|.)/, function (_, ind, tag, classes, attrs, html) {
begin = (indent >= ind.length) && (close = tags.splice(0, indent/ind.length).filter(isNaN)).length ? 'buf += "</' + close.join('></') + '>";\n' : '';
indent = ind.length;
!rshort.test(tag) && tags.unshift(tag || 0);