Commit 316ab164 authored by rg's avatar rg

Création

parent 7105ae63
# tools
# toolkit
Quelques outils utiles
Tous les outils et petites fonctions utiles quelque soit le langage
\ No newline at end of file
## bash
### SelectMenu
Permet d'effectuer une selection visuelle parmi une liste d'éléments.
## Javascript
### RGPWhat
Permet l'affichage de Popin de consentement RGPD. (bêta)
# selectmenu
Permet de créer un menu de navigation par touche fléchées.
Options:
-ro : retourne l'offset de la selection en partant de 1, plutot que le libellé de la selection
-s<offset>: préselectionne un élément. Par défaut 1. Pour ne rien préselectionner, entrer -s0
selectmenu() {
local POS=0;
local RET=0;
for var in $@; do
if [[ "$var" =~ ^-s([0-9]+)$ ]]; then POS=$[${BASH_REMATCH[1]}-1]; shift; fi
if [[ "$var" =~ ^-ro$ ]]; then RET=1; shift; fi
done
local NB_ITEMS=$#;
while true;
do
local i=0;
for item in $@;
do
local STYLE="\x1b[0m";
if [ $((i++)) -eq $POS ]; then STYLE="\e[7m"; fi
echo -en "$STYLE${item}\x1b[0m\n";
done
read -rsn1 key;
case "$key" in
$'\x1b') # Arrow hors escape
read -rsn2 -t0.1 key;
if [ "$key" = $'[A' ] && [ $POS -ne 0 ]; then POS=$[$POS-1]; fi
if [ "$key" = $'[B' ] && [ $POS -lt $[$NB_ITEMS-1] ]; then POS=$[$POS+1]; fi
if [ "$key" = "" ]; then return 1; fi
;;
"") # Enter
if [ $POS -ge 0 ]; then ((POS++)); break; fi
;;
esac
echo -e "\033["$[$NB_ITEMS+1]"A";
done
[[ $RET -eq 0 ]] && echo ${!POS} || echo $POS;
}
This diff is collapsed.
.rgpwhat {background-color: rgba(33,33,33,0.9); color: white; text-align: center; line-height: 2.5em; padding: 2px; vertical-align: middle; position: relative; top: 0;}
.rgpwhat button {line-height: 2.2em; margin-top: 2px; opacity: .9; color: white; background-color: #1BD2A4; border-radius: 5px; border: 0; padding: 0 20px; margin-left: 10px;}
.rgpwhat button:hover {opacity: 1;}
.rgpwhat .consent-list {background-color: black; padding: 1em; width: 100%;}
.rgpwhat .consent-list button {background-color: red; margin-left: 10px;}
.rgpwhat .consent-list button.selected {background-color: #1BD2A4;}
.rgpwhat .consent-list .all-cookies-choice {width: 50%; margin: auto; display: inline-block;}
.rgpwhat .consent-list .all-cookies-choice .action-close {border-radius: 20px; line-height: .5em; padding: .5em; float: right; background-color: #555; color: white;}
.rgpwhat .consent-list .all-cookies-choice .action-close:hover {opacity: .5;}
.rgpwhat .consent-list .cookie-choice {width: 50%; margin: auto; display: flex; flex-direction: row; align-items: center; border-bottom: 1px solid grey;}
.rgpwhat .consent-list .cookie-choice .explanations {text-align: left; flex: 2;}
.rgpwhat .consent-list .cookie-choice .explanations .title {font-size: 1.5em; font-weight: bold;}
.rgpwhat .consent-list .cookie-choice .explanations .description {line-height: 1em;}
.rgpwhat .consent-list .cookie-choice .buttons {flex: 1; text-align: right;}
.rgpwhat .consent-list .cookie-choice .buttons .accept, .rgpwhat .consent-list .cookie-choice .buttons .deny {color: white;}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment