finish the first version of predict tool.and finish the backend control panel of this tool.
This commit is contained in:
parent
24d14e2b3b
commit
190752a275
|
@ -1,4 +1,9 @@
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
var head_images = $.post("/cancerpredictResult",{"header":1})
|
||||||
|
head_images.done(function(){
|
||||||
|
$('.header-nav').html(head_images.responseJSON['head_images']);
|
||||||
|
$('.navbar-brand').html(head_images.responseJSON['title'])
|
||||||
|
});
|
||||||
Array.prototype.remove_item_from_array = function(){
|
Array.prototype.remove_item_from_array = function(){
|
||||||
var result_array = this;
|
var result_array = this;
|
||||||
for(var i=0;i<arguments.length;i++){
|
for(var i=0;i<arguments.length;i++){
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
#cancer_table *[data-key]{
|
#cancer_table *[data-key]{
|
||||||
padding: 0.375em 0;
|
padding: 0.375em 0;
|
||||||
}
|
}
|
||||||
|
.head_logo{
|
||||||
|
float:left;
|
||||||
|
height: 6em;
|
||||||
|
}
|
||||||
|
.header-nav{
|
||||||
|
top:0 !important;
|
||||||
|
}
|
||||||
|
.title_texts{
|
||||||
|
color:rgb(210, 106, 2);
|
||||||
|
}
|
||||||
.cencer_table_name{
|
.cencer_table_name{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
|
|
@ -15,106 +15,164 @@ class Admin::CancerpredictsController < OrbitAdminController
|
||||||
@categories = @module_app.categories.enabled
|
@categories = @module_app.categories.enabled
|
||||||
@filter_fields = filter_fields(@categories, @tags)
|
@filter_fields = filter_fields(@categories, @tags)
|
||||||
@table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified]
|
@table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified]
|
||||||
|
@head_images_id = @form_to_show.head_images_id
|
||||||
|
@title_images_id = @form_to_show.title_images_id
|
||||||
|
@head_images = []
|
||||||
|
@title_images = []
|
||||||
|
@head_images_id.each{|image_id| @head_images.push Headimages.find_by(:id=>image_id.to_s)} rescue nil
|
||||||
|
@title_images_id.each{|image_id| @title_images.push Headimages.find_by(:id=>image_id.to_s)} rescue nil
|
||||||
|
@head_new_image = Headimages.new(:cancerpredictfields_id => @form_to_show.id)
|
||||||
end
|
end
|
||||||
def edit
|
def edit
|
||||||
params["cancerpredictfields"]["form_show"].each do |num,property|
|
if !(params["cancerpredictfields"].nil?)
|
||||||
property.each do |key,value|
|
params["cancerpredictfields"]["form_show"].each do |num,property|
|
||||||
if value != "0" && value != "1"
|
property.each do |key,value|
|
||||||
if key != params[:locale]
|
if value != "0" && value != "1"
|
||||||
if @form_to_show.form_show[num.to_s][key.to_s].class != Array
|
if key != params[:locale]
|
||||||
@form_to_show.form_show[num.to_s][key.to_s] = value
|
if @form_to_show.form_show[num.to_s][key.to_s].class != Array
|
||||||
else
|
@form_to_show.form_show[num.to_s][key.to_s] = value
|
||||||
if value.length > 2
|
|
||||||
@form_to_show.form_show[num.to_s][key.to_s] = YAML.load(value)
|
|
||||||
else
|
else
|
||||||
@form_to_show.form_show[num.to_s][key.to_s] = []
|
if value.length > 2
|
||||||
end
|
@form_to_show.form_show[num.to_s][key.to_s] = YAML.load(value)
|
||||||
end
|
|
||||||
else
|
|
||||||
value.each do |sub_property,sub_value|
|
|
||||||
if @form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s].class != Array
|
|
||||||
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value
|
|
||||||
else
|
|
||||||
if sub_value.length > 2
|
|
||||||
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = YAML.load(sub_value)
|
|
||||||
else
|
else
|
||||||
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = []
|
@form_to_show.form_show[num.to_s][key.to_s] = []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
value.each do |sub_property,sub_value|
|
||||||
|
if @form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s].class != Array
|
||||||
|
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value
|
||||||
|
else
|
||||||
|
if sub_value.length > 2
|
||||||
|
@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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
@form_to_show.form_show[num.to_s][key.to_s] = value.to_i
|
||||||
end
|
end
|
||||||
else
|
|
||||||
@form_to_show.form_show[num.to_s][key.to_s] = value.to_i
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
params["cancerpredictfields"]["form_show_in_result"].each do |num,property|
|
||||||
params["cancerpredictfields"]["form_show_in_result"].each do |num,property|
|
property.each do |key,value|
|
||||||
property.each do |key,value|
|
if value != "0" && value != "1"
|
||||||
if value != "0" && value != "1"
|
if key != params[:locale]
|
||||||
if key != params[:locale]
|
if @form_to_show.form_show_in_result[num.to_s][key.to_s].class != Array
|
||||||
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
|
||||||
@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
|
else
|
||||||
@form_to_show.form_show_in_result[num.to_s][key.to_s] = []
|
if value.length > 2
|
||||||
end
|
@form_to_show.form_show_in_result[num.to_s][key.to_s] = YAML.load(value)
|
||||||
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
|
else
|
||||||
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = []
|
@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
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
@form_to_show.form_show_in_result[num.to_s][key.to_s] = value.to_i
|
||||||
end
|
end
|
||||||
else
|
|
||||||
@form_to_show.form_show_in_result[num.to_s][key.to_s] = value.to_i
|
|
||||||
end
|
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
|
||||||
|
@images = params["cancerpredictfields"]['head_images']
|
||||||
|
@head_images_id = @form_to_show.head_images_id
|
||||||
|
@delete_index = []
|
||||||
|
if !@images.nil?
|
||||||
|
@images.each do |num,image|
|
||||||
|
if num.to_i < @head_images_id.length && @head_images_id.length != 0
|
||||||
|
if image['remove_image'] == "1"
|
||||||
|
@delete_index.push num.to_i
|
||||||
|
else
|
||||||
|
@image_id = @head_images_id[num.to_i]
|
||||||
|
@image = Headimages.find_by(:id=>@image_id.to_s)
|
||||||
|
if !image['sort_number'].nil?
|
||||||
|
@image.sort_number = image['sort_number'].to_i
|
||||||
|
@image.save
|
||||||
|
end
|
||||||
|
next if image['temp_file'] == nil
|
||||||
|
@file_name = image['temp_file'].original_filename.gsub('(','_').gsub(')','_').gsub(' ','_') rescue next
|
||||||
|
@image.sort_number = image['sort_number'].to_i
|
||||||
|
@image.temp_file = image['temp_file']
|
||||||
|
@image.save
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@file_name = image['temp_file'].original_filename.gsub('(','_').gsub(')','_').gsub(' ','_') rescue next
|
||||||
|
@headimages = Headimages.new(:cancerpredictfields_id => @form_to_show.id,:title => @app_title)
|
||||||
|
@headimages.temp_file = image['temp_file']
|
||||||
|
@headimages.sort_number = image['sort_number'].to_i if !image['sort_number'].nil?
|
||||||
|
@headimages.save
|
||||||
|
@form_to_show.head_images_id.push @headimages.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@delete_index.reverse!
|
||||||
|
@delete_index.each do |i|
|
||||||
|
@image_id = @head_images_id[i.to_i]
|
||||||
|
Headimages.find_by(:id => @image_id ).destroy rescue next
|
||||||
|
@form_to_show.head_images_id.delete(@image_id)
|
||||||
|
end
|
||||||
|
@images = params["cancerpredictfields"]['title_images']
|
||||||
|
@title_images_id = @form_to_show.title_images_id
|
||||||
|
@delete_index = []
|
||||||
|
if !@images.nil?
|
||||||
|
@images.each do |num,image|
|
||||||
|
if num.to_i < @title_images_id.length && @title_images_id.length != 0
|
||||||
|
if image['remove_image'] == "1"
|
||||||
|
@delete_index.push num.to_i
|
||||||
|
else
|
||||||
|
@image_id = @title_images_id[num.to_i]
|
||||||
|
@image = Headimages.find_by(:id=>@image_id.to_s)
|
||||||
|
if !image['sort_number'].nil?
|
||||||
|
@image.sort_number = image['sort_number'].to_i
|
||||||
|
@image.save
|
||||||
|
end
|
||||||
|
next if image['temp_file'] == nil
|
||||||
|
@file_name = image['temp_file'].original_filename.gsub('(','_').gsub(')','_').gsub(' ','_') rescue next
|
||||||
|
@image.sort_number = image['sort_number'].to_i
|
||||||
|
@image.temp_file = image['temp_file']
|
||||||
|
@image.save
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@file_name = image['temp_file'].original_filename.gsub('(','_').gsub(')','_').gsub(' ','_') rescue next
|
||||||
|
@headimages = Headimages.new(:cancerpredictfields_id => @form_to_show.id,:title => @app_title)
|
||||||
|
@headimages.temp_file = image['temp_file']
|
||||||
|
@headimages.sort_number = image['sort_number'].to_i if !image['sort_number'].nil?
|
||||||
|
@headimages.save
|
||||||
|
@form_to_show.title_images_id.push @headimages.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@delete_index.reverse!
|
||||||
|
@delete_index.each do |i|
|
||||||
|
@image_id = @title_images_id[i.to_i]
|
||||||
|
Headimages.find_by(:id => @image_id ).destroy rescue next
|
||||||
|
@form_to_show.title_images_id.delete(@image_id)
|
||||||
|
end
|
||||||
|
@form_to_show.title_texts = params['cancerpredictfields']['title_texts']
|
||||||
|
@form_to_show.save
|
||||||
end
|
end
|
||||||
@form_to_show.form_result_is_right = params["cancerpredictfields"]["form_result_is_right"]
|
redirect_to admin_cancerpredicts_path
|
||||||
@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
|
|
||||||
#params.cancerpredictfields
|
|
||||||
#render :html => params["cancerpredictfields"]["form_result_is_right"].to_s
|
|
||||||
render :html => params["cancerpredictfields"].to_s
|
|
||||||
#redirect_to admin_cancerpredicts_path
|
|
||||||
end
|
end
|
||||||
def showSubmit
|
def showSubmit
|
||||||
@results = Cancerpredictrecord.where("title"=>@app_title).take_while{true}
|
@results = Cancerpredictrecord.where("title"=>@app_title).take_while{true}
|
||||||
|
@ -146,7 +204,6 @@ class Admin::CancerpredictsController < OrbitAdminController
|
||||||
@choicenames.push @form_to_show.form_show[index.to_s]["choice_fields"][I18n.locale.to_s]
|
@choicenames.push @form_to_show.form_show[index.to_s]["choice_fields"][I18n.locale.to_s]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#render :html => @result_names.to_s
|
|
||||||
end
|
end
|
||||||
def create_first_field
|
def create_first_field
|
||||||
if Cancerpredictfields.where("title"=>(@app_title + "_back")).take_while{true}.count == 0
|
if Cancerpredictfields.where("title"=>(@app_title + "_back")).take_while{true}.count == 0
|
||||||
|
|
|
@ -10,96 +10,121 @@ class CancerpredictsController < ApplicationController
|
||||||
tags = OrbitHelper.widget_tags
|
tags = OrbitHelper.widget_tags
|
||||||
categories = OrbitHelper.widget_categories || []
|
categories = OrbitHelper.widget_categories || []
|
||||||
create_first_field
|
create_first_field
|
||||||
@record = Cancerpredictrecord.new
|
#begin
|
||||||
@record.title = @app_title
|
if params['header'].to_i == 1
|
||||||
params['data'].each do |rec_key,rec_value|
|
result = {}
|
||||||
@record.result[rec_key] = rec_value
|
@head_images = {}
|
||||||
end
|
@form_to_show.head_images_id.each do |image_id|
|
||||||
@record.submit_time = Time.now.to_s
|
next if image_id.to_s == ""
|
||||||
@record.save
|
@image = Headimages.find_by(:id=>image_id.to_s)
|
||||||
locale = params['data']['locale'].to_s rescue 'zh_tw'
|
@url = @image.temp_file.to_s
|
||||||
locale = 'zh_tw' if locale == 'zh_cn'
|
@head_images[@image.sort_number.to_i] = ('<img class="head_logo" alt ="' + Pathname.new(@image.temp_file.file.file).basename.to_s+'" src="'+@url+'\"/>')
|
||||||
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['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
|
|
||||||
result['grade_2'] = 1
|
|
||||||
else
|
|
||||||
result['grade_2'] = 0
|
|
||||||
end
|
|
||||||
if params['data']['grade'].to_i == 3
|
|
||||||
result['grade_3'] = 1
|
|
||||||
else
|
|
||||||
result['grade_3'] = 0
|
|
||||||
end
|
|
||||||
if params['data']['subtype'].to_i == 2
|
|
||||||
result['subtype_HER2'] = 1
|
|
||||||
else
|
|
||||||
result['subtype_HER2'] = 0
|
|
||||||
end
|
|
||||||
if params['data']['subtype'].to_i == 3
|
|
||||||
result['subtype_triple'] = 1
|
|
||||||
else
|
|
||||||
result['subtype_triple'] = 0
|
|
||||||
end
|
|
||||||
if params['data']['pstage'].to_i == 2
|
|
||||||
result['pstage_2'] = 1
|
|
||||||
else
|
|
||||||
result['pstage_2'] = 0
|
|
||||||
end
|
|
||||||
if params['data']['pstage'].to_i == 3
|
|
||||||
result['pstage_3'] = 1
|
|
||||||
else
|
|
||||||
result['pstage_3'] = 0
|
|
||||||
end
|
|
||||||
if params['data']['pstage'].to_i == 4
|
|
||||||
result['pstage_4'] = 1
|
|
||||||
else
|
|
||||||
result['pstage_4'] = 0
|
|
||||||
end
|
|
||||||
if params['data']['lvi'].to_i == 1
|
|
||||||
result['lvi_yes'] = 1
|
|
||||||
else
|
|
||||||
result['lvi_yes'] = 0
|
|
||||||
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['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 'error')
|
|
||||||
@years = ['1','3','5']
|
|
||||||
result['table'] = '<input id="current_year" type="hidden" value="'+@years[0]+'" index="0"/><p id="cancer_table_texts">此分析微針對已接受手術後病人,下表為此病人分別在第1年、3及5年下,根據選定的術後治療所估計的存活率</p>'
|
|
||||||
result['table'] += '<a>第</a>'
|
|
||||||
result['years'] = @years
|
|
||||||
@years.each{|year| result['table'] += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm">'+year+'</button>')}
|
|
||||||
result['table'] += '<a>年</a>'
|
|
||||||
@table_head = (locale == "zh_tw") ? ['治療','額外治療效益','總生存率(%)'] :['Treatment','Additional Benefit','Overall Survival(%)']
|
|
||||||
@head_name = ['Treatment','Additional_Benefit','Overall_Survival']
|
|
||||||
@therapy_choices = (locale == "zh_tw") ? ['純手術'] :['Surgery only']
|
|
||||||
@form_to_show.form_show_in_result.values.each{|choice| @therapy_choices.push choice["name"][locale]}
|
|
||||||
@therapy_names = ['Surgery_only']
|
|
||||||
@form_to_show.form_show_in_result.values.each{|choice| @therapy_names.push choice["variable"]}
|
|
||||||
result['treatmeny_method'] = @therapy_names
|
|
||||||
result['table'] += '<table><thead><tr>'
|
|
||||||
@table_head.each_with_index{|head,index| result['table'] += ('<th class="cancer_th '+@head_name[index]+'">' + head + '</th>')}
|
|
||||||
result['table'] += '</tr></thead><tbody>'
|
|
||||||
@therapy_choices.each_with_index do |choice,i|
|
|
||||||
result['table'] += '<tr class="'+@therapy_names[i].to_s+'">'
|
|
||||||
@table_head.each_with_index do |head,index|
|
|
||||||
result['table'] += ('<td class="cancer_td '+ @head_name[index]+'">' + ((index == 0) ? (((i==0)? '' : '+') + choice) : '-') + '</td>')
|
|
||||||
end
|
end
|
||||||
result['table'] += '</tr>'
|
result['head_images'] = Hash[@head_images.sort].values.join('')
|
||||||
|
@head_images = {}
|
||||||
|
@form_to_show.title_images_id.each do |image_id|
|
||||||
|
next if image_id.to_s == ""
|
||||||
|
@image = Headimages.find_by(:id=>image_id.to_s)
|
||||||
|
@url = @image.temp_file.to_s
|
||||||
|
@head_images[@image.sort_number.to_i] = ('<img class="head_logo" alt ="' + Pathname.new(@image.temp_file.file.file).basename.to_s+'" src="'+@url+'\"/>')
|
||||||
|
end
|
||||||
|
|
||||||
|
result['title'] = ((@form_to_show.title_texts == "") ? "" : '<a class="title_texts">'+@form_to_show.title_texts+'</a>')+Hash[@head_images.sort].values.join('')
|
||||||
|
else
|
||||||
|
@record = Cancerpredictrecord.new
|
||||||
|
@record.title = @app_title
|
||||||
|
params['data'].each do |rec_key,rec_value|
|
||||||
|
@record.result[rec_key] = rec_value
|
||||||
|
end
|
||||||
|
@record.submit_time = Time.now.to_s
|
||||||
|
@record.save
|
||||||
|
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['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
|
||||||
|
result['grade_2'] = 1
|
||||||
|
else
|
||||||
|
result['grade_2'] = 0
|
||||||
|
end
|
||||||
|
if params['data']['grade'].to_i == 3
|
||||||
|
result['grade_3'] = 1
|
||||||
|
else
|
||||||
|
result['grade_3'] = 0
|
||||||
|
end
|
||||||
|
if params['data']['subtype'].to_i == 2
|
||||||
|
result['subtype_HER2'] = 1
|
||||||
|
else
|
||||||
|
result['subtype_HER2'] = 0
|
||||||
|
end
|
||||||
|
if params['data']['subtype'].to_i == 3
|
||||||
|
result['subtype_triple'] = 1
|
||||||
|
else
|
||||||
|
result['subtype_triple'] = 0
|
||||||
|
end
|
||||||
|
if params['data']['pstage'].to_i == 2
|
||||||
|
result['pstage_2'] = 1
|
||||||
|
else
|
||||||
|
result['pstage_2'] = 0
|
||||||
|
end
|
||||||
|
if params['data']['pstage'].to_i == 3
|
||||||
|
result['pstage_3'] = 1
|
||||||
|
else
|
||||||
|
result['pstage_3'] = 0
|
||||||
|
end
|
||||||
|
if params['data']['pstage'].to_i == 4
|
||||||
|
result['pstage_4'] = 1
|
||||||
|
else
|
||||||
|
result['pstage_4'] = 0
|
||||||
|
end
|
||||||
|
if params['data']['lvi'].to_i == 1
|
||||||
|
result['lvi_yes'] = 1
|
||||||
|
else
|
||||||
|
result['lvi_yes'] = 0
|
||||||
|
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['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 'error')
|
||||||
|
@years = ['1','3','5']
|
||||||
|
result['table'] = '<input id="current_year" type="hidden" value="'+@years[0]+'" index="0"/><p id="cancer_table_texts">此分析微針對已接受手術後病人,下表為此病人分別在第1年、3及5年下,根據選定的術後治療所估計的存活率</p>'
|
||||||
|
result['table'] += '<a>第</a>'
|
||||||
|
result['years'] = @years
|
||||||
|
@years.each{|year| result['table'] += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm">'+year+'</button>')}
|
||||||
|
result['table'] += '<a>年</a>'
|
||||||
|
@table_head = (locale == "zh_tw") ? ['治療','額外治療效益','總生存率(%)'] :['Treatment','Additional Benefit','Overall Survival(%)']
|
||||||
|
@head_name = ['Treatment','Additional_Benefit','Overall_Survival']
|
||||||
|
@therapy_choices = (locale == "zh_tw") ? ['純手術'] :['Surgery only']
|
||||||
|
@form_to_show.form_show_in_result.values.each{|choice| @therapy_choices.push choice["name"][locale]}
|
||||||
|
@therapy_names = ['Surgery_only']
|
||||||
|
@form_to_show.form_show_in_result.values.each{|choice| @therapy_names.push choice["variable"]}
|
||||||
|
result['treatmeny_method'] = @therapy_names
|
||||||
|
result['table'] += '<table><thead><tr>'
|
||||||
|
@table_head.each_with_index{|head,index| result['table'] += ('<th class="cancer_th '+@head_name[index]+'">' + head + '</th>')}
|
||||||
|
result['table'] += '</tr></thead><tbody>'
|
||||||
|
@therapy_choices.each_with_index do |choice,i|
|
||||||
|
result['table'] += '<tr class="'+@therapy_names[i].to_s+'">'
|
||||||
|
@table_head.each_with_index do |head,index|
|
||||||
|
result['table'] += ('<td class="cancer_td '+ @head_name[index]+'">' + ((index == 0) ? (((i==0)? '' : '+') + choice) : '-') + '</td>')
|
||||||
|
end
|
||||||
|
result['table'] += '</tr>'
|
||||||
|
end
|
||||||
|
result['texts'] = '<a>此研究分析來自已接受根除性手術後之婦女所得之結果,根據您所輸入的資訊以及治療方式,</a>'+'<div style="clear:both;"></div>'+'<a>在術後第</a>'
|
||||||
|
@years.each{|year| result['texts'] += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm">'+year+'</button>')}
|
||||||
|
result['texts'] += '<a>年</a>,'
|
||||||
|
@servive_ratio = ((Math.exp(-0.001476145)**(Math.exp(result['lpv'])))*100).round
|
||||||
|
result['texts'] += ('<p class="show"><a>100 位只接受根除性手術的婦女中,有 '+ '<a class="'+@therapy_names[0]+' Overall_Survival">'+@servive_ratio.round.to_s+'</a>'+'<a> 位婦女,術後 </a>'+'<a class="surgery_year">'+@years[0].to_s+'</a>'+'<a>年仍為存活</a></p>')
|
||||||
|
result['texts'] += '<a class="addition">'+',此外</a><div class="extra-text" style="display:none;"><div class="texts_show" style="clear:both;"></div>'
|
||||||
|
result['texts'] += '</div>'
|
||||||
|
result['servive_ratio'] = @servive_ratio
|
||||||
end
|
end
|
||||||
result['texts'] = '<a>此研究分析來自已接受根除性手術後之婦女所得之結果,根據您所輸入的資訊以及治療方式,</a>'+'<div style="clear:both;"></div>'+'<a>在術後第</a>'
|
|
||||||
@years.each{|year| result['texts'] += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm">'+year+'</button>')}
|
|
||||||
result['texts'] += '<a>年</a>,'
|
|
||||||
@servive_ratio = ((Math.exp(-0.001476145)**(Math.exp(result['lpv'])))*100).round
|
|
||||||
result['texts'] += ('<p class="show"><a>100 位只接受根除性手術的婦女中,有 '+ '<a class="'+@therapy_names[0]+' Overall_Survival">'+@servive_ratio.round.to_s+'</a>'+'<a> 位婦女,術後 </a>'+'<a class="surgery_year">'+@years[0].to_s+'</a>'+'<a>年仍為存活</a></p>')
|
|
||||||
result['texts'] += '<a class="addition">'+',此外</a><div class="extra-text" style="display:none;"><div class="texts_show" style="clear:both;"></div>'
|
|
||||||
result['texts'] += '</div>'
|
|
||||||
result['servive_ratio'] = @servive_ratio
|
|
||||||
result = result.merge(params)
|
result = result.merge(params)
|
||||||
render :json=> result
|
render :json=> result
|
||||||
|
# rescue
|
||||||
|
# render :json=> params
|
||||||
|
#end
|
||||||
end
|
end
|
||||||
def index
|
def index
|
||||||
uid = OrbitHelper.params[:uid] rescue ""
|
uid = OrbitHelper.params[:uid] rescue ""
|
||||||
|
|
|
@ -6,7 +6,6 @@ class Cancerpredictfields
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
include OrbitTag::Taggable
|
include OrbitTag::Taggable
|
||||||
include OrbitCategory::Categorizable
|
include OrbitCategory::Categorizable
|
||||||
mount_uploader :temp_file, AssetUploader
|
|
||||||
field :title ,type:String ,default:""
|
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},
|
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},
|
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},
|
||||||
|
@ -29,7 +28,11 @@ class Cancerpredictfields
|
||||||
field :small ,type:String ,default:"0.825em"
|
field :small ,type:String ,default:"0.825em"
|
||||||
field :medium ,type:String ,default:"1em"
|
field :medium ,type:String ,default:"1em"
|
||||||
field :large ,type:String ,default:"1.25em"
|
field :large ,type:String ,default:"1.25em"
|
||||||
field :head_images ,type:Array , default: []
|
field :image_path ,type:String ,default:"1.25em"
|
||||||
|
field :head_images_id ,type:Array , default: []
|
||||||
|
field :title_images_id ,type:Array , default: []
|
||||||
|
field :title_texts ,type:String ,default:""
|
||||||
|
#field :image_uploader ,type:Object
|
||||||
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)}
|
||||||
#before_create :set_expire
|
#before_create :set_expire
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
# encoding: utf-8
|
||||||
|
require 'carrierwave/processing/mime_types'
|
||||||
|
|
||||||
|
class HeadImagesUploader < CarrierWave::Uploader::Base
|
||||||
|
|
||||||
|
include CarrierWave::MimeTypes
|
||||||
|
|
||||||
|
process :set_content_type
|
||||||
|
|
||||||
|
# Include RMagick or ImageScience support:
|
||||||
|
# include CarrierWave::RMagick
|
||||||
|
# include CarrierWave::ImageScience
|
||||||
|
|
||||||
|
# Choose what kind of storage to use for this uploader:
|
||||||
|
# storage :file
|
||||||
|
# storage :s3
|
||||||
|
|
||||||
|
# Override the directory where uploaded files will be stored.
|
||||||
|
# This is a sensible default for uploaders that are meant to be mounted:
|
||||||
|
def store_dir
|
||||||
|
return "uploads/#{model.class.to_s.underscore}/predict_tool"
|
||||||
|
end
|
||||||
|
|
||||||
|
# override
|
||||||
|
def filename
|
||||||
|
@original_filename
|
||||||
|
end
|
||||||
|
|
||||||
|
def cache_dir
|
||||||
|
"#{Rails.root}/tmp/uploads"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,13 @@
|
||||||
|
class Headimages
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
include OrbitModel::Status
|
||||||
|
include OrbitModel::Impression
|
||||||
|
# encoding: utf-8
|
||||||
|
include OrbitTag::Taggable
|
||||||
|
include OrbitCategory::Categorizable
|
||||||
|
mount_uploader :temp_file, HeadImagesUploader
|
||||||
|
field :cancerpredictfields_id ,type:String ,default:""
|
||||||
|
field :title ,type:String ,default:""
|
||||||
|
field :sort_number ,type:Integer ,default: 0
|
||||||
|
end
|
|
@ -0,0 +1,30 @@
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<!-- if this page editing please add class "fileupload-edit" -->
|
||||||
|
<div class="fileupload fileupload-new clearfix" data-provides="fileupload">
|
||||||
|
<span class="show_span"><%= t('cancerpredict.sort_num')+': ' %></span>
|
||||||
|
<%= f.text_field 'sort_number',{:class=>'sort_num',:value=>((image_form['sort_number'] == nil) ? i+1 : image_form['sort_number'] ),:style=>'float: left;width: 3em;'} %>
|
||||||
|
<span class="show_span"><%= t('cancerpredict.logo')+': ' %></span>
|
||||||
|
<div class="fileupload-new thumbnail pull-left">
|
||||||
|
<% if image_form.temp_file.file.present? %>
|
||||||
|
<%= image_tag( image_form.temp_file, :size=>"120x120") rescue ''%>
|
||||||
|
<% else %>
|
||||||
|
<%= image_tag "/assets/site-logo.png", :class => "pull-left upload-picture"%>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
||||||
|
<% if image_form.temp_file.file.present?%>
|
||||||
|
<span class="btn btn-file">
|
||||||
|
<%= f.file_field :temp_file, {:id => "input-upload", :class => 'fileupload-new', :accept=> 'image/png,image/gif,image/jpeg'} %><%= t('preferences.change') %>
|
||||||
|
</span>
|
||||||
|
<%= f.check_box :remove_image,{:checked=>false} %>
|
||||||
|
<%= t(:remove) %> <%= (I18n.locale.to_s == 'en') ? ' this logo' : '該logo' %>
|
||||||
|
<%else%>
|
||||||
|
<span class="btn btn-file">
|
||||||
|
<%= f.file_field :temp_file,{ :id => "input-upload", :class => 'fileupload-new', :accept=> 'image/png,image/gif,image/jpeg'} %><%= t('preferences.select_image') %>
|
||||||
|
</span>
|
||||||
|
<%end%>
|
||||||
|
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -1,6 +1,138 @@
|
||||||
|
<%= stylesheet_link_tag "lib/fileupload"%>
|
||||||
|
<%= javascript_include_tag 'lib/bootstrap-fileupload' %>
|
||||||
<div style="clear:both;"></div>
|
<div style="clear:both;"></div>
|
||||||
<%=form_for @form_to_show ,:url=>{:controller=>"cancerpredicts" ,:action=>"edit"} do |form|%>
|
<%=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.title') %></span>
|
||||||
|
<div style="clear:both;"></div>
|
||||||
|
<label class="label_left" for="title_text"><%= t('cancerpredict.title_text')+':' %></label> <%=form.text_field :title_texts ,{:value => @form_to_show.title_texts,:id=>"title_text"} %>
|
||||||
|
<% if @title_images.length != 0%>
|
||||||
|
<% @title_images.each_with_index do |temp_image,i| %>
|
||||||
|
<%= form.fields_for "title_images" do |image_fields| %>
|
||||||
|
<div class="image_field title_images" value="<%=(i+1).to_s%>">
|
||||||
|
<%= image_fields.fields_for i.to_s do |image_field| %>
|
||||||
|
<%= render :partial => 'image_form', :object => temp_image, :locals => {:f => image_field, :i => i} %>
|
||||||
|
<% if i.to_i == @title_images.length - 1%>
|
||||||
|
<script>
|
||||||
|
$(document).on('click', '#add_file.title_images', function(){
|
||||||
|
var old_id = $('.image_field.title_images').eq(-1).attr('value');
|
||||||
|
if( old_id == undefined)
|
||||||
|
old_id = 0;
|
||||||
|
else
|
||||||
|
old_id = Number(old_id);
|
||||||
|
var new_id = old_id + 1;
|
||||||
|
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => i}).gsub("\"","\'").html_safe %>"
|
||||||
|
$(this).parent().siblings('.add-target.title_images').before(('<div class="image_field title_images" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
|
||||||
|
var name = $('.image_field.title_images').eq(-1).find('[type="file"]').attr('name');
|
||||||
|
$('.image_field.title_images').eq(-1).find('[type="file"]').attr('name',name.replace("<%=i%>",new_id-1));
|
||||||
|
name = $('.image_field.title_images').eq(-1).find('input.sort_num').attr('name');
|
||||||
|
$('.image_field.title_images').eq(-1).find('input.sort_num').attr('name',name.replace("<%=i%>",new_id-1));
|
||||||
|
new_id = $('.image_field.title_images').eq(-2).find('input.sort_num').val();
|
||||||
|
$('.image_field.title_images').eq(-1).find('input.sort_num').val(Number(new_id)+1);
|
||||||
|
formTip();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<%= form.fields_for "title_images" do |image_fields| %>
|
||||||
|
<%= image_fields.fields_for "0" do |image_field| %>
|
||||||
|
<script>
|
||||||
|
$(document).on('click', '#add_file.title_images', function(){
|
||||||
|
var old_id = $('.image_field.title_images').eq(-1).attr('value');
|
||||||
|
if( old_id == undefined)
|
||||||
|
old_id = 0;
|
||||||
|
else
|
||||||
|
old_id = Number(old_id);
|
||||||
|
var new_id = old_id + 1;
|
||||||
|
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => 0}).gsub("\"","\'").html_safe %>"
|
||||||
|
$(this).parent().siblings('.add-target.title_images').before(('<div class="image_field title_images" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
|
||||||
|
var name = $('.image_field.title_images').eq(-1).find('[type="file"]').attr('name');
|
||||||
|
$('.image_field.title_images').eq(-1).find('[type="file"]').attr('name',name.replace("0",new_id-1));
|
||||||
|
name = $('.image_field.title_images').eq(-1).find('input.sort_num').attr('name');
|
||||||
|
$('.image_field.title_images').eq(-1).find('input.sort_num').attr('name',name.replace("0",new_id-1));
|
||||||
|
new_id = $('.image_field.title_images').eq(-2).find('input.sort_num').val();
|
||||||
|
if(new_id != undefined)
|
||||||
|
$('.image_field.title_images').eq(-1).find('input.sort_num').val(Number(new_id)+1);
|
||||||
|
else
|
||||||
|
$('.image_field.title_images').eq(-1).find('input.sort_num').val(1);
|
||||||
|
formTip();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<div class="add-target title_images"></div>
|
||||||
|
<p class="add-btn">
|
||||||
|
<%= hidden_field_tag 'title_images_count', @title_images.count %>
|
||||||
|
<a id="add_file" class="title_images trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t('cancerpredict.add_image') %></a>
|
||||||
|
</p>
|
||||||
|
<span class="show_span"><%= t('cancerpredict.tool_head_pictures') %></span>
|
||||||
|
<div style="clear:both;"></div>
|
||||||
|
<% if @head_images.length != 0%>
|
||||||
|
<% @head_images.each_with_index do |temp_image,i| %>
|
||||||
|
<%= form.fields_for "head_images" do |image_fields| %>
|
||||||
|
<div class="head_images image_field" value="<%=(i+1).to_s%>">
|
||||||
|
<%= image_fields.fields_for i.to_s do |image_field| %>
|
||||||
|
<%= render :partial => 'image_form', :object => temp_image, :locals => {:f => image_field, :i => i} %>
|
||||||
|
<% if i.to_i == @head_images.length - 1%>
|
||||||
|
<script>
|
||||||
|
$(document).on('click', '#add_file.head_images', function(){
|
||||||
|
var old_id = $('.image_field').eq(-1).attr('value');
|
||||||
|
if( old_id == undefined)
|
||||||
|
old_id = 0;
|
||||||
|
else
|
||||||
|
old_id = Number(old_id);
|
||||||
|
var new_id = old_id + 1;
|
||||||
|
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => i}).gsub("\"","\'").html_safe %>"
|
||||||
|
$(this).parent().siblings('.add-target.head_images').before(('<div class="image_field" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
|
||||||
|
var name = $('.image_field').eq(-1).find('[type="file"]').attr('name');
|
||||||
|
$('.image_field').eq(-1).find('[type="file"]').attr('name',name.replace("<%=i%>",new_id-1));
|
||||||
|
name = $('.image_field').eq(-1).find('input.sort_num').attr('name');
|
||||||
|
$('.image_field').eq(-1).find('input.sort_num').attr('name',name.replace("<%=i%>",new_id-1));
|
||||||
|
new_id = $('.image_field').eq(-2).find('input.sort_num').val();
|
||||||
|
$('.image_field').eq(-1).find('input.sort_num').val(Number(new_id)+1);
|
||||||
|
formTip();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<%= form.fields_for "head_images" do |image_fields| %>
|
||||||
|
<%= image_fields.fields_for "0" do |image_field| %>
|
||||||
|
<script>
|
||||||
|
$(document).on('click', '#add_file.head_images', function(){
|
||||||
|
var old_id = $('.image_field.head_images').eq(-1).attr('value');
|
||||||
|
if( old_id == undefined)
|
||||||
|
old_id = 0;
|
||||||
|
else
|
||||||
|
old_id = Number(old_id);
|
||||||
|
var new_id = old_id + 1;
|
||||||
|
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => 0}).gsub("\"","\'").html_safe %>"
|
||||||
|
$(this).parent().siblings('.add-target.head_images').before(('<div class="image_field head_images" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
|
||||||
|
var name = $('.image_field.head_images').eq(-1).find('[type="file"]').attr('name');
|
||||||
|
$('.image_field.head_images').eq(-1).find('[type="file"]').attr('name',name.replace("0",new_id-1));
|
||||||
|
name = $('.image_field.head_images').eq(-1).find('input.sort_num').attr('name');
|
||||||
|
$('.image_field.head_images').eq(-1).find('input.sort_num').attr('name',name.replace("0",new_id-1));
|
||||||
|
new_id = $('.image_field.head_images').eq(-2).find('input.sort_num').val();
|
||||||
|
if(new_id != undefined)
|
||||||
|
$('.image_field.head_images').eq(-1).find('input.sort_num').val(Number(new_id)+1);
|
||||||
|
else
|
||||||
|
$('.image_field.head_images').eq(-1).find('input.sort_num').val(1);
|
||||||
|
formTip();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<div class="add-target head_images"></div>
|
||||||
|
<p class="add-btn">
|
||||||
|
<%= hidden_field_tag 'head_images_count', @head_images.count %>
|
||||||
|
<a id="add_file" class="head_images trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t('cancerpredict.add_image') %></a>
|
||||||
|
</p>
|
||||||
<span class="show_span"><%= t('cancerpredict.text_descibe') %></span>
|
<span class="show_span"><%= t('cancerpredict.text_descibe') %></span>
|
||||||
<div style="clear:both;"></div>
|
<div style="clear:both;"></div>
|
||||||
<%= form.text_field 'text_descibe',{:value=> @form_to_show.text_descibe[I18n.locale.to_s],:style=>'width:100%;'} %>
|
<%= form.text_field 'text_descibe',{:value=> @form_to_show.text_descibe[I18n.locale.to_s],:style=>'width:100%;'} %>
|
||||||
|
|
|
@ -9,6 +9,12 @@ en:
|
||||||
medium: medium
|
medium: medium
|
||||||
large: large
|
large: large
|
||||||
Input_fields: User input fields' contents
|
Input_fields: User input fields' contents
|
||||||
|
tool_head_pictures: All the logos in the page of predict tool
|
||||||
|
sort_num: sort num
|
||||||
|
logo: logo image
|
||||||
|
title: title of the page of predict tool
|
||||||
|
title_text: title texts
|
||||||
|
add_image: add image
|
||||||
table:
|
table:
|
||||||
welcome: Welcome to The after breast cancer healing system of Taiwanprepare!\nTo start, please enter the relevant information below.
|
welcome: Welcome to The after breast cancer healing system of Taiwanprepare!\nTo start, please enter the relevant information below.
|
||||||
Reset: Reset
|
Reset: Reset
|
||||||
|
|
|
@ -9,6 +9,12 @@ zh_tw:
|
||||||
medium: 中
|
medium: 中
|
||||||
large: 大
|
large: 大
|
||||||
Input_fields: 使用者輸入欄位內容
|
Input_fields: 使用者輸入欄位內容
|
||||||
|
tool_head_pictures: 預測工具頁面最上方的所有logo
|
||||||
|
sort_num: 順序號碼
|
||||||
|
logo: logo圖片
|
||||||
|
title: 預測工具頁面標題
|
||||||
|
title_text: 標題文字
|
||||||
|
add_image: 新增圖片
|
||||||
table:
|
table:
|
||||||
welcome: 歡迎使用台灣準備乳癌癒後系統!\n若要開始 請在下方輸入相關資訊
|
welcome: 歡迎使用台灣準備乳癌癒後系統!\n若要開始 請在下方輸入相關資訊
|
||||||
Reset: 重置
|
Reset: 重置
|
||||||
|
|
Loading…
Reference in New Issue