Commit 5714d658 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Getting close to working implementation.

parent 1fa24546
......@@ -85,7 +85,7 @@ class SearchBox{
let query = [...this.searchQuery];
let types = [...this.queryTypes];
// For combining elements connected by AND into a list
// For combining elements/formules connected by AND into a single list
function combineANDIn(query, types) {
const newQuery = []
const newTypes = []
......@@ -99,22 +99,27 @@ class SearchBox{
const q3 = query[i+2];
const t3 = types[i+2];
if ((t1 === "E" || t1 === "EL" ) && (t3 === "E" || t3 === "EL" ) && q2 === "AND" && q0 !== "NOT") {
let active = true
let elements = [q1, q3]
i = i + 3
while(active) {
const q4 = query[i];
const t4 = types[i];
const q5 = query[i+1];
const t5 = types[i+1];
if (q4 === "AND" && (t5 === "E" || t5 === "EL" )) {
elements.push(q5)
i += 2
} else {
active = false
newQuery.push(elements.join(", "))
newTypes.push("EL")
if (q2 === "AND" && q0 !== "NOT") {
if (
((t1 === "E" || t1 === "EL") && (t3 === "E" || t3 === "EL" )) ||
((t1 === "F" && t3 === "F")
) {
let active = true
let joined = [q1, q3]
i = i + 3
while(active) {
const q4 = query[i];
const t4 = types[i];
const q5 = query[i+1];
const t5 = types[i+1];
if (q4 === "AND" && (t5 === "E" || t5 === "EL" )) {
joined.push(q5)
i += 2
} else {
active = false
newQuery.push(joined.join(", "))
newTypes.push("EL")
}
}
}
} else {
......
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