블로그 이미지
항상웃자 애바른2

카테고리

분류 전체보기 (99)
사진 (4)
비공개 (0)
업무 (1)
자동차 (6)
개발 (23)
가족 (33)
모바일 (13)
Total
Today
Yesterday

달력

« » 2011.11
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

공지사항

최근에 올라온 글

'2011/11'에 해당되는 글 2건

  1. 2011.11.29 diy 관련사이트 2
  2. 2011.11.25 javascript UTIL ...base64, setCookie, ..너무 깔끔함.
* diy 관련사이트 * 








제일카넷 http://www.zeilcar.net / 자동차diy 전문 포탈사이트

손잡이닷컴 http://www.sonjabee.com/ 손잡이나 선반판매 
리빙시티 http://www.livingct.com/ 생활교양코너의 유료홈패션동영상(홈샘님직강) 
삼화 페인트 http://www.djpi.co.kr/ 
쿨칼라 http://coolcolor.co.kr/ 페인트 판매 
굳씽크 http://www.good-think.co.kr/씨트지판매 
반쪽이쩜넷 http://www.banzzogi.net/ 
철천지 http://www.77g.com/ 
페인트클럽 http://www.paintclub.co.kr/ 
theDIY(즐거운diy세상) http://www.thediy.co.kr/ 철물,목재절단판매,3M스프레이판매 
마이드림하우스 http://www.mydreamhouse.co.kr/ 패널벽,리폼,재활용정보와 철망,선반,몰딩판매 
뚝딱이네 http://ddukddak.com/doc/frame2.htm 옷 홈패션 십자수 인형옷강의 
박미영의홈데코 http://my.dreamwiz.com/decohome/mainp.html 홈패션강의 
굿퀼트 http://www.goodquilt.com/frame_main.htm 
퀼트나라 http://www.quiltnala.com/ 
한국공예인협회 http://hdarts.co.kr 퀼트,스텐실 
금성스폰지 http://www.ks-sponge.co.kr/ 스폰지재단하여 판매 
알파문구 http://www.alphastationery.co.kr/ 각종접착제, 문구용품 
한국건축자재협회 http://www.kbmshopping.com 건축자재사이트 
철물백화점 http://www.chulmool.biz 
did벽지 http://www.didwallpaper.com/ 

*원단및 레이스, 부자재 
화이트패브릭 http://www.whitefabric.com/ 
레이스나라 http://www.lacenara.co.kr/ 
천나라닷컴 http://1000nara.com/ 
싸다천 http://ssada1000.com/v2/ 
더싸다 http://www.thessada.com/ 
소잉박스 http://www.sewingbox.net/ 
데코랜드http://my.dreamwiz.com/decohome/mainp.html원단,레이스,태슬,커버링 
천모아 http://www.1000moa.com/ 
슈리본 http://www.sueribbon.co.kr/ 수입리본재료,선물포장재료판매 


*예쁜조명(샹들리에,특이한조명) 있는 사이트* 
데코하우스 http://www.deco-house.co.kr /옥션에서 활동중으로 이번에 오픈 한곳 


