forked from hustcc/xmorse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
105 lines (98 loc) · 3.18 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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Xmorse is a pure JavaScript library for encoding/decoding morse code messages, unicode supported.</title>
<meta name="keywords" content="morse encode, morse decode, morse unicode" />
<meta name="description" content="xmorse is a pure JavaScript library for encoding/decoding morse code messages, unicode supported." />
<style type="text/css">
body {
max-width: 1000px;
margin: 0 auto;
}
pre {
background-color: #f6dcd7;
padding: 10px 15px;
white-space: pre-wrap;
word-wrap: break-word;
}
pre.strong {
font-weight: bold;
}
form, form textarea {
width: 100%;
}
</style>
</head>
<body>
<h1> Xmorse </h1>
<p>
Project <a href="https://github.com/hustcc/xmorse">xmorse</a> is a pure JavaScript (1.5 kb) library for encoding/decoding morse code messages, unicode supported.
</p>
<p>
项目 <a href="https://github.com/hustcc/xmorse">xmorse</a> 是一个 JavaScript 开发的摩斯密码编码库(1.5 kb),可以支持 unicode,例如中文摩斯密码。
</p>
<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- sorry for ad -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-7292810486004926"
data-ad-slot="7806394673"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<form>
<textarea rows='10' id='input'>I love you, 我爱你。</textarea>
<br />
Space: <input type='text' id='space' value='/' placeholder='space' />
Short: <input type='text' id='short' value='.' placeholder='short' />
Long: <input type='text' id='long' value='-' placeholder='long' />
<br />
<br />
<input type='button' onclick='encode()' value='Encode morse code' />
<input type='button' onclick='decode()' value='Decode morse code' />
</form>
<pre id='result'></pre>
<h2> Install </h2>
<pre class="strong">
npm install xmorse </pre>
<p> Then import it. </p>
<pre>
// import library use script tag.
<script type="text/javascript" src="dist/xmorse.min.js"></script>
// or ES6 style.
var WordWidth = require('xmorse');</pre>
<h3>Usage</h3>
<pre>
xmorse.encode('Hello, Xmorse!');
// unicode
xmorse.encode('コンニチハ, セカイ!');
xmorse.encode('越过长城,走向世界');
xmorse.decode('../.-../---');
</pre>
<hr />
<p>
The code of xmorse hosted on Github, click <a href="https://github.com/hustcc/xmorse">here</a>. Welcome to issue or pull request.
</p>
<script type="text/javascript" src="dist/xmorse.min.js"></script>
<script type="text/javascript">
function $_(id) {
return document.getElementById(id);
}
function getoption() {
return {
space: $_('space').value,
short: $_('short').value,
long: $_('long').value,
};
}
function encode() {
$_('result').innerHTML = xmorse.encode($_('input').value, getoption());
}
function decode() {
$_('result').innerHTML = xmorse.decode($_('input').value, getoption()) || 'Morse code is not valid.';
}
</script>
</body>
</html>