forked from SouICry/fetch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotification.html
More file actions
103 lines (86 loc) · 3.3 KB
/
notification.html
File metadata and controls
103 lines (86 loc) · 3.3 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/css/materialize.min.css">
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/js/materialize.min.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="/css/style.css">
<script src="js/underscore.js"></script>
<script src="js/loader.js"></script>
</head>
<body style="height: 100%;">
<div id="notifications">
</div>
<div id="chats">
<div class="chat" data-userId="123">
<div class="chat-head">
<div class="chat-name">
</div>
<div class="chat-close">
</div>
</div>
<div class="window"></div>
<div class="input">
<div class="photo">
</div>
<form class="chatForm">
<input name="message" type="text" id="enter_price" placeholder="Enter a message...">
</form>
</div>
</div>
</div>
</body>
</html>
<script>
$(document).ready(function () {
$('.chatForm').submit(function () {
event.preventDefault();
if (message.length > 0) {
var parent = $(this).parent();
var id = $(parent).data('userId');
$.ajax({
type: "POST",
url: "/chat",
contentType: "application/json",
dataType: "json",
data: JSON.stringify({
userIdToChat: id,
message: message
})
});
$(parent).find(".window").append("<div>" + message + "</div>");
$(this).val("");
}
});
});
function addNotification(notification) {
var e = $("#notifications");
$(e).append(notification);
setTimeout(function () {
$(e).children().last().css("transform", "translateX(-400px)")
}, 100);
setTimeout(function () {
$(e).children().first().data("changePage", "false").trigger("click");
}, 10000);
}
function closeNotification(page, element) {
element.style.transform = "translateX(0)";
setTimeout(function () {
element.parentNode.removeChild(element);
}, 600);
if (element.dataset.changePage == "true") {
goToPage(page);
}
}
function createNotification(userId, text, page, icon) {
var onClick = "loader.closeNotification('" + page + "', this);";
masters[userId].notifications.push('<div class="notification" data-changePage="true" onclick="' + onClick + '"><div class="icon"><i class="material-icons">'
+ icon + '</i></div><div class="text">' + text + '</div></div>');
}
</script>