25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

mod_muc_log: Hide join/leave lines, add method to show them

This commit is contained in:
Badlop 2024-03-05 11:49:18 +01:00
parent c0055b7a7f
commit 281515cd9f
3 changed files with 46 additions and 1 deletions

View File

@ -16,12 +16,14 @@ a.roomjid {color: #336699; font-size: 24px; font-weight: bold; font-family: sans
div.logdate {color: #663399; font-size: 20px; font-weight: bold; font-family: sans-serif; letter-spacing: 2px; border-bottom: #224466 solid 1pt; margin-left:80pt; margin-top:20px;}
div.roomsubject {color: #336699; font-size: 18px; font-family: sans-serif; margin-left: 80pt; margin-bottom: 10px;}
div.rc {color: #336699; font-size: 12px; font-family: sans-serif; margin-left: 50%; text-align: right; background: #f3f6f9; border-bottom: 1px solid #336699; border-right: 4px solid #336699;}
div.rct {font-weight: bold; background: #e3e6e9; padding-right: 10px;}
div.rct {font-weight: bold; background: #e3e6e9; padding-right: 10px; cursor: pointer;}
div.rct:hover {text-decoration: underline;}
div.rcos {padding-right: 10px;}
div.rcoe {color: green;}
div.rcod {color: red;}
div.rcoe:after {content: ": v";}
div.rcod:after {content: ": x";}
div.rcot:after {}
div.jl {display: none;}
.legend {width: 100%; margin-top: 30px; border-top: #224466 solid 1pt; padding: 10px 0px 10px 0px; text-align: left; font-family: monospace; letter-spacing: 2px;}
.w3c {position: absolute; right: 10px; width: 60%; text-align: right; font-family: monospace; letter-spacing: 1px;}

View File

@ -6,3 +6,14 @@ function sh(e) {
document.getElementById(e).style.display='none';
}
}
// Show/Hide join/leave elements
function jlf() {
var es = document.getElementsByClassName('jl');
for (var i = 0; i < es.length; i++) {
if (es[i].style.display === 'block') {
es[i].style.display = 'none';
} else {
es[i].style.display = 'block';
}
}
}

View File

@ -443,11 +443,13 @@ add_message_to_log(Nick1, Message, RoomJID, Opts,
{_, _, Microsecs} = Now,
STimeUnique = io_lib:format("~ts.~w",
[STime, Microsecs]),
maybe_print_jl(open, F, Message, FileFormat),
fw(F, io_lib:format("<a id=\"~ts\" name=\"~ts\" href=\"#~ts\" "
"class=\"ts\">[~ts]</a> ",
[STimeUnique, STimeUnique, STimeUnique, STime])
++ Text,
FileFormat),
maybe_print_jl(close, F, Message, FileFormat),
file:close(F),
ok.
@ -598,6 +600,7 @@ put_header(F, Room, Date, CSSFile, Lang, Hour_offset,
RoomOccupants = roomoccupants_to_string(Occupants,
FileFormat),
put_room_occupants(F, RoomOccupants, Lang, FileFormat),
put_occupants_join_leave(F, Lang),
Time_offset_str = case Hour_offset < 0 of
true -> io_lib:format("~p", [Hour_offset]);
false -> io_lib:format("+~p", [Hour_offset])
@ -663,6 +666,35 @@ put_room_occupants(F, RoomOccupants, Lang,
[Now2, RoomOccupants]),
fw(F, <<"</div>">>).
put_occupants_join_leave(F, Lang) ->
fw(F, <<"<div class=\"rc\">">>),
fw(F,
<<"<div class=\"rct\" onclick=\"jlf();return "
"false;\">~ts</div>">>,
[tr(Lang, ?T("Show Occupants Join/Leave"))]),
fw(F, <<"</div>">>).
maybe_print_jl(_Direction, _F, _Message, plaintext) ->
ok;
maybe_print_jl(Direction, F, Message, html) ->
PrintJl = case Message of
join -> true;
leave -> true;
{leave, _} -> true;
_ -> false
end,
case PrintJl of
true -> print_jl(Direction, F);
false -> ok
end.
print_jl(Direction, F) ->
String = case Direction of
open -> "<div class=\"jl\">";
close -> "</div>"
end,
fw(F, io_lib:format(String, [])).
htmlize(S1) -> htmlize(S1, html).
htmlize(S1, plaintext) ->