Module:Sandbox/Aaron Liu/Module:Wikipedia ads/data

-- This module transforms Module:Wikipedia ads/list into a format to be -- used by mw.loadData.

local LIST_MODULE = 'Module:Wikipedia ads/list' local skippedEntries = { {		id = 174, image = "Qxz-ad174.svg", link = "Template:Wikipedia ads", author = "Koavf (after Dromioofephesus)" },	{		id = 175, image = "Qxz-ad175.gif", link = "Template:Wikipedia ads", author = "MMXX" }, }

local list = require(LIST_MODULE) local ids = {} local id = 0 for i, t in ipairs(list) do	assert(t.id, string.format( "no 'id' field in table %d in %s", i, LIST_MODULE ))	if id + 1 < t.id then for id = id + 1, t.id - 1, 1 do -- Insert skipped entries for missing IDs skippedEntries[id % 2 + 1].id = id			ids[id] = skippedEntries[id % 2 + 1] table.insert(list, skippedEntries[id % 2 + 1]) end end id = t.id	ids[t.id] = t end

return { list = list, ids = ids, noAds = #list }