diff --git a/sms/__init__.pyc b/sms/__init__.pyc deleted file mode 100644 index b248034..0000000 Binary files a/sms/__init__.pyc and /dev/null differ diff --git a/sms/config.pyc b/sms/config.pyc deleted file mode 100644 index 1ca3a8b..0000000 Binary files a/sms/config.pyc and /dev/null differ diff --git a/sms/model.pyc b/sms/model.pyc deleted file mode 100644 index 0b32b83..0000000 Binary files a/sms/model.pyc and /dev/null differ diff --git a/sms/static/sms.js b/sms/static/sms.js index bc4a84d..2ced1ec 100644 --- a/sms/static/sms.js +++ b/sms/static/sms.js @@ -1,42 +1,37 @@ var status_checker = 0; -$(function() { - $('#test').click(function() { - $('.sent_message:first').slideToggle(1000); - }); - - $("#sms_form").submit(function() { - // Post form data via AJAX - $.post($SCRIPT_ROOT + "/sms", $("#sms_form").serialize(), - function(data) { - // Insert returned HTML before the first message - $('#sent_message_list h2').after(data); - // Animate height expansion, then opacity - $('.new').animate({height: 'toggle'}) - .animate({opacity: 1}) - // Remove class so it doesn't catch animation again - .removeClass('new'); - // Check status of new messages at set interval - if(status_checker==0) { - status_checker = setInterval('checkStatus()', 5000); - } - }); - return false; - }); - +$("#sms_form").submit(function() { + // Post form data via AJAX + $.post($SCRIPT_ROOT + "/sms", $("#sms_form").serialize(), + function(data) { + // Insert returned HTML after the heading + $('#sent_message_list h2').after(data); + // Animate height expansion, then opacity + $('.new').animate({height: 'toggle'}) + .animate({opacity: 1}) + // Remove class so it doesn't catch animation again + .removeClass('new'); + // Check status of new messages at set interval + if(status_checker==0) { + status_checker = setInterval('checkStatus()', 5000); + } + }); + return false; }); function checkStatus() { - $('.queued, .sending, .fake').children('.status').each(function(i) { - if ($(this).text() == 'fake') { - $(this).html('TEST'); - } else { - $(this).html('FAIL'); - } - $(this).parent().removeClass('queued sending fake'); + // Check every message on the page with status "queued" or "sending" -- + // Twilio's status possibilities for unsent messsages + $('.queued, .sending').children('.status').each(function(i) { + var sid = $(this).parent().find('.sid').html(); + // Update status based on check with twilio + $(this).load($SCRIPT_ROOT + '/sms/update/' + sid, function(status) { + // Add class based on current status; remove former status class + $(this).parent().addClass(status).removeClass('queued sending'); }); - // Stop checking message status - clearInterval(status_checker); - status_checker = 0; + }); + // Stop checking message status + clearInterval(status_checker); + status_checker = 0; } diff --git a/sms/templates/index.html b/sms/templates/index.html index 8d9328f..214f1d7 100644 --- a/sms/templates/index.html +++ b/sms/templates/index.html @@ -17,14 +17,14 @@