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

De La Coppermind
Ir a la navegación Ir a la búsqueda
m (can't do anything with this junk)
m (can't do anything with this junk)
 
Línea 17: Línea 17:
 
edits .classList.add('g-userlist-edits')
 
edits .classList.add('g-userlist-edits')
 
//li.textContent = ''
 
//li.textContent = ''
//li.append(link, ' ', tools, ' ', groups, ' ', created, ' ', edits, text.split(' '))
+
li.append(' ', groups, ' ', created, ' ', edits)
console.log('user-stats:', li)
+
console.debug('user-stats:', li)
 
})// </each_user>
 
})// </each_user>
 
})// </user_stats>
 
})// </user_stats>

Revisión actual del 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) }