Module:xal-utilities


local export = {}


function export.todo(frame)
  local parent_args = frame:getParent().args
  local default_title = parent_args['head'] or mw.title.getCurrentTitle().text
  default_title = 'Clear Script variants of '
    .. require 'Module:script utilities'.tag_text(
    default_title, require 'Module:languages'.getByCode 'xwo', nil, 'term', nil)
  local tabletitle = parent_args['title'] or default_title
  local text = '<div class="NavFrame" style="clear:both;display:inline-block;font-size:100%">\n<div class="NavHead" style="">' .. tabletitle .. '&nbsp;&nbsp;</div>\n<div class="NavContent">\n{| style="text-align:center;"'
  local i = 1
  while parent_args[i] do
    local term = parent_args[i]
    local lang = require 'Module:languages'.getByCode 'xwo'
    local link = require 'Module:links'.full_link( { lang = lang, term = term}, 'term' )
    local spelling = mw.ustring.gsub(link, "%b()", "")
    text = text .. '\n|style="background-color:#efefef;font-size:105%|<span style="margin:0px 6px;"><b>' .. spelling .. '</b></span>'
    i = i + 1
  end
  local j = 1
  local no_read = true
  local since_last = 1
  while parent_args[j] do
  	if parent_args[j] then
			if no_read then
				text = text .. '\n|-'
				no_read = false
			end
			while since_last > 0 do
				text = text .. '\n|'
				since_last = since_last - 1
			end
    	local term = parent_args[j]
    	local lang = require 'Module:languages'.getByCode 'xwo'
    	local link = require 'Module:links'.full_link( { lang = lang, term = term}, 'term' )
    	local translit = mw.ustring.sub(mw.ustring.match(link, "%b()"), 2, -2)
    text = text .. 'style="background-color:#efefef"|' .. translit 
  	end
	since_last = since_last + 1
    j = j + 1
  end
	j = 1
	local no_note = true
	since_last = 1
	local since_note = 1
	local note = 'note1'
	while j < i do
		if parent_args[note] then
			if no_note then
				text = text .. '\n|- style="font-size:70%"'
				no_note = false
			end
			while since_last > 0 do
				text = text .. '\n|'
				since_last = since_last - 1
			end
			text = text .. 'style="background-color:#efefef"|' .. parent_args[note]
		end
		since_last = since_last + 1
		j = j + 1
		note = 'note' .. j
	end
		j = 1
	local no_date = true
	since_last = 1
	local date = 'date1'
	while j < i do
		if parent_args[date] then
			if no_date then
				text = text .. '\n|-'
				no_date = false
			end
			while since_last > 0 do
				text = text .. '\n|'
				since_last = since_last - 1
			end
			text = text .. 'style="background-color:#efefef"|' .. frame:expandTemplate{title = 'defdate', args = {parent_args[date]}}
		end
		since_last = since_last + 1
		j = j + 1
		date = 'date' .. j
	end
  text = text .. '\n|}</div></div>'
  return text
end 


return export