Semantic MediaWikiDit bericht verdwijnt nadat alle relevante taken zijn afgerond.

Er is één onvoltooide of openstaande taak, die nodig is om het bijwerken van Semantic MediaWiki te voltooien. Een beheerder of gebruiker met voldoende rechten kan deze uitvoeren. Dit moet worden gedaan voordat nieuwe gegevens worden toegevoegd om tegenstrijdigheden te voorkomen.

Geen bewerkingssamenvatting
Geen bewerkingssamenvatting
Regel 37: Regel 37:
--local inputField = mFFInput.createCheckInputField( "radio", name, {}, checked, stepSequence )
--local inputField = mFFInput.createCheckInputField( "radio", name, {}, checked, stepSequence )
local checkInputs = ""
for i,step in ipairs(stepSequence) do
for i,step in ipairs(stepSequence) do
local id = name .. "-"  .. string.gsub(step, ".", "-") --{{{name|rating}}}-{{#var:@numericid}}
local id = name .. "-"  .. string.gsub(step, ".", "-") --{{{name|rating}}}-{{#var:@numericid}}
Regel 44: Regel 45:
local title = step .. " "
local title = step .. " "
if ( step == "1" or step == "0.5" ) then title = title .. star else title = title .. stars end
if ( step == "1" or step == "0.5" ) then title = title .. star else title = title .. stars end
local radio = p.createRatingCheckInput( "radio", step, isChecked, id, name, labelName, title )
checkInputs = checkInputs .. p.createRatingCheckInput( "radio", step, isChecked, id, name, "", title )
end
end
local fieldset = mw.text.tag(
"fieldset",
{ class = "rate" },
checkInputs
)


return fieldset;
end
end



Versie van 22 aug 2025 12:28

<fieldset class="rate"><_input type="radio" name="rating" value="10" id="rating---"></_input><label for="rating---" class="ws-star whole" title="10 sterren"></label><_input type="radio" name="rating" value="9.5" id="rating----"></_input><label for="rating----" class="ws-star half" title="9.5 sterren"></label><_input type="radio" name="rating" value="9" id="rating--"></_input><label for="rating--" class="ws-star whole" title="9 sterren"></label><_input type="radio" name="rating" value="8.5" checked id="rating----"></_input><label for="rating----" class="ws-star half" title="8.5 sterren"></label><_input type="radio" name="rating" value="8" id="rating--"></_input><label for="rating--" class="ws-star whole" title="8 sterren"></label><_input type="radio" name="rating" value="7.5" id="rating----"></_input><label for="rating----" class="ws-star half" title="7.5 sterren"></label><_input type="radio" name="rating" value="7" id="rating--"></_input><label for="rating--" class="ws-star whole" title="7 sterren"></label><_input type="radio" name="rating" value="6.5" id="rating----"></_input><label for="rating----" class="ws-star half" title="6.5 sterren"></label><_input type="radio" name="rating" value="6" id="rating--"></_input><label for="rating--" class="ws-star whole" title="6 sterren"></label><_input type="radio" name="rating" value="5.5" id="rating----"></_input><label for="rating----" class="ws-star half" title="5.5 sterren"></label><_input type="radio" name="rating" value="5" id="rating--"></_input><label for="rating--" class="ws-star whole" title="5 sterren"></label><_input type="radio" name="rating" value="4.5" id="rating----"></_input><label for="rating----" class="ws-star half" title="4.5 sterren"></label><_input type="radio" name="rating" value="4" id="rating--"></_input><label for="rating--" class="ws-star whole" title="4 sterren"></label><_input type="radio" name="rating" value="3.5" id="rating----"></_input><label for="rating----" class="ws-star half" title="3.5 sterren"></label><_input type="radio" name="rating" value="3" id="rating--"></_input><label for="rating--" class="ws-star whole" title="3 sterren"></label><_input type="radio" name="rating" value="2.5" id="rating----"></_input><label for="rating----" class="ws-star half" title="2.5 sterren"></label><_input type="radio" name="rating" value="2" id="rating--"></_input><label for="rating--" class="ws-star whole" title="2 sterren"></label><_input type="radio" name="rating" value="1.5" id="rating----"></_input><label for="rating----" class="ws-star half" title="1.5 sterren"></label><_input type="radio" name="rating" value="1" id="rating--"></_input><label for="rating--" class="ws-star whole" title="1 ster"></label><_input type="radio" name="rating" value="0.5" id="rating----"></_input><label for="rating----" class="ws-star half" title="0.5 ster"></label></fieldset>


--[[
Adapted from Template:Wsrating

]]--

local p = {}
local mFFInput = require('Module:FFInput')

--[[
{{#invoke:FFRating|input|... }}
]]--
p.input = function(frame)

end

--[[
display version
{{#invoke:FFRating|display|... }}
]]--

p.display = function(frame)
end


p.common = function( frame )
	local name = frame.args.name or "rating"
	local steps = frame.args.steps or "10;9.5;9;8.5;8;7.5;7;6.5;6;5.5;5;4.5;4;3.5;3;2.5;2;1.5;1;0.5"
	local star = frame.args.star or "ster"
	local stars = frame.args.stars or "sterren"
	local checked = frame.args.checked or ""
	local static = frame.args.static or "false"
	-- 
	local cancellable = frame.args.cancellable or "false"
	local canceltitle = frame.args.canceltitle or "Annuleren"
	
	local stepSequence = mw.text.split( steps, ";" )
	--local inputField = mFFInput.createCheckInputField( "radio", name, {}, checked, stepSequence )
		
	local checkInputs = ""
	for i,step in ipairs(stepSequence) do
		local id = name .. "-"  .. string.gsub(step, ".", "-") --{{{name|rating}}}-{{#var:@numericid}}
		local isChecked = ( step == checked )
		local class = ""
		-- eg 9.5 sterren, 1 ster
		local title = step .. " "
		if ( step == "1" or step == "0.5" ) then title = title .. star else title = title .. stars end
		checkInputs = checkInputs .. p.createRatingCheckInput( "radio", step, isChecked, id, name, "", title )
	end
	
	local fieldset = mw.text.tag(
		"fieldset",
		{ class = "rate" },
		checkInputs
	)

	return fieldset;
end

p.createRatingCheckInput = function( checkType, val, isChecked, id, name, labelName, title, showOnChecked, showOnUnchecked )
	-- (1) create input
	-- <input id="Ratings-10" name="Ratings" value="10" type="radio" data-wssos-show="">
	local args = {
		["type"] = checkType,
		--checked = isChecked,
		name = name,
		id = id
	}
	if val ~= nil then args["value"] = val end
	if isChecked ~= nil then args.checked = isChecked end
	
	local showOnChecked = showOnChecked or nil
	if showOnChecked ~= nil then args["show-on-checked"] = showOnChecked end
	if showOnUnchecked ~= nil then args["show-on-unchecked"] = showOnUnchecked end
	
	local checkInput = mw.text.tag( '_input', args, "" )
	--mw.log( "checkInput: " .. checkInput .. "; ")

	-- (2) create label
	-- <label class="ws-star whole" title="10 sterren" for="Ratings-10"></label>
	local class = "ws-star half"
	if string.find(val, ".5") == nil then
		class = "ws-star whole"
	end
	local labelArgs = {
		class = class,
		title = title,
		["for"] = id
	}
	local labelInput = mw.text.tag( "label", labelArgs, labelName )
	
	-- (3) Join and return
	local res = checkInput .. labelInput
	return res
end

return p