Module:LNDB

local p = {} local nxb_dengeki = mw.loadData( 'Module:LNDB/Dengeki' ) local nxb_fantasia = mw.loadData( 'Module:LNDB/Fantasia' ) local nxb_sneaker = mw.loadData( 'Module:LNDB/Sneaker' ) local nxb_mf = mw.loadData( 'Module:LNDB/MF' ) local nxb_famitsu = mw.loadData( 'Module:LNDB/Famitsu' ) local nxb_dashx = mw.loadData( 'Module:LNDB/DashX' ) local nxb_ga = mw.loadData( 'Module:LNDB/GA' ) local nxb_hj = mw.loadData( 'Module:LNDB/HJ' ) local nxb_gagaga = mw.loadData( 'Module:LNDB/GAGAGA' ) local nxb_kodansha = mw.loadData( 'Module:LNDB/Kodansha' ) local nxb_overlap = mw.loadData( 'Module:LNDB/Overlap' ) local nxb_monster= mw.loadData( 'Module:LNDB/Monster' )

local _header = "font-weight:bold;text-align:left;color:white;padding:0.75em 1.5em;" local _rdate = "background:#f6f6f6;text-transform: uppercase;font-size:75%;text-align:center;padding:0.75em 1.5em;" local _id = "font-size:95%;font-style:italic;padding:0.75em 1.5em;" local _title = "width:350px;font-size:95%;font-style:italic;padding:0.75em 1.5em;" local _personnel = "width:150px;font-size:95%;font-style:italic;padding:0.75em 1.5em;" local _list = {} local _tablestart = "\" local _tableend = "\"

local function _generatetable(frame) local count = 0 local rdate, id, title, author, illustrator, header, sheader local rows = {} --   --Get Time Query-- --   timestamp = tostring(frame.timestamp) ---   --Get Publisher Query-- ---   pub = tostring(frame.publisher)

