Modul:Link utilities: Unterschied zwischen den Versionen

keine Bearbeitungszusammenfassung
(Optik)
Keine Bearbeitungszusammenfassung
Zeile 2: Zeile 2:


-- split separate items like numbers
-- split separate items like numbers
function lb.splitItems( s, delimiters )
function lb.splitItems( s, delimiters, defaultDelimiter )
local i
local i
defaultDelimiter = defaultDelimiter or ','
-- wrap delimiters with zero marks
-- wrap delimiters with zero marks
s = mw.ustring.gsub( s, ',', '\0,\0' );
s = mw.ustring.gsub( s, defaultDelimiter, '\0' .. defaultDelimiter .. '\0' );
 
-- substitude delimiters
-- substitude delimiters
for i = 1, #delimiters, 1 do
for i = 1, #delimiters, 1 do
Zeile 12: Zeile 15:
s = mw.ustring.gsub( s, '%b()', function( t ) return mw.ustring.gsub( t, '%z', '' ) end )
s = mw.ustring.gsub( s, '%b()', function( t ) return mw.ustring.gsub( t, '%z', '' ) end )
-- replace delimeters by commas
-- replace delimeters by commas
s = mw.ustring.gsub( s, '\0' .. delimiters[i] .. '\0', '\0,\0' );
s = mw.ustring.gsub( s, '\0' .. delimiters[i] .. '\0', '\0' .. defaultDelimiter .. '\0' );
end
end
s = mw.text.split( s, '\0,\0' )
 
-- results to an array
s = mw.text.split( s, '\0' .. defaultDelimiter .. '\0' )
for i = #s, 1, -1 do
for i = #s, 1, -1 do
s[ i ] = mw.text.trim( s[ i ] )
s[ i ] = mw.text.trim( s[ i ] )
Zeile 36: Zeile 41:
end
end


function lb.errorInfo( catPrefix, aCat )
function lb.errorInfo( catPrefix, aCat, aClass )
aClass = aClass or 'error'
local ns = mw.title.getCurrentTitle().namespace
local ns = mw.title.getCurrentTitle().namespace
if (ns == 0) or (ns == 828) then
if ( ns == 0 ) or ( ns == 828 ) then
return catPrefix .. aCat .. ']]' .. '<span class="error" title="'
return catPrefix .. aCat .. ']]' .. '<span class="' .. aClass .. '" title="'
.. aCat .. '">' .. aCat .. '</span>'
.. aCat .. '">' .. aCat .. '</span>'
else
else
Anonymer Benutzer