summaryrefslogtreecommitdiffstats
path: root/usr/local/www/filebrowser/browser.js
blob: c9788c4e48053fdc58d0a97ce6c842e819ac1d58 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
	pfSense_MODULE:	shell
*/

jQuery(document).ready(
	function() {
		jQuery("#fbOpen").click(
			function() {
				jQuery("#fbBrowser").fadeIn(750);
				fbBrowse(jQuery("#fbTarget").val());
			}
		);
	}
);

function fbBrowse(path) {
	jQuery("#fileContent").fadeOut();

	if(jQuery("#fbCurrentDir"))
		jQuery("#fbCurrentDir").html("Loading ...");

	jQuery.ajax(
		"/filebrowser/browser.php?path=" + encodeURI(path ? path : "/"),
		{ type: "get", complete: fbComplete }
	);
	
}

function fbComplete(req) {
	jQuery("#fbBrowser").html(req.responseText);

	var actions = {
		fbHome:  function() { fbBrowse("/");                                },
		fbClose: function() { jQuery("#fbBrowser").fadeOut(750); },
		fbDir:   function() { fbBrowse(this.id);                            },
		fbFile:  function() { jQuery("#fbTarget").val(this.id);             }
	}

	for(var type in actions) {
		jQuery("#fbBrowser ." + type).each(
			function() {
				jQuery(this).click(actions[type]);
				jQuery(this).css("cursor","pointer");
			}
		);
	}
}
OpenPOWER on IntegriCloud