• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt/router/lighttpd-1.4.39/external_file/js_src/
1var g_storage = new myStorage();
2var m = new lang();
3var g_modal_url;
4var g_modal_window_width = 200;
5var g_modal_window_height = 80;
6var g_show_modal = 0;
7var g_folder_array;
8var g_file_array;
9var g_root_path = '';
10var g_sharelink_openurl_key = '';
11var g_image_player_setting = null;
12
13var client = new davlib.DavClient();
14client.initialize();
15
16function closeJqmWindow(v){
17	var $modalWindow = $('div#modalWindow');
18
19	var $modalContainer = $('iframe', $modalWindow);
20	$modalContainer.attr('src', '');
21
22	if($modalWindow)
23		$modalWindow.jqmHide();
24}
25
26function resizeJqmWindow(w,h){
27	var $modalWindow = $('.jqmWindow');
28	if($modalWindow){
29		$modalWindow.css("width", w + "px");
30		$modalWindow.css("height", h + "px");
31	}
32}
33
34function onMouseDownPicDIVHandler(e){
35	if( e.button == 2 ) {
36		return false;
37	}
38
39	openSelItem($(this).parents('.thumb-table-parent').find("a#list_item"));
40}
41
42function openAudioPlayer(loc){
43
44	var audio_array = new Array();
45	for(var i=0;i<g_file_array.length;i++){
46   		var file_ext = getFileExt(g_file_array[i].href);
47		if(file_ext=="mp3")
48   			audio_array.push(g_file_array[i]);
49	}
50
51	var audio_array_count = audio_array.length;
52
53	if(audio_array_count==0){
54		alert("No audio files");
55		return;
56	}
57
58	var audio_list = "";
59	var default_index = 0;
60	for(var i=0;i<audio_array.length;i++){
61		var the_loc = audio_array[i].href;
62	 	if( loc == the_loc )
63	 		default_index = i;
64
65	 	audio_list += the_loc;
66	 	if(i!=audio_array.length-1) audio_list += ",";
67	}
68
69	var $modalWindow = $("div#modalWindow");
70	g_modal_url = '/smb/css/audio.html?a=' + loc + '&alist=' + audio_list + '&index=' + default_index + '&s=0';
71
72	g_modal_window_width = 480;
73	g_modal_window_height = 160;
74	$('#jqmMsg').css("display", "none");
75	$('#jqmTitleText').text(m.getString('title_audioplayer'));
76	if($modalWindow){
77		$modalWindow.jqmShow();
78	}
79}
80
81function openImageViewer(loc){
82
83	var image_array = new Array();
84	for(var i=0;i<g_file_array.length;i++){
85   	var file_ext = getFileExt(g_file_array[i].href);
86		if(file_ext=="jpg"||file_ext=="jpeg"||file_ext=="png"||file_ext=="gif")
87   			image_array.push(g_file_array[i]);
88	}
89
90	var image_array_count = image_array.length;
91
92	if(image_array_count==0){
93		alert(m.getString("msg_no_image_list"));
94		return;
95	}
96
97	var default_index = 0;
98	for(var i=0;i<image_array.length;i++){
99   		if( loc == image_array[i].href )
100   			default_index = i;
101  	}
102
103	var div_html='';
104	var page_size = getPageSize();
105
106	div_html += '<div id="image_slide_show" class="barousel unselectable" style="height: 0; width: 0; position: fixed; background-color: rgb(0, 0, 0); left: ' + page_size[0]/2 + 'px; top: ' + page_size[1]/2 + 'px; z-index: 2999;">';
107	div_html += '<div class="barousel_image">';
108
109	for(var i=0;i<image_array.length;i++){
110
111   		var img_url = image_array[i].href;
112
113   		if(i==default_index)
114   			div_html += '<img src="" path="' + img_url + '" alt="" class="default"/>';
115   		else
116     		div_html += '<img src="" path="' + img_url + '" alt="" class=""/>';
117	}
118
119	div_html += '</div>';
120
121	div_html += '<div class="barousel_nav">';
122
123	div_html += '<div class="barousel_content transparent" style="display: block; ">';
124
125	for( var i=0; i<image_array.length; i++ ){
126		div_html += '<div class="';
127
128   		if(i==default_index)
129     		div_html += 'default';
130
131    	div_html += '" style="display: none; ">';
132
133    	div_html += '<p class="header">' + image_array[i].name + '</p>';
134    	div_html += '</div>';
135	}
136
137	div_html += '</div>';
138
139  	div_html += '</div>';
140
141  	div_html += '<div class="barousel_loading" style="position:absolute;display:none;z-index=99;"><img src="/smb/css/load.gif" width="18px" height="18px"/></div>';
142
143	div_html += '</div>';
144
145	$(div_html)
146		.animate({width:"100%", height:"100%", left:"0px", top:"0px"},200, null, null )
147  		.appendTo("body");
148
149  	var close_handler = function(){
150	  	g_image_player_setting = null;
151	};
152
153	var init_handler = function(settings){
154		g_image_player_setting = settings;
155	};
156
157	$('#image_slide_show').barousel({
158		name: 'image_slide_show',
159		manualCarousel: 1,
160		contentResize:0,
161		startIndex:default_index,
162		storage: g_storage,
163		stringTable: m,
164		enableExifFunc: 0,
165		enableShareFunc: 0,
166		closeHandler: close_handler,
167		initCompleteHandler: init_handler
168	});
169
170	image_array = null;
171}
172
173function openSelItem(item){
174	var loc = item.attr("uhref");
175	var qtype = item.attr("qtype");
176	var isdir = item.attr("isdir");
177	var isusb = item.attr("isusb");
178	var this_full_url = item.attr("uhref");
179	var this_play_full_url = item.attr("playhref");
180	var this_file_name = item.attr("title");
181	//alert(this_full_url);
182	var fileExt = getFileExt(loc);
183
184	if( fileExt=="mp4" ||
185		  fileExt=="m4v" ||
186		  fileExt=="wmv" ||
187		  fileExt=="avi" ||
188		  fileExt=="rmvb"||
189		  fileExt=="rm"  ||
190		  fileExt=="mpg" ||
191		  fileExt=="mpeg"||
192		  fileExt=="mkv" ||
193		  fileExt=="mov" ||
194		  fileExt=="flv" ) {
195
196		if( isWinOS() ){
197			if( isBrowser("msie") &&
198				getInternetExplorerVersion() <= 7 ){
199				//- The VLC Plugin doesn't support IE 7 or less
200				alert(m.getString('msg_vlcsupport'));
201			}
202			else{
203				var $modalWindow = $("div#modalWindow");
204
205				var media_hostName = window.location.host;
206				if(media_hostName.indexOf(":")!=-1){
207					media_hostName = media_hostName.substring(0, media_hostName.indexOf(":"));
208				}
209				media_hostName = "http://" + media_hostName + ":" + g_storage.get('slhp');
210
211				open_url = '/smb/css/vlc_video.html?v=' + media_hostName + this_full_url;
212				open_url += '&showbutton=1';
213
214				//- subtitle
215				var array_srt_files = new Array();
216				for(var i=0;i<g_file_array.length;i++){
217					var file_ext = getFileExt(g_file_array[i].href);
218					if(file_ext=="srt"){
219						array_srt_files.push(g_file_array[i].href);
220					}
221				}
222
223				if(array_srt_files.length>0){
224					open_url += '&s=';
225					for(var i=0;i<array_srt_files.length;i++){
226						open_url += array_srt_files[i];
227						if(i!=array_srt_files.length-1) open_url += ";";
228					}
229				}
230				array_srt_files=null;
231
232				//alert(open_url);
233
234				g_modal_url = open_url;
235				g_modal_window_width = 655;
236				g_modal_window_height = 580;
237				$('#jqmMsg').css("display", "none");
238				$('#jqmTitleText').text(m.getString('title_videoplayer'));
239				if($modalWindow){
240					$modalWindow.jqmShow();
241				}
242				return;
243			}
244		}
245	}
246
247	if( fileExt=="mp3" ) {
248		openAudioPlayer(loc);
249		return;
250	}
251
252	if( fileExt=="doc" || fileExt=="docx" ||
253	    fileExt=="ppt" || fileExt=="pptx" ||
254	    fileExt=="xls" || fileExt=="xlsx" ||
255	    fileExt=="pdf") {
256		//- It will open with google doc viewer when OS is window or mac and using public ip.
257		if( ( isWinOS() || isMacOS() ) && !isPrivateIP() ){
258		 	var open_url = 'https://docs.google.com/viewer?url=' + loc;
259			window.open(open_url);
260			return;
261		}
262	}
263
264	if( fileExt=="jpg" ||
265	    fileExt=="jpeg"||
266	    fileExt=="png" ||
267	    fileExt=="gif" ){
268		openImageViewer(loc);
269		return;
270	}
271
272	if(isdir==1){
273		doPROPFIND(loc, null, 0);
274	}
275	else
276		window.open(loc);
277		//window.location = loc;
278}
279
280function sortByName(a, b) {
281	var x = a.name.toLowerCase();
282  var y = b.name.toLowerCase();
283  return ((x < y) ? -1 : ((x > y) ? 1 : 0));
284}
285
286function createThumbView(query_type, parent_url, folder_array, file_array){
287	var html = "";
288
289	$("div#fileview").empty();
290
291	if(query_type==2)
292		return;
293
294	var parent_path = decodeURI(parent_url);
295	var root_path = decodeURI(g_root_path);
296
297	//- Parent Path
298	if( parent_path.indexOf(root_path) != -1 ){
299		html += '<div class="albumDiv">';
300		html += '<table class="thumb-table-parent">';
301		html += '<tbody>';
302		html += '<tr><td>';
303		html += '<div class="picDiv" isParent="1" popupmenu="0" uhref="';
304		html += parent_url;
305		html += '">';
306		html += '<div class="parentDiv bicon"></div></div>';
307		html += '</td></tr>';
308		html += '<tr><td>';
309		html += '<div class="albuminfo">';
310		html += '<a id="list_item" qtype="1" isdir="1" uhref="';
311		html += parent_url;
312		html += '" title="' + m.getString("btn_prevpage") + '" online="0">' + m.getString("btn_prevpage");
313		html += '</a>';
314		html += '</div>';
315		html += '</td></tr>';
316		html += '</tbody>';
317		html += '</table>';
318		html += '</div>';
319	}
320
321	//- Folder List
322	for(var i=0; i<folder_array.length; i++){
323		var this_title = m.getString("table_filename") + ": " + folder_array[i].name;
324
325		if(folder_array[i].time!="")
326			this_title += "\n" + m.getString("table_time") + ": " + folder_array[i].time;
327
328		html += '<div class="albumDiv" ';
329		html += ' title="';
330		html += this_title;
331		html += '">';
332		html += '<table class="thumb-table-parent">';
333		html += '<tbody>';
334
335		html += '<tr><td>';
336		html += '<div class="picDiv" popupmenu="';
337
338		if(query_type == "0")
339			html += '1';
340		else
341			html += '0';
342
343		html += '" uhref="';
344		html += folder_array[i].href;
345		html += '">';
346
347		if(query_type == "2"){
348				//- Host Query
349				if( folder_array[i].type == "usbdisk" )
350					html += '<div id="fileviewicon" class="usbDiv bicon">';
351				else{
352					if(folder_array[i].online == "1")
353						html += '<div id="fileviewicon" class="computerDiv bicon">';
354					else
355						html += '<div id="fileviewicon" class="computerOffDiv bicon">';
356				}
357		}
358		else {
359			html += '<div id="fileviewicon" class="folderDiv bicon">';
360		}
361
362		//- Show router sync icon.
363		if( folder_array[i].routersyncfolder == "1" ){
364			html += '<div id="routersyncicon" class="routersyncDiv sicon"></div>';
365		}
366
367		html += '<div class="selectDiv sicon"></div>';
368		html += '<div class="selectHintDiv sicon"></div>';
369		html += '</div></div>';
370		html += '</td></tr>';
371		html += '<tr><td>';
372		html += '<div class="albuminfo">';
373		html += '<a id="list_item" qtype="';
374		html += query_type;
375		html += '" isdir="1" uhref="';
376		html += folder_array[i].href;
377		html += '" title="';
378		html += folder_array[i].name;
379		html += '" online="';
380		html += folder_array[i].online;
381		html += '" ip="" mac="';
382		html += folder_array[i].mac;
383		html += '" uid="';
384		html += folder_array[i].uid;
385		html += '" freadonly="';
386		html += folder_array[i].freadonly;
387		html += '" fhidden="';
388		html += folder_array[i].fhidden;
389
390		if(folder_array[i].type == "usbdisk")
391			html += '" isusb="1"';
392		else
393			html += '" isusb="0"';
394
395		html += '">';
396
397		html += folder_array[i].shortname;
398
399		if(folder_array[i].online == "0" && query_type == "2")
400			html += "(" + m.getString("title_offline") + ")";
401
402		html += '</a>';
403		html += '</div>';
404		html += '</td></tr>';
405
406		html += '<tr><td>';
407		//- Disable download folder function before we found the solution.
408		//html += '<input type="button" class="btnDownload" value="' + m.getString("func_download") + '">';
409		html += '</td></tr>';
410
411		html += '</tbody>';
412		html += '</table>';
413		html += '</div>';
414
415		/*
416		if(folder_array[i].type == "usbdisk"&&query_type==1){
417			//alert(folder_array[i].name+","+folder_array[i].href+","+query_type);
418
419			client.GETDISKSPACE("/", folder_array[i].name, function(error, statusstring, content){
420				if(error==200){
421					var data = parseXml(content);
422					var x = $(data);
423
424					var queryTag = $('a#list_item[title="' + x.find("DiskName").text() + '"]').parents(".albumDiv");
425
426					var title = queryTag.attr("title") + "\n" + m.getString("table_diskusedpercent") + ": " + x.find("DiskUsedPercent").text();
427					queryTag.attr("title", title);
428
429					//$('a#list_item[title="' + x.find("DiskName").text() + '"]').text(x.find("DiskUsedPercent").text());
430	    		//alert(x.find("DiskUsed").text()+", "+x.find("DiskAvailable").text()+", "+x.find("DiskUsedPercent").text());
431				}
432			});
433		}
434		*/
435
436	}
437
438	//- File List
439	for(var i=0; i<file_array.length; i++){
440		var this_title = m.getString("table_filename") + ": " + file_array[i].name + "\n" +
441		                 m.getString("table_time") + ": " + file_array[i].time + "\n" +
442		                 m.getString("table_size") + ": " + file_array[i].size;
443
444		html += '<div class="albumDiv"';
445		html += ' title="';
446		html += this_title;
447		html += '">';
448		html += '<table class="thumb-table-parent">';
449		html += '<tbody>';
450
451		//- get file ext
452		var file_path = String(file_array[i].href);
453		var file_ext = getFileExt(file_path);
454		if(file_ext.length>5)file_ext="";
455
456		html += '<tr><td>';
457		if(query_type == "0")
458			html += '<div class="picDiv" popupmenu="1" uhref="';
459		else
460			html += '<div class="picDiv" popupmenu="0" uhref="';
461		html += file_array[i].href;
462		html += '">';
463
464		if(file_ext=="jpg"||file_ext=="jpeg"||file_ext=="png"||file_ext=="gif"||file_ext=="bmp")
465			html += '<div id="fileviewicon" class="imgfileDiv bicon">';
466		else if(file_ext=="mp3"||file_ext=="m4a"||file_ext=="m4r"||file_ext=="wav")
467			html += '<div id="fileviewicon" class="audiofileDiv bicon">';
468		else if(file_ext=="mp4"||file_ext=="rmvb"||file_ext=="m4v"||file_ext=="wmv"||file_ext=="avi"||file_ext=="mpg"||
469			      file_ext=="mpeg"||file_ext=="mkv"||file_ext=="mov"||file_ext=="flv"||file_ext=="3gp"||file_ext=="m2v"||file_ext=="rm")
470			html += '<div id="fileviewicon" class="videofileDiv bicon">';
471		else if(file_ext=="doc"||file_ext=="docx")
472			html += '<div id="fileviewicon" class="docfileDiv bicon">';
473		else if(file_ext=="ppt"||file_ext=="pptx")
474			html += '<div id="fileviewicon" class="pptfileDiv bicon">';
475		else if(file_ext=="xls"||file_ext=="xlsx")
476			html += '<div id="fileviewicon" class="xlsfileDiv bicon">';
477		else if(file_ext=="pdf")
478			html += '<div id="fileviewicon" class="pdffileDiv bicon">';
479		else{
480			html += '<div id="fileviewicon" class="fileDiv bicon">';
481		}
482
483		html += '<div class="selectDiv sicon"></div>';
484		html += '<div class="selectHintDiv sicon"></div>';
485		html += '</div></div>';
486
487		html += '</td></tr>';
488		html += '<tr><td>';
489		html += '<div class="albuminfo" style="font-size:80%">';
490		html += '<a id="list_item" qtype="1" isdir="0" uhref="';
491		html += file_array[i].href;
492		html += '" title="';
493		html += file_array[i].name;
494		html += '" uid="';
495		html += file_array[i].uid;
496		html += '" ext="';
497		html += file_ext;
498		html += '" freadonly="';
499		html += file_array[i].freadonly;
500		html += '" fhidden="';
501		html += file_array[i].fhidden;
502		html += '">';
503		html += file_array[i].shortname;
504		html += '</a>';
505		html += '</div>';
506		html += '</td></tr>';
507
508		html += '<tr><td>';
509		html += '<input type="button" class="btnDownload" value="' + m.getString("func_download") + '">';
510		html += '</td></tr>';
511
512		html += '</tbody>';
513		html += '</table>';
514		html += '</div>';
515	}
516
517	$("div#fileview").append(html);
518
519	$(".picDiv").mousedown( onMouseDownPicDIVHandler );
520	$('input.btnDownload').click(function(){
521		var list_item = $(this).parents('.thumb-table-parent').find("a#list_item");
522		var isdir = list_item.attr("isdir");
523		var loc = list_item.attr('uhref');
524
525		if(isdir==1){
526			var $modalWindow = $("div#modalWindow");
527			g_modal_url = '/smb/css/download_folder.html?v='+loc+'&p=slhp&a=agt&u='+g_storage.get(g_sharelink_openurl_key);
528
529			g_modal_window_width = 600;
530			g_modal_window_height = 150;
531			$('#jqmMsg').css("display", "none");
532			$('#jqmTitleText').text(m.getString('title_download_folder'));
533			if($modalWindow){
534				$modalWindow.jqmShow();
535			}
536
537		}
538		else{
539			window.open(loc);
540		}
541	});
542
543	$('input.btnDownloadAll').click(function(){
544
545		var $modalWindow = $("div#modalWindow");
546		var openurl = g_root_path;
547		openurl = openurl.substr(0, openurl.lastIndexOf("/") );
548		g_modal_url = '/smb/css/download_folder.html?v='+g_root_path+'&p=slhp&a=agt&u='+openurl;
549
550		g_modal_window_width = 600;
551		g_modal_window_height = 150;
552		$('#jqmMsg').css("display", "none");
553		$('#jqmTitleText').text(m.getString('title_download_folder'));
554
555		if($modalWindow){
556			$modalWindow.jqmShow();
557		}
558	});
559}
560
561function doPROPFIND(open_url, complete_handler, auth){
562	if(client==null)
563		return;
564
565	//showHideLoadStatus(true);
566
567	try{
568
569		client.PROPFIND(open_url, auth, function(error, statusstring, content){
570			if(error){
571
572				if(error==207){
573
574					var parser;
575					var xmlDoc;
576
577					g_folder_array = new Array();
578					g_file_array = new Array();
579
580					if (window.DOMParser){
581						parser=new DOMParser();
582						xmlDoc=parser.parseFromString(content,"text/xml");
583					}
584					else { // Internet Explorer
585						xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
586            			xmlDoc.async="false";
587						xmlDoc.loadXML(content);
588
589						if(!xmlDoc.documentElement){
590							alert("Fail to load xml!");
591							showHideLoadStatus(false);
592							return;
593						}
594					}
595
596					var i, j, k, l, n;
597					var x = xmlDoc.documentElement.childNodes;
598
599					var this_query_type = xmlDoc.documentElement.getAttribute('qtype'); //- 2: query host, 1: query share, 0: query file
600					var this_folder_readonly = xmlDoc.documentElement.getAttribute('readonly');
601					var this_router_username = xmlDoc.documentElement.getAttribute('ruser');
602					var this_computer_name = xmlDoc.documentElement.getAttribute('computername');
603					var this_isusb = xmlDoc.documentElement.getAttribute('isusb');
604
605					//- D:Response
606					for (i=0;i<x.length;i++){
607						var this_href = "";
608						var this_contenttype = "";
609						var this_uniqueid = "";
610						var this_name = "";
611						var this_short_name = "";
612						var this_online = "";
613						var this_lastmodified = "";
614						var this_contentlength = "";
615						var this_ip = "";
616						var this_mac = "";
617						var this_type = "";
618						var this_attr_readonly = "";
619						var this_attr_hidden = "";
620						var this_uncode_name;
621						var this_user_agent = "";
622						var this_router_sync_folder = "0";
623
624						var y = x[i].childNodes;
625						for (j=0;j<y.length;j++){
626							if(y[j].nodeType==1&&y[j].nodeName=="D:propstat"){
627
628								var z = y[j].childNodes;
629
630								for (k=0;k<z.length;k++)
631								{
632									if(z[k].nodeName=="D:prop"){
633
634										var a = z[k].childNodes;
635
636										for (l=0;l<a.length;l++)
637										{
638											if(a[l].childNodes.length<=0)
639												continue;
640
641											if(a[l].nodeName=="D:getcontenttype"){
642												this_contenttype = String(a[l].childNodes[0].nodeValue);
643											}
644											else if(a[l].nodeName=="D:getuniqueid"){
645												this_uniqueid = String(a[l].childNodes[0].nodeValue);
646											}
647											else if(a[l].nodeName=="D:getonline"){
648												this_online = String(a[l].childNodes[0].nodeValue);
649											}
650											else if(a[l].nodeName=="D:getlastmodified"){
651												this_lastmodified = String(a[l].childNodes[0].nodeValue);
652											}
653											else if(a[l].nodeName=="D:getcontentlength"){
654												this_contentlength = String( size_format(parseInt(a[l].childNodes[0].nodeValue)));
655											}
656											else if(a[l].nodeName=="D:getmac"){
657												this_mac = String(a[l].childNodes[0].nodeValue);
658											}
659											else if(a[l].nodeName=="D:getip"){
660												this_ip = String(a[l].childNodes[0].nodeValue);
661											}
662											else if(a[l].nodeName=="D:gettype"){
663												this_type = String(a[l].childNodes[0].nodeValue);
664											}
665											else if(a[l].nodeName=="D:getattr"){
666												var bb = a[l].childNodes;
667												for (n=0;n<bb.length;n++){
668													if(bb[n].nodeName=="D:readonly")
669														this_attr_readonly = bb[n].childNodes[0].nodeValue;
670													else if(bb[n].nodeName=="D:hidden")
671														this_attr_hidden = bb[n].childNodes[0].nodeValue;
672												}
673											}
674											else if(a[l].nodeName=="D:getuseragent"){
675												this_user_agent = String(a[l].childNodes[0].nodeValue);
676												g_storage.set('user_agent', this_user_agent);
677											}
678											else if(a[l].nodeName=="D:getroutersync"){
679												this_router_sync_folder = String(a[l].childNodes[0].nodeValue);
680											}
681										}
682									}
683								}
684							}
685							else if(y[j].nodeType==1&&y[j].nodeName=="D:href"){
686								this_href = String(y[j].childNodes[0].nodeValue);
687
688								var cur_host = "";
689
690								if(this_href.match(/^http/))
691									cur_host = window.location.protocol + "//" + window.location.host;
692
693								var cururl = cur_host + addPathSlash(open_url);
694
695								if(this_href!=cururl){
696									var o_url = open_url;
697
698									this_href = this_href.replace(cur_host,"");
699
700									this_name = this_href.substring( this_href.lastIndexOf("/")+1, this_href.length );
701
702									if(this_name!=""){
703										this_uncode_name = this_name;
704
705										this_name = mydecodeURI(this_name);
706										this_short_name = this_name;
707									}
708									else{
709										this_href="";
710									}
711								}
712								else{
713									this_href="";
714								}
715							}
716						}
717
718						if(this_href!=""){
719								if( this_contenttype=="httpd/unix-directory" ){
720
721									g_folder_array.push({ contenttype: this_contenttype,
722										                  href: this_href,
723										                  name: this_name,
724										                  uname: this_uncode_name,
725										                  shortname: this_short_name,
726										                  online: this_online,
727										                  time: this_lastmodified,
728										                  size: this_contentlength,
729										                  ip: this_ip,
730										                  mac: this_mac,
731										                  uid: this_uniqueid,
732										                  type: this_type,
733										                  freadonly: this_attr_readonly,
734										                  fhidden: this_attr_hidden,
735										                  routersyncfolder: this_router_sync_folder });
736								}
737								else{
738									g_file_array.push({ contenttype: this_contenttype,
739										                href: this_href,
740										                name: this_name,
741										                uname: this_uncode_name,
742										                shortname: this_short_name,
743										                online: this_online,
744										                time: this_lastmodified,
745										                size: this_contentlength,
746										                ip: this_ip,
747										                mac: this_mac,
748										                uid: this_uniqueid,
749										                type: this_type,
750										                freadonly: this_attr_readonly,
751										                fhidden: this_attr_hidden,
752										                routersyncfolder: this_router_sync_folder });
753								}
754						}
755					}
756
757					//- Sort By Name
758					g_folder_array.sort(sortByName);
759					g_file_array.sort(sortByName);
760
761					//- parent url
762					var parent_url = addPathSlash(open_url);
763					if(parent_url!="/"){
764						parent_url = parent_url.substring(0, parent_url.length-1);
765						parent_url = parent_url.substring(0, parent_url.lastIndexOf("/"));
766						if( parent_url=="" ) parent_url="/";
767					}
768
769					//- Create File thumb list
770					createThumbView(this_query_type, parent_url, g_folder_array, g_file_array);
771
772					g_storage.set(g_sharelink_openurl_key, open_url);
773
774					$('div#fileview').scrollLeft(g_storage.get('contentscrollLeft'));
775					$('div#fileview').scrollTop(g_storage.get('contentscrollTop'));
776
777					closeJqmWindow(0);
778
779					if(complete_handler!=undefined){
780	  				complete_handler();
781	  			}
782		  	}
783		  	else if(error==501){
784					doPROPFIND(open_url);
785				}
786				else{
787					alert(m.getString(error));
788				}
789
790				//showHideLoadStatus(false);
791			}
792		}, null, 1);
793
794		//resetTimer();
795	}
796	catch(err){
797		//Handle errors here
798	  alert('catch error: '+ err);
799	}
800}
801
802$(document).ready(function(){
803	document.oncontextmenu = function() {return false;};
804
805	$(document).keydown(function(e) {
806		if (e.keyCode == 27) {
807			$('#image_slide_show').close(g_image_player_setting);
808		}
809		else if(e.keyCode == 37){
810			//- left(prev) key
811			$('#image_slide_show').prev(g_image_player_setting);
812		}
813		else if(e.keyCode == 39){
814			//- right(next) key
815			$('#image_slide_show').next(g_image_player_setting);
816		}
817	});
818
819	var loc_lan = String(window.navigator.userLanguage || window.navigator.language).toLowerCase();
820	var lan = ( g_storage.get('lan') == undefined ) ? loc_lan : g_storage.get('lan');
821	m.setLanguage(lan);
822
823	g_storage.set('slhp', $("div#fileview").attr("port"));
824	g_storage.set('agt', "");
825	g_root_path = $("div#fileview").attr("rootpath");
826	g_sharelink_openurl_key = g_root_path;
827
828	var openurl = g_storage.get(g_sharelink_openurl_key);
829	if(openurl==undefined) openurl = g_root_path;
830	doPROPFIND( openurl, null, 0);
831
832	//- modal window
833	var modalWindow_html = "";
834	modalWindow_html += "<div id='modalWindow' class='jqmWindow'>";
835	modalWindow_html += "<div id='jqmTitle'>";
836	modalWindow_html += "<span id='jqmTitleText'></span>";
837	modalWindow_html += "</div>";
838	modalWindow_html += "<div id='jqmMsg'>";
839	modalWindow_html += "<span id='jqmMsgText'></span>";
840	modalWindow_html += "</div>";
841	modalWindow_html += "<div id='jqmContent' style='padding;0px;margin:0px'>";
842	modalWindow_html += "</div>";
843	modalWindow_html += "</div>";
844	$(modalWindow_html).appendTo($("body"));
845
846	$('input.btnDownloadAll').attr("value", m.getString('func_downloadall'));
847
848	function closeModal(hash){
849		var $modalWindow = $(hash.w);
850		$modalWindow.fadeOut('2000', function(){
851
852			hash.o.remove();
853
854			g_show_modal = 0;
855		});
856	}
857
858	function openModal(hash){
859		var $modalWindow = $(hash.w);
860		var $modalContent = $('#jqmContent', $modalWindow);
861		var $modalTitle = $('#jqmTitle', $modalWindow);
862		var page_size = getPageSize();
863		var page_width = page_size[0];
864		var page_height = page_size[1];
865		var newLeft = (page_width - g_modal_window_width)/2;
866		var newTop = 0;
867		g_show_modal = 1;
868
869		var sAgent = navigator.userAgent.toLowerCase();
870
871   		var getInternetExplorerVersion = function(){
872		   var rv = -1; // Return value assumes failure.
873		   if (navigator.appName == 'Microsoft Internet Explorer')
874		   {
875		      var ua = navigator.userAgent;
876		      var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
877		      if (re.exec(ua) != null)
878		         rv = parseFloat( RegExp.$1 );
879		   }
880		   return rv;
881		};
882
883		if(g_modal_url!=""){
884			$modalContent.empty();
885
886			var iframe_html = "<iframe src='' frameborder='0' width='100%' height='100%'>";
887			$(iframe_html).appendTo($modalContent);
888
889			var $modalContainer = $('iframe', $modalWindow);
890			$modalContainer.attr('src', g_modal_url);
891		}
892
893		if(isBrowser("msie")&&getInternetExplorerVersion()<=8)
894			g_modal_window_height+=25;
895
896		$modalWindow.css({
897			width:g_modal_window_width,
898			height:g_modal_window_height,
899			left:newLeft,
900			top:-g_modal_window_height,
901			opacity:0,
902			display:"block"
903		}).jqmShow().animate({
904			width:g_modal_window_width,
905			height:g_modal_window_height,
906			top:newTop,
907			left:newLeft,
908			marginLeft:0,
909			opacity:1
910		}, 200, function() {
911	    // Animation complete.
912	  } );
913
914	}
915
916	$("#modalWindow").jqm({
917		overlay:70,
918		modal:true,
919		target: '#jqmContent',
920		onHide:closeModal,
921		onShow:openModal
922	});
923});