This is intended to be used by webmasters/bloggers wishing to add pop-up annotation to their web pages. If you are interested in adding this functionality to your browser instead, you should look at the annotation bookmarklet.
Add the following before </body>, where you'd usually put Google analytics and such
<script src="http://static.mandarinspot.com/static/mandarinspot.min.js" charset="UTF-8"></script> <script>mandarinspot.annotate();</script>
Send a quick note indicating URL of your website.
That's it. It should work with all the assumed defaults.
The script can be loaded anywhere, but to avoid delaying loading of the main content, it either needs to be done asynchronously or at the bottom of the body as suggested above.
The main call is mandarinspot.annotate(selector, options). Both arguments are optional.
options is an object with two optional members:
phonetic, can either be "pinyin" or "zhuyin", pinyin is the default;show, boolean value to indicate whether pop-ups need to be shown initially, default is true.These two calls can be used to switch pop-ups on and off respectively
mandarinspot.showPopups(true); mandarinspot.showPopups(false);
If you want pop-ups initially be inactive, you can call it like this:
<script>mandarinspot.annotate('#chinesetext', {phonetic: 'pinyin', show: false});</script>
If something is unclear or if you think there is something else needs to be implemented, changed or fixed, please ask.
This doesn't work in IE7 and earlier and all version of Opera due to cross domain requests not being implemented properly in these browsers. So if you choose to have pop-ups on/off switchable, you probably have to hide the switch UI element in case it can't work.
To detect whether API is supported in the currnt browser you can call mandarinspot.supported(), which will return true or false based on best guess after detecting some browser features.
All Chinese text found on the page is sent to the MandarinSpot server for segmentation and retrieval of the dictionary definitions. This information is not stored in any form on the server, but the transmission itself is done without encryption at the moment, which makes it possible for the data to be observed by a third party while in transit.