Module:Sandbox/Deryck Chan/rfdt

local rfd = {}

function rfd.test1 (frame)
	local test_string1 = frame.args[1]
	return test_string1
end

function rfd.test2 (frame) --this bit dumps a noinclude into the final output
	local test_string11 = frame.args[1]
	local test_string12 = frame.args[2]
	return test_string11 .. '<noinclude>' .. test_string12 .. '</noinclude>'
end

function rfd.test3(frame) --this bit literally just dumps a human understandable safesubst string
	local linkstring = '[[{{ {{{|safesubst:}}}FULLPAGENAME}}#{{ {{{|safesubst:}}}CURRENTTIMESTAMP}}]]'
	local anchorstring = '<span id="{{ {{{|safesubst:}}}CURRENTTIMESTAMP}}"></span>'
	return linkstring
end

function rfd.test4(frame)
	return mw.title.getCurrentTitle()
end

function rfd.rfdt_collapsebox(frame) --this bit creates the "closed discussion" notice
	local message_string1 = '<includeonly>[[File:Symbol move vote.svg|16px|link=|alt=]] '
	.. "'''Closed discussion''', click "
	
	local link_string = "[[{{ {{{|safesubst:}}}FULLPAGENAME}}#{{ {{{|safesubst:}}}CURRENTTIMESTAMP}}|here]]"
	
	local message_string2 = ' to view full discussion.'
	
	local result_string = ''
	if (frame.args[1]) then --this line doesn't work yet because Lua evaluates an empty string as true
		result_string = ' Result was: ' .. frame.args[1]
	end
	
	local end_string = '</includeonly><noinclude>'

	return message_string1 .. link_string .. message_string2 .. result_string .. end_string
end

function rfd.rfdb_noinclude(frame)
	return '</noinclude>'
end

function rfd.generate_icon(frame)
	
	local function match_result(result_parameter)
			
		local find_count = 0
		
		local result_match = ''
		
		local parameter_lower = result_parameter:lower()
		
		if (parameter_lower:find('keep')) then
			result_match = 'Keep'
			find_count = find_count + 1
		end
		
		if (parameter_lower:find('delete')) then
			result_match = 'Delete'
			find_count = find_count + 1
		end
		
		if (parameter_lower:find('retarget')) then
			result_match = 'Retarget'
			find_count = find_count + 1
		end
		
		if (parameter_lower:find('disambiguate') or parameter_lower:find('dab') or parameter_lower:find('sia') or parameter_lower:find('set index')) then
			result_match = 'Disambiguate'
			find_count = find_count + 1
		end
		
		if find_count >= 2 then
			result_match = 'Multiple'
		elseif find_count <= 0 then
			result_match = 'None'
		end
		
		return result_match, 'lalala'
	end
	
	local result_string1, result_string2 = match_result(frame.args[1])
	
	return result_string1 .. 'abcd' .. result_string2
	
end


return rfd
Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Sandbox/Deryck_Chan/rfdt&oldid=766915998"