• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Changes

Jump to navigation Jump to search
Fixed edit button. Copied edit button formatting from Module:MapRewards.
Line 1: Line 1:  
local _ = require('Module:Core')
 
local _ = require('Module:Core')
local Data = require('Module:Data')
+
-- local Data = require('Module:Data')
local View = require('Module:View')
+
-- local View = require('Module:View')
 +
 
 +
local p = {}
 +
 
 +
p.cache = {}
    
-- [[Category:Todo]]:
 
-- [[Category:Todo]]:
Line 15: Line 19:  
|style="width:20%"|Rewards
 
|style="width:20%"|Rewards
 
|style="width:0.5%"|
 
|style="width:0.5%"|
|style="width:30%"|Note<span style="float:right;margin-top:-2em">[[Module:Data/Quest/${category}|[edit]]]</span>
+
|style="width:30%"|Note<span class="plainlinks" style="float:right">&#x5b;[https://en.kancollewiki.net/Module:Data/Quest/${category}?action=edit edit]&#x5d;</span>
 
|-]=]
 
|-]=]
   Line 31: Line 35:  
|
 
|
 
|${note}]=]
 
|${note}]=]
 +
 +
local table_row_alias = [=[|- id="${label}" class="q${letter}" style="height:50px"
 +
|rowspan="1"|'''${label}'''
 +
|colspan="11"|See [[#${alias_of}|${alias_of}]].
 +
]=]
    
local function render(args, frame)
 
local function render(args, frame)
 
   -- Filter term ([1] = pattern to match, [2] = data element to match)
 
   -- Filter term ([1] = pattern to match, [2] = data element to match)
 
   local filter = { (args.explicit['filterMatch'] or nil), (args.explicit['filterGroup'] or nil) }
 
   local filter = { (args.explicit['filterMatch'] or nil), (args.explicit['filterGroup'] or nil) }
 +
  local idsList = nil
 +
  if(args.explicit['filterIDs']) then
 +
      idsList = mw.text.split(args.explicit['filterIDs'], '%s')
 +
  end
 
   local result = {}
 
   local result = {}
 
   for i, category in ipairs(args.explicit) do
 
   for i, category in ipairs(args.explicit) do
    local data = Data.load('Quest', category)
+
  if not p.cache[category] then
 +
  p.cache[category] = mw.loadData('Module:Data/Quest/' .. category)
 +
end
 +
local data = p.cache[category]
 
     table.insert(result, _.format(table_header, { category = category }))
 
     table.insert(result, _.format(table_header, { category = category }))
 
     for i, q in ipairs(data) do
 
     for i, q in ipairs(data) do
       if (not filter[1] or not filter[2]) or (string.match(q[filter[2]], filter[1])) then
+
       local proceed = false
        -- table.insert(result, _.format(table_row, q))
+
      if(idsList) then
        table.insert(result, _.format(table_row, {
+
        for j, qid in ipairs(idsList) do
          label = q.label,
+
          if(q.label == qid) then
          title = q.title,
+
              proceed = true
          title_en = q.title_en,
+
              table.remove(idsList, j)
          detail_en = q.detail_en,
+
              break
          reward_fuel = q.reward_fuel,
+
          end
          reward_ammo = q.reward_ammo,
+
        end
          reward_steel = q.reward_steel,
+
      end
          reward_bauxite = q.reward_bauxite,
+
      if (proceed or (not idsList and not filter[1] and not filter[2]) or (filter[1] and filter[2] and q[filter[2]] and string.match(q[filter[2]], filter[1]))) then
          reward_other = q.reward_other,
+
        if(q.alias_of) then
          note = q.note,
+
            table.insert(result, _.format(table_row_alias, {
          letter = q.letter or q.label:sub(1, 1)
+
                label = q.label,
        }))
+
                letter = q.letter or q.label:sub(1, 1),
 +
                alias_of = q.alias_of
 +
            }))
 +
        else
 +
            -- table.insert(result, _.format(table_row, q))
 +
            table.insert(result, _.format(table_row, {
 +
              label = q.label,
 +
              title = q.title or '?',
 +
              title_en = q.title_en or '?',
 +
              detail_en = q.detail_en or '?',
 +
              reward_fuel = q.reward_fuel or '?',
 +
              reward_ammo = q.reward_ammo or '?',
 +
              reward_steel = q.reward_steel or '?',
 +
              reward_bauxite = q.reward_bauxite or '?',
 +
              reward_other = q.reward_other or '?',
 +
              note = q.note or '?',
 +
              letter = q.letter or q.label:sub(1, 1)
 +
            }))
 +
        end
 
       end  
 
       end  
 
     end
 
     end
 
     table.insert(result, table_footer)
 
     table.insert(result, table_footer)
 
   end
 
   end
 +
  local s = _.join(result, '\n')
 +
  s = s:gsub("{{Audio|file=([^}]+)}}", '<span class="audio-button">[[Media:%1|Play]]</span>')
 +
  s = s:gsub("{{ShipLink|([^|^}]+)}}", function(e) return string.format('[[%s]]', e:gsub('/', ' ')) end)
 +
  s = s:gsub("{{ShipLink|([^|^}]+)|kai=x}}", function(e) return string.format('[[%s]] (Kai)', e:gsub('/', ' ')) end)
 +
  s = s:gsub("{{ShipLink|([^|^}]+)|kai=x|kai_ni=x}}", function(e) return string.format('[[%s]] (Kai, Kai Ni)', e:gsub('/', ' ')) end)
 
    
 
    
   return frame:preprocess(_.join(result, '\n'))
+
   s = s:gsub("{{ShipLink|[^|^}]+|text=([^|^}]+)|link_class=([^|^}]+)}}", function(text, class) return string.format('[[:Category:%s Class|%s]]', class, text) end)
 +
  s = s:gsub("{{ShipLink|[^|^}]+|[^|^}]+|text=([^|^}]+)|link_class=([^|^}]+)}}", function(text, class) return string.format('[[:Category:%s Class|%s]]', class, text) end)
 +
  s = s:gsub("{{ShipLink|[^|^}]+|[^|^}]+|[^|^}]+|text=([^|^}]+)|link_class=([^|^}]+)}}", function(text, class) return string.format('[[:Category:%s Class|%s]]', class, text) end)
 +
 
 +
  s = s:gsub("{{EquipmentLink|([^|^}]+)}}", "[[%1]]")
 +
  s = s:gsub("{{EquipmentLink|([^|^}]+)|text=true|image=30px}}", "[[%1]]")
 +
  s = s:gsub("{{EquipmentLink|([^|^}]+)|image=30px|text=true}}", "[[%1]]")
 +
  s = s:gsub("{{EquipmentLink|text=true|image=30px|([^|^}]+)}}", "[[%1]]")
 +
  s = s:gsub("{{ItemLink|text=true|image=30px|([^|^}]+)}}", "[[%1]]")
 +
  s = s:gsub("{{color|red|([^}]+)}}", '<span style="color:red">%1</span>')
 +
  return s
 +
end
 +
 
 +
p.render = function(frame)
 +
    return render(frame and _.getTemplateArgs(frame) or {}, frame)
 
end
 
end
   −
return View(render)
+
return p
advmod, cssedit, janitor, Moderators, prechecked, Widget editors
6,964

edits

Navigation menu