Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Jeblad/NLG/layout
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local conf = require 'Module:NLG/layout/conf'('en') --- Table acting as a class for Tag local Tag = {} Tag.__index = Tag setmetatable(Tag, { __call = function(cls, ...) local self = setmetatable({}, cls) self:_init(...) return self end, }) --- Initialiser for the Tag class -- @param t table holding additional data function Tag:_init( t ) self._data = t self._position = t and t.position or 50 end --- Set values in the instance -- @return table representing self function Tag:set( t ) if t then if t.position then self._position = t.position end end return self end --- Get the name -- @return string representing the name, otherwise nil function Tag:name() return self._data.name end --- Get the after list -- @return list of strings representing the tags, otherwise nil function Tag:after() return self._data.after or {} end --- Get the before list -- @return list of strings representing the tags, otherwise nil function Tag:before() return self._data.before or {} end --- Get the position -- @return number representing the position, otherwise nil function Tag:position() return self._position end local layout = {} if 1 or _G['_BDD'] then layout['Tag'] = Tag end layout.order = function( t ) local registry = {} for _,v in ipairs(t) do registry[v.name] = Tag(v):set({['position']=initialOrder[v.name]}) end for _,v in ipairs(t) do local vTag = registry[v.name] for _,w in ipairs(vTag:after()) do local wTag = registry[w.name] local diff = vTag:position() - wTag:position() if diff < 0 then local position = vTag:position() + 0.4 * diff vTag:set({['position']=position}) end end end local max = -100 local min = 200 for _,v in pairs(registry) do if max < v:position() then max = v:position() end if min > v:position() then min = v:position() end end mw.logObject(min) mw.logObject(max) local scale = 100/(max-min) mw.logObject(scale) for _,v in pairs(registry) do local position = scale*v:position() + min v:set({['position']=position}) end return order end return layout
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Jeblad/NLG/layout/doc
(
edit
)