A
A
Alibek Kulseitov2017-05-13 16:25:24
PHP
Alibek Kulseitov, 2017-05-13 16:25:24

How to set color via data-color?

I googled and didn't find a good solution. Found the answer here but they say that this method is not supported in many browsers.
In general, my goal is to make it so that the programmer can set the color through data-color. Because there will be many and different flowers.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey Popov, 2018-07-18
@BarnyBroken

Why is there no /u flag in preg_match? He will ignore the Cyrillic alphabet.

F
Flying, 2018-07-18
@Flying

There is an official library from Twitter which, in particular, provides hashtag extraction functionality ( example for JS ).
If you look at the code, you will see that the real regexp is formed from pieces and its total final size is very large (I think a few kb). In addition, there is another problem, already specific to PHP - the PCRE library used as a regular expression engine for PHP does not support Unicode Surrogates , giving them an error Error 73 disallowed Unicode code point.
At one time, for one project, I converted an implementation from the Twitter library for PHP, if necessary, you can pick it up here. There is indeed a slight difference in the handling of mentions. it was necessary to take into account the specifics of Instagram, and as for the specifics of PCRE, see above.

D
Dima Pautov, 2017-05-13
@AlibekKulseitov

well, store the color in the date attribute and use js to take it from there and do whatever you want with it. What is the problem?
https://jsfiddle.net/090ugdmf/1/

A
Alexander Pushkarev, 2017-05-13
@AXP-dev

Make a js wrapper

<div class="header" data-color="{'color': 'red', 'property':'background'}">...</div>
<div class="footer" data-color="{'color': 'blue', 'property':'color'}">...</div>

Then JS cycle through the elements with data-color

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question