Commit 4353e0b4 by Kim Eunchul

Merge branch 'contract/ttss/1.0.0_kim-ec' into 'contract/ttss/1.1.0'

#40821 【TECSS Web 1.9.2.6】「or」「(」「半角スペース」で検索した時の結果が統一されていない

See merge request abook_web/web-viewer!49
parents b26493a6 3c6f7aef
...@@ -747,51 +747,106 @@ CONTENTVIEW.searchHandle = function() { ...@@ -747,51 +747,106 @@ CONTENTVIEW.searchHandle = function() {
var myQuery; var myQuery;
var myRegExpArr = []; var myRegExpArr = [];
var count = 0; var count = 0;
var textReg = $('#txtSearch').val().replace(/[.*+?^${}|[\]\\]/g, "\\$&").replace("%", "\\%").replace(' ', '" "').replace("("," ( ").replace(")"," ) ");; var textReg = $('#txtSearch').val().replace(/\(/g," \( ").replace(/\)/g," \) ");
if($('#txtSearch').val() == '"("'){
myRegExpArr[0] = new RegExp("[\(]");
for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
if (myRegExpArr[0].test(contentPage[nIndex].pageText)) {
sPageNo.push(contentPage[nIndex]);
}
}
}else if($('#txtSearch').val() == '")"'){
myRegExpArr[0] = new RegExp("[\)]");
for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
if (myRegExpArr[0].test(contentPage[nIndex].pageText)) {
sPageNo.push(contentPage[nIndex]);
}
}
}else if($('#txtSearch').val() == '"or"'){
myRegExpArr[0] = new RegExp("or");
for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
if (myRegExpArr[0].test(contentPage[nIndex].pageText)) {
sPageNo.push(contentPage[nIndex]);
}
}
}else if($('#txtSearch').val() == '"Or"'){
myRegExpArr[0] = new RegExp("Or");
for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
if (myRegExpArr[0].test(contentPage[nIndex].pageText)) {
sPageNo.push(contentPage[nIndex]);
}
}
}else if($('#txtSearch').val() == '"oR"'){
myRegExpArr[0] = new RegExp("oR");
for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
if (myRegExpArr[0].test(contentPage[nIndex].pageText)) {
sPageNo.push(contentPage[nIndex]);
}
}
}else if($('#txtSearch').val() == '"OR"'){
myRegExpArr[0] = new RegExp("OR");
for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
if (myRegExpArr[0].test(contentPage[nIndex].pageText)) {
sPageNo.push(contentPage[nIndex]);
}
}
}else{
try{ try{
do { do {
var match = myRegexp.exec(textReg); var match = myRegexp.exec(textReg);
if (match != null) if (match != null)
{ {
myArray.push(match[1] ? match[1] : match[0]); myArray.push(match[1] ? match[1].replace(/ \( /g,"\(").replace(/ \) /g,"\)") : match[0].replace(/ \( /g,"\(").replace(/ \) /g,"\)"));
} }
} while (match != null); } while (match != null);
if(myArray[0].charAt(0) == "("){ for(var i = 0; i < myArray.length; i++){
if(myArray[i] != "OR" && myArray[i] != "or" && myArray[i] != "Or" && myArray[i] != "oR" && myArray[i] != "(" && myArray[i] != ")"){
count++;
}
}
if(count > 5){
alert('語句数は最大5つです');
return;
}
if(myArray[0] == "("){
if(myArray[0] == "("){ if(myArray[0] == "("){
myRegExpArr[1] = new RegExp(myArray[1]); if(myArray[1] != "("){
myQuery = '( myRegExpArr[1].test(contentPage[nIndex].pageText)'; myRegExpArr[1] = new RegExp(myArray[1]);
}else{ }
myRegExpArr[0] = new RegExp(myArray[0].slice(1)); myQuery = '( ';
myQuery = '( myRegExpArr[0].test(contentPage[nIndex].pageText)';
count++;
} }
}else{ }else{
myRegExpArr[0] = new RegExp(myArray[0]); myRegExpArr[0] = new RegExp(myArray[0]);
myQuery = 'myRegExpArr[0].test(contentPage[nIndex].pageText)'; myQuery = 'myRegExpArr[0].test(contentPage[nIndex].pageText)';
count++; if(myArray[0] == "OR" || myArray[0] == "or" || myArray[0] == "Or" || myArray[0] == "oR"){
myQuery = ' || ';
}
} }
for (var i = 1; i < myArray.length; i++){ for (var i = 1; i < myArray.length; i++){
if(myArray[i] == "OR" || myArray[i] == "or" || myArray[i] == "Or" || myArray[i] == "oR"){ if(myArray[i] == "OR" || myArray[i] == "or" || myArray[i] == "Or" || myArray[i] == "oR"){
myRegExpArr[i] = new RegExp(myArray[i]); myRegExpArr[i] = new RegExp(myArray[i]);
}else if(myArray[i].charAt(0) == "(" || myArray[i] == "("){ }else if(myArray[i] == "(" || myArray[i] == "("){
if(myArray[i] == "("){ if(myArray[i] == "("){
if(myArray[i - 1] == "OR" || myArray[i - 1] == "or" || myArray[i - 1] == "Or" || myArray[i - 1] == "oR"){ if(myArray[i - 1] == "OR" || myArray[i - 1] == "or" || myArray[i - 1] == "Or" || myArray[i - 1] == "oR"){
myQuery += ' || ('; myQuery += ' || (';
}else{ }else if(myArray[i - 1] != "("){
myQuery += ' && ('; myQuery += ' && (';
} }else{
myQuery += ' (';
}
}else{ }else{
if(myArray[i - 1] == "OR" || myArray[i - 1] == "or" || myArray[i - 1] == "Or" || myArray[i - 1] == "oR"){ if(myArray[i - 1] == "OR" || myArray[i - 1] == "or" || myArray[i - 1] == "Or" || myArray[i - 1] == "oR"){
myRegExpArr[i] = new RegExp(myArray[i].slice(1)); myRegExpArr[i] = new RegExp(myArray[i].slice(1));
myQuery += ' || ( myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)'; myQuery += ' || ( myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';
count++;
}else{ }else{
myRegExpArr[i] = new RegExp(myArray[i].slice(1)); myRegExpArr[i] = new RegExp(myArray[i].slice(1));
myQuery += ' && ( myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)'; myQuery += ' && ( myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';
count++;
} }
} }
}else if(myArray[i].charAt(myArray[i].length - 1) == ")" || myArray[i] == ")"){ }else if(myArray[i].charAt(myArray[i].length - 1) == ")" || myArray[i] == ")"){
...@@ -801,27 +856,22 @@ CONTENTVIEW.searchHandle = function() { ...@@ -801,27 +856,22 @@ CONTENTVIEW.searchHandle = function() {
if(myArray[i - 1] == "OR" || myArray[i - 1] == "or" || myArray[i - 1] == "Or" || myArray[i - 1] == "oR"){ if(myArray[i - 1] == "OR" || myArray[i - 1] == "or" || myArray[i - 1] == "Or" || myArray[i - 1] == "oR"){
myRegExpArr[i] = new RegExp(myArray[i].slice(0, -1)); myRegExpArr[i] = new RegExp(myArray[i].slice(0, -1));
myQuery += ' || myRegExpArr[' + i + '].test(contentPage[nIndex].pageText) )'; myQuery += ' || myRegExpArr[' + i + '].test(contentPage[nIndex].pageText) )';
count++;
}else{ }else{
myRegExpArr[i] = new RegExp(myArray[i].slice(0, -1)); myRegExpArr[i] = new RegExp(myArray[i].slice(0, -1));
myQuery += ' && myRegExpArr[' + i + '].test(contentPage[nIndex].pageText) )'; myQuery += ' && myRegExpArr[' + i + '].test(contentPage[nIndex].pageText) )';
count++;
} }
} }
}else{ }else{
if(myArray[i - 1] == "OR" || myArray[i - 1] == "or" || myArray[i - 1] == "Or" || myArray[i - 1] == "oR"){ if(myArray[i - 1] == "OR" || myArray[i - 1] == "or" || myArray[i - 1] == "Or" || myArray[i - 1] == "oR"){
myRegExpArr[i] = new RegExp(myArray[i]); myRegExpArr[i] = new RegExp(myArray[i]);
myQuery += ' || myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)'; myQuery += ' || myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';
count++;
}else{ }else{
if(myArray[i - 1] == "("){ if(myArray[i - 1] == "("){
myRegExpArr[i] = new RegExp(myArray[i]); myRegExpArr[i] = new RegExp(myArray[i]);
myQuery += ' myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)'; myQuery += ' myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';
count++;
}else{ }else{
myRegExpArr[i] = new RegExp(myArray[i]); myRegExpArr[i] = new RegExp(myArray[i]);
myQuery += ' && myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)'; myQuery += ' && myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';
count++;
} }
} }
} }
...@@ -833,20 +883,14 @@ CONTENTVIEW.searchHandle = function() { ...@@ -833,20 +883,14 @@ CONTENTVIEW.searchHandle = function() {
for (var nIndex = 0; nIndex < contentPage.length; nIndex++) { for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
if (eval(myQuery)) { if (eval(myQuery)) {
//searchResult.push(contentPage[nIndex]);
sPageNo.push(contentPage[nIndex]); sPageNo.push(contentPage[nIndex]);
} }
} }
}catch(error){ }catch(error){
searchText = "invaildsearchtextzeroresultfound"; searchText = "invaildsearchtextzeroresultfound";
}
if(count > 5){
alert('語句数は最大5つです');
return;
} }
}
if (sPageNo.length > 0) { if (sPageNo.length > 0) {
//title start //title start
$('#bookmarkBoxHdSearching').children().remove(); $('#bookmarkBoxHdSearching').children().remove();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment