Added Web frontend
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<script src="/static/tailwind.js"></script>
|
||||
</head>
|
||||
<body class="px-5 py-5">
|
||||
<h1 class="text-3xl font-bold">
|
||||
Study task-1
|
||||
</h1>
|
||||
<span class="text-lg mt-4 block">Realtime text transliteration service with API</span>
|
||||
<div class="block mt-5">
|
||||
<div class="mb-5">
|
||||
<label for="originalText" class="block mb-2 text-sm font-medium text-gray-900">Text to transliterate</label>
|
||||
<input type="text" id="originalText" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 ">
|
||||
</div>
|
||||
<div class="mb-5">
|
||||
<label for="transliteratedText" class="block mb-2 text-sm font-medium text-gray-900">Result</label>
|
||||
<input type="text" id="transliteratedText" disabled="" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 ">
|
||||
</div>
|
||||
</div>
|
||||
<a href="https://git.moondev.space/themoon/study-task-1" class="block mt-2 text-lg text-blue-500" target="_blank">REST API Reference</a>
|
||||
<script src="/static/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
29
static/main.js
Normal file
29
static/main.js
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
function transliterate(text) {
|
||||
const transliterationMap = {
|
||||
'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'yo', 'ж': 'zh', 'з': 'z', 'и': 'i',
|
||||
'й': 'y', 'к': 'k', 'л': 'l', 'м': 'm', 'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't',
|
||||
'у': 'u', 'ф': 'f', 'х': 'kh', 'ц': 'ts', 'ч': 'ch', 'ш': 'sh', 'щ': 'shch', 'ъ': '', 'ы': 'y', 'ь': '',
|
||||
'э': 'e', 'ю': 'yu', 'я': 'ya',
|
||||
'А': 'A', 'Б': 'B', 'В': 'V', 'Г': 'G', 'Д': 'D', 'Е': 'E', 'Ё': 'Yo', 'Ж': 'Zh', 'З': 'Z', 'И': 'I',
|
||||
'Й': 'Y', 'К': 'K', 'Л': 'L', 'М': 'M', 'Н': 'N', 'О': 'O', 'П': 'P', 'Р': 'R', 'С': 'S', 'Т': 'T',
|
||||
'У': 'U', 'Ф': 'F', 'Х': 'Kh', 'Ц': 'Ts', 'Ч': 'Ch', 'Ш': 'Sh', 'Щ': 'Shch', 'Ъ': '', 'Ы': 'Y', 'Ь': '',
|
||||
'Э': 'E', 'Ю': 'Yu', 'Я': 'Ya'
|
||||
};
|
||||
|
||||
let result = '';
|
||||
for (let char of text) {
|
||||
result += transliterationMap[char] || char;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const inputField = document.getElementById('originalText');
|
||||
const displayValue = document.getElementById('transliteratedText');
|
||||
|
||||
inputField.addEventListener('input', function(event) {
|
||||
displayValue.setAttribute("value", transliterate(event.target.value));
|
||||
});
|
||||
});
|
||||
874
static/tailwind.js
Normal file
874
static/tailwind.js
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user