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
each(test, function(index, elem) { | |
alert(this); | |
// alert(index + " = " + elem.name); | |
}); |
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
callback.prototype = arr[i]; | |
callback(i); |
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
callback.prototype = arr[i]; | |
new callback(i); | |
// call 또는 apply 함수를 사용하여 구현 할 수도 있음 | |
// callback.call(arr[i], i); |
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
var test1 = function() { | |
alert("test1 : " + this); | |
} | |
var test2 = new function() { | |
alert("test2 : " + this); | |
} | |
onload=function() { | |
test1(); |
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
var each = function(arr, callback) { | |
for(i = 0; i < arr.length; i++) { | |
callback.prototype = arr[i]; | |
new callback(i); | |
} | |
}; | |
onload=function() { | |
var test = [ { name : 'a' }, { name : 'b' }, { name : 'c' } ]; |
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 initParams() { | |
var str = location.href.split("?")[1]; | |
var params = new Array(); | |
if(str != undefined) { | |
if(str.indexOf("&") != -1) { | |
var tmp_params = str.split("&"); | |
for(var i in tmp_params) { | |
var tmp_param = tmp_params[i].split("="); |
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 initTemplate(ctrl, callback) { | |
$.get("temp/" + ctrl + ".temp", {}, function(temp) { | |
callback(temp); | |
}); | |
} |
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(doc) { | |
var obj = window.cont = (window.cont || {}); | |
obj.params = initParams(); | |
// Controller 호출 | |
setTimeout(function() { | |
if(obj.params["ctrl"] != undefined) { | |
initTemplate(obj.params["ctrl"], function(temp) { | |
eval(obj.params["ctrl"] + "(temp, 'view')"); | |
}); |
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
eval(obj.params["ctrl"] + "(temp, 'view')"); | |
// 위의 구문은 아래와 같이 실행되는 것과 같다. (obj.params["ctrl"] 변수의 값이 'board_list' 일 경우) | |
board_list(temp, 'view'); |
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 controller(temp, type) { | |
if(type == "view") { | |
// 뷰 컨트롤러 구현 부분 | |
} else if(type == "action") { | |
// 액션 컨트롤러 구현 부분 | |
return temp; | |
} | |
} |