-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
193 lines (169 loc) · 8.72 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Stegamsg</title>
<!-- Bootstrap core CSS -->
<link href="bootstrap-4.0.0-beta/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="/style.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="//cdn.materialdesignicons.com/2.0.46/css/materialdesignicons.min.css">
</head>
<body>
<nav class="navbar navbar-light gradient0 fixed-top">
<div class="form-inline my-2 my-lg-0">
<div class="input-group">
<input type="text" class="form-control" id="groupcode" placeholder="Group Code">
<div class="input-group-btn">
<button id="dropdown1" type="button" onclick="submit_()" class="btn btn-midcap"><i class="mdi mdi-check-circle-outline"></i></button>
<button onsubmit="submit_()" type="button" class="btn btn-endcap dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle dropdown</span>
</button>
<div onsubmit="submit_()" class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" onclick="function2()">Join a group</a>
<a class="dropdown-item" onclick="function1()">Create a group</a>
</div>
</div>
</div>
</div>
<a class="navbar-brand">Stegamsg</a>
<div class="form-inline">
<a style="margin-right:0.5em" class="btn btn-outline-dark my-2 my-sm-0" target="_blank" href="https://github.com/mhacksx/mhacksx">Github</a>
<a class="btn btn-outline-dark my-2 my-sm-0" target="_blank" href="https://devpost.com/software/stegamsg">Devpost</a>
</div>
</nav>
<script>
var a = 1;
function function1() {
a = 2
$("#dropdown1").html("<i class=\"mdi mdi-plus-circle-outline\"></i>")
}
function function2() {
a = 1
$("#dropdown1").html("<i class=\"mdi mdi-check-circle-outline\"></i>")
}
function submit_() {
if (a == 2) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
}
};
xhttp.open("POST", "/new", false);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("groupname="+$("#groupcode").val());
socket.emit("getKey", "tempcookie="+$("#groupcode").val()+";")
$("#groupcode").val("")
} else {
socket.emit("getKey", "tempcookie="+$("#groupcode").val()+";")
$("#groupcode").val("")
}
clrmsgs();
}
function clrmsgs() {
$('#canvases').empty();
}
</script>
<div class="content-view container-fluid">
<div class="d-flex flex-column">
<div id="channel"></div>
<div id="key_"></div>
<div id="canvases">
<!-- messages get appended to here -->
</div>
</div>
<div class="footer navbar fixed-bottom">
<input type="text" class="form-control align-bottom" placeholder="Enter a message..." id="textbox"></input>
</div>
</div>
<!-- bootstrap stuff -->
<script src="bootstrap-4.0.0-beta/assets/js/vendor/popper.min.js"></script>
<script src="bootstrap-4.0.0-beta/dist/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="bootstrap-4.0.0-beta/assets/js/ie10-viewport-bug-workaround.js"></script>
<!-- other stuff -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<!-- scripts to communicate with node -->
<script src="lsbtools.min.js"></script>
<script>
function getDataFromImage(imageName, key, callback_) {
var image = new Image();
image.onload = function() {
canvas = document.createElement('canvas')
context = canvas.getContext('2d')
canvas.width = image.width;
canvas.height = image.height;
context.drawImage(image, 0, 0, canvas.width, canvas.height);
imageData = context.getImageData(0, 0, canvas.width, canvas.height);
pixels = imageData['data'];
options = {
shuffle: true, // spread data across image instead of writing sequentially
matrix: true, // use matrix encoding to minimize changes
mask: true, // mask data with stream of random bytes
key: key, // array of bytes used as key for shuffling and masking
pm1code: true // use ±1 encoding instead of LSB flip
};
message = lsbTools.read(pixels, options)
messageString = ""
for (x = 0; x < message.length; ++x)
messageString += String.fromCharCode(message[x])
// now redraw with better dimensions
var ratio = image.height / image.width;
canvas.width = window.innerWidth / 5 ;
canvas.height = ratio * canvas.width;
context.drawImage(image, 0, 0, canvas.width, canvas.height);
callback_({"Text":messageString, "Canvas":canvas});
}
image.src = imageName;
};
</script>
<script>
var socket = io.connect('/');
var KEY = []
var channelName_ = ""
var isSent = false;
socket.on('in', function (fileName) {
getDataFromImage(fileName, KEY, function(data) {
// show messages on the right
var d = new Date();
var dstr = moment().format('Do MMMM, HH:mm');
$("#canvases").append("<div class=\"clearfix\"></div>");
if (isSent) {
$("#canvases .clearfix:last-child").html("<div class=\"gradient" + Math.floor(Math.random() * 15) + " float-right message\" data-toggle=\"tooltip\"></div>");
} else { // show messages on the left
$("#canvases .clearfix:last-child").html("<div class=\"gradient" + Math.floor(Math.random() * 15) + " float-left message\" data-toggle=\"tooltip\"></div>");
}
$("#canvases .clearfix:last-child div").attr('title', data['Text']);
$("#canvases .clearfix:last-child div").append("<p class=\"msg-timestamp\">" + dstr + "</p>");
$("#canvases .clearfix:last-child div").append(data['Canvas']);
$('html, body').animate({scrollTop: $('#canvases').height()}, 1000);
isSent = false;
});
});
socket.on("gotInfo", function(channelName, key) {
KEY = key
if (channelName != null) {
$("#channel").html("Channel name: " + channelName)
$("#key_").html(JSON.stringify(key))
}
else {
$("#channel").html("Error: Could not connect")
$("#key_").html("No Key")
}
channelName_ = channelName
});
$('#textbox').keyup(function(e){
if(e.keyCode == 13) {
isSent = true;
socket.emit('out', $("#textbox").val(), KEY, channelName_);
$("#textbox").val("");
}
});
</script>
</body>
</html>