Fill fields with default values
Some checks failed
continuous-integration/drone/push Build is pending
continuous-integration/drone/tag Build is failing

This commit is contained in:
nemunaire 2024-06-18 18:32:52 +02:00
parent 11163f059b
commit a4df681f88
3 changed files with 14 additions and 3 deletions

View File

@ -30,8 +30,11 @@ func DeclareNoJSRoutes(router *gin.Engine, cfg *config.Config, db *reveil.LevelD
return
}
defaultAlarm := time.Now().Add(460 * time.Minute)
if alarm == nil {
c.HTML(http.StatusOK, "index.tmpl", gin.H{
"defaultAlarm": defaultAlarm.Format("15:04"),
"noAlarm": true,
"isPlaying": player.CommonPlayer != nil,
})
@ -43,6 +46,7 @@ func DeclareNoJSRoutes(router *gin.Engine, cfg *config.Config, db *reveil.LevelD
nMinutes := int((time.Until(*alarm) / time.Minute) % 90)
c.HTML(http.StatusOK, "index.tmpl", gin.H{
"defaultAlarm": defaultAlarm.Format("15:04"),
"noAlarm": false,
"nextAlarmDate": alarm.Format("Mon 2"),
"nextAlarmTime": alarm.Format("15:04"),

View File

@ -57,7 +57,7 @@
<div style="display: flex; gap: 10px;">
<form method="post" action="/nojs.html">
<input type="hidden" name="action" value="new">
<input type="text" required name="time" placeholder="00:00">
<input type="text" required name="time" placeholder="00:00" value="{{ .defaultAlarm }}">
<button type="submit">
Nouvelle alarme
</button>

View File

@ -37,15 +37,22 @@
let obj;
const vtime = new Date(Date.now() + 7.6*3600000);
switch($page.params["kind"]) {
case "single":
obj = new AlarmSingle();
obj.time = vtime;
break;
case "repeated":
obj = new AlarmRepeated();
obj.weekday = vtime.getDay();
obj.time = (vtime.getHours() < 10 ? "0" : "") + vtime.getHours() + ":" + (vtime.getMinutes() < 10 ? "0" : "") + vtime.getMinutes();
break;
case "exceptions":
obj = new AlarmException();
obj.start = new Date(Date.now()).toISOString().substring(0,10);
obj.end = new Date(Date.now() + 7.5*86400000).toISOString().substring(0,10);
break;
}