This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ticketRegexp = /[A-Z]+-\d+/; | |
document.addEventListener('contextmenu', (e) => { | |
const link = e.target.closest('a'); | |
const [ticketKey] = link.href.match(ticketRegexp); | |
if (!ticketKey) return; | |
document.documentElement.focus(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Prevent vertical scroll outside of elem, while scrolling on elem | |
* @param {HTMLElement} elem | |
*/ | |
function incapsulateVerticalScroll(elem) { | |
elem.addEventListener('wheel', (event) => { | |
if (event.deltaX !== 0) { | |
return; // horizontal | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function query() { | |
location.search | |
.substr(1) | |
.split('&') | |
.reduce(function (query, component) { | |
component = component.length && component.split('='); | |
if (component.length) { | |
try { | |
var key = decodeURIComponent(component[0]), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mimeCheck = function (type) { | |
return Array.prototype.some.call(navigator.plugins, function (plugin) { | |
return Array.prototype.some.call(plugin, function (mime) { | |
return mime.type == type; | |
}); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var format = function(value, indent) { | |
indent = indent || 1; | |
var tab = new Array(indent).join(' '); | |
switch (typeof value) { | |
case 'number': | |
case 'boolean': | |
return value; | |
break; | |
case 'string': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.rectify = function() { | |
var result = []; | |
this.forEach(function(item) { | |
if (item instanceof Array) { | |
item.forEach(arguments.callee); | |
} else { | |
result.push(item); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($, undefined) { | |
/** | |
* filter input in fields | |
*/ | |
$.widget('namespace.inputFilter', { | |
options: { | |
/** | |
* @type {Boolean} — add .error for empty required fields | |
*/ | |
required: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var autoinit = function() { | |
var autoinit = function() { | |
var handlers = []; | |
this.add = function(foo) { | |
Array.prototype.forEach.call(arguments, function(foo) { | |
typeof foo == 'function' && handlers.push(foo); | |
}); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rules = { | |
l: [0,-1,1,1], | |
r: [1,-1,-1,0], | |
b: [-1,1,0,1] | |
}, | |
go = function(start, direction) { | |
return start.map(function(value, index) { | |
var val = value + rules[direction][index]; | |
if (val < 0) val = 4 + val; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var crypt = function() { | |
var decryptMap = { | |
3: 'A', | |
0: 'B', | |
Q: 'C', | |
S: 'D', | |
2: 'E', | |
P: 'F', | |
6: 'G', | |
I: 'H', |
NewerOlder