mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 12:22:47 +00:00 
			
		
		
		
	Create and use a nopaque namespace for functions and ressources
This commit is contained in:
		@@ -181,18 +181,16 @@
 | 
			
		||||
  var loadingModal;
 | 
			
		||||
  document.addEventListener("DOMContentLoaded", function() {
 | 
			
		||||
    contextModal = M.Modal.init(document.getElementById("context-modal"),
 | 
			
		||||
                                {"dismissible": true,
 | 
			
		||||
                                 "onCloseEnd": function() {
 | 
			
		||||
                                {"onCloseEnd": function() {
 | 
			
		||||
                                   document.getElementById("context-modal-loading").classList.remove("hide");
 | 
			
		||||
                                   document.getElementById("context-modal-ready").classList.add("hide");}
 | 
			
		||||
                                });
 | 
			
		||||
                                   document.getElementById("context-modal-ready").classList.add("hide");}});
 | 
			
		||||
    loadingModal = M.Modal.init(document.getElementById("loading-modal"),
 | 
			
		||||
                                {"dismissible": false});
 | 
			
		||||
    loadingModal.open();
 | 
			
		||||
    socket.emit("request_corpus_analysis", {{ corpus_id }});
 | 
			
		||||
    nopaque.socket.emit("request_corpus_analysis", {{ corpus_id }});
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  socket.on("request_corpus_analysis", function(msg) {
 | 
			
		||||
  nopaque.socket.on("request_corpus_analysis", function(msg) {
 | 
			
		||||
    if (msg === "[201]: Created") {loadingModal.close();}
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
@@ -230,13 +228,13 @@
 | 
			
		||||
                     "hits_per_page": formData.get("hits_per_page"),
 | 
			
		||||
                     "query": formData.get("query")};
 | 
			
		||||
    hitsPerPage = formData.get("hits_per_page");
 | 
			
		||||
    socket.emit("corpus_analysis", queryData);
 | 
			
		||||
    nopaque.socket.emit("corpus_analysis", queryData);
 | 
			
		||||
    queryLoadingElement.classList.remove("hide");
 | 
			
		||||
    queryResultsTableElement.classList.add("hide");
 | 
			
		||||
    toast("Query has been sent!")
 | 
			
		||||
    nopaque.toast("Query has been sent!")
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  socket.on("corpus_analysis", function(message) {
 | 
			
		||||
  nopaque.socket.on("corpus_analysis", function(message) {
 | 
			
		||||
    console.log("### corpus_analysis ###");
 | 
			
		||||
    console.log(message);
 | 
			
		||||
    queryLoadingElement.classList.add("hide");
 | 
			
		||||
@@ -250,11 +248,11 @@
 | 
			
		||||
 | 
			
		||||
    if (message === null) {
 | 
			
		||||
      queryResultsTableElement.classList.add("hide");
 | 
			
		||||
      toast("No results for this query!")
 | 
			
		||||
      nopaque.toast("No results for this query!")
 | 
			
		||||
      return;
 | 
			
		||||
    } else if (message === "CQI_CQP_ERROR_GENERAL") {
 | 
			
		||||
        queryResultsTableElement.classList.add("hide");
 | 
			
		||||
        toast("Invalid query entered!", "red");
 | 
			
		||||
        nopaque.toast("Invalid query entered!", "red");
 | 
			
		||||
        return;
 | 
			
		||||
      } else {
 | 
			
		||||
        total_nr_matches = message["total_nr_matches"];
 | 
			
		||||
@@ -365,7 +363,7 @@
 | 
			
		||||
        var dataIndex = inspectBtn.parentNode.parentNode.getAttribute("data-index");
 | 
			
		||||
        inspectBtn.onclick = function() {
 | 
			
		||||
          contextModal.open();
 | 
			
		||||
          socket.emit("inspect_match", {"cpos": matches[dataIndex]["hit"]});
 | 
			
		||||
          nopaque.socket.emit("inspect_match", {"cpos": matches[dataIndex]["hit"]});
 | 
			
		||||
        };
 | 
			
		||||
      }
 | 
			
		||||
  });
 | 
			
		||||
@@ -399,7 +397,7 @@
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  socket.on("match_context", function(message) {
 | 
			
		||||
  nopaque.socket.on("match_context", function(message) {
 | 
			
		||||
    console.log("### match_context ###");
 | 
			
		||||
    console.log(message);
 | 
			
		||||
    contextResultsElement.innerHTML = "<p> </p>";
 | 
			
		||||
 
 | 
			
		||||
@@ -102,21 +102,27 @@
 | 
			
		||||
      this.corpusId = corpusId;
 | 
			
		||||
      this.foreignCorpusFlag = foreignCorpusFlag;
 | 
			
		||||
      if (this.foreignCorpusFlag) {
 | 
			
		||||
        foreignCorporaSubscribers.push(this);
 | 
			
		||||
        nopaque.foreignCorporaSubscribers.push(this);
 | 
			
		||||
      } else {
 | 
			
		||||
        corporaSubscribers.push(this);
 | 
			
		||||
        nopaque.corporaSubscribers.push(this);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    _init() {
 | 
			
		||||
      var corpus = this.foreignCorpusFlag ? foreignCorpora[this.corpusId] : corpora[this.corpusId];
 | 
			
		||||
      let corpus;
 | 
			
		||||
 | 
			
		||||
      if (this.foreignCorpusFlag) {
 | 
			
		||||
        corpus = nopaque.foreignCorpora[this.corpusId];
 | 
			
		||||
      } else {
 | 
			
		||||
        corpus = nopaque.corpora[this.corpusId];
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // Status
 | 
			
		||||
      this.setStatus(corpus.status);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    _update(patch) {
 | 
			
		||||
      var pathArray;
 | 
			
		||||
      let pathArray;
 | 
			
		||||
 | 
			
		||||
      for (let operation of patch) {
 | 
			
		||||
        /* "/corpusId/valueName" -> ["corpusId", "valueName"] */
 | 
			
		||||
@@ -141,12 +147,13 @@
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    setStatus(status) {
 | 
			
		||||
      var statusElement;
 | 
			
		||||
      let analyseBtn, statusElement;
 | 
			
		||||
 | 
			
		||||
      statusElement = document.getElementById("status");
 | 
			
		||||
      statusElement.classList.remove(...Object.values(CorpusList.STATUS_COLORS));
 | 
			
		||||
      statusElement.classList.add(CorpusList.STATUS_COLORS[status] || CorpusList.STATUS_COLORS['default']);
 | 
			
		||||
      statusElement.innerText = status;
 | 
			
		||||
      var analyseBtn = document.getElementById('analyse');
 | 
			
		||||
      analyseBtn = document.getElementById('analyse');
 | 
			
		||||
      if (status === 'prepared' || status === 'analysing' || status === 'failed') {
 | 
			
		||||
        analyseBtn.classList.remove('hide', 'disabled');
 | 
			
		||||
      } else if (status === 'start analysis' || status === 'stop analysis') {
 | 
			
		||||
@@ -164,7 +171,7 @@
 | 
			
		||||
  var informationUpdater = new InformationUpdater({{ corpus.id }}, false);
 | 
			
		||||
  {% else %}
 | 
			
		||||
  var informationUpdater = new InformationUpdater({{ corpus.id }}, true);
 | 
			
		||||
  socket.emit('subscribe_foreign_user_ressources', {{ corpus.user_id }});
 | 
			
		||||
  nopaque.socket.emit('subscribe_foreign_user_ressources', {{ corpus.user_id }});
 | 
			
		||||
  {% endif %}
 | 
			
		||||
</script>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user