mirror of https://github.com/bvn13/JIrcBot.git
implemented colors for nicknames
parent
c6f0698da6
commit
18b8f8bbe7
|
@ -0,0 +1,22 @@
|
|||
package ru.bvn13.jircbot.utilities;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by bvn13 on 22.03.2018.
|
||||
*/
|
||||
@Component
|
||||
public class ViewHelper {
|
||||
|
||||
public String getColorForString(String s) {
|
||||
Random r = new Random(s.hashCode());
|
||||
return String.format("#%06x", r.nextInt(256*256*256));
|
||||
}
|
||||
|
||||
public String getColorStyleForUser(String username) {
|
||||
return String.format("color: %s;", getColorForString(username));
|
||||
}
|
||||
|
||||
}
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
<div th:if="${msg.isUserSet()}" th:remove="tag">
|
||||
<td class="col-sm-2 col-md-2 col-lg-2" th:text="${msg.getDtCreatedStr()}"></td>
|
||||
<td class="col-sm-2 col-md-2 col-lg-2"><b th:text="${msg.username}"></b></td>
|
||||
<td class="col-sm-2 col-md-2 col-lg-2"><b th:style="|color: ${@viewHelper.getColorForString(msg.username)}|" th:text="${msg.username}"></b></td>
|
||||
<td class="col-sm-8 col-md-8 col-lg-8" style="word-break: break-all;" th:text="${msg.message}"></td>
|
||||
</div>
|
||||
<div th:unless="${msg.isUserSet()}" th:remove="tag">
|
||||
|
|
Loading…
Reference in New Issue