Coder Social home page Coder Social logo

webfind's Introduction

WebFind

Find files in browser with help of serverside.

Install

npm i webfind -g

Use as standalone

Start webfind, go to url http://localhost:1337

API

Client API

webfind(element [, prefix], callback)

  • element - html element, or selector
  • prefix - (optional) prefix to url (same as in server)
  • callback - function to call after init

When prefix set in server and client, you should use same prefix in html. For example, if you use prefix /webfind you should connect webfind script in this way:

<script src="/webfind/webfind.js"></script>

Server API

webfind(options);

Could be used as middleware, or for init WebFind.

webfind({
    server: server,/* only one should be passed: */
    socket: socket,/* server or socket  */
    online: true, /* default */
    minify: true, /* default */
    prefix:'/webfind' /* default */
})

webfind.middle(options);

Middleware function if there is a need of init socket in another place.

webfind.middle({
    prefix: '/webfind', /* default */
    online: true, /* default */
    minify: true, /* default */
})

Use as middleware

To use WebFind in your programs you should make local install:

npm i webfind express --save

And use it in your program

/* server.js */

var webfind     = require('webfind'),
    http        = require('http'),
    express     = require('express'),
    
    app         = express(),
    server      = http.createServer(app),
    
    port        = 1337,
    ip          = '0.0.0.0';
    
app .use(webfind({
        server: server,
        online: true /* load jquery and socket.io from cdn */
    }))
    .use(express.static(__dirname));

server.listen(port, ip);
<!-- index.html -->

<div class="webfind"></div>
<script src="/webfind/webfind.js"></script>
<script>
    (function() {
        'use strict';
        
        window.addEventListener('load', load);
        
        function load() {
            window.removeEventListener('load', load);
            
            webfind('.webfind', function() {
                console.log('webfind ready')
            });
        }
    })()
</script>

License

MIT

webfind's People

Contributors

coderaiser avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

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.