Difference between revisions of "Widget:DCTList"

From LINKS Community Center
Jump to: navigation, search
Line 1: Line 1:
<noinclude>Development version of the Compass.<br><strong style="color:red;">Not ready for production!</strong>
+
<noinclude>Development verstion of the DCT List.<br><span style="color: red; font-weight: bold;">Not ready for production!</span></noinclude>
</noinclude>
 
 
<includeonly>
 
<includeonly>
 +
    <link href="/resources/assets/tabulator.min.css" rel="stylesheet">
 +
    <script type="text/javascript" src="/resources/assets/tabulator.min.js"></script>
 +
 
     <style>
 
     <style>
         :root {
+
         #dct-list-wrapper {
             --compass-color: #C31980;
+
            font-family: 'Open Sans';
            --handbook-color: #C35C19;
+
            margin-top: 4em;
             --safe-color: #80C319;
+
        }
 +
 
 +
        #dct-list-wrapper h1,
 +
        #dct-list-wrapper h2,
 +
        #dct-list-wrapper h3,
 +
        #dct-list-wrapper h4 {
 +
             font-family: 'Raleway';
 +
            font-weight: 300;
 +
            letter-spacing: .06em;
 +
        }
 +
 
 +
        #dct-list-wrapper h1,
 +
        #dct-filters h2 {
 +
            display: flex;
 +
             align-items: center;
 
         }
 
         }
  
         .plus.icon {
+
         #dct-intro {
             color: currentColor;
+
            font-size: larger;
             display: inline-block;
+
            margin-bottom: 4em;
             position: relative;
+
        }
             top: -.3em;
+
 
             margin-left: .5em;
+
        #dct-list-wrapper h1 {
 +
             color: var(--links-blue);
 +
        }
 +
        #dct-list-wrapper h1 svg {
 +
             height: 2.5em;
 +
             width: 2.5em;
 +
             fill: var(--links-blue);
 +
             margin-right: .5em;
 
         }
 
         }
  
         .plus.icon::before {
+
         #filter-bar { position: relative; margin: 1em 0 2em 0; }
            content: '';
+
        #dct-filters {
 
             position: absolute;
 
             position: absolute;
             width: 1em;
+
            top: 0;
             height: 1px;
+
            right: 0;
             background-color: currentColor;
+
            z-index: 100;
 +
            padding: 2em;
 +
             width: 45vw;
 +
            background: #fff;
 +
             border: 1px solid var(--links-blue);
 +
            clip-path: inset(0 0 100% 100%);
 +
            box-shadow: -10px 10px 10px 5px rgb(0 0 0 / 10%);
 +
            transition: all 400ms ease-in-out;
 +
        }
 +
        #dct-filters.open {
 +
             clip-path: inset(0 0 -50px -50px);
 
         }
 
         }
  
         .plus.icon::after {
+
         #close-filter-button {
             content: '';
+
             display: block;
             position: absolute;
+
             cursor: pointer;
             width: 1em;
+
             font-size: 2.5em;
             height: 1px;
+
             line-height: .7em;
             background-color: currentColor;
+
             margin-top: -.2em;
             transform: rotate(90deg);
+
             font-weight: 100;
             transition: all 0.4s ease;
+
             color: var(--links-blue);
 
         }
 
         }
  
         h2.opened .plus.icon::after,
+
         #dct-filters h2 svg {
        h3.opened .plus.icon::after {
+
            height: 1.5em;
             transform: rotate(0);
+
            width: 1.5em;
 +
            margin-right: .5em;
 +
             margin-left: -.2em;
 
         }
 
         }
  
         #cmp-container {
+
         .large-button {
 +
            border: 1px solid var(--links-blue);
 +
            font-size: 1.5em;
 
             font-family: 'Open Sans';
 
             font-family: 'Open Sans';
             font-size: 120%;
+
             font-weight: 100;
 +
            margin-bottom: 2em;
 +
            padding: 0.3em 0.8em;
 +
            color: var(--links-blue);
 +
            background: transparent;
 +
            font-variant: small-caps;
 +
            display: inline-block;
 +
            transition: all 200ms ease-in-out;
 
         }
 
         }
  
         #cmp-container h1,
+
         .large-button:hover {
        #cmp-container h2,
+
             background-color: var(--links-blue);
        #cmp-container h3 {
+
             color: #fff;
             font-family: 'Raleway';
 
            font-weight: 300;
 
            letter-spacing: .06em;
 
             position: relative;
 
 
         }
 
         }
  
         #cmp-container h1 {
+
         #dct-list-wrapper h2 {
             letter-spacing: .06em;
+
             margin-bottom: 1em;
 
         }
 
         }
  
         #cmp-container h2 {
+
         .filter-button-wrapper {
             margin-top: 2em;
+
             margin-bottom: 1em;
            padding-bottom: 5px;
 
            color: var(--compass-color);
 
            cursor: pointer;
 
 
         }
 
         }
  
         #cmp-container h2::before {
+
         .filter-wrapper button {
             content: '';
+
             border: 0 none;
            display: block;
+
             color: var(--links-blue);
            position: absolute;
+
             background-color: transparent;
            left: 0;
+
             font-variant: small-caps;
             bottom: 0;
+
             font-size: 1.2em;
            width: 100%;
+
             text-decoration: underline;
            height: 1px;
+
             padding: 0;
             background-color: currentColor;
 
             letter-spacing: .06em;
 
             transition: all 0.4s ease;
 
             transform: scaleX(0);
 
             transform-origin: bottom left;
 
 
         }
 
         }
  
         #cmp-container h2.opened::before {
+
         .filter-wrapper .filter-container { display: none; }
             transform: scaleX(1);
+
        .filter-wrapper.open .filter-container { display: block; }
 +
 
 +
        .filter-wrapper h4 {
 +
            display: flex;
 +
            justify-content: space-between;
 +
             align-items: flex-start;
 
         }
 
         }
  
         #cmp-container h3 {
+
         .filter-wrapper .filter-toggle svg {
             font-weight: 1.4em;
+
             width: 1.5em;
 +
            height: 1.5em;
 +
            fill: var(--links-blue);
 
             cursor: pointer;
 
             cursor: pointer;
 
         }
 
         }
  
         .subtheme {
+
         .filter-wrapper.open .filter-toggle {
             margin-bottom: 2em;
+
             transform: rotate(180deg);
 
         }
 
         }
  
         .question {
+
         .filter-content {
 
             font-size: 1.2em;
 
             font-size: 1.2em;
             padding-left: 2em;
+
             margin-bottom: 4em;
             cursor: pointer;
+
             display: grid;
             margin-bottom: 1em;
+
             grid-template-columns: repeat(auto-fit, minmax(14em, 1fr));
 +
            gap: 1em 1em;
 +
            align-items: start;
 
         }
 
         }
  
         .question::before {
+
         .filter-group-header {
             content: "→ ";
+
            grid-column: 1/-1;
 +
            margin-bottom: -.5em;
 +
            margin-top: 1em;
 +
            font-family: 'Raleway';
 +
            font-weight: 200;
 +
             letter-spacing: .06em;
 
         }
 
         }
  
         .answer {
+
         .filter-group-start {
             margin: 1.4em;
+
             grid-column-start: 1;
            font-size: 1.2rem;
 
 
         }
 
         }
  
         .subtheme,
+
         .filter-content input[type="checkbox"] {
        .question,
+
             margin-right: .5em;
        .answer {
 
             display: none;
 
 
         }
 
         }
  
         .subtheme.opened,
