This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* HTMLはこんな感じ | |
* <html> | |
* <head> | |
* <meta charset="UTF-8" /> | |
* <title>クロージャの勉強</title> | |
* <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
* </head> | |
* <body> | |
* <ul class="member"></ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//引用URL:http://addyosmani.com/resources/essentialjsdesignpatterns/book/ | |
var module = (function() { | |
var _private = { | |
i:5, | |
get : function() { | |
console.log( 'current value:' + this.i ); | |
}, | |
set : function(val) { | |
this.i = val; | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// htmlがこんな感じだとして | |
// <div id='hoge'>hoge</div> | |
// | |
var addEvent = function(elName, ev, fn) { | |
var el = document.getElementById(elName); | |
if(el.addEventListener) { | |
el.addEventListener(ev, fn, false); | |
} else if(el.attachEvent){ | |
el.attachEvent('on' + ev, fn); | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//引用http://addyosmani.com/resources/essentialjsdesignpatterns/book/ | |
var Singleton = (function(){ | |
var instantiated; | |
function init (){ | |
// singleton here | |
return { | |
publicMethod: function(){ | |
console.log( 'hello world' ); | |
}, | |
publicProperty: 'test' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//sum(10)(10) → 20 | |
function sum(x, y) { | |
return x + y; | |
} | |
funtion c_sum(x) { | |
return function(y) { return sum(x,y); } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EventManager | |
constructor: ()-> | |
@list = {} | |
set: (elmName, event, fnc) -> | |
@list[elmName] = @list[elmName] || {} | |
@list[elmName] = | |
elO:document.getElementById elmName | |
ev:event | |
fn:fnc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//投稿 | |
// @url /posts/:id | |
var posts = { | |
id: "", // 投稿のID (Mongo[ORMapper]の仕様に合わせる) | |
img: "http://example.com/iamges/foo.png", // 画像のURL | |
body: "", // 投稿文 | |
tags: [ // Tagの情報 | |
{ id: "1", name: "Ruby" }, | |
{ id: "4", name: "JavaScript" }, | |
{ id: "6", name: "Python" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//参考サイト:http://d.hatena.ne.jp/sugyan/20090312/1236815025 | |
// http://d.hatena.ne.jp/kudakurage/20091211/1260521031 | |
//独自バリデーション追加方法 | |
jQuery.validator.addMethod("isKatakana", function(value, element) { | |
return this.optional(element) || /^([ァ-ヶーァ-ン゙゚]+)$/.test(value); | |
}, "カタカナで入力してください" | |
); | |
//バリデーション設定方法 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
convertHalfwidthNum = function(obj) { | |
var cObj = $.extend(true, {}, obj); | |
var str = ''; | |
var v = cObj.value; | |
var len = v.length; | |
for (var i = 0; i < len; i++) { | |
var c = v.charCodeAt(i); | |
if ((c >= 65296 && c <= 65305)) | |
str += String.fromCharCode(c - 65248); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$area = "setagaya"; | |
$area_list = array( | |
1 => "setagaya", | |
2 => "sinagawa" | |
); | |
$staff_list = array( |
OlderNewer