Skip to content

Instantly share code, notes, and snippets.

@ethertank
ethertank / Array.min_test.js
Created April 12, 2012 03:17
Array .min() / .max()
Array.prototype.min || (Array.prototype.min = function() {
return this.length ? Math.min.apply("",this) : undefined;
});
/* check result *//*
[1, 2, 3, 0].min() ====> 0
typeof[1, 2, 3, 0].min() ====> number
[1, 2, 3, +100].min() ====> 1
typeof[1, 2, 3, +100].min() ====> number
["1", "2", "3", "+100"].min() ====> 1
typeof["1", "2", "3", "+1"].min() ====> number
@ethertank
ethertank / addClass.js
Created April 2, 2012 20:03 — forked from ryan-blunden/addClass.js
addClass()
function addClass(elem, newClassName) {
var className, classes, classesLength;
if(typeof elem === 'string') { elem = document.getElementById(elem); }
if(elem === null || elem.nodeType !== 1 || typeof newClassName !== 'string') { return null; }
className = elem.className;
classes = newClassName.split(' '),
classIndex = classes.length;
@ethertank
ethertank / jQueryPlugInTemplate.js
Last active May 26, 2017 08:55
オプション付きjQueryプラグインの最小構成テンプレート
/* 先頭行: 他のスクリプトでのセミコロン忘れに備え、且つ、予約語でないundefinedの書換えによる誤動作を防いでいる。*/
;(function($, undefined) {
"use strict";
$.fn.myPlugIn = function(option) {
var a, b, c;
//※未設定のオプション項目に初期値を設定
option = $.extend({
opt1: null,
@ethertank
ethertank / date.getFormatDate
Created March 27, 2012 17:17
日付に関する何か
Date.prototype.getFormatDate = function getFormatDate() {
var d = this,
o = {};
o.date = d;
o.json = d.toJSON();
o.YYYY = d.getFullYear();
o.M = d.getMonth() + 1;
o.D = d.getDate();
o.wday = d.getDay();
@ethertank
ethertank / Object.length.js
Created March 26, 2012 03:12
Object.length
Object.prototype.length || (Object.prototype.length = function() {
var len = -1;
for (prop in this) {
len++;
}
return len;
});
@ethertank
ethertank / getIndividualCSSPropertyValue.js
Created March 22, 2012 22:07
ショートハンドで記述されたCSSプロパティの値から個別のスタイルを抽出する関数
var getIndividualCSSPropertyValue = function(prop, propValue, IndividualProp) {
var d = document.createElement("div");
d.style[prop] = propValue;
return d.style[IndividualProp];
};
@ethertank
ethertank / output.html
Created March 19, 2012 13:27
ZenCoding MiuIpsum
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<article>
<h1>仲村みう</h1>
<p>仲村みう</p>
@ethertank
ethertank / jQuery_TumblrMosaic.js
Created March 19, 2012 10:54
jQuery TumblrMosaic
/*
* jQuery_TumblrMosaic.js
*
* Varsion: 0.0.4
* PublishDate: 2012-03-11 18:18
* LastUpdate : 2012-04-06 19:21
* Copyright (c) 2012 ethertank.jp
* Licensed under the MIT
*
* jQuery required (tested on 1.7.1)
@ethertank
ethertank / jQuery_blrblrTumblrImage.js
Last active October 1, 2015 23:17
jQuery blrblrTumblrImage
/*
* jQuery_blrblrTumblrImage.js
*
* Varsion: 0.1.7
* PublishDate: 2012-03-03 23:30
* LastUpdate : 2014-08-06 23:28
* Copyright (c) 2012- ethertank.jp
* Licensed under the MIT
*
* jQuery required (tested on 1.7.1)
@ethertank
ethertank / clearfix.css
Created March 19, 2012 10:28
Clearfix
@charset "utf-8";
/*
※未検証。これだと古いIEが死ぬかな。でも育て甲斐がありそうな気がする。
※参考URL: http://norisfactory.com/stylesheetlab/000038.php
※データ: http://blog.ethertank.jp/2010/05/01-19:13:22
*/
.clearfix { zoom: 1; }
.clearfix:after {