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
// Check to see if a <select> has an empty selection/no value | |
$.fn.checkEmptySelection = function() { | |
var emptyClass = 'noselection'; | |
$(this).each(function() { | |
if( $(this).val() == emptySelection ) { | |
$(this).addClass(emptyClass); | |
} | |
}); | |
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
// make sure that input type="number" only accepts numbers | |
$.fn.allowNumbersOnly = function() { | |
$(this).keydown(function (event) { | |
var num = event.keyCode; | |
if ((num > 95 && num < 106) || (num > 36 && num < 41) || num == 9) { | |
return; | |
} | |
if (event.shiftKey || event.ctrlKey || event.altKey) { | |
event.preventDefault(); | |
} else if (num != 8 && num != 46 && num != 109 && num != 110 && num != 188 && num != 189 && num != 190) { |
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
<? | |
header("Content-type: text/html; charset=utf-8"); | |
if(empty($_SERVER['PHP_AUTH_USER'])) { | |
header('WWW-Authenticate: Basic realm=""'); | |
header('HTTP/1.0 401 Unauthorized'); | |
echo 'Login and Password Required'; | |
exit; | |
} else { | |
echo "Username: ".$_SERVER['PHP_AUTH_USER']."<br>"; | |
echo "Password: ".$_SERVER['PHP_AUTH_PW']."<p>"; |
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
// url: http://stackoverflow.com/questions/7600454/how-to-prevent-page-scrolling-when-scrolling-a-div-element | |
// function | |
$.fn.isolatedScroll = function() { | |
this.bind('mousewheel DOMMouseScroll', function (e) { | |
var delta = e.wheelDelta || (e.originalEvent && e.originalEvent.wheelDelta) || -e.detail, | |
bottomOverflow = this.scrollTop + $(this).outerHeight() - this.scrollHeight >= 0, | |
topOverflow = this.scrollTop <= 0; | |
if ((delta < 0 && bottomOverflow) || (delta > 0 && topOverflow)) { |