+
         .filter-content img {
        .question.opened,
+
            width: 2em;
        .answer.opened {
+
            height: 2em;
             display: block;
+
             margin: 0 .5em 0 0;
 
         }
 
         }
  
         .answer-wrapper {
+
         .subfunc-filter-block {
             display: grid;
+
             font-size: smaller;
             grid-template-columns: 1fr 1fr;
+
             padding-left: 1em;
            gap: 1em;
 
 
         }
 
         }
  
         .choice {
+
         #dct-tabulator.tabulator {
             display: flex;
+
             border: 0 none;
             flex-flow: row nowrap;
+
             background-color: transparent;
             justify-content: flex-start;
+
             font-size: 1.2em;
            align-items: flex-start;
 
 
         }
 
         }
  
         .choice .button {
+
         #dct-tabulator.tabulator .tabulator-header {
             flex: 0 0 8.2em;
+
             border-bottom: 4px double var(--links-blue);
            white-space: nowrap;
+
             background-color: transparent;
            transition: all 250ms;
 
            display: flex;
 
            justify-content: center;
 
             align-items: center;
 
            padding: 1em;
 
            border: 1px solid currentColor;
 
 
         }
 
         }
  
         .choice .desc {
+
         #dct-tabulator.tabulator .tabulator-header .tabulator-col {
             font-size: 75%;
+
             border-right: 0 none;
            padding-left: 1em;
+
             background: transparent;
             transition: all 250ms;
 
 
         }
 
         }
  
         .choice:hover .desc {
+
         #dct-tabulator.tabulator .tabulator-header .tabulator-col-content {
             font-weight: 600;
+
             padding: .5em 0;
 
         }
 
         }
  
         .choice.tech {
+
         #dct-tabulator.tabulator .tabulator-header .tabulator-col-sorter {
             color: var(--links-blue);
+
             right: 1em;
 
         }
 
         }
  
         .choice.guide {
+
         #dct-tabulator.tabulator .tabulator-row {
             color: var(--links-orange);
+
             background-color: transparent;
 
         }
 
         }
  
         .choice.case {
+
         #dct-tabulator.tabulator .tabulator-cell {
             color: var(--links-cyan);
+
             border-right: 0 none;
 +
            border-top: 1px solid var(--links-blue);
 +
            padding: .5em 0;
 
         }
 
         }
  
         .choice.handbook {
+
         .data-source-img,
             color: var(--handbook-color);
+
        .func-img {
 +
             width: 1.2rem;
 +
            height: 1.2rem;
 +
            margin-right: .4rem;
 +
            margin-bottom: .4rem;
 +
            filter: grayscale(1);
 +
        }
 +
        .func-img {
 +
            width: 1.5rem;
 +
            height: 1.5rem;
 
         }
 
         }
  
         .choice.safe {
+
         #dct-tabulator img.unselected {
             color: var(--safe-color);
+
             opacity: .15;
 
         }
 
         }
  
         .choice.tech:hover .button {
+
         .sources-collapse {
             background-color: var(--links-blue);
+
             display: inline-block;
            color: #fff;
 
 
         }
 
         }
  
         .choice.guide:hover .button {
+
         .sources-collapse-toggle {
             background-color: var(--links-orange);
+
             display: inline-block;
             color: #fff;
+
            width: 2em;
 +
             height: 2em;
 
         }
 
         }
  
         .choice.case:hover .button {
+
         #dct-tabulator .tabulator-row .tabulator-responsive-collapse {
             background-color: var(--links-cyan);
+
             padding: 0 .5em 2em 0;
             color: #fff;
+
             border: 0 none;
 
         }
 
         }
  
         .choice.handbook:hover .button {
+
         #filter-summary { margin-right: 1em; }
            background-color: var(--handbook-color);
+
 
             color: #fff;
+
        #filter-summary table tr td { vertical-align: top; }
 +
        #filter-summary table tr td:first-of-type { padding-right: 10px; }
 +
       
 +
        #dct-tabulator .tabulator-row .tabulator-responsive-collapse table {
 +
             font-size: smaller;
 
         }
 
         }
  
         .choice.safe:hover .button {
+
         #filter-summary table tr td strong,
            background-color: var(--safe-color);
+
        #dct-tabulator .tabulator-row .tabulator-responsive-collapse table tr td strong {
             color: #fff;
+
             font-weight: 300;
 
         }
 
         }
 
     </style>
 
     </style>
  
     <div id="cmp-container">
+
     <script>
         <div class="theme">
+
        'use strict';
            <h2>Engaging Citizens</h2>
+
 
            <div class="subtheme">
+
        const FUNC_KEY = 'functions';
                 <h3>Collecting and Analysing Information from SMCS</h3>
+
         const DESC_KEY = 'description';
                 <div class="question" data-aspect="Social">
+
 
                    Whom do you want to include in your collection and analysis of information, and from whom do you
+
        /** @typedef {Map<string, { [DESC_KEY]: string, [FUNC_KEY]: string[] }>} FuncData */
                    want to collect and analyse information?
+
 
 +
        /** @type FuncData */
 +
        const functionsData = new Map();    // Data on functions and function categories
 +
 
 +
        /**
 +
        * @typedef {Object} DCT
 +
        * @property {string} name
 +
        * @property {string} url
 +
        * @property {string[]} dataSources
 +
        * @property {string[]} businessModel
 +
        * @property {FuncData} functions
 +
        * @property {string} usedByDmo
 +
        * @property {string} logo
 +
        */
 +
 
 +
        let table;  // Tabulator instance
 +
 
 +
        // This defines how sources are grouped in the filter.
 +
        // Any source not listed here will be added to the last group entitled "More platforms".
 +
        const sourcesLayout = [
 +
            {
 +
                title: 'General',
 +
                sources: ['Crowd', 'Web']
 +
            },
 +
            {
 +
                title: 'Platforms',
 +
                 sources: ['Facebook', 'Twitter', 'Instagram', 'YouTube']
 +
            }
 +
        ];
 +
 
 +
        // This object defines the sort order of function categories and matches them to icons.
 +
        const fnImages = {
 +
            'Search and Monitor':  '/index.php/Special:FilePath/File:Func_search.svg',
 +
            'Post and Schedule':    '/index.php/Special:FilePath/File:Func_post.svg',
 +
            'Analysis':            '/index.php/Special:FilePath/File:Func_analysis.svg',
 +
            'Metrics':              '/index.php/Special:FilePath/File:Func_metrics.svg',
 +
            'Report':              '/index.php/Special:FilePath/File:Func_report.svg',
 +
            'Collaboration':        '/index.php/Special:FilePath/File:Func_collaboration.svg',
 +
            'Interoperability':    '/index.php/Special:FilePath/File:Func_interoperability.svg',
 +
            'Meta':                 '/index.php/Special:FilePath/File:Func_meta.svg',
 +
        };
 +
 
 +
        // Helpers
 +
        const escapeAttr = text => text ? text.replace(/\W/g, '-') : text;
 +
        const getFilePath = title => title ? '/index.php/Special:FilePath/' + title : title;
 +
        const getQueryUrl = query => '/api.php?action=ask&format=json&query=' + encodeURIComponent(query);
 +
        const removePrefix = str => str.substring(str.indexOf(':') + 1);
  
                    <div class="answer">
+
        // Fetches platform / data source information.
                        <div class="answer-wrapper">
