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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
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
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
4 highlightKeywords();
62
824b808a7481 improvements and bug fixed
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
5
39
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
6 })
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
7
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
8 function highlightKeywords() // highlight keywords in content column, with class="content"
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
9 {
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
10 if ($("#searchTerm")[0] == undefined ){
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
11 return;
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
12 }
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
13
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
14 var keywords = $("#searchTerm")[0].innerHTML;
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
15 var keywordsArray = keywords.split(", ");
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
16
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
17 var content = $(".content");
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
18 for (var i = 0; i < content.length; i++) {
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
19 // find keywords in content[i]
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
20 var text = content[i].innerHTML;
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
21 for (var j = 0; j < keywordsArray.length; j++) {
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
22 var index = text.indexOf(keywordsArray[j]);
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
23 if (index >= 0) {
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
24 text = text.substring(0,index) + "<span class='highlight'>" + text.substring(index, index+keywordsArray[j].length) + "</span>" + text.substring(index+keywordsArray[j].length);
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
25 content[i].innerHTML = text;
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
26 }
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
27 };
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
28
37840afb7b80 new: full text search
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
29 };
62
824b808a7481 improvements and bug fixed
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 39
diff changeset
30 }