Changes

Jump to navigation Jump to search
move custom styles into CSS
Line 6: Line 6:  
--##########
 
--##########
 
-- Start a SMAPI compatibility table.
 
-- Start a SMAPI compatibility table.
-- @test mw.log(p.header())
+
-- @test mw.log(p.header({}))
function p.header()
+
function p.header(frame)
 
   return
 
   return
     '<table class="wikitable sortable plainlinks" id="mod-list">'
+
     private.style(frame)
     .. "<tr><th style=\"position: sticky; top: 0;\">mod name</th><th style=\"position: sticky; top: 0;\">author</th><th style=\"position: sticky; top: 0;\"><abbr title=\"This only shows whether a mod is *compatible*; it may have bugs unrelated to SMAPI compatibility.\" style=\"position: sticky; top: 0;\">compatibility</abbr></th><th style=\"position: sticky; top: 0;\">broke in</th><th style=\"position: sticky; top: 0; z-index: 100;\">source</th><th style=\"position: sticky; top: 0;\">&nbsp;</th></tr>";
+
    .. '<table class="wikitable sortable plainlinks" id="mod-list">'
 +
     .. "<tr><th>mod name</th><th>author</th><th><abbr title=\"This only shows whether a mod is *compatible*; it may have bugs unrelated to SMAPI compatibility.\">compatibility</abbr></th><th>broke in</th><th>source</th><th>&nbsp;</th></tr>";
 
end
 
end
   Line 83: Line 84:  
   else
 
   else
 
     url = customUrl
 
     url = customUrl
  end
  −
  −
  -- get background color
  −
  local background = '#999'
  −
  if compat.status == "ok" or compat.status == "optional" then
  −
    background = '#9F9'
  −
  elseif compat.status == "workaround" or compat.status == "unofficial" then
  −
    background = '#CF9'
  −
  elseif compat.status == "broken" then
  −
    background = '#F99'
  −
  elseif compat.status == "obsolete" or compat.status == "abandoned" then
  −
    background = '#999'
   
   end
 
   end
   Line 129: Line 118:  
   row:attr("data-map-remote-versions", mapRemoteVersions)
 
   row:attr("data-map-remote-versions", mapRemoteVersions)
 
   row:attr("data-change-update-keys", changeUpdateKeys)
 
   row:attr("data-change-update-keys", changeUpdateKeys)
  row:attr("style", "line-height: 1em; background: " .. background .. ";")
   
   row:newline()
 
   row:newline()
   Line 230: Line 218:  
   do
 
   do
 
     if sourceUrl then
 
     if sourceUrl then
       row:wikitext("<td>[" .. sourceUrl .. " source]</td>")
+
       row:wikitext("<td class=\"mod-source\">[" .. sourceUrl .. " source]</td>")
 
     else
 
     else
       row:wikitext("<td><span style=\"color: red; font-size: 0.85em; opacity: 0.5;\">closed source</span></td>")
+
       row:wikitext("<td class=\"mod-source\"><span>closed source</span></td>")
 
     end
 
     end
 
     row:newline()
 
     row:newline()
Line 240: Line 228:  
   do
 
   do
 
     local field = mw.html.create("td")
 
     local field = mw.html.create("td")
     field:attr("style", "font-size: 0.8em")
+
     field:attr("class", "mod-metadata")
    
     -- anchor
 
     -- anchor
Line 277: Line 265:  
--## Private functions
 
--## Private functions
 
--##########
 
--##########
 +
-- Get the <templatestyles> tag for the module's stylesheet.
 +
-- @param frame The arguments passed to the script.
 +
function private.style(frame)
 +
  if frame.extensionTag ~= nil then
 +
    return frame:extensionTag('templatestyles', '', {src = 'Module:SMAPI compatibility/styles.css'}) 
 +
  else
 +
    return "" -- called from the debug console
 +
  end
 +
end
 +
 
-- Get the normalised compatibility info for a mod.
 
-- Get the normalised compatibility info for a mod.
 
-- @param status The specified status code. If nil or blank, it'll be derived from the other fields.
 
-- @param status The specified status code. If nil or blank, it'll be derived from the other fields.
translators
8,445

edits

Navigation menu