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
// https://stackoverflow.com/a/4020842/893111 | |
Math.max.apply(Math, array.map(o => o.y)) |
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 takeOverConsole() { | |
var console = window.console; | |
function intercept(method) { | |
var original = console[method]; | |
console[method] = function () { | |
var message = Array.prototype.slice.apply(arguments).join(' '); | |
original.call(console, arguments); | |
var xhr = new XMLHttpRequest(); | |
// xhr.open('get', '/log.php?error=' + message); |
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
// Ticker Plugin | |
$.fn.fTicker = function (options) { | |
var $ticker = $(this); | |
var settings = $.extend({ | |
// defaults. | |
timeout: 5000 | |
}, options); | |
$.each($ticker, function () { | |
var $el = $(this).find("ul:first"); | |
if ($el.find("li").length < 2) |
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
$(window).on("blur focus", function (e) { | |
var prevType = $(this).data("prevType"); | |
if (prevType != e.type) { // reduce double fire issues | |
switch (e.type) { | |
case "blur": | |
// do work | |
console.log('blurred'); | |
break; | |
case "focus": | |
// do work |
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
<script type="text/javascript"> | |
$(document).ready(function() { | |
$('.dragger').mousedown(function (event) { | |
$(this) | |
.data('down', true) | |
.data('x', event.clientX) | |
.data('scrollLeft', this.scrollLeft) | |
.addClass("dragging"); | |
return false; |
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
// module with classes and logic for working with local storage in browsers via JavaScript | |
// see also: http://professorweb.ru/my/html/html5/level5/5_1.php | |
module StorageHelper { | |
export interface IStorageItem { | |
key: string; | |
value: any; | |
} | |
export class StorageItem { | |
key: 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
String.prototype.toPersianDigits = function () { | |
var id = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']; | |
return this.replace(/[0-9]/g, function (w) { | |
return id[+w]; | |
}); | |
}; | |
String.prototype.toEnglishDigits = function () { | |
var id = { '۰': '0', '۱': '1', '۲': '2', '۳': '3', '۴': '4', '۵': '5', '۶': '6', '۷': '7', '۸': '8', '۹': '9' }; |
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 persianToLatinDigits (s) { | |
var a = ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"]; | |
var p = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"]; | |
for (var i = 0; i < 10; i++) { | |
s = s.replace(new RegExp(a[i], 'g'), i).replace(new RegExp(p[i], 'g'), i); | |
} | |
return s; | |
} |
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
window.$_GET = {}; | |
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () { | |
function decode(s) { | |
return decodeURIComponent(s.split("+").join(" ")); | |
} | |
$_GET[decode(arguments[1])] = decode(arguments[2]); | |
}); |
NewerOlder