Document doc = null;
try {
doc = Jsoup.parse(new File(getDefaultLogPath() + ".html"), "UTF-8");
} catch (IOException e) {
}
Element body = doc.select("body").first();
if (session == 0) {
session = System.currentTimeMillis();
body.appendElement("br");
Element sess = new Element(Tag.valueOf("div"), "", new Attributes());
sess.addClass("session");
sess.attr("id", String.valueOf(session));
sess.append("Session started on " + new java.util.Date());
body.appendChild(sess);
body.appendElement("br");
if (s.equals("")) {
saveLogFile(doc);
return;
}
}
Element cursession = doc.select("#" + session).first();
if (cursession == null)
return;
Element timestamp = new Element(Tag.valueOf("span"), "",
new Attributes());
timestamp.addClass("timestamp");
if (!s.equals(""))
timestamp.append(new java.util.Date().toString());
String userNick = s.trim().split(" ")[0];
if (s.startsWith("<" + this.getChannelName() + ">")
|| userNick.contains(".") || s.startsWith("<SYSTEM>")) {
Element system = new Element(Tag.valueOf("div"), "",
new Attributes());
system.addClass("system");
Element systemmsg = new Element(Tag.valueOf("span"), "",
new Attributes());
systemmsg.addClass("system-msg");
systemmsg.append(s.replaceAll("<", "<"));
system.appendChild(timestamp);
system.appendChild(systemmsg);
body.appendChild(system);
} else {
// TODO use default user timestamp format
// TODO format links and quicklinks in html log
Element message = new Element(Tag.valueOf("div"), "",
new Attributes());
message.addClass("message" + (alternateMessage ? "-alt" : ""));
Element nick = new Element(Tag.valueOf("span"), "",
new Attributes());
nick.addClass("nick"
+ (userNick.contains(getBot().getNick()) ? "-me" : ""));
nick.append(userNick.replaceAll("<", "<"));
message.appendChild(timestamp);
message.appendChild(nick);
message.append(Message.parseForLinks(s.substring(userNick.length()))
+ " ");