Change a lot,including mapping files and add feature that users can edit calculation formula at backend page by themself.
This commit is contained in:
parent
4d41c5bce0
commit
43711808e9
|
@ -1,3 +1,32 @@
|
|||
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 = {};
|
||||
|
@ -24,6 +53,12 @@ $(document).ready(function(){
|
|||
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<arguments.length;i++){
|
||||
|
@ -348,13 +383,13 @@ $(document).ready(function(){
|
|||
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']];
|
||||
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 = lpv_real[lpv_real.length-1]+lpv_dict[arguments[0]];
|
||||
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];
|
||||
|
@ -398,7 +433,7 @@ $(document).ready(function(){
|
|||
var year = $('#current_year').attr('value');
|
||||
if(index < this.length - 1){
|
||||
for(var i = index + 1;i < this.length; i++){
|
||||
lpv_real[i] -= lpv_dict[arguments[0]];
|
||||
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]);
|
||||
|
@ -546,44 +581,181 @@ $(document).ready(function(){
|
|||
});
|
||||
};
|
||||
};
|
||||
function calculate_and_change_result_value(obj){
|
||||
obj.servive_ratio_arr = [];
|
||||
for(var i = 0;i<obj.active_treatment.length;i++){
|
||||
var servive_ratio = round((1-(obj.lpv_calc[obj.year]**Math.exp(obj.lpv_real[i])))*100,2);
|
||||
var benefit = servive_ratio - obj.servive_ratio_arr[obj.servive_ratio_arr.length-1];
|
||||
obj.servive_ratio_arr.push(servive_ratio);
|
||||
$('tr.'+obj.active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%');
|
||||
$('.'+obj.active_treatment[i]+'.Overall_Survival').html(servive_ratio);
|
||||
if(i != 0){
|
||||
$('tr.'+obj.active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%');
|
||||
$('.'+obj.active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit));
|
||||
}
|
||||
}
|
||||
//$('.'+obj.active_treatment[0]+'.Overall_Survival').html(Math.round(obj.servive_ratio_arr[0]));
|
||||
};
|
||||
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'];
|
||||
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=>(original_value+new_lpv-old_lpv));
|
||||
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);
|
||||
};
|
||||
};
|
||||
function calculate_first_lpv(result_json){
|
||||
result = {}
|
||||
result['sex_value'] = result_json['sex'] - 1
|
||||
result['Age_value'] = result_json['age']
|
||||
if(result_json['calcification_score'] < 1400)
|
||||
result['cal_value'] = 0;
|
||||
else
|
||||
result['cal_value'] = 1;
|
||||
try{
|
||||
result['lpv'] = -0.51427548* (result['sex_value']- 0.508312) + 0.05764604* (result['Age_value'] - 61.894501) + 0.49138819*(result['cal_value'] - 0.334399);
|
||||
}catch(e){result['lpv'] = "error"};
|
||||
console.log(result['lpv']);
|
||||
return result;
|
||||
};
|
||||
/* 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<obj.active_treatment.length;i++){
|
||||
var servive_ratio = round((1-(calculate_servive_ratio(obj.year,obj.lpv_real[i])))*100,2);
|
||||
var benefit = servive_ratio - obj.servive_ratio_arr[obj.servive_ratio_arr.length-1];
|
||||
obj.servive_ratio_arr.push(servive_ratio);
|
||||
$('tr.'+obj.active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%');
|
||||
$('.'+obj.active_treatment[i]+'.Overall_Survival').html(servive_ratio);
|
||||
if(i != 0){
|
||||
$('tr.'+obj.active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%');
|
||||
$('.'+obj.active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit));
|
||||
}
|
||||
}
|
||||
//$('.'+obj.active_treatment[0]+'.Overall_Survival').html(Math.round(obj.servive_ratio_arr[0]));
|
||||
};
|
||||
|
||||
function calculate_servive_ratio(year,obj){
|
||||
var servive_ratio;
|
||||
console.log(obj);
|
||||
var A = obj['A'];
|
||||
switch(year) {
|
||||
case '1':
|
||||
servive_ratio = 0.8095037**( Math.exp(A) );
|
||||
break;
|
||||
|
||||
case '1.5':
|
||||
servive_ratio = 0.729158**( Math.exp(A) );
|
||||
break;
|
||||
|
||||
case '2':
|
||||
servive_ratio = 0.6717211**( Math.exp(A) );
|
||||
break;
|
||||
|
||||
case '2.5':
|
||||
servive_ratio = 0.6056773**( Math.exp(A) );
|
||||
break;
|
||||
|
||||
default:
|
||||
console.log('not found year.');
|
||||
}
|
||||
return servive_ratio;
|
||||
}
|
||||
/* auto add end */
|
||||
function submit_fcn(){
|
||||
var post_json = get_input_data();
|
||||
if(post_json != null){
|
||||
|
|
|
@ -4,6 +4,7 @@ class Admin::CancerpredictsController < OrbitAdminController
|
|||
require 'rubyXL'
|
||||
require 'fileutils'
|
||||
require "axlsx"
|
||||
require "csv"
|
||||
#include Admin::CancerpredictsHelper
|
||||
before_action ->(module_app = @app_title) { set_variables module_app }
|
||||
before_action :create_first_field
|
||||
|
@ -27,74 +28,157 @@ class Admin::CancerpredictsController < OrbitAdminController
|
|||
@head_new_image = Headimages.new(:cancerpredictfields_id => @form_to_show.id)
|
||||
end
|
||||
def edit
|
||||
other_in_use_locales = Site.first.in_use_locales.map{|l| l.to_s}
|
||||
other_in_use_locales.delete(params[:locale])
|
||||
if !(params["cancerpredictfields"].nil?)
|
||||
org_nums = @form_to_show.form_show_was.keys
|
||||
remain_org_nums = params["cancerpredictfields"]["form_show"].values.map{|property| property["old_num"]}.select{|n| n.present?}
|
||||
delete_nums = org_nums - remain_org_nums
|
||||
if !delete_nums.blank?
|
||||
delete_nums.each do |delete_num|
|
||||
@form_to_show.form_show.delete(delete_num)
|
||||
end
|
||||
end
|
||||
params["cancerpredictfields"]["form_show"].each do |num,property|
|
||||
property.each do |key,value|
|
||||
if value != "0" && value != "1"
|
||||
if key != params[:locale]
|
||||
if @form_to_show.form_show[num.to_s][key.to_s].class != Array
|
||||
@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] = YAML.load(value)
|
||||
else
|
||||
@form_to_show.form_show[num.to_s][key.to_s] = []
|
||||
end
|
||||
end
|
||||
if key.include?("_file") && (!value[:temp_file].blank? rescue false)
|
||||
if value[:id].nil?
|
||||
mapping_file = CancerPredictMappingFile.create(value)
|
||||
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
|
||||
mapping_file = CancerPredictMappingFile.find(value[:id])
|
||||
mapping_file.temp_file = value[:temp_file]
|
||||
mapping_file.save
|
||||
end
|
||||
@form_to_show.form_show[num.to_s][key.to_s] = mapping_file.id
|
||||
elsif key.include?("_file")
|
||||
if value[:_destroy] == "1"
|
||||
mapping_file = CancerPredictMappingFile.find(value[:id])
|
||||
mapping_file.destroy
|
||||
@form_to_show.form_show[num.to_s][key.to_s] = ""
|
||||
end
|
||||
end
|
||||
next if key.include?("_file")
|
||||
if (key != "old_num")
|
||||
if value != "0" && value != "1"
|
||||
if key != params[:locale]
|
||||
@form_to_show.form_show[num.to_s] = {} if @form_to_show.form_show[num.to_s].nil?
|
||||
type = Cancerpredictfields::FIELDINFO[key.to_s].constantize rescue String
|
||||
if @form_to_show.form_show[num.to_s][key.to_s].class != Array && type != Array
|
||||
@form_to_show.form_show[num.to_s][key.to_s] = 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)
|
||||
if value.length > 2
|
||||
@form_to_show.form_show[num.to_s][key.to_s] = YAML.load(value)
|
||||
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|
|
||||
type = Cancerpredictfields::FIELDINFO[sub_property.to_s].constantize rescue String
|
||||
@form_to_show.form_show[ num.to_s ][ sub_property ] = {} if @form_to_show.form_show[num.to_s][ sub_property ].nil?
|
||||
if @form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s].class != Array && type != 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
|
||||
if(property["old_num"] != nil && property["old_num"] != num.to_s)
|
||||
other_in_use_locales.each do |locale|
|
||||
@form_to_show.form_show[ num.to_s ][ sub_property ][locale] = @form_to_show.form_show_was[ property["old_num"] ][ sub_property ][locale]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@form_to_show.form_show[num.to_s][key.to_s] = value.to_i
|
||||
end
|
||||
else
|
||||
@form_to_show.form_show[num.to_s][key.to_s] = value.to_i
|
||||
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
|
||||
largest_num = org_nums.map{|n| n.to_i}.sort.last
|
||||
if (params["cancerpredictfields"]["form_show"].keys.last.to_i + 1 ) <= largest_num
|
||||
( (params["cancerpredictfields"]["form_show"].keys.last.to_i + 1 ) .. (largest_num)).each do |i|
|
||||
@form_to_show.form_show.delete i.to_s
|
||||
end
|
||||
end
|
||||
if !params["cancerpredictfields"]["form_show_in_result"].nil?
|
||||
org_nums = @form_to_show.form_show_in_result_was.keys
|
||||
remain_org_nums = params["cancerpredictfields"]["form_show_in_result"].values.map{|property| property["old_num"]}.select{|n| n.present?}
|
||||
delete_nums = org_nums - remain_org_nums
|
||||
if !delete_nums.blank?
|
||||
delete_nums.each do |delete_num|
|
||||
@form_to_show.form_show_in_result.delete(delete_num)
|
||||
end
|
||||
end
|
||||
end if !params["cancerpredictfields"]["form_show_in_result"].nil?
|
||||
@create_items = ['title_texts','form_result_is_right','text_descibe','years','table_above_texts','text_above_texts','surgery_only_texts','extra_texts','extra_therapy_texts','danger_texts','texts_between_Result_and_result_block']
|
||||
params["cancerpredictfields"]["form_show_in_result"].each do |num,property|
|
||||
property.each do |key,value|
|
||||
if key.include?("_file") && (!value[:temp_file].blank? rescue false)
|
||||
if value[:id].nil?
|
||||
mapping_file = CancerPredictMappingFile.create(value)
|
||||
else
|
||||
mapping_file = CancerPredictMappingFile.find(value[:id])
|
||||
mapping_file.temp_file = value[:temp_file]
|
||||
mapping_file.save
|
||||
end
|
||||
@form_to_show.form_show[num.to_s][key.to_s] = mapping_file.id
|
||||
elsif key.include?("_file")
|
||||
if value[:_destroy] == "1"
|
||||
mapping_file = CancerPredictMappingFile.find(value[:id])
|
||||
mapping_file.destroy
|
||||
@form_to_show.form_show[num.to_s][key.to_s] = ""
|
||||
end
|
||||
end
|
||||
next if key.include?("_file")
|
||||
if (key != "old_num")
|
||||
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
|
||||
if(property["old_num"] != nil && property["old_num"] != num.to_s)
|
||||
other_in_use_locales.each do |locale|
|
||||
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][locale] = @form_to_show.form_show_in_result_was[ property["old_num"] ][ sub_property ][locale]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@form_to_show.form_show_in_result[num.to_s][key.to_s] = value.to_i
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
largest_num = org_nums.map{|n| n.to_i}.sort.last
|
||||
if (params["cancerpredictfields"]["form_show_in_result"].keys.last.to_i + 1 ) <= largest_num
|
||||
( (params["cancerpredictfields"]["form_show_in_result"].keys.last.to_i + 1 ) .. (largest_num)).each do |i|
|
||||
@form_to_show.form_show_in_result.delete i.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
@create_items = ['title_texts','form_result_is_right','text_descibe','years','table_above_texts','text_above_texts','surgery_only_texts','extra_texts','extra_therapy_texts','danger_texts','texts_between_Result_and_result_block','prediction_formula']
|
||||
params_cancer = params.require("cancerpredictfields").permit!
|
||||
@create_items.each do |item|
|
||||
if (@form_to_show[item].class == BSON::Document) || (@form_to_show.send(item).class == Hash)
|
||||
puts params_cancer[item]
|
||||
item_hash = @form_to_show[item]
|
||||
item_hash = item_hash.merge(params_cancer[item])
|
||||
@form_to_show[item] = item_hash
|
||||
|
@ -185,7 +269,29 @@ class Admin::CancerpredictsController < OrbitAdminController
|
|||
Headimages.find_by(:id => @image_id ).destroy rescue next
|
||||
@form_to_show.title_images_id.delete(@image_id)
|
||||
end
|
||||
file_ids = @form_to_show.form_show.values.map{|property| [property[:variable],property[:cancer_predict_mapping_file]]}.select{|k,f| f.present?}.to_h
|
||||
mapping_data_from_csv = {}
|
||||
if !file_ids.blank?
|
||||
file_ids.each do |k,v|
|
||||
mapping_data_from_csv[k] = read_mapping_file(v)
|
||||
end
|
||||
end
|
||||
@form_to_show.mapping_data_from_csv = mapping_data_from_csv.to_json
|
||||
@form_to_show.save
|
||||
fork do
|
||||
js_codes = auto_write_predict_js
|
||||
save_path = `bundle show cancerpredict`
|
||||
save_path = save_path.sub("\n","") + '/app/assets/javascripts/cancer_predict.js'
|
||||
file_texts = File.read(save_path)
|
||||
str1 = "/* auto add start */"
|
||||
index1 = file_texts.index(str1)
|
||||
str2 = "/* auto add end */"
|
||||
index2 = file_texts.index(str2)
|
||||
file_texts = file_texts.sub(file_texts[(index1+str1.length+2) .. (index2 - 1)] , js_codes)
|
||||
if !index1.nil? && !index2.nil?
|
||||
File.write(save_path,file_texts)
|
||||
end
|
||||
end
|
||||
end
|
||||
@index = 0
|
||||
Dir.chdir("public") do
|
||||
|
@ -232,16 +338,18 @@ class Admin::CancerpredictsController < OrbitAdminController
|
|||
@field_property = {}
|
||||
property.each do |key,value|
|
||||
@value= value
|
||||
@disp_value
|
||||
if @value.class == BSON::Document || @value.class == Hash
|
||||
@disp_value = @value[current_locale] rescue ""
|
||||
else
|
||||
@disp_value = @value
|
||||
end
|
||||
@disp_value = "" if @disp_value.nil?
|
||||
@field_property[key] = @disp_value
|
||||
end
|
||||
if @field_property['right'] == 0
|
||||
next if @field_property["name"].blank?
|
||||
@table_str_left += '<div data-key='+num.to_s+'>'
|
||||
break if @field_property["name"] == ""
|
||||
@table_str_left += '<label for="'+@field_property["variable"]+'" style="float:left;'+(@field_property["comment_text"] == "" ? "margin-right: 2.125em;" : "")+'" class="cencer_table_name">'
|
||||
@table_str_left += @field_property["name"]
|
||||
@table_str_left += '</label>'
|
||||
|
@ -256,7 +364,7 @@ class Admin::CancerpredictsController < OrbitAdminController
|
|||
@field_property["comment_text"] = property["comment_text"][locale.to_s]
|
||||
break
|
||||
end
|
||||
if @field_property["comment_text"] != ""
|
||||
if @field_property["comment_text"].present?
|
||||
@table_str_left += '<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;"><i aria-hidden="true" class="fa fa-question"></i></button>'
|
||||
@table_str_left += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
|
||||
else
|
||||
|
@ -565,4 +673,125 @@ class Admin::CancerpredictsController < OrbitAdminController
|
|||
end
|
||||
pagination += (((page==all_page_num) ? '<li>['+I18n.t('cancerpredict.next_page')+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+(page+1).to_s+'"> ['+I18n.t('cancerpredict.next_page')+'] </a></li>')+'</ol></div>')
|
||||
end
|
||||
def read_mapping_file(mapping_file_id)
|
||||
mapping_file = CancerPredictMappingFile.find(mapping_file_id) rescue nil
|
||||
if !mapping_file.nil?
|
||||
csv_rows = CSV.read(mapping_file.temp_file.file.path)
|
||||
titles = csv_rows[0]
|
||||
infos = {}
|
||||
titles.each_with_index do |title,i|
|
||||
infos[title] = []
|
||||
csv_rows[1..-1].each do |row|
|
||||
infos[title] << row[i].to_f
|
||||
end
|
||||
end
|
||||
return infos
|
||||
else
|
||||
return {}
|
||||
end
|
||||
end
|
||||
def auto_write_predict_js
|
||||
js_code = "var map_values , mapping_hash , temp_index ,temp_value , index , closest_value;\r\n"
|
||||
mapping_data_from_csv = YAML.load(@form_to_show.mapping_data_from_csv) rescue {}
|
||||
#js_code += "\t\t\t\tvar mapping_data_from_csv = #{mapping_data_from_csv.to_s.gsub("=>",":")};\r\n"
|
||||
variable_keys = []
|
||||
@form_to_show.form_show.each do |num,property|
|
||||
@variable = property[:variable]
|
||||
if @variable.present?
|
||||
if property[:is_num] == 1
|
||||
js_code += "\t\t\t\tresult['#{@variable}'] = Number(result_json['#{@variable}']);\r\n"
|
||||
elsif property[:choice_fields].present?
|
||||
if property[:map_values].class == Array && property[:choice_fields].class == Array && property[:map_values].length == property[:choice_fields].length
|
||||
js_code += "\t\t\t\tmap_values = #{property[:map_values]};\r\n"
|
||||
js_code += "\t\t\t\tresult['#{@variable}'] = map_values[Number(result_json['#{@variable}'']) - 1];\r\n"
|
||||
else
|
||||
if property[:revert_value].to_i != 1
|
||||
js_code += "\t\t\t\tresult['#{@variable}'] = Number(result_json['#{@variable}']) - 1;\r\n"
|
||||
else
|
||||
js_code += "\t\t\t\tresult['#{@variable}'] = (#{property[:choice_fields].length} - Number(result_json['#{@variable}']));\r\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
variable_keys.push(@variable)
|
||||
if property[:cancer_predict_mapping_file].present?
|
||||
if (mapping_data_from_csv != {} && !mapping_data_from_csv[@variable].blank?)
|
||||
variable_keys.concat(mapping_data_from_csv[@variable].keys)
|
||||
js_code += "\t\t\t\tmapping_hash = mapping_data_from_csv['#{@variable}'];\r\n"
|
||||
js_code += "\t\t\t\ttemp_index = 0;\r\n"
|
||||
js_code += "\t\t\t\ttemp_value = result[#{@variable}];\r\n"
|
||||
js_code += "\t\t\t\tindex = 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++;
|
||||
});\r\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
formula = @form_to_show.prediction_formula.gsub("\r\n"," ").gsub("^","**")
|
||||
variable_keys.each do |k|
|
||||
formula = formula.gsub(/#{k}?(-|\+|\*|\s|\=)/){ "result[\"#{k}\"]#{$1}" }
|
||||
end
|
||||
formula_variables = formula.enum_for(:scan,/([^\=]*)?=/).map { Regexp.last_match[1] }.map{|s| s.strip.split(/(\s*|;\r\n)/).last}
|
||||
js_code = "function calculate_first_lpv(result_json){
|
||||
result = {};
|
||||
#{js_code}
|
||||
try{
|
||||
result['lpv'] = (#{formula});
|
||||
}catch(e){result['lpv'] = \"error\"};
|
||||
console.log(result['lpv']);
|
||||
#{formula_variables.map{|v| "result['lpv_variable']['#{v}'] = #{v};"}.join("\r\n\t\t\t\t") }
|
||||
return result;
|
||||
};
|
||||
function calculate_and_change_result_value(obj){
|
||||
obj.servive_ratio_arr = [];
|
||||
for(var i = 0;i<obj.active_treatment.length;i++){
|
||||
var servive_ratio = round((1-(calculate_servive_ratio(obj.year,obj.lpv_real[i])))*100,2);
|
||||
var benefit = servive_ratio - obj.servive_ratio_arr[obj.servive_ratio_arr.length-1];
|
||||
obj.servive_ratio_arr.push(servive_ratio);
|
||||
$('tr.'+obj.active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%');
|
||||
$('.'+obj.active_treatment[i]+'.Overall_Survival').html(servive_ratio);
|
||||
if(i != 0){
|
||||
$('tr.'+obj.active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%');
|
||||
$('.'+obj.active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit));
|
||||
}
|
||||
}
|
||||
//$('.'+obj.active_treatment[0]+'.Overall_Survival').html(Math.round(obj.servive_ratio_arr[0]));
|
||||
};"
|
||||
@years = @form_to_show.years
|
||||
switch_texts = "
|
||||
#{formula_variables.map{|v| "var #{v} = obj['#{v}'];"}.join("\r\n\t\t\t\t")}
|
||||
switch(year) {"
|
||||
@years.each do |year|
|
||||
year_index = @years.index(year)
|
||||
switch_texts +=
|
||||
"
|
||||
case '#{year}':
|
||||
servive_ratio = #{@form_to_show.years_settings[year_index].gsub('^','**').gsub('exp','Math.exp')};
|
||||
break;
|
||||
"
|
||||
end
|
||||
switch_texts += "
|
||||
default:
|
||||
console.log('not found year.');
|
||||
}"
|
||||
js_code = js_code +"
|
||||
|
||||
function calculate_servive_ratio(year,obj){
|
||||
var servive_ratio;
|
||||
#{switch_texts}
|
||||
return servive_ratio;
|
||||
}
|
||||
"
|
||||
return js_code
|
||||
end
|
||||
end
|
|
@ -30,6 +30,9 @@ class CancerpredictsController < ApplicationController
|
|||
result['danger_texts'] = (@form_to_show.danger_texts[locale] rescue '')
|
||||
result['title'] = Hash[@head_images.sort].values.join('')
|
||||
result['page_title'] = @form_to_show.title_texts[params[:locale]]
|
||||
elsif params['get_mapping_data_from_csv'].to_i == 1
|
||||
result = {}
|
||||
result['mapping_data_from_csv'] = YAML.load(@form_to_show.mapping_data_from_csv) rescue {}
|
||||
else
|
||||
@record = Cancerpredictrecord.new
|
||||
@record.title = @app_title
|
||||
|
@ -49,14 +52,66 @@ class CancerpredictsController < ApplicationController
|
|||
locale = params['data']['locale'].to_s rescue 'zh_tw'
|
||||
locale = 'zh_tw' if locale == 'zh_cn'
|
||||
result = {}
|
||||
result['sex_value'] = params['data']['sex'].to_i - 1
|
||||
result['Age_value'] = params['data']['age'].to_i
|
||||
if params['data']['calcification_score'].to_i < 1400
|
||||
result['cal_value'] = 0
|
||||
else
|
||||
result['cal_value'] = 1
|
||||
# result['sex_value'] = params['data']['sex'].to_i - 1
|
||||
# result['Age_value'] = params['data']['age'].to_i
|
||||
# if params['data']['calcification_score'].to_i < 1400
|
||||
# result['cal_value'] = 0
|
||||
# else
|
||||
# result['cal_value'] = 1
|
||||
# end
|
||||
mapping_data_from_csv = YAML.load(@form_to_show.mapping_data_from_csv) rescue {}
|
||||
@form_to_show.form_show.each do |num,property|
|
||||
@variable = property[:variable]
|
||||
if @variable.present?
|
||||
if property[:is_num] == 1
|
||||
result[@variable] = params['data'][@variable].to_f rescue 0.0
|
||||
elsif property[:choice_fields].present?
|
||||
if property[:map_values].class == Array && property[:choice_fields].class == Array && property[:map_values].length == property[:choice_fields].length
|
||||
result[@variable] = property[:map_values][params['data'][@variable].to_i - 1]
|
||||
else
|
||||
if property[:revert_value].to_i != 1
|
||||
result[@variable] = params['data'][@variable].to_i - 1
|
||||
else
|
||||
result[@variable] = ((property[:choice_fields].length - params['data'][@variable].to_i) rescue params['data'][@variable].to_i)
|
||||
end
|
||||
end
|
||||
end
|
||||
if property[:cancer_predict_mapping_file].present?
|
||||
if (mapping_data_from_csv != {})
|
||||
mapping_hash = mapping_data_from_csv[@variable]
|
||||
temp_index = 0
|
||||
temp_value = result[@variable]
|
||||
mapping_hash.each_with_index do |(k,v),i|
|
||||
if i == 0
|
||||
index_val = v.index(temp_value) rescue nil
|
||||
if !index_val.nil?
|
||||
temp_index = index_val
|
||||
else
|
||||
closest_value = v.min_by{|x| (temp_value-x).abs}
|
||||
temp_index = v.index(closest_value)
|
||||
end
|
||||
end
|
||||
result[k] = v[temp_index]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
#result['lpv'] = -0.51427548* (result['sex_value']- 0.508312) + 0.05764604* (result['Age_value'] - 61.894501) + 0.49138819*(result['cal_value'] - 0.334399) rescue 'error'
|
||||
formula = @form_to_show.prediction_formula.gsub("\r\n"," ").gsub("^","**")
|
||||
result.keys.each do |k|
|
||||
formula = formula.gsub(/#{k}?(-|\+|\*|\s|\=)/){ "result[\"#{k}\"]#{$1}" }
|
||||
end
|
||||
formula_variables = formula.enum_for(:scan,/([^\=]*)?=/).map { Regexp.last_match[1] }.map{|s| s.strip.split(/(\s*|;\r\n)/).last}
|
||||
|
||||
@form_to_show.form_show.values.map{|p| p[:variable]}.each{ |k| formula = formula.gsub(/#{k}?(-|\+|\*|\s|\=)/,"result[\"#{k}\"#{$1}]") }
|
||||
|
||||
eval(formula)
|
||||
result['lpv'] = eval(formula_variables.last)
|
||||
result['lpv_variable'] = {}
|
||||
formula_variables.each do |variable_name|
|
||||
eval( "result['lpv_variable']['#{variable_name}'] = #{variable_name}" )
|
||||
end
|
||||
result['lpv'] = -0.51427548* (result['sex_value']- 0.508312) + 0.05764604* (result['Age_value'] - 61.894501) + 0.49138819*(result['cal_value'] - 0.334399) rescue 'error'
|
||||
@years = @form_to_show.years
|
||||
result['table'] = '<input id="current_year" type="hidden" value="'+@years[0].to_s+'" index="0"/><p id="cancer_table_texts">'+@form_to_show.table_above_texts[locale].to_s+'</p>'
|
||||
result['table'] += ('<a style="display: inline-block;">'+(locale == 'zh_tw' ? '第' : '')+'</a><a style="display: inline-block;">')
|
||||
|
@ -82,7 +137,16 @@ class CancerpredictsController < ApplicationController
|
|||
result['table'] += '</tr>'
|
||||
end
|
||||
@lpv_calc = [0.9736358,0.9548993,0.9229336]
|
||||
@servive_ratio = ((1-(@lpv_calc[0]**(Math.exp(result['lpv']))))*100).round(2)
|
||||
year = params['data']['year'] rescue nil
|
||||
if year.nil?
|
||||
year = @years.first.to_f
|
||||
else
|
||||
year = year.to_f
|
||||
end
|
||||
year_index = @years.index(year)
|
||||
#@servive_ratio = ((1-(@lpv_calc[0]**(Math.exp(result['lpv']))))*100).round(2) rescue 1
|
||||
@servive_ratio = eval(@form_to_show.years_settings[year_index].gsub('^','**').gsub('exp','Math.exp'))
|
||||
@servive_ratio = ((1 - @servive_ratio) * 100).round(2)
|
||||
@texts = @form_to_show.text_above_texts[locale].to_s.gsub('<br/>','</span><br/><span>').gsub('{{Surgery_only}}','<span class="'+@therapy_names[0]+' Overall_Survival">'+@servive_ratio.round(2).to_s+'</span>')
|
||||
@texts = @texts.split('{{years}}')
|
||||
@texts.delete('')
|
||||
|
@ -144,4 +208,23 @@ class CancerpredictsController < ApplicationController
|
|||
@form_to_show = Cancerpredictfields.where("title"=>@app_title).first
|
||||
end
|
||||
end
|
||||
def read_mapping_file(mapping_file)
|
||||
if mapping_file.class != CancerPredictMappingFile
|
||||
mapping_file = CancerPredictMappingFile.find(mapping_file_id) rescue nil
|
||||
end
|
||||
if !mapping_file.nil?
|
||||
csv_rows = CSV.read(mapping_file.temp_file.file.path)
|
||||
titles = csv_rows[0]
|
||||
infos = {}
|
||||
titles.each_with_index do |title,i|
|
||||
infos[title] = []
|
||||
csv_rows[1..-1].each do |row|
|
||||
infos[title] << row[i].to_f
|
||||
end
|
||||
end
|
||||
return infos
|
||||
else
|
||||
return {}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
# encoding: utf-8
|
||||
class CancerPredictMappingFile
|
||||
require 'carrierwave/processing/mime_types'
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include CarrierWave::MimeTypes
|
||||
mount_uploader :temp_file, HeadImagesUploader
|
||||
|
||||
def file_identifier
|
||||
filename = self.temp_file.file.original_filename rescue ""
|
||||
end
|
||||
end
|
|
@ -6,10 +6,12 @@ class Cancerpredictfields
|
|||
# encoding: utf-8
|
||||
include OrbitTag::Taggable
|
||||
include OrbitCategory::Categorizable
|
||||
FIELDINFO = {"variable"=>"String","name"=>"String","is_num"=>"Fixnum","hint"=>"String","comment_text"=>"String","choice_fields"=>"Array","range"=>"Array","right"=>"Fixnum","is_float"=>"Fixnum","revert_value"=>"Fixnum","map_values"=>"Array","cancer_predict_mapping_file"=>"String"}
|
||||
|
||||
field :title ,type:String ,default:""
|
||||
field :form_show , :type=> Hash ,default:{0=>{:variable=>"sex",:name=>{"zh_tw"=>"性別<br/>(Sex)","en"=>"Sex"},:is_num=>0, :hint=>{'zh_tw'=>'','en'=>''} , :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['男','女'],"en"=>['Male','Female']},:range=>[],:right=>0,:is_float=>0},
|
||||
1=>{:variable=>"age",:name=>{"zh_tw"=>"年齡<br/>(Age)","en"=>"Age"},:is_num=>1, :hint=>{'zh_tw'=>'從 20 歲(含)開始至 98 歲','en'=>'Age must be between 20 and 98'} , :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[20,98],:right=>0,:is_float=>0},
|
||||
2=>{:variable=>"calcification_score",:name=>{"zh_tw"=>"鈣化指數<br/>(Calcification score)","en"=>"Calcification score"},:is_num=>1,:hint=>{'zh_tw'=>'請輸入0到5000的數字','en'=>'Please enter a number between 0 and 5000'}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[0,5000],:right=>0,:is_float=>1}
|
||||
field :form_show , :type=> Hash ,default:{0=>{:variable=>"sex",:name=>{"zh_tw"=>"性別<br/>(Sex)","en"=>"Sex"},:is_num=>0, :hint=>{'zh_tw'=>'','en'=>''} , :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['男','女'],"en"=>['Male','Female']},:range=>[],:right=>0,:is_float=>0,:revert_value=>0,:map_values=>[],:cancer_predict_mapping_file=>""},
|
||||
1=>{:variable=>"age",:name=>{"zh_tw"=>"年齡<br/>(Age)","en"=>"Age"},:is_num=>1, :hint=>{'zh_tw'=>'從 20 歲(含)開始至 98 歲','en'=>'Age must be between 20 and 98'} , :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[20,98],:right=>0,:is_float=>0,:revert_value=>0,:map_values=>[],:cancer_predict_mapping_file=>""},
|
||||
2=>{:variable=>"calcification_score",:name=>{"zh_tw"=>"鈣化指數<br/>(Calcification score)","en"=>"Calcification score"},:is_num=>1,:hint=>{'zh_tw'=>'請輸入0到5000的數字','en'=>'Please enter a number between 0 and 5000'}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[0,5000],:right=>0,:is_float=>1,:revert_value=>0,:map_values=>[],:cancer_predict_mapping_file=>""}
|
||||
}
|
||||
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'=>'適用賀爾蒙受體陽性病人','en'=>'Hormone/ steroid therapy is available when ER status is positive'} , :comment_text=>{'zh_tw'=>'','en'=>''}, :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=>[]},
|
||||
|
@ -30,9 +32,12 @@ class Cancerpredictfields
|
|||
field :extra_texts ,type:Hash ,default:{'zh_tw'=>',此外','en'=>''}
|
||||
field :extra_therapy_texts ,type:Hash ,default:{'zh_tw'=>'100 位在術後有接受{{extra_therapy}}的婦女中,有{{survival_num}}位婦女,術後{{surgery_year}}年仍為存活(多了{{Additional_Benefit}}位)','en'=>'{{survival_num}} out of 100 women treated with {{extra_therapy}} are alive (an extra {{Additional_Benefit}})'}
|
||||
field :danger_texts ,type:Hash ,default:{'zh_tw'=>'請注意紅框的輸入資料是否符合要求!','en'=>'Please check whether input data in red blocks are correct!'}
|
||||
field :years ,type:Array ,default:[0.5,1,1.5]
|
||||
field :years ,type:Array ,default:[1,1.5,2,2.5]
|
||||
field :texts_between_Result_and_result_block ,type:Hash ,default:{'zh_tw'=>'如果欲將預測結果應用於臨床上,請務必與您的主治醫師討論後再做最後決定。','en'=>'Please note that the patients need to consult with their medical doctors before making any decision.'}
|
||||
#field :image_uploader ,type:Object
|
||||
field :prediction_formula , type: String ,default: ""
|
||||
field :years_settings , type: Array , default: ["0.8095037^( exp(A) )","0.729158^( exp(A) )","0.6717211^( exp(A) )","0.6056773^( exp(A) )"]
|
||||
field :mapping_data_from_csv , type: String ,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,472 +1,39 @@
|
|||
<% content_for :page_specific_css do %>
|
||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||
<%= stylesheet_link_tag "lib/fileupload" %>
|
||||
<%= stylesheet_link_tag "lib/main-list" %>
|
||||
<% end %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
|
||||
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
||||
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
||||
<%= javascript_include_tag "lib/file-type" %>
|
||||
<%= javascript_include_tag "lib/module-area" %>
|
||||
<% end %>
|
||||
|
||||
<!-- Input Area -->
|
||||
<div class="input-area">
|
||||
|
||||
<!-- Module Tabs -->
|
||||
<div class="nav-name"><strong><%= t(:module) %></strong></div>
|
||||
<ul class="nav nav-pills module-nav">
|
||||
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li>
|
||||
<li><a href="#status" data-toggle="tab"><%= t(:status) %></a></li>
|
||||
<li><a href="#tag" data-toggle="tab"><%= t(:tags) %></a></li>
|
||||
<li><a href="#imageupload" data-toggle="tab"><%= t(:image) %></a></li>
|
||||
<li><a href="#mail-group" data-toggle="tab"><%= t('announcement.email_reminder')%></a></li>
|
||||
</ul>
|
||||
<!-- Module -->
|
||||
<div class="tab-content module-area">
|
||||
|
||||
<!-- Basic Module -->
|
||||
<div class="tab-pane fade in active" id="basic">
|
||||
|
||||
<!-- Category -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:category) %></label>
|
||||
<div class="controls">
|
||||
<%= select_category(f, @module_app) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Date Time Picker -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:start_date) %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :postdate, :no_label => true, :new_record => @bulletin.new_record?, :data=>{"picker-type" => "range", "range" => "start"} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:end_date) %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :deadline, :no_label => true, :new_record => @bulletin.new_record?, :data=>{"picker-type" => "range", "range" => "end"} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<%= f.label :is_external_link, t("announcement.is_external_link"), :class => "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= f.check_box :is_external_link %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group" style="display: none;" id="external_link_box">
|
||||
<%= f.label :external_link, t("announcement.external_link"), :class => "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= f.text_field :external_link %>
|
||||
<div class="hint"><%= t("announcement.external_link_hint") %></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Status Module -->
|
||||
<div class="tab-pane fade" id="status">
|
||||
|
||||
<!-- Status -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:status) %></label>
|
||||
<div class="controls" data-toggle="buttons-checkbox">
|
||||
<label class="checkbox inline btn <%= 'active' if @bulletin.is_top? || (!@bulletin.top_end_date.nil? && @bulletin.top_end_date > Time.now) %>">
|
||||
<%= f.check_box :is_top %> <%= t(:top) %>
|
||||
</label>
|
||||
<label class="checkbox inline btn <%= 'active' if @bulletin.is_hot? %>">
|
||||
<%= f.check_box :is_hot %> <%= t(:hot) %>
|
||||
</label>
|
||||
<label class="checkbox inline btn <%= 'active' if @bulletin.is_hidden? %>">
|
||||
<%= f.check_box :is_hidden %> <%= t(:hide) %>
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<% if !@bulletin.is_top? && !AnnouncementSetting.check_limit_for_user((@bulletin.new_record? ? current_user.id : @bulletin.create_user_id)) %>
|
||||
<span>Top limit has been reached. The bulletin wont be marked as top even if you click on it.</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group <%= @bulletin.is_top? || (!@bulletin.top_end_date.nil? && @bulletin.top_end_date > Time.now) ? "" : "hide" %>" data-for="is_top">
|
||||
<label for="" class="control-label muted">Top end time</label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :top_end_date, :no_label => true, :new_record => @bulletin.new_record? %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<%# end %>
|
||||
|
||||
<!-- Tag Module -->
|
||||
<div class="tab-pane fade" id="tag">
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:tags) %></label>
|
||||
<%= select_tags(f, @module_app) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Images Module -->
|
||||
<div class="tab-pane fade" id="imageupload">
|
||||
|
||||
<!-- Images Upload -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:image) %></label>
|
||||
<div class="controls">
|
||||
<div class="fileupload fileupload-new clearfix <%= 'fileupload-edit' if @bulletin.image.file %>" data-provides="fileupload">
|
||||
<div class="fileupload-new thumbnail pull-left">
|
||||
<% if @bulletin.image.file %>
|
||||
<%= image_tag @bulletin.image %>
|
||||
<% else %>
|
||||
<img src="http://www.placehold.it/50x50/EFEFEF/AAAAAA" />
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
||||
<span class="btn btn-file">
|
||||
<span class="fileupload-new"><%= t(:select_image) %></span>
|
||||
<span class="fileupload-exists"><%= t(:change) %></span>
|
||||
<%= f.file_field :image %>
|
||||
</span>
|
||||
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
|
||||
<div class="controls" data-toggle="buttons-checkbox">
|
||||
<label class="checkbox inline btn btn-danger fileupload-remove">
|
||||
<%= f.check_box :remove_image %><%= t(:remove) %>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<%= f.fields_for :image_description_translations do |f| %>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for="image_description_<%= locale.to_s %>"><%= t(:description) + " (#{t(locale.to_s)})" %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field locale, value: (@bulletin.image_description_translations[locale.to_s] rescue nil) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Mail Group Module -->
|
||||
<div class="tab-pane fade" id="mail-group">
|
||||
|
||||
<!-- Mail Group -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("announcement.email_to") %></label>
|
||||
<div class="controls">
|
||||
|
||||
<label class="checkbox inline">
|
||||
<%= check_box_tag('bulletin[email_sent]', '1', (!@bulletin.email_sent.blank? ? true : false), :id=>'remind-check') %><%= t('announcement.activate_email_reminder')%>
|
||||
</label>
|
||||
|
||||
<div class="content-box">
|
||||
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'bulletin[email_member_ids][]', email_members: @bulletin.email_members} %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"></label>
|
||||
<div class="controls">
|
||||
<div class="content-box">
|
||||
<span class="help-block"><%= "#{t("announcement.other_mailaddress")}(#{t("announcement.other_mailaddress_note")})"%> </span>
|
||||
<%= f.text_area :other_mailaddress, :class=>"span12", :cols=>"25", :rows=>"10" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-box">
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("announcement.email_sentdate") %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :email_sentdate, :no_label => true %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if (@bulletin.email.is_sent rescue false) %>
|
||||
<div class="content-box">
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("announcement.resend_mail") %></label>
|
||||
<div class="controls">
|
||||
<input type="checkbox" name="resend_mail" value="true">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<tr>
|
||||
<td class="remove_div">❌</td>
|
||||
<td class="sort_div"></td>
|
||||
<% keys.each do |key| %>
|
||||
<% if key.include? "_file" %>
|
||||
<td>
|
||||
<%= render :partial => 'form_file', :object => (CancerPredictMappingFile.where(:id=> property[key]).first rescue nil), :locals => {:f => make_fields, :key=>key} %>
|
||||
</td>
|
||||
<% else %>
|
||||
<% value = property[key] %>
|
||||
<% if property == {} %>
|
||||
<% value_type = Cancerpredictfields::FIELDINFO[key].constantize rescue String %>
|
||||
<% value = "[]" if value_type == Array %>
|
||||
<% else %>
|
||||
<% value_type = value.class %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Language Tabs -->
|
||||
<div class="nav-name"><strong><%= t(:language) %></strong></div>
|
||||
<ul class="nav nav-pills language-nav">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<li class="<%= 'active' if i == 0 %>">
|
||||
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<!-- Language -->
|
||||
<div class="tab-content language-area">
|
||||
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
|
||||
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
|
||||
|
||||
<!-- Title-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t(:title) %></label>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<%= f.text_field locale, class: "input-block-level", placeholder: t(:title), value: (@bulletin.title_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sub Title -->
|
||||
<div class="control-group input-subtitle">
|
||||
<label class="control-label muted"><%= t(:subtitle) %></label>
|
||||
<div class="controls">
|
||||
<div class="textarea">
|
||||
<%= f.fields_for :subtitle_translations do |f| %>
|
||||
<%= f.text_area locale, rows: 2, class: "input-block-level", value: (@bulletin.subtitle_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Content -->
|
||||
<div class="control-group input-content">
|
||||
<label class="control-label muted"><%= t(:content) %></label>
|
||||
<div class="controls">
|
||||
<div class="textarea">
|
||||
<%= f.fields_for :text_translations do |f| %>
|
||||
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@bulletin.text_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
<!-- Link -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:link) %></label>
|
||||
<div class="controls add-input">
|
||||
|
||||
<!-- Exist -->
|
||||
<% if @bulletin && !@bulletin.bulletin_links.blank? %>
|
||||
<div class="exist">
|
||||
<% @bulletin.bulletin_links.each_with_index do |bulletin_link, i| %>
|
||||
<%= f.fields_for :bulletin_links, bulletin_link do |f| %>
|
||||
<%= render :partial => 'form_link', :object => bulletin_link, :locals => {:f => f, :i => i} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Add -->
|
||||
<div class="add-target">
|
||||
</div>
|
||||
<p class="add-btn">
|
||||
<%= hidden_field_tag 'bulletin_link_field_count', @bulletin.bulletin_links.count %>
|
||||
<a id="add_link" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- File -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:file_) %></label>
|
||||
<div class="controls">
|
||||
|
||||
<!-- Exist -->
|
||||
<% if @bulletin && !@bulletin.bulletin_files.blank? %>
|
||||
<div class="exist">
|
||||
<% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %>
|
||||
<%= f.fields_for :bulletin_files, bulletin_file do |f| %>
|
||||
<%= render :partial => 'form_file', :object => bulletin_file, :locals => {:f => f, :i => i} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Add -->
|
||||
<div class="add-target">
|
||||
</div>
|
||||
<p class="add-btn">
|
||||
<%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %>
|
||||
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Form Actions -->
|
||||
<div class="form-actions">
|
||||
<%= get_referer_url[:action] rescue "" %>
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
<input type="hidden" name="referer_url" value="<%= get_referer_url %>">
|
||||
<%= button_tag t("preview"), id: "button_for_preview", name: "commit", class: 'btn', type: :button %>
|
||||
<%= link_to t('cancel'), admin_announcements_path, :class=>"btn" %>
|
||||
</div>
|
||||
|
||||
<span id='show_preview'>
|
||||
<div class="modal hide fade in banner-preview" id="">
|
||||
<div class="modal-header">
|
||||
<a class="close" data-dismiss="modal">×</a>
|
||||
<h3><%= t(:preview) %></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<iframe id="preview-iframe" src=""></iframe>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
<% if !@module_app.tags.empty? %>
|
||||
<script type="text/javascript">
|
||||
$("form.previewable").on("submit", function(){
|
||||
if(!$("input[name='bulletin[tags][]']").is(":checked")){
|
||||
if(!confirm("You have selected no tag, do you wish to continue?")){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<% end %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<script>
|
||||
function Appendzero(obj)
|
||||
{
|
||||
if(obj<10) return "0" +""+ obj;
|
||||
else return obj;
|
||||
}
|
||||
|
||||
$(function() {
|
||||
if (location.pathname.substr(-3)=='new'){
|
||||
var getDate = new Date();
|
||||
var toDay = getDate.getFullYear()+"/"+ (Appendzero(getDate.getMonth()+1))+"/"+Appendzero(getDate.getDate())+" "+Appendzero(getDate.getHours())+":"+Appendzero(getDate.getMinutes());
|
||||
$('input[name="bulletin[postdate]"]').val(toDay);
|
||||
}
|
||||
|
||||
$("#main-wrap").after("");
|
||||
|
||||
$(document).on('click', '#add_link', function(){
|
||||
var new_id = $(this).prev().attr('value');
|
||||
var old_id = new RegExp("new_bulletin_links", "g");
|
||||
var on = $('.language-nav li.active').index();
|
||||
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
|
||||
$(this).prev().attr('value', parseInt(new_id) + 1);
|
||||
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_link', f, :bulletin_links) %>").replace(old_id, new_id));
|
||||
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.tab-content').children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
|
||||
formTip();
|
||||
});
|
||||
$(document).on('click', '#add_file', function(){
|
||||
var new_id = $(this).prev().attr('value');
|
||||
var old_id = new RegExp("new_bulletin_files", "g");
|
||||
var on = $('.language-nav li.active').index();
|
||||
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
|
||||
$(this).prev().attr('value', parseInt(new_id) + 1);
|
||||
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :bulletin_files) %>").replace(old_id, new_id));
|
||||
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
|
||||
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
|
||||
});
|
||||
formTip();
|
||||
});
|
||||
$(document).on('click', '.delete_link', function(){
|
||||
$(this).parents('.input-prepend').remove();
|
||||
});
|
||||
$(document).on('click', '.delete_file', function(){
|
||||
$(this).parents('.input-prepend').remove();
|
||||
});
|
||||
$(document).on('click', '.remove_existing_record', function(){
|
||||
if(confirm("<%= I18n.t(:sure?)%>")){
|
||||
$(this).children('.should_destroy').attr('value', 1);
|
||||
$(this).parents('.start-line').hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('#remind-check').prop('checked') ? '':$('.content-box').addClass('hide')
|
||||
$('#remind-check').on('change', function() {
|
||||
$(this).prop('checked') ? $('.content-box').removeClass('hide'):$('.content-box').addClass('hide')
|
||||
})
|
||||
|
||||
$('#button_for_preview').click(function(){
|
||||
var method = $('.main-forms input[name="_method"]').val();
|
||||
$('.main-forms input[name="_method"]').val("post");
|
||||
|
||||
for ( instance in CKEDITOR.instances )
|
||||
CKEDITOR.instances[instance].updateElement();
|
||||
|
||||
var formData = new FormData( $('.main-forms')[0] );
|
||||
formData.append("preview_type", ( (method==undefined) ? "new" : "edit" ));
|
||||
formData.append("bulletin_id", '<%= @bulletin.id.to_s %>');
|
||||
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: '<%= admin_announcement_preview_path %>',
|
||||
data : formData,
|
||||
processData: false,
|
||||
contentType: false
|
||||
}).done(function(data){
|
||||
if(window.location.protocol === "https:"){
|
||||
data = data.replace("http:","https:");
|
||||
}
|
||||
$('.modal-body iframe').attr('src',data);
|
||||
$('#show_preview .modal').modal();
|
||||
$('#show_preview .modal').height(function() {
|
||||
return $(window).height() * 0.7;
|
||||
});
|
||||
|
||||
var slug = data.split('/')[(data.split('/').length-1)];
|
||||
// $('#preview-iframe').on('load', function(){
|
||||
// $.get('/admin/announcement/destroy_preview/'+slug,function(data){
|
||||
// });
|
||||
// });
|
||||
});
|
||||
$('.main-forms input[name="_method"]').val(method);
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#bulletin_is_top").parent().on("click",function(){
|
||||
setTimeout(function(){
|
||||
if($("#bulletin_is_top").parent().hasClass("active")){
|
||||
$("div[data-for=is_top]").removeClass("hide");
|
||||
}else{
|
||||
$("div[data-for=is_top]").addClass("hide");
|
||||
$("div[data-for=is_top]").find("input[type=text]").val("");
|
||||
}
|
||||
},100)
|
||||
})
|
||||
|
||||
$("#bulletin_is_external_link").on("click",function(){
|
||||
if($(this).is(":checked")){
|
||||
$("#external_link_box").show();
|
||||
}else{
|
||||
$("#external_link_box").hide();
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
</script>
|
||||
<% end %>
|
||||
<% @value= value %>
|
||||
<% if value_type == BSON::Document || value_type == Hash %>
|
||||
<% @disp_value = @value[I18n.locale.to_s] rescue "" %>
|
||||
<%else%>
|
||||
<% @disp_value = @value %>
|
||||
<%end%>
|
||||
<% if value_type == Fixnum %>
|
||||
<% if @value == 1%>
|
||||
<td><%= make_fields.check_box key,{:checked=>true,:class=>"checkbox",:style=>"float:left;"}%></td>
|
||||
<% else%>
|
||||
<td><%= make_fields.check_box key,{:checked=>false,:class=>"checkbox",:style=>"float:left;"}%></td>
|
||||
<%end%>
|
||||
<% elsif value_type == BSON::Document || value_type == Hash %>
|
||||
<%=make_fields.fields_for I18n.locale.to_s do |locale_fields|%>
|
||||
<td><%= locale_fields.text_field key,{:value=>@disp_value}%></td>
|
||||
<%end%>
|
||||
<% else %>
|
||||
<td><%= make_fields.text_field key,{:value=>@disp_value}%></td>
|
||||
<%end%>
|
||||
<%end%>
|
||||
<%end%>
|
||||
<td><%= make_fields.hidden_field :old_num,:value=>num.to_s %></td>
|
||||
</tr>
|
|
@ -1,69 +1,33 @@
|
|||
<% if form_file.new_record? %>
|
||||
<% if form_file.nil? %>
|
||||
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
|
||||
<% else %>
|
||||
<div class="fileupload fileupload-exist start-line" data-provides="fileupload">
|
||||
<% if form_file.file.blank? %>
|
||||
<% if form_file.temp_file.blank? %>
|
||||
<%= t(:no_file) %>
|
||||
<% else %>
|
||||
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
|
||||
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.temp_file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= f.fields_for key do |f|%>
|
||||
<div class="input-prepend input-append">
|
||||
<label>
|
||||
<span class="add-on btn btn-file" title='<%= t(:file_) %>'>
|
||||
<i class="icons-paperclip"></i>
|
||||
<%= f.file_field :file %>
|
||||
<%= f.file_field :temp_file %>
|
||||
</span>
|
||||
<div class="uneditable-input input-medium">
|
||||
<i class="icon-file fileupload-exists"></i>
|
||||
<span class="fileupload-preview"><%= (form_file.new_record? || form_file.file.blank?) ? t(:select_file) : t(:change_file) %></span>
|
||||
<span class="fileupload-preview"><%= (form_file.nil? || form_file.temp_file.blank?) ? t(:select_file) : t(:change_file) %></span>
|
||||
</div>
|
||||
</label>
|
||||
<span class="add-on icons-pencil" title='<%= t(:alternative) %>'></span>
|
||||
<span class="tab-content">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_file.title_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
</span>
|
||||
<span class="add-on icons-pencil" title='<%= t(:description) %>'></span>
|
||||
<span class="tab-content">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
|
||||
<%= f.fields_for :description_translations do |f| %>
|
||||
<%= f.text_field locale, :class => "input-medium", placeholder: t(:description), :value => (form_file.description_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
</span>
|
||||
</span>
|
||||
<span class="add-on btn-group btn" title="<%= t('archive.show_lang') %>">
|
||||
<i class="icons-earth"></i> <span class="caret"></span>
|
||||
<ul class="dropdown-menu">
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<li>
|
||||
<label class="checkbox">
|
||||
<%= check_box_tag "bulletin[bulletin_files_attributes][#{( form_file.new_record? ? 'new_bulletin_files' : "#{i}" )}][choose_lang][]", locale, form_file.choose_lang.include?(locale.to_s) %>
|
||||
<%= t(locale.to_s) %>
|
||||
</label>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<%= hidden_field_tag 'bulletin[bulletin_files_attributes][0][choose_lang][]', '' %>
|
||||
</span>
|
||||
<% if form_file.new_record? %>
|
||||
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
|
||||
<a class="icon-trash"></a>
|
||||
</span>
|
||||
<% else %>
|
||||
<% if !form_file.nil? %>
|
||||
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
|
||||
<%= f.hidden_field :id %>
|
||||
<%= f.hidden_field :id,:value=>(form_file.id) %>
|
||||
<a class="icon-remove"></a>
|
||||
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
|
@ -1,5 +1,32 @@
|
|||
<%= stylesheet_link_tag "lib/fileupload"%>
|
||||
<%= javascript_include_tag 'lib/bootstrap-fileupload' %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
|
||||
<%#= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
||||
<%#= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
||||
<%= javascript_include_tag "lib/file-type" %>
|
||||
<%= javascript_include_tag "lib/module-area" %>
|
||||
<%= javascript_include_tag "form" %>
|
||||
<% end %>
|
||||
|
||||
<style type="text/css">
|
||||
.sort_div:before{
|
||||
content: "\e096";
|
||||
font-family: 'entypo';
|
||||
cursor: pointer;
|
||||
}
|
||||
.sort_div{
|
||||
padding: 1em;
|
||||
}
|
||||
.sort_table tbody td:last-child{
|
||||
display: none;
|
||||
}
|
||||
.remove_div{
|
||||
cursor: pointer;
|
||||
}
|
||||
.remove_div:hover{
|
||||
font-size: 1.3em;
|
||||
}
|
||||
</style>
|
||||
<div style="clear:both;"></div>
|
||||
<%=form_for @form_to_show ,:url=>{:controller=>"cancerpredicts" ,:action=>"edit"} do |form|%>
|
||||
<span class="show_span"><%= t('cancerpredict.title') %></span>
|
||||
|
@ -156,11 +183,15 @@
|
|||
<%end%>
|
||||
<span class="show_span"><%= t('cancerpredict.Input_fields') %></span>
|
||||
<div style="clear:both;"></div>
|
||||
<table>
|
||||
<table id="fields_table" class="sort_table">
|
||||
<% keys = @form_to_show.form_show.values[0].keys rescue [] %>
|
||||
<% keys = Cancerpredictfields::FIELDINFO.keys if keys.blank? %>
|
||||
<thead>
|
||||
<tr>
|
||||
<% @form_to_show.form_show.values[1].each do |key,vlaue|%>
|
||||
<th><%=key%></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<% keys.each do |key|%>
|
||||
<th><%=t("cancerpredict.table.#{key}")%></th>
|
||||
<%end%>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -168,34 +199,14 @@
|
|||
<%= form.fields_for :form_show do |formfield|%>
|
||||
<% @form_to_show.form_show.each do |num,property| %>
|
||||
<%=formfield.fields_for num.to_s do |make_fields|%>
|
||||
<tr>
|
||||
<% property.each do |key,value|%>
|
||||
<% @value= value %>
|
||||
<% if @value.class == BSON::Document || @value.class == Hash %>
|
||||
<% @disp_value = @value[I18n.locale.to_s] rescue "" %>
|
||||
<%else%>
|
||||
<% @disp_value = @value %>
|
||||
<%end%>
|
||||
<% if @value.class == Fixnum %>
|
||||
<% if @value == 1%>
|
||||
<td><%= make_fields.check_box key,{:checked=>true,:class=>"checkbox",:style=>"float:left;"}%></td>
|
||||
<% else%>
|
||||
<td><%= make_fields.check_box key,{:checked=>false,:class=>"checkbox",:style=>"float:left;"}%></td>
|
||||
<%end%>
|
||||
<% elsif @value.class == BSON::Document || @value.class == Hash %>
|
||||
<%=make_fields.fields_for I18n.locale.to_s do |locale_fields|%>
|
||||
<td><%= locale_fields.text_field key,{:value=>@disp_value}%></td>
|
||||
<%end%>
|
||||
<% else %>
|
||||
<td><%= make_fields.text_field key,{:value=>@disp_value}%></td>
|
||||
<%end%>
|
||||
<%end%>
|
||||
</tr>
|
||||
<%= render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>property,:num=>num,:keys => keys} %>
|
||||
<%end%>
|
||||
<%end%>
|
||||
<%end%>
|
||||
</tbody>
|
||||
</table>
|
||||
<button id="add_field" type="button" class="btn btn-primary"><%= t('cancerpredict.table.add_field') %></button>
|
||||
<div style="clear:both;"></div>
|
||||
<span class="show_span"><%=t('cancerpredict.table.Results')%></span>
|
||||
<div style="clear:both;"></div>
|
||||
<label for="form_result_is_right" style="float: left;"><%= t('cancerpredict.result_is_right') %></label>
|
||||
|
@ -217,21 +228,31 @@
|
|||
<% end %>
|
||||
<div style="clear:both;"></div>
|
||||
<% end %>
|
||||
<% if (!@form_to_show.form_show_in_result.blank? rescue false) %>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<% @form_to_show.form_show_in_result.values[1].each do |key,vlaue|%>
|
||||
<th><%=key%></th>
|
||||
<table id="therapies_table" class="sort_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<% keys = @form_to_show.form_show_in_result.values[0].keys rescue [] %>
|
||||
<% keys = Cancerpredictfields::FIELDINFO.keys if keys.blank? %>
|
||||
<% keys.each do |key,vlaue|%>
|
||||
<th><%=t("cancerpredict.table.#{key}")%></th>
|
||||
<%end%>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%= form.fields_for :form_show_in_result do |formfield|%>
|
||||
<% @form_to_show.form_show_in_result.each do |num,property| %>
|
||||
<%=formfield.fields_for num.to_s do |make_fields|%>
|
||||
<tr>
|
||||
<% property.each do |key,value|%>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%= form.fields_for :form_show_in_result do |formfield|%>
|
||||
<% @form_to_show.form_show_in_result.each do |num,property| %>
|
||||
<%=formfield.fields_for num.to_s do |make_fields|%>
|
||||
<tr>
|
||||
<td class="remove_div">❌</td>
|
||||
<td class="sort_div"></td>
|
||||
<% property.each do |key,value|%>
|
||||
<% if key.include? "_file" %>
|
||||
<td>
|
||||
<%= render :partial => 'form_file', :object => (CancerPredictMappingFile.where(:id=> property[key]).first rescue nil), :locals => {:f => make_fields, :key=>key} %>
|
||||
</td>
|
||||
<% else %>
|
||||
<% @value= value %>
|
||||
<% if @value.class == BSON::Document || @value.class == Hash %>
|
||||
<% @disp_value = @value[I18n.locale.to_s] rescue "" %>
|
||||
|
@ -252,13 +273,39 @@
|
|||
<td><%= make_fields.text_field key,{:value=>@disp_value}%></td>
|
||||
<%end%>
|
||||
<%end%>
|
||||
</tr>
|
||||
<%end%>
|
||||
<td><%= make_fields.hidden_field :old_num,:value=>num.to_s %></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
<%end%>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
<%end%>
|
||||
</tbody>
|
||||
</table>
|
||||
<button id="add_therapy" type="button" class="btn btn-primary"><%= t('cancerpredict.table.add_therapy') %></button>
|
||||
<div style="clear:both;"></div>
|
||||
<span class="show_span"><%=t('cancerpredict.table.calculate_settings')%></span>
|
||||
<div style="clear:both;"></div>
|
||||
<div class="control-group">
|
||||
<div class="control-label" style="float: left;margin-right: 1em;width: 11em;">
|
||||
<label><%= t('cancerpredict.table.prediction_formula') %></label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<%= form.text_area :prediction_formula, :rows=>"5", :style=> 'width: calc(100% - 12em);' %>
|
||||
</div>
|
||||
</div>
|
||||
<div id="years_settings">
|
||||
<% years = @form_to_show.years %>
|
||||
<% years.each_with_index do |year,i| %>
|
||||
<div data-year="<%= year.to_s.strip %>">
|
||||
<div class="control-label" style="float: left;margin-right: 1em;width: 11em;">
|
||||
<label>P(t=<%=year%>) <%=year%> Year</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<textarea name="<%= form.object_name %>[years_settings][]" style= "width: calc(100% - 12em);" value="<%= @form_to_show.years_settings[i] rescue '' %>"><%= @form_to_show.years_settings[i] rescue '' %></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<%=form.submit "#{t(:updatefont)}",{:id=>"updatebtn"}%>
|
||||
<%end%>
|
||||
<link href="/assets/admin/cancerpredict.css" media="screen" rel="stylesheet">
|
||||
|
@ -267,4 +314,115 @@
|
|||
$('.text_choice').prop('checked' , false);
|
||||
$(this).prop('checked' , true);
|
||||
});
|
||||
$("#add_field").click(function(){
|
||||
var index = $("#fields_table tbody tr").length.toString();
|
||||
<%= fields_for :cancerpredictfields do |form|%>
|
||||
<%= form.fields_for :form_show do |formfield|%>
|
||||
<%=formfield.fields_for :new_index do |make_fields|%>
|
||||
<% keys = @form_to_show.form_show.values[0].keys rescue [] %>
|
||||
<% keys = Cancerpredictfields::FIELDINFO.keys if keys.blank? %>
|
||||
var html = "<%= "#{render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>{},:num=>'',:keys => keys}}".gsub(/(\r\n|\n)/,"").gsub("\"","\\\"").html_safe %>";
|
||||
$("#fields_table tbody").append(html.replaceAll('new_index',index));
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
$(".remove_div").off("click").on("click",function(){
|
||||
$el = $(this).parent().siblings("tr").not($(this)).eq(0);
|
||||
$(this).parent().remove();
|
||||
update_key($el);
|
||||
})
|
||||
})
|
||||
$("#add_therapy").click(function(){
|
||||
var index = $("#therapies_table tbody tr").length.toString();
|
||||
<%= fields_for :cancerpredictfields do |form|%>
|
||||
<%= form.fields_for :form_show_in_result do |formfield|%>
|
||||
<%=formfield.fields_for :new_index do |make_fields|%>
|
||||
<% keys = @form_to_show.form_show_in_result.values[0].keys rescue [] %>
|
||||
<% keys = Cancerpredictfields::FIELDINFO.keys if keys.blank? %>
|
||||
var html = "<%= "#{render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>{},:num=>'',:keys => keys}}".gsub(/(\r\n|\n)/,"").gsub("\"","\\\"").html_safe %>";
|
||||
$("#therapies_table tbody").append(html.replaceAll('new_index',index));
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
$(".remove_div").off("click").on("click",function(){
|
||||
$el = $(this).parent().siblings("tr").not($(this)).eq(0);
|
||||
$(this).parent().remove();
|
||||
update_key($el);
|
||||
})
|
||||
})
|
||||
function update_key(ele){
|
||||
console.log($(ele))
|
||||
var ui_child=$(ele).parent().find('> tr');
|
||||
console.log(ui_child);
|
||||
for (var i=0;i<ui_child.length;i++){
|
||||
var now_ele = ui_child.eq(i);
|
||||
var $inputs = now_ele.find('input');
|
||||
$inputs.each(function(input_index,input){
|
||||
var name = input.name;
|
||||
name = $.map(name.split(/(\[|\])/),function(v,ii){
|
||||
var vv = v;
|
||||
var num = Number.parseInt(vv);
|
||||
if(!Number.isNaN(num)){
|
||||
vv = i.toString();
|
||||
}
|
||||
return vv;
|
||||
}).join("");
|
||||
console.log(name)
|
||||
input.name = name;
|
||||
})
|
||||
}
|
||||
}
|
||||
$( ".sort_table > tbody" ).sortable({
|
||||
axis: "y",
|
||||
revert: true,
|
||||
placeholder: "sortable-placeholder",
|
||||
handle: ".sort_div",
|
||||
update: function(event, ui) {
|
||||
update_key($(ui.item[0]))
|
||||
}
|
||||
});
|
||||
$(".remove_div").click(function(){
|
||||
$el = $(this).parent().siblings("tr").not($(this)).eq(0);
|
||||
$(this).parent().remove();
|
||||
update_key($el);
|
||||
})
|
||||
$(".remove_existing_record").click(function(){
|
||||
if(window.confirm("Are you sure want to remove this file?")){
|
||||
$(this).find(".should_destroy").val("1");
|
||||
$(this).parent().siblings(".file-link").remove();
|
||||
}
|
||||
})
|
||||
$("#years").on('blur',function(){
|
||||
var years = [];
|
||||
try{
|
||||
years = $(this).val().split(/\[|,|\]/).filter(function(aa){return aa !="" && aa != undefined}).map(function(aa){return aa.trim()});
|
||||
}catch(e){};
|
||||
var index = 0;
|
||||
years.forEach(function(year){
|
||||
if($("#years_settings [data-year='"+year+"']").length == 0){
|
||||
var year_text = ('<div data-year="'+year+'">'+
|
||||
'<div class="control-label" style="float: left;margin-right: 1em;width: 11em;">'+
|
||||
'<label> P(t='+year+') '+year+' Year</label>'+
|
||||
'</div>'+
|
||||
'<div class="controls">'+
|
||||
'<textarea name="cancerpredictfields[years_settings][]" style= "width: calc(100% - 12em);"></textarea>'+
|
||||
'</div>'+
|
||||
'</div>');
|
||||
if(index != 0){
|
||||
$("#years_settings [data-year='"+years[index - 1]+"']").after(year_text);
|
||||
}else{
|
||||
$("#years_settings").html(year_text+$("#years_settings").html());
|
||||
}
|
||||
}
|
||||
index++;
|
||||
})
|
||||
var all_years = $("#years_settings [data-year]").map(function(i,aa){return $(aa).attr("data-year").toString().trim() }).toArray();
|
||||
all_years.forEach(function(a_year){
|
||||
if(years.indexOf(a_year) == -1){
|
||||
$("#years_settings [data-year='"+a_year+"']").remove()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
</script>
|
|
@ -0,0 +1,926 @@
|
|||
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<arguments.length;i++){
|
||||
if(Array.isArray(arguments[i])){
|
||||
for(var j=0;j<arguments.length;j++){
|
||||
var index = result_array.indexOf(arguments[i][j]);
|
||||
if(index == -1)
|
||||
continue;
|
||||
else{
|
||||
result_array = result_array.slice(0, index).concat(result_array.slice(index + 1, result_array.length));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
var index = result_array.indexOf(arguments[i]);
|
||||
if(index == -1)
|
||||
continue;
|
||||
else{
|
||||
result_array = result_array.slice(0, index).concat(result_array.slice(index + 1, result_array.length));
|
||||
};
|
||||
};
|
||||
};
|
||||
result_array.push = this.push;
|
||||
result_array.remove_item_from_array = this.remove_item_from_array;
|
||||
return result_array;
|
||||
};
|
||||
$('input#lymph_nodes_examined').data('range_new' , $('input#lymph_nodes_examined').data('range'));
|
||||
$('input#lymph_nodes_positive').data('range_new' , $('input#lymph_nodes_positive').data('range'));
|
||||
$('.num_only').on('input', function() {
|
||||
$(this).siblings('.num_only_value').val($(this).val());
|
||||
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();
|
||||
};
|
||||
};
|
||||
});
|
||||
$('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("<div class='modal-dialog'><div class='modal-content'><div class='modal-header'><button type='button' aria-hidden='true' class='close'>×</button><h4 class='modal-title'>"+modal_head+"</h4>"+
|
||||
"</div><div class='modal-body'>"+modal_body+"</div><div class='modal-footer'><button type='button' class='btn btn-default'>Close</button></div></div></div>")
|
||||
$('#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('<a id="danger_texts" style="color:red;">'+data['danger_texts']+'</a>') : 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<add_choices.length;i++){
|
||||
add_choices_transform.push($('[for="'+add_choices[i]+'"]').html())
|
||||
};
|
||||
var add_choices_str = (I18n.locale == 'en' ? add_choices_transform.slice(0,add_choices_transform.length-1).join(', ') : add_choices_transform.slice(0,add_choices_transform.length-1).join('、'));
|
||||
if(add_choices_transform.length >= 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}}','</span><span class="'+arguments[0]+' choices">'+add_choices_str+'</span><span>');
|
||||
extra_therapy_texts = extra_therapy_texts.replace('{{survival_num}}','</span><span class="'+arguments[0]+' Overall_Survival">'+Math.round(servive_ratio)+'</span><span>');
|
||||
extra_therapy_texts = extra_therapy_texts.replace('{{surgery_year}}','</span><span class="surgery_year">'+year+'</span><span>');
|
||||
extra_therapy_texts = extra_therapy_texts.replace('{{Additional_Benefit}}','</span><span class="'+arguments[0]+' Additional_Benefit">'+Math.round(benefit)+'</span><span>');
|
||||
var new_text = '<p class="texts_show"><span>';
|
||||
new_text += (extra_therapy_texts+'</span></p>');
|
||||
$('#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<add_choices.length;j++){
|
||||
add_choices_transform.push($('[for="'+add_choices[j]+'"]').html())
|
||||
};
|
||||
var add_choices_str = (I18n.locale == 'en' ? add_choices_transform.slice(0,add_choices_transform.length-1).join(', ') : add_choices_transform.slice(0,add_choices_transform.length-1).join('、'));
|
||||
if(add_choices_transform.length >= 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;i<treatmeny_method.length;i++){
|
||||
lpv_dict[treatmeny_method[i]] = lpv[i];
|
||||
var click_flag=false;
|
||||
$('#'+treatmeny_method[i]+' .cancer_table_btn').eq(1).off('click');
|
||||
$('#'+treatmeny_method[i]+' .cancer_table_btn').eq(1).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.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<obj.active_treatment.length;i++){
|
||||
var servive_ratio = round((1-(calculate_servive_ratio(obj.year,obj.lpv_real[i])))*100,2);
|
||||
var benefit = servive_ratio - obj.servive_ratio_arr[obj.servive_ratio_arr.length-1];
|
||||
obj.servive_ratio_arr.push(servive_ratio);
|
||||
$('tr.'+obj.active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%');
|
||||
$('.'+obj.active_treatment[i]+'.Overall_Survival').html(servive_ratio);
|
||||
if(i != 0){
|
||||
$('tr.'+obj.active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%');
|
||||
$('.'+obj.active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit));
|
||||
}
|
||||
}
|
||||
//$('.'+obj.active_treatment[0]+'.Overall_Survival').html(Math.round(obj.servive_ratio_arr[0]));
|
||||
};
|
||||
|
||||
function calculate_servive_ratio(year,obj){
|
||||
var servive_ratio;
|
||||
console.log(obj);
|
||||
var A = obj['A'];
|
||||
switch(year) {
|
||||
case '1':
|
||||
servive_ratio = 0.8095037**( Math.exp(A) );
|
||||
break;
|
||||
|
||||
case '1.5':
|
||||
servive_ratio = 0.729158**( Math.exp(A) );
|
||||
break;
|
||||
|
||||
case '2':
|
||||
servive_ratio = 0.6717211**( Math.exp(A) );
|
||||
break;
|
||||
|
||||
case '2.5':
|
||||
servive_ratio = 0.6056773**( Math.exp(A) );
|
||||
break;
|
||||
|
||||
default:
|
||||
console.log('not found year.');
|
||||
}
|
||||
return servive_ratio;
|
||||
}
|
||||
/* auto add end */
|
||||
function submit_fcn(){
|
||||
var post_json = get_input_data();
|
||||
if(post_json != null){
|
||||
post_json['locale'] = I18n.locale;
|
||||
var result = $.post("/cancerpredictResult",{"data":post_json});
|
||||
result.done(function(){
|
||||
console.log(result.responseJSON);
|
||||
set_result(result);
|
||||
window.location.hash = '';
|
||||
window.location.hash = '#cancer_predict_result_block';
|
||||
});
|
||||
};
|
||||
};
|
||||
$('#cancer_table_submit').click(function(){
|
||||
submit_fcn();
|
||||
});
|
||||
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_tab').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
$('.result_content').css('display','none');
|
||||
$('.result_content[index="'+index+'"]').css('display','block');
|
||||
})
|
||||
$('.num_only').keypress(function(event){
|
||||
return event.keyCode>=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%');
|
||||
};
|
||||
};
|
||||
});
|
|
@ -57,4 +57,21 @@ zh_tw:
|
|||
table: 列表
|
||||
curve: 曲線
|
||||
text: 文字
|
||||
Therapy_choice: 治療選項
|
||||
Therapy_choice: 治療選項
|
||||
variable: 變數名稱
|
||||
name: 名稱
|
||||
is_num: 數字欄位
|
||||
hint: 提示文字
|
||||
comment_text: 說明文字
|
||||
choice_fields: '選項設定([]代表無選項)'
|
||||
range: '數字範圍設定([]代表無範圍限制)'
|
||||
right: 顯示在右側
|
||||
is_float: 可輸入小數
|
||||
revert_value: 預設值從大到小(ex:有兩個選項,則選項值依序為1和0)
|
||||
map_values: 選項對應到的值(若無,則會使用預設值)
|
||||
cancer_predict_mapping_file: 欄位對應檔案
|
||||
calculate_settings: 計算設定
|
||||
prediction_formula: 預測公式
|
||||
add_field: 新增填寫欄位
|
||||
add_therapy: 新增治療選項
|
||||
|
||||
|
|
Loading…
Reference in New Issue