Commit 3c6f7aef by Kim Eunchul

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

parent a8ca3a66
......@@ -747,51 +747,106 @@ CONTENTVIEW.searchHandle = function() {
var myQuery;
var myRegExpArr = [];
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{
do {
var match = myRegexp.exec(textReg);
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);
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[1] != "("){
myRegExpArr[1] = new RegExp(myArray[1]);
myQuery = '( myRegExpArr[1].test(contentPage[nIndex].pageText)';
}else{
myRegExpArr[0] = new RegExp(myArray[0].slice(1));
myQuery = '( myRegExpArr[0].test(contentPage[nIndex].pageText)';
count++;
}
myQuery = '( ';
}
}else{
myRegExpArr[0] = new RegExp(myArray[0]);
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++){
if(myArray[i] == "OR" || myArray[i] == "or" || myArray[i] == "Or" || myArray[i] == "oR"){
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 - 1] == "OR" || myArray[i - 1] == "or" || myArray[i - 1] == "Or" || myArray[i - 1] == "oR"){
myQuery += ' || (';
}else{
}else if(myArray[i - 1] != "("){
myQuery += ' && (';
}else{
myQuery += ' (';
}
}else{
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));
myQuery += ' || ( myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';
count++;
}else{
myRegExpArr[i] = new RegExp(myArray[i].slice(1));
myQuery += ' && ( myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';
count++;
}
}
}else if(myArray[i].charAt(myArray[i].length - 1) == ")" || myArray[i] == ")"){
......@@ -801,27 +856,22 @@ CONTENTVIEW.searchHandle = function() {
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));
myQuery += ' || myRegExpArr[' + i + '].test(contentPage[nIndex].pageText) )';
count++;
}else{
myRegExpArr[i] = new RegExp(myArray[i].slice(0, -1));
myQuery += ' && myRegExpArr[' + i + '].test(contentPage[nIndex].pageText) )';
count++;
}
}
}else{
if(myArray[i - 1] == "OR" || myArray[i - 1] == "or" || myArray[i - 1] == "Or" || myArray[i - 1] == "oR"){
myRegExpArr[i] = new RegExp(myArray[i]);
myQuery += ' || myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';
count++;
}else{
if(myArray[i - 1] == "("){
myRegExpArr[i] = new RegExp(myArray[i]);
myQuery += ' myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';
count++;
}else{
myRegExpArr[i] = new RegExp(myArray[i]);
myQuery += ' && myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';
count++;
}
}
}
......@@ -833,7 +883,6 @@ CONTENTVIEW.searchHandle = function() {
for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
if (eval(myQuery)) {
//searchResult.push(contentPage[nIndex]);
sPageNo.push(contentPage[nIndex]);
}
}
......@@ -841,12 +890,7 @@ CONTENTVIEW.searchHandle = function() {
}catch(error){
searchText = "invaildsearchtextzeroresultfound";
}
if(count > 5){
alert('語句数は最大5つです');
return;
}
if (sPageNo.length > 0) {
//title start
$('#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