Can someone help me with the following codes? I’m trying to create a keyword search so that users can look up specific words in the Job Listing and Description pages.
import wixData from ‘wix-data’;
var lastJobType;
var lastIndustry;
var lastKeyword = ‘’;
var timer;
$w.onReady(function () {});
// Job Type Dropdown
function filterResults(jobType, industryType, keyword){
var newFilter = wixData.filter();
newFilter = newFilter.eq('jobType', jobType);
newFilter = newFilter.eq('industry', industryType);
newFilter = newFilter.contains('jobDescription', keyword)
.or(newFilter.contains('title', keyword))
.or(newFilter.contains('location', keyword))
.or(newFilter.contains('requirements', keyword))
.or(newFilter.contains('aboutUs', keyword));
$w("#dbJob").setFilter(newFilter)
.then(() => {
resultChecker();
});
lastJobType = jobType;
lastIndustry = industryType;
lastKeyword = keyword;
}
export function iptJobType_change(event) {
var allJobType;
if($w("#iptJobType").value !== 'All'){
allJobType = $w("#iptJobType").value;
}
filterResults(allJobType, lastIndustry, lastKeyword);
}
// Industry Dropdown
export function iptIndustry_change(event) {
var allIndustryType;
if($w("#iptIndustry").value !== 'anyIndustry'){
allIndustryType = $w("#iptIndustry").value;
}
filterResults(lastJobType, allIndustryType, lastKeyword);
}
//Job title / Keyword search
export function iptKeyword_keyPress(event) {
if(timer){
clearTimeout(timer);
timer = undefined;
}
timer = setTimeout(() => {
filterResults(lastJobType, lastIndustry, $w("#iptKeyword").value)
}, 2000);
}
function resultChecker(){
var count = $w("#dbJob").getTotalCount();
if(count === 0){
$w("#txtMsg").show();
$w("#jobListingRep").hide(); $w("#jobListingRep").collapse();
$w("#pagJob").hide(); $w("#pagJob").collapse();
}else{
$w("#txtMsg").hide();
$w("#jobListingRep").show(); $w("#jobListingRep").expand();
$w("#pagJob").show(); $w("#pagJob").expand();
}
}