2014-09-27 16:04:57 -04:00
|
|
|
if (active_page == 'thread' || active_page == 'index') {
|
|
|
|
$(document).ready(function(){
|
2014-10-05 12:30:47 -04:00
|
|
|
if (window.Options && Options.get_tab('general')) {
|
|
|
|
selector = '#color-ids>input';
|
|
|
|
event = 'change';
|
|
|
|
Options.extend_tab("general", "<label id='color-ids'><input type='checkbox' /> "+_('Color IDs')+"</label>");
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
selector = '#color-ids';
|
|
|
|
event = 'click';
|
|
|
|
$('hr:first').before('<div id="color-ids" style="text-align:right"><a class="unimportant" href="javascript:void(0)">'+_('Color IDs')+'</a></div>')
|
|
|
|
}
|
|
|
|
|
|
|
|
$(selector).on(event, function() {
|
|
|
|
if (localStorage.color_ids === 'true') {
|
|
|
|
localStorage.color_ids = 'false';
|
|
|
|
} else {
|
|
|
|
localStorage.color_ids = 'true';
|
2014-09-27 16:04:57 -04:00
|
|
|
}
|
2014-10-05 12:30:47 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!localStorage.color_ids || localStorage.color_ids === 'false') {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
$('#color-ids>input').attr('checked','checked');
|
|
|
|
}
|
|
|
|
|
|
|
|
function IDToRGB(id_str){
|
|
|
|
var id = id_str.match(/.{1,2}/g);
|
|
|
|
var rgb = new Array();
|
|
|
|
|
|
|
|
for (i = 0; i < id.length; i++) {
|
|
|
|
rgb[i] = parseInt(id[i], 16);
|
|
|
|
}
|
|
|
|
|
2014-09-27 16:04:57 -04:00
|
|
|
return rgb;
|
|
|
|
}
|
2014-09-27 14:56:05 -04:00
|
|
|
|
2014-09-27 16:17:31 -04:00
|
|
|
function colorPostId(el) {
|
2014-09-27 23:55:10 -04:00
|
|
|
var rgb = IDToRGB($(el).text());
|
|
|
|
var ft = "#fff";
|
|
|
|
|
|
|
|
if ((rgb[0]*0.299 + rgb[1]*0.587 + rgb[2]*0.114) > 125)
|
|
|
|
ft = "#000";
|
|
|
|
|
2014-09-27 16:19:58 -04:00
|
|
|
$(el).css({
|
2014-09-27 16:04:57 -04:00
|
|
|
"background-color": "rgb("+rgb[0]+", "+rgb[1]+", "+rgb[2]+")",
|
2014-09-27 19:58:39 -04:00
|
|
|
"padding": "0px 5px",
|
2014-09-27 16:04:57 -04:00
|
|
|
"border-radius": "8px",
|
2014-09-27 23:55:10 -04:00
|
|
|
"color": ft
|
2014-09-27 16:04:57 -04:00
|
|
|
});
|
2014-09-27 20:17:30 -04:00
|
|
|
|
|
|
|
$(el).mouseover(function() {
|
2014-09-27 23:55:10 -04:00
|
|
|
$(this).css('color', '#800000'); // how about a CSS :hover rule instead?
|
2014-09-27 20:17:30 -04:00
|
|
|
}).mouseout(function() {
|
2014-09-27 23:55:10 -04:00
|
|
|
$(this).css('color', ft);
|
2014-09-27 20:17:30 -04:00
|
|
|
});
|
2014-09-27 16:17:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$(".poster_id").each(function(k, v){
|
|
|
|
colorPostId(v);
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('new_post', function(e, post) {
|
|
|
|
$(post).find('.poster_id').each(function(k, v) {
|
|
|
|
colorPostId(v);
|
|
|
|
});
|
2014-09-27 16:04:57 -04:00
|
|
|
});
|
2014-09-27 14:56:05 -04:00
|
|
|
});
|
2014-09-27 16:04:57 -04:00
|
|
|
}
|