blob: ca32fa987915b9693295ed9df912b39a94a7a0dd (
plain)
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
|
$(function(){
var confirm_msg = "This will send the notification {{key}} to {{count}} people. Click OK to confirm.";
$(".notifications button").click(function(){
var $el = $(this)
var data = $el.data()
var msg = confirm_msg.replace("{{key}}", capitalize(data.key)).replace("{{count}}", data.count)
if (! confirm(msg)) return
$.ajax({
type: "POST",
url: "/_services/push/send",
data: { channel: data.key },
success: function(){
alert("Push notification sent.")
var now = new Date()
// "%a %d-%b-%Y %H:%M"
var months = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")
var days = "Sun Mon Tue Wed Thu Fri Sat".split(" ")
var date = days[ now.getDay() ]
date += " " + now.getDate()
date += "-" + months[now.getMonth()]
date += "-" + now.getFullYear()
date += " " + now.getHours()
var mins = now.getMinutes()
if (mins < 10) mins = "0" + mins
date += ":" + mins
$el.closest("tr").find(".notification-date").html(date)
}
})
})
$('#custom').submit(function(e){
e.preventDefault()
var message = $("#message").val().trim()
var url = $("#url").val()
var msg = "This will send this push notification to everyone. Click OK to confirm.\n\n" + message
if (! confirm(msg)) return
$.ajax({
type: "POST",
url: "/_services/push/custom",
data: {
message: message,
url: url,
},
success: function(){
alert("Push notification sent.")
}
})
})
})
function capitalize (string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
|