*인테리어 소품판매 
화이트홈 http://www.whitehomes.co.kr 
프리티홈 http://www.prettydeco.com/ 
데미스타일 http://www.demistyle.com 
쉬크홈 http://www.chichome.co.kr/ 
바닐라스푼 http://www.vanillaspoon.com/ 
라라데코 http://www.laladeco.com/ 
원룸데코 http://www.oneroomdeco.com/ 독신자타겟 패브릭,소품 
로즈앤핑크 http://www.rosenpink.com/ 인테리어 소품 
앤스홈 http://annshome.co.kr/ 맞춤패브릭 전문 
풍경 http://www.pksopum.com/ 
프로방스 http://www.provence.co.kr/ 프로방스풍 그릇과 가구 
인플로라 http://www.in-flora.co.kr/ 
슈가홈 http://sugarhome.com/ 
포룸 http://www.forroom.com/ 
머쉬룸 http://www.mushroomdeco.co.kr/ 
햄마 http://www.hemma.co.kr/ 이케야제품판매 
핑크데코 http://pinkdeco.co.kr/ 
미세스델러웨이 http://www.mrsdalloway.co.kr/ 
로즈마리 http://www.rosemarihome.com/ 
바인홈http://www.vinehome.co.kr/ 
두산오토 http://www.otto.co.kr/ 
씨씨브랜드 http://www.ccbrand.co.kr/ 
필데코 http://www.feeldeco.com/ 
프롬데코 http://www.fromdeco.com/ 
인플로라 http://www.in-flora.co.kr/ 
포홈 http://www.forhome.co.kr/ 
스위트베리 http://www.sweet-berry.com/index.htm 장식접시와 쿠션등등 
소품채널 http://sofum.co.kr/ 
디피존 http://www.dpzone.co.kr/화이트철재&원목등 상업공간인테리어소품 
인파스텔 http://www.inpastel.co.kr/ 키즈가구,침구,커튼 
소품샵 http://www.sofumshop.co.kr/인테리어소품, 선물샵 
디자인마노 http://www.designmano.co.kr/ 
앤틱하우스 http://www.antichouse.co.kr/ 
아름다운방 http://www.beauty-room.net/ 침구커텐 홈인테리어 
담너머예쁜집 http://www.damzip.com 
제이홈 http://www.jhomes.co.kr/ 
로맨틱홈 http://www.romantic-home.com/ 

*가구관련 
씨리디자인쇼파 http://www.seelee.co.kr 
한샘 http://www.hanssem.com/ 
까사미아 http://www.casamia.co.kr/ 
올리브데코 http://www.olivedeco.co.kr/ 
프란시아 http://www.francia.co.kr/ 
디자인얀 http://www.oyan.co.kr/ 
에프룸 http://www.f-room.com/ (공사중)인테리어코디네이터 최희의 사이트 
디자인앤 http://www.designann.com 
리빙트리 http://www.livingtree.co.kr/ 
대송가구 http://www.daesongmall.com/ 
리빙디자인넷 http://www.livingdesign.net/ 
제니아하우스 http://www.zeniahouse.com/profile/ 

*DIY,맞춤가구 
내가디자인하고내가만드는가구 http://www.my-diy.co.kr/ 
정크가구 http://www.junkstyle.co.kr/ 
상상나무 http://www.interior911.co.kr/ 

*정원용품판매 
쉐르보네 http://www.cherbonheur.com/ 야외 정원용품판매,목재맞춤절단판매 
브라이덜가이드 http://www.bridalguide.co.kr/ 다양한 조화판매 
조은자리 http://www.jounjary.co.kr/ 

*해외인테리어사이트 
로라애슐리 http://www.laura-ashley.com/ 
마샤스튜어트 http://www.marthastewart.com/ 
쉭새크http://chicshack.net/ 
유로데코 http://www.eurodecony.com/ 한인조각가 최린의 조각인테리어소품사이트 

*해외구매대행사이트 
맘앤키즈 http://www.momandkids.co.kr/ 로라애슐리침구나 장식접시, 샤워커튼등 수입대행 
까사까사 http://www.casacasa.co.kr/ 해외 주방용품 

*월간인테리어잡지 
레이디경향 http://www.khan.co.kr/ 
리빙센스 http://livingsense.ismg.co.kr/ 
여성동아 http://women.donga.com/ 
팟찌닷컴 http://www.patzzi.com/ 
까사리빙 http://www.casa.co.kr/home/ 
행복이가득한 집 http://www.design.co.kr/ 
우먼센스 http://womansense.ismg.co.kr/womansense/index.php 

*미싱판매 
썬마트 http://www.sunmart.co.kr/ 
부라더미싱 http://www.brother-shop.co.kr/ 

*대표로드샵 
2001아울렛 www.2001outlet.com
이마트 www.cyberemart.co.kr/ 
홈플러스 www.homeplus.co.kr/
코즈니 www.kosney.co.kr/ 
전망좋은방(룸앤데코) http://www.room-deco.co.kr/ 

