var debug = "found" var debugtitle = "string" let curr = dv.current(); let {placetype, dateadded, style, ambiance, area, theme, country, status} = input; let page = dv.pages() .filter(p => {return !p.file.path.contains('00.') && p.DocType !== undefined && p.DocType !== null && p.DocType.contains('Place')}) function PDataCheck(arg1, arg2) { var iarg1 = arg1 if (moment(iarg1).isValid()) {iarg1 = arg1.toString()} var iarg2 = arg2 if (moment(iarg2).isValid()) {iarg2 = arg2.toString()} if (!Array.isArray(iarg2)) { var resultdc = iarg1.contains(iarg2) } else if (!Array.isArray(iarg1)) { var resultdc = iarg2.contains(iarg1) } else { let count = iarg2.length let tempresult = false for (let i = 0; i < count; i++) { tempresult = tempresult || iarg1.contains(iarg2[i]) } var resultdc = tempresult } return resultdc } function IsInPSearch(argobj) { if (Boolean(placetype)) { var result_ptype = PDataCheck(argobj.Place.Type, placetype) } else {var result_ptype = true} if (Boolean(theme)) { var result_tag = PDataCheck(argobj.Tag, theme) } else {var result_tag = true} if (Boolean(dateadded)) { var result_date = PDataCheck(argobj.Date, dateadded) } else {var result_date = true} if (Boolean(ambiance)) { var result_amb = PDataCheck(argobj.Place.SubType, ambiance) } else {var result_amb = true} if (Boolean(style)) { if (argobj.Place.Style == undefined) {var result_style = false} else { var result_style = PDataCheck(argobj.Place.Style, style) } } else {var result_style = true} if (Boolean(area)) { var result_area = PDataCheck(argobj.Place.Location, area) } else {var result_area = true} if (Boolean(country)) { var result_ctry = PDataCheck(argobj.Place.Country, country) } else {var result_ctry = true} if (Boolean(status)) { var result_stat = PDataCheck(argobj.Place.Status, status) } else {var result_stat = true} var resultiid = result_ptype && result_tag && result_date && result_amb && result_style && result_area && result_ctry && result_stat return resultiid } let templacetype = GetMainPlaceType(placetype) function GetMainPlaceType(arg3) { if (!Array.isArray(arg3)) { return arg3 } else { return arg3[0] } } if (page.length > 0 && (templacetype == 'Restaurant' || templacetype == 'Brunch')) { dv.table(["Name", "Style", "Cuisine", "Phone", "Email", "Website"], page .where(p => p && IsInPSearch(p)) .sort(p => p.file.name, `asc`) .map(p => [p.file.link, p.Place.SubType, p.Place.Style, p.Phone, p.Email, p.Website])); } else if (page.length > 0 && (templacetype == 'Hotel' || templacetype == 'Bar')) { dv.table(["Name", "Type", "Influence", "Phone", "Email", "Website"], page .where(p => p && IsInPSearch(p)) .sort(p => p.file.name, `asc`) .map(p => [p.file.link, p.Place.SubType, p.Place.Style, p.Phone, p.Email, p.Website])); } else if (page.length > 0 && (templacetype == 'Sport')) { dv.table(["Name", "Phone", "Email", "Website"], page .where(p => p && IsInPSearch(p)) .sort(p => p.file.name, `asc`) .map(p => [p.file.link, p.Phone, p.Email, p.Website])); } else if (page.length > 0 && (templacetype == 'Café')) { dv.table(["Name", "Style", "Phone", "Email", "Website"], page .where(p => p && IsInPSearch(p)) .sort(p => p.file.name, `asc`) .map(p => [p.file.link, p.Place.SubType, p.Phone, p.Email, p.Website])); } else { return '"No result matching your query"'}