bcmagic_status('Error', 'No redirect URL provided by server');
}
}
+ else if (data['mode'] == 'autofill')
+ {
+ bcmagic_autofill(data['field'], data['value'])
+ }
else {
bcmagic_message('Message recieved!');
bcmagic_status(data['mode'], data['status']);
var text = magic.attr('value');
magic.attr('value', '');
+ var bcm_mode = $("#id_bcm_mode");
+ var mode = bcm_mode.attr('value');
+
// Show what we have captured
bcmagic_message('Sent command to server');
- $.post('/bcmagic/magic/', {'text': text}, bcmagic_process_callback, 'json');
+ $.post('/bcmagic/magic/', {'text': text, 'bcm_mode': mode}, bcmagic_process_callback, 'json');
}
var bcmagic_keyhandler = function(e) {
window.location = url;
}
+var bcmagic_autofill = function(field, val)
+{
+ var txtbox = $('#'+field);
+ txtbox.attr('value', val);
+
+ var input_fields = $('form input').not(':hidden').not('[type=submit]');
+
+ // Count the number of text fields which have been filled in.
+ var count = 0;
+ input_fields.each( function(){
+ if(this.value.length > 0){
+ count = count + 1;
+ }
+ });
+
+ // If the number of text fields filled in is equal to the number of input_fields in the form, submit the form!
+ if (count == input_fields.length)
+ {
+ bcmagic_status('Form Full', 'Form is now full and ready to process');
+ }
+ else
+ {
+ bcmagic_status('Form Fill Count', 'Count(' + count +') - Total(' + input_fields.length + ')');
+ }
+}
+
//---------------------------------------
// Main Ready Function
//---------------------------------------