*원예사이트 
새싹닷컴 http://saesak.com/식충식물,허브,관엽등에대한 질문답변,판매 
플랜트플러스 http://www.plantplus.co.kr/ 

*기타 데코플라자를 통하면좋은사이트 
노니포유 http://www.noni4u.co.kr/ 직수입 석류,노니관련제품, 건강제품 
웹딱 http://www.webddak.co.kr/ 감각디자인소품 선물용품 

잘 정리된곳
http://myhome.naver.com/cejbaby/menu12.html

소담(릴렉스비슷한거 공구)
http://sodam.odsoft.co.kr

인하우스 지점 안내
http://www.innhaus.co.kr/index.html

수예품+소품파는 곳 (커픈이쁨)
http://www.decotop.com/

레몬스위티(행가집 쥔장 레오가 만든 쇼핑몰)
http://www.lemonsweety.com/

리본묶는 법등 포장법의 모든 것


http://okgift.pe.kr
http://www.forhome.co.kr (다들 아시는 곳이죠..)
http://www.ccbrand.co.kr (자신의 이니셜을 세겨주는 곳이죠...좀 비싸요..)
http://www.thediy.co.kr (각종 DIY제품을 파는곳..MDF나 합판을 잘라서 팔아요..)
http://www.sewingbox.net/index.php (원단파는곳..)
http://www.thessada.com/ (여기도 원단파는 곳...)
http://www.rosecoco.com/ (부산에 오프라인 샾이있죠..그리고 사장님이 남자분이시라는...)
http://www.djpi.co.kr/ (페인트 용품파는곳..)
http://rodam.co.kr/mini.htm (실내정원꾸며주는 곳인데요..비싸니 눈팅만하세요..)
http://www.rosenpink.com/ (아시는분은 다아시는 가격이 비교적 싸더라구요..)
http://www.designmano.co.kr/ (패브릭 소품이 이쁜곳..)
http://www.oneroomdeco.com/ 
(최그에 알게된곳...이쁜게 많터라구요..)
http://www.pksopum.com/default.asp (역시 최근에 알게된곳 인테리어 소품점)
http://www.whitefabric.com/ (이쁜 원단이 많은 곳..)
http://boddary.com/ (원단파는곳..)


Posted by 애바른2
, |

http://localhost:7402/crx/de/js/CRX/util/Util.js


/*
 * Copyright 1997-2008 Day Management AG
 * Barfuesserplatz 6, 4001 Basel, Switzerland
 * All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * Day Management AG, ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Day.
 */

/**
 * The <code>CRX.utils.Util</code> library contains utility methods for CRXDE.
 * @static
 * @class CRX.utils.Util
 */

