编辑“︁
Module:Element/ElectronConfiguration
”︁
跳转到导航
跳转到搜索
警告:
您没有登录。如果您进行任何编辑,您的IP地址会公开展示。如果您
登录
或
创建账号
,您的编辑会以您的用户名署名,此外还有其他益处。
反垃圾检查。
不要
加入这个!
local p={} local lib_arg = {} local eleconfdata = {'s','p','d','f','g','h','i','k','l','m','n','o'} local element_main_data = mw.loadData("Module:Element/data") local element_lib = require("Module:Element") local utils = require( 'Module:PeriodicTable/utils' ) function p.ElectronConfiguration(frame) return p._ElectronConfiguration(element_lib._loadArgFromFrame(frame)) end local yesno = nil function p._ElectronConfiguration(args) --去除模板引用時可能產生的空格 local eleString='' if (args[1] and args[1] ~= '') then eleString = mw.text.trim(args[1]) else return '' end local eleid = element_lib.getListID(eleString) local ele1 = p._copytable(element_main_data[eleid]) if (eleid==-1) then return '' end if (ele1.correct and ele1.correct ~= '') then return '' end local display_all = false if args["displayAll"] then if type(yesno) ~= type(tonumber) then yesno = require('Module:Yesno') end display_all = yesno(args["displayAll"] or 'no') end if (ele1.Z and ele1.Z ~= '') then return p._eleconftostring(ele1.EC, display_all) end return '' end function p._copytable(input_table) local output_table if type(input_table) == type({}) then output_table = {} for k,v in pairs(input_table) do local temp if type(input_table) == type({}) then temp = mw.clone(p._copytable(v)) elseif type(input_table) == type(tonumber) then else temp = mw.copy(v) end output_table[k]=temp end elseif type(input_table) == type(tonumber) then --do nothing else output_table = mw.clone(input_table) end return output_table end function p._eleconftostring(eleconf, showall) local cen = eleconf.cen or '' local ceneledata if cen ~= '' then local eleid = element_lib.getListID(cen) ceneledata = p._copytable(element_main_data[eleid]) end if not ceneledata then ceneledata = p._copytable(element_main_data[2]) end local elecdis = '' for _period, eles in ipairs(eleconf) do local elecstr = '' local period = _period local shell_length = math.ceil((_period+1)/2) if not(showall == true) then --不顯示全部 照原始順序與數量 shell_length = #eles end for shell_it=1,shell_length do if showall == true then --顯示全部: 能級交錯 (s,t不變,其餘-2,如7s 7p 6d 5f) period = _period - math.max(shell_it - 2,0) end --不顯示全部: 原樣 if eleconf[period][shell_it] then local shell = shell_it local elecount = eleconf[period][shell_it] if type(elecount) == type({}) then--亞軌域 for shell_id, shell_ent in ipairs(elecount) do local shellstr = '' local shell_name = shell_ent[2] local shell_elecount = shell_ent[1] local valence = shell_elecount local censhell_ent = ((ceneledata.EC[period] or {})[shell] or {{0,''}})[shell_id] --尋找同名亞軌域 local shell_ent_check = (ceneledata.EC[period] or {})[shell] if type(shell_ent_check) == type({}) then for subshell_id, subshell_ent in ipairs(shell_ent_check) do if subshell_ent[2] == shell_name then censhell_ent = {subshell_ent[1],subshell_ent[2]} break end end else censhell_ent = {shell_ent_check,''} end if not(showall == true) then valence = valence - ((censhell_ent or {})[1] or 0) end if valence > 0 then local frame = mw.getCurrentFrame() --{{su|p=2|b=1/2}} shellstr = tostring(period) .. eleconfdata[shell] .. frame:expandTemplate{ title = 'su', args = { p=tostring(valence), b=tostring(shell_name) } } elecstr = elecstr .. shellstr end end else local shellstr = '' local valence = elecount if not(showall == true) then local subshell_name = '' local shell_ent = (ceneledata.EC[period] or {})[shell] if type(shell_ent) == type({}) then--亞軌域 for subshell_id, subshell_ent in ipairs(shell_ent) do if subshell_ent[2] == subshell_name then shell_ent = subshell_ent[1] break end end end valence = valence - (shell_ent or 0) end if valence > 0 then shellstr = tostring(period) .. eleconfdata[shell] .. '<sup>' .. tostring(valence) .. '</sup>' elecstr = elecstr .. shellstr end end end end elecdis = elecdis .. elecstr end if cen ~= '' and not(showall == true) then elecdis = '[' .. cen .. ']' .. elecdis end return elecdis end function p.ElectronShell(frame) return p._electronShell(element_lib._loadArgFromFrame(frame)) end function p._electronShell(args) --去除模板引用時可能產生的空格 local eleString='' if (args[1] and args[1] ~= '') then eleString = mw.text.trim(args[1]) else return '' end local eleid = element_lib.getListID(eleString) local ele1 = p._copytable(element_main_data[eleid]) if (eleid==-1) then return '' end if (ele1.correct and ele1.correct ~= '') then return '' end local comma = ',' if args["comma"] and args["comma"]~='' then comma = args["comma"] or comma end if (ele1.Z and ele1.Z ~= '') then return p._eleshelltostring(ele1.EC, display_all) end return '' end function p._eleshelltostring(eleconf, _comma) local comma=_comma or',' local elecdis = '' for period, eles in ipairs(eleconf) do local ele_shell_count = 0 for shell, elecount in ipairs(eles) do if type(elecount) == type({}) then for shell_id, shell_ent in ipairs(elecount) do local shell_name = shell_ent[2] local shell_elecount = shell_ent[1] ele_shell_count = ele_shell_count + shell_elecount end else ele_shell_count = ele_shell_count + elecount end end if elecdis~='' then elecdis=elecdis..comma end elecdis=elecdis..tostring(ele_shell_count) end return elecdis end return p
摘要:
请注意,所有对Local Chinese Wikipedia的贡献均可能会被其他贡献者编辑、修改或删除。如果您不希望您的文字作品被随意编辑,请不要在此提交。
您同时也向我们承诺,您提交的内容为您自己所创作,或是复制自公共领域或类似自由来源(详情请见
Project:著作权
)。
未经许可,请勿提交受著作权保护的作品!
取消
编辑帮助
(在新窗口中打开)
导航菜单
个人工具
未登录
讨论
贡献
创建账号
登录
命名空间
模块
讨论
English
查看
阅读
编辑
查看历史
更多
搜索
导航
首页
最近更改
随机页面
MediaWiki帮助
工具
链入页面
相关更改
特殊页面
页面信息