Module:Indicator datasets table: Difference between revisions

From Visual Data Wiki
Jump to navigation Jump to search
No edit summary
Tag: Manual revert
No edit summary
Line 11: Line 11:
      
      
     for _, id in ipairs(ids) do
     for _, id in ipairs(ids) do
         local titleobject = mw.title.new( tonumber(id) )
         local titleobject = mw.title.new(tonumber(id))
--Doesn't use a colon
        local existspage = titleobject.exists
local existspage = titleobject.exists
       
local pagecontent
        if existspage then
            local content = titleobject:getContent()
if existspage then
            -- Speichere den Inhalt der Seite
-- Method uses a colon
            table.insert(pagecontent, content)
  pagecontent = titleobject:getContent()
        else
end
            table.insert(pagecontent, "Error: Page not found for ID " .. id)
        end
return pagecontent
     end
     end
  return table.concat(pagecontent, " - ")
   
    -- Erstelle für jeden Inhalt ein <div>-Element
    local result = {}
    for _, content in ipairs(pagecontent) do
        table.insert(result, '<div>' .. content .. '</div>')
    end
   
    -- Gib alle <div>-Elemente als zusammengefügten String zurück
    return table.concat(result, "\n")
end
end


return p
return p

Revision as of 14:16, 2 May 2024

Documentation for this module may be created at Module:Indicator datasets table/doc

local p = {}

function p.getDatasets(frame)
    local articleids = frame.args.articleids
    if not articleids then
        return "Error: articleids not provided"
    end
    
    local ids = mw.text.split(articleids, ",")
    local pagecontent = {}
    
    for _, id in ipairs(ids) do
        local titleobject = mw.title.new(tonumber(id))
        local existspage = titleobject.exists
        
        if existspage then
            local content = titleobject:getContent()
            -- Speichere den Inhalt der Seite
            table.insert(pagecontent, content)
        else
            table.insert(pagecontent, "Error: Page not found for ID " .. id)
        end
    end
    
    -- Erstelle für jeden Inhalt ein <div>-Element
    local result = {}
    for _, content in ipairs(pagecontent) do
        table.insert(result, '<div>' .. content .. '</div>')
    end
    
    -- Gib alle <div>-Elemente als zusammengefügten String zurück
    return table.concat(result, "\n")
end

return p