Module:Library
From Comprehensible Input Wiki
Documentation for this module may be created at Module:Library/doc
local p = {}
function createTable(lang)
if lang[1] then
local g = mw.ext.externaldata.getWebData {
url = 'https://comprehensibleinputwiki.com/sqltest.php?language=' .. lang[1],
data = {level, title, channel, id, service, index},
format = 'JSON'
}
local h = mw.ext.externaldata.getWebData {
url = tostring(mw.uri.fullUrl( 'Data:Mandarin Chinese/Videos' )) .. '?action=raw',
format = 'CSV with header'
}
tableOut = '{| class="wikitable sortable" id="library"\n! Video\n! Title\n! Level\n! Channel\n! Copy to Personal Library\n! Delete\n! class="hi" style="display:none"|f\n'
for key, value in ipairs(g) do
tableOut = tableOut .. '|- data-videoid="' .. value['id'] .. '" data-index="' .. value['index'] .. '"\n| ' .. mw.getCurrentFrame():callParserFunction( '#ev', 'youtube', value['id']) .. '\n| class="title"|' .. value['title'] .. '\n| ' .. value['level'] .. '\n| ' .. value['channel'] .. '\n| <div class="copy">Copy</div>\n| <div class="delete">Delete</div>\n| class="testing" style="display:none"|' .. math.random(500) .. '\n'
end
tableOut = tableOut .. '|}'
return tableOut
else
return 'No language selected.'
end
end
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '\n['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
p.showLibrary = function(frame)
return createTable(frame:getParent().args)
end
return p