From 67879d25c3ca1d6e3b1e8023a068e6fce7c8d70a 2016-05-10 22:08:19 From: Fiorella Quino Date: 2016-05-10 22:08:19 Subject: [PATCH] Task #99: Modulo web del JARS (static: jars.js) git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@152 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71 --- diff --git a/apps/jars/forms.py b/apps/jars/forms.py index 4085f01..56e274a 100644 --- a/apps/jars/forms.py +++ b/apps/jars/forms.py @@ -16,8 +16,8 @@ class JARSConfigurationForm(forms.ModelForm): self.fields['experiment'].widget.choices = [(experiment.id, experiment) for experiment in experiments] self.fields['device'].widget.choices = [(device.id, device) for device in devices] - self.fields['spectral'].widget = SpectralWidget() - + #self.fields['spectral'].widget = SpectralWidget() + self.fields['spectral'].widget = SpectralWidget() #-------------JARS Configuration needs an Experiment----------------- def clean(self): cleaned_data = super(JARSConfigurationForm, self).clean() diff --git a/apps/jars/static/js/jars.js b/apps/jars/static/js/jars.js new file mode 100644 index 0000000..63fbe6b --- /dev/null +++ b/apps/jars/static/js/jars.js @@ -0,0 +1,124 @@ +$(document).ready(function() { + var type = $("#id_exp_type").val(); + spectral_number = $("#id_spectral_number") + spectral = $("#id_spectral") + fftpoints = $("#id_fftpoints") + save_ch_dc = $("#id_save_ch_dc") + add_spec_button = $("#add_spectral_button") + del_spec_button = $("#delete_spectral_button") + sel_spec_button = $("#self_spectral_button") + cro_spec_button = $("#cross_spectral_button") + all_spec_button = $("#all_spectral_button") + + if (type == 0) { + $(spectral_number).attr('readonly', true); + $(spectral).attr('readonly', true); + $(fftpoints).attr('readonly', true); + $(save_ch_dc).attr('disabled', true); + $(save_ch_dc).attr('readonly', true); + $(add_spec_button).attr('disabled', true); + $(del_spec_button).attr('disabled', true); + $(sel_spec_button).attr('disabled', true); + $(cro_spec_button).attr('disabled', true); + $(all_spec_button).attr('disabled', true); + } + else { + $(spectral_number).attr('readonly', false); + $(spectral).attr('readonly', false); + $(fftpoints).attr('readonly', false); + $(save_ch_dc).attr('disabled', false); + $(save_ch_dc).attr('readonly', false); + $(add_spec_button).attr('disabled', false); + $(del_spec_button).attr('disabled', false); + $(sel_spec_button).attr('disabled', false); + $(cro_spec_button).attr('disabled', false); + $(all_spec_button).attr('disabled', false); + } +}); + +$("#id_exp_type").change(function() { + var type = $("#id_exp_type").val(); + spectral_number = $("#id_spectral_number") + spectral = $("#id_spectral") + fftpoints = $("#id_fftpoints") + save_ch_dc = $("#id_save_ch_dc") + add_spec_button = $("#add_spectral_button") + del_spec_button = $("#delete_spectral_button") + sel_spec_button = $("#self_spectral_button") + cro_spec_button = $("#cross_spectral_button") + all_spec_button = $("#all_spectral_button") + + if (type == 0) { + $(spectral_number).attr('readonly', true); + $(spectral).attr('readonly', true); + $(fftpoints).attr('readonly', true); + $(save_ch_dc).attr('disabled', true); + $(save_ch_dc).attr('readonly', true); + $(add_spec_button).attr('disabled', true); + $(del_spec_button).attr('disabled', true); + $(sel_spec_button).attr('disabled', true); + $(cro_spec_button).attr('disabled', true); + $(all_spec_button).attr('disabled', true); + } + else { + $(spectral_number).attr('readonly', false); + $(spectral).attr('readonly', false); + $(fftpoints).attr('readonly', false); + $(save_ch_dc).attr('disabled', false); + $(save_ch_dc).attr('readonly', false); + $(add_spec_button).attr('disabled', false); + $(del_spec_button).attr('disabled', false); + $(sel_spec_button).attr('disabled', false); + $(cro_spec_button).attr('disabled', false); + $(all_spec_button).attr('disabled', false); + } +}); + + +$("#id_cards_number").on('change', function() { + var cards_number = $("#id_cards_number").val(); + channels_number = $("#id_channels_number") + $(channels_number).val(cards_number*2) + updateChannelsNumber(); +}); + + +$("#id_channels_number").on('change', function() { + updateChannelsNumber(); +}); + + +$("#id_spectral").on('change', function() { + updateSpectralNumber(); +}); + + +function updateSpectralNumber(){ + var spectral_comb = $("#id_spectral").val(); + var num = spectral_comb.length; + var cont = 0 + for (i = 0; i < num; i++) { + if (spectral_comb[i] == "]"){ + cont = cont + 1 + } + } + $("#id_spectral_number").val(cont) +} + + +function updateChannelsNumber() { + + var channels_number = $("#id_channels_number").val(); + channels = $("#id_channels") + sequence = "" + + for (i = 1; i <= channels_number; i++) { + if (i==1){ + sequence = i.toString() + } + else{ + sequence = sequence + "," + i.toString() + } + } + $(channels).val(sequence) +} \ No newline at end of file diff --git a/apps/jars/templates/jars_conf_edit.html b/apps/jars/templates/jars_conf_edit.html index 81c2500..738b54c 100644 --- a/apps/jars/templates/jars_conf_edit.html +++ b/apps/jars/templates/jars_conf_edit.html @@ -4,131 +4,5 @@ {% load main_tags %} {% block extra-js%} - + {% endblock %} \ No newline at end of file diff --git a/apps/main/templates/dev_conf_edit.html b/apps/main/templates/dev_conf_edit.html index 327d7b5..770e53d 100644 --- a/apps/main/templates/dev_conf_edit.html +++ b/apps/main/templates/dev_conf_edit.html @@ -110,4 +110,8 @@ {% endif %} +{% if device == 'jars' %} + +{% endif %} + {% endblock %} \ No newline at end of file