Coder Social home page Coder Social logo

annotator-js's Introduction

Annotator.js

A JavaScript library that puts pinyin on top of Chinese text.

It uses the web service https://mand.chinesezerotohero.com/api/multitextjsonv2 which I created. (Note the request only words over secured https.)

Demo

See the annotation in action.

Usage

First, make sure to include the non-slim version of jQuery 3.3.1 on your HTML page:

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

Then, include all css and js included in this package.

<link rel="stylesheet" href="css/tipped.css">
<link rel="stylesheet" href="css/annotator.css">
<script src="js/tipped.js"></script><!-- For popup tooltips that shows definitions. -->
<script src="js/annotator.js"></script>

Any element with the class "add-pinyin" will be automatically annotated and styled:

<div class="add-pinyin">学而不思则惘</div>

Also works with inline elements:

<p>Chinese people like eating <span class="add-pinyin">饺子</span> and drinking <span class="add-pinyin">热水</span>.</p>

Custom elements

If you want to annotate a different selector, do this:

<div id="#custom" class="add-pinyin">学而不思则惘</div>
var annotator = new Annotator();  
annotator.annotateBySelector('#custom, #custom *")

annotator-js's People

Stargazers

Jyan avatar 林都 avatar Andre Zapico 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.