Update utils.sh

This commit is contained in:
MacRimi
2025-11-30 18:05:56 +01:00
parent 9bd17bdf6f
commit fe53c11447

View File

@@ -493,6 +493,7 @@ hybrid_menu() {
if is_web_mode; then if is_web_mode; then
local interaction_id=$(generate_interaction_id) local interaction_id=$(generate_interaction_id)
local clean_text=$(echo -e "$text" | sed 's/\\Z[0-9bn]//g')
local options_json="[" local options_json="["
for ((i=0; i<${#items[@]}; i+=2)); do for ((i=0; i<${#items[@]}; i+=2)); do
if [ $i -gt 0 ]; then options_json+=","; fi if [ $i -gt 0 ]; then options_json+=","; fi
@@ -500,10 +501,10 @@ hybrid_menu() {
done done
options_json+="]" options_json+="]"
echo "WEB_INTERACTION:menu:${interaction_id}:$(echo -n "$title" | base64 -w0):$(echo -n "$text" | base64 -w0):$options_json" >> "${WEB_LOG:-/tmp/proxmenux_web.log}" echo "WEB_INTERACTION:menu:${interaction_id}:$(echo -n "$title" | base64 -w0):$(echo -n "$clean_text" | base64 -w0):$options_json" >> "${WEB_LOG:-/tmp/proxmenux_web.log}"
wait_for_web_response "$interaction_id" wait_for_web_response "$interaction_id"
else else
dialog --title "$title" --menu "$text" "$height" "$width" "$menu_height" "${items[@]}" 3>&1 1>&2 2>&3 dialog --colors --title "$title" --menu "$text" "$height" "$width" "$menu_height" "${items[@]}" 3>&1 1>&2 2>&3
fi fi
} }
@@ -516,11 +517,12 @@ hybrid_yesno() {
if is_web_mode; then if is_web_mode; then
local interaction_id=$(generate_interaction_id) local interaction_id=$(generate_interaction_id)
echo "WEB_INTERACTION:yesno:${interaction_id}:$(echo -n "$title" | base64 -w0):$(echo -n "$text" | base64 -w0)" >> "${WEB_LOG:-/tmp/proxmenux_web.log}" local clean_text=$(echo -e "$text" | sed 's/\\Z[0-9bn]//g')
echo "WEB_INTERACTION:yesno:${interaction_id}:$(echo -n "$title" | base64 -w0):$(echo -n "$clean_text" | base64 -w0)" >> "${WEB_LOG:-/tmp/proxmenux_web.log}"
local response=$(wait_for_web_response "$interaction_id") local response=$(wait_for_web_response "$interaction_id")
[[ "$response" == "yes" ]] && return 0 || return 1 [[ "$response" == "yes" ]] && return 0 || return 1
else else
dialog --title "$title" --yesno "$text" "$height" "$width" dialog --colors --title "$title" --yesno "$text" "$height" "$width"
fi fi
} }
@@ -533,10 +535,11 @@ hybrid_msgbox() {
if is_web_mode; then if is_web_mode; then
local interaction_id=$(generate_interaction_id) local interaction_id=$(generate_interaction_id)
echo "WEB_INTERACTION:msgbox:${interaction_id}:$(echo -n "$title" | base64 -w0):$(echo -n "$text" | base64 -w0)" >> "${WEB_LOG:-/tmp/proxmenux_web.log}" local clean_text=$(echo -e "$text" | sed 's/\\Z[0-9bn]//g')
echo "WEB_INTERACTION:msgbox:${interaction_id}:$(echo -n "$title" | base64 -w0):$(echo -n "$clean_text" | base64 -w0)" >> "${WEB_LOG:-/tmp/proxmenux_web.log}"
wait_for_web_response "$interaction_id" > /dev/null wait_for_web_response "$interaction_id" > /dev/null
else else
dialog --title "$title" --msgbox "$text" "$height" "$width" dialog --colors --title "$title" --msgbox "$text" "$height" "$width"
fi fi
} }