Skip to content
Snippets Groups Projects
Select Git revision
  • c7cec09acb3ac09f00094442adefe45bd8935907
  • master default
  • JS-based-scroll-rendering
  • Paul_Marius_Level
  • Paul_Marius_2
  • Paul_Marius
  • Andi_Mark
  • be-UnityWebView
  • gitignoreFrameitServer
  • ZimmerBSc
  • Bugfix_StageLoading
  • stages
  • MAZIFAU_Experimental
  • tsc/coneworld
  • tsc/fact-interaction
  • marcel
  • MaZiFAU_TopSort
  • mergeHelper
  • zwischenSpeichern
  • tempAndrToMaster
  • SebBranch
  • 3.0
  • v2.1
  • v2.0
  • v1.0
25 results

SetScrollContent.js

Blame
  • SetScrollContent.js 1.52 KiB
    "use strict";
    let currentScrollRef = ""; // ref of the scroll currently displayed 
    function RenderScroll() {
        const dataSource = document.querySelector("#Unity-Data-Interface");
        if (!(dataSource instanceof HTMLElement)
            || dataSource === null
            || dataSource.dataset.scrollDynamic === undefined) {
            console.error("No Scroll found in the Unity-Data-Interface");
            return;
        }
        const scroll_json = JSON.parse(dataSource.dataset.scrollDynamic);
        const scroll = backendObject_fromJSON(scroll_json);
        if (!isScroll(scroll)) {
            console.error("The Scroll in the Unity-Data-Interface cannot be parsed");
            return;
        }
        //console.log(scroll.requiredFacts);
        const scrollContainer = document.querySelector("#scrollContainer");
        // replace the description if the scroll changed, otherwise only its content needs update
        // if (scroll.ref != currentScrollRef) {
        //     currentScrollRef = scroll.ref;
        //     scrollContainer.innerHTML = scroll.description;
        // }
        // go through the facts in the scroll, show their labels, add dropzones and limit the allowed types
        scroll.slots.forEach(slot => {
            $(`[data-slot-id='${slot.uri}']`)
                .html(slot.label)
                .attr("dropzone", "copy");
        });
        // acquired facts only need updated labels
        scroll.acquiredFacts.forEach(fact => {
            $(`[data-solution-id='${fact.uri}']`)
                .html(fact.label);
        });
        console.log(scroll.label + 'Scroll rendered');
    }
    $(function () {
        RenderScroll();
    });