Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
38 additions
and
47 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,42 +1,37 @@ | |||
var status_checker = 0; | var status_checker = 0; | ||
|
|
||
$(function() { | $("#sms_form").submit(function() { | ||
$('#test').click(function() { | // Post form data via AJAX | ||
$('.sent_message:first').slideToggle(1000); | $.post($SCRIPT_ROOT + "/sms", $("#sms_form").serialize(), | ||
}); | function(data) { | ||
|
// Insert returned HTML after the heading | ||
$("#sms_form").submit(function() { | $('#sent_message_list h2').after(data); | ||
// Post form data via AJAX | // Animate height expansion, then opacity | ||
$.post($SCRIPT_ROOT + "/sms", $("#sms_form").serialize(), | $('.new').animate({height: 'toggle'}) | ||
function(data) { | .animate({opacity: 1}) | ||
// Insert returned HTML before the first message | // Remove class so it doesn't catch animation again | ||
$('#sent_message_list h2').after(data); | .removeClass('new'); | ||
// Animate height expansion, then opacity | // Check status of new messages at set interval | ||
$('.new').animate({height: 'toggle'}) | if(status_checker==0) { | ||
.animate({opacity: 1}) | status_checker = setInterval('checkStatus()', 5000); | ||
// Remove class so it doesn't catch animation again | } | ||
.removeClass('new'); | }); | ||
// Check status of new messages at set interval | return false; | ||
if(status_checker==0) { | |||
status_checker = setInterval('checkStatus()', 5000); | |||
} | |||
}); | |||
return false; | |||
}); | |||
|
|||
}); | }); | ||
|
|
||
function checkStatus() { | function checkStatus() { | ||
$('.queued, .sending, .fake').children('.status').each(function(i) { | // Check every message on the page with status "queued" or "sending" -- | ||
if ($(this).text() == 'fake') { | // Twilio's status possibilities for unsent messsages | ||
$(this).html('TEST'); | $('.queued, .sending').children('.status').each(function(i) { | ||
} else { | var sid = $(this).parent().find('.sid').html(); | ||
$(this).html('FAIL'); | // Update status based on check with twilio | ||
} | $(this).load($SCRIPT_ROOT + '/sms/update/' + sid, function(status) { | ||
$(this).parent().removeClass('queued sending fake'); | // Add class based on current status; remove former status class | ||
$(this).parent().addClass(status).removeClass('queued sending'); | |||
}); | }); | ||
// Stop checking message status | }); | ||
clearInterval(status_checker); | // Stop checking message status | ||
status_checker = 0; | clearInterval(status_checker); | ||
status_checker = 0; | |||
} | } | ||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.