• Stars
    star
    30
  • Rank 839,658 (Top 17 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

File browser jQuery plugin

jQuery File Browser version 0.8.4

jQuery File Browser is a plugin for creating OS like file browsers.

Demo

installation

to install you can grab the files from the repo or install from

bower

bower install jquery.filebrowser --save

npm

npm install jquery.filebrowser --save

include the files:

<script src="js/jquery.filebrowser.min.js"></script>
<link href="css/jquery.filebrowser.min.css" rel="stylesheet"/>

and you can use this code to initialize the plugin:

$(function() {
    var browse = $('#browser').browse({
        root: '/',
        separator: '/',
        contextmenu: true,
        dir: function(path) {
            return new Promise(function(resolve, reject) {
                 if (path == '/') {
                     resolve({dirs: ['foo', 'bar'], files: []});
                 } else if (path == '/foo/') {
                     resolve({dirs: [], files: ['baz', 'quux']});
                 } else if (path == '/bar/') {
                     resolve({dirs: [], files: ['lorem', 'ipsum']});
                 } else {
                     reject(); // for cases when you type wrong path in address bar
                 }
             });
        },
        open: function(filename) {
            console.log('opening ' + filename);
        }
    });
});

All user functions that modify the Directory like create, remove, copy, rename can return a promise, and the plugin will refresh the view (call dir function) when it's resolved.

more examples and usage in examples directory.

Requirement

If you want context menu (enabled using contextmenu option) you'll need jQuery UI and of course you need jQuery itself.

Options

  • name - used to distinguish different filesystem for copying nad moving files (rename)
  • dir - function that should return a promise that resolve to object {files: <ARRAY>, dirs: <ARRAY>} or return that object
  • exists - function that will return true/false or a promise that resolve to true/false that indicate if file or directory exists (used when create new file/directory)
  • separator - path separator (a string) usualy / or \ (to use \ you need to put '\\') default /
  • root - root of the filesystem, it can be any path like /home/<user>, default /
  • change - callback function that's called on refresh of the directory
  • init - callack executed on initalization of the plugin
  • item_class - function that should return addiional classes for the element (directory or file) you can use this to have different icons for C or D drive that's in root directory, see windows example
  • dbclick_delay - if the time of the second click is lower then this but hight then rename_delay it's consider as action for rename a file or directory
  • open - callback function executed with path of the file when you double click on the file
  • rename - callback function called with old path nad new path when you rename a file or directory
  • remove - callback function called with path when you delete file or directory
  • create - callback called with path of the new file or directory and string 'directory' or 'file' as second argument
  • copy - callback executed when you copy a file using CTRL+C and CTRL+V
  • upload - callback called with file object and the path when you drag and drop a file or directory to browser container, you can also drag into visible directory
  • error - called when error accured like when you try to enter invalid path in address bar
  • refresh_timer - timeout after fetch of the content of the file in miliseconds, used to see visible refresh when you change direcotry (you can set it to 0), default 100
  • menu - should return object which keys are names of the context menu and values are other object (they will create submenus) or a function that will be executed when menu item is click it acceppt single argument string 'li' or 'content' depend if you click on file/directory or on empty browser space. example:
    menu: function(type) {
        if (type == 'li') {
            return {
                'alert': function($li) {
                    alert('alert for item ' + $li.text());
                }
            }
        }  else {
            return {
                'Create File': function() {
                    var name = prompt('name: ');
                    var path;
                    if (name) {
                        path = this.join(this.path(), name);
                    }
                    this.create('file', path);
                }
            };
        }
    },

API methods

  • path - return current path
  • name - return settings name
  • back - go back one directory
  • destroy - remove all events and DOM nodes
  • create - function(type, [path]) - create new directory of file (depend of first argument which is string 'file' or 'directory') if there is second argument it will create new file/directory of it's undefined it will create placeholder for file/directory with textarea to enter name
  • copy - selected files/directories for later paste
  • cut - like copy but when call paste it will remove old items
  • paste - if cut was executed it will call settings.rename and if copy was called it will call settings.copy and then refresh all views with the same directory
  • up - go up one directory
  • show - call settings.dir and rerender the directory view
  • join - return new path based on settings.separator and settings.root, accept any number of arguments
  • split - split the path using settings.separator and settings.root
  • walk - function(filename, fn) - call function for each file/directory the signature for callaback function: function(path_part, last, return_value) the function return value from last call to callback function, 3rd argument is a value from previous call to callback function.

License

Licensed under MIT license

Copyright (c) 2016-2021 Jakub T. Jankiewicz

More Repositories

1

jquery.terminal

jQuery Terminal Emulator - JavaScript library for creating web-based terminals with custom commands
JavaScript
2,940
star
2

sysend.js

Web application synchronization between different tabs
JavaScript
1,025
star
3

wayne

Service Worker Routing library for in browser HTTP requests
JavaScript
547
star
4

lips

Scheme based powerful lisp interpreter written in JavaScript
JavaScript
323
star
5

chat-gpt

ChatGPT conversation saving bookmark
JavaScript
291
star
6

tagger

Zero Dependency, Vanilla JavaScript Tag Editor
JavaScript
261
star
7

jquery.splitter

jQuery Splitter is plugin that split your content with movable splitter between them
JavaScript
240
star
8

gaiman

Gaiman: Text based game engine and programming language
JavaScript
137
star
9

leash

Browser Shell
JavaScript
120
star
10

jquery.rotate

Simple plugin that add rotate css property and animation
JavaScript
94
star
11

git

GIT Web Terminal
JavaScript
82
star
12

Clarity

Customizable Monoshape Vector Icon Theme for GTK+
SVG
39
star
13

jquery.terminal-www

jQuery Terminal Website
HTML
26
star
14

favloader

Vanilla JavaScript library for loading animation in favicon
JavaScript
23
star
15

cmatrix

Render Matrix effect animation on Canvas in JavaScript
JavaScript
22
star
16

lily

Simple JavaScript options parser inspired by yargs
JavaScript
21
star
17

jsh.php

Terminal like php shell (PHP web terminal emulator)
PHP
20
star
18

jsvi

fork of JSVI - VI in JavaScript
JavaScript
18
star
19

Monadic

JavaScript micro library - POC
JavaScript
16
star
20

fake-linux-terminal

Fake GNU/Linux, Unix, MacOS terminal based system
HTML
15
star
21

json-rpc

JSON-RPC implementaion in php and JavaScript
PHP
13
star
22

electron-terminal

Base for jQuery Terminal based Electron apps
JavaScript
12
star
23

route.js

Simple routing library that can be use on the server or in the browser
JavaScript
11
star
24

jquery.micro

Pico/Nano like editor for jquery.
JavaScript
11
star
25

coverage.el

Emacs minor mode for displaying code coverage
Emacs Lisp
10
star
26

chat

Simple Chat with Server Side Events, PHP and SQLite
PHP
8
star
27

prism-cli

Syntax highlighting for command line
JavaScript
7
star
28

try-python

Try Python website
Python
7
star
29

commodore64

Commodore 64 jQuery Terminal Demo
HTML
7
star
30

ascii-canvas

String based text rendering for Node and Browser
JavaScript
6
star
31

jquery.resize

Custom resize jQuery event for element
JavaScript
6
star
32

notes

Simple text based notes taking app
JavaScript
6
star
33

webrtc-share

Application for sharing files using WebRTC
PHP
6
star
34

jcubic.pl

Głównie JavaScript - blog głównie o Front-Endzie
PHP
5
star
35

awesome-ascii

List of Awesome ASCII libraries
5
star
36

ansidec

Unix formatting transformer in JavaScript
JavaScript
5
star
37

firepad

Simple firepad based source code editor
HTML
5
star
38

quizerach

Simple Quiz Maker Open Source App (WIP)
TypeScript
4
star
39

calendar

ASCII calendar that can be used in Node.js or Browser
JavaScript
4
star
40

angular.piechart

Angular 1.5 component for svg based piecharts
JavaScript
4
star
41

velvet

Vanilla JavaScript Universal CSS in JS library
TypeScript
4
star
42

jcubic

3
star
43

chess

Terminal based chess game
HTML
3
star
44

snapp

Simple Text based notes taking app
PHP
3
star
45

open-source-library

Template for JavaScript Open Source library
Makefile
3
star
46

ToME

ToME - Tales of Middle Earth
C
3
star
47

leash-cordova

Cordova leash shell
JavaScript
3
star
48

filter-paste-js

intercept content pasting into iframe with design mode
JavaScript
3
star
49

fs-browser

In Browser File System App
JavaScript
3
star
50

jquery-position-event

jQuery cursor position change event
JavaScript
2
star
51

isomorphic-lolcat

Lolcat gradient that can be used in browser or Node
JavaScript
2
star
52

react-wayne-auth

JavaScript
2
star
53

koduj-curriculum

Curriculum for teaching programming using JavaScript and p5.js library
2
star
54

dotfiles

Linux dotfiles
Shell
2
star
55

cataloger

Shopping cart like catalog library
JavaScript
2
star
56

json-rpc-list

List of JSON-RPC implementations
2
star
57

compickr

Flickr composition checker
JavaScript
2
star
58

jankiewicz

Personal Blog of Jakub T. Jankiewicz
Liquid
2
star
59

aimed

Simple JavaScript Markdown Editor
JavaScript
2
star
60

yapp

Yet Another PHP Proxy
JavaScript
2
star
61

kopalinski.sqlite

Słownik Wyrazów Obcych Kopalińskiego jako baza sqlite
Python
2
star
62

koduj

P5.js playground
PHP
2
star
63

static

static files used with cdn.jsdelivr.net
JavaScript
2
star
64

opensourcelogo

Logo for you Open Source project
2
star
65

price.py

Scraping prices from Ceneo.pl and save in SQLite database
Python
1
star
66

php-terminal-jwt

Demo of JWT with jQuery Terminal
PHP
1
star
67

refClass

R
1
star
68

jquery.draglessClick

Better jQuery click event that's not invoked when you drag or select text
JavaScript
1
star
69

swift.manager

Server file browser and terminal with apps support
JavaScript
1
star
70

bassel.jcubic.pl

Bassel badge page
PHP
1
star
71

roman

ReactJS application with unit tests
TypeScript
1
star
72

REPL

REPL Bookmarklets for different languages
1
star
73

Similar-Stuff

Get Similar stuff from tastekid.com
Python
1
star
74

expression.php

Safely evaluate math, string, and boolean expressions
PHP
1
star
75

cv

My resume
Makefile
1
star
76

quatro

Simple Q&A Open Source application in PHP
PHP
1
star
77

interactive-scheme-tutorial

Interactive Scheme Tutorial
HTML
1
star
78

Downloader

Command Line tool for download file from file hosting sites.
Ruby
1
star
79

gps.py

Simple script to add GPS EXIF data to images
Python
1
star
80

flash-3d

School project 3D Flash animation in C++
C
1
star
81

FizzBuzz

JavaScript version of function only FizzBuzz
JavaScript
1
star
82

uncp

UNsplash Cache Proxy
PHP
1
star
83

jsvi-app

jsvi app for leash shell
JavaScript
1
star
84

bash

Bash Interpreter written in JavaScript
1
star