+
        async function getSources() {
                            <div class="choice case" id="q1-case">
+
            const IMG_KEY = 'IMAGE';
                                <div class="button">Use Cases</div>
+
            const sourceResponse = await fetch(
                                <div class="desc">
+
                getQueryUrl('[[Category:Social media platform]]|?' + IMG_KEY)
                                    It provides helpful information from social media and crowdsourcing
+
            ).then(response => response.json());
                                    examples around the theme “Collecting and Analysing Information from SMCS”. Also the
+
 
                                    question, which vulnerable groups (disabled, migrants, minorities,…) were
+
            return Object.keys(sourceResponse.query.results).map(platform => {
                                    specifically involved in social media and crowdsourcing activities is answered.
+
                const img = sourceResponse.query.results[platform].printouts[IMG_KEY][0];
                                </div>
+
                return {
                            </div>
+
                    name: platform,
                            <div class="choice guide" id="q1-guide">
+
                     image: img ? getFilePath(img.fulltext) : undefined
                                <div class="button">Guidelines</div>
+
                 };
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
+
            });
                                    consectetur, adipisci velit...</div>
+
        }
                            </div>
 
                        </div>
 
                     </div>
 
                 </div>
 
                <div class="question" data-aspect="Socio-/Technical">
 
                    How to collect and analyse information from citizens?
 
  
                    <div class="answer">
+
        // Fetches DCTs and their functions.
                        <div class="answer-wrapper">
+
        async function getDcts() {
                            <div class="choice tech" id="q2-tech">
+
            const functionsQuery = '[[Category:Function_category]]'
                                <div class="button">Technologies</div>
+
                                + '|?-Subproperty_of=' + FUNC_KEY
                                <div class="desc">
+
                                + '|?Has_description=' + DESC_KEY;
                                    It allows filtering for software that covers the functions Search &
+
            const functionsQueryResponse = await fetch(getQueryUrl(functionsQuery)).then(response => response.json());
                                    Monitor and Analysis of information from social media.
+
       
                                </div>
+
            const sortOrder = Object.keys(fnImages);
                            </div>
+
            Object.entries(functionsQueryResponse.query.results)
                            <div class="choice guide" id="q2-guide">
+
                .map(([key, value]) => ([removePrefix(key), value]))
                                <div class="button">Guidelines</div>
+
                .sort(([keyA,], [keyB,]) => sortOrder.indexOf(keyA) - sortOrder.indexOf(keyB))
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
+
                .forEach(([categoryName, results]) => {
                                    consectetur, adipisci velit...</div>
+
                    functionsData.set(
                            </div>
+
                        categoryName,
                            <div class="choice case" id="q2-case">
+
                        {
                                <div class="button">Use Cases</div>
+
                            [DESC_KEY]: results.printouts[DESC_KEY][0],
                                <div class="desc">
+
                             [FUNC_KEY]: results.printouts[FUNC_KEY].map(func => removePrefix(func.fulltext))
                                    It provides helpful information from social media and crowdsourcing
+
                         }
                                    examples around the theme “Collecting and Analysing Information from SMCS”. Also the
+
                     );
                                    question, which specific functionality SMCS has been used for and how (e.g.
+
                 });
                                    gathering of information) is answered.
 
                                </div>
 
                             </div>
 
                         </div>
 
                     </div>
 
                 </div>
 
            </div>
 
            <div class="subtheme">
 
                <h3>Mobilising Citizens</h3>
 
                <div class="question" data-aspect="Social">
 
                    Who do you want to mobilise, and from whom would you want mobility-affiliated information?
 
  
                    <div class="answer">
+
            // TODO: Remove properties that are not relevant for the filter? (e.g. 'Supported content types')
                        <div class="answer-wrapper">
+
            const allFunctions = Array.from(functionsData.values(), entry => entry[FUNC_KEY]).flat();
                            <div class="choice case" id="q3-case">
 
                                <div class="button">Use Cases</div>
 
                                <div class="desc">
 
                                    It provides helpful information from social media and crowdsourcing
 
                                    examples around the theme “Mobilising Citizens”.
 
                                </div>
 
                            </div>
 
                            <div class="choice handbook" id="q3-handbook">
 
                                <div class="button">Citizens Handbook</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                        </div>
 
                    </div>
 
                </div>
 
                <div class="question" data-aspect="Socio-/Technical">
 
                    How can you mobilise the citizens?
 
  
                    <div class="answer">
+
            const DATASRC_PROP = 'Data Sources';
                        <div class="answer-wrapper">
+
            const IMG_PROP = 'Image';
                            <div class="choice tech" id="q4-tech">
+
            const BUSINESS_PROP = 'Business model';
                                <div class="button">Technologies</div>
+
            const DMO_PROP = 'Used by Practitioners';
                                <div class="desc">
+
            const dctQuery = '[[Category:Disaster Community Technology]]'
                                    It allows filtering for software that covers the function Post &
+
                          + '[[Is Archived::No]]'
                                    Schedule, which aims at publishing information on social media.
+
                          + '|limit=500'
                                </div>
+
                          + '|?' + IMG_PROP
                            </div>
+
                          + '|?' + DATASRC_PROP
                            <div class="choice guide" id="q4-guide">
+
                          + '|?' + BUSINESS_PROP
                                <div class="button">Guidelines</div>
+
                          + '|?' + DMO_PROP
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
+
                          + '|?' + allFunctions.join('|?');
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                            <div class="choice case" id="q4-case">
 
                                <div class="button">Use Cases</div>
 
                                <div class="desc">
 
                                    It provides helpful information from social media and crowdsourcing
 
                                    examples around the theme “Mobilising Citizens”.
 
                                </div>
 
                            </div>
 
                            <div class="choice safe" id="q4-safe">
 
                                <div class="button">Feel Safe</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                        </div>
 
                    </div>
 
                </div>
 
            </div>
 
            <div class="subtheme">
 
                <h3>Mobilising Volunteers</h3>
 
                <div class="question" data-aspect="Social">
 
                    Who do you want to mobilise (interested in volunteering), and from whom in such volunteering
 
                    positions would you want mobility-affiliated information?
 
  
                    <div class="answer">
+
            const dctResponse = await fetch(getQueryUrl(dctQuery)).then(response => response.json());
                        <div class="answer-wrapper">
 
                            <div class="choice guide" id="q5-guide">
 
                                <div class="button">Guidelines</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                            <div class="choice case" id="q5-case">
 
                                <div class="button">Use Cases</div>
 
                                <div class="desc">
 
                                    It provides helpful information from social media and crowdsourcing
 
                                    examples around the theme “Mobilising Volunteers”.
 
                                </div>
 
                            </div>
 
                            <div class="choice handbook" id="q5-handbook">
 
                                <div class="button">Citizens Handbook</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                            <div class="choice safe" id="q5-safe">
 
                                <div class="button">Feel Safe</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                        </div>
 
                    </div>
 
                </div>
 
                <div class="question" data-aspect="Socio-/Technical">
 
                    How can you mobilise the volunteers?
 
  
                    <div class="answer">
+
            const dctList = Object.keys(dctResponse.query.results).map(dctName => {
                        <div class="answer-wrapper">
+
                const dctResult = dctResponse.query.results[dctName];
                            <div class="choice tech" id="q6-tech">
 
                                <div class="button">Technologies</div>
 
                                <div class="desc">
 
                                    It allows filtering for software that covers the function Post &
 
                                    Schedule, which aims at publishing information on social media.
 
                                </div>
 
                            </div>
 
                            <div class="choice guide" id="q6-guide">
 
                                <div class="button">Guidelines</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                            <div class="choice case" id="q6-case">
 
                                <div class="button">Use Cases</div>
 
                                <div class="desc">
 
                                    It provides helpful information from social media and crowdsourcing
 
                                    examples around the theme “Mobilising Volunteers”.
 
                                </div>
 
                            </div>
 
                            <div class="choice safe" id="q6-safe">
 
                                <div class="button">Feel Safe</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                        </div>
 
                    </div>
 
                </div>
 
            </div>
 
        </div>
 
  
        <div class="theme">
+
                /** @type {DCT} */
            <h2>Improving Communication</h2>
+
                const dct = {};
            <div class="subtheme">
+
                dct.name = dctName;
                 <h3>Making Information Accessible</h3>
+
                dct.url = dctResult.fullurl;
                 <div class="question" data-aspect="Social">
+
                 dct.dataSources = dctResult.printouts[DATASRC_PROP].map(source => source.fulltext).sort();
                    Who do you want to access your information, and from whom do you want to access information?
+
                 dct.businessModel = dctResult.printouts[BUSINESS_PROP].map(bModel => bModel.fulltext);
 +
                dct.logo = dctResult.printouts[IMG_PROP][0] ? getFilePath(dctResult.printouts[IMG_PROP][0].fulltext) : undefined;
 +
                dct.usedByDmo = dctResult.printouts[DMO_PROP][0] ? dctResult.printouts[DMO_PROP][0].fulltext : 'Unknown';
  
                    <div class="answer">
+
                dct.functions = new Map();
                        <div class="answer-wrapper">
+
                functionsData.forEach((categoryData, funcCategory) => {
                            <div class="choice case" id="q7-case">
+
                    const confirmedFunctions = categoryData[FUNC_KEY]
                                <div class="button">Use Cases</div>
+
                        .filter(func => dctResult.printouts[func][0] && dctResult.printouts[func][0].fulltext.toLowerCase() === 'yes');
                                <div class="desc">
 
                                    It provides helpful information from social media and crowdsourcing
 
                                    examples around the theme “Making Information Accessible”.
 
                                </div>
 
                            </div>
 
                            <div class="choice handbook" id="q7-handbook">
 
                                <div class="button">Citizens Handbook</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                            <div class="choice safe" id="q7-safe">
 
                                <div class="button">Feel Safe</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                        </div>
 
                    </div>
 
                </div>
 
                <div class="question" data-aspect="Socio-/Technical">
 
                    How can you make your information accessible?
 
  
                     <div class="answer">
+
                     if (confirmedFunctions.length > 0) {
                         <div class="answer-wrapper">
+
                         dct.functions.set(funcCategory, { [DESC_KEY]: categoryData[DESC_KEY], [FUNC_KEY]: confirmedFunctions });
                            <div class="choice tech" id="q8-tech">
+
                     }
                                <div class="button">Technologies</div>
+
                 });
                                <div class="desc">
 
                                    It allows filtering for software that covers the function Post &
 
                                    Schedule, which aims at publishing information on social media.
 
                                </div>
 
                            </div>
 
                            <div class="choice case" id="q8-case">
 
                                <div class="button">Use Cases</div>
 
                                <div class="desc">
 
                                    It provides helpful information from social media and crowdsourcing
 
                                    examples around the theme “Making Information Accessible”.
 
                                </div>
 
                            </div>
 
                            <div class="choice handbook" id="q8-handbook">
 
                                <div class="button">Citizens Handbook</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                            <div class="choice safe" id="q8-safe">
 
                                <div class="button">Feel Safe</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                        </div>
 
                     </div>
 
                 </div>
 
            </div>
 
            <div class="subtheme">
 
                <h3>Targeting Communication</h3>
 
                <div class="question" data-aspect="Social">
 
                    Who do you want to target with your communication plan?
 
  
                    <div class="answer">
+
                 return dct;
                        <div class="answer-wrapper">
+
            });
                            <div class="choice case" id="q9-case">
 
                                <div class="button">Use Cases</div>
 
                                <div class="desc">
 
                                    It provides helpful information from social media and crowdsourcing
 
                                    examples around the theme “Targeting Communication”.
 
                                </div>
 
                            </div>
 
                            <div class="choice handbook" id="q9-handbook">
 
                                <div class="button">Citizens Handbook</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                            <div class="choice safe" id="q9-safe">
 
                                <div class="button">Feel Safe</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                        </div>
 
                    </div>
 
                </div>
 
                 <div class="question" data-aspect="Socio-/Technical">
 
                    How can you target your communication?
 
  
                    <div class="answer">
+
             return dctList;
                        <div class="answer-wrapper">
+
        }
                            <div class="choice tech" id="q10-tech">
 
                                <div class="button">Technologies</div>
 
                                <div class="desc">
 
                                    It allows filtering for software that covers the function Post &
 
                                    Schedule, which aims at publishing information on social media. It is also possible
 
                                    to filter by different platforms.
 
                                </div>
 
                            </div>
 
                            <div class="choice guide" id="q10-guide">
 
                                <div class="button">Guidelines</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                            <div class="choice case" id="q10-case">
 
                                <div class="button">Use Cases</div>
 
                                <div class="desc">
 
                                    It provides helpful information from social media and crowdsourcing
 
                                    examples around the theme “Targeting Communication”.
 
                                </div>
 
                            </div>
 
                            <div class="choice safe" id="q10-safe">
 
                                <div class="button">Feel Safe</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                        </div>
 
                    </div>
 
                </div>
 
            </div>
 
             <div class="subtheme">
 
                <h3>Ensuring Credible Information</h3>
 
                <div class="question" data-aspect="Social">
 
                    Who do you want to share credible information with, and from whom do you receive credible
 
                    information?
 
  
                    <div class="answer">
