App.Views.NewPing = Backbone.View.extend({ events:{ "submit form" : "ping" }, initialize: function() { var name = this.model.get('name'); this.render(name); this.model.new_ping(name); if(name == undefined) this.model.get_users('ping'); }, ping: function(e) { e.preventDefault(); var users = $('#pinguser').val().split(','); var message = $('#pingmessage').val(); var vibrate = $('#pingvibrate').val(); var sound = $('#pingsound').val(); var badge = $('#pingbadge').val(); var sources = $('#sources').val(); if(sources.length > 0) { sources = sources.split(','); } else { sources = []; } var token = this.model.get('api_token'); $.ajax({ type: 'POST', url: '/rc/v1/users/ping', data: { user_id : users, message : message, vibrate : vibrate, sound : sound, badge : badge, sources : sources }, beforeSend: function (HttpRequest) { HttpRequest.setRequestHeader("X-RhoConnect-API-TOKEN", token); }, success: function(){ router.navigate("users", true); }, error: function(resp){ if(resp.status == 422){ new App.Views.Index() } $('#ping-alert')[0].innerHTML = resp.responseText; $('#ping-alert').css('display','block'); } }) }, render: function(name) { $('#secondary-nav').css('display','block'); out = ""; out += ""; out += "
"; out += ""; out += ""; out += "" out += ""; out += "" out += ""; out += "" out += ""; out += "" out += "" out += "" out += "" out += "
Message:Message to be displayed in push notification
SourcesList of sources to be synchronized
Soundallows you to play audio file if it exists on client
BadgeNumber displayed on device next to app when push notification arrives. Available for iPhone
Vibrate (milliseconds)Duration of vibration when push notification is received
"; $(this.el).html(out); $('#main_content').html(this.el); } });