Results 1 to 10 of 10
Jun 20, 2007, 13:24 #1
- Join Date
- Jan 2004
- 0 Post(s)
- 0 Thread(s)
Using JS to detect colour codes in a css file
I am trying to find a way to pull out all the colours used in a template css file so that I can make a list of the colours automatically.
Due to the various ways in which the colours are typed in the template css file, the only way I can think of is to actually search for the 6-digit hex codes that make up the colour. Yes, I know about named colours, RGB coding and hex sorthand, but I am going to ignore those for now.
So, I need a JS routine that:
1. steps through the css file
2. stops at every # sign
3. reads the following text to see if it is 6 digits long
4. if it is, sees whether it is a valid code (as opposed to a CSS id that happens to be six letters long!)
5. outputs a comma separated list of colours
6. removes the duplicates