模組:Element

文档图示 模块文档

Module:Element编辑 | 讨论 | 历史 | 链接 | 监视 | 日志

函數說明

symbol

輸入一個與元素相關字串(如原子序、名稱、符號、別名等),回傳該元素的元素符號,資料記載於Module:Element/data

  • 輸入{{#invoke:Element|symbol|26}}→回傳「Fe」
  • 輸入{{#invoke:Element|symbol|水銀}}→回傳「Hg」
  • 輸入{{#invoke:Element|symbol|}}→回傳「Hg」
  • 輸入{{#invoke:Element|symbol|168}}→回傳「Uho」
例外狀況
  • 輸入{{#invoke:Element|symbol|娜娜奇}}→回傳「未知的元素“娜娜奇”
  • 輸入{{#invoke:Element|symbol|-168}}→回傳「未知的元素“-168”
其他
  • 輸入{{#invoke:Element|symbol|元素}}→回傳「X」
  • 輸入{{#invoke:Element|symbol|}}→回傳「NH4

neutron

輸入一個與元素相關字串(如原子序、名稱、符號、別名等),回傳該元素最穩定同位素且豐度最高之同位素的中子數,資料記載於Module:Element/data

  • 輸入{{#invoke:Element|neutron|Oxygen}}→回傳「8」
  • 輸入{{#invoke:Element|neutron|26}}→回傳「30」
  • 輸入{{#invoke:Element|neutron|水銀}}→回傳「122」
  • 輸入{{#invoke:Element|neutron|}}→回傳「122」
  • 輸入{{#invoke:Element|neutron|Tc}}→回傳「54」
  • 輸入{{#invoke:Element|neutron|61}}→回傳「84」
失敗則回傳空白
  • 輸入{{#invoke:Element|neutron|娜娜奇}}→回傳「」
  • 輸入{{#invoke:Element|neutron|168}}→回傳「」

protons

輸入一個與元素相關字串(如原子序、名稱、符號、別名等),回傳該元素的質子數,資料記載於Module:Element/data

  • 輸入{{#invoke:Element|protons|Oxygen}}→回傳「8」
  • 輸入{{#invoke:Element|protons|26}}→回傳「26」
  • 輸入{{#invoke:Element|protons|水銀}}→回傳「80」
  • 輸入{{#invoke:Element|protons|}}→回傳「80」
  • 輸入{{#invoke:Element|protons|Tc}}→回傳「43」
  • 輸入{{#invoke:Element|protons|61}}→回傳「61」
失敗則回傳空白
  • 輸入{{#invoke:Element|protons|娜娜奇}}→回傳「」
  • 輸入{{#invoke:Element|protons|168}}→回傳「168」

protons與neutron

結合protons與neutron可輸出質量數

  • 輸入{{#expr:{{#invoke:Element|protons|1=Oxygen}}+{{#invoke:Element|neutron|1=Oxygen}} }}→回傳「16」
  • 輸入{{#expr:{{#invoke:Element|protons|1=26}}+{{#invoke:Element|neutron|1=26}} }}→回傳「56」
  • 輸入{{#expr:{{#invoke:Element|protons|1=水銀}}+{{#invoke:Element|neutron|1=水銀}} }}→回傳「202」
  • 輸入{{#expr:{{#invoke:Element|protons|1=汞}}+{{#invoke:Element|neutron|1=汞}} }}→回傳「202」
  • 輸入{{#expr:{{#invoke:Element|protons|1=Tc}}+{{#invoke:Element|neutron|1=Tc}} }}→回傳「97」
  • 輸入{{#expr:{{#invoke:Element|protons|1=61}}+{{#invoke:Element|neutron|1=61}} }}→回傳「145」

getAtomicWeight

輸入一個與元素相關字串(如原子序、名稱、符號、別名等),回傳該元素的轉換標準原子量英语Standard_atomic_weight#Conventional atomic weight,資料記載於Module:Element/data

  • 輸入{{#invoke:Element|getAtomicWeight|Oxygen}}→回傳「15.999」
  • 輸入{{#invoke:Element|getAtomicWeight|26}}→回傳「55.845」
  • 輸入{{#invoke:Element|getAtomicWeight|水銀}}→回傳「200.592」
  • 輸入{{#invoke:Element|getAtomicWeight|}}→回傳「200.592」
  • 輸入{{#invoke:Element|getAtomicWeight|Tc}}→回傳「[97]」
  • 輸入{{#invoke:Element|getAtomicWeight|61}}→回傳「[145]」
失敗則回傳空白
  • 輸入{{#invoke:Element|getAtomicWeight|娜娜奇}}→回傳「」
  • 輸入{{#invoke:Element|getAtomicWeight|168}}→回傳「」

getName

輸入一個與元素相關字串(如原子序、名稱、符號、別名等),回傳該元素的元素名稱,資料記載於Module:Element/data

  • 輸入{{#invoke:Element|getName|26}}→回傳「鐵」
  • 輸入{{#invoke:Element|getName|水銀}}→回傳「汞」
  • 輸入{{#invoke:Element|getName|}}→回傳「汞」
例外狀況
  • 輸入{{#invoke:Element|getName|娜娜奇}}→回傳「未知的元素“娜娜奇”

getPhase

輸入一個與元素相關字串(如原子序、名稱、符號、別名等),回傳該元素的相態,值有可能是soild、gas、liquid或unknown四者其中之一,資料記載於Module:Element/data

  • 輸入{{#invoke:Element|getPhase|26}}→回傳「solid」
  • 輸入{{#invoke:Element|getPhase|水銀}}→回傳「liquid」
  • 輸入{{#invoke:Element|getPhase|}}→回傳「liquid」
  • 輸入{{#invoke:Element|getPhase|}}→回傳「gas」
  • 輸入{{#invoke:Element|getPhase|113}}→回傳「solid」
失敗則回傳空白
  • 輸入{{#invoke:Element|getPhase|娜娜奇}}→回傳「」
  • 輸入{{#invoke:Element|getPhase|168}}→回傳「unknown」

wikidataID

輸入一個與元素相關字串(如原子序、名稱、符號、別名等),回傳該元素的維基數據項目編號,資料記載於Module:Element/data

  • 輸入{{#invoke:Element|wikidataID|26}}→回傳「Q677」
  • 輸入{{#invoke:Element|wikidataID|水銀}}→回傳「Q925」
  • 輸入{{Q|{{#invoke:Element|wikidataID|26}}}}→回傳「 (Q677)
  • 輸入{{Q|{{#invoke:Element|wikidataID|水銀}}}}→回傳「 (Q925)

meltingPoint

輸入一個與元素相關字串(如原子序、名稱、符號、別名等),回傳該元素的熔點(單位為絕對溫標),資料記載於Module:Element/data

  • 輸入{{#invoke:Element|meltingPoint|26}}→回傳「1811」
  • 輸入{{#invoke:Element|meltingPoint|水銀}}→回傳「234.43」

boilingPoint

輸入一個與元素相關字串(如原子序、名稱、符號、別名等),回傳該元素的熔點(單位為絕對溫標),資料記載於Module:Element/data

  • 輸入{{#invoke:Element|boilingPoint|26}}→回傳「3134」
  • 輸入{{#invoke:Element|boilingPoint|水銀}}→回傳「629.88」

輸入一個與衰變方式相關字串,回傳該衰變方式的內部連結,資料記載於Module:Element/data

  • 輸入{{#invoke:Element|decaylink|γ衰變}}→回傳「γ

ElectronConfiguration

輸入一個與元素相關字串(如原子序、名稱、符號、別名等),回傳該元素的電子組態,資料記載於Module:Element/data

  • 輸入{{#invoke:Element|ElectronConfiguration|26}}→回傳「[Ar]3d64s2
  • 輸入{{#invoke:Element|ElectronConfiguration|水銀}}→回傳「[Xe]4f145d106s2

輸入一個與元素相關字串(如原子序、名稱、符號、別名等),回傳該元素的條目名稱(用於在導航模板提供直接連結,以使在對應條目顯示為粗體,達到導航效果),注意,使用getName可能會連結到重新導向頁,資料記載於Module:Element/data

  • 輸入[[{{#invoke:Element|link|26}}]]→回傳「
  • 輸入[[{{#invoke:Element|link|水銀}}]]→回傳「
  • 輸入[[{{#invoke:Element|link|}}]]→回傳「
  • 輸入[[{{#invoke:Element|link|}}]]→回傳「
  • 輸入[[{{#invoke:Element|link|113}}]]→回傳「
例外狀況
  • 輸入{{#invoke:Element|link|娜娜奇}}→回傳「未知的元素“娜娜奇”
  • 輸入{{#invoke:Element|link|元素}}→回傳「元素“元素”沒有對應的頁面。
  • 輸入{{#invoke:Element|link|168}}→回傳「元素“168”沒有對應的頁面。
使用getName
  • 輸入[[{{#invoke:Element|getName|}}]]→回傳「
  • 輸入[[{{#invoke:Element|link|}}]]→回傳「

輸入一個與元素相關字串(如原子序、名稱、符號、別名等),回傳顯示為該元素符號且指向該元素條目的內部連結,資料記載於Module:Element/data

  • 輸入{{#invoke:Element|elementlink|26}}→回傳「Fe
  • 輸入{{#invoke:Element|elementlink|水銀}}→回傳「Hg

check

當字串不是有效的元素名稱或「x」時,會顯示以下錯誤信息:

  • 輸入{{#invoke:Element|check|C}}→會顯示「」(正確無誤)
  • 輸入{{#invoke:Element|check|Carbon}}→會顯示「」(正確無誤)
  • 輸入{{#invoke:Element|check|}}→會顯示「」(正確無誤)
  • 輸入{{#invoke:Element|check|娜娜奇}}→會顯示「未知的元素“娜娜奇”
  • 輸入{{#invoke:Element|check|Blablabla}}→會顯示「未知的元素“Blablabla”

支持"link=yes"參數。如果元素或符號沒有對應的頁面,則錯誤信息如下:

  • 輸入{{#invoke:Element|check|C | link=yes}}→會顯示「」
  • 輸入{{#invoke:Element|check|Carbon | link=yes}}→會顯示「」
  • 輸入{{#invoke:Element|check|碳 | link=yes}}→會顯示「」(正確無誤)
  • 輸入{{#invoke:Element|check|X | link=yes}}→會顯示「元素“X”沒有對應的頁面。

如果所輸入的元素名稱不符合英文維基百科的拼寫規則,則會顯示以下錯誤信息:

  • 輸入{{#invoke:Element|check|Aluminum}}→會顯示「“Aluminum”不是“鋁”的正確拼法。
  • 輸入{{#invoke:Element|check|Sulphur}}→會顯示「“Sulphur”不是“硫”的正確拼法。
  • 輸入{{#invoke:Element|check|Sulfur}}→會顯示「」(正確無誤)
  • 輸入{{#invoke:Element|check|Cesium}}→會顯示「“Cesium”不是“銫”的正確拼法。

compare_series

比對兩個輸入是否屬於同一種元素分類。

  • 輸入{{#invoke:Element|compare_series|鹼金屬|鉀}}→回傳「yes」
  • 輸入{{#invoke:Element|compare_series|鹼金屬|氫}}→回傳「」
  • 輸入{{#invoke:Element|compare_series|鐵|金屬}}→回傳「yes」
  • 輸入{{#invoke:Element|compare_series|氯|鉀}}→回傳「」
  • 輸入{{#invoke:Element|compare_series|氯|氟}}→回傳「yes」
失敗回傳空白
  • 輸入{{#invoke:Element|compare_series|氯|娜娜奇}}→回傳「」

series

輸入一個與元素相關字串(如原子序、名稱、符號、別名等),回傳該元素主要的元素分類,資料記載於Module:Element/data

  • 輸入{{#invoke:Element|series|}}→回傳「非金屬」
  • 輸入{{#invoke:Element|series|}}→回傳「鹼金屬」
  • 輸入{{#invoke:Element|series|}}→回傳「類金屬」
  • 輸入{{#invoke:Element|series|}}→回傳「惰性氣體」
  • 輸入{{#invoke:Element|series|}}→回傳「過渡金屬」
  • 輸入{{#invoke:Element|series|}}→回傳「鑭系元素」
  • 輸入{{#invoke:Element|series|}}→回傳「官能基」
  • 輸入{{#invoke:Element|series|116}}→回傳「貧金屬(預測)」
  • 輸入{{#invoke:Element|series|119}}→回傳「鹼金屬(預測)」
  • 輸入{{#invoke:Element|series|9487}}→回傳「未知」

相關模板

核素模板是用來顯示核素同位素元素符號的,特別是用在化學公式當中。編者可以選擇加上指向對應頁面的鏈接。

以下為不同模板對碳-12的輸出效果,包括有鏈接的和沒有鏈接的:

模板名稱沒有鏈接有鏈接
{{Element}}
C

C
{{SimpleNuclide}}12
C
12
C
{{Nuclide}}12
6
C
12
6
C
{{ComplexNuclide}}12
6
C
6
12
6
C
6

參數

所有有關模板都是用同樣的參數。

1要輸出符號的元素名稱(中文、英文或符號)
2
(可選)
該同位素的質量數。
默認值為最常見或最穩定的同位素質量數。
3
(可選)
表示原子核在激發態時的同核異構體符號(「m」、「m2」等等)。
可以直接輸入這項選項,無需先輸入質量數。
link=yes
(可選)
自動加上指向相關元素或同位素頁面的鏈接。
許多同位素沒有單獨的頁面,請編者建立新頁面,或者重定向至「『某某元素』的同位素」頁面。
anti=yes
(可選)
表示該元素由反物質組成,因此需要在頂端標以橫線。
charge=...
(可選)
表示離子的電荷。
q=...
(可選)
指定該原子的數量(在化學公式中非常有用)。

例子

{{SimpleNuclide|Carbon}}12
C
{{SimpleNuclide|Carbon|14}}14
C
{{SimpleNuclide|碳|14}}14
C
{{SimpleNuclide|link=yes|Carbon}}12
C
{{SimpleNuclide|anti=yes|Carbon}}12
C
{{SimpleNuclide|link=yes|Carbon|14}}14
C
{{SimpleNuclide|Carbon|12|m}}12m
C
{{Element|Carbon|12|charge=2+}}
C2+
{{ComplexNuclide|link=yes|anti=yes|Carbon|12|m|charge=2+}}12m
6
C2+
6

包含的模板

  • 以上所有模板都使用{{ProtonsForElement}}來檢測元素名稱是否正確,而當link=yes參數被加入時,檢測是否使用統稱的元素名「X」或「element」。
  • 以上某些模板使用{{ProtonsForElement}}為某特定元素提取其原子序。
  • 以上某些模板使用{{NeutronsForElement}}為某特定元素提取其中子數
  • 以上某些模板使用{{ProtonsForElement}}和{{NeutronsForElement}}為某特定元素提取其質量數。
  • 以上所有模板都使用{{LinkForElement}},在link=yes參數被加入時加上鏈接。
  • 以上所有模板都使用{{PhysicsParticle}}為所有物理符號創建視覺上統一的HTML輸出。

錯誤使用

錯誤使用這些模板的頁面將會被加入分類:帶有錯誤格式模板的頁面。請定時查看分類並修改錯處。

以下為一些錯誤信息:

{{Nuclide |Blabla}}未知的元素“Blabla”
{{Nuclide |Aluminum}}“Aluminum”不是“鋁”的正確拼法。
{{Element |Element |link=yes}}元素“Element”沒有對應的頁面。

模板编辑说明

若要調整本模板的內容請至Module:Element/data編輯

編輯時請按照下面格式,以為例,其中參數有大小寫敏感,大小寫要跟下列示例一致
{name='鎝',isotopePage='鎝的同位素',page='锝',stability={stableCount=0,halflife=1.3276656e14},Symbol='Tc',period=5, group=7, block='d',series={'過渡金屬','金屬'},Z=43,N=56,Melting=2430,Boiling=4538,othername={'Tc','tc','technetium','Technetium','鎝','鍀','锝'},Isotope={{N=56,name='鎝-99m',page='鎝-99m'}{N=56,name='鎝-99'}},wikidata=1054,density=11,atomicRadius=136,CovalentRadius=147,vdwRadius="nan",EN=1.9,EC={{2},{2,6},{2,6,10},{2,6,5},{2},cen="Kr"}}
參數名稱意義說明範例
(以為主)
備註
name元素名稱這是本資料表的key,應先到先得,請勿竄改,
否則部分模板將會出現查無資料類的錯誤
'鎝'
page元素條目名稱元素的條目名稱,請使用未繁簡轉換的原始條目名
(否則連到頁面的鏈接在條目中不會變成粗體)
''
isotopePage同位素條目名稱同位素的條目名稱,請使用未繁簡轉換的原始條目名
(否則連到頁面的鏈接在條目中不會變成粗體)
'鎝的同位素'
stability元素穩定資訊
stability={stableCount=0,halflife=1.3276656e14},
stability={
stableCount
}
穩定同位素的數量0
stability={
halflife
}
最穩定同位素的半衰期以秒為單位。若有同位素穩定請不要寫此參數1.3276656e14
Symbol元素符號'Tc'開頭字母大寫
period週期元素的週期,整數
用於確定元素在週期表的位置
5
group元素的族,整數
用於確定元素在週期表的位置
7
block元素分區元素的區
用於確定元素在週期表的位置
'd'
series元素種類元素的種類/系列
Z原子序
N中子數主同位素的中子數
stdAtomicWeight標準原子量元素的標準原子質量英语Standard atomic weight

以氦為例

stdAtomicWeight={4.002602}

以氫為例

stdAtomicWeight={1.00784, 1.00811}
未填即使用Z和N推算
並標記為未確定特性
Melting熔點熔點,單位為絕對溫度2430
Boiling沸點沸點,單位為絕對溫度4538
othername別名能夠表示此種元素的各種別名。
Isotope同位素同位素列表,以有條目存在的為主。
Isotope={{N=56,name='鎝-99m',page='鎝-99m'}{N=56,name='鎝-99'}},
wikidata維基數據項目元素條目的維基數據項目。wikidata=1054
density密度密度,單位為g/cm³11
atomicRadius原子半径原子半径,單位為皮米136
CovalentRadius共价半径共价半径,單位為皮米147
vdwRadius范德华半径范德华半径,單位為皮米
EN電負度电负性,單位為鮑林標度1.9
EC電子組態電子組態,表達方式為{{1s},{2s,2p},{3s,3p,3d}...,cen="內層元素"}{{2}, {2,6}, {2,6,10}, {2,6,5}, {2}, cen="Kr"}

local p = {}local origArgslocal lib_arg = {}local error = require( 'Module:Error' )local lib_EC = {}local element_data = mw.loadData( 'Module:Element/data' )local series_name_data = {{"錒系元素", "锕系元素", "錒系金屬", "锕系金属", "actinide"},{"鹼金屬", "碱金属", "alkali metal"},{"鹼金屬(預測)", "碱金属(预测)", "alkali metal (predicted)"},{"鹼土金屬", "碱土金属", "alkaline earth metal"},{"鹼土金屬(預測)", "碱土金属(预测)", "alkaline earth metal (predicted)"},{"雙原子非金屬", "双原子非金属", "diatomic nonmetal"},{"雙原子非金屬(預測)", "双原子非金属(预测)", "diatomic nonmetal (predicted)"},{"多原子非金屬", "多原子非金属", "polyatomic nonmetal"},{"多原子非金屬(預測)", "多原子非金属(预测)", "polyatomic nonmetal (predicted)"},{"eka-超錒系元素", "eka-超锕系元素", "下超錒系元素", "eka-superactinide"},{"eka-超錒系元素(預測)", "eka-超锕系元素(预测)", "eka-superactinide (predicted)"},{"惰性氣體", "惰性气体", "稀有氣體", "稀有气体", "noble gas"},{"惰性氣體(預測)", "惰性气体(预测)", "稀有氣體(預測)", "稀有气体(预测)", "noble gas (predicted)"},{"鹵素", "卤素", "halogen"},{"鹵素(預測)", "卤素(预测)", "halogen (predicted)"},{"金屬", "金属", "metal"},{"類金屬", "类金属", "metalloid"},{"類金屬(預測)", "类金属(预测)", "metalloid (predicted)"},{"鑭系元素", "镧系元素", "鑭系金屬", "镧系金属", "lanthanide"},{"其他非金屬", "其他非金属", "非金属", "非金屬", "other non-metal"},{"其他非金屬(預測)", "其他非金属(预测)", "非金屬(預測)", "other non-metal (predicted)"},{"貧金屬", "贫金属", "主族金屬", "主族金属", "post-transition metal"},{"貧金屬(預測)", "贫金属(预测)", "主族金屬(預測)", "主族金属(预测)", "post-transition metal (predicted)"},{"超錒系元素", "超锕系元素", "superactinide"},{"超錒系元素(預測)", "超锕系元素(预测)", "superactinide (predicted)"},{"過渡金屬", "过渡金属", "过渡元素", "過渡元素", "transition metal"},{"過渡金屬(預測)", "过渡金属(预测)", "过渡元素(预测)", "過渡元素(預測)", "transition metal (predicted)"},{"超臨界原子", "離子態", "超临界原子", "离子态", "supercritical atoms", "supercritical atoms (predicted)"},{"無電子", "无电子", "no electron"},{"可能不存在", "maybe not exist"},{"s區元素", "s区元素", "s區", "s区", "s block"},{"s區元素(預測)", "s区元素(预测)", "s區(預測)", "s区(预测)", "s block (predicted)"},{"p區元素", "p区元素", "p區", "p区", "p block"},{"p區元素(預測)", "p区元素(预测)", "p區(預測)", "p区(预测)", "p block (predicted)"},{"d區元素", "d区元素", "d區", "d区", "d block"},{"d區元素(預測)", "d区元素(预测)", "d區(預測)", "d区(预测)", "d block (predicted)"},{"ds區元素", "ds区元素", "ds區", "ds区", "ds block"},{"ds區元素(預測)", "ds区元素(预测)", "ds區(預測)", "ds区(预测)", "ds block (predicted)"},{"f區元素", "f区元素", "f區", "f区", "f block"},{"f區元素(預測)", "f区元素(预测)", "f區(預測)", "f区(预测)", "f block (predicted)"},{"g區元素", "g区元素", "g區", "g区", "g block"},{"g區元素(預測)", "g区元素(预测)", "f區(預測)", "g区(预测)", "g block (predicted)"},{"h區元素", "h区元素", "h區", "h区", "h block"},{"h區元素(預測)", "h区元素(预测)", "h區(預測)", "h区(预测)", "h block (predicted)"},{"未知特性", "未知", "化學性質未知", "化学性质未知", "unknown", "unknown chemical properties"}}function p.symbol(frame)return p._symbol(p._loadArgFromFrame(frame))endfunction p.getAtomicWeight(frame)return p._getAtomicWeight(p._loadArgFromFrame(frame))endfunction p.getName(frame)return p._getName(p._loadArgFromFrame(frame))endfunction p.getPhase(frame)return p._getPhase(p._loadArgFromFrame(frame))endfunction p.link(frame)return p._link(p._loadArgFromFrame(frame))endfunction p.check(frame)return p._check(p._loadArgFromFrame(frame))endfunction p.neutron(frame)return p._neutron(p._loadArgFromFrame(frame))endfunction p._neutron(args)--去除模板引用時可能產生的空格local eleString='' if (args[1] and args[1] ~= '') then eleString = mw.text.trim(args[1]) else return '' endlocal eleid = p.getListID(eleString)local ele1 = p._copytable(element_data[eleid])if (eleid==-1) thenreturn ''endif (ele1.correct and ele1.correct  ~= '') thenreturn ''endif (ele1.N and ele1.N ~= '') thenreturn ele1.Nendreturn ''endfunction p.compare_series(frame)-- For calling from #invoke.    local load_args    if frame == mw.getCurrentFrame() then        -- We're being called via #invoke. The args are passed through to the module        -- from the template page, so use the args that were passed into the template.        if lib_arg.getArgs == nil then lib_arg = require('Module:Arguments') end        load_args = lib_arg.getArgs(frame) --frame.args    else        -- We're being called from another module or from the debug console, so assume        -- the args are passed in directly.        load_args = frame    endlocal args = {}for k, v in pairs( load_args ) doargs[k] = v;   endlocal arg1=''if (args[1] and args[1] ~= '') thenarg1 = mw.text.trim(args[1]) endlocal arg2=''if (args[2] and args[2] ~= '') thenarg2 = mw.text.trim(args[2]) endreturn p.compareSeries(arg1, arg2)endfunction p.compareSeries(series1, series2)local checked = falselocal series_left, eleSeriesfor v, x in ipairs(series_name_data) dofor v1, x1 in ipairs(x) doif (x1 == series1) then series_left = {x[1]}checked = truebreakendendif checked then break endendif not checked theneleSeries = p.getSeries({series1})eleSeries = mw.text.split( table.concat(eleSeries, ',') .. ',' .. series1 , ',' ) for index, it in ipairs(eleSeries) dochecked = falsefor v, x in ipairs(series_name_data) dofor v1, x1 in ipairs(x) doif (x1 == it) then eleSeries[index] = x[1]checked = truebreakendendif checked then break endendendseries_left = eleSeriesendchecked = falsefor v, x in ipairs(series_name_data) dofor v1, x1 in ipairs(x) doif (x1 == series2) then series_right = {x[1]}checked = truebreakendendif checked then break endendif not checked theneleSeries = p.getSeries({series2})eleSeries = mw.text.split( table.concat(eleSeries, ',') .. ',' .. series2 , ','  ) for index, it in ipairs(eleSeries) dochecked = falsefor v, x in ipairs(series_name_data) dofor v1, x1 in ipairs(x) doif (x1 == it) then eleSeries[index] = x[1]checked = truebreakendendif checked then break endendendseries_right = eleSeriesendif series_left.predicted then series_left.predicted = nil endif series_right.predicted then series_right.predicted = nil endfor v_left, x_left in ipairs(series_left) dofor v_right, x_right in ipairs(series_right) doif mw.text.trim(x_left) == mw.text.trim(x_right) then return 'yes' endendendif series_left == series_right then return 'yes' endreturn ''endfunction p.series(frame)-- For calling from #invoke.    local load_args    if frame == mw.getCurrentFrame() then        -- We're being called via #invoke. The args are passed through to the module        -- from the template page, so use the args that were passed into the template.        if lib_arg.getArgs == nil then lib_arg = require('Module:Arguments') end        load_args = lib_arg.getArgs(frame) --frame.args    else        -- We're being called from another module or from the debug console, so assume        -- the args are passed in directly.        if type(frame) ~= type({}) then args = {frame}        else args = frame end    endlocal args = {}for k, v in pairs( load_args ) doargs[k] = v;   endlocal eleSeries = p.getSeries(args)if (eleSeries.predicted) then return eleSeries[1] .. '(預測)' endreturn eleSeries[1]endfunction p.getSeries(args)--去除模板引用時可能產生的空格local eleString='' if (args[1] and args[1] ~= '') then eleString = mw.text.trim(args[1]) else return {'錯誤'} endlocal eleid = p.getListID(eleString)local ele1 = p._copytable(element_data[eleid])if (eleid==-1) then return {'未知'} endif (ele1.correct and ele1.correct  ~= '') theneleid = p.getListID(ele1.correct)ele1 = p._copytable(element_data[eleid])if (eleid==-1) then return {'未知'} endendif (ele1.series and ele1.series ~= '') thenif (ele1.predictedSeries and ele1.predictedSeries ~= '') then ele1.series.predicted=1 endreturn ele1.seriesendreturn {'錯誤'}endfunction p.protons(frame)return p._protons(p._loadArgFromFrame(frame))endfunction p._protons(args)--去除模板引用時可能產生的空格local eleString='' if (args[1] and args[1] ~= '') then eleString = mw.text.trim(args[1]) else return '' endlocal eleid = p.getListID(eleString)local ele1 = p._copytable(element_data[eleid])if (eleid==-1) thenreturn ''endif (ele1.correct and ele1.correct  ~= '') thenreturn ''endif (ele1.Z and ele1.Z ~= '') thenreturn ele1.Zendreturn ''endfunction p.wikidataID(frame)    local result = p._wikidataID(p._loadArgFromFrame(frame))    if result ~= '' then result = 'Q' .. result endreturn resultendfunction p._wikidataID(args)--去除模板引用時可能產生的空格local eleString='' if (args[1] and args[1] ~= '') then eleString = mw.text.trim(args[1]) else return '' endlocal eleid = p.getListID(eleString)local ele1 = p._copytable(element_data[eleid])if (eleid==-1) thenreturn ''endif (ele1.wikidata and ele1.wikidata ~= '') thenreturn ele1.wikidataendreturn ''endfunction p.ElementProperty(frame)return p._getEleProperty(p._loadArgFromFrame(frame))endfunction p.meltingPoint(frame)return p._getEleProperty(p._loadArgFromFrame(frame),"Melting")endfunction p.boilingPoint(frame)return p._getEleProperty(p._loadArgFromFrame(frame),"Boiling")endfunction p.density(frame)return p._getEleProperty(p._loadArgFromFrame(frame),"density")endfunction p.atomicRadius(frame)return p._getEleProperty(p._loadArgFromFrame(frame),"atomicRadius")endfunction p.covalentRadius(frame)return p._getEleProperty(p._loadArgFromFrame(frame),"CovalentRadius")endfunction p.vdwRadius(frame)return p._getEleProperty(p._loadArgFromFrame(frame),"vdwRadius")endfunction p.electronegativity(frame)return p._getEleProperty(p._loadArgFromFrame(frame),"EN")endfunction p._loadArgFromFrame(frame)-- For calling from #invoke.    local args    if frame == mw.getCurrentFrame() then        -- We're being called via #invoke. The args are passed through to the module        -- from the template page, so use the args that were passed into the template.        if lib_arg.getArgs == nil then lib_arg = require('Module:Arguments') end        args = lib_arg.getArgs(frame) --frame.args    else        -- We're being called from another module or from the debug console, so assume        -- the args are passed in directly.        if type(frame) ~= type({}) then args = {frame}        else args = frame end    end    return argsendfunction p._getEleProperty(args, _prop)local prop = _propif _prop==nil then prop = args[2] or args.propif prop == nil then return ''else prop = mw.text.trim(prop) endendlocal eleString='' if type(args) == type("string") or type(args) == type(0) then eleString = mw.text.trim(tostring(args)) elseif (args[1] and args[1] ~= '') then eleString = mw.text.trim(args[1]) else return '' end --去除模板引用時可能產生的空格local eleid = p.getListID(eleString)local ele1 = p._copytable(element_data[eleid])if (eleid==-1) thenreturn ''endif (ele1[prop] and ele1[prop] ~= '') thenreturn ele1[prop]endreturn ''endfunction p._getName(args)--去除模板引用時可能產生的空格local eleString='' if (args[1] and args[1] ~= '') then eleString = mw.text.trim(args[1]) else return error.error{ '未輸入元素' } endlocal eleid = p.getListID(eleString)local ele1 = p._copytable(element_data[eleid])if (eleid==-1) thenreturn error.error{ '未知的元素“' .. args[1] .. '”' } .. '[[Category:含有錯誤元素符號的條目]]'endreturn ele1.nameendfunction p._check(args)--去除模板引用時可能產生的空格local eleString='' if (args[1] and args[1] ~= '') then eleString = mw.text.trim(args[1]) else return error.error{ '未輸入元素' } endlocal linkString='' if (args['link'] and args['link'] ~= '') thenlinkString = mw.text.trim(args['link']) endif (linkString and linkString  ~= '') thenif (linkString == 'yes') thenpagetest=trueendendlocal eleid = p.getListID(eleString)local ele1 = p._copytable(element_data[eleid])if (eleid==-1) thenreturn error.error{ '未知的元素“' .. args[1] .. '”' } .. '[[Category:含有錯誤元素符號的條目]]'endif (ele1.correct and ele1.correct  ~= '') thenreturn error.error{ '“' .. args[1] .. '”不是“'.. ele1.correct .. '”的正確拼法。' }endif (ele1.page and ele1.page ~= '') thenreturn ''endif(pagetest)thenreturn error.error{ '元素“' .. args[1] .. '”' .. '沒有對應的頁面。'}elsereturn ''endendfunction p._symbol(args)if not(args[1] and args[1] ~= '') then return error.error{ '未輸入元素' } endlocal myString = mw.text.trim(args[1]) --去除模板引用時可能產生的空格local eleid = p.getListID(myString)if (eleid==-1) thenif(tonumber(myString) or -1 > 0)thenlocal ele_tmp = p.getElementByZ(tonumber(myString))if(ele_tmp and ele_tmp.Symbol)then return ele_tmp.Symbol endendreturn error.error{ '未知的元素“' .. args[1] .. '”' } .. '[[Category:含有錯誤元素符號的條目]]'endlocal ele1 = p._copytable(element_data[eleid])if(ele1.NotElement)thenreturn ele1.Symbolendif (ele1.Z == nil) then return ele1.Symbol endlocal num = ele1.Z + (ele1.N or 0) --計算質量數local n = (ele1.N or 0)local number=tonumber(args[2])if (number and number  ~= '') thennum = numbern = num - ele1.Zif (n > 0) then --讀到有效的原子量才會進來這裡執行if (ele1.Isotope) thenfor v, x in ipairs(ele1.Isotope) doif (x.N == n) thenif (x.Symbol and x.Symbol  ~= '') thenreturn x.Symbolendendendendendendreturn ele1.Symbol endfunction p._link(args)--去除模板引用時可能產生的空格local arg1=''if (args[1] and args[1] ~= '') thenarg1 = mw.text.trim(args[1]) else return error.error{ '未輸入元素' } endlocal arg2=''if (args[2] and args[2] ~= '') thenarg2 = mw.text.trim(args[2]) endlocal arg3=''if (args[3] and args[3] ~= '') thenarg3 = mw.text.trim(args[3]) endlocal eleid = p.getListID(arg1)local has_m=''if (arg3 and arg3  ~= '') thenhas_m=arg3endif (eleid == -1) thenreturn error.error{ '未知的元素“' .. arg1 .. '”' } .. '[[Category:含有錯誤元素符號的條目]]'endlocal ele1 = p._copytable(element_data[eleid])if(ele1.NotElement)thenreturn ele1.pageendif (ele1.page and ele1.page  ~= '') thenlocal num = ele1.Z + (ele1.N or 0) --計算質量數local n = ele1.Nlocal hasmass=falselocal number=tonumber(arg2)if (number and number  ~= '') thennum = numbern = num - ele1.Zhasmass=trueif (n < 0) thenreturn error.error{ '中子數不得為“' .. n .. '”' }endelseif (args2 and args2 ~= '') thenreturn error.error{ '未知的質量數“' .. args2 .. '”' }endendif (hasmass == true) thenif (ele1.Isotope) thenfor v, x in ipairs(ele1.Isotope) doif (x.N == n) thenif (x.page and x.page  ~= '') thenreturn  x.pageelsereturn error.error{ '元素“' .. args[1] .. '”' .. '質量數為“'.. num  ..'”的同位素沒有對應的頁面。'}endendendreturn ele1.page .. '-' .. num .. has_mendendreturn ele1.page endreturn error.error{ '元素“' .. args[1] .. '”' .. '沒有對應的頁面。'}end--This notation states that the various sources on Earth have substantially different isotopic constitutions, and uncertainties are incorporated in the two numbers. For these elements, there is not an 'Earth average' constitution, and the 'right' value is not its middle p.conventional_atomic_weight={H=1.008,Li=6.941,B=10.81,C=12.011,N=14.007,O=15.999,Mg=24.305,Si=28.085,S=32.04,Cl=35.45,Ar=39.948,Br=79.904,Tl=204.38}function p._get_atomic_weight(element)if (element) thenif(type(element.stdAtomicWeight) == type(0))then return element.stdAtomicWeight , trueelseif(p.conventional_atomic_weight[element.Symbol or ''])then return p.conventional_atomic_weight[element.Symbol or ''] , true endif(type(element.stdAtomicWeight) == type({0,0}))then return element.stdAtomicWeight[1] , true endendif (element.Z and element.N) then return (element.Z + element.N) , false endendreturn nilendfunction p._getAtomicWeight(args)--去除模板引用時可能產生的空格local eleString='' if (args[1] and args[1] ~= '') then eleString = mw.text.trim(args[1]) else return '' endlocal eleid = p.getListID(eleString)local ele1 = p._copytable(element_data[eleid])if (eleid==-1) thenreturn ''endlocal Weight, is_natural = p._get_atomic_weight(ele1)if Weight thenif is_natural ~= true thenreturn '[' .. Weight ..']'endreturn Weightendreturn ''endfunction p._get_phase(element, temperature)local test_temperature = temperature or 298.15 --STPif (element) thenif element.Melting thenif element.Melting > test_temperature then --STPreturn "solid"endendif element.Boiling thenif element.Boiling > test_temperature then --STPreturn "liquid"elsereturn "gas"endendendreturn nilendfunction p._getPhase(args)--去除模板引用時可能產生的空格local eleString='' if (args[1] and args[1] ~= '') then eleString = mw.text.trim(args[1]) else return '' endlocal temperature= 298.15 if (args[2] and args[2] ~= '') then temperature = tonumber( mw.text.trim(args[2]) ) or 298.15 endlocal eleid = p.getListID(eleString)local ele1 = p._copytable(element_data[eleid])if (eleid==-1) thenreturn ''endreturn p._get_phase(ele1) or 'unknown'endfunction p.getListID(_names)local names = _namesif type(_names)==type({})thenif type(_names.args)==type({})thennames = _names.args['1'] or _names.args[1]elseif _names['1'] or _names[1] or _names.name thennames = _names['1'] or _names[1] or _names.nameendendlocal body ='' if tonumber(names) or type(names) == type(0) thenlocal index = tonumber(names)for v, x in ipairs(element_data) do                                if (x.Z == index) thenreturn  vendendendi=1for v, x in ipairs(element_data) do                                if ((x.name == names) or (x.page == names)) thenreturn  iendfor v1, x1 in ipairs(x.othername) doif (x1 == names) thenreturn  iendendi=i+1endreturn -1 endfunction p.decaylink(frame)return p._decaylink(p._loadArgFromFrame(frame))endfunction p.elementlink(frame)return p._elementlink(p._loadArgFromFrame(frame))endfunction p._elementlink(args)local arg1=''if (args[1] and args[1] ~= '') thenarg1 = mw.text.trim(args[1]) else return '' endlocal arg2=''if (args[2] and args[2] ~= '') thenarg2 = mw.text.trim(args[2]) endlocal eleid = p.getListID(arg1)if (eleid==-1) thenreturn error.error{ '未知的元素“' .. arg1 .. '”' } .. '[[Category:含有錯誤元素符號的條目]]'endlocal ele1 = p._copytable(element_data[eleid])local symbol1=ele1.Symbolif(arg2 and arg2 ~= '')then if(arg2 ~= '1' )thenif (ele1.compound)then symbol1 ='(' .. symbol1 .. ')' endsymbol1 = symbol1 .. '<sub>' .. arg2 .. '</sub>'end endif (ele1.compound)thenreturn '[[' .. ele1.page .. '|' .. symbol1 .. ']]'endif (ele1.NotElement)thenreturn error.error{ '“' .. args[1] .. '”不是元素。'}endif (ele1.correct and ele1.correct  ~= '') thenreturn error.error{ '“' .. args[1] .. '”不是“'.. ele1.correct .. '”的正確拼法。' }endif (ele1.page and ele1.page  ~= '') thenreturn '[[' .. ele1.page .. '|' .. symbol1 .. ']]'elsereturn error.error{ '元素“' .. args[1] .. '”沒有對應的頁面。'}endreturn ''endfunction p._element_symbol(args)local arg1=''if (args[1] and args[1] ~= '') thenarg1 = mw.text.trim(args[1]) else return '' endlocal arg2=''if (args[2] and args[2] ~= '') thenarg2 = mw.text.trim(args[2]) endlocal eleid = p.getListID(arg1)if (eleid==-1) thenreturn error.error{ '未知的元素“' .. arg1 .. '”' } .. '[[Category:含有錯誤元素符號的條目]]'endlocal ele1 = p._copytable(element_data[eleid])local symbol1=ele1.Symbolif(arg2 and arg2 ~= '')then if(arg2 ~= '1' )thenif (ele1.compound)then symbol1 ='(' .. symbol1 .. ')' endsymbol1 = symbol1 .. '<sub>' .. arg2 .. '</sub>'end endif (ele1.compound)thenreturn symbol1endif (ele1.NotElement)thenreturn error.error{ '“' .. args[1] .. '”不是元素。'}endif (ele1.correct and ele1.correct  ~= '') thenreturn error.error{ '“' .. args[1] .. '”不是“'.. ele1.correct .. '”的正確拼法。' }endif (ele1.page and ele1.page  ~= '') thenreturn symbol1elsereturn error.error{ '元素“' .. args[1] .. '”沒有對應的頁面。'}endreturn ''endfunction p._decaylink(args)local arg1=''if (args[1] and args[1] ~= '') thenarg1 = mw.text.trim(args[1]) else return '' endif(arg1=='p') then arg1='p+'end if(arg1=='n') then arg1='n0'endlocal decayid = p.getListID(arg1)if (decayid==-1) thenreturn ''endlocal decay1 = p._copytable(element_data[decayid])if (decay1.decay)thenreturn '[[' .. decay1.page .. '|' .. decay1.Symbol .. ']]'endreturn ''endp.IUPAC = { [0] = 'n', [1] = 'u', [2] = 'b', [3] = 't', [4] = 'q', [5] = 'p', [6] = 'h', [7] = 's', [8] = 'o', [9] = 'e' }p.IUPAC_name = { [0] = 'nil', [1] = 'un', [2] = 'bi', [3] = 'tri', [4] = 'quad', [5] = 'pent', [6] = 'hex', [7] = 'sept', [8] = 'oct', [9] = 'enn', [10] = 'ium', [11] = 'um' }function p.DecodeByIUPAC_rules(symbol_data)local symbol = mw.ustring.lower(symbol_data)local symbol_len = mw.ustring.len(symbol)local Z_data = ''for i = 1, symbol_len dolocal get_id = nilfor j = 0, 9 do if mw.ustring.sub(symbol ,i, i) == p.IUPAC[j] then get_id = j end endif get_id == nil then return nil endZ_data = Z_data .. get_idendreturn tonumber(Z_data)endfunction p.outputLuaListTemplate()local body=''for _, ele in ipairs(element_data) dobody = body .. "\t[\"" .. ele.name .. "\"] = {  },\n"endreturn "{\n" .. body .. '}'endfunction p.getElementByIUPAC_rules(index_input)local result = ''local result_name = ''local index = tonumber(index_input)if index ~= nil then index = math.floor(index) else index = 0 endlocal index_str = '' .. indexlocal index_len = mw.ustring.len(index_str)if index > 100 thenfor i = 1, index_len dolocal data = p.IUPAC[tonumber('' .. mw.ustring.sub(index_str ,i, i)) or 0]local name = p.IUPAC_name[tonumber('' .. mw.ustring.sub(index_str ,i, i)) or 0]if i == 1 then result = result .. mw.ustring.upper(data)result_name = result_name .. mw.ustring.upper(mw.ustring.sub(name,1,1)) .. mw.ustring.sub(name,2,-1)elseresult = result .. dataresult_name = result_name .. nameendendendif result == '' thenreturn nilendlocal result_name_index = 11 if mw.ustring.sub(result_name,-1,-1) ~= 'i' then result_name_index = result_name_index - 1 endreturn { name=result_name .. p.IUPAC_name[result_name_index] , page=result, Symbol=result, Z=index }endfunction p.getElementByZ(index)local body =''         for v, x in ipairs(element_data) do                                if (x.Z == index) thenreturn p._copytable(x)endendif index > 0 thenreturn p._copytable(p.getElementByIUPAC_rules(index))endreturn nil endfunction p.next_element(symbol)local eleid = p.getListID(symbol)local ele1 = p._copytable(element_data[eleid])if ele1 == nil then ele_z = p.DecodeByIUPAC_rules(symbol) else if ele1.Z == nil thenele_z = p.DecodeByIUPAC_rules(symbol) else ele_z = ele1.Z endendif ele_z ~= nil thenreturn p.getElementByZ(ele_z + 1)endreturn nilendfunction p.last_element(symbol)local eleid = p.getListID(symbol)local ele1 = p._copytable(element_data[eleid])if ele1 == nil then ele_z = p.DecodeByIUPAC_rules(symbol) else if ele1.Z == nil thenele_z = p.DecodeByIUPAC_rules(symbol) else ele_z = ele1.Z endendif ele_z ~= nil thenreturn p.getElementByZ(ele_z - 1)endreturn nilendfunction p._copytable(input_table)local output_tableif type(input_table) == type({}) thenoutput_table = {}for k,v in pairs(input_table) dolocal tempif type(input_table) == type({}) thentemp = mw.clone(p._copytable(v))elseif type(input_table) == type(tonumber) thenelsetemp = mw.copy(v)endoutput_table[k]=tempendelseif type(input_table) == type(tonumber) then--do nothingelseoutput_table = mw.clone(input_table)endreturn output_tableendfunction p.ElectronConfiguration(frame)if type(lib_EC.ElectronConfiguration) ~= type(function()end) then lib_EC = require( 'Module:Element/ElectronConfiguration' ) endreturn lib_EC.ElectronConfiguration(frame)endfunction p._ElectronConfiguration(args)if type(lib_EC._ElectronConfiguration) ~= type(function()end) then lib_EC = require( 'Module:Element/ElectronConfiguration' ) endreturn lib_EC._ElectronConfiguration(args)endfunction p.htmleleconf(eleconf, showall)if type(lib_EC._eleconftostring) ~= type(function()end) then lib_EC = require( 'Module:Element/ElectronConfiguration' ) endreturn lib_EC._eleconftostring(eleconf, showall)end--本模塊的沙盒(測試)函數function p.sandbox(frame)-- For calling from #invoke.    local args    if frame == mw.getCurrentFrame() then        -- We're being called via #invoke. The args are passed through to the module        -- from the template page, so use the args that were passed into the template.        if lib_arg.getArgs == nil then lib_arg = require('Module:Arguments') end        args = lib_arg.getArgs(frame) --frame.args    else        -- We're being called from another module or from the debug console, so assume        -- the args are passed in directly.        args = frame    endreturn p._elementlink(args)endfunction p._sandbox(args)return element_data[p.getListID(args[1])].name endreturn p