GithubHelp home page GithubHelp logo

na-2n / compleet Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 24 KB

Zero dependency HTML input autocompletion library

License: GNU Lesser General Public License v3.0

CSS 9.39% JavaScript 62.96% HTML 27.65%
autocomplete-search vanilla-javascript zero-dependency html-input

compleet's Introduction

Compleet

Zero dependency JavaScript autocompletion library.

Why

Because there weren't any other libraries that did what I needed.

Usage

const input = document.querySelector("input#myinput");

input.compleet({
// OR
compleet(input, {
    // General options
    maxResults: 10, // max results, default is 5
    raw: false, // whether to use innerHTML or innerText to set autocomplete options, default is false (innerText)
    //   ^^^^^ DO NOT SET THIS TO TRUE IF YOU PROVIDE UNFILTERED USER TAGS, YOU HAVE BEEN WARNED

    // Tag source options
    source: function(term, resp) {
        const val = term.split(" ").pop(); // split the value by spaces
        const terms = getTermsFromSomewhere(); // get the terms from somewhere
        const matched = terms.filter(function(t) { return t.startsWith(val); }); // filter the terms

        resp(matched, val); // send the response
    },
    // OR
    tags: function(resp) {
        getTermsFromSomewhere(function(terms) { resp(terms); });
    }
});

Contributing

PRs are always welcome!

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.