Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / Object.prototype.extend.js
Last active October 3, 2015 06:18
extend() : オブジェクトに別オブジェクトのプロパティを追加(上書き)して返す関数
Object.prototype.extend || (Object.prototype.extend = function(e) {
if (!e && (this !== null) && e instanceof Object !== "object") throw new Error("引数はオブジェクトで!一個だけな!(・∀・)");
for (var p in e) e.hasOwnProperty(p) && (this[p] = e[p]);
return this;
});
(function(AP, isF) {
'use strict';
// isArray : https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
Array.isArray || (Array.isArray = function (a) {
return Object.prototype.toString.call(a) == "[object Array]";
});
// toSource(Non-standard)
AP.toSource || (AP.toSource = function() {