Skip to content

Instantly share code, notes, and snippets.

@mmmpa
Last active August 29, 2015 14:00
Show Gist options
  • Save mmmpa/d1335c277688ecbbab12 to your computer and use it in GitHub Desktop.
Save mmmpa/d1335c277688ecbbab12 to your computer and use it in GitHub Desktop.
(function(){
var src = document.getElementById('SRC');
var tag = '<div style="display:inline-block;padding:10px;background:#color;width:140px;text-align:center;border:1px solid #000;margin:0 -1px -1px 0;">#color</div>'
var tags = '';
var exist = {};
src.innerHTML.match(/"[0-9a-f]{6}"/ig).sort().forEach(function(color, i, array){
var color = color.replace(/"/ig, '');
if(exist[color]){
return;
}
exist[color] = true;
tags += tag.replace(/#color/ig, color);
});
src.innerHTML = tags
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment