Created
June 28, 2013 18:29
-
-
Save pedroha/5886899 to your computer and use it in GitHub Desktop.
Retrieve color palettes from Adobe Kuler. 1) Visit: https://kuler.adobe.com/explore/most-favorite/
2) Open command console and copy/paste the code.
This file contains hidden or 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
var getPaletteColors = function () { | |
var $items = $('div.collection-assets-item > .content'); | |
var palette = []; | |
$items.each(function () { | |
var self = this; | |
var $frame = $('.frame', this); | |
var colors = []; | |
$('.frame > div', this).each(function () { | |
var style = $(this).attr('style'); | |
var color = style.substr('background: '.length); | |
colors.push(color); | |
}); | |
// console.log(colors); | |
palette.push({ | |
colors: colors | |
}); | |
}); | |
var metadata = []; | |
$items.each(function () { | |
var self = this; | |
$('.assets-item-meta a', self).each(function () { | |
var $link = $(this); | |
var data = { | |
name: $link.text() | |
// href: $link.attr('href') | |
// , name: $link.text() | |
}; | |
// console.log(data); | |
metadata.push(data); | |
}); | |
}); | |
for (var i = 0; i < metadata.length; i++) { | |
metadata[i].colors = palette[i].colors; | |
} | |
var output = JSON.stringify(metadata); | |
output = output.replace(/},{/g, '},\n{'); | |
output = output.replace(/#/g, ''); | |
return output; | |
}; | |
var out = getPaletteColors(); | |
console.log(out); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment