PageSourceSearch

https://www.joinkfa.com/nexacro17lib/component/extPrototype/File.js

js joinkfa.com collected 2026-10-02 06:35:02 UTC 5,799 bytes, 181 lines download raw bytes

1/**
2*  컨설팅 표준화 작업
3*  @FileName 	File.js 
4*  @Creator 	consulting
5*  @CreateDate 	2017.03.08
6*  @Desction   
7************** 소스 수정 이력 ***********************************************
8*  date          		Modifier                Description
9*******************************************************************************
10*  2017.03.08     	consulting 	                최초 생성 
11*  2017.10.17     	consulting       	        주석 정비
12*******************************************************************************
13*/
14
15var pForm = nexacro.Form.prototype;
16
17/**
18 * @class 현재 Form 상의 FileUpload 컴포넌트를 서버에 업로드한다. <br>
19 * @param {Object} objFileUpload - 파일업로드 컴포넌트
20 * @param {String} [sUrl] - 파일업로드 서비스 호출 경로
21 * @param {String} [sPath] - 파일업로드시킬 폴더 위치
22 * @return N/A
23 * @example 
24 * this.gfn_FileUpload(objFileUpload);
25 */
26pForm.gfn_FileUpload = function(objFileUpload, sUrl, sPath)
27{	
28	var svcUrl = this.gfn_GetServerUrl();
29	
30	if (this.gfn_IsNull(sUrl)) sUrl = svcUrl;
31	
32	//파일업로드 서비스 호출 경로
33	var sFileUrl = sUrl + "fileUpload.jsp";
34    
35	//파일 업로드 시킬 폴더 위치 지정
36	if (this.gfn_IsNull(sPath)) sPath = "PATH=upload";
37	
38	var bSucc = objFileUpload.upload(sFileUrl + "?" + sPath);
39	trace("bSucc >> " + bSucc);
40};
41
42/**
43 * @class 현재 Form 상의 FileDownload 컴포넌트를 이용하여 지정한 위치에서 원하는 파일을 다운로드한다. <br>
44 * @param {Object} objFileDownload - 파일다운로드 컴포넌트
45 * @param {String} sFilename - 다운로드 할 파일명
46 * @param {String} [sUrl] - 파일업로드 서비스 호출 경로
47 * @param {String} [sPath] - 파일업로드시킬 폴더 위치
48 * @return N/A
49 * @example this.gfn_FileUpload(objFileUpload, sFilename);
50 */
51pForm.gfn_FileDownload = function(objFileDownload, sFilename, sUrl, sPath)
52{
53	var svcUrl = this.gfn_GetServerUrl();
54	if (this.gfn_IsNull(sUrl)) sUrl = svcUrl;
55	
56	
57	//파일다운로드 서비스 호출 경로
58	var sFileUrl = sUrl + "fileDownload.jsp";
59	
60	//파일 다운로드할 폴더 위치 지정
61	if (this.gfn_IsNull(sPath)) sPath = "PATH=upload";
62	
63	objFileDownload.download(sFileUrl + "?" + sPath + "&file=" + sFilename);
64};
65
66/**
67 * @class File Path 문자열(예 : C:\a\b\filename.ext)에서 File명(예 : filename)을 추출 <br>
68 * @param {String} sPath - File Path 문자열 (예 : "C:\a\b\filename.ext")
69 * @param {String} bExt - extend를 return되는 File명에 포함시킬지 여부 ( 옵션 : Default=false )
70 * @return {String} 
71 * 성공 : <br>
72 * bExt가 true인 경우 ==> sPath에서 File명(예 : "filename.ext") <br>
73 * bExt가 false인 경우 ==> sPath에서 File명(예 : "filename") <br>
74 * 실패 : "" <br>
75 */
76pForm.gfn_GetFileName = function (sPath, bExt)
77{
78	var start_pos,end_pos,tmp_pos,filename;
79
80	if (this.gfn_IsNull(sPath)) 
81	{
82		return "";
83	}
84	if (this.gfn_IsNull(bExt)) 
85	{
86		bExt = false;
87	}
88
89	start_pos = Math.max(this.gfn_PosReverse(sPath, "\\"), this.gfn_PosReverse(sPath, "/"));
90	tmp_pos = this.gfn_PosReverse(sPath, "::");
91	if (tmp_pos > 0) 
92	{
93		tmp_pos++;
94	}
95	start_pos = Math.max(start_pos, tmp_pos);
96	if (bExt == false) 
97	{
98		end_pos = this.gfn_PosReverse(sPath, ".");
99		if (end_pos < 0) 
100		{
101			end_pos = sPath.length;
102		}
103		filename = sPath.substr(start_pos + 1, end_pos - start_pos - 1);
104	}
105	else 
106	{
107		filename = sPath.substr(start_pos + 1);
108	}
109
110	return filename;
111};
112
113/**
114 * @description 통신 오류 시 발생하는 이벤트입니다
115*/ 
116pForm.gfn_Download_onerror = function(obj, e)
117{
118	trace('gfn_Download_onerror');
119  //런타임에서 e.errortype; <-- 원하는 type이 아닌 error object 가 전송됨.
120	trace("An error occurred: extDownload_onerror index=" + e.index  + ", errortype=" + e.errortype   + "\n, statuscode=" + e.statuscode + ", requesturi=" + e.requesturi);
121	
122};
123
124/**
125 * @description 다운로드 성공시에 발생하는 이벤트입니다
126*/  
127pForm.gfn_Download_onsuccess = function(obj, e)
128{
129	trace('gfn_Download_onsuccess');
130	trace("	 ★ extFileDownload_onsuccess url=" + e.url);
131	
132
133	if(!this.gfn_IsNull(e.url))
134	{
135		alert("Successfully downloaded.");
136	}
137	else
138	{
139		alert("다운로드 실패");
140	}
141	
142};
143/**
144 * @description [HTML5 Only] XMLHttpRequest가 데이터를 보내거나 받는 동안 서버에서 정의된 간격으로 발생합니다.
145 * file upload & download 진행시 progress bar 처리용
146 * @param {ExtFileUpload} obj ExtFileUpload
147 * @param {ExtFileProgress} e ExtFileProgress
148*/   
149pForm.gfn_Download_onprogress = function(obj,e)
150{
151	trace('gfn_Download_onprogress');
152	if (e.lengthComputable)
153	{
154
155	}
156};
157/**
158 * @description [HTML5 Only] 파일다운로드
159 * @param {String} downUrl 	다운로드 fileUrl
160 * @param {String} fileName 다운로드 파일명
161 * @return N/A
162*/   
163pForm.gfn_downloadFile = function(downUrl, fileName)
164{
165	var name = this.gfn_GetUniqueId("gv_Download");
166	if(this.gfn_IsNull(this.gv_Download))
167	{
168		this.gv_Download  = new nexacro.ExtFileDownload(name, this);
169		this.addChild(this.gv_Download.name, this.gv_Download);
170
171		this.gv_Download.addEventHandler("onsuccess", pForm.gfn_Download_onsuccess, false);
172		//통신 오류 시 발생하는 이벤트입니다.
173		this.gv_Download.addEventHandler("onerror", pForm.gfn_Download_onerror, false);
174		//HTML5 Only : XMLHttpRequest가 데이터를 보내거나 받는 동안 서버에서 정의된 간격으로 발생합니다.
175		this.gv_Download.addEventHandler("onprogress", pForm.gfn_Download_onprogress);
176
177		this.gv_Download.show();	
178
179	}
180	this.gv_Download.download(downUrl, fileName)
181};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.