summaryrefslogtreecommitdiff
path: root/lib/okpush/public/push.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2017-05-18 23:26:05 +0200
committerJules Laplace <jules@okfoc.us>2017-05-18 23:26:05 +0200
commit852b4d626cddac12fa8097be6bcff183f228bf52 (patch)
tree88b97a56122cf0205b92ea23bc5fbaecb487e63c /lib/okpush/public/push.js
parent3a94f72966125b2b0bffbd07bea75d9217a8cc44 (diff)
okpush
Diffstat (limited to 'lib/okpush/public/push.js')
-rw-r--r--lib/okpush/public/push.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/okpush/public/push.js b/lib/okpush/public/push.js
new file mode 100644
index 0000000..e75fc7f
--- /dev/null
+++ b/lib/okpush/public/push.js
@@ -0,0 +1,34 @@
+$(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)
+ }
+ })
+ })
+})
+
+function capitalize (string) {
+ return string.charAt(0).toUpperCase() + string.slice(1);
+} \ No newline at end of file