https://mh.wdf.ink/w/index.php?title=%E6%A8%A1%E5%9D%97:Sprite&feed=atom&action=history
模块:Sprite - 版本历史
2024-03-29T06:25:18Z
本wiki上该页面的版本历史
MediaWiki 1.41.0
https://mh.wdf.ink/w/index.php?title=%E6%A8%A1%E5%9D%97:Sprite&diff=226&oldid=prev
SkyEye FAST:// Edit via Wikiplus
2021-05-05T11:31:04Z
<p>// Edit via Wikiplus</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="zh-Hans-CN">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">←上一版本</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">2021年5月5日 (三) 11:31的版本</td>
</tr><tr>
<td colspan="2" class="diff-lineno">第10行:</td>
<td colspan="2" class="diff-lineno">第10行:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local data = args.data and mw.loadData( 'Module:' .. args.data ) or {}</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local data = args.data and mw.loadData( 'Module:' .. args.data ) or {}</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local settings = data.settings</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local settings = data.settings</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><br /></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> local Autolink = require( 'Module:Autolink' )</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- Default settings</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- Default settings</div></td>
</tr>
<tr>
<td colspan="2" class="diff-lineno">第95行:</td>
<td colspan="2" class="diff-lineno">第93行:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local spriteText</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local spriteText</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if text then</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if text then</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"> </del> if not args['wrap'] then</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins> if not args['wrap'] then</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> <del style="font-weight: bold; text-decoration: none;"> </del>root = mw.html.create( 'span' ):addClass( 'nowrap' )</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> <ins style="font-weight: bold; text-decoration: none;"> </ins>root = mw.html.create( 'span' ):addClass( 'nowrap' )</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"> </del>end</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins>end</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> spriteText = mw.html.create( 'span' ):addClass( 'sprite-text' ):wikitext<del style="font-weight: bold; text-decoration: none;">( Autolink.invlink</del>( text<del style="font-weight: bold; text-decoration: none;">, 'nolink', args.data )</del> )</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> spriteText = mw.html.create( 'span' ):addClass( 'sprite-text' ):wikitext( text )</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
</tr>
<tr>
<td colspan="2" class="diff-lineno">第123行:</td>
<td colspan="2" class="diff-lineno">第121行:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- Internal link</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> -- Internal link</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local linkPrefix = setting( 'linkprefix' ) or ''</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> local linkPrefix = setting( 'linkprefix' ) or ''</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> return '[[' .. linkPrefix ..<del style="font-weight: bold; text-decoration: none;"> Autolink.invlink(</del> link<del style="font-weight: bold; text-decoration: none;">, 'linkonly', args.data )</del> .. '|' .. tostring( root ) .. ']]'</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> return '[[' .. linkPrefix .. link .. '|' .. tostring( root ) .. ']]'</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
</tr>
<tr>
<td colspan="2" class="diff-lineno">第153行:</td>
<td colspan="2" class="diff-lineno">第151行:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> args.class = ( args.class or '' ) .. ' sprite-deprecated'</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> args.class = ( args.class or '' ) .. ' sprite-deprecated'</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if not disallowCats then</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> if not disallowCats then</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> categories[#categories + 1] = <del style="font-weight: bold; text-decoration: none;">'[[Category</del>:<del style="font-weight: bold; text-decoration: none;">使用已弃用Sprite的页面]]</del>'</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> categories[#categories + 1] = <ins style="font-weight: bold; text-decoration: none;">f</ins>:<ins style="font-weight: bold; text-decoration: none;">expandTemplate{ title = 'Translation category', args = { 'Pages using deprecated sprite names</ins>'<ins style="font-weight: bold; text-decoration: none;">, project = 0 } }</ins></div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
</tr>
<tr>
<td colspan="2" class="diff-lineno">第159行:</td>
<td colspan="2" class="diff-lineno">第157行:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> args.pos = idData.pos</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> args.pos = idData.pos</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> elseif not disallowCats then</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> elseif not disallowCats then</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> categories[#categories + 1] = <del style="font-weight: bold; text-decoration: none;">'[[Category</del>:<del style="font-weight: bold; text-decoration: none;">含有错误Sprite的页面]]</del>'</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> categories[#categories + 1] = <ins style="font-weight: bold; text-decoration: none;">f</ins>:<ins style="font-weight: bold; text-decoration: none;">expandTemplate{ title = 'Translation category', args = { 'Pages with missing sprites</ins>'<ins style="font-weight: bold; text-decoration: none;">, project = 0 } }</ins></div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> end</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td>
</tr>
<!-- diff cache key miraclehabitat:diff:1.41:old-201:rev-226:wikidiff2=table:1.14.1:bc2a06be -->
</table>
SkyEye FAST
https://mh.wdf.ink/w/index.php?title=%E6%A8%A1%E5%9D%97:Sprite&diff=201&oldid=prev
SkyEye FAST:建立内容为“local p = {} function p.base( f ) local args = f if f == mw.getCurrentFrame() then args = require( 'Module:ProcessArgs' ).merge( true ) else f = mw.getCur…”的新页面
2021-05-05T10:54:07Z
<p>建立内容为“local p = {} function p.base( f ) local args = f if f == mw.getCurrentFrame() then args = require( 'Module:ProcessArgs' ).merge( true ) else f = mw.getCur…”的新页面</p>
<p><b>新页面</b></p><div>local p = {}<br />
function p.base( f )<br />
local args = f<br />
if f == mw.getCurrentFrame() then <br />
args = require( 'Module:ProcessArgs' ).merge( true )<br />
else<br />
f = mw.getCurrentFrame()<br />
end<br />
<br />
local data = args.data and mw.loadData( 'Module:' .. args.data ) or {}<br />
local settings = data.settings<br />
<br />
local Autolink = require( 'Module:Autolink' )<br />
<br />
-- Default settings<br />
local default = {<br />
scale = 1,<br />
sheetsize = 256,<br />
size = 16,<br />
pos = 1,<br />
align = 'text-top'<br />
}<br />
<br />
local defaultStyle = default<br />
if settings then<br />
if not settings.stylesheet then<br />
-- Make a separate clone of the current default settings<br />
defaultStyle = mw.clone( default )<br />
end<br />
for k, v in pairs( settings ) do<br />
default[k] = v<br />
end<br />
end<br />
<br />
local setting = function( arg )<br />
return args[arg] or default[arg]<br />
end<br />
<br />
local sprite = mw.html.create( 'span' ):addClass( 'sprite' )<br />
<br />
-- mw.html's css method performs very slow escaping, which doubles the time it takes<br />
-- to run, so we'll construct the styles manually, and put them in the cssText<br />
-- method, which only does html escaping (which isn't slow)<br />
local styles = {}<br />
<br />
if not setting( 'nourl' ) and setting( 'url' ) then<br />
styles[#styles + 1] = 'background-image:' .. ( setting( 'url' ).url or setting( 'url' ) )<br />
end<br />
if setting( 'stylesheet' ) then<br />
sprite:addClass(<br />
setting( 'classname' ) or<br />
mw.ustring.lower( setting( 'name' ):gsub( ' ', '-' ) ) .. '-sprite'<br />
)<br />
elseif not setting( 'url' ) then<br />
styles[#styles + 1] = 'background-image:' .. p.getUrl(<br />
setting( 'image' ) or setting( 'name' ) .. 'Sprite.png'<br />
).url<br />
end<br />
local class = setting( 'class' )<br />
if class then<br />
sprite:addClass( class )<br />
end<br />
<br />
local size = setting( 'size' )<br />
local sheetWidth = setting( 'sheetsize' )<br />
local tiles = sheetWidth / size<br />
local pos = setting( 'pos' ) - 1<br />
local scale = setting( 'scale' )<br />
local autoScale = setting( 'autoscale' )<br />
<br />
if pos then<br />
local left = pos % tiles * size * scale<br />
local top = math.floor( pos / tiles ) * size * scale<br />
styles[#styles + 1] = 'background-position:-' .. left .. 'px -' .. top .. 'px'<br />
end<br />
<br />
if not autoScale and scale ~= defaultStyle.scale then<br />
styles[#styles + 1] = 'background-size:' .. sheetWidth * scale .. 'px auto'<br />
end<br />
if size ~= defaultStyle.size or ( not autoScale and scale ~= defaultStyle.scale ) then<br />
styles[#styles + 1] = 'height:' .. size * scale .. 'px'<br />
styles[#styles + 1] = 'width:' .. size * scale .. 'px'<br />
end<br />
<br />
local align = setting( 'align' )<br />
if align ~= defaultStyle.align then<br />
styles[#styles + 1] = 'vertical-align:' .. align<br />
end<br />
styles[#styles + 1] = setting( 'css' )<br />
<br />
sprite:cssText( table.concat( styles, ';' ) )<br />
<br />
local text = setting( 'text' )<br />
local root<br />
local spriteText<br />
if text then<br />
if not args['wrap'] then<br />
root = mw.html.create( 'span' ):addClass( 'nowrap' )<br />
end<br />
spriteText = mw.html.create( 'span' ):addClass( 'sprite-text' ):wikitext( Autolink.invlink( text, 'nolink', args.data ) )<br />
end<br />
<br />
local title = setting( 'title' )<br />
if title then<br />
( root or sprite ):attr( 'title', title )<br />
end<br />
<br />
if not root then<br />
root = mw.html.create( '' )<br />
end<br />
root:node( sprite )<br />
if spriteText then<br />
root:node( spriteText )<br />
end<br />
<br />
local link = setting( 'link' ) or ''<br />
if link ~= '' and mw.ustring.lower( link ) ~= 'none' then<br />
-- External link<br />
if link:find( '//' ) then<br />
return '[' .. link .. ' ' .. tostring( root ) .. ']'<br />
end<br />
<br />
-- Internal link<br />
local linkPrefix = setting( 'linkprefix' ) or ''<br />
return '[[' .. linkPrefix .. Autolink.invlink( link, 'linkonly', args.data ) .. '|' .. tostring( root ) .. ']]'<br />
end<br />
<br />
return tostring( root )<br />
end<br />
<br />
function p.sprite( f )<br />
local args = f<br />
if f == mw.getCurrentFrame() then<br />
args = require( 'Module:ProcessArgs' ).merge( true )<br />
else<br />
f = mw.getCurrentFrame()<br />
end<br />
<br />
local data = args.data and mw.loadData( 'Module:' .. args.data ) or {}<br />
local categories = {}<br />
local idData = args.iddata<br />
if not idData then<br />
local name = args.name or data.settings.name<br />
local id = mw.text.trim( tostring( args[1] or '' ) )<br />
idData = data.ids[id] or data.ids[mw.ustring.lower( id ):gsub( '[%s%+]', '-' )]<br />
end<br />
<br />
local title = mw.title.getCurrentTitle()<br />
-- Remove categories on language pages, talk pages, and in User/UserWiki/UserProfile namespaces<br />
local disallowCats = args.nocat or title.isTalkPage or title.nsText:find( '^User' )<br />
if idData then<br />
if idData.deprecated then<br />
args.class = ( args.class or '' ) .. ' sprite-deprecated'<br />
if not disallowCats then<br />
categories[#categories + 1] = '[[Category:使用已弃用Sprite的页面]]'<br />
end<br />
end<br />
<br />
args.pos = idData.pos<br />
elseif not disallowCats then<br />
categories[#categories + 1] = '[[Category:含有错误Sprite的页面]]'<br />
end<br />
<br />
return p.base( args ), table.concat( categories )<br />
end<br />
<br />
function p.link( f )<br />
local args = f<br />
if f == mw.getCurrentFrame() then<br />
args = require( 'Module:ProcessArgs' ).merge( true )<br />
end<br />
<br />
local link = args[1]<br />
if args[1] and not args.id then<br />
link = args[1]:match( '^(.-)%+' ) or args[1]<br />
end<br />
local text<br />
if not args.notext then<br />
text = args.text or args[2] or link<br />
end<br />
<br />
args[1] = args.id or args[1]<br />
args.link = args.link or link<br />
args.text = text<br />
<br />
return p.sprite( args )<br />
end<br />
<br />
function p.getUrl( image, query, classname )<br />
local f = mw.getCurrentFrame()<br />
local t = {<br />
url = f:expandTemplate{<br />
title = 'FileUrl',<br />
args = { image, query = query }<br />
},<br />
}<br />
if classname and classname ~= '' then<br />
t.style = f:expandTemplate{<br />
title = 'FileUrlStyle',<br />
args = { classname, image, query = query }<br />
}<br />
end<br />
return t<br />
end<br />
<br />
function p.getParsedUrlStyle( f )<br />
local args = f:getParent().args<br />
local module = args[1]<br />
return require( 'Module:' .. module ).settings.url.style<br />
end<br />
<br />
function p.doc( f )<br />
local args = f<br />
if f == mw.getCurrentFrame() then<br />
args = f.args<br />
else<br />
f = mw.getCurrentFrame()<br />
end<br />
local dataPage = mw.text.trim( args[1] )<br />
local data = mw.loadData( 'Module:' .. dataPage )<br />
<br />
local getProtection = function( title, action, extra )<br />
local protections = { 'edit' }<br />
if extra then<br />
protections[#protections + 1] = extra<br />
end<br />
<br />
local addProtection = function( protection )<br />
if protection == 'autoconfirmed' then<br />
protection = 'editsemiprotected'<br />
elseif protection == 'sysop' then<br />
protection = 'editprotected'<br />
end<br />
<br />
protections[#protections + 1] = protection<br />
end<br />
<br />
local direct = title.protectionLevels[action] or {}<br />
for _, protection in ipairs( direct ) do<br />
addProtection( protection )<br />
end<br />
local cascading = title.cascadingProtection.restrictions[action] or {}<br />
if #cascading > 0 then<br />
protections[#protections + 1] = 'protect'<br />
end<br />
for _, protection in ipairs( cascading ) do<br />
addProtection( protection )<br />
end<br />
<br />
return table.concat( protections, ',' )<br />
end<br />
<br />
local spriteStyle = ''<br />
if data.settings.url and data.settings.url.style then<br />
spriteStyle = data.settings.url.style<br />
end<br />
<br />
local dataTitle = mw.title.new( 'Module:' .. dataPage )<br />
-- Temporary until this is updated<br />
local classname = ''<br />
if data.settings.stylesheet then<br />
classname = data.settings.classname or<br />
mw.ustring.lower( data.settings.name:gsub( ' ', '-' ) ) .. '-sprite'<br />
end<br />
local spritesheet = data.settings.image or data.settings.name .. 'Sprite.png'<br />
local spriteTitle = mw.title.new( 'File:' .. spritesheet )<br />
local dataProtection = getProtection( dataTitle, 'edit' )<br />
local spriteProtection = getProtection( spriteTitle, 'upload', 'upload,reupload' )<br />
local body = mw.html.create( 'div' ):attr( {<br />
id = 'spritedoc',<br />
['data-dataprotection'] = dataProtection,<br />
['data-datatimestamp'] = f:callParserFunction( 'REVISIONTIMESTAMP', 'Module:' .. dataPage ),<br />
['data-datapage'] = 'Module:' .. dataPage,<br />
['data-spritesheet'] = spritesheet,<br />
['data-spriteprotection'] = spriteProtection,<br />
['data-urlfunc'] = "require( [[Module:Sprite]] ).getUrl( '" .. spritesheet .. "', '$1', '" .. classname .. "' )",<br />
['data-refreshtext'] = mw.text.nowiki( '{{#invoke:sprite|doc|' .. dataPage .. '|refresh=1}}' ),<br />
['data-settings'] = mw.text.jsonEncode( data.settings ),<br />
} )<br />
<br />
local sections = {}<br />
for _, sectionData in ipairs( data.sections or { name = 'Uncategorized' } ) do<br />
local sectionTag = body:tag( 'div' ):addClass( 'spritedoc-section' ):attr( 'data-section-id', sectionData.id )<br />
sectionTag:tag( 'h3' ):wikitext( sectionData.name )<br />
sections[sectionData.id] = { boxes = sectionTag:tag( 'ul' ):addClass( 'spritedoc-boxes' ) }<br />
end<br />
<br />
local keyedData = {}<br />
local i = 1<br />
for name, idData in pairs( data.ids ) do<br />
keyedData[i] = {<br />
sortKey = mw.ustring.lower( name ),<br />
name = name,<br />
data = idData<br />
}<br />
i = i + 1<br />
end<br />
table.sort( keyedData, function( a, b )<br />
return a.sortKey < b.sortKey<br />
end )<br />
<br />
for _, data in ipairs( keyedData ) do<br />
local idData = data.data<br />
local pos = idData.pos<br />
local section = sections[idData.section]<br />
local names = section[pos]<br />
if not names then<br />
local box = section.boxes:tag( 'li' ):addClass( 'spritedoc-box' ):attr( 'data-pos', pos )<br />
box:tag( 'div' ):addClass( 'spritedoc-image' )<br />
:wikitext( p.base{ pos = pos, data = dataPage, nourl = spriteStyle ~= '' } )<br />
<br />
names = box:tag( 'ul' ):addClass( 'spritedoc-names' )<br />
section[pos] = names<br />
end<br />
local nameElem = mw.html.create( 'li' ):addClass( 'spritedoc-name' )<br />
local codeElem = nameElem:tag( 'code' ):wikitext( data.name )<br />
<br />
if idData.deprecated then<br />
codeElem:addClass( 'spritedoc-deprecated' )<br />
end<br />
names:wikitext( tostring( nameElem ) )<br />
end<br />
<br />
if args.refresh then<br />
return '', '', tostring( body )<br />
end<br />
local styles = f:callParserFunction( '#widget:SpriteDoc.css' )<br />
return styles, spriteStyle, tostring( body )<br />
end<br />
return p</div>
SkyEye FAST