Skip to content

Instantly share code, notes, and snippets.

@Takazudo
Takazudo / scripts.css
Created October 7, 2010 00:44
JA font-family
// for font-family swap
(navigator.appVersion.indexOf("Win")>-1) && $('html').addClass('os-win');
@Takazudo
Takazudo / styles.css
Created October 7, 2010 09:13
ie 6,7 border-spacing
/* ie 6,7 border-spacing */
table{
width:100%;
border-spacing:0;
border-collapse:separate;
*border-collapse:collapse; /* ie6,7 */
border-right:8px solid #333;
border-bottom:8px solid #333;
}
@Takazudo
Takazudo / scripts.js
Created October 11, 2010 00:03
quick orientation detection
/* quick orientation detection */
document.body.onorientationchange = (function(){
document.body.className =
orientation % 180 == 0 ? 'vertical' : 'horizontal';
return arguments.callee;
})();
/* from http://mir.aculo.us/2010/10/08/quick-and-easy-orientation-detection-for-mobile-sites/ */
@Takazudo
Takazudo / scripts.js
Created October 12, 2010 09:17
iPhone, iPad UA detection
/* $.ua: iPhone, iPad, iPod detection */
/**
* $.ua
*/
$.ua = (function(){
var o = {};
var ua = navigator.userAgent;
$.each(['iPhone', 'iPod', 'iPad'], function(i, current){
@Takazudo
Takazudo / gist:625936
Created October 14, 2010 09:28
random val
/* random val 40~60 */
function randomNum(from, to){
return from + Math.floor( Math.random() * (to - from + 1) );
}
console.log(random(40,60));
@Takazudo
Takazudo / gist:627716
Created October 15, 2010 06:14
clearfix
element:after{ content:"."; display:block; clear:both; height:0; visibility: hidden; }
@Takazudo
Takazudo / gist:631849
Created October 18, 2010 07:14
word-break 折り返し url 文字
.ex-wordwrap {
word-wrap: break-word;
}
@Takazudo
Takazudo / gist:638415
Created October 21, 2010 12:47
$.fn.zebraTable
/**
* $.fn.zebraTable
* $(anyTableElement).zebraTable() will attach 'odd' or 'even' to each trs.
*/
$.fn.zebraTable = function(){
return this.each(function(){
var $el = $(this);
var $tbody = $('tbody', $el);
$el = $tbody.size() ? $tbody : $el;
$('tr:odd', $el).addClass('odd');
@Takazudo
Takazudo / gist:638418
Created October 21, 2010 12:48
$.fn.autolink
/**
* $.fn.autolink
* wrap a element for each http://~ text inside the dom
*/
$.fn.autolink = function(){
return this.each(function(){
var $el = $(this);
var re = /((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g;
$el.html( $el.html().replace(re, '<a href="$1">$1</a> ') );
});
@Takazudo
Takazudo / gist:638421
Created October 21, 2010 12:48
console.log wrapper
// usage: log('inside coolFunc',this,arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
if(this.console){
console.log( Array.prototype.slice.call(arguments) );
}
};