-
Notifications
You must be signed in to change notification settings - Fork 43
/
index.html
135 lines (112 loc) · 4.08 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>greybax/cyrillic-to-translit-js</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<style>
.container-fluid {
max-width: 960px;
}
.column {
margin-bottom: 20px;
}
.space-replacement {
margin-top: 20px;
}
#source,
#result {
height: 30vh;
min-height: 100px;
}
@media (max-width: 767px) {
.navbar-brand {
float: none;
padding-bottom: 0;
}
.navbar-text {
margin-top: 0;
padding: 0 15px;
}
}
</style>
</head>
<body>
<div class="navbar navbar-default navbar-static-top">
<div class="container-fluid">
<div class="navbar-header">
<div class="navbar-brand">
greybax/cyrillic-to-translit-js
</div>
<p class="navbar-text">
Simple javascript function for converting Cyrillic symbols to Translit
</p>
</div>
</div>
</div>
<div class="main container-fluid">
<div class="row">
<div class="column col-sm-6">
<textarea class="form-control" id="source" placeholder="Paste Cyrillic text here"></textarea>
<div class="space-replacement input-group">
<span class="input-group-addon">Presets</span>
<label class="btn btn-secondary">
<input type="radio" name="options" id="option-ru" value="ru" autocomplete="off" checked="checked"> Russian
</label>
<label class="btn btn-secondary">
<input type="radio" name="options" id="option-uk" value="uk" autocomplete="off"> Ukrainian
</label>
</div>
<div class="space-replacement input-group">
<span class="input-group-addon">Space replacement</span>
<input type="text" class="form-control text-center" id="space-rep">
</div>
</div>
<div class="column col-sm-6">
<textarea class="form-control" id="result" readonly placeholder="Get converted text here"></textarea>
</div>
</div>
<div class="text-center">
<a class="github-button" href="https://github.com/greybax" aria-label="Follow @greybax on GitHub">Follow
@greybax</a>
<a class="github-button" href="https://github.com/greybax/cyrillic-to-translit-js" data-icon="octicon-star"
aria-label="Star greybax/cyrillic-to-translit-js on GitHub">Star</a>
<a class="github-button" href="https://github.com/greybax/cyrillic-to-translit-js/fork"
data-icon="octicon-repo-forked" aria-label="Fork greybax/cyrillic-to-translit-js on GitHub">Fork</a>
</div>
</div>
<script>
var $source = document.querySelector('#source');
var $spaceRep = document.querySelector('#space-rep');
var $result = document.querySelector('#result');
var $ru = document.querySelector('#option-ru');
var $uk = document.querySelector('#option-uk');
var value;
var spaceRep;
$source.addEventListener('input', function (e) {
update(value = e.target.value, spaceRep);
});
$spaceRep.addEventListener('input', function (e) {
update(value, spaceRep = e.target.value);
});
$ru.addEventListener('click', function (e) {
update(value, spaceRep = $spaceRep.value);
});
$uk.addEventListener('click', function (e) {
update(value, spaceRep = $spaceRep.value);
});
function update(value, spaceRep) {
if ($ru.checked) {
$result.value = cyrillicToTranslit({ preset: 'ru' }).transform(value, spaceRep);
} else if ($uk.checked) {
$result.value = cyrillicToTranslit({ preset: 'uk' }).transform(value, spaceRep);
}
}
</script>
<script src="https://unpkg.com/cyrillic-to-translit-js@latest/dist/bundle.js"></script>
<script async defer src="https://buttons.github.io/buttons.js"></script>
</body>
</html>