956
个编辑
Economy666(讨论 | 贡献) 无编辑摘要 |
Economy666(讨论 | 贡献) (尝试优化) |
||
第112行: | 第112行: | ||
end | end | ||
local DL | local DL,CDL,SDL | ||
local dInit,sdlInit | |||
local function designerInit() | |||
DL = mw.text.jsonDecode(mw.title.new('Template:DesignersList.json'):getContent()) | |||
CDL = DL.complex | |||
SDL = DL.simple | |||
dInit = true | |||
end | |||
local function SDL_Init() | |||
table.sort(SDL, | |||
function(a,b) | |||
return #(a.display)<#(b.display) | |||
end) | |||
sdlInit = true | |||
end | |||
local function findDesigner(designerName, songid) | local function findDesigner(designerName, songid) | ||
if not dInit then designerInit() end | |||
local theType = '谱师' | local theType = '谱师' | ||
local function defaultSDL(text) | local function defaultSDL(text) | ||
if not sdlInit then SDL_Init() end | |||
local temp_text = text | local temp_text = text | ||
local text_len = #text | |||
local link_placeholders = {} | local link_placeholders = {} | ||
local placeholder_count = 0 | local placeholder_count = 0 | ||
第131行: | 第148行: | ||
link_placeholders[placeholder] = link_text | link_placeholders[placeholder] = link_text | ||
temp_text = string.gsub(temp_text, dis, placeholder) | temp_text = string.gsub(temp_text, dis, placeholder) | ||
text_len = text_len - #dis | |||
placeholder_count = placeholder_count + 1 | placeholder_count = placeholder_count + 1 | ||
if text_len < #dis then break end | |||
end | end | ||
-- temp_text = temp_text .. '__'..text_len | |||
end | end | ||
if placeholder_count == 0 then return text end | if placeholder_count == 0 then return text end | ||
第143行: | 第163行: | ||
local designer | local designer | ||
local designer_list = CDL[designerName] | local designer_list = CDL[designerName] | ||
if designer_list then | if designer_list then |
个编辑