<commit_before>/* Author: Praekelt */

$("#timepicker_1").timePicker({step:10, startTime:"00:00", endTime:"23:50", show24Hours: true,separator: ':',});
$('#conv-message').keyup(function(){
	    	$('#charcount').text($('#conv-message').val().length);
			if($('#conv-message').val().length>140){$('#valid-twitter').hide()}else{$('#valid-twitter').show()}
			if($('#conv-message').val().length>160){$('#valid-sms').hide()}else{$('#valid-sms').show()}
			$('span.preview-message').text($('#conv-message').val());
			
});

$('.typeahead').typeahead();

$(function() { $( "#datepicker" ).datepicker({ minDate: 0, dateFormat: 'yy-mm-dd' }); });
$(function() { $( "#dob" ).datepicker({ minDate: 0, dateFormat: 'yy-mm-dd' }); });

$('#surveyUSSD').click(function() {
	if($('#surveyUSSD').attr('checked')) { $('#surveyUSSDNum').show(); } else { $('#surveyUSSDNum').hide(); }
});

$('#search-filter-input').focus(function() {
	$('input#search-filter-input').val('');
});

$('#convtype').change(function() {
	var newAction = $('#convtype').val();
	$('#newConversationType').attr('action', newAction);
});

/* show or hide the tag pool options depending on the delivery class chosen */
$('.delivery-class-radio').change(function() {
    delivery_classes = $('.delivery-class-radio[name=delivery_class]');
    delivery_classes.each(function(index, element) {
        var deliveryClass = $(element);
        var tagPoolDiv = $('#' + deliveryClass.val() + '_tag_pool_selection');
        if($(deliveryClass).attr('checked')) {
            tagPoolDiv.show();
            $('#' + deliveryClass.val() + '_tag_pool_selection select').removeAttr('disabled');
        } else {
            tagPoolDiv.hide();
            $('#' + deliveryClass.val() + '_tag_pool_selection select').attr('disabled', 'disabled');
        }
    });

})<commit_msg>Add some magic Javascript to display / hide the option group.<commit_after>/* Author: Praekelt */

$("#timepicker_1").timePicker({step:10, startTime:"00:00", endTime:"23:50", show24Hours: true,separator: ':',});
$('#conv-message').keyup(function(){
	    	$('#charcount').text($('#conv-message').val().length);
			if($('#conv-message').val().length>140){$('#valid-twitter').hide()}else{$('#valid-twitter').show()}
			if($('#conv-message').val().length>160){$('#valid-sms').hide()}else{$('#valid-sms').show()}
			$('span.preview-message').text($('#conv-message').val());
			
});

$('.typeahead').typeahead();

$(function() { $( "#datepicker" ).datepicker({ minDate: 0, dateFormat: 'yy-mm-dd' }); });
$(function() { $( "#dob" ).datepicker({ minDate: 0, dateFormat: 'yy-mm-dd' }); });

$('#surveyUSSD').click(function() {
	if($('#surveyUSSD').attr('checked')) { $('#surveyUSSDNum').show(); } else { $('#surveyUSSDNum').hide(); }
});

$('#search-filter-input').focus(function() {
	$('input#search-filter-input').val('');
});

$('#convtype').change(function() {
	var newAction = $('#convtype').val();
	$('#newConversationType').attr('action', newAction);
});

function addOptGroupLabel(selectField) {
    stripOptGroupLabel(selectField);
    var selectedOpt = selectField.find('option:selected');
    var optGroupLabel = selectedOpt.closest('optgroup').attr('label');
    selectedOpt.prepend("<span class='optgroup-label'>"
                        + optGroupLabel + ": </span>");
}

function stripOptGroupLabel(selectField) {
    selectField.find('.optgroup-label').remove();
}

/* show or hide the tag pool options depending on the delivery class chosen */
$('.delivery-class-radio').change(function() {
    delivery_classes = $('.delivery-class-radio[name=delivery_class]');
    delivery_classes.each(function(index, element) {
        var deliveryClass = $(element);
        var tagPoolDiv = $('#' + deliveryClass.val() + '_tag_pool_selection');
        var selectField = $('#' + deliveryClass.val() + '_tag_pool_selection select');
        if($(deliveryClass).attr('checked')) {
            tagPoolDiv.show();
            selectField.removeAttr('disabled');
            selectField.blur(function() { addOptGroupLabel(selectField); });
            selectField.focus(function() { stripOptGroupLabel(selectField); });
            addOptGroupLabel(selectField);
        } else {
            tagPoolDiv.hide();
            selectField.attr('disabled', 'disabled');
        }
    });

})
{'fraction_non_alphanumeric': 0.24093023255813953, 'fraction_numerical': 0.009767441860465116, 'mean_word_length': 4.492975734355045, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '488888', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1321, 'n_words': 185}