<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ACommonChemistry</id>
	<title>Module:CommonChemistry - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ACommonChemistry"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:CommonChemistry&amp;action=history"/>
	<updated>2026-08-08T16:25:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:CommonChemistry&amp;diff=135722&amp;oldid=prev</id>
		<title>imported&gt;Leyo: Leyo moved page Module:Sandbox/Leyo/CommonChemistry to Module:CommonChemistry without leaving a redirect: correct location</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:CommonChemistry&amp;diff=135722&amp;oldid=prev"/>
		<updated>2022-02-14T22:08:03Z</updated>

		<summary type="html">&lt;p&gt;Leyo moved page &lt;a href=&quot;/index.php?title=Module:Sandbox/Leyo/CommonChemistry&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Module:Sandbox/Leyo/CommonChemistry (page does not exist)&quot;&gt;Module:Sandbox/Leyo/CommonChemistry&lt;/a&gt; to &lt;a href=&quot;/research/Module:CommonChemistry&quot; title=&quot;Module:CommonChemistry&quot;&gt;Module:CommonChemistry&lt;/a&gt; without leaving a redirect: correct location&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- copy of de:Modul:Benutzer:MisterSynergy/test with a slight modification (modified function name)&lt;br /&gt;
local function check_reference(reference, cas_from_template)&lt;br /&gt;
	if not reference.snaks then&lt;br /&gt;
		return false -- empty reference&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for ref_prop_qualifier, values in pairs(reference.snaks) do&lt;br /&gt;
		if ref_prop_qualifier == &amp;#039;P248&amp;#039; then&lt;br /&gt;
			for i, value in ipairs(values) do&lt;br /&gt;
				if value.snaktype == &amp;#039;value&amp;#039; and value.datavalue.value.id == &amp;#039;Q18907859&amp;#039; then&lt;br /&gt;
					return true&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if ref_prop_qualifier == &amp;#039;P854&amp;#039; then&lt;br /&gt;
			for i, value in ipairs(values) do&lt;br /&gt;
				if value.snaktype == &amp;#039;value&amp;#039; and value.datavalue.value == &amp;#039;https://commonchemistry.cas.org/detail?cas_rn=&amp;#039; .. cas_from_template then&lt;br /&gt;
					return true&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return false -- reference without qualifiers we are looking for&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function check_claim(statement, cas_from_template)&lt;br /&gt;
	if statement.rank == &amp;#039;deprecated&amp;#039; then&lt;br /&gt;
		return false -- ignore claim with deprecated rank&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if statement.mainsnak.snaktype ~= &amp;#039;value&amp;#039; then&lt;br /&gt;
		return false -- ignore claim with &amp;#039;unknown value&amp;#039; or &amp;#039;no value&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if statement.mainsnak.datavalue.value ~= cas_from_template then&lt;br /&gt;
		return false -- ignore claim with different CAS number than in infobox&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not statement.references then&lt;br /&gt;
		return false -- ignore claim without references&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for i, reference in ipairs(statement.references) do&lt;br /&gt;
		local success, result = pcall(check_reference, reference, cas_from_template)&lt;br /&gt;
		if success and result then&lt;br /&gt;
			return true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return false -- ignore, if no suitable references were found&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.entry_CAS_Common_Chemistry(frame)&lt;br /&gt;
	local cas_from_template = mw.text.trim(frame.args[&amp;#039;cas&amp;#039;] or &amp;#039;&amp;#039;)&lt;br /&gt;
	if cas_from_template == nil or #cas_from_template == 0 then&lt;br /&gt;
		return &amp;#039;&amp;#039; -- no local CAS number provided&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local statements&lt;br /&gt;
	local qid = mw.wikibase.getEntityIdForCurrentPage()&lt;br /&gt;
	if qid then&lt;br /&gt;
		statements = mw.wikibase.getAllStatements( qid, &amp;#039;P231&amp;#039; )&lt;br /&gt;
	end&lt;br /&gt;
	if statements == nil or #statements == 0 then -- no CAS property P231 found in connected Wikidata item&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for i, statement in ipairs(statements) do&lt;br /&gt;
		local success, result = pcall(check_claim, statement, cas_from_template)&lt;br /&gt;
		if success and result then&lt;br /&gt;
			return &amp;#039;1&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return &amp;#039;&amp;#039; -- no suitable claims found at Wikidata&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Leyo</name></author>
	</entry>
</feed>