Widget: DCTList: Difference between revisions

From LINKS Community Center
Jump to: navigation, search
Eschmidt (talk | contribs)
No edit summary
Marterer (talk | contribs)
No edit summary
(653 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<noinclude>Development verstion of the DCT List.<br><span style="color: red; font-weight: bold;">Not ready for production!</span></noinclude>
<noinclude>DCT list widget.<br><span style="color: red; font-weight: bold;">Currently in use &ndash; do not modify!</span></noinclude>
 
<includeonly>
<includeonly>
     <script>
     <link href="/resources/assets/tabulator/dist/css/tabulator.min.css" rel="stylesheet">
        async function getImages(imageTitles) {
    <script type="text/javascript" src="/resources/assets/tabulator/dist/js/tabulator.min.js"></script>
            const imageUrlQuery = '/api.php?action=query&format=json&prop=imageinfo&iiprop=url&titles=' + encodeURIComponent(imageTitles.join('|'));
            const imageUrlResponse = await fetch(imageUrlQuery).then(response => response.json());
            return Object.getOwnPropertyNames(imageUrlResponse.query.pages).map(page => ({
                title: imageUrlResponse.query.pages[pageId].title,
                url: imageUrlResponse.query.pages[pageId].imageinfo[0].url
            }));
        }
 
        async function getSources() {
            const sourceQuery = '/api.php?action=ask&format=json&query=' + encodeURIComponent('[[Category:Social media platform]]|?IMAGE');
            const sourceResponse = await fetch(sourceQuery).then(response => response.json());
 
            const sources = Object.getOwnPropertyNames(sourceResponse.query.results).map(platformName => ({
                name: platformName,
                image: sourceResponse.query.results[platformName].printouts.IMAGE[0].fulltext.replace('PAGENAME:', '')
            }));


            var images = await getImages(sources.map(source => source.image));
    <!-- STYLES BEGIN -->
            console.log('img', images)
<link rel="stylesheet" href="https://www.safetyinnovation.center/lcc/dct_list/styles.css">
<!-- STYLES END -->


            const logoUrlQuery = '/api.php?action=query&format=json&prop=imageinfo&iiprop=url&titles=' +
    <!-- SCRIPT BEGIN -->
                                  encodeURIComponent(sources.map(source => source.image).join('|'));
    <script type="text/javascript" src="https://www.safetyinnovation.center/lcc/dct_list/script.js"></script>
            const logoUrlResponse = await fetch(logoUrlQuery).then(response => response.json());
    <!-- SCRIPT END -->


            console.log(logoUrlResponse)
    <!-- Icon definitons -->
    <img src="https://www.safetyinnovation.center/lcc/dct_list/img/unknown.svg">


             Object.getOwnPropertyNames(logoUrlResponse.query.pages).forEach(pageId => {
    <div id="dct-list-wrapper">
                 const logoFileName = logoUrlResponse.query.pages[pageId].title;
        <h1>
                 const logoUrl = logoUrlResponse.query.pages[pageId].imageinfo[0].url;
             <img src="https://www.safetyinnovation.center/lcc/dct_list/img/1-dct.svg">
                 sources[sources.findIndex(source => source.image === logoFileName)].image = logoUrl;
            <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>The overall goal of the Social Media and Crowdsourcing (SMCS) Technologies Library is to face the growing
                 heterogeneous use of technologies in disasters and the overwhelming number of technologies on the
                market. It gathers and structures information about existing technologies to provide an up-to-date overview and
                 thus support the selection of suitable technologies.
            </p>
            <p>
                You can use the filters to identify relevant technologies according to your needs and then click on the
                name of the technology to get further information.
             </p>
        </div>


             console.log(sources)
        <div id="filter-bar">
             <div style="display: flex; justify-content: space-between;">
                <div style="flex: 1 1;">
                    <h2 style="margin-bottom: 1rem;">Selected Filters</h2>
                    <div id="filter-summary">No filter. Showing all results.</div>
                </div>
                <div>
                    <button class="large-button open-filters" type="button" onclick="toggleFilter()">Open Filters</button>
                </div>
            </div>


             return sources;
             <div style="display: flex; justify-content: space-between; align-items: center; margin-top: 2.5rem;">
        }
                <h2 style="margin-bottom: 0;">Results: <span id="result-count"></span></h2>
                <div><a href="/index.php/Form:Disaster_Community_Technology" style="color: var(--links-blue); font-size: 1.5em; font-variant:small-caps">Add new technology</a></div>
            </div>


        async function getDcts() {
            <div id="dct-filters">
            const dctQuery = '[[Category:Disaster Community Technology]]' +
                <h2 style="display: flex; justify-content: space-between;">
                            '|?Image' +
                    <div>
                            '|?Data Sources';
                        <img src="filters.svg">
            const dctQueryUrl = '/api.php?action=ask&format=json&query=' + encodeURIComponent(dctQuery);
                        <span>Filters</span>
            const dctResponse = await fetch(dctQueryUrl).then(response => response.json());
                    </div>
             console.log(dctResponse);
                    <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 class="filter-toggle">Functions <div class="plus icon"></div>
                    </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 loose" id="functions-filter"></div>
                    </div>
                </div>
                <div class="filter-wrapper">
                    <h4 class="filter-toggle">Supported Platforms <div class="plus icon"></div>
                    </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 loose" id="data-source-filter"></div>
                    </div>
                </div>
                <div class="filter-wrapper">
                    <h4 class="filter-toggle">Pricing <div class="plus icon"></div>
                    </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 class="filter-toggle">Used by Practitioners <div class="plus icon"></div>
                    </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 id="bool-filters"
                    style="border-top: 1px solid var(--links-blue); margin-top: 1em; padding-top: 1em;">
                    <div>
                        <input type="checkbox" id="used-by-practitioners" value="yes">
                        <label for="used-by-practitioners">Used by practitioners</label>
                    </div>
                    <div>
                        <input type="checkbox" id="has-use-case" value="yes">
                        <label for="has-use-case">Use case available</label>
                    </div>
                    <div>
                        <input type="checkbox" id="show-archived" value="yes">
                        <label for="show-archived">Show archived</label>
                    </div>
                </div>
             </div>
        </div>
         <div id="dct-tabulator"></div>
    </div>


        getSources();
        getDcts();
    </script>
</includeonly>
</includeonly>

Revision as of 22:22, 10 May 2024

DCT list widget.
Currently in use – do not modify!