PageSourceSearch

https://www.ammersbek.de/wp-content/plugins/wp-file-download/app/site/assets/js/jaofiletree.js?ver=6.3.4

js ammersbek.de collected 2026-10-02 21:33:48 UTC 12,842 bytes, 320 lines download raw bytes

1// jQuery File Tree Plugin
2//
3// Version 1.0
4//
5// Base on the work of Cory S.N. LaViska  A Beautiful Site (http://abeautifulsite.net/)
6// Dual-licensed under the GNU General Public License and the MIT License
7// Icons from famfamfam silk icon set thanks to http://www.famfamfam.com/lab/icons/silk/
8//
9// Usage : $('#jao').jaofiletree(options);
10//
11// Author: Damien Barrère
12// Website: http://www.crac-design.com
13
14(function ($) {
15    var options = {
16        'root': '/',
17        'script': 'connectors/jaoconnector.php',
18        'showroot': 'root',
19        'onclick': function (elem, type, file) {
20        },
21        'oncheck': function (elem, checked, type, file) {
22        },
23        'expanded': false,
24        'expandedParent': false,
25        'usecheckboxes': true, // Can be true files dirs or false
26        'expandSpeed': 0,
27        'collapseSpeed': 0,
28        'expandEasing': null,
29        'collapseEasing': null,
30        'canselect': true
31    };
32
33    var methods = {
34        init: function (o) {
35            if ($(this).length == 0) {
36                return;
37            }
38            $this = $(this);
39            $.extend(options, o);
40            $(this).data('jaofiletree', $.extend({}, options));
41            if (typeof wpfdparams !== 'undefined' && wpfdparams.hasOwnProperty('allow_category_tree_parent_expanded')) {
42                options.expandedParent = parseInt(wpfdparams.allow_category_tree_parent_expanded) === 1 ? true : false;
43            }
44            firstload(options.root, $this);
45        },
46        open: function (dir, $this) {
47            openfolder(dir, $this);
48        },
49        close: function (dir, $this) {
50            closedir(dir, $this);
51        },
52        getchecked: function () {
53            var list = new Array();
54            var ik = 0;
55            $this.find('input:checked + a').each(function () {
56                list[ik] = {
57                    type: $(this).attr('data-type'),
58                    file: $(this).attr('data-file')
59                }
60                ik++;
61            });
62            return list;
63        },
64        getselected: function () {
65            var list = new Array();
66            var ik = 0;
67            $this.find('li.selected > a').each(function () {
68                list[ik] = {
69                    type: $(this).attr('data-type'),
70                    file: $(this).attr('data-file')
71                }
72                ik++;
73            });
74            return list;
75        }
76    };
77    firstload = function (dir, $this) {
78        $.ajax({
79            url: options.script,
80            data: {dir: dir},
81            context: $this,
82            dataType: 'json',
83            beforeSend: function () {
84                this.find('a[data-file="' + dir + '"]').parent().addClass('wait');
85            }
86        }).done(function (datas) {
87            if (typeof datas !== 'undefined' && datas.success) {
88                if (typeof datas.data !== 'undefined' && datas.data) {
89                    var tree = buildtree(datas.data, true, dir);
90                    $this.html(tree);
91                    if (options.expandedParent) {
92                        setTimeout(function () {
93                            if ($('.icon-open-close[data-parent_id=0]').length) {
94                                $this.find('.icon-open-close[data-parent_id=0]').click();
95                            } else {
96                                if (typeof datas.data[0].term_id !== 'undefined' && $('.icon-open-close[data-id=' + datas.data[0].term_id + ']').length) {
97                                    $this.find('.icon-open-close[data-id=' + datas.data[0].term_id + ']').click();
98                                }
99                            }
100                        }, 100);
101                    }
102                    setevents($this);
103                } else {
104                    $this.html('No cat found');
105                }
106            } else {
107                if (typeof datas.message !== 'undefined') {
108                    $this.html(datas.message);
109                } else {
110                    $this.html('Something wrong! Please reload this page.');
111                }
112            }
113        });
114    };
115    buildtree = function (datas, display, dir) {
116        // Sort by term_group
117        var sortable = [];
118        for (var key in datas) {
119            sortable.push(datas[key]);
120        }
121        datas = [];
122        sortable.forEach(function (data) {
123            if (typeof data !== 'function') {
124                datas.push(data);
125            }
126        });
127        ret = '<ul class="jaofiletree" ';
128        if (options.expanded) {
129            display === true;
130        }
131        if (display) {
132            ret += '>';
133        } else {
134            ret += 'style="display: none">';
135        }
136        for (var id = 0; id < datas.length; id++) {
137            classe = 'directory collapsed';
138            var parent_id = datas[id].parent;
139            var cat_id = datas[id].term_id;
140            if (typeof parent_id === 'undefined') {
141                parent_id = 0;
142            }
143            if (options.expanded) {
144                classe = 'directory';
145                if (typeof dir !== 'undefined') {
146                    classe += ' selected';
147                }
148                if (typeof datas[id].children !== 'undefined' && datas[id].children.length > 0) {
149                    classe += ' expanded';
150                }
151            }
152            if (datas[id].term_id === 0) {
153                cat_id = 'all_0';
154                classe = 'directory selected';
155                if (typeof datas[id].children !== 'undefined' && datas[id].children.length > 0) {
156                    classe += ' expanded';
157                }
158            }
159            ret += '<li class="' + classe + '">';
160            if (typeof datas[id].children !== 'undefined' && datas[id].children.length > 0) {
161                ret += '<div class="icon-open-close" data-id="' + datas[id].term_id + '" data-parent_id="' + parent_id + '" data-file="' + datas[id].term_id + '" ></div>';
162            }
163
164            var classIcon = '';
165            var color = '';
166            if (typeof (datas[id].color) !== 'undefined' && datas[id].color !== '') {
167                color = 'color: ' + datas[id].color;
168            } else {
169                color = 'color: #b2b2b2';
170            }
171
172            if (typeof datas[id].cloudType !== 'undefined' && typeof datas[id].cloudType !== 'number' && datas[id].cloudType !== false) {
173                classIcon = ' wpfd-icon-cloud wpfd-icon-' + datas[id].cloudType;
174            }
175
176            if (datas[id].term_id === dir) {
177                ret += '<i class="zmdi zmdi-folder zmdi-folder-open' + classIcon + '" style="' + color + '"></i>';
178            } else {
179                ret += '<i class="zmdi zmdi-folder' + classIcon + '" style="' + color + '"></i>';
180            }
181
182            ret += '<a href="#" data-file="' + datas[id].term_id + '" data-catid="' + cat_id + '" data-parent_id="' + parent_id + '">' + datas[id].name + '</a>';
183            if (typeof datas[id].children !== 'undefined') {
184                var display = options.expanded;
185                if (datas[id].term_id === 0) {
186                    display = true;
187                }
188                ret += buildtree(datas[id].children, display);
189            }
190            ret += '</li>';
191        }
192        ret += '</ul>';
193
194        return ret;
195    };
196
197    openfolder = function (dir, $this) {
198        if ($this.find('a[data-file="' + dir + '"]').parent().hasClass('expanded')) {
199            return;
200        }
201        $this.find('a[data-file="' + dir + '"]').parent().removeClass('wait').removeClass('collapsed').addClass('expanded');
202        $this.find('a[data-file="' + dir + '"]').parent().find(' > .zmdi.zmdi-folder').removeClass('zmdi-folder').addClass('zmdi-folder-outline');
203        $this.find('a[data-file="' + dir + '"]').next().slideDown(options.expandSpeed, options.expandEasing);
204        setevents($this);
205
206        //Trigger custom event
207        $this.trigger('afteropen');
208        $this.trigger('afterupdate');
209    };
210
211    closedir = function (dir, $this) {
212        $this.find('a[data-file="' + dir + '"]').next().slideUp(options.collapseSpeed, options.collapseEasing);
213        $this.find('a[data-file="' + dir + '"]').parent().removeClass('expanded').addClass('collapsed');
214        $this.find('a[data-file="' + dir + '"]').parent().find(' > .zmdi.zmdi-folder-outline').removeClass('zmdi-folder-outline').addClass('zmdi-folder');
215        setevents($this);
216
217        //Trigger custom event
218        $this.trigger('afterclose');
219        $this.trigger('afterupdate');
220    };
221
222    setevents = function ($this) {
223        var options = $this.data('jaofiletree');
224        var allow_category_tree_click_scroll_up = false;
225        if (typeof wpfdparams !== 'undefined' && wpfdparams.hasOwnProperty('allow_category_tree_click_scroll_up')) {
226            allow_category_tree_click_scroll_up = parseInt(wpfdparams.allow_category_tree_click_scroll_up) === 1 ? true : false;
227        }
228        $this.find('li a, li .icon-open-close').unbind('click');
229        // Bind userdefined function on click an element
230        $this.find('li.directory a').bind('click', function (e) {
231            $this.find('li').removeClass('selected');
232            $this.find('i.zmdi').removeClass('zmdi-folder-open').addClass("zmdi-folder");
233            $(this).parent().addClass('selected');
234            $(this).parents('li.directory.expanded').find(' > i.zmdi').removeClass('zmdi-folder').removeClass('zmdi-folder-outline').addClass('zmdi-folder-outline');
235            $(this).parent().find(' > i.zmdi').removeClass('zmdi-folder').addClass("zmdi-folder-open").addClass("zmdi-folder-outline");
236
237            if ($this.find('i.zmdi.zmdi-folder.zmdi-folder-outline').parent().length) {
238                $this.find('i.zmdi.zmdi-folder.zmdi-folder-outline').parent().each(function () {
239                    if ($(this).find(' > .jaofiletree li.directory').length) {
240                        $(this).find('i.zmdi.zmdi-folder.zmdi-folder-outline').removeClass('zmdi-folder');
241                    } else {
242                        $(this).find('i.zmdi.zmdi-folder-outline').removeClass('zmdi-folder-outline').addClass('zmdi-folder');
243                    }
244                });
245            }
246
247            var $el = $(this);
248            if ($el.data('clicked')) {
249                // Previously clicked, stop actions
250                e.preventDefault();
251                e.stopPropagation();
252            } else {
253                // Mark to ignore next click
254                $el.data('clicked', true);
255                options.onclick(this, $(this).attr('data-file'));
256                // Unmark after 1 second
257                window.setTimeout(function () {
258                    $el.removeData('clicked');
259                }, 1000)
260            }
261
262            if (allow_category_tree_click_scroll_up) {
263                var offsetTop = $(this).closest(".wpfd-content").offset().top - 200;
264                $('html, body').animate({
265                    scrollTop: offsetTop
266                }, 1000);
267            }
268
269            return false;
270        });
271
272        $this.find('li.directory.collapsed .icon-open-close').bind('click', function (e) {
273            e.preventDefault;
274
275            var $el = $(this);
276            if ($el.data('clicked')) {
277                // Previously clicked, stop actions
278                e.preventDefault();
279                e.stopPropagation();
280            } else {
281                // Mark to ignore next click
282                $el.data('clicked', true);
283                methods.open($(this).attr('data-file'), $this);
284                // Unmark after 1 second
285                window.setTimeout(function () {
286                    $el.removeData('clicked');
287                }, 1000)
288            }
289        });
290
291        $this.find('li.directory.expanded .icon-open-close').bind('click', function (e) {
292            e.preventDefault;
293            var $el = $(this);
294            if ($el.data('clicked')) {
295                // Previously clicked, stop actions
296                e.preventDefault();
297                e.stopPropagation();
298            } else {
299                // Mark to ignore next click
300                $el.data('clicked', true);
301                methods.close($(this).attr('data-file'), $this);
302                // Unmark after 1 second
303                window.setTimeout(function () {
304                    $el.removeData('clicked');
305                }, 1000)
306            }
307        });
308    };
309
310    $.fn.jaofiletree = function (method) {
311        // Method calling logic
312        if (methods[method]) {
313            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
314        } else if (typeof method === 'object' || !method) {
315            return methods.init.apply(this, arguments);
316        } else {
317            //error
318        }
319    };
320})(jQuery);

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.