From 606b39450d29194fd7241898cfd4d1b9746a3c8b Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Oct 2014 18:30:47 +0200 Subject: better synchronize the javascripts with 8chan --- js/id_colors.js | 52 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 19 deletions(-) (limited to 'js/id_colors.js') 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", ""); + } + + else { + selector = '#color-ids'; + event = 'click'; + $('hr:first').before('
'+_('Color IDs')+'
') + } + + $(selector).on(event, function() { + if (localStorage.color_ids === 'true') { + localStorage.color_ids = 'false'; + } else { + localStorage.color_ids = 'true'; } - - 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; - + }); + + 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 rgb; } -- cgit v1.3