From 677a9a84289f0bd1612bcf9c3551f49124712719 Mon Sep 17 00:00:00 2001 From: anonfagola Date: Sat, 27 Sep 2014 09:47:11 -0700 Subject: [PATCH 1/5] Create id_highlighter --- js/id_highlighter | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 js/id_highlighter diff --git a/js/id_highlighter b/js/id_highlighter new file mode 100644 index 00000000..60052031 --- /dev/null +++ b/js/id_highlighter @@ -0,0 +1,40 @@ +Array.prototype.remove = function(v) { this.splice(this.indexOf(v) == -1 ? this.length : this.indexOf(v), 1); } + +var idshighlighted = []; + +function getPostsById(id){ + return $(".poster_id").filter(function(i){ + return $(this).text() == id; + }); +} + +function getMasterPosts(parents){ + if(!parents.hasClass("post")) return; + + var toRet = []; + + $(parents).each(function(){ + if($(this).hasClass("post")) + toRet.push($(this)); + }); + + return toRet; +} + +$(".poster_id").click(function(){ + var id = $(this).text(); + + if($.inArray(id, idshighlighted) !== -1){ + idshighlighted.remove(id); + + $(getMasterPosts(getPostsById(id).parents())).each(function(i){ + $(this).removeClass("highlighted"); + }); + }else{ + idshighlighted.push(id); + + $(getMasterPosts(getPostsById(id).parents())).each(function(i){ + $(this).addClass("highlighted"); + }); + } +}); From 4c720120e401f885b07e9fb9952ec0bffa8957a6 Mon Sep 17 00:00:00 2001 From: anonfagola Date: Sat, 27 Sep 2014 09:49:17 -0700 Subject: [PATCH 2/5] Added id_highlighter.js to additional_javscript --- inc/instance-config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/instance-config.php b/inc/instance-config.php index 7ab9dfdc..75145129 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -121,6 +121,7 @@ $config['additional_javascript'][] = 'js/toggle-locked-threads.js'; $config['additional_javascript'][] = 'js/toggle-images.js'; $config['additional_javascript'][] = 'js/mobile-style.js'; + $config['additional_javascript'][] = 'js/id_highlighter.js' $config['font_awesome_css'] = '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css'; From e7c1f7d22f351e903fa79893dd5a2cfc920b1146 Mon Sep 17 00:00:00 2001 From: anonfagola Date: Sat, 27 Sep 2014 11:55:39 -0700 Subject: [PATCH 3/5] Forgot .js extension --- js/{id_highlighter => id_highlighter.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename js/{id_highlighter => id_highlighter.js} (100%) diff --git a/js/id_highlighter b/js/id_highlighter.js similarity index 100% rename from js/id_highlighter rename to js/id_highlighter.js From 4086749dfe62ad0a1f304ffd04b3f9c8c99bfbb9 Mon Sep 17 00:00:00 2001 From: anonfagola Date: Sat, 27 Sep 2014 11:56:05 -0700 Subject: [PATCH 4/5] Added id_colors.js --- js/id_colors.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 js/id_colors.js diff --git a/js/id_colors.js b/js/id_colors.js new file mode 100644 index 00000000..6923dbec --- /dev/null +++ b/js/id_colors.js @@ -0,0 +1,34 @@ +$.hash = function(str) { + var i, j, msg = 0; + + for (i = 0, j = str.length; i < j; ++i) { + msg = ((msg << 5) - msg) + str.charCodeAt(i); + } + + 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; +} + +$(".poster_id").each(function(){ + var rgb = stringToRGB($(this).text()); + + $(this).css({ + "background-color": "rgb("+rgb[0]+", "+rgb[1]+", "+rgb[2]+")", + "padding": "3px 5px", + "border-radius": "8px", + "color": "white" + }); +}); + From 180a99ee65cdfe26bfbdf40eca9be645024e3155 Mon Sep 17 00:00:00 2001 From: anonfagola Date: Sat, 27 Sep 2014 12:08:59 -0700 Subject: [PATCH 5/5] Added pointer cursor to ids, to show clickability --- stylesheets/style.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stylesheets/style.css b/stylesheets/style.css index dbc367cf..f7a70780 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -905,6 +905,10 @@ div.thread:hover { word-wrap: break-word; } +.poster_id{ + cursor: pointer; +} + code > pre { /* Better code tags */ background:black;