forked from GithubBackups/vichan
Rewrite color IDs script so it actually works
This commit is contained in:
parent
150480f3fc
commit
befe393778
@ -84,6 +84,7 @@
|
|||||||
$config['mod']['recent_reports'] = 65535;
|
$config['mod']['recent_reports'] = 65535;
|
||||||
|
|
||||||
// Board shit
|
// Board shit
|
||||||
|
$config['poster_id_length'] = 6;
|
||||||
$config['ayah_enabled'] = true;
|
$config['ayah_enabled'] = true;
|
||||||
$config['url_banner'] = '/banners.php';
|
$config['url_banner'] = '/banners.php';
|
||||||
//$config['default_stylesheet'] = array('Notsuba', 'notsuba.css');
|
//$config['default_stylesheet'] = array('Notsuba', 'notsuba.css');
|
||||||
|
@ -1,30 +1,44 @@
|
|||||||
if (active_page == 'thread' || active_page == 'index') {
|
if (active_page == 'thread' || active_page == 'index') {
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$.hash = function(str) {
|
if (window.Options && Options.get_tab('general')) {
|
||||||
var i, j, msg = 0;
|
selector = '#color-ids>input';
|
||||||
|
event = 'change';
|
||||||
for (i = 0, j = str.length; i < j; ++i) {
|
Options.extend_tab("general", "<label id='color-ids'><input type='checkbox' /> "+_('Color IDs')+"</label>");
|
||||||
msg = ((msg << 5) - msg) + str.charCodeAt(i);
|
}
|
||||||
}
|
|
||||||
|
else {
|
||||||
return msg;
|
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';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
function stringToRGB(str){
|
|
||||||
var rgb, hash;
|
|
||||||
|
|
||||||
rgb = [];
|
|
||||||
hash = $.hash(str);
|
|
||||||
|
|
||||||
rgb[0] = (hash >> 24) & 0xFF;
|
|
||||||
rgb[1] = (hash >> 16) & 0xFF;
|
|
||||||
rgb[2] = (hash >> 8) & 0xFF;
|
|
||||||
|
|
||||||
return rgb;
|
return rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
function colorPostId(el) {
|
function colorPostId(el) {
|
||||||
var rgb = stringToRGB($(el).text());
|
var rgb = IDToRGB($(el).text());
|
||||||
|
|
||||||
$(el).css({
|
$(el).css({
|
||||||
"background-color": "rgb("+rgb[0]+", "+rgb[1]+", "+rgb[2]+")",
|
"background-color": "rgb("+rgb[0]+", "+rgb[1]+", "+rgb[2]+")",
|
||||||
@ -43,5 +57,6 @@ if (active_page == 'thread' || active_page == 'index') {
|
|||||||
colorPostId(v);
|
colorPostId(v);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user