We have a Lore FAQ page. If you have Story/Lore related questions - make sure to check it out!

Difference between revisions of "MediaWiki:Common.js"

From The Ark: NieR Automata Lore
Jump to: navigation, search
m
m
Line 1: Line 1:
 
jQuery(document).ready( function( $ ) {
 
jQuery(document).ready( function( $ ) {
 +
 +
var shades = [];
  
 
  $('.rss-date').each(function() {
 
  $('.rss-date').each(function() {
Line 5: Line 7:
 
     $(this).html(a.replace(/\/u\/(.* )/g,"<a href='https://www.reddit.com/user/$1'>/u/$1</a> "));
 
     $(this).html(a.replace(/\/u\/(.* )/g,"<a href='https://www.reddit.com/user/$1'>/u/$1</a> "));
 
  });
 
  });
 +
 +
 +
$('td[data-sort-value]').each(function() {
 +
  var value = $(this).attr('data-sort-value')
 +
  shades.push(value);
 +
}
 +
 +
uniq = shades.filter(onlyUnique);
 +
 +
$('td[data-sort-value]').each(function() {
 +
  var value = $(this).attr('data-sort-value')
 +
 +
  $(this).css("background-color", getFixedColor(uniq.indexOf(value)))
 +
}
  
 
  $('td[data-sort-value]').each(function() {
 
  $('td[data-sort-value]').each(function() {
    var value = $(this).attr('data-sort-value')
+
 
 +
  var value = $(this).attr('data-sort-value')
 
     //color = getRandomColor()
 
     //color = getRandomColor()
 
     color = 'rgb(' + value + ',' + value + ',' + value + ')';
 
     color = 'rgb(' + value + ',' + value + ',' + value + ')';
Line 17: Line 34:
 
});
 
});
 
});
 
});
 +
 +
function getFixedColor(a) {
 +
return 'rgb(200,200,200)'
 +
}
  
 
function getRandomColor() {
 
function getRandomColor() {
Line 25: Line 46:
 
     }
 
     }
 
     return color;
 
     return color;
 +
}
 +
 +
function onlyUnique(value, index, self) {
 +
    return self.indexOf(value) === index;
 
}
 
}

Revision as of 21:14, 7 October 2017

jQuery(document).ready( function( $ ) {

 var shades = [];

 $('.rss-date').each(function() {
     var a = $(this).html().replace(/http.*/g, ' ');
    $(this).html(a.replace(/\/u\/(.* )/g,"<a href='https://www.reddit.com/user/$1'>/u/$1</a> "));
 });


 $('td[data-sort-value]').each(function() {
  var value = $(this).attr('data-sort-value')
  shades.push(value);
 }
 
 uniq = shades.filter(onlyUnique);

 $('td[data-sort-value]').each(function() {
  var value = $(this).attr('data-sort-value')

  $(this).css("background-color", getFixedColor(uniq.indexOf(value)))
 }

 $('td[data-sort-value]').each(function() {

   var value = $(this).attr('data-sort-value')
    //color = getRandomColor()
    color = 'rgb(' + value + ',' + value + ',' + value + ')';
    $('td[data-sort-value]').each(function() {
       if (value == $(this).attr('data-sort-value')) {
          $(this).css("background-color", color)
         }
    });
});
});

function getFixedColor(a) {
 return 'rgb(200,200,200)'
}

function getRandomColor() {
    var letters = 'BCDEF'.split('');
    var color = '#';
    for (var i = 0; i < 6; i++ ) {
        color += letters[Math.floor(Math.random() * letters.length)];
    }
    return color;
}

function onlyUnique(value, index, self) { 
    return self.indexOf(value) === index;
}