Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Xinbenlv/WikiLoop
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
---------- Module:WikiLoop ---------------- local p = {} local supported_languages = {'ru', 'fr', 'en'} -- Returns the conflict table local function parseConflictValueObject(frame) local qid = frame.args.qid -- Qnum id local conflict_value_object = {} -- out = '' for i, lang in ipairs(supported_languages) do local prefix = "lang_" .. lang if frame.args["lang_" .. lang] ~= nil then local site_link = mw.wikibase.getSitelink(qid, lang.."wiki") local value = frame.args[prefix] conflict_value_object[lang] = { ["value"] = value, ["site_link"] = site_link } end end return conflict_value_object end local function conflictValueObjectToTableData(conflict_value_object) local headers = {"language", "title", "value"} local rows = {} for lang, value_pair in pairs(conflict_value_object) do table.insert(rows ,{ lang, -- language "[[:"..lang..":"..value_pair.site_link.."]]", -- link to value value_pair.value }) end return {headers, rows} end local function printTableHtml(table_data) local column_headers = table_data[1] local rows = table_data[2] local output = "<table class=\"wikitable\">\n" output = output .. " <tr>\n" for i, th in ipairs(column_headers) do output = output .. " <th>" .. th .. "</th>\n" end output = output .. " </tr>\n" for row_i, row in ipairs(rows) do output = output .. " <tr>\n" for col_i, col in ipairs(row) do output = output .. " <td>" .. col .. "</td>\n" end output = output .. " </tr>\n" end output = output .. "</table>\n" return output end function p.PrintConflictTable(frame) conflict_value_object = parseConflictValueObject(frame) table_data = conflictValueObjectToTableData(conflict_value_object) return printTableHtml(table_data) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Module:Sandbox/Xinbenlv/WikiLoop
(
edit
)
Module:Sandbox/Xinbenlv/WikiLoop/doc
(
edit
)