Skip to content

Instantly share code, notes, and snippets.

View baghayi-gist's full-sized avatar

Hossein Baghayi baghayi-gist

View GitHub Profile
@baghayi-gist
baghayi-gist / gist:4009068
Created November 3, 2012 22:11
JavaScript: Placeholder html5 shim (jQuery Based)
/* <![CDATA[ */
$(function() {
var input = document.createElement("input");
if(('placeholder' in input)==false) {
$('[placeholder]').focus(function() {
var i = $(this);
if(i.val() == i.attr('placeholder')) {
i.val('').removeClass('placeholder');
if(i.hasClass('password')) {
i.removeClass('password');
@baghayi-gist
baghayi-gist / gist:4009084
Created November 3, 2012 22:15
PHP: Converting Persian Numbers To English One (function).
function convertPersianNumbersToEnglish($number)
{
$persian = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
$num = range(0, 9);
return (int)str_replace($persian, $num, $number);
}
@baghayi-gist
baghayi-gist / gist:4064465
Created November 13, 2012 07:22
JavaScript: Remove Element Function
<script>
function removeElement(child, parent)
{
var parent = document.getElementById(parent);
var child = document.getElementById(child);
parent.removeChild(child);
return false;
}
@baghayi-gist
baghayi-gist / gist:4981081
Created February 18, 2013 21:50
JavaScript: Image Preloader
function preload() {
while(arguments.length) {
new Image().src = [].shift.call(arguments);
}
}
#usage
#preload('img1.jpg', 'path/to/img2.jpg', 'img3.jpg');