„MediaWiki:Common.js” változatai közötti eltérés
a bugfix |
filetimes.js-ben frissítés (színezés) |
||
| 962. sor: | 962. sor: | ||
(function ($, mw) { | (function ($, mw) { | ||
if (mw.config.values.wgNamespaceNumber == 6) | |||
return false; | |||
var filelinks = $('a[href^="/images"]'); | var filelinks = $('a[href^="/images"]'); | ||
var batchsize = | var batchsize = 49; | ||
var prefix = 'Fájl:' | var prefix = 'Fájl:' | ||
var fileurls = [[]]; | var fileurls = [[]]; | ||
| 970. sor: | 973. sor: | ||
'font-size': 'x-small', | 'font-size': 'x-small', | ||
'color': '#555', | 'color': '#555', | ||
'padding-left': '3px' | 'padding-left': '3px', | ||
'white-space': 'nowrap' | |||
' | |||
}; | }; | ||
$('.datenote').remove(); | $('.datenote').remove(); | ||
filelinks.removeData('showfiletime'); | |||
filelinks.each( function ( index, elem ) { | filelinks.each( function ( index, elem ) { | ||
| 989. sor: | 991. sor: | ||
var getelapsedtime = function(sec) { | var getelapsedtime = function(sec) { | ||
if ( sec < 60 ) | if ( sec < 60 ) | ||
return 'most'; | return [Math.round(sec), 'most', 'Épp most']; | ||
if ( sec / 60 < | |||
return Math.round(sec / 60) | if ( sec / 60 < 50) | ||
if ( sec / 3600 < | return [Math.round(sec / 60), '$ perc', '$ perce']; | ||
return Math.round(sec / 3600) | |||
if ( sec / 3600 < 20 ) | |||
return [Math.round(sec / 3600), '$ óra', '$ órája']; | |||
if ( sec / (3600 * 24) < 7 ) | if ( sec / (3600 * 24) < 7 ) | ||
return Math.round(sec / (3600 * 24)) | return [Math.round(sec / (3600 * 24)), '$ nap', '$ napja']; | ||
if ( sec / (3600 * 24 * 7) < 6 ) | if ( sec / (3600 * 24 * 7) < 6 ) | ||
return Math.round(sec / (3600 * 24 * 7)). | return [Math.round(sec / (3600 * 24 * 7)), '$ hét', '$ hete']; | ||
return Math.round(sec / (3600 * 24 * | |||
if ( sec / (3600 * 24 * 30) < 12 ) | |||
return [Math.round(sec / (3600 * 24 * 30)), '$ hó', '$ hónapja']; | |||
return [Math.round(sec / (3600 * 24 * 365)), '$ év', '$ éve']; | |||
}; | |||
var mixcolors = function(r1, g1, b1, r2, g2, b2, a, b) { | |||
return [ | |||
Math.round(r1 / (a + b) * a + r2 / (a + b) * b), | |||
Math.round(g1 / (a + b) * a + g2 / (a + b) * b), | |||
Math.round(b1 / (a + b) * a + b2 / (a + b) * b), | |||
]; | |||
}; | |||
var colortohex = function(color) { | |||
var r = color[0].toString(16); | |||
var g = color[1].toString(16); | |||
var b = color[2].toString(16); | |||
return '#' + (r.length == 1 ? '0' + r : r) + | |||
(g.length == 1 ? '0' + g : g) + | |||
(b.length == 1 ? '0' + b : b); | |||
}; | |||
var colorfromage = function(age) { | |||
return colortohex(mixcolors(0x80, 0x80, 0x80, 0, 0xA0, 0, | |||
Math.atan(Math.log(age) - 13.7) + 1.6, | |||
0.8 | |||
)); | |||
}; | }; | ||
var addfiledate = function(filename, date) { | var addfiledate = function(filename, date) { | ||
var links = filelinks.filter(function(index) { | var links = filelinks.filter(function(index) { | ||
if ( | var obj = $(this); | ||
if (obj.data('showfiletime')) | |||
return false; | return false; | ||
return ( | return (obj.prop('href').replace( /.*\//, '') == filename); | ||
}); | }); | ||
links.data('showfiletime', true); | |||
var d = new Date(date); | var d = new Date(date); | ||
var now = new Date(); | var now = new Date(); | ||
var diff = Math.floor((now.getTime() - d.getTime()) / 1000); | var diff = Math.floor((now.getTime() - d.getTime()) / 1000); | ||
var diffres = getelapsedtime(diff); | |||
var datenote = $(document.createElement('SUP')); | var datenote = $(document.createElement('SUP')); | ||
var datenotelink = $(document.createElement('A')); | var datenotelink = $(document.createElement('A')); | ||
datenote.addClass('datenote'); | datenote.addClass('datenote'); | ||
datenote.prop('title', ' | datenote.prop('title', 'A fájl ' + diffres[2].replace('$', diffres[0].toString()) + ' volt feltöltve vagy utoljára módosítva: ' + decodeURIComponent(filename.replace(/_/g, ' ')) + ' (' + d.toLocaleString() + ')'); | ||
datenote.css(datenotecss); | datenote.css(datenotecss); | ||
datenotelink.text( | datenotelink.text(diffres[1].replace('$', diffres[0].toString())); | ||
datenotelink.prop('href', '/Fájl:' + filename); | datenotelink.prop('href', '/Fájl:' + filename); | ||
datenotelink.css | datenotelink.css('color', colorfromage(diff)); | ||
datenote.append(datenotelink); | datenote.append(datenotelink); | ||
links.after(datenote); | links.after(datenote); | ||
}; | }; | ||