class globalFunc { DataCheck(/*luxon, */arg1, arg2) { let tempresult = false let iarg1 = arg1 let iarg2 = arg2 switch(true) { case arg1.isValid: case arg2.isValid: case (!Boolean(iarg2 instanceof Object) && !Boolean(iarg1 instanceof Object)): tempresult = this.compareData(/*luxon, */iarg1, iarg2) break; case (!Boolean(iarg1 instanceof Object)): for (let i = 0; i < iarg2.length; i++) { tempresult = tempresult || this.compareData(/*luxon, */iarg1, iarg2[i]) } break; case (!Boolean(iarg2 instanceof Object)): for (let i = 0; i < iarg1.length; i++) { tempresult = tempresult || this.compareData(/*luxon, */iarg1[i], iarg2) } break; default: for (let i = 0; i < iarg2.length; i++) { for (let j = 0; j < iarg1.length; j++) { tempresult = tempresult || this.compareData(/*luxon, */iarg1[j], iarg2[i]) } } break; } return tempresult } compareData(/*luxon, */arg1, arg2) { let tempresult = false; let targ1 = arg1 let toperator = "" let targ2 = arg2 if (this.hasOperator(arg2.toString())) { toperator = this.getOperator(arg2) targ2 = arg2.replace(toperator, "") } switch(true) { case Boolean(arg1.isValid): targ1 = arg1.toString() //startOf("day") break; case Boolean(arg2.isValid): targ2 = arg2.toString() // startOf("day") //(arg2.isValid) ? arg2.startOf("day") : (luxon.DateTime.fromISO(`${targ2}`)).startOf("day") break; case (arg1.length == 0): targ1 = '' break; } switch(toperator) { case '<': tempresult = (targ1 < targ2) break; case '<=': tempresult = (targ1 <= targ2) break; case '>': tempresult = (targ1 > targ2) break; case '>=': tempresult = (targ1 >= targ2) break; case '!': tempresult = (typeof targ1 === 'string' || targ1 instanceof String) ? !(targ1.search(new RegExp(targ2, "i")) > -1) : (targ1 != targ2) break; default: tempresult = (typeof targ1 === 'string' || targ1 instanceof String) ? (targ1.search(new RegExp(targ2, "i")) > -1) : (targ1 == targ2) break; } return tempresult } hasOperator(arg1) { let tempresult = false; switch(arg1.charAt(0)) { case '<': case '>': case '!': case '=': tempresult = true break; } return tempresult } getOperator(arg1) { return (this.hasOperator(arg1.charAt(1))) ? arg1.charAt(0) + arg1.charAt(1) : arg1.charAt(0); } BuildList(arg1, construct) { let TempS = "" for (let i = 0; i < arg1.length; i++) { if (Boolean(arg1[i])) { if (TempS == "") { TempS = arg1[i] } else { TempS = TempS + construct + arg1[i] } } } return TempS } buildToPrint(arg1, arg2, construct) { let TempS = "" if (arg2 instanceof Object) { for (let i = 0; i < arg1.length; i++) { if (Boolean(arg1[i])) { if (TempS == "") { TempS = arg2[i] + ": " + "" + arg1[i] + "" } else { TempS = TempS + construct + arg2[i] + ": " + "" + arg1[i] + "" } if (arg2[i].search(new RegExp("time", "i")) > -1) { TempS = TempS + " min" } } } } else { for (let i = 0; i < arg1.length; i++) { if (Boolean(arg1[i])) { if (TempS == "") { TempS = "" + arg1[i] + "" } else { TempS = TempS + construct + "" + arg1[i] + "" } } } } return TempS } Get1stArg(arg3) { return ((arg3 instanceof Object) || (arg3 instanceof Array)) ? arg3[0] : arg3 } topLevelFilter(pobj, DocType, subType) { let result = true let folderExcl = (DocType == 'Source') ? '00.01' : '00.'; result = !pobj.file.path.contains(folderExcl) && this.GetPoint(pobj, "main", "type") !== undefined && this.GetPoint(pobj, "main", "type") !== null && this.GetPoint(pobj, "main", "type").contains(DocType) if (Boolean(subType)) { result = result && this.GetPoint(pobj, DocType, "type") !== undefined && this.GetPoint(pobj, DocType, "type") !== null && this.GetPoint(pobj, DocType, "type").contains(subType) } return result } IsInSearch(/*luxon, */pobj, DocType, darray, iarray) { let ilength = iarray.length; let result = true for (let i = 0; i < iarray.length; i++) { if (iarray[i] == undefined || darray[i] == undefined) {result = result && true} else { switch(darray[i]) { case 'readingd': if (iarray[i] == true || iarray[i] == false) {result = result && (Boolean(this.GetpProp(pobj, DocType, darray[i])) == iarray[i])} else { if (Boolean(iarray[i])) { let pProp = this.GetpProp(pobj, DocType, darray[i]) if (!Boolean(pProp)) { result = result && false } else { result = result && this.DataCheck(/*luxon, */pProp, iarray[i]) } } else {result = result && true} } break; default: if (Boolean(iarray[i])) { let pProp = this.GetpProp(pobj, DocType, darray[i]) if (!Boolean(pProp)) { result = result && false } else { result = result && this.DataCheck(/*luxon, */pProp, iarray[i]) } } else {result = result && true} break; } } } return result } getTable(dv, /*luxon, */DocType, darray, iarray, tabletype) { let page = dv.pages() .filter(p => p && this.topLevelFilter(p, DocType, 0)) .where(p => p && this.IsInSearch(/*luxon, */p, DocType, darray, iarray)) if (page.length == 0) { return this.EmptyQueryMessage(dv) } dv.table(this.GetTableHeaders(DocType, tabletype), page .sort(p => p.file.name, `asc`) .map(p => this.GetTableMap(DocType, tabletype,p))); } EmptyQueryMessage(dv) { return dv.el('b', '⚠️ Warning:\nNo result matching your query!') } GetTableHeaders(DataT, TableT) { let TempData = ["Name"] switch(DataT) { case 'Investment': switch(TableT) { case 'overview': TempData = ["Name", "Currency", "Style", "Stage", "Themes"] break; case 'trading': TempData = ["Name", "Currency", "Trading date", "Trading price"] break; } break; case 'Source': TempData = ["Title", "Author", "Published date", "Language", "Date read", "Cover"] // TempData = ["Title", "Author", "Published date", "Language", "Themes", "Date read"] break; case 'Place': switch(TableT) { case 'Restaurant': case 'Brunch': TempData = ["Name", "Style", "Cuisine", "☎️", "📧", "🌐"] break; case 'Hotel': case 'Bar': TempData = ["Name", "Type", "Influence", "☎️", "📧", "🌐"] break; case 'Sport': TempData = ["Name", "☎️", "📧", "🌐"] break; case 'Café': TempData = ["Name", "Style", "☎️", "📧", "🌐"] break; } break; case 'Product': TempData = ["Name", "Category", "🌐", "💵", "🏷️"] break; case 'Server': switch(TableT) { case 'overview': TempData = ["Name", "🏪", "🌐", "🗺️", "📍"] break; case 'technical': TempData = ["Name", "OS", "CPU", "RAM", "Disk size", "Disk type", "Bandwidth", "Speed"] break; case 'usage': TempData = ["Name", "Disk size", "Used space", "Date updated"] break; } break; case 'Recipe': switch(TableT) { default: TempData = ["Name", "Category", "🌍", "⏳", "🎖️"] break; case 'extended': TempData = ["Name", "Course", "Category", "🌍", "⏳", "🎖️", "❤️"] break; } break; case 'Wine': switch(TableT) { default: TempData = ["Name", "Type", "Vintage", "Country", "Terroir", "Appellation"] break; case 'extended': TempData = ["Name", "Type", "Vintage", "Country", "Region", "Terroir", "Appellation", "Vineyard", "Variety", "Notes"] break; } break; case 'Coffee': switch(TableT) { default: TempData = ["Name", "Coffee type", "📶", "🌍", "🔥", "🏷️", "©️"] break; } break; } return TempData } GetTableMap(DataT, TableT, p) { let TempData = [p.file.link] switch(DataT) { case 'Investment': switch(TableT) { case 'overview': TempData = [p.file.link, this.GetPoint(p, DataT, "ccy"), this.GetPoint(p, DataT, "style"), this.GetPoint(p, DataT, "stage"), this.GetPoint(p, "main", "tag")] break; case 'trading': TempData = [p.file.link, this.GetPoint(p, DataT, "ccy"), this.GetPoint(p, DataT, "tradingd"), this.GetPoint(p, DataT, "tradingp")] break; } break; case 'Source': TempData = [p.file.link, this.GetPoint(p, DataT, "author"), this.GetPoint(p, DataT, "published"), this.GetPoint(p, DataT, "lang"), this.GetPoint(p, DataT, "read"), "![](" + this.GetPoint(p, DataT, "cover") + ")"] // TempData = [p.file.link, this.GetPoint(p, DataT, "author"), this.GetPoint(p, DataT, "published"), this.GetPoint(p, DataT, "lang"), this.GetPoint(p, "main", "tag"), this.GetPoint(p, DataT, "read")] break; case 'Place': switch(TableT) { case 'Restaurant': case 'Brunch': case 'Hotel': case 'Bar': TempData = [p.file.link, this.GetPoint(p, DataT, "subtype"), this.toEmoji(this.GetPoint(p, DataT, "style")), this.GetPoint(p, DataT, "phone"), this.GetPoint(p, DataT, "email"), this.GetPoint(p, DataT, "website")] break; case 'Sport': TempData = [p.file.link, this.GetPoint(p, DataT, "phone"), this.GetPoint(p, DataT, "email"), this.GetPoint(p, DataT, "website")] break; case 'Café': TempData = [p.file.link, this.GetPoint(p, DataT, "subtype"), this.GetPoint(p, DataT, "phone"), this.GetPoint(p, DataT, "email"), this.GetPoint(p, DataT, "website")] break; } break; case 'Product': TempData = [p.file.link, this.GetPoint(p, DataT, "type"), this.GetPoint(p, DataT, "link"), this.GetPoint(p, DataT, "value"), this.GetPoint(p, "main", "tag")] break; case 'Server': switch(TableT) { case 'overview': TempData = [p.file.link, this.GetPoint(p, DataT, "host"), this.GetPoint(p, DataT, "subdomain"), this.GetPoint(p, DataT, "dom"), this.GetPoint(p, DataT, "ipv4")] break; case 'technical': TempData = [p.file.link, this.GetPoint(p, DataT, "os"), this.GetPoint(p, DataT, "cpu"), this.GetPoint(p, DataT, "ram"), this.GetPoint(p, DataT, "capa"), this.GetPoint(p, DataT, "type"), this.GetPoint(p, DataT, "bw"), this.GetPoint(p, DataT, "speed")] break; case 'usage': TempData = [p.file.link, this.GetPoint(p, DataT, "capa"), this.GetPoint(p, DataT, "usedspace"), this.GetPoint(p, DataT, "timestamp")] break; } break; case 'Recipe': switch(TableT) { default: TempData = [p.file.link, this.GetPoint(p, DataT, "category"), this.toEmoji(this.GetPoint(p, DataT, "collection")), this.GetPoint(p, DataT, "cooking") + " min", this.toEmoji(this.GetPoint(p, DataT, "rating"))] break; case 'extended': TempData = [p.file.link, this.GetPoint(p, DataT, "course"), this.GetPoint(p, DataT, "category"), this.toEmoji(this.GetPoint(p, DataT, "collection")), this.GetPoint(p, DataT, "cooking") + " min", this.toEmoji(this.GetPoint(p, DataT, "rating")), this.toEmoji(Boolean(this.GetPoint(p, DataT, "isfavourite")))] break; } break; case 'Wine': switch(TableT) { default: TempData = [p.file.link, this.GetPoint(p, DataT, "type"), this.GetPoint(p, DataT, "vintage"), this.toEmoji(this.GetPoint(p, DataT, "country")), this.GetPoint(p, DataT, "subregion"), this.GetPoint(p, DataT, "appellation")] break; case 'extended': TempData = [p.file.link, this.GetPoint(p, DataT, "type"), this.GetPoint(p, DataT, "vintage"), this.toEmoji(this.GetPoint(p, DataT, "country")), this.GetPoint(p, DataT, "region"), this.GetPoint(p, DataT, "subregion"), this.GetPoint(p, DataT, "appellation"), this.GetPoint(p, DataT, "vineyard"), this.GetPoint(p, DataT, "varietal"), this.toEmoji(this.GetPoint(p, "main", "tag"))] break; } break; case 'Coffee': switch(TableT) { default: TempData = [p.file.link, this.GetPoint(p, DataT, "type"), this.GetPoint(p, DataT, "strength"), this.toEmoji(this.GetPoint(p, DataT, "country")), this.GetPoint(p, DataT, "roast"), this.toEmoji(this.GetPoint(p, "main", "tag")), this.GetPoint(p, DataT, "brand")] break; } break; } return TempData } toEmoji(label) { let tempresult = "" //other test for below: typeof label == 'object' //return Object.entries(label) if (label instanceof Object) { for (let i = 0; i < label.length; i++) { if (tempresult == '') { tempresult = this.getEmoji(label[i]); } else {tempresult = tempresult + " / " + this.getEmoji(label[i]);} } } else {tempresult = this.getEmoji(label)} return tempresult } getEmoji(label) { let tempresult = "" switch(label) { case 'French': case 'France': tempresult = "🇫🇷" break; case 'Italian': case 'Italy': tempresult = "🇮🇹" break; case 'British': tempresult = "🇬🇧" break; case 'American': case 'US': tempresult = "🇺🇸" break; case 'Indian': tempresult = "🇮🇳" break; case 'Mexican': tempresult = "🇲🇽" break; case 'Asian': case 'Asian Fusion': tempresult = "⛩" break; case 'Modern': tempresult = "💠" break; case 'Peruvian': tempresult = "🇵🇪" break; case 'Spanish': case 'Spain': tempresult = "🇪🇸" break; case 'Greek': tempresult = "🇬🇷" break; case 'Japanese': tempresult = "🇯🇵" break; case 'Argentine': tempresult = "🇦🇷" break; case 'Chinese': tempresult = "🇨🇳" break; case 'Taiwanese': tempresult = "🇹🇼" break; case 'Korean': tempresult = "🇰🇷" break; case 'Swiss': tempresult = "🇨🇭" break; case 'Jamaican': tempresult = "🇯🇲" break; case 'Haitian': tempresult = "🇭🇹" break; case 'Finnish': tempresult = "🇫🇮" break; case 'Filipino': tempresult = "🇵🇭" break; case 'Hungarian': tempresult = "🇭🇺" break; case 'Afghan': tempresult = "🇦🇫" break; case 'German': tempresult = "🇩🇪" break; case 'Egg': tempresult = "🥚" break; case 'Middle Eastern': tempresult = "☪️" break; case 'European': tempresult = "🇪🇺" break; case 'North African': case 'Morroccan': case 'North African Fusion': tempresult = "🇲🇦" break; case 'Swedish': case 'Nordics': tempresult = "🇸🇪" break; case 'Brazil': tempresult = "🇧🇷" break; case 'Colombia': tempresult = "🇨🇴" break; case 'El Salvador': case 'ElSalvador': tempresult = "🇸🇻" break; case 'Pub': tempresult = "🍺" break; case true: tempresult = "✅" break; case false: tempresult = "❌" break; case 'Fish': tempresult = "🐠" break; case 'Apricot': case 'Peach': tempresult = "🍑 " + label break; case 'Berries': tempresult = "🫐 " + label break; case 'Caramel': tempresult = "🍮 " + label break; case 'Cocoa': case 'Chocolate': tempresult = "🍫 " + label break; case 'Fruity': tempresult = "🥝 " + label break; case 'DriedFruit': tempresult = "🍇 " + label break; case 'Nutty': case 'Hazelnut': tempresult = "🌰 " + label break; case 'SugarCane': tempresult = "🍬 " + label break; case 'Crisp': tempresult = "❄️ " + label break; case 'Mango': tempresult = "🥭 " + label break; case 'Oak': tempresult = "🪵 " + label break; case 'Powerful': tempresult = "🔋 " + label break; case 0: tempresult = "☆☆☆☆☆" break; case 1: tempresult = "★☆☆☆☆" break; case 2: tempresult = "★★☆☆☆" break; case 3: tempresult = "★★★☆☆" break; case 4: tempresult = "★★★★☆" break; case 5: tempresult = "★★★★★" break; default: tempresult = label } return tempresult } GetpProp(pobj, DocType, dPoint) { let result = null switch(dPoint) { case 'dateadded': result = this.GetPoint(pobj, "main", "date") break; case 'theme': result = this.GetPoint(pobj, "main", "tag") break; case 'invtype': case 'sourcetype': case 'placetype': case 'prodtype': case 'disktype': case 'winetype': case 'coffeetype': result = this.GetPoint(pobj, DocType, "type") break; case 'style': result = this.GetPoint(pobj, DocType, "style") break; case 'stage': result = this.GetPoint(pobj, DocType, "stage") break; case 'ccy': result = this.GetPoint(pobj, DocType, "ccy") break; case 'tradingd': result = this.GetPoint(pobj, DocType, "tradingd") break; case 'tradingp': result = this.GetPoint(pobj, DocType, "tradingp") break; case 'language': result = this.GetPoint(pobj, DocType, "lang") break; case 'author': result = this.GetPoint(pobj, DocType, "author") break; case 'publicationd': result = this.GetPoint(pobj, DocType, "published") break; case 'readingd': result = this.GetPoint(pobj, DocType, "read") break; case 'country': result = this.GetPoint(pobj, DocType, "country") break; case 'area': result = this.GetPoint(pobj, DocType, "location") break; case 'ambiance': result = this.GetPoint(pobj, DocType, "subtype") break; case 'status': result = this.GetPoint(pobj, DocType, "status") break; case 'prodvalue': result = this.GetPoint(pobj, DocType, "value") break; case 'host': result = this.GetPoint(pobj, DocType, "host") break; case 'subdomain': result = this.GetPoint(pobj, DocType, "subdomain") break; case 'OS': result = this.GetPoint(pobj, DocType, "os") break; case 'CPU': result = this.GetPoint(pobj, DocType, "cpu") break; case 'RAM': result = this.GetPoint(pobj, DocType, "ram") break; case 'Capa': result = this.GetPoint(pobj, DocType, "capa") break; case 'BW': result = this.GetPoint(pobj, DocType, "bw") break; case 'speed': result = this.GetPoint(pobj, DocType, "speed") break; case 'dom': result = this.GetPoint(pobj, DocType, "dom") break; case 'course': result = this.GetPoint(pobj, DocType, "course") break; case 'category': result = this.GetPoint(pobj, DocType, "category") break; case 'cuisine': result = this.GetPoint(pobj, DocType, "collection") break; case 'ingredient': result = this.GetPoint(pobj, DocType, "ingredient") break; case 'isfavourite': result = this.GetPoint(pobj, DocType, "isfavourite") break; case 'rating': result = this.GetPoint(pobj, DocType, "rating") break; case 'cookingtime': result = this.GetPoint(pobj, DocType, "cooking") break; case 'vintage': result = this.GetPoint(pobj, DocType, "vintage") break; case 'vineyard': result = this.GetPoint(pobj, DocType, "vineyard") break; case 'terroir': result = this.GetPoint(pobj, DocType, "subregion") break; case 'region': result = this.GetPoint(pobj, DocType, "region") break; case 'producer': result = this.GetPoint(pobj, DocType, "producer") break; case 'appellation': result = this.GetPoint(pobj, DocType, "appellation") break; case 'variety': result = this.GetPoint(pobj, DocType, "varietal") break; case 'designation': result = this.GetPoint(pobj, DocType, "designation") break; case 'brand': result = this.GetPoint(pobj, DocType, "brand") break; case 'roast': result = this.GetPoint(pobj, DocType, "roast") break; case 'strength': result = this.GetPoint(pobj, DocType, "strength") break; } return result } GetPoint(pobj, fstline, dPoint) { let result = null switch(fstline) { case 'main': switch(dPoint) { case 'alias': result = pobj.Alias break; case 'tag': result = pobj.Tag break; case 'date': result = pobj.Date break; case 'type': result = pobj.DocType break; case 'hierarchy': result = pobj.Hierarchy break; case 'location': result = pobj.location break; case 'meatatable': result = pobj.CollapseMetaTable break; case 'timestamp': result = pobj.TimeStamp break; } break; case 'Investment': switch(dPoint) { case 'style': result = pobj.Investment.Style break; case 'stage': result = pobj.Investment.Stage break; case 'ccy': result = pobj.Investment.Ccy break; case 'type': result = pobj.Investment.Type break; case 'tradingd': result = pobj.Trading.PDate break; case 'tradingp': result = pobj.Trading.PPrice break; } break; case 'Place': switch(dPoint) { case 'style': result = pobj.Place.Style break; case 'subtype': result = pobj.Place.SubType break; case 'location': result = pobj.Place.Location break; case 'type': result = pobj.Place.Type break; case 'country': result = pobj.Place.Country break; case 'status': result = pobj.Place.Status break; case 'phone': result = pobj.Phone break; case 'email': result = pobj.Email break; case 'website': result = pobj.Website break; } break; case 'Source': switch(dPoint) { case 'author': result = pobj.Source.Author break; case 'lang': result = pobj.Source.Language break; case 'published': result = pobj.Source.Published break; case 'type': result = pobj.Source.Type break; case 'link': result = pobj.Source.Link break; case 'read': result = pobj.Source.Read break; case 'cover': result = pobj.Source.Cover break; } break; case 'Product': switch(dPoint) { case 'value': result = pobj.Product.Value break; case 'type': result = pobj.Product.Type break; case 'link': result = pobj.Product.Link break; } break; case 'Server': switch(dPoint) { case 'cpu': result = pobj.Performance.CPU break; case 'ram': result = pobj.Performance.RAM break; case 'bw': result = pobj.Performance.Bandwidth break; case 'speed': result = pobj.Performance.Speed break; case 'os': result = pobj.Characteristics.OS break; case 'dom': result = pobj.Characteristics.Domiciliation break; case 'ipv4': result = pobj.Characteristics.IPv4 break; case 'hostname': result = pobj.Characteristics.Hostname break; case 'host': result = pobj.Characteristics.Host break; case 'subdomain': result = pobj.Characteristics.SubDomain break; case 'capa': result = pobj.Disk.Capa break; case 'type': result = pobj.Disk.Type break; case 'usedspace': result = pobj.Disk.UsedSpace break; case 'timestamp': result = pobj.Disk.TimeStamp break; } break; case 'Task': switch(dPoint) { case 'priority': result = pobj.Task.Priority break; case 'status': result = pobj.Task.Status break; case 'startdate': result = pobj.Task.StartDate break; case 'duedate': result = pobj.Task.DueDate break; case 'nextreviewdate': result = pobj.Task.NextReviewDate break; } break; case 'Travel': switch(dPoint) { case 'country': result = pobj.Travel.Country break; case 'duration': result = pobj.Travel.Duration break; case 'budget': result = pobj.Travel.Budget break; case 'type': result = pobj.Travel.Type break; case 'lbestseason': result = pobj.Travel.BestSeason break; case 'departuredate': result = pobj.Travel.DepartureDate break; } break; case 'Recipe': switch(dPoint) { case 'course': result = pobj.Recipe.Courses break; case 'category': result = pobj.Recipe.Categories break; case 'collection': result = pobj.Recipe.Collections break; case 'source': result = pobj.Recipe.Source break; case 'preparation': result = pobj.Recipe.PreparationTime break; case 'cooking': result = pobj.Recipe.CookingTime break; case 'ingredient': result = pobj.Ingredients break; case 'isfavourite': result = pobj.Meta.IsFavourite break; case 'rating': result = pobj.Meta.Rating break; } break; case 'Wine': switch(dPoint) { case 'vintage': result = pobj.Wine.Vintage break; case 'type': result = pobj.Wine.Type break; case 'producer': result = pobj.Wine.Producer break; case 'varietal': result = pobj.Wine.Varietal break; case 'designation': result = pobj.Wine.Designation break; case 'vineyard': result = pobj.Wine.Vineyard break; case 'country': result = pobj.Wine.Country break; case 'region': result = pobj.Wine.Region break; case 'subregion': result = pobj.Wine.SubRegion break; case 'appellation': result = pobj.Wine.Appellation break; } break; case 'Coffee': switch(dPoint) { case 'brand': result = pobj.Coffee.Brand break; case 'roast': result = pobj.Coffee.Roast break; case 'country': result = pobj.Coffee.Country break; case 'type': result = pobj.Coffee.Type break; case 'strength': result = pobj.Coffee.Strength break; } break; } return result } }