-
Notifications
You must be signed in to change notification settings - Fork 14
/
finder.js
58 lines (58 loc) · 1.68 KB
/
finder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
eslint-disable es5/no-es6-methods,
es5/no-es6-static-methods,
es5/no-arrow-functions,
es5/no-binary-and-octal-literals,
es5/no-block-scoping,
es5/no-classes,
es5/no-computed-properties,
es5/no-default-parameters,
es5/no-destructuring,
es5/no-exponentiation-operator,
es5/no-for-of,
es5/no-generators,
es5/no-modules,
es5/no-object-super,
es5/no-rest-parameters,
es5/no-shorthand-properties,
es5/no-spread,
es5/no-template-literals,
es5/no-typeof-symbol,
es5/no-unicode-code-point-escape,
es5/no-unicode-regex
*/
const meshkiUtil = {
TRange: null,
search (event, str) {
if (event.keyCode === 13 || event.type === 'click') {
if (!str && str === "" && str.trim().length <= 0) {
alert(`Nothing to search for. Please enter a text.`)
return
}
if (parseInt(navigator.appVersion) < 4) { return }
let strFound
if (window.find) {
strFound = self.find(str)
if (!strFound) {
strFound = self.find(str, 0, 1)
while (self.find(str, 0, 1)) { continue }
}
} else if (navigator.appName.indexOf('Microsoft') !== -1) {
if (meshki.TRange != null) {
meshki.TRange.collapse(false)
strFound = meshki.TRange.findText(str)
if (strFound) { meshki.TRange.select() }
}
if (meshki.TRange == null || strFound === 0) {
meshki.TRange = self.document.body.createTextRange()
strFound = meshki.TRange.findText(str)
if (strFound) { meshki.TRange.select() }
}
} else if (navigator.appName === 'Opera') {
alert('Opera browsers not supported, sorry...')
return
}
if (!strFound) { alert(`String '${str}' not found!`) }
}
}
}