summaryrefslogtreecommitdiff
path: root/lib/okpush/public
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2017-02-16 02:17:03 +0100
committerJules Laplace <jules@okfoc.us>2017-02-16 02:17:03 +0100
commitf40e2286faef696c25a81c04635aaf737606a39a (patch)
treebedf10e8c731deae7d275e0e5d9d6ded604db154 /lib/okpush/public
parent71e277a76862a1787ab34194faf762b7623347fd (diff)
lib
Diffstat (limited to 'lib/okpush/public')
-rw-r--r--lib/okpush/public/push.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/okpush/public/push.js b/lib/okpush/public/push.js
new file mode 100644
index 00000000..d369c903
--- /dev/null
+++ b/lib/okpush/public/push.js
@@ -0,0 +1,31 @@
+$(function(){
+ var count = $(".device-count").data("count");
+ 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}}", data.key).replace("{{count}}", count)
+ if (! confirm(msg)) return
+ $.ajax({
+ type: "POST",
+ url: "/_services/push/send",
+ data: { key: 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)
+ }
+ })
+ })
+}) \ No newline at end of file