-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
71 lines (63 loc) · 2.15 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
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
This is a skeleton html file that you can use to get you started on each new
HTML project
Name: Your Name Here
Class: CIS 3303
Section: x
-->
<html>
<head>
<title>My Title</title>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.6.3.min.js"></script>
<script type="text/javascript">
// See the Configuring section to configure credentials in the SDK
AWS.config.credentials = {accessKeyId: 'AKIAJJLK5TACYCAGIHGQ', secretAccessKey: 'AHLkD0akakPYzpVXEEb8IZsGi3ypxcZPWRf3ZkTl'};
// Configure your region
AWS.config.region = 'us-east-1';
var sqs = new AWS.SQS();
setInterval(getMessage, 1000);
function getMessage() {
sqs.getQueueUrl({QueueName: 'Pipi'}, function (err, data) {
if (data) {
var url = data.QueueUrl; // use this queue URL to operate on the queue
var queue = new AWS.SQS({params: {QueueUrl: url}}); // using url to queue
queue.receiveMessage(function (err, data) {
var i, message, elem
if (data.Messages) {
for (i = 0; i < data.Messages.length; i++) {
message = data.Messages[i];
console.log(message); // message data in Messages structure
removeFromQueue(message);
}
if (message) {
elem = document.getElementById("viewport");
elem.src = './welcome.gif';
setTimeout( function() {
elem.src = 'black.jpg';
}, 10000);
}
}
});
function removeFromQueue(message) {
sqs.deleteMessage({
QueueUrl: url,
ReceiptHandle: message.ReceiptHandle
}, function(err, data) {
// If we errored, tell us that we did
err && console.log(err);
});
}
}
});
}
</script>
</head>
<body>
<div>
<img id='viewport' src='black.jpg'></img>
</div>
</body>
</html>