You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@annotator.apache.org by ra...@apache.org on 2019/07/01 00:17:38 UTC
[incubator-annotator] 04/04: Remove demo error display
This is an automated email from the ASF dual-hosted git repository.
randall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
commit a96b01cd5e058454f444611ef19907a9ad749430
Author: Randall Leeds <ra...@apache.org>
AuthorDate: Sun Jun 30 17:17:08 2019 -0700
Remove demo error display
---
demo/index.html | 7 ++-----
demo/index.js | 33 ++++++++++++---------------------
2 files changed, 14 insertions(+), 26 deletions(-)
diff --git a/demo/index.html b/demo/index.html
index a41a949..1b62b4c 100644
--- a/demo/index.html
+++ b/demo/index.html
@@ -28,14 +28,11 @@ specific language governing permissions and limitations under the License.
background-color: rgba(255, 255, 120, 0.5);
outline: 0.1px solid rgba(255, 100, 0, 0.8);
}
- #debug {
+ #selector {
color: #666;
background: #f8f8f8;
padding: 2em;
}
- #debug.error {
- color: red;
- }
#selectable, #corpus {
display: inline-block;
max-width: 15em;
@@ -73,7 +70,7 @@ specific language governing permissions and limitations under the License.
<a href="https://www.w3.org/TR/2017/NOTE-selectors-states-20170223/#frags"
target="_blank">as the fragment identifier</a>.</p>
<p>Here is the selector in JSON format:</p>
- <pre id="debug"></pre>
+ <pre id="parsed"></pre>
<p>Notice how, when the text of your selection appears multiple times, just
enough characters around it are stored in the selector to find the right
occurrence again.</p>
diff --git a/demo/index.js b/demo/index.js
index 290ba69..78f0d23 100644
--- a/demo/index.js
+++ b/demo/index.js
@@ -13,12 +13,11 @@
* the License.
*/
-/* global corpus, debug, module, selectable */
+/* global corpus, module, parsed, selectable */
import {
parse as parseFragment,
stringify as stringifyFragment,
- SyntaxError as FragmentSyntaxError,
} from '@annotator/fragment-identifier';
import { describeTextQuoteByRange as describeRange } from '@annotator/dom';
@@ -35,26 +34,18 @@ const refresh = async () => {
const identifier = window.location.hash.slice(1);
if (!identifier) return;
- try {
- const { selector } = parseFragment(identifier);
- const ranges = [];
-
- for await (const range of search(corpus, selector)) {
- ranges.push(range);
- }
-
- for (const range of ranges) {
- mark(range);
- }
-
- debug.classList.remove('error');
- debug.innerText = JSON.stringify(selector, null, 2);
- } catch (e) {
- debug.classList.add('error');
- debug.innerText = JSON.stringify(e, null, 2);
- if (e instanceof FragmentSyntaxError) return;
- else throw e;
+ const { selector } = parseFragment(identifier);
+ const ranges = [];
+
+ for await (const range of search(corpus, selector)) {
+ ranges.push(range);
+ }
+
+ for (const range of ranges) {
+ mark(range);
}
+
+ parsed.innerText = JSON.stringify(selector, null, 2);
};
async function describeSelection() {