Skip to content

Instantly share code, notes, and snippets.

View Xordal's full-sized avatar

Luzhbin Denis Xordal

  • Russia, Taganrog
View GitHub Profile
@Xordal
Xordal / scroll.js
Last active December 18, 2015 22:48
Position of element before click
$(this).mouseup(function (e) {
e.stopPropagation();
x = e.pageX - $(window).scrollLeft;
y = e.pageY - $(window).scrollTop;
}
@Xordal
Xordal / div.html
Created June 25, 2013 07:27
Default undeletable text in textarea.
<div class="textarea-container" onclick="document.getElementById('myTextarea').focus()">
<div>I like/dislike this site because:</div>
<textarea id="myTextarea"></textarea>
</div>
@Xordal
Xordal / div.html
Created August 6, 2013 11:37
jqGrid clienside data storage http://jsfiddle.net/yNw3C/649/
<table id="list47"></table>
<div id="plist47"></div>
@Xordal
Xordal / script.js
Last active December 29, 2015 23:59
Return serialized form without null-value fields
// Удаление null-полей из модели
var cleanedForm = function(form) {
"use strict";
var thisArray = $("#" + form).serializeArray();
$.each(thisArray, function(index, item) {
if (item.value.toString().toLowerCase() == "null") {
delete thisArray[index];
}
});
@Xordal
Xordal / script.js
Last active December 31, 2015 19:39
js DateDiff
var timeDiff = Math.abs($('#DateTo').datepicker('getDate').getTime() - $('#DateFrom').datepicker('getDate').getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
@Xordal
Xordal / minuteDiff.sql
Last active January 1, 2016 12:09
DateDiff(min, :toDate, :fromDate) for PostgreSql
SELECT extract(epoch from (to_timestamp(:toDate, 'DD.MM.YYYY HH24:MI') - to_timestamp(:fromDate, 'DD.MM.YYYY HH24:MI'))) / 60
@Xordal
Xordal / multiple options
Last active January 3, 2016 07:39
For select boxes with multiple options
http://harvesthq.github.com/chosen/
@Xordal
Xordal / Layout.html
Created January 15, 2014 05:45
Multiple versions of jQuery on the same page
<script type='text/javascript' src='@Url.Content( "~/Scripts/jquery-1.5.1.js" )'></script>
<script type="text/javascript">
$(selector).dosome(); // for use 1.5.1 jquery
</script>
@Xordal
Xordal / invertRGB.js
Created July 7, 2014 12:26
Invert RGB color js
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
function invert(rgb) {
@Xordal
Xordal / singleDoubleClick.js
Created July 7, 2014 12:28
Single- and double-click functions
jQuery.fn.single_double_click = function(single_click_callback, double_click_callback, timeout) {
return this.each(function() {
var clicks = 0, self = this;
jQuery(this).click(function(event) {
clicks++;
if (clicks == 1) {
setTimeout(function() {
if (clicks == 1) {
single_click_callback.call(self, event);
} else {