-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtext-conv.html
More file actions
58 lines (58 loc) · 2.15 KB
/
text-conv.html
File metadata and controls
58 lines (58 loc) · 2.15 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>
Text-Converter
</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css" rel="stylesheet">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<style type="text/css">
.first-jt {
margin-top: 25px;
}
</style>
</head>
<body>
<div class="navbar navbar-inverse navbar-static-top">
<div class="navbar-inner">
<a class="brand" href="../">jamietech</a>
<ul class="nav">
<li><a href="https://github.com/jamietech">Projects</a></li>
<li class="active"><a href=".">Text Converter</a></li>
</ul>
</div>
</div>
<div class="container first-jt">
<textarea placeholder="Enter text to convert" id="toConv" class="input-xxlarge"></textarea>
<div class="well">
<div id="converted">Enter text to convert</div>
</div>
<a href="#" id="giveMeGiveMe" class="btn btn-success">Copy</a>
</div>
<script type="text/javascript">
$('#toConv').bind('input propertychange', function() {
var oldText = $("#toConv").val();
var newText = "";
var up = true;
$.each(oldText.split("\n"), function(i, item) {
$.each(item.split(''), function(j, jtem) {
newText += (up ? jtem.toUpperCase() : jtem.toLowerCase());
if (newText != jtem && jtem != ' ')
up = !up;
});
if (newText != '')
newText += "<br>";
});
if (newText == "") {
newText = "Enter text to convert";
}
$("#converted").html(newText);
});
$("#giveMeGiveMe").click(function(event) {
event.preventDefault();
prompt("Press Ctrl-C (or ⌘-C) to copy the converted text.", $("#converted").html().replace(/<br>/g, '\n'));
});
</script>
</body>
</html>