olympiamanagement/app/assets/javascripts/admin/olympiamanagement.js

24 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-01-28 12:48:13 +00:00
$(document).ready(function(){
$('.class_setting_block input[type="reset"]').off('click').on('click',function(){
2020-01-28 12:48:13 +00:00
$('.col_input').val('');
});
$('.class_setting_block input[type="submit"]').off('click').on('click',function(){
2020-01-28 12:48:13 +00:00
var class_number_range = [];
class_number_range.push(Number($('.class_setting_block .col_input[name="MinClass"]').val()));
class_number_range.push(Number($('.class_setting_block .col_input[name="MaxClass"]').val()));
var enrollment_available = $('.class_setting_block .col_input#Person').val();
2020-01-28 12:48:13 +00:00
class_number_range.sort();
var params_array = (window.location.search.substring(1)=="") ? [] : window.location.search.substring(1).split('&').map(function(el){return el.split('=')});
var params = {};
params_array.forEach(function(el){params[el[0]] = el[1]});
var params_to_send = {'type':'class_setting','class_number_range':class_number_range,'enrollment_available':enrollment_available};
params_to_send = Object.assign(params,params_to_send);
var post_data = $.post('/admin/olympiamanagements/update_school_data',params_to_send);
post_data.done(function(){
window.location.search="";
});
2020-01-28 12:48:13 +00:00
});
var $el = $('.fieldset_block select');
for(var i = 0 ; i < $el.length ; i++)
$el.eq(i).find('option[value='+$el.eq(i).attr('value')+']').attr('selected','selected');
2020-01-28 12:48:13 +00:00
});