finish result choices and result_tab

This commit is contained in:
BOHUNG 2019-12-07 12:12:33 +08:00
parent d8d02fb590
commit c1a2927e1e
8 changed files with 251 additions and 89 deletions

View File

@ -86,7 +86,8 @@ $(document).ready(function(){
$('.cancer_form_field').removeClass('cancertable_empty'); $('.cancer_form_field').removeClass('cancertable_empty');
}); });
$('#cancer_table_submit').click(function(){ $('#cancer_table_submit').click(function(){
var flag = 1; var flag;
flag = 1;
for(var i = 0;i < $('.cancer_form_field').length;i++){ for(var i = 0;i < $('.cancer_form_field').length;i++){
if($('.cancer_form_field').eq(i).hasClass('num_only')){ if($('.cancer_form_field').eq(i).hasClass('num_only')){
if($('.cancer_form_field').eq(i).val()==""){ if($('.cancer_form_field').eq(i).val()==""){
@ -115,9 +116,23 @@ $(document).ready(function(){
post_json[name] = index; post_json[name] = index;
}; };
}; };
var result = $.post("/cancerpredictResult",{"data":post_json},function(data){console.log(data)}); var result = $.post("/cancerpredictResult",{"data":post_json});
result.done(function(){
$('#result_table_content').html(result.responseJSON.table);
})
} }
}); });
for(var i = 0;i < $('.result_tab').length;i++){
$('.result_tab').eq(i).attr('index',i)
};
for(var i = 0;i < $('.result_content').length;i++){
$('.result_content').eq(i).attr('index',i)
};
$('.result_tab').click(function(){
var index = $(this).attr('index');
$('.result_content').css('display','none');
$('.result_content[index="'+index+'"]').css('display','block');
})
$('.num_only').focus $('.num_only').focus
for(var i=0;i<$('.num_only').length;i++) for(var i=0;i<$('.num_only').length;i++)
$('.num_only').eq(i).data('range') $('.num_only').eq(i).data('range')

View File

@ -57,8 +57,9 @@ class CancerpredictsController < ApplicationController
end end
result['lpv'] = ((result['age1']-0.7276655)*(-10.87)+(result['age2']-0.4540707)*8.968+(result['size1']-0.643632)*0.7678+(result['nposit']-1.346932)*0.5339+ result['lpv'] = ((result['age1']-0.7276655)*(-10.87)+(result['age2']-0.4540707)*8.968+(result['size1']-0.643632)*0.7678+(result['nposit']-1.346932)*0.5339+
result['grade_2']*0.4795+result['grade_3']*0.818+result['subtype_HER2']*0.1806+result['subtype_triple']*0.6457+result['pstage_2']*0.5311+ result['grade_2']*0.4795+result['grade_3']*0.818+result['subtype_HER2']*0.1806+result['subtype_triple']*0.6457+result['pstage_2']*0.5311+
result['pstage_3']*1.134+result['pstage_4']*2.172+result['lvi_yes']*0.3321-0.04 rescue 0) result['pstage_3']*1.134+result['pstage_4']*2.172+result['lvi_yes']*0.3321-0.04 rescue 'error')
result['table'] = '<a id="cancer_table_texts">此分析微針對已接受手術後病人下表為此病人分別在第1年、3及5年下根據選定的術後治療所估計的存活率</a>' result['table'] = '<a id="cancer_table_texts">此分析微針對已接受手術後病人下表為此病人分別在第1年、3及5年下根據選定的術後治療所估計的存活率</a>'
#result['table'] +=
result = result.merge(params) result = result.merge(params)
render :json=> result render :json=> result
end end
@ -67,7 +68,6 @@ class CancerpredictsController < ApplicationController
tags = OrbitHelper.widget_tags tags = OrbitHelper.widget_tags
categories = OrbitHelper.widget_categories || [] categories = OrbitHelper.widget_categories || []
locale = OrbitHelper.get_site_locale.to_s locale = OrbitHelper.get_site_locale.to_s
if (OrbitHelper.params[:result] == nil rescue true)
@table_str = '<div id="cancer_table"><div id="show_help_modal" class="modal fade"></div>' @table_str = '<div id="cancer_table"><div id="show_help_modal" class="modal fade"></div>'
@table_str_left = '<div id="cancer_table_left">' @table_str_left = '<div id="cancer_table_left">'
@table_str_right = '<div id="cancer_table_right">' @table_str_right = '<div id="cancer_table_right">'
@ -141,17 +141,60 @@ class CancerpredictsController < ApplicationController
@table_str_right += '</div>' @table_str_right += '</div>'
@table_str += (@table_str_left+@table_str_right) @table_str += (@table_str_left+@table_str_right)
@table_str +='<div style="clear:both;"></div>' @table_str +='<div style="clear:both;"></div>'
@table_result_str = '<div id="cancer_predict_result" style="display:block;"><span id="result_title">'+t("cancerpredict.table.result").to_s+'</span><div style="clear:both;"></div>' @table_result_str = '<div id="cancer_predict_result" style="display:block;"><span class="result_title">'+t("cancerpredict.table.result").to_s+'</span><div style="clear:both;"></div>'
@table_result_str += '<div class="result_tab_group">' @tab_name = ['table','curve','text']
@table_result_str += '<div id="result_table" class="result_tab"><a>'+t("cancerpredict.table.table").to_s+'</a></div><div style="clear:both;"></div>' @table_result_str += '<div id="result_contents"><div class="result_tab_group">'
@table_result_str += '<div id="result_curve" class="result_tab"><a>'+t("cancerpredict.table.curve").to_s+'</a></div><div style="clear:both;"></div>' @tab_name.each{|name| @table_result_str += '<div id="result_'+name+'_tab" class="result_tab"><a>'+t("cancerpredict.table."+name).to_s+'</a></div><div style="clear:both;"></div>'}
@table_result_str += '<div id="result_text" class="result_tab"><a>'+t("cancerpredict.table.text").to_s+'<a></div><div style="clear:both;"></div></div></div>' @table_result_str += '</div><div class="result_content_group">'
@tab_name.each{|name| @table_result_str += '<div id="result_'+name+'_content" class="result_content"><a>'+'no content'+'</a></div>'}
@table_result_str += '</div></div></div>'
@table_button = '<div id="cancer_table_button_group">'
@submit_btn_str='<button id="cancer_table_submit">'+t('cancerpredict.table.Submit').to_s+'</button>' @submit_btn_str='<button id="cancer_table_submit">'+t('cancerpredict.table.Submit').to_s+'</button>'
@reset_btn_str='<button id="cancer_table_reset">'+t('cancerpredict.table.Reset').to_s+'</button>' @reset_btn_str='<button id="cancer_table_reset">'+t('cancerpredict.table.Reset').to_s+'</button>'
@table_str += (@submit_btn_str+@reset_btn_str+@table_result_str+'</div>') @table_button += (@submit_btn_str+@reset_btn_str+'<div style="clear:both;"></div></div>')
@table_result_choice_fileds = '<div id="cancer_table_right_result">' if @form_to_show.form_result_is_right == 1
@table_result_choice_fileds = '<div id="cancer_table_left_result">' if @form_to_show.form_result_is_right == 0
@table_result_choice_fileds += '<span class="result_title">'+t('cancerpredict.table.Therapy_choice').to_s+'</span><div style="clear:both;"></div>'
@table_result_choice_fileds += '<div id="choice_fields">'
@form_to_show.form_show_in_result.each do |num,property|
@field_property = {}
property.each do |key,value|
@value= value
if @value.class == BSON::Document || @value.class == Hash
@disp_value = @value[I18n.locale.to_s] rescue ""
else else
@table_str = OrbitHelper.params.to_s @disp_value = @value
end end
@field_property[key] = @disp_value
end
@table_result_choice_fileds += '<div data-key='+num.to_s+'>'
break if @field_property["name"] == ""
@table_result_choice_fileds += '<label for="'+@field_property["variable"]+'" style="float:left;'+(@field_property["comment_text"] == "" ? "margin-right: 2.125em;" : "")+'" class="cencer_table_name">'
@table_result_choice_fileds += @field_property["name"]
@table_result_choice_fileds += '</label>'
if @field_property["comment_text"] != ""
@table_result_choice_fileds += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"></button>'
@table_result_choice_fileds += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'></input>'
else
@table_result_choice_fileds += '<div style="margin-right: 2.125em;"></div>'
end
if @field_property["is_num"] == 1
@table_result_choice_fileds += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"></input><button class="btn-sub"></button><button class="btn-add"></button>'
else
@table_result_choice_fileds += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
@field_property["choice_fields"].each do |create_choice|
@table_result_choice_fileds += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice+'</button>'
@table_result_choice_fileds += '<input type="hidden" value="0" name="'+create_choice+'"></input>'
end
@table_result_choice_fileds += '</div>'
end
if @field_property["hint"].to_s != ""
@table_result_choice_fileds +='<div style="color: rgb(104, 104, 104);font-size:0.75em;clear:both;">'+@field_property["hint"]+'</div>'
end
@table_result_choice_fileds += '</div><div style="clear:both;"></div>'
end
@table_result_choice_fileds += '</div></div>'
@table_str += (@table_button+@table_result_str+@table_result_choice_fileds+'<div style="clear:both;"></div></div>')
{ {
"cancerpredict" => [], "cancerpredict" => [],
"extras"=>{"table"=> @table_str} "extras"=>{"table"=> @table_str}

View File

@ -15,6 +15,15 @@ class Cancerpredictfields
5=>{:variable=>"pstage",:name=>{"zh_tw"=>"病理分期","en"=>"pathologic stage"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無分期資訊,請選擇“未知”選項,將以病理分期第 1 期進行預測。','en'=>''}, :choice_fields=> {"zh_tw"=>['1','2','3','4','未知'],"en"=>['1','2','3','4','unknown']},:range=>[],:right=>1}, 5=>{:variable=>"pstage",:name=>{"zh_tw"=>"病理分期","en"=>"pathologic stage"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無分期資訊,請選擇“未知”選項,將以病理分期第 1 期進行預測。','en'=>''}, :choice_fields=> {"zh_tw"=>['1','2','3','4','未知'],"en"=>['1','2','3','4','unknown']},:range=>[],:right=>1},
6=>{:variable=>"lvi",:name=>{"zh_tw"=>"淋巴管或血管侵犯","en"=>"lymph vessel or vascular invasion, LVI"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無淋巴管或血管侵犯資訊,請選擇“未知”選項,將以佔多數比例的淋巴管或血管未侵犯進行預測','en'=>''}, :choice_fields=> {"zh_tw"=>['是','否','未知'],"en"=>['yes','no','unknown']},:range=>[],:right=>1} 6=>{:variable=>"lvi",:name=>{"zh_tw"=>"淋巴管或血管侵犯","en"=>"lymph vessel or vascular invasion, LVI"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無淋巴管或血管侵犯資訊,請選擇“未知”選項,將以佔多數比例的淋巴管或血管未侵犯進行預測','en'=>''}, :choice_fields=> {"zh_tw"=>['是','否','未知'],"en"=>['yes','no','unknown']},:range=>[],:right=>1}
} }
field :form_show_in_result , :type=> Hash ,default:{0=>{:variable=>"hormone_therapy",:name=>{"zh_tw"=>"賀爾蒙治療","en"=>"Hormone/steroid therapy"},:is_num=>0, :hint=>{'zh_tw'=>'賀爾蒙治療適用於ER狀態為陽性之病人','en'=>'Hormone (endocrine) therapy is available when ER-status is positive'} , :comment_text=>{'zh_tw'=>'年齡為該婦女於確診罹患乳癌時之年齡','en'=>'<p>Hormone therapy, or endocrine therapy, involves a woman taking drugs to prevent the growth of tumour cells that are boosted by the hormone oestrogen. Drugs of this kind include tamoxifen (brand names include Nolvadex, Istabul, Valodex, and Soltamox) and aromatase inhibitors such as anastrozole, exemestane, and letrozole (brand names Arimidex, Aromasin, and Femara).</p>'+
'<p>Some hormone therapy drugs act by blocking the action of oestrogen on the cells and some work by lowering the amount of oestrogen in the body (NB hormone therapy for breast cancer is the opposite of hormone replacement therapy or HRT, which is taken by women to help INCREASE oestrogen levels to help deal with side-effects of the menopause).</p>'+
'<p>Treatments usually have the potential to cause harm as well as benefit. It is important to weigh up the risks of potential harm against the potential benefits of treatment in order to reach a decision. Some may cause more harm than benefit to some people.</p>'+
'<p>It is useful to switch between 1 and 5 years hormone therapy to compare the survival outcomes.</p>'}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]},
1=>{:variable=>"Chemotherapy",:name=>{"zh_tw"=>"化學治療","en"=>"Chemotherapy"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'化學治療','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]},
2=>{:variable=>"Radiotherapy",:name=>{"zh_tw"=>"放射治療","en"=>"Radiotherapy"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'放射治療','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]},
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 # before_destroy :destroy_email
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 :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)} scope :is_approved, ->{where(:approved => true)}

26
built_in_extensions.rb Normal file
View File

@ -0,0 +1,26 @@
gem 'announcement', git: 'http://gitlab.tp.rulingcom.com/saurabh/announcement-test.git'
gem 'ad_banner', git: 'http://gitlab.tp.rulingcom.com/saurabh/adbanner-test.git'
gem "archive", git: 'http://gitlab.tp.rulingcom.com/saurabh/archive.git'
gem 'gallery', git: 'http://gitlab.tp.rulingcom.com/saurabh/gallery.git'
gem 'web_resource', git: 'http://gitlab.tp.rulingcom.com/saurabh/links.git'
gem 'page_content', git: 'http://gitlab.tp.rulingcom.com/saurabh/pagecontent.git'
gem 'faq', git: 'http://gitlab.tp.rulingcom.com/saurabh/faq.git'
#Personal Plugins
gem 'personal_journal', git: 'http://gitlab.tp.rulingcom.com/saurabh/personal-journal.git'
gem 'personal_conference', git: 'http://gitlab.tp.rulingcom.com/saurabh/personal-conference.git'
gem 'personal_book', git: 'http://gitlab.tp.rulingcom.com/saurabh/personal-book.git'
gem 'personal_project', git: 'http://gitlab.tp.rulingcom.com/saurabh/personal-project.git'
gem 'personal_patent', git: 'http://gitlab.tp.rulingcom.com/saurabh/personal-patent.git'
gem 'personal_research', git: 'http://gitlab.tp.rulingcom.com/saurabh/personal-research.git'
gem 'personal_lab', git: 'http://gitlab.tp.rulingcom.com/saurabh/personal-lab.git'
gem 'personal_diploma', git: 'http://gitlab.tp.rulingcom.com/saurabh/personal-diploma.git'
gem 'personal_experience', git: 'http://gitlab.tp.rulingcom.com/saurabh/personal-experience.git'
gem 'personal_honor', git: 'http://gitlab.tp.rulingcom.com/saurabh/personal-honor.git'
#widgets
gem "site_menu_widget", git: 'http://gitlab.tp.rulingcom.com/saurabh/site-menu-widget.git'
gem "breadcrumb_widget", git: "http://gitlab.tp.rulingcom.com/saurabh/breadcrumb-widget.git"
gem "announcement_link_widget", git: "http://gitlab.tp.rulingcom.com/harry/announcement-link-widget.git"
gem 'patchfile', git: 'http://gitlab.tp.rulingcom.com/chiu/patch_file.git'
gem 'cancerpredict', git: 'http://gitlab.tp.rulingcom.com/chiu/cancer_predict.git'

View File

@ -29,4 +29,5 @@ en:
table: Table table: Table
curve: Curves curve: Curves
text: Texts text: Texts
Therapy_choice: Therapy_choices

View File

@ -30,3 +30,4 @@ zh_tw:
table: 列表 table: 列表
curve: 曲線 curve: 曲線
text: 文字 text: 文字
Therapy_choice: 治療選項

27
modules/_head.html.erb Normal file
View File

@ -0,0 +1,27 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%= favicon_link_tag (current_site.favicon.blank? ? 'favicon.ico' : current_site.favicon.url) %>
<title><%= render_site_title %></title>
<%= stylesheet_link_tag "//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css"%>
<%= stylesheet_link_tag "bootstrap/bootstrap.min.css"%>
<%= stylesheet_link_tag "template/template"%>
<link rel="stylesheet" media="print" type="text/css" href="/assets/template/print.css">
<%= javascript_include_tag "plugin/modernizr.js"%>
<%= javascript_include_tag "plugin/picturefill.min.js"%>
<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js"%>
<%= javascript_include_tag "plugin/jquery.mobile.custom.min.js"%>
<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"%>
<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/jquery.cycle2/20140415/jquery.cycle2.min.js"%>
<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/jquery.cycle2/20140415/jquery.cycle2.carousel.min.js"%>
<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/jquery.cycle2/20140415/jquery.cycle2.scrollVert.min.js"%>
<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/jquery.cycle2/20140415/jquery.cycle2.tile.min.js"%>
<%= javascript_include_tag "plugin/jquery.cycle2.video.min.js"%>
<%= javascript_include_tag "plugin/jquery-bullseye-min.js"%>
<%= javascript_include_tag "app"%>
<%= javascript_include_tag "#{@dataApi}" if @dataApi != nil%>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<%= render_google_analytics %>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->

View File

@ -92,7 +92,7 @@
border-radius: 5px !important; border-radius: 5px !important;
padding: 2px !important; padding: 2px !important;
} }
#result_title{ .result_title{
background-color: rgb(210, 105, 0); background-color: rgb(210, 105, 0);
color: white; color: white;
border: 0em; border: 0em;
@ -103,11 +103,21 @@
background: #023d79; background: #023d79;
background: linear-gradient(135deg, transparent 0.3em, #023d79 0); background: linear-gradient(135deg, transparent 0.3em, #023d79 0);
border: none; border: none;
float:left; float:right;
padding: 0.5em 0.125em 0.5em 0.5em; padding: 0.5em 0.125em 0.5em 0.5em;
margin-top: 0.5em; margin-top: 0.5em;
cursor: pointer; cursor: pointer;
} }
#cancer_table a:hover{
text-decoration: none;
color: #5d7ca2;
}
#result_contents{
padding-top: 2em;
}
#choice_fields{
padding: 2em 0 0 1em;
}
.result_tab:hover{ .result_tab:hover{
background: #d16801; background: #d16801;
background: linear-gradient(135deg, transparent 0.3em, #d16801 0); background: linear-gradient(135deg, transparent 0.3em, #d16801 0);
@ -120,7 +130,37 @@
color: white; color: white;
} }
.result_tab_group{ .result_tab_group{
width:20%; width: 20%;
margin:0; 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;
float: right;
}
.result_content{
display: none;
min-height: 25em;
border: 0.125em solid #c0cbdd;
padding: 0.5em;
}
.result_content:first-child{
display: block;
}
.result_content a{
color: #5d7ca2;
} }
</style> </style>