Module:My module

From Omniversalis

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

------------------------------------------------------------------
-------Extract From http://lua-users.org/wiki/SplitJoin-----------
------------------------------------------------------------------

-- Compatibility: Lua-5.1
function split(str, pat)
   local t = {}  -- NOTE: use {n = 0} in Lua-5.0
   local fpat = "(.-)" .. pat
   local last_end = 1
   local s, e, cap = str:find(fpat, 1)
   while s do
      if s ~= 1 or cap ~= "" then
         table.insert(t,cap)
      end
      last_end = e+1
      s, e, cap = str:find(fpat, last_end)
   end
   if last_end <= #str then
      cap = str:sub(last_end)
      table.insert(t, cap)
   end
   return t
end

------------------------------------------------------------------
---------------Extract End----------------------------------------
------------------------------------------------------------------


function splitIn2(streen)
    flag = true
    for i in string.gmatch(streen, "[^:]+") do
        if flag then
            var1 = i
            flag = false
        else
            var2 = i
        end
    end
    return var1, var2
end

function splitIn4(streen)
    flag1 = true
    flag2 = true
    flag3 = true
    for i in string.gmatch(streen, "[^:]+") do
        if flag1 then
            var1 = i
            flag1 = false
        elseif flag2 then
            var2 = i
            flag2 = false
        elseif flag3 then
            var3 = i
            flag3 = false
        else
            var4 = i
        end
    end
    return var1, var2, var3, var4
end

local p = {}



function p.headerRender(frame)
	-- Attempting to remove the key from the table frame args, Unsuccessful attempt
	lookie_here = frame.args['color']
	if lookie_here == nil then
		lookie_here = 'f1f1f1'
	end
	-- place_holder = type(frame.args)
    -- frame.args['color'] = nil
    -- place_holder = frame.args['color']
    returner = --lookie_here..place_holder..
    '<span style="overflow: hidden; border: 1px solid #ccc; width:100%; background-color:#'..lookie_here..';">'
    
    for i in pairs(frame.args) do
    	-- val = string.gmatch(frame.args[i], "%S+")
    	-- dic = {}
    	-- local val1, val2 = string:match("([^,]+):([^,]+)")
    	-- Doesnt work Code local val1, val2 = (frame.args[i]):match("([^,]+),([^,]+)")
    	tot = ""
    	-- local myTable = (frame.args[i]):split(", ")
    	--[[myTable = split(frame.args[i],'[\\/]+')
    	local val1 = myTable[2]
    	local val2 = myTable[1]]--
    	-- local color, sectionHeader = splitIn2(frame.args[i])
    	-- local headerBgColor='ffffff'
		local color, sectionHeader, headerBgColor, descr = splitIn4(frame.args[i])
    	-- flag = 1
    	-- -- tot = tot..next(val).."$$1"
    	-- for every in val do
    	-- 	-- local val1, val2 = string:match("([^,]+),([^,]+)")
    	-- 	-- dic[#dic] = every
    	-- 	if flag == 1 then 
    	-- 		val1 = every
    	-- 		tot = tot..'TTT'
    	-- 		flag = 2 
    	-- 	else
    	-- 		tot = tot..'FFF'
    	-- 		val2 = every
    	-- 		flag = 1 
    	-- 	end
    	-- 	tot = tot..every	
    	-- end
    	
    	-- tot = tot..tostring(val1)..tostring(val2)
    	styling = ''
    	-- if headerBgColor ~=  nil then
    	-- 	styling = styling..'background-color: '..headerBgColor..';'
    	-- else
    	-- 	styling = styling..'background-color: white;'
    	-- end
    	if tostring(mw.title.getCurrentTitle().id) == tostring(sectionHeader) then
    		styling = styling..'background-color: gray;'
    		-- returner = returner..'gray'
    	else
    		styling = styling..'background-color: white;'
    		-- returner = returner..'white'
    	end
    	if i ~= 'color' then
	    	returner = returner..'<span style="color: '..color..'; float: left; border-top: 6px solid '
	    	..color..'; font-weight: bold; outline: none; cursor: pointer; padding: 14px 16px; transition: 0.3s; '..styling..'">'
	    	returner = returner..sectionHeader
	    	returner = returner..'</span>'
	    end
	    -- headerBgColor = nil
    end
    -- for i, j in pairs(mw.title.getCurrentTitle()) do
    -- 	returner = returner..tostring(i)..tostring(j)..'Herehere'
    -- end
    -- mw.title.getCurrentTitle().subpageText..
    returner = returner..'</span>'
    return returner
end






return p