Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Documentation for this module may be created at Module:Infobox/common/doc

require("strict");

local p = {}

function p.get_length ( length, units )
	if length == nil then return nil end
	return '<span class="convertable-length">' .. length .. '&nbsp;' .. units .. '</span>'
end

function p.get_speed ( speed, units )
	if speed == nil then return nil end
	return '<span class="convertable-speed">' .. speed .. '&nbsp;' .. units .. '</span>'
end

function p.get_dimensions( dimension1, dimension2, imperial )
	if (dimension1 == nil or dimension2 == nil) then return nil end
	local units
	if imperial == true then 
		units = 'feet'
	else 
		units = 'metres'
	end
	return p.get_length(dimension1,units) .. ' × ' .. p.get_length(dimension2,units)
end

function p.get_section( section, subsection )
	if section == nil then 
		return nil
	elseif subsection == nil then
		return section
	else
		return section .. ' — ' .. subsection
	end
end

function p.get_min_height( min_height, length_units_small )
	if min_height == nil then
		return nil
	elseif min_height == 'none' then
		return 'None'
	else return p.get_length(min_height, length_units_small)
	end
end

function p.get_attraction_subheading(park, owner, location, state, country)
	
	--- If park parameter is in use for a travelling ride and has a country in brackets, remove the country
	if location == 'Travelling' then
		park = string.gsub(park, ' %(' .. country .. '%)', '')
	end
	--- Start the subheading creation
	local subheading = location

	if (state ~= nil) then
		subheading = string.gsub(subheading, ', ' .. state, '')
		subheading = subheading .. ', [[' .. state .. ']]'	
	end
	
	if (country ~= nil) then
		if location ~= nil then
			subheading = string.gsub(subheading, ', ' .. country, '')
			subheading = subheading .. ', [[' .. country .. ']]'
		end
	end
	if (location == 'Travelling') then
		if (park ~= nil) then
			subheading = 'Travelling with ' .. park .. ', [[' .. country .. ']]'
		elseif (owner ~= nil) then
			subheading = 'Travelling with ' .. owner .. ', [[' .. country .. ']]'
		else
			subheading = 'Travelling'
		end
	elseif (park ~= nil) then
		subheading = park .. ', ' .. subheading
	end
	if (country == 'ship') then
		if (park == nil) then
			subheading = 'Please enter ship name into the "park" parameter'
		else
			subheading = 'On board the ' .. park
		end
	end
	
	return subheading
end
return p