Template:EditButton/CheckList
From Metabolomics.JP
< Template:EditButton(Difference between revisions)
Line 5: | Line 5: | ||
{{#get:title}} 「species」や「効能」と言ったようなタイトル | {{#get:title}} 「species」や「効能」と言ったようなタイトル | ||
-->{{#lua: | -->{{#lua: | ||
− | --%% | + | --%% Preprocessing %%-- |
local list = {} -- データリスト | local list = {} -- データリスト | ||
local i = 0; | local i = 0; | ||
Line 12: | Line 12: | ||
i = i + 1; | i = i + 1; | ||
end | end | ||
− | --%% | + | --%% Display Setting %%-- |
print('{{#form' .. 'tag:form|action="/wiki/{{#get:prevpage}}" method="post"|') | print('{{#form' .. 'tag:form|action="/wiki/{{#get:prevpage}}" method="post"|') | ||
print('{{#form' .. 'tag:input|type="submit" value="update"}}<br>') | print('{{#form' .. 'tag:input|type="submit" value="update"}}<br>') | ||
− | |||
local head, body; | local head, body; | ||
for i = 0, table.maxn(list) do | for i = 0, table.maxn(list) do | ||
head = string.match(list[i], "^([\*\#]+%s*)"); | head = string.match(list[i], "^([\*\#]+%s*)"); | ||
− | --%% *,# | + | --%% If *,# precedes a line, then place a checkbox, otherwise not. %%-- |
if (head ~= nil) then | if (head ~= nil) then | ||
body = string.sub(list[i],string.len(head)+1); | body = string.sub(list[i],string.len(head)+1); | ||
− | --%% | + | --%% Check whether items are already selected. {{{1}}} is the separator %%-- |
− | if (string.match("{{#get:initset}}", " | + | if (string.match("{{#get:initset}}", "{{{1|&&}}}" .. body .. "{{{1|&&}}}", 0) or |
− | string.match("{{#get:initset}}", "^" .. body .. " | + | string.match("{{#get:initset}}", "^" .. body .. "{{{1|&&}}}", 0) or |
− | string.match("{{#get:initset}}", " | + | string.match("{{#get:initset}}", "{{{1|&&}}}" .. body .. "$", 0) ) then |
checked = ' checked="yes"' | checked = ' checked="yes"' | ||
else | else |