-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
147 lines (131 loc) · 5.82 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
136
137
138
139
140
141
142
143
144
145
146
147
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="author" content="Nathan Cooper">
<meta name="description"
content="convert numbers to hexadecimal, translate hex numbers to hex words, and hear them spoken">
<meta name="keywords" content="hexadecimal,decimal,translation,html5,speech api">
<title>hexpeak | hexadecimal translator and reader</title>
<link rel="shortcut icon" type="image/x-icon" href="icon/favicon.ico">
<link rel="stylesheet" type="text/css" href="hexpeak.css">
<link rel="stylesheet" type="text/css" id="ui-css"
href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/themes/smoothness/jquery-ui.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js"></script>
<script src="hexpeak.js"></script>
</head>
<body>
<h4>Input a number into any field</h4>
<div class="t">
<div class="tr">
<div>
<table>
<tr title="decimal"><td>Dec</td>
<td><div data-radix="10" contenteditable></div></td></tr>
<tr title="binary"><td>Bin</td>
<td><div data-radix="2" contenteditable></div></td></tr>
<tr title="octal"><td>Oct</td>
<td><div data-radix="8" contenteditable></div></td></tr>
<tr title="hexadecimal"><th>Hex</th>
<td><div data-radix="16" contenteditable id="hex"></div></td></tr>
</table>
<div class="center" id="widget-bar">
<button id="zero" title="clear fields">zero</button>
<button id="random" title="get a random number">random</button>
<span id="count-type">
<!--<input type="radio" name="counting" id="frac" checked>
<label for="frac" title="Fractional numbers">n.m<sup> </sup></label>-->
<input type="radio" name="counting" id="card" checked>
<label for="card" title="Cardinal numbers">n<sup> </sup></label>
<input type="radio" name="counting" id="ord">
<label for="ord" title="Ordinal numbers">n<sup>th</sup></label>
</span>
<button id="playback" title="read aloud">playback button</button>
</div>
</div>
<p id="translation" title="translation of hex appears here"></p>
</div>
</div>
<footer><span><a href="https://github.com/ncoop/hexpeak/">View hexpeak source</a></span>
<span>Hexadecimal lexicon from <a href="http://www.intuitor.com/hex/words.html">Hex Headquarters</a></span>
</footer>
<script>
$(function () {
var trans = $( "#translation" ), playBtn = $( "#playback" ), randBtn = $( "#random" ),
fields = $("[contenteditable]" ), cols = $( ".tr>*" );
/* create a header, populate it from the meta description, and prepend to body */
$( "<h3></h3>" ).text( $( "meta[name='description']" ).attr( "content" )).prependTo( "body" );
/* expand tooltip content */
$( "tr[title]" ).each(function() {
$(this).attr( "title", "enter a number in " + $(this).attr( "title" ) );
});
/* auto-tooltips for web links */
$( "a[href]:not([title])" ).each(function() {
$(this).attr( "title", $(this).attr( "href" ) );
});
/* deactivate spellcheck for input fields */
fields.attr( "spellcheck", "false");
/* widgetize the appropriate elements */
$( "#count-type" ).buttonset();
$( "#zero" ).button({
icons: {
primary: "ui-icon-radio-off"
},
text: false
}).click(function() {
zeroFields();
});
randBtn.attr( "title", randBtn.attr( "title" ) + " from 0x" + rand.min.toString(0x10).toUpperCase() +
" to 0x" + rand.max.toString(0x10).toUpperCase() ).button({
icons: {
primary: "ui-icon-shuffle"
},
text: false
}).click(function() {
randFields();
});
playBtn.button({
icons: {
primary: "ui-icon-play"
},
text: false
});
/* statically assign UI class */
$( "body" ).addClass( "ui-state-default" );
$( "h3, h4, footer" ).add( cols, fields ).addClass( "ui-widget" );
$( cols, fields ).addClass( "ui-corner-all" );
trans.add( fields ).addClass( "ui-state-active" );
/* dynamically assign UI class */
fields.each(function() {
$(this).focus(function() {
$(this).addClass( "ui-state-highlight" );
});
$(this).blur(function() {
$(this).removeClass( "ui-state-highlight" );
});
});
/* detect if speech API is supported */
if (typeof SpeechSynthesisUtterance === "undefined") {
playBtn.button( "disable" );
$( "<div></div>" ).addClass( "ui-widget" )
.css({"text-align": "center", "font-size": "smaller", "text-indent": ".5em"}).append(
$( "<section></section>" ).text( "The speech synthesis API doesn't work in this browser. Try Chrome?" )
.addClass( "ui-state-error ui-corner-all" ).prepend(
$( "<span></span>" ).addClass( "ui-icon ui-icon-alert" ).css( "float", "left" )
)
).insertAfter( ".t" );
} else {
var speech = initSpeech();
playBtn.click(function () {
if ( speechSynthesis.speaking ) {
speech.stop();
} else {
speech.start();
}
});
}
});
</script>
</body>
</html>