+
        /**
                        <div class="answer-wrapper">
+
        * @param {DCT} dct
                            <div class="choice case" id="q11-case">
+
        */
                                <div class="button">Use Cases</div>
+
        function dctFilter(dct, filterState) {
                                <div class="desc">
+
            // If filtering property is empty, don't apply the filter (set the check to true).
                                    It provides helpful information from social media and crowdsourcing
+
            // Passing an empty object (as with applyFilters(true)) should result in an unfiltered table.
                                    examples around the theme “Ensuring Credible Information”.
 
                                </div>
 
                            </div>
 
                            <div class="choice safe" id="q11-safe">
 
                                <div class="button">Feel Safe</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                        </div>
 
                    </div>
 
                </div>
 
                <div class="question" data-aspect="Socio-/Technical">
 
                    How can you ensure credible information exchange?
 
  
                    <div class="answer">
+
            let functionsCheck = true;
                        <div class="answer-wrapper">
+
            if (filterState.functions) {
                            <div class="choice tech" id="q12-tech">
+
                // If filterState has a category but subfunctions array is empty, we only care about the category.
                                <div class="button">Technologies</div>
+
                const emptyCategories = [], nonemptyCategories = [];
                                <div class="desc">
+
                Array.from(filterState.functions).forEach(([key, subs]) => {
                                    There are no mature technologies on the market yet that can examine
+
                    if (subs.length > 0) { nonemptyCategories.push(key); } else { emptyCategories.push(key); }
                                    information for credibility.
+
                });
                                </div>
+
               
                            </div>
+
                 // Empty categories should only be checked by their name, nonempty - ONLY by subfunctions.
                            <div class="choice guide" id="q12-guide">
+
                const checkEmpty = emptyCategories.some(cat => dct.functions.has(cat));
                                <div class="button">Guidelines</div>
+
                const checkNonempty = nonemptyCategories.some(cat => {
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
+
                    const selectedSubs = filterState.functions.get(cat);
                                    consectetur, adipisci velit...</div>
+
                    const dctCat = dct.functions.get(cat);
                            </div>
+
                    return dctCat && dctCat[FUNC_KEY] && dctCat[FUNC_KEY].some(sub => selectedSubs.includes(sub));
                            <div class="choice case" id="q12-case">
+
                });
                                <div class="button">Use Cases</div>
 
                                <div class="desc">
 
                                    It provides helpful information from social media and crowdsourcing
 
                                    examples around the theme “Ensuring Credible Information”.
 
                                </div>
 
                            </div>
 
                            <div class="choice safe" id="q12-safe">
 
                                <div class="button">Feel Safe</div>
 
                                <div class="desc">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
 
                                    consectetur, adipisci velit...</div>
 
                            </div>
 
                        </div>
 
                    </div>
 
                 </div>
 
            </div>
 
        </div>
 
    </div>
 
    <script>
 
        // Attach plus icon to the title of expandable blocks.
 
        document.querySelectorAll('.theme > h2, .subtheme > h3').forEach(el => {
 
            const icon = document.createElement('div');
 
            icon.classList.add('plus', 'icon');
 
            el.appendChild(icon);
 
        });
 
  
        // Set up toggles for expandable blocks.
+
                 functionsCheck = checkEmpty || checkNonempty;
        document.getElementById('cmp-container').addEventListener('click', event => {
 
            if (event.target.tagName === 'H2') {
 
                event.target.classList.toggle('opened');
 
                 event.target.closest('.theme').querySelectorAll('.subtheme').forEach(el => el.classList.toggle('opened'));
 
 
             }
 
             }
             if (event.target.tagName === 'H3') {
+
 
                 event.target.classList.toggle('opened');
+
            // const functionsCheck = filterState.functions
                 event.target.closest('.subtheme').querySelectorAll('.question').forEach(el => el.classList.toggle('opened'));
+
             //    ? dctFunctions.some(func => filterState.functions.includes(func))
 +
            //    : true;
 +
            const sourcesCheck = filterState.dataSources
 +
                ? dct.dataSources.some(source => filterState.dataSources.includes(source))
 +
                : true;
 +
            const businessModelCheck = filterState.businessModel
 +
                 ? dct.businessModel.some(bm => filterState.businessModel.includes(bm))
 +
                : true;
 +
            const dmUseCheck = filterState.usedByDmo
 +
                 ? filterState.usedByDmo.includes(dct.usedByDmo)
 +
                : true;
 +
            return sourcesCheck && functionsCheck && businessModelCheck && dmUseCheck;
 +
        }
 +
 
 +
        function applyFilters(clear) {
 +
            if (!table) return;
 +
 
 +
            // If clear=true, pass empty object to the filter to disable it.
 +
            if (clear) {
 +
                table.setFilter(dctFilter, {});
 +
                return;
 
             }
 
             }
             if (event.target.classList.contains('question')) {
+
 
                 event.target.querySelector('.answer')?.classList.toggle('opened');
+
            /** @type {Partial<Omit<DCT, 'usedByDmo'> & { usedByDmo: string[]>}} */
 +
            const filterState = {};
 +
 
 +
             if (
 +
                // Don't pass the filter on if everything is selected.
 +
                document.querySelectorAll('#functions-filter input[type="checkbox"]').length !==
 +
                document.querySelectorAll('#functions-filter input[type="checkbox"]:checked').length
 +
            ) {  
 +
                 const functionFilterBlocks = document.querySelectorAll('#functions-filter .func-filter-block');
 +
                const funcOpts = new Map();
 +
                functionFilterBlocks.forEach(block => {
 +
                    const cat = block.querySelector('input.func-cat');
 +
                    if (cat.checked) {
 +
                        funcOpts.set(
 +
                            cat.value,
 +
                            Array.from(block.querySelectorAll('.subfunc-filter-block input[type="checkbox"]:checked'))
 +
                                .map(box => box.value)
 +
                        );
 +
                    }
 +
                });
 +
                filterState.functions = funcOpts;
 +
 
 +
                // TEMPORARY! Restores original functionality. Delete after fixing the 'dataFiltered' hook.
 +
                // filterState.functions = Array.from(funcOpts).flat(2);
 
             }
 
             }
        });
 
  
        const search = 'Search and Monitor',
+
            const sourceOptions = Array.from(document.querySelectorAll('#data-source-filter input[type="checkbox"]'));
             post = 'Post and Schedule',
+
            const selectedSources = sourceOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
             analysis = 'Analysis',
+
            filterState.dataSources = selectedSources.length === sourceOptions.length ? undefined : selectedSources;
             metrics = 'Metrics',
+
 
             report = 'Report',
+
             const bmOptions = Array.from(document.querySelectorAll('#business-model-filter input[type="checkbox"]'));
             collab = 'Collaboration',
+
            const selectedBModels = bmOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
             interop = 'Interoperability',
+
            filterState.businessModel = selectedBModels.length === bmOptions.length ? undefined : selectedBModels;
            meta = 'Meta';
+
 
 +
             const dmUseOptions = Array.from(document.querySelectorAll('#dm-use-filter input[type="checkbox"]'));
 +
             const selectedDmUseOptions = dmUseOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
 +
             filterState.usedByDmo = selectedDmUseOptions.length === dmUseOptions.length ? undefined : selectedDmUseOptions;
 +
 
 +
            table.setFilter(dctFilter, filterState);
 +
        }
 +
 
 +
        // Load data and build page.
 +
        Promise.all([getSources(), getDcts()]).then(data => {
 +
             const [dataSources, dcts] = data;
 +
 
 +
            // Set up functions filter
 +
             let funcFilterHtml = '';
 +
            Array.from(functionsData).forEach(([fnCat, fnInfo], index) => {
 +
                const identifier = 'func-filter-' + escapeAttr(fnCat);
 +
                funcFilterHtml +=
 +
                    `<div class="func-filter-block">
 +
                        <div>
 +
                            <input type="checkbox" checked id="${identifier}" value="${fnCat}" class="func-cat">
 +
                            <label for="${identifier}"><img src="${fnImages[fnCat]}"> ${fnCat}</label>
 +
                        </div>`;
  
        // Click actions.
+
                // add subfunctions
        const actions = {
+
                if (index < 4) {
            'q2-tech': {
+
                    funcFilterHtml += '<div class="subfunc-filter-block">';
                filter: {
+
                     for (const func of fnInfo.functions) {
                     functions: {
+
                         const subfuncId = 'subfunc-filter-' + escapeAttr(func);
                         [search]: true,
+
                         funcFilterHtml +=
                         [analysis]: true,
+
                            `<div>
                        [post]: false,
+
                                <input type="checkbox" checked id="${subfuncId}" value="${func}">
                        [metrics]: false,
+
                                <label for="${subfuncId}">${func}</label>
                        [report]: false,
+
                            </div>`;
                        [collab]: false,
 
                        [interop]: false,
 
                        [meta]: false,
 
 
                     }
 
                     }
 +
                    funcFilterHtml += '</div>';
 +
                }
 +
                funcFilterHtml += '</div>';
 +
            });
 +
            document.getElementById('functions-filter').innerHTML = funcFilterHtml;
 +
 +
            // Set up sources filter
 +
            const groupedSources = [];
 +
            const sourcesCopy = Array.from(dataSources);
 +
            for (const layoutGroup of sourcesLayout) {
 +
                const group = [];
 +
                for (const source of layoutGroup.sources) {
 +
                    let idx = sourcesCopy.findIndex(src => src.name === source);
 +
                    if (idx !== -1) { group.push(sourcesCopy.splice(idx, 1)[0]); }
 
                 }
 
                 }
             },
+
                if (group.length > 0) { groupedSources.push({ title: layoutGroup.title, sources: group }); }
             'q4-tech': {
+
             }
                 filter: {
+
            groupedSources.push({ title: 'More platforms', sources: sourcesCopy });
                     functions: {
+
 
                         [search]: false,
+
             let dataSourceFilterHtml = '';
                         [analysis]: false,
+
            groupedSources.forEach(group => {
                         [post]: true,
+
                dataSourceFilterHtml += '<div class="filter-group-header">' + group.title + '</div>';
                         [metrics]: false,
+
                dataSourceFilterHtml += group.sources.reduce((acc, curr, idx) => {
                         [report]: false,
+
                    const identifier = escapeAttr(curr.name);
                         [collab]: false,
+
                    return acc +
                         [interop]: false,
+
                        '<div ' + (idx === 0 ? ' class="filter-group-start">' : '>') +
                         [meta]: false,
+
                        '<input type="checkbox" id="filter-' + identifier + '" value="' + curr.name + '" checked>' +
 +
                        '<label for="filter-' + identifier + '"><img src="' + curr.image + '"> ' + curr.name + '</label></div>'
 +
                }, '');
 +
            });
 +
            document.getElementById('data-source-filter').innerHTML = dataSourceFilterHtml;
 +
 
 +
            // TODO: Fetch from server?
 +
            const FREE_KEY = 'Freeware', FREE_PLAN_KEY = 'Free edition';
 +
            const bModels = [FREE_KEY, FREE_PLAN_KEY, 'Paid subscription', 'Other'];
 +
            let bModelFilterHtml = bModels.reduce((acc, curr) => {
 +
                 const identifier = escapeAttr(curr);
 +
                return acc
 +
                    + '<div><input type="checkbox" checked id="bm-filter-' + identifier
 +
                    + '" value="' + curr + '">'
 +
                    + '<label for="bm-filter-' + identifier + '">' + curr
 +
                    + '</label></div>'
 +
            }, '');
 +
            document.getElementById('business-model-filter').innerHTML = bModelFilterHtml;
 +
 
 +
            const dmUse = ['Yes', 'Yes with Use Case', 'Unknown'];
 +
            let dmUseFilterHtml = dmUse.reduce((acc, curr) => {
 +
                const identifier = escapeAttr(curr);
 +
                return acc
 +
                    + '<div><input type="checkbox" checked id="dm-use-filter-' + identifier
 +
                    + '" value="' + curr + '">'
 +
                    + '<label for="dm-use-filter-' + identifier + '">' + curr + '</label></div>'
 +
            }, '');
 +
            document.getElementById('dm-use-filter').innerHTML = dmUseFilterHtml;
 +
 
 +
            // Set up table.
 +
            const tabulator = new Tabulator("#dct-tabulator", {
 +
                layout: 'fitColumns',
 +
                responsiveLayout: 'collapse',
 +
                columns: [
 +
                    {
 +
                        title: 'Name',
 +
                        field: 'name',
 +
                        minWidth: 300, // required for responsiveness when using fitColumns
 +
                        formatter: function (cell) {
 +
                            /** @type {DCT} */
 +
                            const dct = cell.getData();
 +
                            let out = '<a href="' + dct.url + '">' + dct.name + '</a><br>';
 +
                            if (dct.businessModel.includes(FREE_KEY)) {
 +
                                out += '<small><span class="badge badge-success">' + FREE_KEY + '</span></small> ';
 +
                            }
 +
                            if (dct.businessModel.includes(FREE_PLAN_KEY)) {
 +
                                out += '<small><span class="badge badge-success">' + FREE_PLAN_KEY + '</span></small> ';
 +
                            }
 +
                            if (dct.usedByDmo.toLowerCase() === 'yes') {
 +
                                out += '<small><span class="badge badge-danger">Used by practitioners</span></small> ';
 +
                            }
 +
                            if (dct.usedByDmo.toLowerCase() === 'yes with use case') {
 +
                                out += '<small><span class="badge badge-danger">Used by practitioners</span></small>';
 +
                                out += ' <small><span class="badge badge-warning">Use case</span></small>'
 +
                            }
 +
                            return out;
 +
                        }
 +
                     },
 +
                    {
 +
                        title: 'Functions',
 +
                        field: 'functions',
 +
                        minWidth: 300, // required for responsiveness when using fitColumns
 +
                         cssClass: 'functions-cell',
 +
                         formatter: function (cell) {
 +
                            return Array.from(cell.getValue().keys())
 +
                                .map(fn => `<img class="func-img" src="${fnImages[fn]}" data-value="${fn}" alt="${fn}" title="${fn}">`)
 +
                                .join('');
 +
                        }
 +
                    },
 +
                    {
 +
                        title: 'Supported Platforms',
 +
                         field: 'dataSources',
 +
                         minWidth: 300, // required for responsiveness when using fitColumns
 +
                         cssClass: 'data-sources-cell',
 +
                         formatter: function (cell) {
 +
                            const val = cell.getValue();
 +
                            let out = '<div>';
 +
 
 +
                            groupedSources.forEach((group, gIndex) => {
 +
                                // if (gIndex === groupedSources.length - 1) { out += '<div class="sources-collapse">'; }
 +
                                out += group.sources.reduce((prev, curr) => {
 +
                                    const idx = val.findIndex(src => src === curr.name);
 +
                                    if (idx === -1) {
 +
                                        return prev;
 +
                                    } else {
 +
                                        return curr.image
 +
                                            ? prev + '<img class="data-source-img" data-value="' + curr.name
 +
                                            + '" src="' + curr.image
 +
                                            + '" alt="' + curr.name
 +
                                            + '" title="' + curr.name + '">'
 +
                                            : prev + ' ' + curr.name;
 +
                                    }
 +
                                }, '');
 +
                                if (gIndex === groupedSources.length - 1) {
 +
                                    // out += '<span class="sources-collapse-toggle"></span>';
 +
                                    // out += '</div>';
 +
                                }
 +
                            });
 +
                            return out + '</div>';
 +
                         }
 +
                    }
 +
                ]
 +
            });
 +
 
 +
            tabulator.on('tableBuilt', () => {
 +
                tabulator.setData(dcts);
 +
                table = tabulator;
 +
 
 +
                // Set up the table if parameter was passed.
 +
                const params = new URLSearchParams(window.location.search);
 +
                const encoded = params.get('do');
 +
 
 +
                if (encoded) {
 +
                    const action = JSON.parse(decodeURIComponent(atob(encoded)));
 +
 
 +
                    const filter = action.filter;
 +
                    if (filter) {
 +
                         // Functions filter
 +
                        const functions = filter.functions;
 +
                        if (functions) {
 +
                            Object.keys(functions).forEach(fnCat => {
 +
                                document.getElementById('func-filter-' + escapeAttr(fnCat))
 +
                                    .closest('.func-filter-block')
 +
                                    .querySelectorAll('input[type="checkbox"]').forEach(box => box.checked = functions[fnCat]);
 +
                            });
 +
                        }
 +
 
 +
                        // Further filters
 +
                        // ...
 +
 
 +
                        applyFilters();
 
                     }
 
                     }
 +
 +
                    // Further actions (e.g. open filter panel, etc.)
 +
                    // ...
 
                 }
 
                 }
             },
+
             });
            'q6-tech': {
+
 
                 filter: {
+
            tabulator.on('dataFiltered', (filters, rows) => {
                     functions: {
+
                const summary = document.getElementById('filter-summary');
                         [search]: false,
+
                const filter = filters[0];
                         [analysis]: false,
+
 
                        [post]: true,
+
                // Set result counter
                         [metrics]: false,
+
                document.getElementById('result-count').textContent = rows.length;
                         [report]: false,
+
               
                         [collab]: false,
+
                // Exit if filter object/type doesn't exist (happens after Tabulator's own filter reset).
                         [interop]: false,
+
                if (!(filter && filter.type)) { summary.textContent = 'No filter. Showing all results.'; return; }
                         [meta]: false,
+
 
 +
                 // Update filter text.
 +
                if (
 +
                    !filter.type.functions &&
 +
                    !filter.type.dataSources &&
 +
                    !filter.type.businessModel &&
 +
                    !filter.type.usedByDmo
 +
                ) { summary.textContent = 'No filter. Showing all results.'; }
 +
                else {
 +
                     let summaryHtml = '<table>';
 +
                    if (filter.type.functions) {
 +
                         summaryHtml += '<tr><td><strong>Functions</strong></td><td>';
 +
                        if (filter.type.functions.size === 0) {
 +
                            summaryHtml += 'none';
 +
                         } else {
 +
                            for (const [cat, subs] of filter.type.functions) {
 +
                                summaryHtml += cat;
 +
                                summaryHtml += subs.length > 0 ? ' <small>(' + subs.join(', ') + ')</small>' : '';
 +
                                summaryHtml += ', ';
 +
                            }
 +
                            summaryHtml = summaryHtml.substring(0, summaryHtml.length - 2);
 +
                         }
 +
                         summaryHtml  += '</td></tr>';
 +
                    }
 +
                    if (filter.type.dataSources) {
 +
                         summaryHtml += '<tr><td><strong>Platforms</strong></td><td>'
 +
                            + (filter.type.dataSources.length > 0 ? filter.type.dataSources.join(', ') : 'none')
 +
                            + '</td></tr>';
 +
                    }
 +
                    if (filter.type.businessModel) {
 +
                         summaryHtml += '<tr><td><strong>License model</strong></td><td>'
 +
                            + (filter.type.businessModel.length > 0 ? filter.type.businessModel.join(', ') : 'none')
 +
                            + '</td></tr>';
 +
                    }
 +
                    if (filter.type.usedByDmo) {
 +
                         summaryHtml += '<tr><td><strong>Used by practitioners</strong></td><td>'
 +
                            + (filter.type.usedByDmo.length > 0 ? filter.type.usedByDmo.join(', ') : 'none')
 +
                            + '</td></tr>';
 
                     }
 
                     }
 +
                    summaryHtml += '</table>';
 +
                    summary.innerHTML = summaryHtml;
 +
                }
 +
 +
                const markImages = () => {
 +
                    const selectedSources = filter.type.dataSources;
 +
                    const selectedFunctions = Array.from(filter.type.functions.keys());
 +
 +
                    // Mark data source images
 +
                    document.querySelectorAll('.data-sources-cell .data-source-img, .tabulator-responsive-collapse .data-source-img')
 +
                        .forEach(img => {
 +
                            if (!selectedSources || selectedSources.includes(img.dataset.value)) { img.classList.remove('unselected'); }
 +
                            else { img.classList.add('unselected'); }
 +
                        });
 +
 +
                    // Mark functions images
 +
                    document.querySelectorAll('.functions-cell .func-img').forEach(img => {
 +
                        if (!selectedFunctions || selectedFunctions.includes(img.dataset.value)) { img.classList.remove('unselected'); }
 +
                        else { img.classList.add('unselected'); }
 +
                    });
 +
 +
                    tabulator.off('renderComplete', markImages);
 
                 }
 
                 }
             },
+
                tabulator.on('renderComplete', markImages); // TODO: Prevent this from running if corresponding filters are not active.
             'q8-tech': {
+
             });
                 filter: {
+
 
                    functions: {
+
            // Listen for changes in filter checkbox state.
                        [search]: false,
+
             document.getElementById('functions-filter').addEventListener('change', event => {
                        [analysis]: false,
+
                 const filterBlock = event.target.closest('.func-filter-block');
                        [post]: true,
+
                const category = filterBlock.querySelector('input.func-cat');
                        [metrics]: false,
+
                const subfunctions = filterBlock.querySelectorAll('.subfunc-filter-block input[type="checkbox"]');
                        [report]: false,
+
 
                        [collab]: false,
+
                if (event.target === category) {
                        [interop]: false,
+
                    // Selecting/deselecting the category checks/unchecks all subfunctions.
                        [meta]: false,
+
                    subfunctions.forEach(checkbox => checkbox.checked = category.checked);
                     }
+
                } else {
 +
                    // If no subfunctions are selected, deactivate the category. Activate otherwise.
 +
                    const checkedSubs = Array.from(subfunctions).filter(sub => sub.checked).length;
 +
                     if (checkedSubs > 0) { category.checked = true; } else { category.checked = false; }
 
                 }
 
                 }
             },
+
 
             'q10-tech': {
+
                applyFilters();
                 filter: {
+
             }, { passive: true });
                    functions: {
+
             document.getElementById('data-source-filter').addEventListener('change', event => {
                        [search]: false,
+
                applyFilters();
                        [analysis]: false,
+
            }, { passive: true });
                        [post]: true,
+
            document.getElementById('business-model-filter').addEventListener('change', event => {
                        [metrics]: false,
+
                 applyFilters();
                         [report]: false,
+
            }, { passive: true });
                         [collab]: false,
+
            document.getElementById('dm-use-filter').addEventListener('change', event => {
                        [interop]: false,
+
                applyFilters();
                         [meta]: false,
+
            }, { passive: true });
 +
 
 +
            // Listen for clicks on filter toggles
 +
            document.querySelectorAll('.filter-wrapper .filter-toggle').forEach(el => {
 +
                const wrapper = el.closest('.filter-wrapper');
 +
                el.addEventListener('click', event => void wrapper.classList.toggle('open'));
 +
            });
 +
 
 +
            // Fix bug where the table is truncated to zero height despite having visible rows.
 +
            tabulator.on('renderComplete', function() {
 +
                // TODO: Check the bugfix for a possible infinite event loop.
 +
                // This will help detect it, in case it happens.
 +
                // console.log('Table height bugfix: render complete.');
 +
               
 +
                try {
 +
                    const holderHeight = tabulator.rowManager.element.offsetHeight;
 +
                    const tableHeight = tabulator.rowManager.tableElement.offsetHeight;
 +
                    if (
 +
                         holderHeight < tableHeight ||                          // table is truncated vertically (including zero-height)
 +
                         holderHeight - tableHeight > window.screen.availHeight  // table is more than a screen longer than content
 +
                    ) {
 +
                         tabulator.redraw();
 
                     }
 
                     }
                 }
+
                 } catch (ignore) { }
             }
+
             });
         };
+
            // End bugfix
 +
 
 +
         });
  
         const handler = event => {
+
         function selectAll(context) {
             const answerId = event.currentTarget.id;
+
             document.querySelectorAll(context + ' input[type="checkbox"]').forEach(checkbox => checkbox.checked = true);
             const act = actions[answerId];
+
             applyFilters();
 +
        }
  
             if (!actions) return;
+
        function deselectAll(context) {
 +
            document.querySelectorAll(context + ' input[type="checkbox"]').forEach(checkbox => checkbox.checked = false);
 +
             applyFilters();
 +
        }
  
             if (answerId.indexOf('tech') !== -1) {
+
        function clearFilters() {
                // Action takes us to Tech Library
+
             document.querySelectorAll('#dct-filters input[type="checkbox').forEach(checkbox => checkbox.checked = checkbox.defaultChecked);
                const enc = btoa(encodeURIComponent(JSON.stringify(act)));
+
            applyFilters(true);
                window.location.assign('/index.php/List_of_Disaster_Community_Technologies?do=' + enc);
+
        }
            }
 
  
             if (answerId.indexOf('safe') !== -1) {
+
        function toggleFilter() {
                // Action takes us to Feel Safe
+
             document.getElementById('dct-filters').classList.toggle('open');
                window.location.assign('/index.php/Feel_Safe');
 
            }
 
 
         }
 
         }
  
         document.querySelectorAll('.choice').forEach(el => el.addEventListener('click', handler, { passive: true }));
