implemented colors for nicknames

pull/2/head
Vyacheslav N. Boyko 2018-03-22 15:53:59 +03:00
parent c6f0698da6
commit 18b8f8bbe7
2 changed files with 23 additions and 1 deletions

View File

@ -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));
}
}

View File

@ -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">