GithubHelp home page GithubHelp logo

annotator's Introduction

Annotator

Dependencies

Usage

If you include annotator.js and its dependencies on a page you can instantiate an annotator with a Javascript constructor, e.g.:

var myAnnotator = new Annotator({selector: 'body', db: 'https://brilliant-torch-2878.firebaseio.com/'});

You can pass the Annotator constructor options such as the address of your firebase instance and a CSS selector for the annotatable content. In this initial example I'm passing 'body' as the selector so the entire DOM is annotatable. You can imagine how it's useful to pass a more specific selector as you may have a page with navigation, a footer, etc. that is not annotatable as well as annotatable content.

Once the Annotator is instantiated any DOM element within the element selected will be annotatable with a left click (if you click on an anchor you will follow the link rather than revealing the annotation form).

When you left click a form pops up. Clicking submit pushes a new comment to Firebase and clears the form. Right now the annotations are available in memory, e.g.:

myAnnotator.annotations;
-> { Object of annotations... }

Firebase handles pushing new annotations to an Annotator via an asynchronous callback.

Future

In this implementation each commentable URL would need it's own Firebase instance but in the future it would be an improvement to refactor the Annotator so that the page URL is a key in a key/value store where the value is that page's annotations.

The other key improvement that I would make next is adding a clickable DOM element to show all comments associated with that element. Currently all the relevant data (tagName, id, classList & innerHTML) is stored on an annotation so it would be straightforward to iterate through annotations and add a list of relevant annotations to a given DOM element.

annotator's People

Contributors

ritchiea avatar

Watchers

 avatar  avatar

annotator's Issues

Comments do not get store

It took me a few minutes to realize that I had to inject the code myself in the .html example.
var myAnnotator = new Annotator({selector: 'body', db: 'https://brilliant-torch-2878.firebaseio.com/'});

Once I do it, I can create some comments, but the comments don't seem to be stored anywhere.
Each time, the comment widget is empty.

What happens to my comment when I press submit?

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.