diff --git a/app/assets/javascripts/cancer_predict.js b/app/assets/javascripts/cancer_predict.js index 38a3a3e..30553c5 100644 --- a/app/assets/javascripts/cancer_predict.js +++ b/app/assets/javascripts/cancer_predict.js @@ -479,8 +479,8 @@ $(document).ready(function(){ }; function calculate_first_lpv(result_json){ result = {} - result['age1'] = -Math.pow((Number(result_json['age'])/100),-0.5); - result['age2'] = -Math.pow((Number(result_json['age'])/100),-0.5)*Math.log(result_json['age']/100); + result['age1'] = -Math.pow((Number(result_json['age'])/100),0.5); + result['age2'] = -Math.pow((Number(result_json['age'])/100),0.5)*Math.log(result_json['age']/100); result['size1'] = -Math.log(Number(result_json['size'])/10); result['nposit'] = -Math.pow(((Number(result_json['ratio'])+0.1)/0.1),0.5); if( Number(result_json['grade']) == 2) @@ -589,4 +589,14 @@ $(document).ready(function(){ $('#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',''); + }; }); diff --git a/app/assets/stylesheets/cancer_predict.css b/app/assets/stylesheets/cancer_predict.css index 081bf88..ec7b437 100644 --- a/app/assets/stylesheets/cancer_predict.css +++ b/app/assets/stylesheets/cancer_predict.css @@ -18,6 +18,24 @@ } #cancer_table{ font-size:0.825em; + color:#5d7ca2; +} +#cancer_table_top{ + padding-bottom: 4em; +} +#font_texts{ + padding-right: 0.5em; +} +#text_descibe{ + font-weight: bold; + float: left; + max-width: 50%; +} +#font_size_choices{ + font-weight: bold; + float: right; + max-width: 50%; + padding-left:1em; } form.for_num{ position: relative; @@ -30,6 +48,7 @@ select.select_num{ left:1em; clip: rect(0.25em,3.8em,1.5em,2.875em); border:none; + padding: 0.5em; } input.num_only{ color: black; @@ -48,12 +67,10 @@ input.float_num{ position: relative; } #cancer_table_left{ - float:left; - width:50%; + width:100%; } #cancer_table_right{ - float:right; - width:50%; + width:100%; } #cancer_table_submit{ margin-left: 1em; @@ -63,6 +80,7 @@ input.float_num{ border: 0em; padding: 0.125em 0.5em; border-radius: 0.5em; + font-size: 1.25em; } #cancer_table_reset{ float: right; @@ -71,6 +89,7 @@ input.float_num{ border: 0em; padding: 0.125em 0.5em; border-radius: 0.5em; + font-size: 1.25em; } .btn-sub{ background:url("/assets/cancerpredict/triangle_sub.png") no-repeat top transparent; @@ -120,6 +139,7 @@ input.float_num{ border: 0em; padding: 0.125em 0.5em; border-radius: 0.5em; + font-size: 1.25em; } .result_tab{ background: #023d79; @@ -162,18 +182,6 @@ input.float_num{ margin: 0; float: left; } -#cancer_predict_result{ - width: 50%; - float: left; -} -#cancer_table_left_result{ - width: 50%; - float: left; -} -#cancer_table_right_result{ - width: 50%; - float: right; -} .result_content_group{ width: 80%; margin: 0; @@ -276,4 +284,29 @@ div.texts_show{ transform: translate(-50%, -50%) !important; overflow: auto; overflow-y: auto; +} +#cancer_predict_result{ + width: 80%; +} +@media screen and (min-width: 48em) { + #cancer_table_right{ + float:right; + width:50%; + } + #cancer_table_left{ + float:left; + width:50%; + } + #cancer_table_right_result{ + width: 50%; + float: right; + } + #cancer_table_left_result{ + width: 50%; + float: left; + } + #cancer_predict_result{ + width: 50%; + float: left; + } } \ No newline at end of file diff --git a/app/controllers/admin/cancerpredicts_controller.rb b/app/controllers/admin/cancerpredicts_controller.rb index 0d43159..a034718 100644 --- a/app/controllers/admin/cancerpredicts_controller.rb +++ b/app/controllers/admin/cancerpredicts_controller.rb @@ -25,7 +25,7 @@ class Admin::CancerpredictsController < OrbitAdminController @form_to_show.form_show[num.to_s][key.to_s] = value else if value.length > 2 - @form_to_show.form_show[num.to_s][key.to_s] = value[1..-2].split(',').collect!{|n| n.to_i} + @form_to_show.form_show[num.to_s][key.to_s] = YAML.load(value) else @form_to_show.form_show[num.to_s][key.to_s] = [] end @@ -36,8 +36,7 @@ class Admin::CancerpredictsController < OrbitAdminController @form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value else if sub_value.length > 2 - #render :html => sub_value.gsub('"','') and return - @form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value.gsub('"','')[1..-2].split(',').collect!{|n| n} + @form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = YAML.load(sub_value) else @form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = [] end @@ -49,8 +48,73 @@ class Admin::CancerpredictsController < OrbitAdminController end end end + params["cancerpredictfields"]["form_show_in_result"].each do |num,property| + property.each do |key,value| + if value != "0" && value != "1" + if key != params[:locale] + if @form_to_show.form_show_in_result[num.to_s][key.to_s].class != Array + @form_to_show.form_show_in_result[num.to_s][key.to_s] = value + else + if value.length > 2 + @form_to_show.form_show_in_result[num.to_s][key.to_s] = YAML.load(value) + else + @form_to_show.form_show_in_result[num.to_s][key.to_s] = [] + end + end + else + value.each do |sub_property,sub_value| + if @form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s].class != Array + @form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value + else + if sub_value.length > 2 + @form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = YAML.load(sub_value) + else + @form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = [] + end + end + end + end + else + @form_to_show.form_show_in_result[num.to_s][key.to_s] = value.to_i + end + end + end + @form_to_show.form_result_is_right = params["cancerpredictfields"]["form_result_is_right"] + @form_to_show.text_descibe[I18n.locale.to_s] = params["cancerpredictfields"]["text_descibe"] + @size = ['small','medium','large'] + @size.each{|size| @form_to_show[size] = params["cancerpredictfields"][size]} + @file_path = Rails.root.to_s + '/app/assets/images/predict_tool' + if !Dir.exist? @file_path + #FileUtils.mkdir_p @file_path + end + # if @file.nil? != true + # @file_name = @file.original_filename + # @file_content = @file.read + # FileUtils.cp(@file , @file_path) + # @file_content.force_encoding('UTF-8') + # Dir.chdir(@file_path) + # @filetowrite + # if !File.file?(@file_name) + # @filetowrite = File.new(@file_name,"w") + # else + # @filetowrite = File.open(@file_name,"w") + # end + # @filetowrite.write(@file_content) + # @filetowrite.close + # Dir.chdir(Rails.root.to_s) + # else + # @file_name = @font_settings.font_file_name + # end + @field_name = {"font_file_name" => @file_name,"font_dir" => @file_path} + @field_name.each do |name,value| + @font_settings["old_" + name.to_s] = @font_settings[name.to_s] + @font_settings[name.to_s] = value.to_s + end @form_to_show.save - redirect_to admin_cancerpredicts_path + #params.cancerpredictfields + #render :html => params["cancerpredictfields"]["form_result_is_right"].to_s + render :html => params["cancerpredictfields"].to_s + #redirect_to admin_cancerpredicts_path end def showSubmit @results = Cancerpredictrecord.where("title"=>@app_title).take_while{true} @@ -68,7 +132,7 @@ class Admin::CancerpredictsController < OrbitAdminController @result_variables = [] @result_names = [] @indexs=[] - @results[0].result.each{|key,value| @result_variables.push key} + @results[0].result.each{|key,value| @result_variables.push key} rescue nil @result_variables.each do |variable| @index = @variables.index(variable.to_s) @result_names.push @names[@index] if !@index.nil? diff --git a/app/controllers/cancerpredicts_controller.rb b/app/controllers/cancerpredicts_controller.rb index 68b6ca6..3ee4656 100644 --- a/app/controllers/cancerpredicts_controller.rb +++ b/app/controllers/cancerpredicts_controller.rb @@ -20,8 +20,8 @@ class CancerpredictsController < ApplicationController locale = params['data']['locale'].to_s rescue 'zh_tw' locale = 'zh_tw' if locale == 'zh_cn' result = {} - result['age1'] = -(params['data']['age'].to_f/100)**(-0.5) - result['age2'] = -((params['data']['age'].to_f/100)**(-0.5))*Math.log(params['data']['age'].to_f/100,Math.exp(1)) + result['age1'] = -(params['data']['age'].to_f/100)**(0.5) + result['age2'] = -((params['data']['age'].to_f/100)**(0.5))*Math.log(params['data']['age'].to_f/100,Math.exp(1)) result['size1'] = -Math.log(params['data']['size'].to_f/10,Math.exp(1)) result['nposit'] = -((params['data']['ratio'].to_f+0.1)/0.1)**0.5 if params['data']['grade'].to_i == 2 @@ -105,10 +105,15 @@ class CancerpredictsController < ApplicationController uid = OrbitHelper.params[:uid] rescue "" tags = OrbitHelper.widget_tags categories = OrbitHelper.widget_categories || [] + create_first_field @table_str = '