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
m |
m |
||
(17 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | colors = ['rgb(189, 222, 187)', 'rgb(252, 236, 219)', 'rgb(222, 187, 190)']; | ||
+ | |||
jQuery(document).ready( function( $ ) { | jQuery(document).ready( function( $ ) { | ||
− | |||
var shades = []; | var shades = []; | ||
Line 10: | Line 11: | ||
$('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'); |
shades.push(value); | shades.push(value); | ||
− | } | + | }); |
− | uniq = shades.filter( | + | uniq = shades.filter(function(item, pos) { |
+ | return shades.indexOf(item) != pos; | ||
+ | }); | ||
+ | |||
$('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') | ||
− | |||
$(this).css("background-color", getFixedColor(uniq.indexOf(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 = 'rgb(' + value + ',' + value + ',' + value + ')'; | + | //color = 'rgb(' + value + ',' + value + ',' + value + ')'; |
$('td[data-sort-value]').each(function() { | $('td[data-sort-value]').each(function() { | ||
if (value == $(this).attr('data-sort-value')) { | if (value == $(this).attr('data-sort-value')) { | ||
Line 32: | Line 35: | ||
} | } | ||
}); | }); | ||
− | }); | + | });*/ |
+ | |||
}); | }); | ||
function getFixedColor(a) { | function getFixedColor(a) { | ||
− | + | if (a >= 0) | |
+ | return colors[a] | ||
} | } | ||
+ | |||
+ | |||
function getRandomColor() { | function getRandomColor() { | ||
Line 46: | Line 53: | ||
} | } | ||
return color; | return color; | ||
− | |||
− | |||
− | |||
− | |||
} | } |
Latest revision as of 22:26, 7 October 2017
colors = ['rgb(189, 222, 187)', 'rgb(252, 236, 219)', 'rgb(222, 187, 190)']; 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(function(item, pos) { return shades.indexOf(item) != pos; }); $('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) { if (a >= 0) return colors[a] } 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; }