모듈:HelpNavigation

최근 편집: 2018년 9월 25일 (화) 20:45
낙엽1124 (토론 | 기여)님의 2018년 9월 25일 (화) 20:45 판 (사용하지 않는 함수 지웁니다(책날개와 templateStyles로 대체됨))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

이 모듈에 대한 설명문서는 모듈:HelpNavigation/설명문서에서 만들 수 있습니다

local p = {}

function p.helpArray(frame) 
    return p._helpArray(frame.args[1],frame)
end

function p._helpArray(title,frame)
    local titlesRawText = frame:expandTemplate{title=title}

    local helpTitlesArray = {}
    for word in string.gmatch(titlesRawText, '%[%[([^:]*:[^\|]+)') do
        helpTitlesArray[table.getn(helpTitlesArray)+1] = word
    end

    return helpTitlesArray
end
    

function p.previous(frame) 	
	local helpTitlesArray = p._helpArray(frame.args[2],frame)
	for i,v in ipairs(helpTitlesArray) do 
		if string.match(v,':(.+)') == string.match(frame.args[1],':(.+)') and i-1 > 0 then return helpTitlesArray[i-1] end
	end
	return nil
end

function p.next(frame)
	local helpTitlesArray = p._helpArray(frame.args[2],frame)
	for i,v in ipairs(helpTitlesArray) do 
		if string.match(v,':(.+)') == string.match(frame.args[1],':(.+)') and i+1 <= table.getn(helpTitlesArray) then return helpTitlesArray [i+1] end
	end
	return nil
end

return p