Skip to content

Instantly share code, notes, and snippets.

@jordanharper
jordanharper / gist:991217
Created May 25, 2011 15:47
Activate <input> placeholder attributes for non webkit browsers
$('input[placeholder]').each(function(){
$(this).focus(function(){
if ($(this).val()==$(this).attr('placeholder')) $(this).val('');
}).blur(function(){
if ($(this).val()=='') $(this).val($(this).attr('placeholder'));
});
});
Or, using modernizer:
@jordanharper
jordanharper / gist:991223
Created May 25, 2011 15:52
Expansion of hitareas for links
$('.hitarea-container').each(function(){
$(this).click(function(){
$target = $(this).find('a.hitarea-source').first().attr('href');
if ($target) window.location.href = $target;
});
});
// Relies on container to become 'clickable' having a class
// of 'hitarea-container' and the link that should be the
// target needs to be the href of the first link within that
@jordanharper
jordanharper / gist:993034
Created May 26, 2011 12:29
HTTP authentication with a file_get_contents request
<?php
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$username:$password")
)
));
$data = file_get_contents($url, false, $context);
<!DOCTYPE html>
<!doctype HTML>
<html>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# blog: http://ogp.me/ns/blog#">
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">