mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-03 20:02:47 +00:00 
			
		
		
		
	Continue new list building for results
This commit is contained in:
		@@ -38,6 +38,11 @@ main {
 | 
			
		||||
}
 | 
			
		||||
/* ### End sidenav-fixed offset ### */
 | 
			
		||||
 | 
			
		||||
/* add custom bold class */
 | 
			
		||||
.bold {
 | 
			
		||||
  font-weight: bold;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* CSS for clickable th elements in tables. Needed for sortable table data with
 | 
			
		||||
list js. On click on th header elements will be sorted accordingly. Also a caret
 | 
			
		||||
indicator will show up how the column is sorted right now.; */
 | 
			
		||||
@@ -87,6 +92,7 @@ indicator will show up how the column is sorted right now.; */
 | 
			
		||||
  z-index: 999; /* tmp fix */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* styles for resource lists */
 | 
			
		||||
.service[data-service]:before {
 | 
			
		||||
  content: "help";
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -93,66 +93,55 @@ RessourceList.options = {
 | 
			
		||||
class ResultList extends List {
 | 
			
		||||
 | 
			
		||||
  createResultRowElement(item, chunk) {
 | 
			
		||||
    let values, cpos, matchRowElement, lcCellElement, lcTokenElement, token;
 | 
			
		||||
    let values, cpos, token, matchRowElement, lcCellElement, hitCellElement, rcCellElement, textTitlesCellElement;
 | 
			
		||||
    // gather values from item
 | 
			
		||||
    values = item.values();
 | 
			
		||||
    console.log("CHONK");
 | 
			
		||||
    console.log(chunk);
 | 
			
		||||
 | 
			
		||||
    // get infos for full match row
 | 
			
		||||
    matchRowElement = document.createElement("tr");
 | 
			
		||||
    for (cpos of values["lc"]) {
 | 
			
		||||
      console.log(cpos);
 | 
			
		||||
      lcCellElement = document.createElement("td");
 | 
			
		||||
      lcTokenElement = document.createElement("span");
 | 
			
		||||
      lcTokenElement.classList.add("token");
 | 
			
		||||
      lcTokenElement.dataset.cpos = cpos;
 | 
			
		||||
      token = chunk["cpos_lookup"][cpos];
 | 
			
		||||
      lcTokenElement.innerText = token["word"];
 | 
			
		||||
      lcCellElement.appendChild(lcTokenElement);
 | 
			
		||||
      //   let hit_tokens = "";
 | 
			
		||||
    }
 | 
			
		||||
    matchRowElement.setAttribute("data-index", values["index"])
 | 
			
		||||
    lcCellElement = document.createElement("td");
 | 
			
		||||
    lcCellElement.classList.add("left-context");
 | 
			
		||||
    matchRowElement.appendChild(lcCellElement);
 | 
			
		||||
    //   // get infos of match
 | 
			
		||||
    //   let textTitles = new Set();
 | 
			
		||||
    //   for (cpos of match["hit"]) {
 | 
			
		||||
    //     tokenElement = document.createElement("span");
 | 
			
		||||
    //     tokenElement.classList.add("token");
 | 
			
		||||
    //     tokenElement.dataset.cpos = cpos;
 | 
			
		||||
    //     token = chunk["cpos_lookup"][cpos];
 | 
			
		||||
    //     tokenElement.innerText = token["word"];
 | 
			
		||||
    //     hit_tokens += " " + tokenElement.outerHTML;
 | 
			
		||||
    //     // get text titles of every hit cpos token
 | 
			
		||||
    //     textTitles.add(chunk["text_lookup"][token["text"]]["title"]);
 | 
			
		||||
    //   }
 | 
			
		||||
    //   // add button to trigger more context to every match td
 | 
			
		||||
    //   var inspectBtn = document.createElement("a");
 | 
			
		||||
    //   inspectBtn.setAttribute("class", "btn-floating btn-flat waves-effect waves-light grey right inspect");
 | 
			
		||||
    //   inspectBtn.onclick = function() {inspect()};
 | 
			
		||||
    //   inspectBtn.innerHTML = '<i class="material-icons">search</i>';
 | 
			
		||||
    //   hit_tokens += "<p>" + inspectBtn.outerHTML + "</p>";
 | 
			
		||||
    //   // get infos for right context of match
 | 
			
		||||
    //   let rc_tokens = "";
 | 
			
		||||
    //   for (cpos of match["rc"]) {
 | 
			
		||||
    //     tokenElement = document.createElement("span");
 | 
			
		||||
    //     tokenElement.classList.add("token");
 | 
			
		||||
    //     tokenElement.dataset.cpos = cpos;
 | 
			
		||||
    //     token = chunk["cpos_lookup"][cpos];
 | 
			
		||||
    //     tokenElement.innerText = token["word"];
 | 
			
		||||
    //     rc_tokens += " " + tokenElement.outerHTML;
 | 
			
		||||
    //   }
 | 
			
		||||
    //   // put all infos into an javascribt object
 | 
			
		||||
    //   textTitleElement = document.createElement("span");
 | 
			
		||||
    //   textTitleElement.classList.add("text-titles");
 | 
			
		||||
    //   textTitles = [...textTitles].join(",");
 | 
			
		||||
    //   textTitleElement.innerText = textTitles;
 | 
			
		||||
    //
 | 
			
		||||
    //   matchRowElement.appendChild(textTitleElement);
 | 
			
		||||
    //   // matchRowElement.appendChild(lc_tokens);
 | 
			
		||||
    //   // matchRowElement.appendChild(hit_tokens);
 | 
			
		||||
    //   // matchRowElement.appendChild(rc_tokens);
 | 
			
		||||
    //   // matchRowElement.appendChild(index);
 | 
			
		||||
    // }
 | 
			
		||||
    console.log(matchRowElement.outerHTML);
 | 
			
		||||
    for (cpos of values["lc"]) {
 | 
			
		||||
      token = chunk["cpos_lookup"][cpos];
 | 
			
		||||
      lcCellElement.insertAdjacentHTML("beforeend", `<span class="token" data-cpos="${cpos}">${token["word"]} </span>`);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // get infos for hit of match
 | 
			
		||||
    let textTitles = new Set();
 | 
			
		||||
    hitCellElement = document.createElement("td");
 | 
			
		||||
    hitCellElement.classList.add("match-hit");
 | 
			
		||||
    textTitlesCellElement = document.createElement("td");
 | 
			
		||||
    textTitlesCellElement.classList.add("titles");
 | 
			
		||||
    matchRowElement.appendChild(hitCellElement);
 | 
			
		||||
    for (cpos of values["hit"]) {
 | 
			
		||||
      token = chunk["cpos_lookup"][cpos];
 | 
			
		||||
      hitCellElement.insertAdjacentHTML("beforeend", `<span class="token" data-cpos="${cpos}">${token["word"]} </span>`);
 | 
			
		||||
      // get text titles of every hit cpos token
 | 
			
		||||
      textTitles.add(chunk["text_lookup"][token["text"]]["title"]);
 | 
			
		||||
      // add button to trigger more context to every match td
 | 
			
		||||
      var inspectBtn = document.createElement("a");
 | 
			
		||||
      inspectBtn.setAttribute("class", "btn-floating btn-flat waves-effect waves-light grey right inspect");
 | 
			
		||||
      inspectBtn.innerHTML = '<i class="material-icons">search</i>';
 | 
			
		||||
      inspectBtn.onclick = function () {inspect(values["index"])};
 | 
			
		||||
    }
 | 
			
		||||
    // add text titles at front as first td of one row
 | 
			
		||||
    hitCellElement.appendChild(inspectBtn);
 | 
			
		||||
    textTitlesCellElement.innerText = [...textTitles].join(", ");
 | 
			
		||||
    matchRowElement.insertAdjacentHTML("afterbegin", textTitlesCellElement.outerHTML);
 | 
			
		||||
 | 
			
		||||
    // get infos for right context of match
 | 
			
		||||
    rcCellElement = document.createElement("td");
 | 
			
		||||
    rcCellElement.classList.add("right-context");
 | 
			
		||||
    matchRowElement.appendChild(rcCellElement);
 | 
			
		||||
    for (cpos of values["rc"]) {
 | 
			
		||||
      token = chunk["cpos_lookup"][cpos];
 | 
			
		||||
      rcCellElement.insertAdjacentHTML("beforeend", `<span class="token" data-cpos="${cpos}">${token["word"]} </span>`);
 | 
			
		||||
    }
 | 
			
		||||
    console.log(matchRowElement);
 | 
			
		||||
    return matchRowElement
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user