Debian Codegraph @

closure-library/closure/goog/demos/plaintextspellchecker.html

raw
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <!--
5 Copyright 2010 The Closure Library Authors. All Rights Reserved.
6
7 Use of this source code is governed by the Apache License, Version 2.0.
8 See the COPYING file for details.
9 -->
10 <head>
11 <title>Plain Text Spell Checker</title>
12 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
13 <script type="text/javascript" src="../base.js"></script>
14 <script type="text/javascript">
15 goog.require('goog.ui.PlainTextSpellChecker');
16 </script>
17 <style type="text/css">
18
19 .goog-spellcheck-invalidword {
20 background: yellow;
21 }
22
23 .goog-spellcheck-correctedword {
24 background: green;
25 }
26
27 textarea, .goog-spellcheck-correctionpane {
28 font: menu;
29 font-size: 0.8em;
30 border: 1px solid black;
31 padding: 2px;
32 margin: 0px;
33 overflow: auto;
34 line-height: 1.25em;
35 }
36
37 .goog-menu {
38 position: absolute;
39 color: #000;
40 border: 1px solid #B5B6B5;
41 background-color: #F3F3F7;
42 cursor: default;
43 font: normal small arial, helvetica, sans-serif;
44 width: 25ex;
45 outline: 0;
46 }
47
48 .goog-menuitem {
49 padding: 2px 5px;
50 position: relative;
51 }
52
53 .goog-menuitem-highlight {
54 background-color: #4279A5;
55 color: #FFF;
56 }
57
58 .goog-menuitem-disabled {
59 background-color: #F3F3F7;
60 color: #999;
61 }
62
63 .goog-menu hr {
64 background-color: #999;
65 height: 1px;
66 border: 0px;
67 margin: 0px;
68 }
69 </style>
70 </head>
71 <body>
72 <h1>Plain Text Spell Checker</h1>
73 <p>
74 The words "test", "words", "a", and "few" are set to be valid words,
75 all others are considered spelling mistakes.
76 </p>
77 <p>
78 The following keyboard shortcuts can be used to navigate inside the editor:
79 <ul>
80 <li>Previous misspelled word: ctrl + left-arrow</li>
81 <li>next misspelled word: ctrl + right-arrow</li>
82 <li>Open suggestions menu: down arrow</li>
83 </ul>
84 </p>
85 <p>
86
87 <textarea id="t0" style="width: 50ex; height: 15em;"></textarea>
88
89
90 </p>
91
92 <button onclick="s.check();">check</button>
93 <button onclick="s.resume();">resume</button>
94
95 <script type="text/javascript">
96
97 function localSpellCheckingFunction(words, spellChecker, callback) {
98 var len = words.length;
99 var results = [];
100 for (var i = 0; i < len; i++) {
101 var word = words[i];
102 if (word == 'test' || word == 'words' || word == 'a' || word == 'few') {
103 results.push([word, goog.spell.SpellCheck.WordStatus.VALID]);
104 } else {
105 results.push([word, goog.spell.SpellCheck.WordStatus.INVALID,
106 ['foo', 'bar', 'test']]);
107 }
108 }
109 callback.call(spellChecker, results);
110 }
111
112 var handler = new goog.spell.SpellCheck(localSpellCheckingFunction);
113 var s = new goog.ui.PlainTextSpellChecker(handler);
114 s.markCorrected = true;
115 s.decorate(document.getElementById('t0'));
116 </script>
117 </body>
118 </html>