Die Dokumentation für dieses Modul kann unter Modul:UEC Editcounter/Doku erstellt werden
local EditCounter = {} local metatable = {} local methodtable = {} metatable.__index = methodtable local log = require( 'Module:Log' ) --- Creates the infobox function methodtable.getUecInfo( self ) local title = mw.title.getCurrentTitle() if title.namespace ~= 2 then title = { fullText = 'Benutzer:FoXFTW' } end local data = mw.smw.ask( { '[[' .. title.fullText .. ']]', '?User edit count#-=count' } ) if data == nil or data[ 1 ] == nil or data[ 1 ].count == nil then return log.info( 'Konnte keine Bearbeitungsdaten laden. Ist die Vorlage auf der Benutzerseite eingebunden?' ) end data = data[ 1 ] local totalEdits = self.currentFrame:preprocess( '{{NUMBEROFEDITS}}' ) local cleanEdits = string.gsub( totalEdits, '%.', '' ) local userEditPercent = tonumber( string.format( "%.2f", ( ( data[ 'count' ] / cleanEdits ) * 100 ) ) ) local out = mw.html.create( 'div' ) :addClass('uec-counter') :tag('div') :addClass( 'uec-counter__edit-info') :tag('div') :addClass('uec-counter__total-edits') :tag('div') :addClass('uec-counter__number') :wikitext( data[ 'count' ] ) :done() :tag('div') :addClass('uec-counter__text') :wikitext( 'Bearbeitungen' ) :done() :done() :tag('div') :addClass('uec-counter__total-edits-percent') :tag('div') :addClass('uec-counter__number') :wikitext( userEditPercent .. '%' ) :done() :tag('div') :addClass('uec-counter__text') :wikitext( 'aller Bearbeitungen' ) :done() :done() :done() :tag('div') :addClass( 'uec-counter__payment') :tag('div') :addClass( 'uec-counter__payment-title' ) :wikitext( 'Das Wiki zahlt dir' ) :done() :tag('div') :addClass('uec-counter__number') :wikitext( ( data[ 'count' ] / 10 ) .. ' <span>UEC</span>' ) :done() :allDone() return tostring( out ) end --- Set the frame and load args --- @param frame table function methodtable.setFrame( self, frame ) self.currentFrame = frame end --- Template entry function EditCounter.main( frame ) local instance = EditCounter:new() instance:setFrame( frame ) return tostring( instance:getUecInfo() ) end --- New Instance function EditCounter.new( self ) local instance = { currentFrame = mw.getCurrentFrame() } setmetatable( instance, metatable ) return instance end return EditCounter