Mercurial > hg > LGServices
annotate src/main/webapp/resources/js/LGSearch.js @ 77:997601ee0c6e
fix form submit issue above Chrome 56.x edition
author | Calvin Yeh <cyeh@mpiwg-berlin.mpg.de> |
---|---|
date | Wed, 03 May 2017 19:51:43 +0200 |
parents | 824b808a7481 |
children |
rev | line source |
---|---|
39 | 1 $(document).ready(function(){ |
62
824b808a7481
improvements and bug fixed
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
2 |
824b808a7481
improvements and bug fixed
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
3 $(".hiddenField").remove(); |
39 | 4 highlightKeywords(); |
62
824b808a7481
improvements and bug fixed
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
5 |
39 | 6 }) |
7 | |
8 function highlightKeywords() // highlight keywords in content column, with class="content" | |
9 { | |
10 if ($("#searchTerm")[0] == undefined ){ | |
11 return; | |
12 } | |
13 | |
14 var keywords = $("#searchTerm")[0].innerHTML; | |
15 var keywordsArray = keywords.split(", "); | |
16 | |
17 var content = $(".content"); | |
18 for (var i = 0; i < content.length; i++) { | |
19 // find keywords in content[i] | |
20 var text = content[i].innerHTML; | |
21 for (var j = 0; j < keywordsArray.length; j++) { | |
22 var index = text.indexOf(keywordsArray[j]); | |
23 if (index >= 0) { | |
24 text = text.substring(0,index) + "<span class='highlight'>" + text.substring(index, index+keywordsArray[j].length) + "</span>" + text.substring(index+keywordsArray[j].length); | |
25 content[i].innerHTML = text; | |
26 } | |
27 }; | |
28 | |
29 }; | |
62
824b808a7481
improvements and bug fixed
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
39
diff
changeset
|
30 } |