Skip to content

Instantly share code, notes, and snippets.

@glenndevenish
Created January 3, 2018 17:29
Show Gist options
  • Save glenndevenish/42984a8db16625d99d0b7334d86a9a2f to your computer and use it in GitHub Desktop.
Save glenndevenish/42984a8db16625d99d0b7334d86a9a2f to your computer and use it in GitHub Desktop.
returns javascript array from the pantone colour finder: https://www.pantone.com/color-finder/
// Todo: get document from array of pantones
// Load jQuery
(function () {
if ( !window.jQuery ) {
var dollarInUse = !!window.$;
var s = document.createElement('script');
s.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js');
s.addEventListener('load', function(){
console.log('jQuery loaded!');
if(dollarInUse) {
jQuery.noConflict();
}
});
document.body.appendChild(s);
}
})();
$ = jQuery
// Do replacements (probably an easier way)
$("body").html($(".color-values .boxLrg").text()
.replace(/ /g, "")
.replace(/\n/g, " ")
.replace(/ /g, " ")
.replace(/ /g, " ")
.trim()
.replace(/ /g, ",")
.replace(/,,/g, '",\n')
.replace("RGB,", '"rgb": [')
.replace("HEX/HTML,", '"hex": "#')
.replace("CMYK,", '"cymk": [')
.replace(/",$/gm, "],")
.replace(/(#......)(?:],)/, '$1",')
.replace(/(\d)$/m, '$1],')
.replace(/\n/g, "<br/>")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment