Giter VIP home page Giter VIP logo

Comments (11)

jcubic avatar jcubic commented on May 30, 2024

Do you mean that you have thousands of files in a single directory and the browser is slowing down? The way it works now is that the library doesn't care what is the content of the files and it loads only a single directory at once.

I'm not sure what the problem you have is, can you maybe create a reproduction of the issue or share your working code? If you can't expose your code you can send it to my email I can check out what the problem is.

from jquery.filebrowser.

jcubic avatar jcubic commented on May 30, 2024

Are you maybe referring to the CodePen demo that loads the whole directory tree and content of the files at once?

https://codepen.io/jcubic/pen/aBKYRR

This is just a demo to show how the API works (the simplest I could come up with), this is not how you should create your application with this library if you have big files and a large tree. See the API for clarification.

Also note, that I provide paid support for all my Open Source projects, so if you need help writing an app (if you can't do that yourself) I can help.

from jquery.filebrowser.

nbao avatar nbao commented on May 30, 2024

Yes exactly i use the code https://codepen.io/jcubic/pen/aBKYRR to load all files.
You can check here
https://git.drupalcode.org/project/link_filebrowser/-/blob/1.0.0/js/filebrowser-block.js
Backend with drupal
https://git.drupalcode.org/project/link_filebrowser/-/blob/1.0.0/src/Controller/LinkFileBrowserController.php
method public function scan($dir) it will get all files. It works for test with under 500 files
I think there is a way to make it load files better on 2 levels if it checks the directory it will call ajax to load. it will callback automatically to get sub folder

} else if ($.isPlainObject(dir[key])) {
                    result.dirs.push(key);
                  }

thanks a lot for this library very helpful. I will find another clever way

from jquery.filebrowser.

jcubic avatar jcubic commented on May 30, 2024

But you can do this with the current API, just look at the readme:

$(function() {
    var browse = $('#browser').browse({
        root: '/',
        separator: '/',
        contextmenu: true,
        dir: function(path) {
            return $.get(`/dir?path=${path}`);
        },
        open: function(filename) {
            console.log('opening ' + filename);
        }
    });
});

from jquery.filebrowser.

nbao avatar nbao commented on May 30, 2024

thanks, i think it works with ajax load current path, it takes time to request from server every click.

from jquery.filebrowser.

nbao avatar nbao commented on May 30, 2024

there is error if folder is empty
jquery.filebrowser.js?v=9.5.9:571 Uncaught TypeError: $menu.menu is not a function
at HTMLDivElement. (jquery.filebrowser.js?v=9.5.9:571:31)
Line : 571
https://github.com/jcubic/jquery.filebrowser/blob/master/js/jquery.filebrowser-0.8.4.js

 var $menu = make_menu(context_menu_object.menu).appendTo('body');
 if($menu){
                    $menu.menu();
                    var offset = $content.offset();
                    $menu.css({
                        left: e.pageX,
                        top: e.pageY
                    });
}
                    return false;

from jquery.filebrowser.

jcubic avatar jcubic commented on May 30, 2024

Again can you share your working code? This is not helpful.

Here is the FS demo that allows creation of empty directories

https://jcubic.github.io/wayne/fs/

so the bug is probably in your code. I will not be able to debug your code if you don't show it.

from jquery.filebrowser.

jcubic avatar jcubic commented on May 30, 2024

I think that what you're trying to do is to use contexmenu without including jQuery UI. I have nothing to do with empty directory.

from jquery.filebrowser.

jcubic avatar jcubic commented on May 30, 2024

If you still have a problem create another issue.

from jquery.filebrowser.

nbao avatar nbao commented on May 30, 2024

My work is on drupal https://www.drupal.org/project/link_filebrowser/
I create static html and Js it works but when I use ajax it doesn't work with empty directory. I guess Php returns array[] but js needs {} object. I change the algorithm for loading subdirectory files at 2 levels of recusive. because if i use ajax directly when clicking on folder icon its not smooth (or it have to chane icone folder to spinner on ajax load, i don't know how to do that)

from jquery.filebrowser.

jcubic avatar jcubic commented on May 30, 2024

You should be able to add spinner on your own in CSS, by adding a class to the div element.

dir: async function(dirname) {
   $('.browser-widget').addClass('loading');
   const content = await $.get(`/backend?path=${dirname}`);
   $('.browser-widget').removeClass('loading');
   return content;
}

and you can add spinner in CSS pseudo element:

.browser-widget.loading .content::before {
   
}

I can add loading class and spinner to the library, but you can do that in your own code.

from jquery.filebrowser.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.