+
        // Close filter pane when clicked outside of it.
 +
         document.body.addEventListener('click', event => {
 +
            const filterPane = document.getElementById('dct-filters');
 +
            if (
 +
                filterPane.classList.contains('open') &&
 +
                !filterPane.contains(event.target) &&
 +
                event.target !== document.querySelector('#filter-bar .large-button')
 +
            ) { filterPane.classList.remove('open'); }
 +
        }, { passive: true });
 +
    </script>
 +
 
 +
    <!-- Icon definitons -->
 +
    <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" overflow="hidden" style="display:none;">
 +
        <defs>
 +
            <symbol id="chevron-down" viewBox="0 0 96 96">
 +
                <clipPath id="chev">
 +
                    <path d="M592 312h96v96h-96z" />
 +
                </clipPath>
 +
                <g clip-path="url(#chev)" transform="translate(-592 -312)">
 +
                    <path d="m640 370.586-25.293-25.293-1.414 1.414L640 373.414l26.707-26.707-1.414-1.414L640 370.586Z" />
 +
                </g>
 +
            </symbol>
 +
        </defs>
 +
    </svg>
 +
 
 +
    <div id="dct-list-wrapper">
 +
        <h1>
 +
            <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" overflow="hidden" viewBox="0 0 96 96">
 +
                <defs>
 +
                    <clipPath id="a">
 +
                        <path d="M65 334h96v96H65z" />
 +
                    </clipPath>
 +
                </defs>
 +
                <g clip-path="url(#a)" transform="translate(-65 -334)">
 +
                    <path d="m142 395.981.004-35.993H84.001v36.01Zm-55.999-33.993h54.003L140 393.981l-53.999.017Z" />
 +
                    <path
 +
                        d="M81.001 358.987a2.002 2.002 0 0 1 2-2h60.003a2.002 2.002 0 0 1 2 2V400h2v-41.013a4.003 4.003 0 0 0-4-4H83.001a4.003 4.003 0 0 0-4 4V400h2ZM118.003 402.981v2h-10.001v-2H67v1.999a5.006 5.006 0 0 0 5 5.001h82.004a5.006 5.006 0 0 0 5.001-5.001v-1.999Zm36.001 5H72a3.004 3.004 0 0 1-3-3h37.002a1.934 1.934 0 0 0 2 2h10.001a1.934 1.934 0 0 0 2-2h37.002a3.005 3.005 0 0 1-3.001 3Z" />
 +
                    <path
 +
                        d="M113 365c-7.18 0-13 5.82-13 13s5.82 13 13 13 13-5.82 13-13c-.008-7.176-5.824-12.992-13-13Zm10.949 12h-3.518a14.167 14.167 0 0 0-4.176-9.508 11.023 11.023 0 0 1 7.694 9.508ZM112 368.226V377h-4.426c.254-3.771 1.929-7.06 4.426-8.774ZM112 379v8.775c-2.494-1.717-4.17-5.017-4.425-8.775Zm2 8.774V379h4.425c-.255 3.754-1.932 7.056-4.425 8.774ZM114 377v-8.773c2.492 1.718 4.17 5.019 4.425 8.773Zm-4.273-9.502a14.124 14.124 0 0 0-4.158 9.502h-3.518a11.02 11.02 0 0 1 7.676-9.502ZM102.051 379h3.518a14.157 14.157 0 0 0 4.173 9.507 11.022 11.022 0 0 1-7.691-9.507Zm14.205 9.508a14.168 14.168 0 0 0 4.175-9.508h3.518a11.023 11.023 0 0 1-7.693 9.508Z" />
 +
                </g>
 +
            </svg>
 +
            <div>
 +
                <div>Technologies</div>
 +
                <div style="font-size:small; letter-spacing:.03em; margin-left: .6em;">Social Media and Crowdsourcing Library</div>
 +
            </div>
 +
        </h1>
 +
        <div id="dct-intro">
 +
 
 +
            <p>This page provides an&nbsp;overview of&nbsp;various Technologies related to Social Media and
 +
                Crowdsourcing. You can use the&nbsp;filters to&nbsp;identify
 +
                relevant technologies according to your needs and then click on the name of a&nbsp;tool to&nbsp;get
 +
                further information.</p>
 +
        </div>
 +
 
 +
        <div id="filter-bar">
 +
            <div style="display: flex; justify-content: space-between;">
 +
                <div style="flex: 1 1;">
 +
                    <h2 style="margin-bottom: 1rem;">Applied Filters</h2>
 +
                    <div id="filter-summary">No filter. Showing all results.</div>
 +
                </div>
 +
                <div style="flex: 0 0;">
 +
                    <button class="large-button" type="button" onclick="toggleFilter()">Filters</button>
 +
                </div>
 +
            </div>
 +
 
 +
            <h2 style="margin-top: 2.5rem; margin-bottom: 0;">Results: <span id="result-count"></span></h2>
 
          
 
          
     </script>
