„MediaWiki:Common.js” változatai közötti eltérés

Palotasb (vitalap | szerkesztései)
a bugfix
Palotasb (vitalap | szerkesztései)
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 = 50;
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'
var datenotelinkcss = {
     'color': '#555'
};
};


$('.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 < 60)
 
         return Math.round(sec / 60).toString() + ' perce';
     if ( sec / 60 < 50)
     if ( sec / 3600 < 24 )
         return [Math.round(sec / 60), '$ perc', '$ perce'];
         return Math.round(sec / 3600).toString() + ' órája';
 
     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)).toString() + ' napja';
         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)).toString() + ' hete';
         return [Math.round(sec / (3600 * 24 * 7)), '$ hét', '$ hete'];
     return Math.round(sec / (3600 * 24 * 30)).toString() + ' hónapja';
 
    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 (mw.config.values.wgNamespaceNumber == 6)
        var obj = $(this);
         if (obj.data('showfiletime'))
             return false;
             return false;
         return ($(this).prop('href').replace( /.*\//, '') == filename);
         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', 'Ennyi ideje volt feltöltve vagy utoljára módosítva a fájl (' + decodeURIComponent(filename.replace(/_/g, ' ')) + ')');
     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(getelapsedtime(diff));
     datenotelink.text(diffres[1].replace('$', diffres[0].toString()));
     datenotelink.prop('href', '/Fájl:' + filename);
     datenotelink.prop('href', '/Fájl:' + filename);
     datenotelink.css(datenotelinkcss);
     datenotelink.css('color', colorfromage(diff));
    datenote.append('[');
     datenote.append(datenotelink);
     datenote.append(datenotelink);
    datenote.append(']');
     links.after(datenote);
     links.after(datenote);
};
};
A lap eredeti címe: „https://vik.wiki/MediaWiki:Common.js