Module:Library/Testing
From Comprehensible Input Wiki
Documentation for this module may be created at Module:Library/Testing/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 = {title, channel, id, service, index, difficulty, difficulty_ordered},
format = 'JSON'
}
local h = mw.ext.externaldata.getWebData {
url = tostring(mw.uri.fullUrl( 'Data:Mandarin Chinese/Videos' )) .. '?action=raw',
format = 'CSV with header'
}
tableOut = '<table id="library2"><tr id="lib-header"><th>Video</th><th>Title</th><th>Difficulty</th><th>Channel</th><th style="display:none"></th></tr>'
for key, value in ipairs(g) do
tableOut = tableOut .. '<tr data-index="' .. value['index'] .. '"><td><div class="spacer" style="width:320px;height:180px;border:solid"><div class="outsideEmbed" style="display:none"> ' .. mw.getCurrentFrame():callParserFunction( '#ev', 'youtube', value['id']) .. '</div></div></td><td>' .. value['title'] .. '</td><td>' .. value['difficulty'] .. '</td><td>' .. value['channel'] .. '</td><td class="lib-diffic-num" style="display:none">' .. value['difficulty_ordered'] .. '</td></tr>'
end
tableOut = tableOut .. '</table>'
return tableOut
else
return 'No language selected.'
end
end
p.showLibrary = function(frame)
return createTable(frame:getParent().args)
end
return p