CRX.util.Util = function() {

    var lastAuthHeader = null;

	var connectionData = null;
	
    var globalDialogs = {};
    
    // private property
    var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

    // private method for UTF-8 encoding
    var _utf8_encode = function (string) {
        string = string.replace(/\\r\\n/g,'\\n');
        var utftext = '';
        for (var n = 0; n < string.length; n++) {
            var c = string.charCodeAt(n);
            if (c < 128) {
                utftext += String.fromCharCode(c);
            } else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            } else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }
        }
        return utftext;
    };
    
    var fileMap = {};

    var eventObject = new Ext.util.Observable();
    eventObject.addEvents("reinit");

    return {
        on : function(eventName, fn, scope, o) {
            eventObject.on(eventName, fn, scope, o);
        },

        /**
         * Evaluates and returns a string.
         * @param {String} param The string
         * @return The evaluated object
         * @type Object
         */
        eval: function(json) {
            try {
                return eval("(" + json + ")");
            } catch (e) {
                return null;
            }
        },

		/**
         * Returns the anchor part of the URL.
         * @static
         * @param {String} url The URL
         * @return {String} The anchor
         */
        getAnchor: function(url) {
            if (url.indexOf("#") != -1) {
                return url.substring(url.indexOf("#") + 1);
            }
        },
        
    	getURLParams: function(url) {
    	    url = url || window.location.search;
    	    url = url.split("?");
    	    if (url.length > 1) {
    	        return Ext.urlDecode(url[1]);
    	    }
    	    return {};
    	},

        /**
         * Returns the value of the cookie with the given name.
         * @static
         * @param {String} name The name of the cookie
         * @return {String} The value of the cookie
         */
        getCookie: function(name) {
            var cname = encodeURIComponent(name) + "=";
            var dc = document.cookie;
            if (dc.length > 0) {
                var begin = dc.indexOf(cname);
                if (begin != -1) {
                    begin += cname.length;
                    var end = dc.indexOf(";", begin);
                    if (end == -1) end = dc.length;
                    return decodeURIComponent(dc.substring(begin, end));
                }
            }
            return null;
        },

        /**
         * Sets the value of the cookie with the given name.
         * @static
         * @param {String} name The name of the cookie
         * @param {String} value The value of the cookie
         * @param {String} path (Optional) The server path the cookie applies to
         * @param {int} days (Optional) The number of days the cookie will live, 
		 *                              no value creates a session cookie, 0 removes
		 *                              the cookie
         * @param {String} domain (Optional) The server domain
         * @param {boolean} secure (Optional) <code>true</code> if the
         *        connection is secure, <code>false</code> otherwise
         * @return {String} The value of the cookie
         */
        setCookie: function(name, value, path, days, domain, secure) {
            if (days && (typeof(days) != "number")) days = 7;

            var date;
            if (days > 0) {
                date = new Date();
                date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            } else if (days == 0) {
				date = new Date(1970, 0, 1);
			}
            document.cookie = encodeURIComponent(name) + "=" +
                         encodeURIComponent(value) + "; " +
                         (date ? "expires=" + date.toGMTString() + "; " : "") +
                         (domain ? "domain=" + domain + "; " : "") +
                         (path ? "path=" + path : "") +
                         (secure ? "; secure" : "");
            return value;
        },

        // public method for encoding
        base64Encode: function (input) {
            var output = '';
            var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
            var i = 0;
            input = _utf8_encode(input);
            while (i < input.length) {
                chr1 = input.charCodeAt(i++);
                chr2 = input.charCodeAt(i++);
                chr3 = input.charCodeAt(i++);
                enc1 = chr1 >> 2;
                enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
                enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
                enc4 = chr3 & 63;
                if (isNaN(chr2)) {
                    enc3 = enc4 = 64;
                } else if (isNaN(chr3)) {
                    enc4 = 64;
                }
                output = output +
                _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
                _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
            }
            return output;
        },
        
        reinit: function() {
            Ext.Ajax.request({
                url:CRX.Util.getContextPath() + "/de/init.jsp",
                success:function(response, options) {
                    connectionData = CRX.Util.eval(response.responseText);

                    eventObject.fireEvent("reinit", this);

                    if (CRX.NodetypeRegistry) {
                        // todo: probably the wrong place, use event listener
                        // reload node types
                        CRX.NodetypeRegistry.reload(function() {
                            var tree = Ext.getCmp(CRX.ide.TREE_ID);
                            tree.setWorkspace(CRX.Util.getWorkspace());
                        });
                    }
                }
            });
        },
        
        /**
         * Creates a new dialog or returns an existing dialog if there was already a dialog
         * created with the same xtype before.
         *
         * @param {String/Object} config either an xtype string or a full dialog config object
         * @param {Object} dialogs (optional) cache for dialogs; if omitted, a global cache will be used
         **/
        getDialog: function(config, dialogs) {
            dialogs = dialogs || globalDialogs;
            var type   = typeof config === "string" ? config : config.xtype;
            config = typeof config === "string" ? {xtype: type} : config;
            
            if (!dialogs[type]) {
                dialogs[type] = Ext.ComponentMgr.create(config);
            }
            return dialogs[type];
        },

		getLocalWorkspacePath: function(path) {
			var localPath = path.substr(path.indexOf(CRX.ide.JCR_ROOT_NAME) 
									+ CRX.ide.JCR_ROOT_NAME.length);
			if (localPath == "") {
				localPath = "/"; // it the root node
			}
			return decodeURIComponent(localPath);
		},
		
		convertToTreePath: function(path) {
			// encode path
	        var labels = path.split("/");
	        for (var i=0; i<labels.length; i++) {
	            labels[i] = encodeURIComponent(labels[i]);
	        }
	        path = labels.join("/");
			return "/" + CRX.Util.getWorkspace() + "/" + CRX.ide.JCR_ROOT_NAME + path;
		},
		
		setWorkspaceFromPath: function(path) {
            connectionData.workspace = path.substr(0, path.indexOf(CRX.ide.JCR_ROOT_NAME) - 1).substr(1);
		},
		
		setConnectionData: function(data) {
            connectionData = CRX.Util.eval(data);
        },

        getWorkspace: function() {
            return connectionData.workspace;
        },

        getWorkspaces: function() {
            return connectionData.workspaces;
        },

		getLaunchpadContextPath: function() {
            return connectionData.launchpadContextPath == "/" ? "" : connectionData.launchpadContextPath;
        },
        
		getSpiBaseUrl: function() {
			return CRX.Util.getContextPath() + "/server";
		},
		
		getSpiRootUrl: function() {
			return CRX.Util.getSpiBaseUrl() 
			        + "/" + CRX.Util.getWorkspace() 
			        + "/" + CRX.ide.JCR_ROOT_NAME;
		},
		
		getJcrVersion: function() {
			return connectionData.jcrVersion;
		},
		
		getContextPath: function() {
			return connectionData.contextPath;
		},

		getUserID: function() {
			return connectionData.userID;
		},
		
		getFileExtension: function(name) {
			name = name.replace(/^\s|\s$/g, ""); //trims string

			if (/\.\w+$/.test(name)) {
				if (name.match(/([^\/\\]+)\.(\w+)$/)) {
					return RegExp.$2;
				} 
			}
		},
		
		getDateAsISO8601: function(date) {
			return date.format("Y-m-d") + "T" + date.format("H:i:s.uP");
		},

		isFormatISO8601: function(date) {
			return Date.parseDate(date,"Y-m-dTH:i:s.uP") != undefined;
		},
		
		getErrorMsgFromXML: function(response) {
			var msgs, xmlDoc = response.responseXML;
			
			if (xmlDoc) {
				if (Ext.isGecko) {
					msgs = xmlDoc.getElementsByTagName("dcr:message");
					return msgs[0].textContent;
				} else {
					msgs = xmlDoc.getElementsByTagName("message");
					return msgs.item(0).textContent;
				}
			} else {
				return "Unknown error (Error Code: " + response.status + ")";
			}
		},
		
		openActionDialog: function() {
			var dialogId;
			var loadSelection;
			if (this.baseAction) {
				dialogId = this.baseAction.initialConfig.dialogId;
				loadSelection = this.baseAction.initialConfig.loadSelection;
			} else {
				dialogId = this.initialConfig.dialogId;
				loadSelection = this.initialConfig.loadSelection;
			}
			var tree = Ext.getCmp(CRX.ide.TREE_ID);
	    	var node = tree.getSelectionModel().getSelectedNode();
	    	if (node) {
				var dlg = CRX.Util.getDialog(dialogId);
				dlg.init(node);
				
				if (Ext.isFunction(dlg.reset)) {
					dlg.reset();
				}
				
				if (loadSelection) {
					var cb = function() {
						dlg.show();
					};
					if (!node.isLoaded()) {
						node.reload(cb);
					} else {
						cb.call();
					}
				} else {
					dlg.show();
				}
			}
		},
		
		validateNodeName: function(value) {
			var valid = true;
			
			var tree = Ext.getCmp(CRX.ide.TREE_ID);
			var selection = tree.getSelectionModel().getSelectedNode();
        	if (selection) {
				var node = selection.findChild("name", value);
				if (node) {
					if (CRX.State.isDeleted(node.getRealPath())) {
						valid = "A locally deleted node with the same name was detected. "
							+"Please save changes in order to create a new node with this name.";
					} else {
						valid = "A node with this name already exist";
					}
				}
			}
			return valid;
			
			// TODO validate name against child node definitions
		},
		
		createNode: function(name, text, type, parent, loader, atts, data) {
			var attr = loader.processAttributes({
				name:encodeURIComponent(name), text:text,
				primaryType:type
			}, type);
			
			var node = loader.createNode(attr);
			if (node) {
				parent.appendChild(node);

				var propDefs = CRX.NodetypeRegistry.getPropertyDefinitions([ 
					node.getPrimaryType() 
				]);

				if (!atts) {
					atts = {};
				}
				atts[CRX.util.JCR_PRIMARY_TYPE] = type;
				atts[":" + CRX.util.JCR_PRIMARY_TYPE] = CRX.util.NAME;

				var records = loader.createPropertyRecords(atts, propDefs);
				records.each(function(record) {
					if (record.get("name") == CRX.util.JCR_DATA) {
						record.set("type", CRX.util.BINARY);
						if (data) {
							record.set("value", data);
						}
					}
					record.markDirty(); // ugly hack to deal with property grid
				});
				node.addPropertyRecords(records);
				CRX.State.addTransientNode(node);
			}
			return node;
		},
		
		/**
		 * Recursive variant of Ext.applyIf(). The optional last param "r" is
		 * true/false (go recursive), or number (number of levels to go recursive);
		 * defaults to "true".
		 **/
        applyDefaults: function(o, c, r) {
            // default r to true
            r = (typeof r == "undefined") ? true : r;
            
            if (o && c) {
                for (var p in c) {
                    if (typeof o[p] == "undefined") {
                        o[p] = c[p];
                    } else if (typeof o[p] == "object" && r) {
                        if (typeof r == "number") {
                            r--;
                        }
                        CRX.Util.applyDefaults(o[p], c[p], r);
                    }
                }
            }
            return o;
        },
        
        /**
         * Requests the specified URL from the server using GET. The request
         * will be synchronous, unless a callback function is specified.
         * @static
         * @param {String} url The URL to request
         * @param {Function} callback (optional) The callback function which is
         *        called regardless of success or failure and is passed the following
         *        parameters:<ul>
         *        <li><b>options</b> : Object<div class="sub-desc">The parameter to the request call.</div></li>
         *        <li><b>success</b> : Boolean<div class="sub-desc">True if the request succeeded.</div></li>
         *        <li><b>response</b> : Object<div class="sub-desc">The response object.</div></li>
         *        </ul>
         * @return {Mixed} The response object or, if the
         *         request is asynchronous, the transaction ID
         */
        httpGet: function(url, callback) {
            if (callback != undefined) {
                return Ext.Ajax.request({
                    url: url,
                    callback: callback
                });
            } else {
                var request = document.all ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
                try {
                    request.open("GET", url, false);
                    request.send(null);
                    return {
                        status: request.status,
                        body: request.responseText
                    };
                } catch (e) {
                    return null;
                }
            }
        },
        
        /**
         * Pre-caches file contents for {@link #loadFile()}.
         *
         * @param {String} path URL path to the file (without CRX.Util.getContentPath())
         * @param {String} content file contents to cache
         */
        storeFile: function(path, content) {
            fileMap[path] = content;
        },
        
        /**
         * Loads a server side file via Ajax and caches its contents internally.
         * To pre-populate the cache, for example in a single production js file,
         * {@link #storeFile()} can be used.
         *
         * @param {String} path URL path to the file (without CRX.Util.getContentPath(),
         *                      but with leading slash)
         * @param {Boolean} noCaching (optional) if true, the file will be fetched and not
         *                  cached; if it was pre-cached via {@link #storeFile()}
         *                  it will be removed from the cache. Useful for larger
         *                  files that are used one time only
         *
         * @return {String} the file contents or null if not found
         */
        loadFile: function(path, noCaching) {
    		if (fileMap[path] === undefined) {
    		    var response = CRX.Util.httpGet( CRX.Util.getContextPath() + path );
    		    if (response !== null && response.status == 200) {
    		        if (noCaching) {
    		            return response.body;
    		        }
    		        fileMap[path] = response.body;
    		        return fileMap[path];
    		    }
    		    return null;
    		} else {
    		    var content = fileMap[path];
    		    if (noCaching) {
    		        delete fileMap[path];
    		    }
    			return content;
    		}
    	},

        logout: function() {
            Ext.Ajax.request({
                url:CRX.Util.getContextPath() + "/de/logout.jsp",
                params: {
                },
                success:function(response, options) {
                    CRX.Util.setAuthHeader("");
                    CRX.Util.reinit();
                },
                failure:function(response, options) {
                }
            });
            return false;
        },

        isLoggedIn: function() {
            return connectionData && connectionData.userID && connectionData.userID != "anonymous";
        },

        getAuthHeader: function() {
            if (lastAuthHeader) {
                return lastAuthHeader;
            } else {
                if (window.name.indexOf("Basic ") == 0) {
                    return window.name;
                } else {
                    return null;
                }
            }
        },

        setAuthHeader: function(hdr) {
            window.name = lastAuthHeader = hdr;
        },


        login: function(username, password, workspace, opts) {
            Ext.Ajax.request({
                url:CRX.Util.getContextPath() + "/de/login.jsp",
                params: {
                    UserId: username,
                    Password: password,
                    Workspace: workspace,
                    _charset_: "utf-8",
                    ".token": ""
                },
                success:function(response, options) {
                    // TODO: check response if token-auth is supported.
                    var tokenLoginSupported = !!CRX.Util.getCookie("login-token");
                    if (!tokenLoginSupported) {
                        // store auth header
                        CRX.Util.setAuthHeader("Basic " + CRX.Util.base64Encode(username + ":" + password));
                        CRX.Util.setCookie("login-workspace", workspace, CRX.Util.getContextPath());
                    }
                    if (opts.success) {
                        opts.success(response, options);
                    }
                    CRX.Util.reinit();
                },
                failure:function(response, options) {
                    if (opts.failure) {
                        opts.failure(response, options);
                    }
                }
            });
            return false;
    	},

    	/**
    	 * Utility for updating a panel body's contents regardless whether the panel
    	 * is already rendered (ie. the body el is present) or not (ie. if called
    	 * right after the constructor).
    	 */
    	updatePanel: function(panel, html) {
    	    if (panel.body) {
    	        panel.body.update(html);
    	    } else {
    	        panel.html = html;
    	    }
    	},
    	
    	/**
    	 * Rendering bug utility that will re-set the current height of the
    	 * Ext element or component passed.
    	 */
    	updateHeight: function(el) {
    	    var h = el.getHeight();
    	    el.setHeight(h + 1);
    	    el.setHeight(h);
    	},

    	/**
    	 * Rendering bug utility that will re-set the current width of the
    	 * Ext element or component passed.
    	 */
    	updateWidth: function(el) {
    	    var w = el.getWidth();
    	    el.setWidth(w + 1);
    	    el.setWidth(w);
    	}
    };
}();


CRX.util.Mimetypes = function() {
    var mimetypes = {
		"css":"text/css",
		"html":"text/html",
		"js":"text/javascript",
		"ecma":"text/javascript",
		"txt":"text/plain",
		"xml":"text/xml",
		"json":"application/json",
		"java":"text/plain",
		"bnd":"text/plain",
		"esp":"text/plain",
		"jsp":"text/plain",
		"bmp":"image/bmp",
		"bmp":"image/bmp",
		"gif":"image/gif",
		"bmp":"image/bmp",
		"jpg":"image/jpeg",
		"jpeg":"image/jpeg",
		"bmp":"image/bmp",
		"png":"image/png",
		"tif":"image/tiff",
		"tiff":"image/tiff"
	};
    
    return {
        getMimetype: function(name) {
			var ext = CRX.Util.getFileExtension(name);
			if (mimetypes[ext]) {
				return mimetypes[ext];
			} else {
				return "application/octet-stream";
			}
		}
}; 
Posted by 애바른2
, |