summaryrefslogtreecommitdiff
path: root/js/id_colors.js
diff options
context:
space:
mode:
authorczaks <marcin@6irc.net>2014-10-05 18:30:47 +0200
committerczaks <marcin@6irc.net>2014-10-05 18:30:47 +0200
commit606b39450d29194fd7241898cfd4d1b9746a3c8b (patch)
tree663094e1487f56b287e6065525472cea61399cca /js/id_colors.js
parent1964279436f61e56e6b138b64d9d4f6e476fdc02 (diff)
better synchronize the javascripts with 8chan
Diffstat (limited to 'js/id_colors.js')
-rw-r--r--js/id_colors.js50
1 files changed, 32 insertions, 18 deletions
diff --git a/js/id_colors.js b/js/id_colors.js
index f92113d8..17f8b4d9 100644
--- a/js/id_colors.js
+++ b/js/id_colors.js
@@ -1,25 +1,39 @@
if (active_page == 'thread' || active_page == 'index') {
$(document).ready(function(){
- $.hash = function(str) {
- var i, j, msg = 0;
-
- for (i = 0, j = str.length; i < j; ++i) {
- msg = ((msg << 5) - msg) + str.charCodeAt(i);
+ 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';
+ }
+ });
+
+ 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);
}
-
- return msg;
- };
- 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;
}