Add debug messages to show in notification box

Rename show_notifybox() to add_to_notifybox() to use a more meaningful
name.
This commit is contained in:
Carsten Grohmann 2023-01-08 11:25:22 +01:00
parent f281642379
commit 7907c6265f
2 changed files with 31 additions and 13 deletions

View File

@ -202,15 +202,21 @@ THIS PROGRAM COMES WITH NO WARRANTY
word-wrap: break-word;
}
.js-notify_box__msg--warning {
color: #9F6000;
background-color: #FEEFB3;
.js-notify_box__msg--debug {
color: #000000;
background-color: #e8ffb3;
}
.js-notify_box__msg--error {
color: #D8000C;
background-color: #FFD2D2;
}
.js-notify_box__msg--warning {
color: #9F6000;
background-color: #FEEFB3;
}
.license__text {
font-size: small;
}

View File

@ -183,27 +183,39 @@ def escape_html(unsafe):
)
def debug(msg):
"""Add debug message to the notification box"""
add_to_notifybox("DEBUG", msg)
def error(msg):
"""Show the error box and add the error message"""
show_notifybox("ERROR", msg)
"""Show the notification box and add the error message"""
add_to_notifybox("ERROR", msg)
def internal_error(msg):
"""Show the error box and add the internal error message"""
show_notifybox("INTERNAL ERROR", msg)
"""Show the notification box and add the internal error message"""
add_to_notifybox("INTERNAL ERROR", msg)
def warning(msg):
"""Show the error box and add the warning message"""
show_notifybox("WARNING", msg)
"""Show the notification box and add the warning message"""
add_to_notifybox("WARNING", msg)
def show_notifybox(prefix, msg):
"""Show escaped message in the notification box"""
if prefix == "WARNING":
def add_to_notifybox(prefix, msg):
"""
Escaped and add message to the notification box
If the message has a prefix "ERROR" or "WARNING" the notification box will be shown.
"""
if prefix == "DEBUG":
css_class = "js-notify_box__msg--debug"
elif prefix == "WARNING":
css_class = "js-notify_box__msg--warning"
else:
css_class = "js-notify_box__msg--error"
if prefix != "DEBUG":
show_element("notify_box")
notify_box = document.getElementById("notify_box")
notification = document.createElement("div")