Diferencia entre revisiones de «MediaWiki:Gadget-user-stats.js»

De La Coppermind
Ir a la navegación Ir a la búsqueda
(begin)
 
m (can't do anything with this junk)
 
(No se muestran 7 ediciones intermedias del mismo usuario)
Línea 1: Línea 1:
const periods = {
'second': 1000, 'minute': 1000 * 60, 'hour': 1000 * 60 * 60,
'day': 1000 * 60 * 60 * 24, 'year': 1000 * 60 * 60 * 24 * 365,
}

mw.hook('Special:ListUsers').add(function user_stats(content){
mw.hook('Special:ListUsers').add(function user_stats(content){

console.log('user-stats:', content)
Array.from($('li', content)).forEach(function each_user(li) {
})
const text = li.textContent
const link = li.querySelector('.mw-userlink')
const tools = li.querySelector('.mw-usertoollinks')
const groups = document.createElement('span')
groups.classList.add('g-userlist-groups')
const created = document.createElement('span')
created.classList.add('g-userlist-created')
const edits = document.createElement('span')
edits .classList.add('g-userlist-edits')
//li.textContent = ''
li.append(' ', groups, ' ', created, ' ', edits)
console.debug('user-stats:', li)
})// </each_user>
})// </user_stats>

///
function edits_per_period(edits, since, period) { return +edits / ((new Date - new Date(since)) / period) }

Revisión actual - 19:36 6 may 2020

const periods = {
  'second': 1000, 'minute': 1000 * 60, 'hour': 1000 * 60 * 60,
  'day': 1000 * 60 * 60 * 24, 'year': 1000 * 60 * 60 * 24 * 365,
}

mw.hook('Special:ListUsers').add(function user_stats(content){

Array.from($('li', content)).forEach(function each_user(li) {
 const text = li.textContent
 const link = li.querySelector('.mw-userlink')
 const tools = li.querySelector('.mw-usertoollinks')
 const groups = document.createElement('span')
 groups.classList.add('g-userlist-groups')
 const created = document.createElement('span')
 created.classList.add('g-userlist-created')
 const edits = document.createElement('span')
 edits .classList.add('g-userlist-edits')
 //li.textContent = ''
 li.append(' ', groups, ' ', created, ' ', edits)
 console.debug('user-stats:', li)
})// </each_user>
})// </user_stats>

/// 
function edits_per_period(edits, since, period) { return +edits / ((new Date - new Date(since)) / period) }