Difference between revisions of "Module:Clade/labels"

From blackwiki
Jump to navigation Jump to search
blackwiki>Jts1882
(fix)
blackwiki>Jts1882
(basic functionality added and demonstrated using direct invoke)
Line 11: Line 11:
 
     args = p.getArgs(frame)  
 
     args = p.getArgs(frame)  
 
      
 
      
     local i = 1                       -- index for labels
+
     local i = 1                     -- index for labels
     local label = args['label'..i]    or ""
+
     local output = ""
 +
    local groupStyle = args['style']
 +
    local topStyle = args['top']
 +
     local leftStyle = args['left']
 +
    local rightStyle = args['right']
 +
    local bottomStyle = args['bottom']
 
      
 
      
     local style = args['style'..i] or "background-color:#ccffff;"  -- default for testing
+
     while  args['label'..i] do
    local top = args['top'..i]     or ""
+
   
    local left = args['left'..i]     or ""
+
    local label = args['label'..i]    or ""
    local right = args['right'..i]     or ""
+
   
    local bottom = args['bottom'..i]     or ""
+
    local style = args['style'..i] or args['style']  or "background-color:#ccffff;"  -- default for testing
    if top ~= ""    then top = 'top:'    .. top    .. ';' end   
+
    local top   = args['top'..i]   or args['top']    or ""
    if left ~= ""  then top = 'left:'    .. left  .. ';' end   
+
    local left   = args['left'..i]   or args['left']  or ""
    if right ~= ""  then top = 'right:'  .. right  .. ';' end   
+
    local right = args['right'..i] or args['right']  or ""
    if bottom ~= "" then top = 'bottom:'  .. bottom .. ';' end  
+
    local bottom = args['bottom'..i] or args['bottom'] or ""
    local position = top .. left .. right .. bottom
+
    if top ~= ""    then top   = 'top:'    .. top    .. ';' end   
   
+
    if left ~= ""  then left  = 'left:'    .. left  .. ';' end   
output = '<div style="position:absolute;' .. style .. position .. '">' .. label .. '</div>'
+
    if right ~= ""  then right  = 'right:'  .. right  .. ';' end   
--background-color:#ffccff;top:75%;">
+
    if bottom ~= "" then bottom = 'bottom:'  .. bottom .. ';' end  
 +
    local position = top .. left .. right .. bottom
 +
   
 +
output = output .. '<div style="position:absolute;' .. style .. position .. '">' .. label .. '</div>'
 +
--background-color:#ffccff;top:75%;">
 +
i=i+1
 +
end
 
return output
 
return output
 
end
 
end
  
 
return p
 
return p

Revision as of 08:49, 10 November 2019

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

local p = {}

--local args =frame:getParent().args  -- get parent arguments
--local args = {}

p.getArgs = function(frame)
	return frame.args -- use frame arguments
end
p.main = function(frame)
     
    args = p.getArgs(frame) 
    
    local i = 1                     -- index for labels
    local output = ""
    local groupStyle = args['style']
    local topStyle = args['top']
    local leftStyle = args['left']
    local rightStyle = args['right']
    local bottomStyle = args['bottom']
    
    while  args['label'..i] do
    	
	    local label = args['label'..i]     or ""
	    
	    local style  = args['style'..i]  or args['style']  or "background-color:#ccffff;"  -- default for testing
	    local top    = args['top'..i]    or args['top']    or ""
	    local left   = args['left'..i]   or args['left']   or ""
	    local right  = args['right'..i]  or args['right']  or ""
	    local bottom = args['bottom'..i] or args['bottom'] or ""
	    if top ~= ""    then top    = 'top:'     .. top    .. ';' end  
	    if left ~= ""   then left   = 'left:'    .. left   .. ';' end  
	    if right ~= ""  then right  = 'right:'   .. right  .. ';' end  
	    if bottom ~= "" then bottom = 'bottom:'  .. bottom .. ';' end 
	    local position = top .. left .. right .. bottom
	    
		output = output .. '<div style="position:absolute;' .. style .. position .. '">' .. label .. '</div>'
		--background-color:#ffccff;top:75%;">
		i=i+1
	end
	return output
end

return p