aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2014-03-18 06:11:00 +0700
committerGravatar Ugnich Anton2014-03-18 06:11:00 +0700
commitc137f9c5acdb896a04569c5276cc53eaa68a5b2b (patch)
tree32df4ebe3dd76a9eee03dc1ee7baddc31d1a68bb /src
parent9fae780d462eee90dc1c3891308f436699342e7d (diff)
Login dialog in javascript
Diffstat (limited to 'src')
-rw-r--r--src/java/com/juick/http/www/PageTemplates.java10
-rw-r--r--src/java/com/juick/http/www/UserThread.java16
2 files changed, 16 insertions, 10 deletions
diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java
index f171eb07..c3ed163b 100644
--- a/src/java/com/juick/http/www/PageTemplates.java
+++ b/src/java/com/juick/http/www/PageTemplates.java
@@ -52,9 +52,9 @@ public class PageTemplates {
out.println("<!DOCTYPE html>");
out.print("<html>");
out.print("<head>");
- out.print("<link rel=\"stylesheet\" href=\"/style.2014031701.css\"/>");
+ out.print("<link rel=\"stylesheet\" href=\"/style.2014031801.css\"/>");
out.print("<script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js\"></script>");
- out.print("<script type=\"text/javascript\" src=\"/scripts.2014031201.js\"></script>");
+ out.print("<script type=\"text/javascript\" src=\"/scripts.2014031801.js\"></script>");
if (headers != null) {
out.print(headers);
}
@@ -92,7 +92,7 @@ public class PageTemplates {
out.print("<li><a href=\"/logout\">Выйти</a></li>");
out.println("</ul></nav>");
} else {
- out.println("<p>Чтобы добавлять сообщения и комментарии, <a href=\"/login\">представьтесь</a>.</p>");
+ out.println("<p>Чтобы добавлять сообщения и комментарии, <a href=\"#\" onclick=\"return openDialogLogin()\">представьтесь</a>.</p>");
}
out.println(" </section>");
out.println("</header>");
@@ -511,7 +511,9 @@ public class PageTemplates {
}
out.print(" <nav class=\"l\">");
msg.ReadOnly |= blUIDs.contains(msg.User.UID);
- if (visitor != null && (msg.ReadOnly == false || visitor.UID == msg.User.UID)) {
+ if (visitor == null && msg.ReadOnly == false) {
+ out.print("<a href=\"#\" onclick=\"return openDialogLogin()\">Комментировать</a> ");
+ } else if (visitor != null && (msg.ReadOnly == false || visitor.UID == msg.User.UID)) {
out.print("<a href=\"#\" onclick=\"return showCommentFooter(this)\">Комментировать</a> ");
}
out.print("<a href=\"/post?body=%21+%23" + msg.MID + "\">Рекомендовать</a>");
diff --git a/src/java/com/juick/http/www/UserThread.java b/src/java/com/juick/http/www/UserThread.java
index 8496fbe4..6b42d4a1 100644
--- a/src/java/com/juick/http/www/UserThread.java
+++ b/src/java/com/juick/http/www/UserThread.java
@@ -260,9 +260,9 @@ public class UserThread {
out.println("<ul id=\"replies\">");
if (listview) {
- printList(out, replies);
+ printList(out, replies, visitor);
} else {
- printTree(out, replies, 0, 0, false);
+ printTree(out, replies, visitor, 0, 0, false);
}
out.println("</ul>");
@@ -273,7 +273,7 @@ public class UserThread {
}
}
- public static void printTree(PrintWriter out, ArrayList<com.juick.Message> replies, int ReplyTo, int margin, boolean hidden) {
+ public static void printTree(PrintWriter out, ArrayList<com.juick.Message> replies, com.juick.User visitor, int ReplyTo, int margin, boolean hidden) {
if (margin > 240) {
margin = 240;
}
@@ -302,6 +302,8 @@ public class UserThread {
if (msg.VisitorCanComment) {
out.println(" <div class=\"msg-links\"><a href=\"#\" onclick=\"return showCommentForm(" + msg.MID + "," + msg.RID + ")\">Ответить</a></div>");
out.println(" <div class=\"msg-comment\" style=\"display: none\"></div>");
+ } else if (visitor == null) {
+ out.println(" <div class=\"msg-links\"><a href=\"#\" onclick=\"return openDialogLogin()\">Ответить</a></div>");
}
int childs = msg.getChildsCount();
@@ -313,15 +315,15 @@ public class UserThread {
out.println(" </li>");
if (ReplyTo == 0 && childs > 1 && replies.size() > 10) {
- printTree(out, msg.childs, msg.RID, margin + 20, true);
+ printTree(out, msg.childs, visitor, msg.RID, margin + 20, true);
} else if (childs > 0) {
- printTree(out, msg.childs, msg.RID, margin + 20, hidden);
+ printTree(out, msg.childs, visitor, msg.RID, margin + 20, hidden);
}
}
}
}
- public static void printList(PrintWriter out, ArrayList<com.juick.Message> replies) {
+ public static void printList(PrintWriter out, ArrayList<com.juick.Message> replies, com.juick.User visitor) {
for (int i = 0; i < replies.size(); i++) {
com.juick.Message msg = replies.get(i);
@@ -342,6 +344,8 @@ public class UserThread {
if (msg.VisitorCanComment) {
out.println(" &#183; <a href=\"#\" onclick=\"return showCommentForm(" + msg.MID + "," + msg.RID + ")\">Ответить</a></div>");
out.println(" <div class=\"msg-comment\" style=\"display: none\"></div>");
+ } else if (visitor == null) {
+ out.println(" <div class=\"msg-links\"><a href=\"#\" onclick=\"return openDialogLogin()\">Ответить</a></div>");
}
out.println(" </div>");
out.println(" </li>");