diff --git a/app/assets/javascripts/cancer_predict.js b/app/assets/javascripts/cancer_predict.js index d34384e..813f0f8 100644 --- a/app/assets/javascripts/cancer_predict.js +++ b/app/assets/javascripts/cancer_predict.js @@ -155,12 +155,22 @@ $(document).ready(function(){ $('.surgery_year').html($(this).html()); $('#current_year').change(); }); + for(var i = 0;i < $('#cancer_table_left_result .cancer-btn-group').length;i++){ + $('#cancer_table_right_result .cancer-btn-group').eq(i).find('.cancer_table_btn').eq(0).addClass('active'); + $('#cancer_table_right_result .cancer-btn-group').eq(i).find('>input').eq(0).attr('value',"1"); + }; + for(var i = 0;i < $('#cancer_table_right_result .cancer-btn-group').length;i++){ + $('#cancer_table_right_result .cancer-btn-group').eq(i).find('.cancer_table_btn').eq(0).addClass('active'); + $('#cancer_table_right_result .cancer-btn-group').eq(i).find('>input').eq(0).attr('value',"1"); + }; var treatmeny_method = result.responseJSON.treatmeny_method; + $('tr.'+treatmeny_method[0]).addClass('tr_show') var lpv = [0,-0.8397,-0.4147,-0.3203,0.3321]; var servive_ratio_arr = [result.responseJSON.servive_ratio] var yes = (I18n.locale=="zh_tw") ? "是" : "yes"; var year = $('#current_year').attr('value'); - var active_treatment = ['Surgery_only'] + var active_treatment = ['Surgery_only']; + $('.'+active_treatment[0]+' .Overall_Survival').html(servive_ratio_arr[0]); var lpv_real = [result.responseJSON['lpv']]; var lpv_dict={} var lpv_calc={1:-0.001476145,3:-0.01261639,5:-0.02519608} @@ -170,16 +180,97 @@ $(document).ready(function(){ var lpv_current = lpv_real[lpv_real.length-1]+lpv_dict[arguments[0]]; lpv_real.push(lpv_current); var servive_ratio = (Math.exp(lpv_calc[year])**lpv_current)*100; - var benefit = servive_ratio - servive_ratio_arr[servive_ratio_arr.legnth - 1]; + var benefit = servive_ratio - servive_ratio_arr[servive_ratio_arr.length - 1]; servive_ratio_arr.push(servive_ratio); $('tr.'+arguments[0]+' td.Overall_Survival').html(servive_ratio); $('tr.'+arguments[0]+' td.Additional_Benefit').html(benefit); - console.log(servive_ratio_arr[servive_ratio_arr.legnth - 1]); + $('tr.'+arguments[0]).css('display','table-row'); + $('tr.tr_show').eq(-1).after($('tr.'+arguments[0])); + $('tr.'+arguments[0]).addClass('tr_show'); + console.log(servive_ratio_arr); + if(this.length == 1){ + $('.addition').css('display','block'); + $('#result_text_content .extra-text').css('display','inline-block'); + } + var add_choices = this.slice(1,this.length); + add_choices.push(arguments[0]); + var add_choices_transform = []; + for(var i = 0;i= 2) + add_choices_str += ('以及'+add_choices_transform[add_choices_transform.length-1]) + else + add_choices_str = add_choices_transform[0]; + console.log(add_choices_transform); + var new_text = '

'+'100 位在術後有接受'+add_choices_str+'的婦女中,有 '+''+servive_ratio+''+' 位婦女,術後 '+''+year+''+'年仍為存活(多了'+''+benefit+'位)'+'

'; + $('#result_text_content .extra-text .texts_show').eq(-1).after(new_text) return Array.prototype.push.apply(this, arguments); }else{ return Array.prototype.push.apply(this, arguments); } }; + Array.prototype.remove_item_from_array = function(){ + var result_array = this; + for(var i=0;i= 2) + add_choices_str += ('以及'+add_choices_transform[add_choices_transform.length-1]) + else + add_choices_str = add_choices_transform[0]; + console.log(add_choices_transform); + var new_text = '

'+'100 位在術後有接受'+add_choices_str+'的婦女中,有 '+''+servive_ratio+''+' 位婦女,術後 '+''+year+''+'年仍為存活(多了'+''+benefit+'位)'+'

'; + $('#result_text_content .extra-text .texts_show').eq(-1).after(new_text) + return Array.prototype.remove_item_from_array.apply(this, arguments); + }else{ + return Array.prototype.remove_item_from_array.apply(this, arguments); + }; + }; for(var i = 0;i'+year+'')} result['texts'] += ',' @servive_ratio = (Math.exp(-0.001476145)**(result['lpv']))*100 - result['texts'] += ('100 位只接受根除性手術的婦女中,有 '+ ''+@servive_ratio.round.to_s+''+' 位婦女,術後 '+''+@years[0].to_s+''+'年仍為存活') - result['texts'] += '