Skip to content

Instantly share code, notes, and snippets.

@knugie
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knugie/fe3466ed32427a31fc9d to your computer and use it in GitHub Desktop.
Save knugie/fe3466ed32427a31fc9d to your computer and use it in GitHub Desktop.
/*jslint browser: true, indent: 2 */
(function () {
'use strict';
var rgb, style, idx = 0, store = {}, tiles = document.getElementById('box').childNodes;
for (idx; idx < tiles.length; idx += 1) {
rgb = tiles[idx].style.backgroundColor.split("(")[1].split(")")[0].split(",");
store[Math.sqrt(Math.pow(rgb[0], 2), Math.pow(rgb[2], 2), Math.pow(rgb[2], 2))] = tiles[idx];
}
style = Object.keys(store).map(function (key) { return [key, store[key]]; }).
sort(function (a, b) { return parseInt(a[0], 10) < parseInt(b[0], 10) ? 1 : -1; })[0][1].style;
style.border = '2px solid white';
style.outline = '2px solid black';
}());
@knugie
Copy link
Author

knugie commented Apr 14, 2015

minified for KuKu Kube Bookmarklet:

javascript: !function(){"use strict";var t,e,o=0,n={},r=document.getElementById("box").childNodes;for(o;o<r.length;o+=1)t=r[o].style.backgroundColor.split("(")[1].split(")")[0].split(","),n[Math.sqrt(Math.pow(t[0],2),Math.pow(t[2],2),Math.pow(t[2],2))]=r[o];e=Object.keys(n).map(function(t){return[t,n[t]]}).sort(function(t,e){return parseInt(t[0],10)<parseInt(e[0],10)?1:-1})[0][1].style,e.border="2px solid white",e.outline="2px solid black"}();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment