-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathjqueryFileTree.js
executable file
·39 lines (33 loc) · 1.05 KB
/
jqueryFileTree.js
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
// jQuery File Tree Plugin
//
if (jQuery) (function($){
$.extend($.fn, {
fileTree: function(options, callback) {
// Defaults
var defaults = {
script: 'jqueryFileTree.php',
root: '/',
loadingMessage: 'Loading...'
};
// Expand the defaults with the supplied options
options = $.extend(defaults, options);
$(this).each(function() {
var $this = $(this);
$this.html('<ul class="jqueryFileTree start"><li class="wait">' + options.loadingMessage + '<li></ul>');
$.get(options.script, {dir: 'nothingyet'}, function (data) {
var listHtml = '';
for (var i in data) {
if (data.hasOwnProperty(i)) {
var item = data[i],
classHtml = (item.dir?' class="dir"':'');
console.log(item);
listHtml += '<li' + classHtml + '>' + item.name + '</li>';
console.log(listHtml);
}
};
$this.find('.start').html(listHtml);
}, 'json');
});
}
});
})(jQuery);