Module:ItemData/nav: Difference between revisions

Jump to navigation Jump to search
LVL (talk | contribs)
Added search bar stuff
No edit summary
Line 81: Line 81:
                     end
                     end
                      
                      
                     -- Wrap item and its bullet separator in a searchable span
                     -- Wrap item in an open searchable span (closing tags and bullets added post-sort)
                     item_template = '<span class="item-nav-search-wrapper"><span class="item-nav-search-item" data-item-name="' .. search_data .. '">' .. item_template .. '</span><span class="item-nav-search-sep"> &bull; </span></span>'
                     item_template = '<span class="item-nav-search-wrapper"><span class="item-nav-search-item" data-item-name="' .. search_data .. '">' .. item_template .. '</span>'
                 elseif template == "ItemBox" then
                 elseif template == "ItemBox" then
                     if lang_code == "en" then
                     if lang_code == "en" then
Line 112: Line 112:
     -- Order list alphabetically
     -- Order list alphabetically
     table.sort(items) -- O(nlogn)
     table.sort(items) -- O(nlogn)
   
    -- Append closing tags and bullets (omitting the bullet for the last item)
    if template == "ItemIcon" then
        for i = 1, #items do
            if i == #items then
                items[i] = items[i] .. '</span>'
            else
                items[i] = items[i] .. '<span class="item-nav-search-sep"> &bull; </span></span>'
            end
        end
    end
      
      
     -- Add each item to output
     -- Add each item to output
    -- Each item is already wrapped in the template, so no need for additional wrapping
     local ret = table.concat(items, sep)
     local ret = table.concat(items, sep)