From 285c543f71d65bcd34cf72d0e03085b3915bff89 Mon Sep 17 00:00:00 2001 From: chiu Date: Fri, 23 Oct 2020 10:53:56 +0800 Subject: [PATCH] Remove unused file. --- app/assets/javascripts/cancer_predict.js | 4 +- cancer_predict.js | 926 ----------------------- 2 files changed, 2 insertions(+), 928 deletions(-) delete mode 100644 cancer_predict.js diff --git a/app/assets/javascripts/cancer_predict.js b/app/assets/javascripts/cancer_predict.js index 24c00f7..b7669e7 100644 --- a/app/assets/javascripts/cancer_predict.js +++ b/app/assets/javascripts/cancer_predict.js @@ -594,7 +594,7 @@ $(document).ready(function(){ function calculate_first_lpv(result_json){ result = {}; var map_values , mapping_hash , temp_index ,temp_value , index , closest_value; - result['sex_value'] = Number(result_json['sex_value']) - 1; + result['sex_value'] = (2 - Number(result_json['sex_value'])); result['age'] = Number(result_json['age']); mapping_hash = mapping_data_from_csv['age']; temp_index = 0; @@ -731,7 +731,7 @@ function calculate_first_lpv(result_json){ function calculate_servive_ratio(year,obj){ var servive_ratio; - console.log(obj); + var A = obj['A']; switch(year) { case '1': diff --git a/cancer_predict.js b/cancer_predict.js deleted file mode 100644 index 24c00f7..0000000 --- a/cancer_predict.js +++ /dev/null @@ -1,926 +0,0 @@ -Array.prototype.get_nearest_value = function(goal){ - var nearest_value = this.reduce(function(prev, curr) { - return (Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev); - }); - return nearest_value; -} -function change_object_variables(obj1,obj2,operator="-",target="new"){ - var obj_new = {}; - Object.keys(function(k){ - if(operator == "-"){ - if( target == "new"){ - obj_new[k] = obj1[k] - obj2[k]; - }else{ - obj1[k] = obj1[k] - obj2[k]; - } - }else if(operator == "+"){ - if( target == "new"){ - obj_new[k] = obj1[k] + obj2[k]; - }else{ - obj1[k] = obj1[k] + obj2[k]; - } - } - }) - if( target == "new"){ - return obj_new; - }else{ - return obj1; - } -} -$(document).ready(function(){ - var head_data = $.post("/cancerpredictResult",{"header":1,locale:I18n.locale}); - var data = {}; - if(I18n.locale == 'en'){ - var window_width = $(window).width(); - if(window_width < 520){ - $('#cancer_table .cencer_table_name').css('max-width',''); - }else if(window_width < 768){ - $('#cancer_table .cencer_table_name').css({'max-width':'','width':'11em'}); - }else if(window_width < 860){ - $('#cancer_table .cencer_table_name').css('max-width','30%'); - }else if(window_width < 1130){ - $('#cancer_table .cencer_table_name').css('max-width','33%'); - }else{ - $('#cancer_table .cencer_table_name').css('max-width','39%'); - }; - }; - function round(num,Digit=0){ - return Math.round(Number(num)*(10**Digit))/(10**Digit); - }; - head_data.done(function(){ - // $('.header-nav').html(head_images.responseJSON['head_images']); - // $('.navbar-brand').html(head_images.responseJSON['title']) - data['danger_texts'] = head_data.responseJSON['danger_texts']; - $('head title').text(head_data.responseJSON['page_title']) - }); - var mapping_data = $.post("/cancerpredictResult",{"get_mapping_data_from_csv":1,locale:I18n.locale}); - mapping_data.done(function(){ - // $('.header-nav').html(head_images.responseJSON['head_images']); - // $('.navbar-brand').html(head_images.responseJSON['title']) - window.mapping_data_from_csv = mapping_data.responseJSON['mapping_data_from_csv']; - }); - Array.prototype.remove_item_from_array = function(){ - var result_array = this; - for(var i=0;i $(this).data('range')[1] && $(this).data('range')[1] != undefined) ){ - $(this).css('color','#f24a69'); - $(this).addClass('cancertable_empty'); - }else{ - $(this).css('color','#333'); - $(this).removeClass('cancertable_empty'); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }; - }); - $('input#lymph_nodes_positive').off('input').on('input',function(){ - $(this).siblings('.num_only_value').val($(this).val()); - if( Number($(this).val()) < $(this).data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range_new')[1] && $(this).data('range_new')[1] != undefined) ){ - $(this).css('color','#f24a69'); - $(this).addClass('cancertable_empty'); - }else{ - $(this).css('color','#333'); - $(this).removeClass('cancertable_empty'); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }; - }); - $('input#lymph_nodes_examined').off('input').on('input',function(){ - $(this).siblings('.num_only_value').val($(this).val()); - if( Number($(this).val()) < $(this).data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range_new')[1] && $(this).data('range_new')[1] != undefined) ){ - $(this).css('color','#f24a69'); - $(this).addClass('cancertable_empty'); - }else{ - $(this).css('color','#333'); - $(this).removeClass('cancertable_empty'); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }; - }); - $('.cancer_help_btn').off("click").on('click',function(){ - var modal_head = ""; - try{ modal_head = $(this).parent().find(">label").html()}catch(e){}; - var modal_body = ""; - try{ modal_body = $(this).parent().find(">input.help_texts").attr('value')}catch(e){}; - $('#show_help_modal').html("") - $('#show_help_modal').modal('show'); - $('#show_help_modal .close').off("click").on('click',function(){ - $('#show_help_modal').modal('hide'); - }); - $('#show_help_modal .modal-footer button').off("click").on('click',function(){ - $('#show_help_modal').modal('hide'); - }); - }); - $('.btn-add').click(function(){ - $(this).parent().find('.num_only').removeClass('cancertable_empty'); - if($(this).parent().find('.num_only').val()!=""){ - var input_value = Number($(this).parent().find('.num_only').val()); - if(Array.isArray($(this).parent().find('.num_only').data('range'))){ - var compare_value = $(this).parent().find('.num_only').data('range')[1]; - if(compare_value != undefined){ - if(input_value+1 <= Number(compare_value)) - $(this).parent().find('.num_only').val(input_value+1); - else{ - input_value = $(this).parent().find('.num_only').data('range')[0]; - if(input_value != undefined) - $(this).parent().find('.num_only').val(input_value); - }; - }else{ - $(this).parent().find('.num_only').val(input_value+1); - }; - compare_value = $(this).parent().find('.num_only').data('range')[0]; - if(compare_value != undefined){ - if($(this).parent().find('.num_only').val() >= compare_value){ - $(this).parent().find('.num_only').removeClass('cancertable_empty'); - $(this).parent().find('.num_only').css('color','#333'); - }; - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }else{ - $(this).parent().find('.num_only').removeClass('cancertable_empty'); - $(this).parent().find('.num_only').css('color','#333'); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }; - }; - }else{ - try{ - var input_value = $(this).parent().find('.num_only').data('range')[0]; - if(input_value != undefined) - $(this).parent().find('.num_only').val(input_value); - }catch(e){ - $(this).parent().find('.num_only').val(0); - }; - if($(this).parent().find('.num_only').val() != ""){ - $(this).parent().find('.num_only').removeClass('cancertable_empty'); - $(this).parent().find('.num_only').css('color','#333'); - }; - }; - }); - $('.btn-sub').click(function(){ - if($(this).parent().find('.num_only').val()!=""){ - var input_value = Number($(this).parent().find('.num_only').val()); - if(Array.isArray($(this).parent().find('.num_only').data('range'))){ - var compare_value = $(this).parent().find('.num_only').data('range')[0]; - if(compare_value != undefined){ - if(input_value-1 >= Number(compare_value)) - $(this).parent().find('.num_only').val(input_value-1); - else{ - input_value = $(this).parent().find('.num_only').data('range')[1]; - if(input_value != undefined) - $(this).parent().find('.num_only').val(input_value); - }; - }else{ - $(this).parent().find('.num_only').val(input_value-1); - }; - compare_value = $(this).parent().find('.num_only').data('range')[1]; - if(compare_value != undefined){ - if($(this).parent().find('.num_only').val() <= compare_value){ - $(this).parent().find('.num_only').removeClass('cancertable_empty'); - $(this).parent().find('.num_only').css('color','#333'); - }; - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }else{ - $(this).parent().find('.num_only').removeClass('cancertable_empty'); - $(this).parent().find('.num_only').css('color','#333'); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }; - }; - }else{ - try{ - var input_value = $(this).parent().find('.num_only').data('range')[1]; - if(input_value != undefined){ - $(this).parent().find('.num_only').val(input_value); - }else{ - input_value = $(this).parent().find('.num_only').data('range')[0]; - if(input_value != undefined) - $(this).parent().find('.num_only').val(input_value); - } - }catch(e){ - $(this).parent().find('.num_only').val(0); - }; - if($(this).parent().find('.num_only').val() != ""){ - $(this).parent().find('.num_only').removeClass('cancertable_empty'); - $(this).parent().find('.num_only').css('color','#333'); - }; - }; - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }); - $('.cancer_table_btn').off('click').on('click',function(){ - var index = $(this).index()/2; - try{ - $(this).parent().find('>input').attr('value',0); - $(this).parent().find('>input').eq(index).attr('value',1); - $(this).parent().find('>button').removeClass('active'); - $(this).parent().removeClass('cancertable_empty'); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }catch(e){}; - $(this).addClass('active'); - }); - $('#cancer_table_reset').click(function(){ - $('.cancer_table_btn').removeClass('active'); - $('.cancer-btn-group input').attr('value',0); - $('.num_only').val(''); - $('.num_only_value').val(''); - $('#cancer_table .cancer_form_field').removeClass('cancertable_empty'); - $('#cancer_predict_result_block').css('display','none'); - $('#danger_texts').remove(); - $('select.select_num').val(''); - }); - function get_input_data(){ - var flag; - flag = 1; - for(var i = 0;i < $('#cancer_table .cancer_form_field').length;i++){ - if($('#cancer_table .cancer_form_field').eq(i).hasClass('num_only')){ - if($('#cancer_table .cancer_form_field').eq(i).val()==""){ - flag = 0; - $('#cancer_table .cancer_form_field').eq(i).addClass('cancertable_empty'); - }else if($('#cancer_table .cancer_form_field').eq(i).val() != "" && !$('#cancer_table .cancer_form_field').eq(i).hasClass('cancertable_empty')){ - $('#cancer_table .cancer_form_field').eq(i).removeClass('cancertable_empty'); - }; - }else{ - if($('#cancer_table .cancer_form_field').eq(i).find('[value="1"]').length == 0){ - flag = 0; - $('#cancer_table .cancer_form_field').eq(i).addClass('cancertable_empty'); - }else{ - $('#cancer_table .cancer_form_field').eq(i).removeClass('cancertable_empty'); - } - }; - }; - if( Number($('input#lymph_nodes_examined').siblings('.num_only_value').val()) < Number($('input#lymph_nodes_positive').siblings('.num_only_value').val())){ - $('input#lymph_nodes_positive').addClass('cancertable_empty'); - $('input#lymph_nodes_positive').css('color','rgb(242, 74, 105)'); - }; - if($('.cancertable_empty').length != 0){ - flag = 0; - ($('#danger_texts').length == 0) ? $('#cancer_table_submit').parent().before(''+data['danger_texts']+'') : null; - $('#danger_texts').css('margin-left',$(window).width()/2-$('#danger_texts').width()/2); - }else{ - $('#danger_texts').remove(); - }; - if(flag == 1){ - var post_json= {}; - for(var i = 0;i < $('#cancer_table .cancer_form_field').length;i++){ - var name = $('#cancer_table .cancer_form_field').eq(i).attr('id') - if($('#cancer_table .cancer_form_field').eq(i).hasClass('num_only')) - post_json[name] = Number($('#cancer_table .cancer_form_field').eq(i).siblings('.num_only_value').val()); - else{ - var index = ($('#cancer_table .cancer_form_field').eq(i).find('[value="1"]').index()+1)/2; - post_json[name] = index; - }; - }; - if( post_json["ER_status"] == 2 && post_json["PR_status"] == 2 ){ - $('#hormone_therapy .cancer_table_btn').attr('disabled','disabled'); - $('[for="hormone_therapy"]').css('color','rgb(204, 204, 204)'); - }else{ - $('#hormone_therapy .cancer_table_btn').removeAttr('disabled'); - $('[for="hormone_therapy"]').css('color',''); - }; - if(post_json["HER2_status"] != 1){ - $('#Targeted_therapy .cancer_table_btn').attr('disabled','disabled'); - $('[for="Targeted_therapy"]').css('color','rgb(204, 204, 204)'); - }else{ - $('#Targeted_therapy .cancer_table_btn').removeAttr('disabled'); - $('[for="Targeted_therapy"]').css('color',''); - }; - return post_json; - }else{ - return null; - } - }; - function set_result(result){ - if(result.responseJSON.lpv != "error"){ - $('#choice_fields .cancer_table_btn').removeClass('active'); - var load_heml = $('#result_table_content').html(result.responseJSON.table); - load_heml.ready(function(){ - $('#result_table_content .cancer_years').eq(0).addClass('active'); - for(var i = 0;i < $('#result_table_content .cancer_years').length;i++){ - $('#result_table_content .cancer_years').eq(i).attr('index',i) - }; - $('#result_table_content .cancer_years').off('click').on('click',function(){ - try{ - $(this).parent().find('.cancer_years').removeClass('active'); - }catch(e){}; - $(this).addClass('active'); - $('#current_year').attr('index',$(this).attr('index')); - $('#current_year').attr('value',$(this).html()); - $('#current_year').change(); - }); - }); - load_heml = $('#result_text_content').html(result.responseJSON.texts); - load_heml.ready(function(){ - $('#result_text_content .cancer_years').eq(0).addClass('active'); - for(var i = 0;i < $('#result_text_content .cancer_years').length;i++){ - $('#result_text_content .cancer_years').eq(i).attr('index',i) - }; - $('#current_year').off('change'); - $('#result_text_content .cancer_years').off('click') - $('#result_text_content .cancer_years').click(function(){ - try{ - $(this).parent().find('.cancer_years').removeClass('active'); - }catch(e){}; - $(this).addClass('active'); - $('#current_year').attr('value',$(this).html()); - $('#current_year').attr('index',$(this).attr('index')); - $('.surgery_year').html($(this).html()); - $('#current_year').change(); - }); - $('#cancer_table_right_result .cancer-btn-group .cancer_table_btn').removeClass('active'); - $('#cancer_table_right_result .cancer-btn-group >input').attr('value',"0"); - for(var i = 0;i < $('#cancer_table_left_result .cancer-btn-group').length;i++){ - $('#cancer_table_left_result .cancer-btn-group').eq(i).find('.cancer_table_btn').eq(0).addClass('active'); - $('#cancer_table_left_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.4687]; - 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']; - $('tr.'+active_treatment[0]+' .Overall_Survival').html(servive_ratio_arr[0]+'%'); - $('#cancer_predict_result_block').css('display','block'); - var lpv_real = [result.responseJSON['lpv_variable']]; - var lpv_dict={} - var lpv_calc={0.5:0.9736358,1:0.9548993,1.5:0.9229336} - active_treatment.push = function() { - if(arguments.length == 1){ - var year = $('#current_year').attr('value'); - var lpv_current = change_object_variables(lpv_real[lpv_real.length-1],lpv_dict[arguments[0]],'+'); - lpv_real.push(lpv_current); - var servive_ratio = round((1 - (lpv_calc[year]**Math.exp(lpv_current)))*100,2); - 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(round(benefit,2)+'%'); - $('tr.'+arguments[0]).css('display','table-row'); - $('tr.tr_show').eq(-1).after($('tr.'+arguments[0])); - $('tr.'+arguments[0]).addClass('tr_show'); - if(this.length == 1){ - $('.addition').css('display','inline-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 += ((I18n.locale == 'en' ? ', and ': '以及')+add_choices_transform[add_choices_transform.length-1]) - else - add_choices_str = add_choices_transform[0]; - var extra_therapy_texts = result.responseJSON['extra_therapy_texts']; - extra_therapy_texts = extra_therapy_texts.replace('{{extra_therapy}}',''+add_choices_str+''); - extra_therapy_texts = extra_therapy_texts.replace('{{survival_num}}',''+Math.round(servive_ratio)+''); - extra_therapy_texts = extra_therapy_texts.replace('{{surgery_year}}',''+year+''); - extra_therapy_texts = extra_therapy_texts.replace('{{Additional_Benefit}}',''+Math.round(benefit)+''); - var new_text = '

'; - new_text += (extra_therapy_texts+'

'); - $('#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); - } - }; - active_treatment.remove_item_from_array = function(){ - if(arguments.length == 1 && !Array.isArray(arguments[0])){ - var index = this.indexOf(arguments[0]) - var year = $('#current_year').attr('value'); - if(index < this.length - 1){ - for(var i = index + 1;i < this.length; i++){ - change_object_variables(lpv_real[i] , lpv_dict[arguments[0]] , '-' , 'self'); - var servive_ratio = round((Math.exp(lpv_calc[year])**Math.exp(lpv_real[i]))*100,2); - servive_ratio_arr[i] = servive_ratio; - var benefit = servive_ratio - ((i == index+1) ? servive_ratio_arr[index - 1] : servive_ratio_arr[i - 1]); - $('tr.'+active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%'); - $('.'+active_treatment[i]+'.Overall_Survival').html(Math.round(servive_ratio)); - $('tr.'+active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%'); - $('.'+active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit)); - }; - var add_choices = []; - for(var i = 1;i < this.length; i++){ - if(i != index){ - add_choices.push(this[i]); - var add_choices_transform = []; - for(var j = 0;j= 2) - add_choices_str += ((I18n.locale == 'en' ? ', and ': '以及')+add_choices_transform[add_choices_transform.length-1]) - else - add_choices_str = add_choices_transform[0]; - $('.'+active_treatment[i]+'.choices').html(add_choices_str); - } - }; - }; - $('tr.'+arguments[0]+' td.Overall_Survival').html('-'); - $('tr.'+arguments[0]+' td.Additional_Benefit').html('-'); - $('tr.'+arguments[0]).css('display','none'); - $('tr.'+arguments[0]).removeClass('tr_show'); - $('span.'+arguments[0]).eq(0).parent().remove(); - lpv_real = lpv_real.remove_item_from_array(lpv_real[index]); - servive_ratio_arr = servive_ratio_arr.remove_item_from_array(servive_ratio_arr[index]); - if(this.length == 2){ - $('.addition').css('display','none'); - $('#result_text_content .extra-text').css('display','none'); - }; - console.log(this) - return Array.prototype.remove_item_from_array.apply(this, arguments); - }else{ - console.log(this) - return Array.prototype.remove_item_from_array.apply(this, arguments); - }; - }; - for(var i = 0;iinput').attr('value',0); - $(this).parent().find('>input').eq(index).attr('value',1); - $(this).parent().find('>button').removeClass('active'); - $(this).parent().removeClass('cancertable_empty'); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }catch(e){}; - $(this).addClass('active'); - if(!click_flag){ - if(!active_treatment.includes($(this).parent().attr('id'))){ - click_flag = true; - active_treatment.push($(this).parent().attr('id')); - click_flag = false; - }; - } - }); - $('#'+treatmeny_method[i]+' .cancer_table_btn').eq(0).off('click'); - $('#'+treatmeny_method[i]+' .cancer_table_btn').eq(0).click(function(){ - var index = $(this).index()/2; - try{ - $(this).parent().find('>input').attr('value',0); - $(this).parent().find('>input').eq(index).attr('value',1); - $(this).parent().find('>button').removeClass('active'); - $(this).parent().removeClass('cancertable_empty'); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }catch(e){}; - $(this).addClass('active'); - if(!click_flag){ - if(active_treatment.includes($(this).parent().attr('id'))){ - click_flag = true; - active_treatment = active_treatment.remove_item_from_array($(this).parent().attr('id')); - click_flag = false; - }; - }; - }); - }; - $('#current_year').change(function(){ - year = $(this).attr('value'); - $('.surgery_year').html(year); - $('.cancer_years').removeClass('active'); - $('#result_text_content .cancer_years').eq($(this).attr("index")).addClass('active'); - $('#result_table_content .cancer_years').eq($(this).attr("index")).addClass('active'); - var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year} - calculate_and_change_result_value(obj); - servive_ratio_arr = obj.servive_ratio_arr; - active_treatment = obj.active_treatment; - lpv_real = obj.lpv_real; - lpv_calc = obj.lpv_calc; - year = obj.year; - }); - $('#cancer_table .cancer_form_field').off('change').on('change',function(){ - var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year} - after_submit_change_func(obj); - servive_ratio_arr = obj.servive_ratio_arr; - active_treatment = obj.active_treatment; - lpv_real = obj.lpv_real; - lpv_calc = obj.lpv_calc; - year = obj.year; - }); - $('#cancer_table .cancer_form_field').click(function(){ - $(this).change(); - }); - $('select.select_num').off('click').on('click',function(){ - $(this).change(); - var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year} - after_submit_change_func(obj); - servive_ratio_arr = obj.servive_ratio_arr; - active_treatment = obj.active_treatment; - lpv_real = obj.lpv_real; - lpv_calc = obj.lpv_calc; - year = obj.year; - }); - $('.num_only').on('input', function() { - if( Number($(this).val()) < $(this).data('range')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range')[1] && $(this).data('range')[1] != undefined) ){ - $(this).css('color','#f24a69'); - $(this).addClass('cancertable_empty'); - }else{ - $(this).css('color','#333'); - $(this).removeClass('cancertable_empty'); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year}; - after_submit_change_func(obj); - servive_ratio_arr = obj.servive_ratio_arr; - active_treatment = obj.active_treatment; - lpv_real = obj.lpv_real; - lpv_calc = obj.lpv_calc; - year = obj.year; - }; - }); - }); - }; - }; - function after_submit_change_func(obj){ - var post_json = get_input_data(); - if(post_json != null){ - var new_lpv = calculate_first_lpv(post_json)['lpv_variable']; - var old_lpv = obj.lpv_real[0]; - obj.lpv_real = obj.lpv_real.map(original_value=>(change_object_variables(original_value,change_object_variables(new_lpv,old_lpv,'-'),'+'))); - calculate_and_change_result_value(obj); - }; - }; - /* auto add start */ -function calculate_first_lpv(result_json){ - result = {}; - var map_values , mapping_hash , temp_index ,temp_value , index , closest_value; - result['sex_value'] = Number(result_json['sex_value']) - 1; - result['age'] = Number(result_json['age']); - mapping_hash = mapping_data_from_csv['age']; - temp_index = 0; - temp_value = result[age]; - index = 0; - $.each(mapping_hash,function(k,v){ - if( i == 0 ){ - var index_val = v.indexOf(temp_value); - if( index_val != -1 ){ - temp_index = index_val; - }else{ - closest_value = v.get_nearest_value(temp_value); - temp_index = v.indexOf(closest_value) - } - } - result[k] = v[temp_index]; - index++; - }); - result['calH'] = Number(result_json['calH']); - mapping_hash = mapping_data_from_csv['calH']; - temp_index = 0; - temp_value = result[calH]; - index = 0; - $.each(mapping_hash,function(k,v){ - if( i == 0 ){ - var index_val = v.indexOf(temp_value); - if( index_val != -1 ){ - temp_index = index_val; - }else{ - closest_value = v.get_nearest_value(temp_value); - temp_index = v.indexOf(closest_value) - } - } - result[k] = v[temp_index]; - index++; - }); - result['calAH'] = Number(result_json['calAH']); - mapping_hash = mapping_data_from_csv['calAH']; - temp_index = 0; - temp_value = result[calAH]; - index = 0; - $.each(mapping_hash,function(k,v){ - if( i == 0 ){ - var index_val = v.indexOf(temp_value); - if( index_val != -1 ){ - temp_index = index_val; - }else{ - closest_value = v.get_nearest_value(temp_value); - temp_index = v.indexOf(closest_value) - } - } - result[k] = v[temp_index]; - index++; - }); - result['calDH'] = Number(result_json['calDH']); - mapping_hash = mapping_data_from_csv['calDH']; - temp_index = 0; - temp_value = result[calDH]; - index = 0; - $.each(mapping_hash,function(k,v){ - if( i == 0 ){ - var index_val = v.indexOf(temp_value); - if( index_val != -1 ){ - temp_index = index_val; - }else{ - closest_value = v.get_nearest_value(temp_value); - temp_index = v.indexOf(closest_value) - } - } - result[k] = v[temp_index]; - index++; - }); - result['fat'] = Number(result_json['fat']); - mapping_hash = mapping_data_from_csv['fat']; - temp_index = 0; - temp_value = result[fat]; - index = 0; - $.each(mapping_hash,function(k,v){ - if( i == 0 ){ - var index_val = v.indexOf(temp_value); - if( index_val != -1 ){ - temp_index = index_val; - }else{ - closest_value = v.get_nearest_value(temp_value); - temp_index = v.indexOf(closest_value) - } - } - result[k] = v[temp_index]; - index++; - }); - result['N4'] = (2 - Number(result_json['N4'])); - result['O20'] = (2 - Number(result_json['O20'])); - result['O18'] = (2 - Number(result_json['O18'])); - result['N12'] = (2 - Number(result_json['N12'])); - result['N20'] = (2 - Number(result_json['N20'])); - result['N31'] = (2 - Number(result_json['N31'])); - result['O6'] = (2 - Number(result_json['O6'])); - result['N34'] = (2 - Number(result_json['N34'])); - result['N46'] = (2 - Number(result_json['N46'])); - result['N14'] = (2 - Number(result_json['N14'])); - result['N29'] = (2 - Number(result_json['N29'])); - result['N2'] = (2 - Number(result_json['N2'])); - result['N26'] = (2 - Number(result_json['N26'])); - result['O11'] = (2 - Number(result_json['O11'])); - result['N6'] = (2 - Number(result_json['N6'])); - result['O14'] = (2 - Number(result_json['O14'])); - result['N43'] = (2 - Number(result_json['N43'])); - result['O3'] = (2 - Number(result_json['O3'])); - result['O17'] = (2 - Number(result_json['O17'])); - result['O9'] = (2 - Number(result_json['O9'])); - - try{ - result['lpv'] = (A = 0.1327868* (result["sex_value"]- 0.4858824) + 0.0371720* (result["age_test1"] - 61.56000) -0.07447278* (result["age_test2"] - 13.10152) + 0.4315686* (result["age_test3"] - 0.9844332) + 0.0009163615*( result["calH_test1"] - 182.9347) -0.0007536899*( result["calH_test2"] - 124.8706) -0.0004697183*( result["calH_test3"] -80.75636) + 0.0001401325*( result["calAH_test1"] - 700.7824) -0.001349783*( result["calAH_test2"] - 634.2167) +0.001753832*( result["calAH_test3"] -419.3361) + 0.0001906046*( result["calDH_test1"] -835.2894) -0.000251567*( result["calDH_test2"] - 213.1630) -0.002173942*( result["fat_test1"] -108.4149)+0.003066541*( result["fat_test2"] - 28.33497) +0.6700708*(result["N4"]-0.3241176) +0.3336162*(result["O3"]-0.4994118) +0.1322476*(result["O20"]-0.1741176) +0.9084972*(result["O18"]-0.008823529) +0.2978388*(result["N12"]-0.1152941) +0.1777935*(result["N20"]-0.3582353) +1.588042*(result["N31"]-0.002352941) +0.2197419*(result["O6"]-0.07823529) +1.791159*(result["N34"]-0.001176471) -14.02639*(result["N46"]-0.003529412) +0.4305973*(result["N14"]-0.02176471) -0.4472885*(result["N29"]-0.02411765) -1.570431*(result["N20"]-0.0005882353) +0.2601319*(result["N26"]-0.04941176) -0.2364269*(result["O11"]-0.1164706) +0.1784179*(result["N6"]-0.1070588) +0.6023170*(result["O14"]-0.01294118) -1.031959*(result["N43"]-0.007058824) +0.4257809*(result["O17"]-0.01823529) +0.2002546*(result["O9"]-0.06176471)); - }catch(e){result['lpv'] = "error"}; - console.log(result['lpv']); - result['lpv_variable']['A'] = A; - return result; - }; - function calculate_and_change_result_value(obj){ - obj.servive_ratio_arr = []; - for(var i = 0;i=48&&event.keyCode<=57||(this.value.indexOf('.')<0?event.keyCode==46:false); - }); - $('.float_num').off('keyup').on('keyup',function(){ - this.value = this.value.replace(/[^\d.]/g,''); - }); - $('.num_only').blur(function() { - if( Number($(this).val()) < $(this).data('range')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range')[1] && $(this).data('range')[1] != undefined) ){ - $(this).css('color','#f24a69'); - $(this).addClass('cancertable_empty'); - }else{ - $(this).css('color','#333'); - $(this).removeClass('cancertable_empty'); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }; - }); - $('select.select_num').off('click').on('click',function(){ - $(this).change(); - }); - $('select.select_num').change(function(){ - if(this.selectedIndex != 0){ - $(this).siblings('input.num_only').val($(this).find('option').eq(this.selectedIndex).text()); - $(this).siblings('input.num_only').removeClass('cancertable_empty'); - $(this).siblings('input.num_only').css('color','#333'); - }else{ - $(this).siblings('input.num_only').addClass('cancertable_empty'); - $(this).siblings('input.num_only').css('color','rgb(242, 74, 105)'); - $(this).siblings('input.num_only').val($(this).val()); - } - $(this).siblings('input.num_only_value').val($(this).val()); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }); - $('input#lymph_nodes_examined').siblings('select.select_num').off('change').on('change',function(){ - var range = $('input#lymph_nodes_positive').data('range'); - range[1] = Number($(this).val()); - $('input#lymph_nodes_positive').data('range_new', range); - if(this.selectedIndex != 0){ - $(this).siblings('input.num_only').val($(this).find('option').eq(this.selectedIndex).text()); - $(this).siblings('input.num_only').removeClass('cancertable_empty'); - $(this).siblings('input.num_only').css('color','#333'); - }else{ - $(this).siblings('input.num_only').addClass('cancertable_empty'); - $(this).siblings('input.num_only').css('color','rgb(242, 74, 105)'); - $(this).siblings('input.num_only').val($(this).val()); - } - $(this).siblings('input.num_only_value').val($(this).val()); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - $(this).siblings('.num_only_value').val($(this).val()); - if( Number($('input#lymph_nodes_positive').siblings('.num_only_value').val()) <= Number($(this).val()) ){ - $('input#lymph_nodes_positive').css('color','#333'); - $('input#lymph_nodes_positive').removeClass('cancertable_empty'); - }; - if( Number($(this).val()) < $(this).siblings('.num_only').data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).siblings('.num_only').data('range_new')[1] && $(this).siblings('.num_only').data('range_new')[1] != undefined) ){ - $(this).siblings('.num_only').css('color','#f24a69'); - $(this).siblings('.num_only').addClass('cancertable_empty'); - }else{ - $(this).siblings('.num_only').css('color','#333'); - $(this).siblings('.num_only').removeClass('cancertable_empty'); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }; - }); - $('input#lymph_nodes_positive').siblings('select.select_num').off('change').on('change',function(){ - var range = $('input#lymph_nodes_examined').data('range'); - range[0] = Number($(this).val()); - $('input#lymph_nodes_examined').data('range_new', range); - if(this.selectedIndex != 0){ - $(this).siblings('input.num_only').val($(this).find('option').eq(this.selectedIndex).text()); - $(this).siblings('input.num_only').removeClass('cancertable_empty'); - $(this).siblings('input.num_only').css('color','#333'); - }else{ - $(this).siblings('input.num_only').addClass('cancertable_empty'); - $(this).siblings('input.num_only').css('color','rgb(242, 74, 105)'); - $(this).siblings('input.num_only').val($(this).val()); - } - $(this).siblings('input.num_only_value').val($(this).val()); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - $(this).siblings('.num_only_value').val($(this).val()); - if( Number($('input#lymph_nodes_examined').siblings('.num_only_value').val()) >= Number($(this).val()) ){ - $('input#lymph_nodes_examined').css('color','#333'); - $('input#lymph_nodes_examined').removeClass('cancertable_empty'); - }; - if( Number($(this).val()) < $(this).siblings('.num_only').data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).siblings('.num_only').data('range_new')[1] && $(this).siblings('.num_only').data('range_new')[1] != undefined) ){ - $(this).siblings('.num_only').css('color','#f24a69'); - $(this).siblings('.num_only').addClass('cancertable_empty'); - }else{ - $(this).siblings('.num_only').css('color','#333'); - $(this).siblings('.num_only').removeClass('cancertable_empty'); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }; - }); - $('select.select_num').blur(function() { - if( Number($(this).siblings('.num_only_value').val()) < $(this).siblings('.num_only').data('range')[0] || $(this).siblings('.num_only_value').val() == "" || (Number($(this).siblings('.num_only_value').val()) > $(this).siblings('.num_only').data('range')[1] && $(this).siblings('.num_only').data('range')[1] != undefined) ){ - $(this).siblings('.num_only').css('color','#f24a69'); - $(this).siblings('.num_only').addClass('cancertable_empty'); - }else{ - $(this).siblings('.num_only').css('color','#333'); - $(this).siblings('.num_only').removeClass('cancertable_empty'); - if($('.cancertable_empty').length == 0){ - $('#danger_texts').remove(); - }; - }; - }); - if($(window).width() < 768) - $('#cancer_predict_result').attr('style',''); -}); -$(window).resize(function(){ - if($(window).width() > 768){ - if($('.cancer_table_right_result').length != 0) - $('#cancer_predict_result').css('float','right'); - }else{ - $('#cancer_predict_result').attr('style',''); - }; - if(I18n.locale == 'en'){ - var window_width = $(window).width(); - if(window_width < 520){ - $('#cancer_table .cencer_table_name').css('max-width',''); - }else if(window_width < 768){ - $('#cancer_table .cencer_table_name').css({'max-width':'','width':'11em'}); - }else if(window_width < 860){ - $('#cancer_table .cencer_table_name').css('max-width','30%'); - }else if(window_width < 1130){ - $('#cancer_table .cencer_table_name').css('max-width','33%'); - }else{ - $('#cancer_table .cencer_table_name').css('max-width','39%'); - }; - }; -});