Module:ProfessionList: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(Created page with "local currency = require('Module:Currency') local p = {} -- this module provides functions that are commonly used among all of the modules to greate tables of profession activities -- such as AlchemistList, DetectivePassiveList, BlacksmithSmeltingList, and so on -- creates the html directly for a currency cell of a table -- will always be 10 cells wide, for currency alignment -- if not supplied with an amount, displays "unknown" -- use within :node() function p.curren...")
 
No edit summary
Line 24: Line 24:
-- creates the html for an unknown value cell
-- creates the html for an unknown value cell
-- use within :node()
-- use within :node()
function p.unknown_value_cell()
function p.unknown_value_cell(N)
return mw.html.create('td')
return mw.html.create('td')
:addClass('table-bg-gray')
:addClass('table-bg-gray')
:css{ ['text-align'] = 'center' }
:css{ ['text-align'] = 'center' }
:attr{ colspan = tostring(N) }
:wikitext("''unknown''")
:wikitext("''unknown''")
:done()
:done()
Line 33: Line 34:


-- creates the html for an unknown value cell, with a link to edit the page that has the unknown parameter
-- creates the html for an unknown value cell, with a link to edit the page that has the unknown parameter
-- NOT YET FUNCTIONAL
-- use within :node()
-- use within :node()
function p.unkown_value_edit_cell(page)
function p.unknown_value_edit_cell(page,N)
local url = tostring(mw.uri.fullUrl(page,'action=edit'))
return mw.html.create('td')
return mw.html.create('td')
:addClass('table-bg-gray')
:addClass('table-bg-gray')
:css{ ['text-align'] = 'center' }
:css{ ['text-align'] = 'center' }
:attr{ colspan = tostring(N) }
:wikitext("''unknown''")
:wikitext('['..url.." ''unknown'' (edit)]")
:done()
:done()
end
end
Line 51: Line 53:
local query = {
local query = {
queryString,
queryString,
'? #- = page',
'? #- = pageName',
'?Image #- = pageImage',
'?Image #- = pageImage',
'?Activity JSON = activityJSON',
'?Activity JSON = activityJSON',
Line 63: Line 65:
return nil
return nil
end
end

-- output structure
-- output structure
local output = {}
local output = {}
Line 77: Line 79:
else
else
for _, json in page.activityJSON do
for _, json in page.activityJSON do
json.type = 'activity'
table.insert(JSONs,json)
table.insert(JSONs,json)
end
end
Line 85: Line 88:
table.insert(JSONs,page.recipeJSON)
table.insert(JSONs,page.recipeJSON)
else
else
for _, json in page.activityJSON do
for _, json in page.recipeJSON do
json.type = 'recipe'
table.insert(JSONs,json)
table.insert(JSONs,json)
end
end
Line 97: Line 101:
--decode the JSON to a Lua table, add data from the page that had it
--decode the JSON to a Lua table, add data from the page that had it
local item = mw.text.jsonDecode(JSON)
local item = mw.text.jsonDecode(JSON)
item.page = page.page
item.page = page.pageName
item.pageImage = page.pageImage
item.pageImage = page.pageImage
--insert into output table
--insert into output table
table.insert(output,itemNew)
table.insert(output,item)
end
end
end
end
end
end

return output
return output