Giter Site home page Giter Site logo

jerry's Introduction

jerry

Pages on the web are modeled as data in the form of a tree. Nodes have child nodes, such that your average webpage consists of containers of containers of containers of--ultimately--text or media content. In certain contexts, notably from the perspective of a user, webpages are better represented with the flat structure of a more traditional document. Jerry is a framework for translating between webpages-as-tree-structures and -as-linear-text. With jerry, every Node on a webpage is given an Address---which can then be manipulated in various ways.

jerry

install

$ npm install jerrymander

usage

const jerry = new Jerry()
jerry.getSelection().highlight()
localStorage.highlights = JSON.stringify(jerry.serialize())

docs

  • new Jerry(root = document.body)

create a Jerry instance around a given root node.

  • Jerry#getSelection(): Address

get the address of the current user selection.

  • Address#highlight(className = 'highlight)

highlight the content at a given address (takes an optional className to apply).

  • Address#select()

set selected text range to the contents of this address

  • Jerry#serialize(): string[]

serializes all highlights for storage or transmission.

  • Jerry#deserialize(highlights: string[]): Address[]

deserialize a serialization result back into Addresses.

  • Address#getHash(): number

get the hash of the content at an address.

jerry's People

Contributors

mattneary avatar

Stargazers

Shashank Agrawal avatar Justin Bennett avatar

Watchers

 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.