Last active
August 29, 2015 14:00
-
-
Save mmmpa/d1335c277688ecbbab12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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