From d2299d24a23c9d0d835631b72e4f1d1974958f94 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 6 Oct 2016 17:08:38 -0400 Subject: js component --- examples/lib/okpush/public/push.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/lib/okpush/public/push.js (limited to 'examples/lib/okpush/public/push.js') diff --git a/examples/lib/okpush/public/push.js b/examples/lib/okpush/public/push.js new file mode 100644 index 0000000..d369c90 --- /dev/null +++ b/examples/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 -- cgit v1.2.3-70-g09d2