gpt4 book ai didi

javascript - 我需要关于 Annotator.js 的例子

转载 作者:行者123 更新时间:2023-11-30 07:59:26 25 4
gpt4 key购买 nike

如何使用 Annotator 脚本?简单的例子创建、更新、删除、检索。

$('#content').annotator('addPlugin', 'Store', {
urls: {
// These are the default URLs.
create: '/annotations',
update: '/annotations/:id',
destroy: '/annotations/:id',
search: '/search'
}
}):

最佳答案

此示例展示了如何使用 Annotator.js 以及如何将两个插件“离线”和“触摸”关联到它以永久离线存储注释并使其在触摸设备上工作:

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Annotator Touch Plugin</title>
<link rel="stylesheet" href="annotator.min.css" />
<link rel="stylesheet" href="annotator.touch.css" />
<style>body { font-size: 1.6em }</style>
</head>
<body>
<p>Current Connectivity: <span id="status"></span></p>
<p><button id="clear-storage">Clear LocalStorage</button></p>
<div id="content">
<p>One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment. His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked.</p>

<p>"What's happened to me?" he thought. It wasn't a dream. His room, a proper human room although a little too small, lay peacefully between its four familiar walls. A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer.</p>

<p>Gregor then turned to look out the window at the dull weather. Drops of rain could be heard hitting the pane, which made him feel quite sad. "How about if I sleep a little bit longer and forget all this nonsense", he thought, but that was something he was unable to do because he was used to sleeping on his right, and in his present state couldn't get into that position. However hard he threw himself onto his right, he always rolled back to where he was. He must have tried it a hundred times, shut his eyes so that he wouldn't have to look at the floundering legs, and only stopped when he began to feel a mild, dull pain there that he had never felt before.</p>
</div>
<script src="jquery.js"></script>
<script src="highlighter.js"></script>
<script src="annotator-full.min.js"></script>
<script src="annotator.touch.min.js"></script>
<script src="annotator.offline.min.js"></script>
<script>
jQuery("#content").annotator().annotator('addPlugin', 'Touch', {
force: location.search.indexOf('force') > -1,
useHighlighter: location.search.indexOf('highlighter') > -1
});

jQuery("#content").annotator().annotator('addPlugin', 'Offline', {
online: function () {
jQuery("#status").text("Online");
},
offline: function () {
jQuery("#status").text("Offline");
} });

jQuery("#clear-storage").click(function () {
if (annotator) {
annotator.plugins.Offline.store.clear()
}
});

if (!Annotator.Plugin.Touch.isTouchDevice()) {
if (location.search.indexOf('force') > -1) {
jQuery("body").prepend('<p><a href="./index.html">Disable Plugin in Desktop Browser</a></p>');
} else {
jQuery("body").prepend('<p><a href="./index.html?force">Enable Plugin in Desktop Browser</a></p>');
}
}

var annotator = jQuery("#content").data('annotator');
</script>
</body>
</html>

请注意,所有这些文件必须存在于同一个文件夹中:

CSS:

  • 注释器.min.css
  • annotator.touch.css

JS:

  • jquery.js
  • highlighter.js
  • annotator-full.min.js
  • annotator.touch.min.js
  • annotator.offline.min.js

(highlighter.js 在 annotator.touch 插件的 VENDOR 文件夹中)

关于javascript - 我需要关于 Annotator.js 的例子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31944609/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com