-0.5=>0.5,add image uploader
This commit is contained in:
parent
788f495c29
commit
24d14e2b3b
|
@ -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','');
|
||||
};
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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?
|
||||
|
|
|
@ -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 = '<div id="cancer_table"><div id="show_help_modal" class="modal fade"></div>'
|
||||
@table_str += '<div id="cancer_table_top"><div id="text_descibe">'+@form_to_show.text_descibe[I18n.locale.to_s] +'</div>'
|
||||
@size = {'small'=>@form_to_show.small,'medium'=>@form_to_show.medium,'large'=>@form_to_show.large}
|
||||
@table_str += '<div id="font_size_choices">'+'<label id="font_texts">'+t('cancerpredict.font_size')+':</label>'
|
||||
@size.each{|size_key,size_value| @table_str += ('<button class="cancer_table_btn btn btn-default btn-sm" onclick="document.getElementById(\'cancer_table\').style[\'font-size\']=\''+size_value+'\'">'+t('cancerpredict.'+size_key)+'</button>' )}
|
||||
@table_str += '</div></div><div style="clear:both;"></div>'
|
||||
@table_str_left = '<div id="cancer_table_left">'
|
||||
@table_str_right = '<div id="cancer_table_right">'
|
||||
create_first_field
|
||||
@form_to_show.form_show.each do |num,property|
|
||||
@field_property = {}
|
||||
property.each do |key,value|
|
||||
|
@ -200,7 +205,7 @@ class CancerpredictsController < ApplicationController
|
|||
@table_str_right += '</div>'
|
||||
@table_str += (@table_str_left+@table_str_right)
|
||||
@table_str +='<div style="clear:both;"></div>'
|
||||
@table_result_str = '<div id="cancer_predict_result_block"><div id="cancer_predict_result"><span class="result_title">'+t("cancerpredict.table.result").to_s+'</span><div style="clear:both;"></div>'
|
||||
@table_result_str = '<div id="cancer_predict_result" style="'+((@form_to_show.form_result_is_right == 0) ? 'float:right;' : '')+'"><span class="result_title">'+t("cancerpredict.table.result").to_s+'</span><div style="clear:both;"></div>'
|
||||
@tab_name = ['table','text']
|
||||
@table_result_str += '<div id="result_contents"><div class="result_tab_group">'
|
||||
@tab_name.each_with_index{|name,index| @table_result_str += ('<div id="result_'+name+'_tab" class="result_tab'+((index != 0) ? "" : " active")+'"><a>'+t("cancerpredict.table."+name).to_s+'</a></div><div style="clear:both;"></div>')}
|
||||
|
@ -263,8 +268,8 @@ class CancerpredictsController < ApplicationController
|
|||
end
|
||||
@table_result_choice_fileds += '</div><div style="clear:both;"></div>'
|
||||
end
|
||||
@table_result_choice_fileds += '</div></div></div>'
|
||||
@table_str += (@table_button+@table_result_str+@table_result_choice_fileds+'<div style="clear:both;"></div>')
|
||||
@table_result_choice_fileds += '</div></div>'
|
||||
@table_str += (@table_button+'<div id="cancer_predict_result_block">'+@table_result_str+@table_result_choice_fileds+'</div>'+'<div style="clear:both;"></div>')
|
||||
{
|
||||
"cancerpredict" => [],
|
||||
"extras"=>{"table"=> @table_str}
|
||||
|
|
|
@ -6,6 +6,7 @@ class Cancerpredictfields
|
|||
# encoding: utf-8
|
||||
include OrbitTag::Taggable
|
||||
include OrbitCategory::Categorizable
|
||||
mount_uploader :temp_file, AssetUploader
|
||||
field :title ,type:String ,default:""
|
||||
field :form_show , :type=> Hash ,default:{0=>{:variable=>"age",:name=>{"zh_tw"=>"年齡<br/>(age)","en"=>"age"},:is_num=>1, :hint=>{'zh_tw'=>'從 18 歲(含)開始至 93 歲','en'=>''} , :comment_text=>{'zh_tw'=>'年齡為該婦女於確診罹患乳癌時之年齡','en'=>''}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[18,93],:right=>0,:is_float=>0},
|
||||
1=>{:variable=>"size",:name=>{"zh_tw"=>"腫瘤大小<br/>(tumor size)","en"=>"tumor size"},:is_num=>1,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若有多個原發腫瘤,請輸入最大尺寸之原發腫瘤','en'=>''}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[1,300],:right=>0,:is_float=>0},
|
||||
|
@ -24,7 +25,11 @@ class Cancerpredictfields
|
|||
3=>{:variable=>"Targeted_therapy",:name=>{"zh_tw"=>"標靶治療","en"=>"Targeted therapy"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]}
|
||||
}
|
||||
field :form_result_is_right , :type=> Integer ,default: 1
|
||||
# before_destroy :destroy_email
|
||||
field :text_descibe ,type:Hash ,default:{"zh_tw"=>"歡迎使用台灣準備乳癌癒後系統!<br/>若要開始 請在下方輸入相關資訊","en"=>" Welcome to The after breast cancer healing system of Taiwanprepare!\nTo start, please enter the relevant information below."}
|
||||
field :small ,type:String ,default:"0.825em"
|
||||
field :medium ,type:String ,default:"1em"
|
||||
field :large ,type:String ,default:"1.25em"
|
||||
field :head_images ,type:Array , default: []
|
||||
scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc],[:postdate, :desc])}
|
||||
scope :is_approved, ->{where(:approved => true)}
|
||||
#before_create :set_expire
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
<div style="clear:both;"></div>
|
||||
<% @i = 0 %>
|
||||
<%=form_for @form_to_show ,:url=>{:controller=>"cancerpredicts" ,:action=>"edit"} do |form|%>
|
||||
<%= form.file_field :temp_file, accept: 'image/png,image/gif,image/jpeg'%>
|
||||
<span class="show_span"><%= t('cancerpredict.text_descibe') %></span>
|
||||
<div style="clear:both;"></div>
|
||||
<%= form.text_field 'text_descibe',{:value=> @form_to_show.text_descibe[I18n.locale.to_s],:style=>'width:100%;'} %>
|
||||
<span class="show_span"><%= t('cancerpredict.font_size') %></span>
|
||||
<div style="clear:both;"></div>
|
||||
<% @size=['small','medium','large'] %>
|
||||
<% @size.each do |size|%>
|
||||
<div><label class="label_left" for=<%='font_'+size%>><%=t('cancerpredict.'+size)+':'%></label><%= form.text_field size,{:value=> @form_to_show[size],:id=>'font_'+size} %></div>
|
||||
<%end%>
|
||||
<span class="show_span"><%= t('cancerpredict.Input_fields') %></span>
|
||||
<div style="clear:both;"></div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -43,7 +54,7 @@
|
|||
</table>
|
||||
<span class="show_span"><%=t('cancerpredict.table.Results')%></span>
|
||||
<div style="clear:both;"></div>
|
||||
<label for="form_result_is_right" style="float: left;">結果在右邊</label>
|
||||
<label for="form_result_is_right" style="float: left;"><%= t('cancerpredict.result_is_right') %></label>
|
||||
<% if @form_to_show.form_result_is_right.to_i == 1%>
|
||||
<div><%= form.check_box "form_result_is_right",{:checked=>true,:class=>"checkbox",:style=>"float: left;position: relative;left: 0;transform: none!important;margin-left: 1em;",:id=>"form_result_is_right"}%></div>
|
||||
<% else%>
|
||||
|
@ -123,7 +134,7 @@
|
|||
#updatebtn{
|
||||
margin-top: 1em;
|
||||
right: 1em;
|
||||
background-color: rgb(210, 105, 0);
|
||||
background-color: #0088cc;
|
||||
color: white;
|
||||
border: 0em;
|
||||
padding: 0.125em 0.5em;
|
||||
|
@ -139,4 +150,8 @@
|
|||
border-radius: 0.5em;
|
||||
width: fit-content;
|
||||
}
|
||||
.label_left{
|
||||
float: left;
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
</style>
|
|
@ -2,6 +2,13 @@ en:
|
|||
cancerpredict:
|
||||
cancerpredict: adjust the predict breast cancer tool
|
||||
submitResult: see submit results of the users
|
||||
result_is_right: Is therapy choices in the right hand side of result block?
|
||||
text_descibe: text descibe
|
||||
font_size: font size
|
||||
small: small
|
||||
medium: medium
|
||||
large: large
|
||||
Input_fields: User input fields' contents
|
||||
table:
|
||||
welcome: Welcome to The after breast cancer healing system of Taiwanprepare!\nTo start, please enter the relevant information below.
|
||||
Reset: Reset
|
||||
|
|
|
@ -2,6 +2,13 @@ zh_tw:
|
|||
cancerpredict:
|
||||
cancerpredict: 乳癌預測工具調整
|
||||
submitResult: 查看用戶繳交表單結果
|
||||
result_is_right: 治療選項在結果的右邊?
|
||||
text_descibe: 文字說明
|
||||
font_size: 字體
|
||||
small: 小
|
||||
medium: 中
|
||||
large: 大
|
||||
Input_fields: 使用者輸入欄位內容
|
||||
table:
|
||||
welcome: 歡迎使用台灣準備乳癌癒後系統!\n若要開始 請在下方輸入相關資訊
|
||||
Reset: 重置
|
||||
|
|
Loading…
Reference in New Issue