-   --Dengeki Bunko-- -   if (pub == "dengeki") then for k, v in spairs(nxb_dengeki) do           if string.sub(nxb_dengeki[k].d,3,6) == timestamp then _list[#_list+1] = nxb_dengeki[k] datestamp = string.sub(nxb_dengeki[k].d,1,2) end end sheader = "background:linear-gradient(#3c3c3c,black);background: -moz-linear-gradient(#3c3c3c,black);background: -o-linear-gradient(#3c3c3c,black);background: -webkit-linear-gradient(#3c3c3c,black);".._header end --   --Fantasia Bunko-- --   if (pub == "fantasia") then for k, v in spairs(nxb_fantasia) do           if string.sub(nxb_fantasia[k].d,3,6) == timestamp then _list[#_list+1] = nxb_fantasia[k] datestamp = string.sub(nxb_fantasia[k].d,1,2) end end sheader = "background:linear-gradient(#C25151,#A52A2A);background: -moz-linear-gradient(#C25151,#A52A2A);background: -o-linear-gradient(#C25151,#A52A2A);background: -webkit-linear-gradient(#C25151,#A52A2A);".._header end -   --Sneaker Bunko-- -   if (pub == "sneaker") then for k, v in spairs(nxb_sneaker) do           if string.sub(nxb_sneaker[k].d,3,6) == timestamp then _list[#_list+1] = nxb_sneaker[k] datestamp = string.sub(nxb_sneaker[k].d,1,2) end end sheader = "background:linear-gradient(#FCA356,#f47100);background: -moz-linear-gradient(#FCA356,#f47100);background: -o-linear-gradient(#FCA356,#f47100);background: -webkit-linear-gradient(#FCA356,#f47100);".._header end --MF Bunko-- if (pub == "mf") then for k, v in spairs(nxb_mf) do           if string.sub(nxb_mf[k].d,3,6) == timestamp then _list[#_list+1] = nxb_mf[k] datestamp = string.sub(nxb_mf[k].d,1,2) end end sheader = "background:linear-gradient(#2ED1B0,#01b18d);background: -moz-linear-gradient(#2ED1B0,#01b18d);background: -o-linear-gradient(#2ED1B0,#01b18d);background: -webkit-linear-gradient(#2ED1B0,#01b18d);".._header end -   --Famitsu Bunko-- -   if (pub == "famitsu") then for k, v in spairs(nxb_famitsu) do           if string.sub(nxb_famitsu[k].d,3,6) == timestamp then _list[#_list+1] = nxb_famitsu[k] datestamp = string.sub(nxb_famitsu[k].d,1,2) end end sheader = "background:linear-gradient(#E83131,#d40000);background: -moz-linear-gradient(#E83131,#d40000);background: -o-linear-gradient(#E83131,#d40000);background: -webkit-linear-gradient(#E83131,#d40000);".._header end --Dash X Bunko-- if (pub == "dashx") then for k, v in spairs(nxb_dashx) do           if string.sub(nxb_dashx[k].d,3,6) == timestamp then _list[#_list+1] = nxb_dashx[k] datestamp = string.sub(nxb_dashx[k].d,1,2) end end sheader = "background:linear-gradient(#A437CC,#7D00AB);background: -moz-linear-gradient(#A437CC,#7D00AB);background: -o-linear-gradient(#A437CC,#7D00AB);background: -webkit-linear-gradient(#A437CC,#7D00AB);".._header end --GA Bunko-- if (pub == "ga") then for k, v in spairs(nxb_ga) do           if string.sub(nxb_ga[k].d,3,6) == timestamp then _list[#_list+1] = nxb_ga[k] datestamp = string.sub(nxb_ga[k].d,1,2) end end sheader = "background:linear-gradient(#75BFEB,#017DC7);background: -moz-linear-gradient(#75BFEB,#017DC7);background: -o-linear-gradient(#75BFEB,#017DC7);background: -webkit-linear-gradient(#75BFEB,#017DC7);".._header end --HJ Bunko-- if (pub == "hj") then for k, v in spairs(nxb_hj) do           if string.sub(nxb_hj[k].d,3,6) == timestamp then _list[#_list+1] = nxb_hj[k] datestamp = string.sub(nxb_hj[k].d,1,2) end end sheader = "background:linear-gradient(#D2E87B,#BADB32);background: -moz-linear-gradient(#D2E87B,#BADB32);background: -o-linear-gradient(#D2E87B,#BADB32);background: -webkit-linear-gradient(#D2E87B,#BADB32);".._header end --GAGAGA Bunko-- if (pub == "gagaga") then for k, v in spairs(nxb_gagaga) do           if string.sub(nxb_gagaga[k].d,3,6) == timestamp then _list[#_list+1] = nxb_gagaga[k] datestamp = string.sub(nxb_gagaga[k].d,1,2) end end sheader = "background:linear-gradient(#4574BF,#003EA1);background: -moz-linear-gradient(#4574BF,#003EA1);background: -o-linear-gradient(#4574BF,#003EA1);background: -webkit-linear-gradient(#4574BF,#003EA1);".._header end

-   --Kodansha Ranobe Bunko-- -   if (pub == "kodansha") then for k, v in spairs(nxb_kodansha) do           if string.sub(nxb_kodansha[k].d,3,6) == timestamp then _list[#_list+1] = nxb_kodansha[k] datestamp = string.sub(nxb_kodansha[k].d,1,2) end end sheader = "background:linear-gradient(#FFD5C4,#FFB091);background: -moz-linear-gradient(#FFD5C4,#FFB091);background: -o-linear-gradient(#FFD5C4,#FFB091);background: -webkit-linear-gradient(#FFD5C4,#FFB091);".._header end -   --Overlap Bunko-- -   if (pub == "overlap") then for k, v in spairs(nxb_overlap) do           if string.sub(nxb_overlap[k].d,3,6) == timestamp then _list[#_list+1] = nxb_overlap[k] datestamp = string.sub(nxb_overlap[k].d,1,2) end end sheader = "background:linear-gradient(#dcd189,#CCBD5E);background: -moz-linear-gradient(#dcd189,#CCBD5E);background: -o-linear-gradient(#dcd189,#CCBD5E);background: -webkit-linear-gradient(#dcd189,#CCBD5E);".._header end

-   --Monster Bunko-- -   if (pub == "monster") then for k, v in spairs(nxb_monster) do           if string.sub(nxb_monster[k].d,3,6) == timestamp then _list[#_list+1] = nxb_monster[k] datestamp = string.sub(nxb_monster[k].d,1,2) end end sheader = "background:linear-gradient(#4E9C60,#00731B);background: -moz-linear-gradient(#4E9C60,#00731B);background: -o-linear-gradient(#4E9C60,#00731B);background: -webkit-linear-gradient(#4E9C60,#00731B);".._header end header = "\\#\\Tác phẩm\\Tác giả\\Minh họa\" rdate = "\\"..datemonth(datestamp..timestamp).."\\" --Application Code-- for k, v in spairs(_list) do       count = count + 1 if (count % 2 ==0) then id = "\"..count.."\</td\>" title = "\<td style='background:#f6f6f6;".._title.."'\>".._list[k].tr.."\</td\>" author = "\<td style='background:#f6f6f6;".._personnel.."'\>".._list[k].ar.."\</td\>" illustrator = "\<td style='background:#f6f6f6;".._personnel.."'\>".._list[k].ir.."\</td\>" else id = "\<td style='background:#e9e9e9;".._id.."'\>"..count.."\</td\>" title = "\<td style='background:#e9e9e9;".._title.."'\>".._list[k].tr.."\</td\>" author = "\<td style='background:#e9e9e9;".._personnel.."'\>".._list[k].ar.."\</td\>" illustrator = "\<td style='background:#e9e9e9;".._personnel.."'\>".._list[k].ir.."\</td\>" end rows[#rows+1] = "\"..id..title..author..illustrator.."\</tr\>" end return _tablestart..header..rdate..table.concat(rows,'').._tableend end

local function _generatecalendar(frame)

local datestamp = {} local timestamp = {}

--Get Date-- for k, v in spairs(nxb_dengeki) do       if string.sub(nxb_dengeki[k].d,3,6) == frame.args[1] then datestamp[dengeki] = string.sub(nxb_dengeki[k].d,1,2) break end end --Get Date--

_month = tonumber(string.sub(frame.args[1],1,2)) _year = tonumber(string.sub(frame.args[1],3,4)) + 2000 local _firstdate, _lastdate, _datelength local days_in_month = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } _datelength = days_in_month[_month] if (_month == 2) then if (math.mod(_year,4) == 0) then if (math.mod(_year,100) == 0)then if (math.mod(_year,400) == 0) then _datelength = 29 end else _datelength = 29 end end end -   --Set Timestamp-- -   --timestamp[dengeki] = os.time{year=_year, month=_month, day=datestamp[dengeki]} --tmp = os.date("*t",timestamp[dengeki]) return datestamp[dengeki]

end

function spairs(t) local keys = {} for k in pairs(t) do keys[#keys+1] = k end table.sort(keys) local i = 0 return function i = i + 1 if keys[i] then return keys[i], t[keys[i]] end end end

function datemonth(timestamp) return "ngày \<b\>"..string.sub(timestamp,1,2).."\</b\> tháng \<b\>"..string.sub(timestamp,3,4).."\</b\> năm \<b\>20"..string.sub(timestamp,5,6).."\</b\>" end

function p.dengeki(frame) arg = {timestamp=frame.args[1],publisher='dengeki'} return _generatetable(arg) end

function p.fantasia(frame) arg = {timestamp=frame.args[1],publisher='fantasia'} return _generatetable(arg) end

function p.sneaker(frame) arg = {timestamp=frame.args[1],publisher='sneaker'} return _generatetable(arg) end

function p.mf(frame) arg = {timestamp=frame.args[1],publisher='mf'} return _generatetable(arg) end

function p.famitsu(frame) arg = {timestamp=frame.args[1],publisher='famitsu'} return _generatetable(arg) end

function p.dashx(frame) arg = {timestamp=frame.args[1],publisher='dashx'} return _generatetable(arg) end

function p.ga(frame) arg = {timestamp=frame.args[1],publisher='ga'} return _generatetable(arg) end

function p.hj(frame) arg = {timestamp=frame.args[1],publisher='hj'} return _generatetable(arg) end

function p.gagaga(frame) arg = {timestamp=frame.args[1],publisher='gagaga'} return _generatetable(arg) end

function p.kodansha(frame) arg = {timestamp=frame.args[1],publisher='kodansha'} return _generatetable(arg) end

function p.overlap(frame) arg = {timestamp=frame.args[1],publisher='overlap'} return _generatetable(arg) end

function p.monster(frame) arg = {timestamp=frame.args[1],publisher='monster'} return _generatetable(arg) end

function p.calendar(frame) return _generatecalendar(frame) end return p