mai/views/index.html
yakumo.izuru 9b4b6b7193 Fix bugs, many other changes
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>

git-svn-id: https://svn.yakumo.dev/yakumo.izuru/mai/trunk@67 e410bdd4-646f-c54f-a7ce-fffcc4f439ae
2024-02-07 00:26:14 +00:00

139 lines
4.5 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<title>Mai</title>
<link rel="shortcut icon" href="/static/favicon.ico">
<meta name="description" content="Experience simple and private translations">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'">
<meta name="referrer" content="no-referrer">
<link rel="stylesheet" href="/static/style.css">
</head>
<body>
<header class="center">
<h1>Mai</h1>
</header>
<form action="/?engine={{.Engine}}" method="POST" id="translation-form">
<div class="center">
Choose translation engine:
<br>
{{$i := 0}}
{{ range $k, $v := .enginesNames }}
<a {{ if eq $k $.Engine }}style="text-decoration:underline" {{end}} href="/?engine={{ $k }}">{{ $v }}</a>
{{$i = (inc $i)}}
{{if eq $i (len $.enginesNames)}}{{else}}|{{end}}
{{end}}
</div>
<br>
<div class="wrap languages">
<div class="language">
<select name="from" aria-label="Source language">
{{range $code, $name := .SourceLanguages}}
{{if and (eq $code "auto") $.SourceLanguage}}
<option value="{{ $code }}" {{if eq $code $.From}}selected{{end}}>{{ $name }} ({{index
$.SourceLanguages $.SourceLanguage}})</option>
{{else }}
<option value="{{ $code }}" {{if eq $code $.From}}selected{{end}}>{{ $name }}</option>
{{end}}
{{end}}
</select>
</div>
<div class="switch_languages">
<button id="switchbutton" aria-label="Switch languages"
formaction="/switchlanguages/?engine={{ .Engine }}" type="submit">&lt;-&gt;</button>
</div>
<div class="language">
<select name="to" aria-label="Target language">
{{range $code, $name := .TargetLanguages}}
<option value="{{ $code }}" {{if eq $code $.To}}selected{{end}}>{{ $name }}</option>
{{end}}
</select>
</div>
</div>
<div class="wrap">
<div class="item-wrapper">
<textarea autofocus class="item" id="input" name="text" dir="auto" placeholder="Enter text here">{{ .OriginalText }}</textarea>
{{if .TtsFrom}}
<audio controls>
<source type="audio/mpeg" src="{{ .TtsFrom }}">
</audio>
{{end}}
</div>
<div class="item-wrapper">
<textarea id="output" class="translation item" dir="auto" readonly>{{.Translation.TranslatedText}}</textarea>
{{if .TtsTo}}
<audio controls>
<source type="audio/mpeg" src="{{ .TtsTo }}">
</audio>
{{end}}
</div>
</div>
<br>
<div class="center">
<button type="submit">Translate with {{ index .enginesNames .Engine }}!</button>
</div>
<br>
<div id="definitions_and_translations">
{{ if .Translation.Definitions }}
<div class="definitions">
{{ range $type, $definitions :=.Translation.Definitions }}
<span class="def_type">{{ $type }}</span>
<ol>
{{ range $definition_item := $definitions }}
<li>
{{ $definition_item.definition }}
<br>
{{with $definition_item.use_in_sentence}}
<span class="use_in_sentence">"{{$definition_item.use_in_sentence}}"</span>
<br>
{{end}}
{{with $definition_item.synonyms}}
{{ range $synonym_type, $_ := $definition_item.synonyms }}
<span class="syn">
{{if $synonym_type }}
<br>
<span class="syn_type">{{$synonym_type}}: </span>{{end}}{{ range $index, $element := index
$definition_item.synonyms $synonym_type}}{{if $index}}, {{end}}{{$element}}{{end}}
</span>
{{end}}
{{end}}
</li>
{{end}}
</ol>
{{end}}
</div>
{{ end}}
{{ if .Translation.Translations }}
<div class="translations">
{{ range $def_type, $translations := .Translation.Translations }}
<span class="def_type">{{ $def_type }}</span>
<ul>
{{ range $word, $word_translations := $translations }}
<li>
<span class="syn_type">{{$word}}:</span>
<span class="syn">{{ range $index, $element := $word_translations.words}}{{if $index}},
{{end}}{{$element}}{{end}}</span>
<span class="syn_type">{{$word_translations.frequency}}</span>
</li>
<br>
{{end}}
</ul>
{{end}}
</div>
{{end}}
</div>
</form>
<br><br><br><br><br>
<footer class="center">
<p>
<a href="https://git.chaotic.ninja/yakumo.izuru/mai">Source code</a>
</p>
<p>
A <a href="https://mirage.h0stname.net">Mirage AIB</a> project
</p>
</footer>
<script src="/static/script.js"></script>
</body>
</html>