I would like to know such a thing. When adding a new comment, you can insert " @ 123 " or "# 123" in the field, where 123 is the identifier of the user or article. But how to convert these tags into a link when the message is processed and even the link code becomes text. (PS Something like as like on Twitter or even like on HeshCode). PPS "HashCode", you have implemented such a function here, do not tell me how? I would appreciate it. What are the guesses? Thank.
1 answer
As an option:
1) Replace all the substrings of the form / @ (d +) / with a certain structure that catches the mouse, for example:
<a href = "comment.php?id=ID" onmouseover = "showComment(this, ID);" onmouseout = "hideComment(this);" >ΠΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠΉ βID</a>
2) Write the function to show / hide the comment:
function showComment( el, id ){ //AJAX Π·Π°ΠΏΡΠΎΡ Π½Π° ΠΏΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ³ΠΎ ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΡ ID = id //ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° Ρ ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠ΅ΠΌ Π² DOM Π³Π΄Π΅-ΡΠΎ ΡΡΠ΄ΠΎΠΌ Ρ el //ΠΡΡΠ°Π²Π»ΡΠ΅ΠΌ ΡΡΡΠ»ΠΊΡ Π² el Π½Π° ΡΠΎΠ·Π΄Π°Π½Π½ΡΠΉ } function hideComment( el ){ //Π£Π΄Π°Π»ΡΠ΅ΠΌ ΡΠ»Π΅ΠΌΠ΅Π½Ρ Ρ ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠ°ΡΠΈΠ΅ΠΌ ΠΈΠ· DOM }
- Thank! Exactly what is needed. - Elected
|