Created
January 3, 2018 17:29
-
-
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/
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
// 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