Module:Library Listing: Difference between revisions

From Comprehensible Input Wiki
Content added Content deleted
(Created page with "local p = {} function createTable() local g = mw.ext.externaldata.getWebData { url = 'https://comprehensibleinputwiki.com/api.php?count=true', data = {language, count}, format = 'JSON' } tableOut = '<table id="library-listing"><tr id="lib-header"><th>Language</th><th>Video Count</th></tr>' for key, value in ipairs(g) do tableOut = tableOut .. '<tr><td>[[' .. value['language'] .. '/Library ' .. value['language'] .. ']]</...")
 
No edit summary
Tag: Manual revert
 
(4 intermediate revisions by the same user not shown)
Line 9: Line 9:
}
}


tableOut = '<table id="library-listing"><tr id="lib-header"><th>Language</th><th>Video Count</th></tr>'
tableOut = '<table id="library-listing" class="wikitable" style="margin-left:auto;margin-right:auto"><tr id="lib-header"><th>Language</th><th>Video Count</th></tr>'


for key, value in ipairs(g) do
for key, value in ipairs(g) do
tableOut = tableOut .. '<tr><td>[[' .. value['language'] .. '/Library ' .. value['language'] .. ']]</td><td>' .. value['count'] .. '</td></tr>'
tableOut = tableOut .. '<tr><td>[[' .. value['language'] .. '/Library|' .. value['language'] .. ']]</td><td>' .. value['count'] .. '</td></tr>'
end
end


Line 23: Line 23:




p.showLibrary = function()
p.showList = function()
return createTable()
return createTable()
end
end

Latest revision as of 22:35, 16 March 2023

Documentation for this module may be created at Module:Library Listing/doc

local p = {}

function createTable()

    local g = mw.ext.externaldata.getWebData {
        url = 'https://comprehensibleinputwiki.com/api.php?count=true',
        data = {language, count},
        format = 'JSON'
    }

    tableOut = '<table id="library-listing" class="wikitable" style="margin-left:auto;margin-right:auto"><tr id="lib-header"><th>Language</th><th>Video Count</th></tr>'

    for key, value in ipairs(g) do
        tableOut = tableOut .. '<tr><td>[[' .. value['language'] .. '/Library|' .. value['language'] .. ']]</td><td>' .. value['count'] .. '</td></tr>'
    end

    tableOut = tableOut .. '</table>'

    return tableOut

end



p.showList = function()
	return createTable()
end


return p