+
            <div id="dct-filters">
 +
                <h2 style="display: flex; justify-content: space-between;">
 +
                    <div>
 +
                        <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" overflow="hidden" viewBox="0 0 96 96">
 +
                            <defs>
 +
                                <clipPath id="b">
 +
                                    <path d="M592 312h96v96h-96z" />
 +
                                </clipPath>
 +
                            </defs>
 +
                            <g clip-path="url(#b)" transform="translate(-592 -312)">
 +
                                <path
 +
                                d="M636 356.012v38.011l8-8v-30.011L674 326h-68Zm6.588-1.412-.588.584v30.008l-4 4v-34.008l-.585-.586L610.828 328h58.348Z" />
 +
                            </g>
 +
                        </svg>
 +
                        <span>Filters</span>
 +
                    </div>
 +
                    <a onclick="toggleFilter()" id="close-filter-button">&times;</a>
 +
                </h2>
 +
                <div style="text-align: center;">
 +
                    <button class="large-button" type="button" onclick="clearFilters()">Clear Filters</button>
 +
                </div>
 +
                <div class="filter-wrapper">
 +
                    <h4>Functions <span class="filter-toggle"><svg><use href="#chevron-down"/></svg></span></h4>
 +
                    <div class="filter-container">
 +
                        <div class="filter-button-wrapper">
 +
                            <button type="button" onclick="selectAll('#functions-filter')">Select all</button> |
 +
                            <button type="button" onclick="deselectAll('#functions-filter')">Clear all</button>
 +
                        </div>
 +
                        <div class="filter-content" id="functions-filter"></div>
 +
                    </div>
 +
                </div>
 +
                <div class="filter-wrapper">
 +
                    <h4>Supported Platforms <span class="filter-toggle"><svg><use href="#chevron-down"/></svg></span></h4>
 +
                    <div class="filter-container">
 +
                        <div class="filter-button-wrapper">
 +
                            <button type="button" onclick="selectAll('#data-source-filter')">Select all</button> |
 +
                            <button type="button" onclick="deselectAll('#data-source-filter')">Clear all</button>
 +
                        </div>
 +
                        <div class="filter-content" id="data-source-filter"></div>
 +
                    </div>
 +
                </div>
 +
                <div class="filter-wrapper">
 +
                    <h4>License Model <span class="filter-toggle"><svg><use href="#chevron-down"/></svg></span></h4>
 +
                    <div class="filter-container">
 +
                        <div class="filter-button-wrapper">
 +
                            <button type="button" onclick="selectAll('#business-model-filter')">Select all</button> |
 +
                            <button type="button" onclick="deselectAll('#business-model-filter')">Clear all</button>
 +
                        </div>
 +
                        <div class="filter-content" id="business-model-filter"></div>
 +
                    </div>
 +
                </div>
 +
                <div class="filter-wrapper">
 +
                    <h4>Used by Practitioners <span class="filter-toggle"><svg><use href="#chevron-down"/></svg></span></h4>
 +
                    <div class="filter-container">
 +
                        <div class="filter-button-wrapper">
 +
                            <button type="button" onclick="selectAll('#dm-use-filter')">Select all</button> |
 +
                            <button type="button" onclick="deselectAll('#dm-use-filter')">Clear all</button>
 +
                        </div>
 +
                        <div class="filter-content" id="dm-use-filter"></div>
 +
                    </div>
 +
                </div>
 +
            </div>
 +
        </div>
 +
        <div id="dct-tabulator"></div>
 +
     </div>
 
</includeonly>
 
</includeonly>

Revision as of 16:03, 24 November 2022

Development verstion of the DCT List.
Not ready for production!