git ssb

0+

cel / text-node-searcher



Commit 773e0457b8ce91b62f7467c859c413529fe4c0a7

Spell out Previous

Charles Lehner committed on 12/18/2015, 7:27:27 PM
Parent: eaffcf142a7836aa59f9b83355a378d57912fb10

Files changed

example.htmlchanged
index.jschanged
example.htmlView
@@ -44,9 +44,9 @@
4444 };
4545 input.onkeypress = function (e) {
4646 if (e.keyCode == 13) { // Enter
4747 if (e.shiftKey)
48- searcher.selectPrev();
48 + searcher.selectPrevious();
4949 else
5050 searcher.selectNext();
5151 }
5252 };
@@ -54,9 +54,9 @@
5454 document.getElementById("next-btn").onclick = function () {
5555 searcher.selectNext();
5656 };
5757 document.getElementById("prev-btn").onclick = function () {
58- searcher.selectPrev();
58 + searcher.selectPrevious();
5959 };
6060 </script>
6161 </body>
6262 </html>
index.jsView
@@ -59,9 +59,9 @@
5959 } while (node.nodeType != Node.TEXT_NODE);
6060 return node;
6161 }
6262
63-function getPrevTextNode(node, container, wrap) {
63 +function getPreviousTextNode(node, container, wrap) {
6464 do {
6565 if (node == container) {
6666 if (!wrap)
6767 return null;
@@ -113,23 +113,23 @@
113113 }
114114 }
115115 };
116116
117-TextNodeSearcher.prototype.selectPrev = function () {
117 +TextNodeSearcher.prototype.selectPrevious = function () {
118118 if (!this.queryStr)
119119 return;
120120
121121 var sel = window.getSelection();
122122 var endNode = sel.anchorNode;
123123 var endOffset = 0;
124124 if (!endNode || endNode.nodeType != Node.TEXT_NODE ||
125125 !this.container.contains(endNode))
126- endNode = getPrevTextNode(endNode, this.container, true);
126 + endNode = getPreviousTextNode(endNode, this.container, true);
127127 else
128128 endOffset = sel.anchorOffset;
129129
130130 for (var node = endNode; node;
131- node = getPrevTextNode(node, this.container, true)) {
131 + node = getPreviousTextNode(node, this.container, true)) {
132132 var str = node.data;
133133 if (endOffset < Infinity) {
134134 str = node.data.substr(0, endOffset);
135135 endOffset = Infinity;

Built with git-ssb-web