Skip to content

Instantly share code, notes, and snippets.

each(test, function(index, elem) {
alert(this);
// alert(index + " = " + elem.name);
});
callback.prototype = arr[i];
callback(i);
callback.prototype = arr[i];
new callback(i);
// call 또는 apply 함수를 사용하여 구현 할 수도 있음
// callback.call(arr[i], i);
var test1 = function() {
alert("test1 : " + this);
}
var test2 = new function() {
alert("test2 : " + this);
}
onload=function() {
test1();
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' } ];
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("=");
function initTemplate(ctrl, callback) {
$.get("temp/" + ctrl + ".temp", {}, function(temp) {
callback(temp);
});
}
(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')");
});
eval(obj.params["ctrl"] + "(temp, 'view')");
// 위의 구문은 아래와 같이 실행되는 것과 같다. (obj.params["ctrl"] 변수의 값이 'board_list' 일 경우)
board_list(temp, 'view');
function controller(temp, type) {
if(type == "view") {
// 뷰 컨트롤러 구현 부분
} else if(type == "action") {
// 액션 컨트롤러 구현 부분
return temp;
}
}