Hi guys
I need to save all the color values of the elements in the pages of my site and put them in a database. I thought I'd do it this way:
First thing I'm going to pick up the rgb values of each element so
$("*").each(function (e) {
createColorArray($(this).css('backgroundColor'));
});
then in the function createColorArray store into an array all the values that are passed
function createColorArray(rgbColor) {
//Create rgb array
}
and finally remove duplicate items from my array
function removeDoupe(ar) {
var temp = {};
for (var i = 0; i < ar.length; i++)
temp[ar[i]] = true;
var r = [];
for (var k in temp)
r.push(k);
return r;
}
now my question is, how recommended to create the array? directly inside the $ ("*") or in a dedicated function as I'm thinking? also, i need than once removed duplicates in the new array "clean" as well as the rgb value I would have also given the number of times that value was in the original. Some example code?
Norman Reedus
31-Oct-2014