문서 편집 권한이 없습니다. 다음 이유를 확인해주세요: 요청한 명령은 다음 중 하나의 권한을 가진 사용자에게 제한됩니다: 사용자, 관리자. 문서를 고치려면 이메일 인증 절차가 필요합니다. 사용자 환경 설정에서 이메일 주소를 입력하고 이메일 주소 인증을 해주시기 바랍니다. 문서의 원본을 보거나 복사할 수 있습니다. local p = {} function p.main(frame) local args = frame:getParent().args local out = {} -- 선거명 + 선거구 local election_type = (args["유형"] == "참") and "참의원 의원 통상선거" or "중의원 의원 총선거" local election_number = args["선거"] or "??" local election_name = string.format("제%s회 일본 %s", election_number, election_type) local election_link = string.format("[[%s]]", election_name) local district = args["선거구"] or "" table.insert(out, '<table class="wikitable">') table.insert(out, string.format( '<caption style="font-size:larger; font-weight:bold;"><big>%s</big><br>%s</caption>', election_link, district)) -- 표 머리: 후보자 + 정당색 셀 병합 table.insert(out, [[<tr> <th colspan="2">후보자</th><th>정당</th><th>득표</th><th>득표율</th><th>당락</th><th>비고</th> </tr>]]) -- 총득표 계산 local total = 0 for i = 1, 20 do local votes = tonumber(args["c" .. i .. "vote"] or "0") or 0 total = total + votes end -- 후보자 출력 for i = 1, 20 do local name = args["c" .. i .. "name"] if name and name ~= "" then local age = args["c" .. i .. "age"] or "" local party = args["c" .. i .. "party"] or "" local color = args["c" .. i .. "color"] or "#ccc" local votes = tonumber(args["c" .. i .. "vote"] or "0") or 0 local outcome = args["c" .. i .. "result"] or "" local note = args["c" .. i .. "note"] or "" local percent = total > 0 and math.floor(votes * 1000 / total + 0.5) / 10 or 0.0 local style = "" if outcome == "당선" then style = ' style="background:pink;"' elseif outcome == "석패율" then style = ' style="background:#ffe6e6;"' end local bar = string.format( '<div style="display:flex; align-items:center;"><div style="background-color:%s; width:%.1fpx; height:10px; border-radius:3.75px; display:inline-block; margin-right:5px;"></div><span style="font-size:0.833em;"><b>%.1f%%</b></span></div>', color, percent * 1.25, percent) table.insert(out, string.format( '<tr%s><td style="background:%s;"></td><td><span style="font-weight:bold;">%s</span>(%s)</td><td>%s</td><td style="text-align:right;">%s표</td><td style="text-align:left;">%s</td><td style="text-align:center;">%s</td><td>%s</td></tr>', style, color, name, age, party, mw.language.getContentLanguage():formatNum(votes), bar, outcome, note)) end end -- 합계 행 table.insert(out, string.format( '<tr style="font-weight:bold; background:#f9f9f9;"><td colspan="3" style="text-align:center;">합계</td><td style="text-align:right;">%s표</td><td style="text-align:right;">투표율: %s%%</td><td colspan="2" style="text-align:center;">유권자 수: %s명</td></tr>', mw.language.getContentLanguage():formatNum(total), args["투표율"] or "?", mw.language.getContentLanguage():formatNum(tonumber(args["유권자"] or "0") or 0) )) table.insert(out, "</table>") return table.concat(out, "\n") end return p 이 문서에서 사용한 틀: 모듈:선거결과/설명문서 (원본 보기) 모듈:선거결과 문서로 돌아갑니다.