copy from final_version branch to master

This commit is contained in:
BOHUNG 2020-01-13 19:35:30 +08:00
parent 34b4187716
commit 294d98f83f
28 changed files with 2944 additions and 596 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 992 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,828 @@
$(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%');
};
};
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'])
});
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] = $('#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(-1).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(-1).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']];
var lpv_dict={}
var lpv_calc={1:-0.001476145,3:-0.01261639,5:-0.02519608}
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]];
lpv_real.push(lpv_current);
var servive_ratio = Math.round((Math.exp(lpv_calc[year])**Math.exp(lpv_current))*100);
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(benefit+'%');
$('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">'+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">'+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++){
lpv_real[i] -= lpv_dict[arguments[0]];
var servive_ratio = Math.round((Math.exp(lpv_calc[year])**Math.exp(lpv_real[i]))*100);
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(servive_ratio);
$('tr.'+active_treatment[i]+' td.Additional_Benefit').html(benefit+'%');
$('.'+active_treatment[i]+'.Additional_Benefit').html(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 = add_choices_transform.slice(0,add_choices_transform.length-1).join('、');
if(add_choices_transform.length >= 2)
add_choices_str += ('以及'+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');
$('a.'+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');
};
return Array.prototype.remove_item_from_array.apply(this, arguments);
}else{
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 calculate_and_change_result_value(obj){
obj.servive_ratio_arr = [];
for(var i = 0;i<obj.active_treatment.length;i++){
var servive_ratio = Math.round((Math.exp(obj.lpv_calc[obj.year])**Math.exp(obj.lpv_real[i]))*100);
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(benefit+'%');
$('.'+obj.active_treatment[i]+'.Additional_Benefit').html(benefit);
}
}
$('.'+obj.active_treatment[0]+'.Overall_Survival').html(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 old_lpv = obj.lpv_real[0];
obj.lpv_real = obj.lpv_real.map(original_value=>(original_value+new_lpv-old_lpv));
calculate_and_change_result_value(obj);
};
};
function calculate_first_lpv(result_json){
result = {}
result['age1'] = Math.pow((Number(result_json['age'])/100),0.5);
result['age2'] = Math.pow((Number(result_json['age'])/100),0.5)*Math.log(result_json['age']/100);
result['size1'] = Math.log(Number(result_json['size'])/10);
if(Number(result_json['lymph_nodes_examined']) != 0)
try{result['ratio'] = Number(result_json['lymph_nodes_positive'])/Number(result_json['lymph_nodes_examined'])}catch(e){result['ratio'] = 0}
else
result['ratio'] = 0
if(result['ratio'] > 1)
result['ratio'] = 1
result['nposit'] = Math.pow(((Number(result['ratio'])+0.1)/0.1),0.5);
var T = '';
if(Number(result_json['tumor_direct_extension']) != 1){
if(Number(result_json['size']) <= 20)
T = 'T1';
else if(Number(result_json['size']) > 20 && Number(result_json['size']) <= 50)
T = 'T2';
else if(Number(result_json['size']) > 50)
T = 'T3';
}else{
T = 'T4';
};
var N = '';
if(Number(result_json['lymph_nodes_positive']) == 0)
N = 'N0';
else if(Number(result_json['lymph_nodes_positive']) >= 1 && Number(result_json['lymph_nodes_positive']) <= 3 && Number(result_json['micrometastasis']) != 1)
N = 'N1';
else if(Number(result_json['lymph_nodes_positive']) >= 1 && Number(result_json['lymph_nodes_positive']) <= 3 && Number(result_json['micrometastasis']) == 1)
N = 'N1mi';
else if(Number(result_json['lymph_nodes_positive']) >= 4 && Number(result_json['lymph_nodes_positive']) <= 9)
N = 'N2';
else if(Number(result_json['lymph_nodes_positive']) >= 10)
N = 'N3';
M = '';
if(Number(result_json['Distant_Metastasis']) != 1)
M = 'M0';
else
M = 'M1';
if(Number(M == 'M0'))
if(T == 'T1' && (N == 'N0' || N == 'N1mi'))
result['pstage'] = 1;
else if(((T == 'T2' || T == 'T3') && (N == 'N0')) || ((T == 'T1' || T == 'T2') && (N == 'N1')))
result['pstage'] = 2;
else if((T == 'T4' && N == 'N0') || ((T == 'T3' || T == 'T4') && N == 'N1') || (N == 'N2' || N == 'N3'))
result['pstage'] = 3;
else
result['pstage'] = 4
if((Number(result_json['ER_status']) != 2 || Number(result_json['PR_status']) != 2) && (Number(result_json['HER2_status']) != 1))
result['subtype'] = 1;
else if(Number(result_json['ER_status']) == 2 && Number(result_json['PR_status']) == 2 && (Number(result_json['HER2_status']) == 1))
result['subtype'] = 2;
else if(Number(result_json['ER_status']) == 2 && Number(result_json['PR_status']) == 2 && (Number(result_json['HER2_status']) != 1))
result['subtype'] = 3;
if( Number(result_json['grade']) == 2 || Number(result_json['grade']) == 4)
result['grade_2'] = 1;
else
result['grade_2'] = 0;
if( Number(result_json['grade']) == 3)
result['grade_3'] = 1;
else
result['grade_3'] = 0;
if( Number(result['subtype']) == 2)
result['subtype_HER2'] = 1;
else
result['subtype_HER2'] = 0;
if( Number(result['subtype']) == 3)
result['subtype_triple'] = 1;
else
result['subtype_triple'] = 0;
if( Number(result['pstage']) == 2)
result['pstage_2'] = 1;
else
result['pstage_2'] = 0;
if( Number(result['pstage']) == 3)
result['pstage_3'] = 1;
else
result['pstage_3'] = 0;
if( Number(result['pstage']) == 4)
result['pstage_4'] = 1;
else
result['pstage_4'] = 0;
if( Number(result_json['lvi']) == 1)
result['lvi_yes'] = 1;
else
result['lvi_yes'] = 0;
try{
result['lpv'] = ((result['age1']-0.7276655)*(-10.87)+(result['age2']+0.4540707)*8.968+(result['size1']-0.643632)*0.7678+(result['nposit']-1.346932)*0.5339+
result['grade_2']*0.4795+result['grade_3']*0.818+result['subtype_HER2']*0.1806+result['subtype_triple']*0.6457+result['pstage_2']*0.5311+
result['pstage_3']*1.134+result['pstage_4']*2.172+result['lvi_yes']*0.3321-0.04);
}catch(e){result['lpv'] = "error"};
return result;
};
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%');
};
};
});

View File

@ -9,7 +9,6 @@ if (typeof Math.imul == "undefined" || (Math.imul(0xffffffff, 5) == 0)) {
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0) | 0);
}
}
/**
* React v15.3.1
*
@ -3105,7 +3104,7 @@ if (typeof Math.imul == "undefined" || (Math.imul(0xffffffff, 5) == 0)) {
null), React.createElement("p", null, "Which ", React.createElement("strong", null, "result tab"), " should appear first?"), Y(OQ(NB))), React.createElement("div", { className: "modal-footer" }, React.createElement("button", { type: "button", onClick: function () { return $("#settingsModal").modal("hide") }, className: "btn btn-default" }, "Close")))))
}, new R(null, 1, 5, S, [aH], null), "settings-modal"); var $W = QG(function () { return Y(p(bH(FQ)) ? function () { sU("tool-postamble"); return new R(null, 4, 5, S, [gB, new m(null, 4, [ps, "button", nu, function () { return zQ.ma(null, "print") }, lC, function (a) { return B.h("Enter", a.nativeEvent.code) ? zQ.ma(null, "print") : null }, Ru, ni([Bn, Do, cp, dr, Fr, xt, $t, Gx, jy, xz, Uz], ["#ffffff", 16, 300, "#444466", 70, 10, 10, .5, "0.9375em 5px 0.9375em 5px", -1, "fixed"])], null), function () { var a = new m(null, 1, [Qm, DF], null); return XQ.h ? XQ.h(a, "print") : XQ.call(null, a, "print") }(), " Print"], null) }() : null) }, new R(null,
1, 5, S, [aH], null), "results-footer"),is_submit={flag: true , submit_func: function(){var a = bH(FQ);return (cc(E(a)) || null == a)}} , aX = QG(function () {
var a = bH(FQ); console.log(cc(E(a)) || null == a);return is_submit.flag ? React.createElement("div", { className: "row" }, React.createElement("div", { className: "col-sm-10 col-sm-offset-1 col-xs-12" }, React.createElement("div", { style: { backgroundColor: "#d3e7fd", padding: "0.625em 0.625em 3px 0.625em", marginBottom: 20 } }, React.createElement("div", { style: { color: "#002e5d", fontSize: "1.25em" } }, React.createElement("p", { style: { paddingBottom: 0 } }, Y(function () {
var a = bH(FQ); /*important it's result*/return cc(E(a)) || null == a ? React.createElement("div", { className: "row" }, React.createElement("div", { className: "col-sm-10 col-sm-offset-1 col-xs-12" }, React.createElement("div", { style: { backgroundColor: "#d3e7fd", padding: "0.625em 0.625em 3px 0.625em", marginBottom: 20 } }, React.createElement("div", { style: { color: "#002e5d", fontSize: "1.25em" } }, React.createElement("p", { style: { paddingBottom: 0 } }, Y(function () {
var a = new m(null, 2, [Qm, DF, Ru, new m(null, 2, [Do, 35, iu, 8],
null)], null); return XQ.h ? XQ.h(a, "info-circle") : XQ.call(null, a, "info-circle")
}()), " Treatment options and results will appear here when you have filled in all the information needed above."))))) : React.createElement("div", null, React.createElement("div", { className: "row" }, React.createElement("div", { className: "col-md-6 clearfix" }, React.createElement("h3", null, "Treatment Options"), Y(VW.l ? VW.l() : VW.call(null))), function () {

View File

@ -2,6 +2,54 @@
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/
.table .expired{
color: #BE2E2E;
thead > tr > th{
border:1px solid;
background: bisque;
}
tbody{
background:white;
}
tbody > tr > td{
border:1px solid;
position: relative;
}
.show_li,.show_li *{
list-style:none;
color:balck;
}
.show_li ul{
display:none;
}
#clicktosee{
color:blue;
cursor:pointer;
}
table .checkbox{
left: 50%;
position: absolute;
transform: translate(-50%, -50%) !important;
top: 50%;
}
#updatebtn{
margin-top: 1em;
right: 1em;
background-color: #0088cc;
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
}
.show_span{
margin: 1em;
float: left;
background-color: rgb(210, 105, 0);
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
width: fit-content;
}
.label_left{
float: left;
padding-right: 0.5em;
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,384 @@
#cancer_table *[data-key]{
padding: 0.375em 0;
display: inline-block;
width: 100%;
}
.head_logo{
height: 4em;
}
@media screen and (max-width: 48em){
.navbar-brand{
width: 100%;
}
}
div.num_group{
position: relative;
float: left;
width: 4.125em;
height: 2.25em;
}
@media screen and (min-width: 93.75em){
.navbar-brand>img.head_logo{
width: 50%;
height: auto;
}
}
@media screen and (min-width: 48.125em) and (max-width: 93.625em){
.navbar-brand>img.head_logo{
width: 70%;
height: auto;
}
}
.header-nav{
top:0 !important;
}
.title_texts{
color:rgb(210, 106, 2);
display:none;
}
.cencer_table_name{
display: inline-block;
vertical-align: middle;
color:#5d7ca2;
}
@media screen and (min-width: 71.125em){
#cancer_table .cencer_table_name{
width: 16.25em;
}
}
@media screen and (min-width: 28.375em) and (max-width: 71em){
#cancer_table .cencer_table_name{
width: 12.25em;
}
}
@media screen and (max-width: 28.25em){
#cancer_table .cencer_table_name{
width: 7em;
}
}
#cancer_predict_result_block .cencer_table_name{
width: 5em;
}
.cancer_table_btn{
margin-right: 0.5em;
color:#5d7ca2;
border-color: #5d7ca2;
font-weight: 600;
}
.cancer_table_btn::last-of-type{
margin-right:auto;
}
#cancer_table{
font-size:0.825em;
color:#5d7ca2;
}
#cancer_table_top{
padding-bottom: 4em;
}
#font_texts{
padding-right: 0.5em;
}
#text_describe{
font-weight: bold;
float: left;
max-width: 75%;
padding-bottom: 3em;
}
#font_size_choices{
font-weight: bold;
float: right;
max-width: 50%;
padding-left:1em;
}
form.for_num{
position: relative;
float:left;
}
select.select_num{
position: absolute;
width: 5.125em;
height: 1.75em;
left: 1em;
clip: rect(0.25em,4.8em,1.5em,3.875em);
border:none;
padding: 0.5em;
}
input.num_only{
color: black;
border-top: 0.125em solid rgb(221, 221, 221);
width: 5.125em;
padding: 0em 0em 0.25em;
border-left: 0.125em solid rgb(221, 221, 221);
text-align: center;
font-size: 0.875em;
background-color: rgb(255, 255, 255);
height: 2.25em;
position: absolute;
left:0.625em;
}
input.float_num{
position: relative;
}
#cancer_table_left{
width:100%;
}
#cancer_table_right{
width:100%;
}
#cancer_table_submit{
margin-left: 1em;
float: right;
background-color: rgb(210, 105, 0);
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
font-size: 1.25em;
}
#cancer_table_reset{
float: right;
background-color: rgb(210, 105, 0);
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
font-size: 1.25em;
}
.btn-sub{
background:url("/assets/cancerpredict/triangle_sub.png") no-repeat top transparent;
position: relative;
width: 1.875em;
border: 0;
height: 1.875em;
background-size: contain;
top:1em;
bottom: -0.7em;
padding: 0;
}
.btn-add{
background:url("/assets/cancerpredict/triangle_add.png") no-repeat top transparent;
position: relative;
width: 1.875em;
border: 0;
height: 1.875em;
background-size: contain;
right: 1.815em;
top: -0.3em;
padding: 0;
}
.cancer_table_btn:focus{
color: #5d7ca2 !important;
background-color: #9dc3e6 !important;
border-color: #8c8c8c !important;
}
.cancer_table_btn:hover{
color: #5d7ca2 !important;
background-color: #9dc3e6 !important;
border-color: #8c8c8c !important;
}
.cancer_table_btn.active{
color: #5d7ca2;
background-color: #9dc3e6;
border-color: #8c8c8c;
}
.cancertable_empty{
border: 0.25em solid pink !important;
border-radius: 0.5em !important;
padding: 0.125em !important;
}
.result_title{
background-color: rgb(210, 105, 0);
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
font-size: 1.25em;
float: left;
}
.result_tab{
background: #023d79;
background: linear-gradient(135deg, transparent 0.3em, #023d79 0);
border: none;
float:right;
padding: 0.5em 0.125em 0.5em 0.5em;
margin-top: 0.5em;
cursor: pointer;
}
#cancer_table a:hover{
text-decoration: none;
color: #5d7ca2;
}
#result_contents{
padding-top: 2em;
}
#choice_fields{
padding: 2em 0 0 calc(20% - 1.625em);
}
.result_tab:hover{
background: #d16801;
background: linear-gradient(135deg, transparent 0.3em, #d16801 0);
padding: 0.8em 0.125em 0.5em 1em;
margin-left: -0.5em;
}
.result_tab.active{
background: #d16801;
background: linear-gradient(135deg, transparent 0.3em, #d16801 0);
padding: 0.8em 0.125em 0.5em 1em;
margin-left: -0.5em;
}
.result_tab > a{
writing-mode: vertical-lr;
-webkit-writing-mode: vertical-lr;
color: white;
}
.result_tab_group{
width: 20%;
margin: 0;
float: left;
}
.result_content_group{
width: 80%;
margin: 0;
float: right;
}
.result_content{
display: none;
min-height: 25em;
border: 0.125em solid #c0cbdd;
padding: 0.5em;
}
.result_content:first-of-type{
display: block;
}
.result_content a{
color: #5d7ca2;
}
.result_content p{
color: #5d7ca2;
clear: both;
}
.cancer_years{
float:left;
color: #5d7ca2;
background-color: #fff;
border-color: #5d7ca2;
border-width: 0.125em;
margin: 0em;
}
.cancer_years:first-of-type{
margin-left: 1em;
}
.cancer_years:last-of-type{
margin-right: 1em;
}
.cancer_form_field{
margin-left: 1em;
}
#result_table_content a{
float:left;
display: contents;
}
.result_content span{
color: #5d7ca2;
}
.hint-texts{
color: rgb(104, 104, 104);
font-size: 0.75em;
clear: both;
padding: 0.5em 0;
}
#result_text_content a{
float:left;
}
#result_table_content table{
clear: both;
width:100%;
table-layout: fixed;
overflow-wrap: break-word;
}
#result_table_content table tbody tr{
display: none;
}
#result_table_content table tbody tr:first-of-type{
display: table-row;
}
.white_text,.white_text:link,.white_text:visited{
color:white;
}
.cancer_th{
color: white;
background-color: #003d79;
border-right: 0.375em solid white;
border-top: 0.375em solid white;
}
.cancer_td {
background-color: #e9eaf5;
border-right: 0.375em solid white;
border-top: 0.375em solid white;
}
#cancer_predict_result_block{
display:none;
font-size: 0.825em;
margin-top: 3em;
border-top: #666 solid;
padding-top: 2em;
}
p.texts_show{
display: list-item;
margin-left: 1.5em;
clear: both;
}
div.texts_show{
display: block;
margin-left: 0;
}
.addition{
display: none;
}
#cancer_table_right_result .cancer_table_btn{
padding: 0.25em 1em;
}
#cancer_table_left_result .cancer_table_btn{
padding: 0.25em 1em;
}
.modal-dialog {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%) !important;
overflow: auto;
overflow-y: auto;
}
#cancer_predict_result{
width: 80%;
}
@media screen and (min-width: 48em) {
#cancer_table_right{
float:right;
width:50%;
}
#cancer_table_left{
float:left;
width:50%;
}
#cancer_table_right_result{
width: 50%;
float: right;
}
#cancer_table_left_result{
width: 50%;
float: left;
}
#cancer_predict_result{
width: 50%;
float: left;
}
.result_title{
margin-top: 1em;
}
}
@media print {
* {
-webkit-print-color-adjust: exact !important;
}
}

View File

@ -0,0 +1,383 @@
@import url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css);
button, input, optgroup, select, textarea {
margin: 0;
font: inherit;
color: inherit;
}
.fa {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
transform: translate(0, 0);
}
.fa-question:before {
content: "\f128";
}
button {
overflow: visible;
}
button, input, select, textarea {
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
#cancer_table *[data-key]{
padding: 0.375em 0;
display: inline-block;
width: 100%;
}
.head_logo{
height: 4em;
}
div.num_group{
position: relative;
float: left;
width: 4.125em;
height: 2.25em;
}
.navbar-brand>img.head_logo{
width: 70%;
height: auto;
}
.header-nav{
top:0 !important;
}
.title_texts{
color:rgb(210, 106, 2);
display:none;
}
.cencer_table_name{
display: inline-block;
vertical-align: middle;
color:#5d7ca2;
}
#cancer_table .cencer_table_name{
width: 16.25em;
}
#cancer_predict_result_block .cencer_table_name{
width: 5em;
}
.cancer_table_btn{
margin-right: 0.5em;
color:#5d7ca2;
border-color: #5d7ca2;
font-weight: 600;
}
.cancer_table_btn::last-of-type{
margin-right:auto;
}
#cancer_table{
font-size:0.825em;
color:#5d7ca2;
}
#cancer_table_top{
padding-bottom: 4em;
}
#font_texts{
padding-right: 0.5em;
}
#text_describe{
font-weight: bold;
float: left;
max-width: 75%;
padding-bottom: 3em;
}
#font_size_choices{
font-weight: bold;
float: right;
max-width: 50%;
padding-left:1em;
}
form.for_num{
position: relative;
float:left;
}
select.select_num{
position: absolute;
width: 5.125em;
height: 1.75em;
left: 1em;
clip: rect(0.25em,4.8em,1.5em,3.875em);
border:none;
padding: 0.5em;
}
input.num_only{
color: black;
border-top: 0.125em solid rgb(221, 221, 221);
width: 5.125em;
padding: 0em 0em 0.25em;
border-left: 0.125em solid rgb(221, 221, 221);
text-align: center;
font-size: 0.875em;
background-color: rgb(255, 255, 255);
height: 2.25em;
position: absolute;
left:0.625em;
}
input.float_num{
position: relative;
}
#cancer_table_left{
width:100%;
}
#cancer_table_right{
width:100%;
}
#cancer_table_submit{
margin-left: 1em;
float: right;
background-color: rgb(210, 105, 0);
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
font-size: 1.25em;
}
#cancer_table_reset{
float: right;
background-color: rgb(210, 105, 0);
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
font-size: 1.25em;
}
.btn-sub{
background:url("/assets/cancerpredict/triangle_sub.png") no-repeat top transparent;
position: relative;
width: 1.875em;
border: 0;
height: 1.875em;
background-size: contain;
top:1em;
bottom: -0.7em;
padding: 0;
}
.btn-add{
background:url("/assets/cancerpredict/triangle_add.png") no-repeat top transparent;
position: relative;
width: 1.875em;
border: 0;
height: 1.875em;
background-size: contain;
right: 1.815em;
top: -0.3em;
padding: 0;
}
.cancer_table_btn:focus{
color: #5d7ca2 !important;
background-color: #9dc3e6 !important;
border-color: #8c8c8c !important;
}
.cancer_table_btn:hover{
color: #5d7ca2 !important;
background-color: #9dc3e6 !important;
border-color: #8c8c8c !important;
}
.cancer_table_btn.active{
color: #5d7ca2;
background-color: #9dc3e6;
border-color: #8c8c8c;
}
.cancertable_empty{
border: 0.25em solid pink !important;
border-radius: 0.5em !important;
padding: 0.125em !important;
}
.result_title{
background-color: rgb(210, 105, 0);
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
font-size: 1.25em;
float: left;
}
.result_tab{
background: #023d79;
background: linear-gradient(135deg, transparent 0.3em, #023d79 0);
border: none;
float:right;
padding: 0.5em 0.125em 0.5em 0.5em;
margin-top: 0.5em;
cursor: pointer;
}
#cancer_table a:hover{
text-decoration: none;
color: #5d7ca2;
}
#result_contents{
padding-top: 2em;
}
#choice_fields{
padding: 2em 0 0 calc(20% - 1.625em);
}
.result_tab:hover{
background: #d16801;
background: linear-gradient(135deg, transparent 0.3em, #d16801 0);
padding: 0.8em 0.125em 0.5em 1em;
margin-left: -0.5em;
}
.result_tab.active{
background: #d16801;
background: linear-gradient(135deg, transparent 0.3em, #d16801 0);
padding: 0.8em 0.125em 0.5em 1em;
margin-left: -0.5em;
}
.result_tab > a{
writing-mode: vertical-lr;
-webkit-writing-mode: vertical-lr;
color: white;
}
.result_tab_group{
width: 20%;
margin: 0;
float: left;
}
.result_content_group{
width: 80%;
margin: 0;
float: right;
}
.result_content{
display: none;
min-height: 25em;
border: 0.125em solid #c0cbdd;
padding: 0.5em;
}
.result_content:first-of-type{
display: block;
}
.result_content a{
color: #5d7ca2;
}
.result_content span{
color: #5d7ca2;
}
.result_content p{
color: #5d7ca2;
clear: both;
}
.cancer_years{
float:left;
color: #5d7ca2;
background-color: #fff;
border-color: #5d7ca2;
border-width: 0.125em;
margin: 0em;
}
.cancer_years:first-of-type{
margin-left: 1em;
}
.cancer_years:last-of-type{
margin-right: 1em;
}
.cancer_form_field{
margin-left: 1em;
}
#result_table_content a{
float:left;
display: contents;
}
.hint-texts{
color: rgb(104, 104, 104);
font-size: 0.75em;
clear: both;
padding: 0.5em 0;
}
#result_text_content a{
float:left;
}
#result_table_content table{
clear: both;
width:100%;
table-layout: fixed;
overflow-wrap: break-word;
}
#result_table_content table tbody tr{
display: none;
}
#result_table_content table tbody tr:first-of-type{
display: table-row;
}
.white_text,.white_text:link,.white_text:visited{
color:white;
}
.cancer_th{
color: white;
background-color: #003d79;
border-right: 0.375em solid white;
border-top: 0.375em solid white;
}
.cancer_td {
background-color: #e9eaf5;
border-right: 0.375em solid white;
border-top: 0.375em solid white;
}
#cancer_predict_result_block{
display:none;
font-size: 0.825em;
margin-top: 3em;
border-top: #666 solid;
padding-top: 2em;
}
p.texts_show{
display: list-item;
margin-left: 1.5em;
clear: both;
}
div.texts_show{
display: block;
margin-left: 0;
}
.addition{
display: none;
}
#cancer_table_right_result .cancer_table_btn{
padding: 0.25em 1em;
}
#cancer_table_left_result .cancer_table_btn{
padding: 0.25em 1em;
}
.modal-dialog {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%) !important;
overflow: auto;
overflow-y: auto;
}
#cancer_predict_result{
width: 80%;
}
#cancer_table_right{
float:right;
width:50%;
}
#cancer_table_left{
float:left;
width:50%;
}
#cancer_table_right_result{
width: 50%;
float: right;
}
#cancer_table_left_result{
width: 50%;
float: left;
}
#cancer_predict_result{
width: 50%;
float: left;
}
.result_title{
margin-top: 1em;
}
@media print {
* {
-webkit-print-color-adjust: exact !important;
}
}

View File

@ -3,6 +3,7 @@ require 'rubyXL'
class Admin::CancerpredictsController < OrbitAdminController
#include Admin::CancerpredictsHelper
before_action ->(module_app = @app_title) { set_variables module_app }
before_action :create_first_field
#before_action :load_access_levels
def initialize
super
@ -14,8 +15,236 @@ class Admin::CancerpredictsController < OrbitAdminController
@categories = @module_app.categories.enabled
@filter_fields = filter_fields(@categories, @tags)
@table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified]
if request.xhr?
render :partial => "index"
end
@head_images_id = @form_to_show.head_images_id
@title_images_id = @form_to_show.title_images_id
@head_images = []
@title_images = []
@head_images_id.each{|image_id| @head_images.push Headimages.find_by(:id=>image_id.to_s)} rescue nil
@title_images_id.each{|image_id| @title_images.push Headimages.find_by(:id=>image_id.to_s)} rescue nil
@head_new_image = Headimages.new(:cancerpredictfields_id => @form_to_show.id)
end
def edit
if !(params["cancerpredictfields"].nil?)
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
else
value.each do |sub_property,sub_value|
if @form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s].class != Array
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value
else
if sub_value.length > 2
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = YAML.load(sub_value)
else
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = []
end
end
end
end
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
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']
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
elsif @form_to_show[item].class == Array
@form_to_show[item] = YAML.load(params_cancer[item])
@form_to_show[item] = [] if @form_to_show[item].class != Array
else
@form_to_show[item] = params_cancer[item]
end
end
@size = ['small','medium','large']
@size.each{|size| @form_to_show[size] = params["cancerpredictfields"][size]}
@file_path = Rails.root.to_s + '/app/assets/images/predict_tool'
if !Dir.exist? @file_path
FileUtils.mkdir_p @file_path
end
@images = params["cancerpredictfields"]['head_images']
@head_images_id = @form_to_show.head_images_id
@delete_index = []
if !@images.nil?
@images.each do |num,image|
if num.to_i < @head_images_id.length && @head_images_id.length != 0
if image['remove_image'] == "1"
@delete_index.push num.to_i
else
@image_id = @head_images_id[num.to_i]
@image = Headimages.find_by(:id=>@image_id.to_s)
if !image['sort_number'].nil?
@image.sort_number = image['sort_number'].to_i
@image.save
end
next if image['temp_file'] == nil
@file_name = image['temp_file'].original_filename.gsub('(','_').gsub(')','_').gsub(' ','_') rescue next
@image.sort_number = image['sort_number'].to_i
@image.temp_file = image['temp_file']
@image.save
end
else
@file_name = image['temp_file'].original_filename.gsub('(','_').gsub(')','_').gsub(' ','_') rescue next
@headimages = Headimages.new(:cancerpredictfields_id => @form_to_show.id,:title => @app_title+'head_images')
@headimages.temp_file = image['temp_file']
@headimages.sort_number = image['sort_number'].to_i if !image['sort_number'].nil?
@headimages.save
@form_to_show.head_images_id.push @headimages.id
end
end
end
@delete_index.reverse!
@delete_index.each do |i|
@image_id = @head_images_id[i.to_i]
Headimages.find_by(:id => @image_id ).destroy rescue next
@form_to_show.head_images_id.delete(@image_id)
end
@images = params["cancerpredictfields"]['title_images']
@title_images_id = @form_to_show.title_images_id
@delete_index = []
if !@images.nil?
@images.each do |num,image|
if num.to_i < @title_images_id.length && @title_images_id.length != 0
if image['remove_image'] == "1"
@delete_index.push num.to_i
else
@image_id = @title_images_id[num.to_i]
@image = Headimages.find_by(:id=>@image_id.to_s)
if !image['sort_number'].nil?
@image.sort_number = image['sort_number'].to_i
@image.save
end
next if image['temp_file'] == nil
@file_name = image['temp_file'].original_filename.gsub('(','_').gsub(')','_').gsub(' ','_') rescue next
@image.sort_number = image['sort_number'].to_i
@image.temp_file = image['temp_file']
@image.save
end
else
@file_name = image['temp_file'].original_filename.gsub('(','_').gsub(')','_').gsub(' ','_') rescue next
@headimages = Headimages.new(:cancerpredictfields_id => @form_to_show.id,:title => @app_title+'title_images' )
@headimages.temp_file = image['temp_file']
@headimages.sort_number = image['sort_number'].to_i if !image['sort_number'].nil?
@headimages.save
@form_to_show.title_images_id.push @headimages.id
end
end
end
@delete_index.reverse!
@delete_index.each do |i|
@image_id = @title_images_id[i.to_i]
Headimages.find_by(:id => @image_id ).destroy rescue next
@form_to_show.title_images_id.delete(@image_id)
end
@form_to_show.save
end
@index = 0
Dir.chdir("public") do
while File.exist?('cancerfield_back'+@index.to_s+'.txt')
@index += 1
end
end
Dir.chdir("public") do
@file_back = File.open('cancerfield_back'+@index.to_s+'.txt', 'w')
@file_back.write(@form_to_show.attributes)
@file_back.close
@file_org = File.open('cancerfield_org'+@index.to_s+'.txt', 'w')
@file_org.write(Cancerpredictfields.where("title"=>@app_title+'_back').first.attributes)
@file_org.close
end
redirect_to admin_cancerpredicts_path
end
def showSubmit
@results = Cancerpredictrecord.where("title"=>@app_title).take_while{true}
@variables = []
@names = []
@form_to_show.form_show.each do |num,property|
property.each do |key,value|
if key == "variable"
@variables.push value
elsif key == "name"
@names.push value[I18n.locale.to_s]
end
end
end
@result_variables = []
@result_names = []
@indexs=[]
@results[0].result.each{|key,value| @result_variables.push key} rescue nil
@result_variables.each do |variable|
@index = @variables.index(variable.to_s)
@result_names.push @names[@index] if !@index.nil?
@indexs.push @index if !@index.nil?
end
@choicenames=[]
@indexs.each do |index|
if @form_to_show.form_show[index.to_s]["is_num"] == 1 || @form_to_show.form_show[index.to_s]["is_float"] == 1
@choicenames.push ""
else
@choicenames.push @form_to_show.form_show[index.to_s]["choice_fields"][I18n.locale.to_s]
end
end
end
def create_first_field
if Cancerpredictfields.where("title"=>(@app_title + "_back")).take_while{true}.count == 0
@form_to_show = Cancerpredictfields.new()
@form_to_show.title = @app_title +"_back"
@form_to_show.save
end
@form_to_show
if Cancerpredictfields.where("title"=>@app_title).take_while{true}.count == 0
@form_to_show = Cancerpredictfields.new()
@form_to_show.title=@app_title
@form_to_show.save
@form_to_show = Cancerpredictfields.where("title"=>@app_title).first
else
@form_to_show = Cancerpredictfields.where("title"=>@app_title).first
end
end
end

View File

@ -1,24 +0,0 @@
# encoding: utf-8
require 'rubyXL'
class CancerpredictsController < ApplicationController
before_filter :set_I18n
before_action ->(module_app = @app_title) { set_variables module_app }
#before_action :load_access_levels
def initialize
super
@app_title = "cancerpredict"
end
def index
@tags = @module_app.tags
@categories = @module_app.categories.enabled
@filter_fields = filter_fields(@categories, @tags)
@table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified]
if request.xhr?
render :partial => "index"
end
end
def set_I18n
I18n.locale = params[:lang] if params[:lang].present?
end
end

View File

@ -1,27 +1,463 @@
# encoding: utf-8
require 'rubyXL'
class CancerpredictsController < ApplicationController
before_filter :set_I18n
before_action ->(module_app = @app_title) { set_variables module_app }
#before_action :load_access_levels
def initialize
super
@app_title = "cancerpredict"
end
def calculate
uid = OrbitHelper.params[:uid] rescue ""
tags = OrbitHelper.widget_tags
categories = OrbitHelper.widget_categories || []
create_first_field
#begin
if params['header'].to_i == 1
locale = params['locale'].to_s rescue 'zh_tw'
locale = 'zh_tw' if locale == 'zh_cn'
result = {}
@head_images = {}
@form_to_show.head_images_id.each do |image_id|
next if image_id.to_s == ""
@image = Headimages.find_by(:id=>image_id.to_s)
@url = @image.temp_file.to_s
@head_images[@image.sort_number.to_i] = ('<img class="head_logo" alt ="' + Pathname.new(@image.temp_file.file.file).basename.to_s+'" src="'+@url+'"/>')
end
result['head_images'] = Hash[@head_images.sort].values.join('')
@head_images = {}
@form_to_show.title_images_id.each do |image_id|
next if image_id.to_s == ""
@image = Headimages.find_by(:id=>image_id.to_s)
@url = @image.temp_file.to_s
@head_images[@image.sort_number.to_i] = ('<img class="head_logo" alt ="' + Pathname.new(@image.temp_file.file.file).basename.to_s+'" src="'+@url+'"/>')
end
result['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]]
else
@record = Cancerpredictrecord.new
@record.title = @app_title
@choice_keys = []
@choice_values = []
@choice_names = []
@form_to_show.form_show.values.each{|choice| @choice_keys.push choice[:variable]}
@form_to_show.form_show.values.each{|choice| @choice_values.push choice[:choice_fields]}
@form_to_show.form_show.values.each{|choice| @choice_names.push choice[:name]}
@choice_keys.each_with_index{|key,i| @record.names[key] = @choice_names[i]}
@choice_keys.each_with_index{|key,i| @record.values[key] = @choice_values[i]}
params['data'].each do |rec_key,rec_value|
@record.result[rec_key] = rec_value
end
@record.submit_time = Time.now.to_s
@record.save
locale = params['data']['locale'].to_s rescue 'zh_tw'
locale = 'zh_tw' if locale == 'zh_cn'
result = {}
result['age1'] = (params['data']['age'].to_f/100)**(0.5)
result['age2'] = ((params['data']['age'].to_f/100)**(0.5))*Math.log(params['data']['age'].to_f/100,Math.exp(1))
result['size1'] = Math.log(params['data']['size'].to_f/10,Math.exp(1))
if params['data']['lymph_nodes_examined'].to_i != 0
result['ratio'] = params['data']['lymph_nodes_positive'].to_f/params['data']['lymph_nodes_examined'].to_f rescue 0
else
result['ratio'] = 0
end
result['ratio'] = 1 if result['ratio'] > 1
result['nposit'] = ((result['ratio'].to_f+0.1)/0.1)**0.5
@T = ''
if params['data']['tumor_direct_extension'].to_i != 1
if params['data']['size'].to_i <= 20
@T = 'T1'
elsif params['data']['size'].to_i > 20 && params['data']['size'].to_i <= 50
@T = 'T2'
elsif params['data']['size'].to_i > 50
@T = 'T3'
end
else
@T = 'T4'
end
result['T'] = @T
@N = ''
if params['data']['lymph_nodes_positive'].to_i == 0
@N = 'N0'
elsif params['data']['lymph_nodes_positive'].to_i >= 1 && params['data']['lymph_nodes_positive'].to_i <= 3 && params['data']['micrometastasis'].to_i != 1
@N = 'N1'
elsif params['data']['lymph_nodes_positive'].to_i >= 1 && params['data']['lymph_nodes_positive'].to_i <= 3 && params['data']['micrometastasis'].to_i == 1
@N = 'N1mi'
elsif params['data']['lymph_nodes_positive'].to_i >= 4 && params['data']['lymph_nodes_positive'].to_i <= 9
@N = 'N2'
elsif params['data']['lymph_nodes_positive'].to_i >= 10
@N = 'N3'
end
result['N'] = @N
@M = ''
if params['data']['Distant_Metastasis'].to_i != 1
@M = 'M0'
else
@M = 'M1'
end
result['M'] = @M
if @M == 'M0'
if @T == 'T1' && (@N == 'N0' || @N == 'N1mi')
result['pstage'] = 1
elsif ((@T == 'T2' || @T == 'T3') && (@N == 'N0')) || ((@T == 'T1' || @T == 'T2') && (@N == 'N1'))
result['pstage'] = 2
elsif (@T == 'T4' && @N == 'N0') || ((@T == 'T3' || @T == 'T4') && @N == 'N1') || (@N == 'N2' || @N == 'N3')
result['pstage'] = 3
end
else
result['pstage'] = 4
end
if (params['data']['ER_status'].to_i != 2 || params['data']['PR_status'].to_i != 2) && (params['data']['HER2_status'].to_i != 1)
result['subtype'] = 1
elsif params['data']['ER_status'].to_i == 2 && params['data']['PR_status'].to_i == 2 && (params['data']['HER2_status'].to_i == 1)
result['subtype'] = 2
elsif params['data']['ER_status'].to_i == 2 && params['data']['PR_status'].to_i == 2 && (params['data']['HER2_status'].to_i != 1)
result['subtype'] = 3
end
if params['data']['grade'].to_i == 2 || params['data']['grade'].to_i == 4
result['grade_2'] = 1
else
result['grade_2'] = 0
end
if params['data']['grade'].to_i == 3
result['grade_3'] = 1
else
result['grade_3'] = 0
end
if result['subtype'].to_i == 2
result['subtype_HER2'] = 1
else
result['subtype_HER2'] = 0
end
if result['subtype'].to_i == 3
result['subtype_triple'] = 1
else
result['subtype_triple'] = 0
end
if result['pstage'].to_i == 2
result['pstage_2'] = 1
else
result['pstage_2'] = 0
end
if result['pstage'].to_i == 3
result['pstage_3'] = 1
else
result['pstage_3'] = 0
end
if result['pstage'].to_i == 4
result['pstage_4'] = 1
else
result['pstage_4'] = 0
end
if params['data']['lvi'].to_i == 1
result['lvi_yes'] = 1
else
result['lvi_yes'] = 0
end
result['lpv'] = ((result['age1']-0.7276655)*(-10.87)+(result['age2']+0.4540707)*8.968+(result['size1']-0.643632)*0.7678+(result['nposit']-1.346932)*0.5339+
result['grade_2']*0.4795+result['grade_3']*0.818+result['subtype_HER2']*0.1806+result['subtype_triple']*0.6457+result['pstage_2']*0.5311+
result['pstage_3']*1.134+result['pstage_4']*2.172+result['lvi_yes']*0.3321-0.04 rescue 'error')
@years = @form_to_show.years
result['table'] = '<input id="current_year" type="hidden" value="'+@years[-1].to_s+'" index="0"/><p id="cancer_table_texts">'+@form_to_show.table_above_texts[locale]+'</p>'
result['table'] += '<a style="display: inline-block;">第</a><a style="display: inline-block;">'
result['years'] = @years
@years.each{|year| result['table'] += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm">'+year.to_s+'</button>')}
result['table'] += '</a><a style="display: inline-block;">年</a>'
@table_head = (locale == "zh_tw") ? ['治療','額外治療效益','總生存率(%)'] :['Treatment','Additional Benefit','Overall Survival(%)']
@head_name = ['Treatment','Additional_Benefit','Overall_Survival']
@therapy_choices = (locale == "zh_tw") ? ['純手術'] :['Surgery only']
@form_to_show.form_show_in_result.values.each{|choice| @therapy_choices.push choice["name"][locale]}
@therapy_names = ['Surgery_only']
@form_to_show.form_show_in_result.values.each{|choice| @therapy_names.push choice["variable"]}
result['treatmeny_method'] = @therapy_names
result['table'] += '<table><thead><tr>'
@table_head.each_with_index{|head,index| result['table'] += ('<th class="cancer_th '+@head_name[index]+'">' + head + '</th>')}
result['table'] += '</tr></thead><tbody>'
@therapy_choices.each_with_index do |choice,i|
result['table'] += '<tr class="'+@therapy_names[i].to_s+'">'
@table_head.each_with_index do |head,index|
result['table'] += ('<td class="cancer_td '+ @head_name[index]+'">' + ((index == 0) ? (((i==0)? '' : '+') + choice) : '-') + '</td>')
end
result['table'] += '</tr>'
end
@texts = @form_to_show.text_above_texts[locale].gsub('<br/>','</span><br/><span>')
@texts = @texts.split('{{years}}')
@texts.delete('')
result['texts'] = '<span>'+@texts[0]
@years.each{|year| result['texts'] += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm" style="float:none;">'+year.to_s+'</button>')}
if @texts.count > 1
result['texts'] += (@texts[1]+'</span>') if @texts.count > 1
else
result['texts'] += '</span>'
end
@lpv_calc = [-0.001476145,-0.01261639,-0.02519608]
@servive_ratio = ((Math.exp(@lpv_calc[-1])**(Math.exp(result['lpv'])))*100).round
@surgery_only_texts = @form_to_show.surgery_only_texts[locale]
@surgery_only_texts.insert(0,'<p class="show"><span>')
@surgery_only_texts = @surgery_only_texts.gsub('{{Surgery_only}}','<span class="'+@therapy_names[0]+' Overall_Survival">'+@servive_ratio.round.to_s+'</span><span>')
@surgery_only_texts = @surgery_only_texts.gsub('{{surgery_year}}','</span><span class="surgery_year">'+@years[-1].to_s+'</span><span>')
@surgery_only_texts += '</span>'
result['texts'] += @surgery_only_texts
result['texts'] += '<span class="addition">'+@form_to_show.extra_texts[locale]+'</span><div class="extra-text" style="display:none;"><div class="texts_show" style="clear:both;"></div></div></p>'
result['extra_therapy_texts'] = @form_to_show.extra_therapy_texts[locale] rescue @form_to_show.extra_therapy_texts['zh_tw']
result['servive_ratio'] = @servive_ratio
end
result = result.merge(params)
render :json=> result
# rescue
# render :json=> params
#end
end
def index
uid = OrbitHelper.params[:uid] rescue ""
tags = OrbitHelper.widget_tags
categories = OrbitHelper.widget_categories || []
locale = OrbitHelper.get_site_locale.to_s
create_first_field
@size = {}
@size_name = ['small','medium','large']
@size_name.each{|name| @size[name] = @form_to_show[name]['font_size']}
@size_active_size = ''
@size.each{|size_key,size_value| (@form_to_show[size_key]['active'].to_i == 1) ? ( @size_active_size = size_value ): nil }
@table_str = '<div id="cancer_table" style="font-size:' + @size_active_size + ';"><div id="show_help_modal" class="modal fade"></div>'
@table_str += '<div id="cancer_table_top"><div id="text_describe">'+@form_to_show.text_descibe[I18n.locale.to_s] +'</div>'
@table_str += '<div id="font_size_choices">'+'<label id="font_texts">'+t('cancerpredict.font_size')+':</label>'
@size.each{|size_key,size_value| @table_str += ('<button class="cancer_table_btn '+((@form_to_show[size_key]['active'].to_i == 1) ? 'active' :'') + ' btn btn-default btn-sm" onclick="document.getElementById(\'cancer_table\').style[\'font-size\']=\''+size_value+'\';document.getElementById(\'cancer_predict_result_block\').style[\'font-size\']=\''+size_value+'\';">'+t('cancerpredict.'+size_key)+'</button>' )}
@table_str += '</div></div><div style="clear:both;"></div>'
@table_str_left = '<div id="cancer_table_left">'
@table_str_right = '<div id="cancer_table_right">'
@form_to_show.form_show.each do |num,property|
@field_property = {}
property.each do |key,value|
@value= value
if @value.class == BSON::Document || @value.class == Hash
@disp_value = @value[I18n.locale.to_s] rescue ""
else
@disp_value = @value
end
@field_property[key] = @disp_value
end
if @field_property['right'] == 0
@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>'
if @field_property["comment_text"] != ""
@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
@site_locales = current_site.in_use_locales
@site_locales.delete(I18n.locale)
@site_locales.each do |locale|
next if property["comment_text"][locale.to_s] == ""
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"] != ""
@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
@table_str_left += '<div style="margin-right: 2.125em;float: left;"></div>'
end
end
if @field_property["is_num"] == 1
if @field_property["is_float"] == 1
@table_str_left += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/></div>'
else
@table_str_left += '<div class="num_group"><form class="for_num">'
@table_str_left += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/>'
@table_str_left += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_str_left += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_str_left += ('<option value="0">' + choice.to_s + '</option>')
end
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_str_left += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_str_left += '</select></form></div>'
end
else
@table_str_left += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
@field_property["choice_fields"].each do |create_choice|
@table_str_left += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice+'</button>'
@table_str_left += '<input type="hidden" value="0" name="'+create_choice+'"/>'
end
@table_str_left += '</div>'
end
if @field_property["hint"].to_s != ""
@table_str_left +='<div style="color: rgb(104, 104, 104);font-size:0.75em;clear:both;">'+@field_property["hint"]+'</div>'
end
@table_str_left += '</div><div style="clear:both;"></div>'
else
@table_str_right += '<div data-key='+num.to_s+'>'
break if @field_property["name"] == ""
@table_str_right += '<label for="'+@field_property["variable"]+'" style="float:left;'+(@field_property["comment_text"] == "" ? "margin-right: 2.125em;" : "")+'" class="cencer_table_name">'
@table_str_right += @field_property["name"]
@table_str_right += '</label>'
if @field_property["comment_text"] != ""
@table_str_right += '<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_right += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@site_locales = current_site.in_use_locales
@site_locales.delete(I18n.locale)
@site_locales.each do |locale|
next if property["comment_text"][locale.to_s] == ""
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"] != ""
@table_str_right += '<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_right += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@table_str_right += '<div style="margin-right: 2.125em;float: left;"></div>'
end
end
if @field_property["is_num"] == 1
if @field_property["is_float"] == 1
@table_str_right += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/><button class="btn-sub"></button><button class="btn-add"></button></div>'
else
@table_str_right += '<div class="num_group"><form class="for_num">'
@table_str_right += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/>'
@table_str_right += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_str_right += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_str_right += ('<option value="0">' + choice.to_s + '</option>')
end
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_str_right += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_str_right += '</select></form></div>'
end
else
@table_str_right += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
@field_property["choice_fields"].each do |create_choice|
@table_str_right += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice+'</button>'
@table_str_right += '<input type="hidden" value="0" name="'+create_choice+'"/>'
end
@table_str_right += '</div>'
end
if @field_property["hint"].to_s != ""
@table_str_right +='<div class="hint-texts">'+@field_property["hint"]+'</div>'
end
@table_str_right += '</div><div style="clear:both;"></div>'
end
end
@table_str_left += '</div>'
@table_str_right += '</div>'
@table_str += (@table_str_left+@table_str_right)
@table_str +='<div style="clear:both;"></div>'
@table_result_str = '<div id="cancer_predict_result" style="'+((@form_to_show.form_result_is_right == 0) ? 'float:right;' : '')+'"><span class="result_title">'+t("cancerpredict.table.result").to_s+'</span><div style="clear:both;"></div>'
@tab_name = ['table','text']
@table_result_str += '<div id="result_contents"><div class="result_tab_group">'
@tab_name.each_with_index{|name,index| @table_result_str += ('<div id="result_'+name+'_tab" class="result_tab'+((index != 0) ? "" : " active")+'"><a>'+t("cancerpredict.table."+name).to_s+'</a></div><div style="clear:both;"></div>')}
@table_result_str += '</div><div class="result_content_group">'
@tab_name.each{|name| @table_result_str += '<div id="result_'+name+'_content" class="result_content"><a>'+'no content'+'</a></div>'}
@table_result_str += '</div></div></div>'
@table_button = '<div id="cancer_table_button_group">'
@submit_btn_str='<button id="cancer_table_submit">'+t('cancerpredict.table.Submit').to_s+'</button>'
@reset_btn_str='<button id="cancer_table_reset">'+t('cancerpredict.table.Reset').to_s+'</button>'
@table_button += (@submit_btn_str+@reset_btn_str+'<div style="clear:both;"></div></div></div>')
@table_result_choice_fileds = '<div id="cancer_table_right_result">' if @form_to_show.form_result_is_right == 1
@table_result_choice_fileds = '<div id="cancer_table_left_result">' if @form_to_show.form_result_is_right == 0
@table_result_choice_fileds += '<span class="result_title">'+t('cancerpredict.table.Therapy_choice').to_s+'</span><div style="clear:both;"></div>'
@table_result_choice_fileds += '<div id="choice_fields">'
@form_to_show.form_show_in_result.each do |num,property|
@field_property = {}
property.each do |key,value|
@value= value
if @value.class == BSON::Document || @value.class == Hash
@disp_value = @value[I18n.locale.to_s] rescue ""
else
@disp_value = @value
end
@field_property[key] = @disp_value
end
@table_result_choice_fileds += '<div data-key='+num.to_s+'>'
break if @field_property["name"] == ""
@table_result_choice_fileds += '<label for="'+@field_property["variable"]+'" style="float:left;'+(@field_property["comment_text"] == "" ? "margin-right: 2.125em;" : "")+'" class="cencer_table_name">'
@table_result_choice_fileds += @field_property["name"]
@table_result_choice_fileds += '</label>'
if @field_property["comment_text"] != ""
@table_result_choice_fileds += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_result_choice_fileds += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'></input>'
else
@site_locales = current_site.in_use_locales
@site_locales.delete(I18n.locale)
@site_locales.each do |locale|
next if property["comment_text"][locale.to_s] == ""
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"] != ""
@table_result_choice_fileds += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_result_choice_fileds += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@table_result_choice_fileds += '<div style="margin-right: 2.125em;float: left;"></div>'
end
end
if @field_property["is_num"] == 1
if @field_property["is_float"] == 1
@table_result_choice_fileds += '<div class="num_group"><input class="num_only float_num cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'"/><button class="btn-sub"></button><button class="btn-add"></button>'
else
@table_result_choice_fileds += '<div class="num_group"><form class="for_num">'
@table_result_choice_fileds += '<input class="num_only cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;" data-range="'+@field_property["range"].to_s+'" onkeyup="value=value.replace(/[^\d]/g,\'\') "onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\d]/g,\'\'))"/><button class="btn-sub"></button><button class="btn-add"></button></div>'
@table_str_left += '<input class="num_only_value" type="hidden" value="0"/>'
@please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please choice"
@table_result_choice_fileds += '<select class="select_num"><option value="">'+@please_choice+'</option>'
if @field_property["choice_fields"] != []
@field_property["choice_fields"].each do |choice|
@table_result_choice_fileds += ('<option value="0">' + choice.to_s + '</option>')
end
end
for @num in @field_property["range"][0] .. @field_property["range"][1]
@table_result_choice_fileds += ('<option value="' + @num.to_s + '">' + @num.to_s + '</option>')
end
@table_result_choice_fileds += '</select></form></div>'
end
else
@table_result_choice_fileds += '<div class= "cancer-btn-group cancer_form_field" id="'+@field_property["variable"]+'" style="float:left;clear:right;">'
@field_property["choice_fields"].each do |create_choice|
@table_result_choice_fileds += '<button class="cancer_table_btn btn btn-default btn-sm">'+create_choice+'</button>'
@table_result_choice_fileds += '<input type="hidden" value="0" name="'+create_choice+'"></input>'
end
@table_result_choice_fileds += '</div>'
end
if @field_property["hint"].to_s != ""
@table_result_choice_fileds +='<div class="hint-texts">'+@field_property["hint"]+'</div>'
end
@table_result_choice_fileds += '</div><div style="clear:both;"></div>'
end
@table_result_choice_fileds += '</div></div>'
@table_str += (@table_button+'<div id="cancer_predict_result_block" style="font-size:' + @size_active_size + ';">'+@table_result_str+@table_result_choice_fileds+'</div>'+'<div style="clear:both;"></div>')
{
"cancerpredict" => [],
"extras"=>{"table"=> @table_str}
}
end
def widget
uid = OrbitHelper.params[:uid] rescue ""
tags = OrbitHelper.widget_tags
categories = OrbitHelper.widget_categories || []
locale = OrbitHelper.get_site_locale.to_s
end
def set_I18n
I18n.locale = params[:lang] if params[:lang].present?
def create_first_field
if Cancerpredictfields.where("title"=>(@app_title + "_back")).take_while{true}.count == 0
@form_to_show = Cancerpredictfields.new()
@form_to_show.title = @app_title +"_back"
@form_to_show.save
end
@form_to_show
if Cancerpredictfields.where("title"=>@app_title).take_while{true}.count == 0
@form_to_show = Cancerpredictfields.new()
@form_to_show.title=@app_title
@form_to_show.save
@form_to_show = Cancerpredictfields.where("title"=>@app_title).first
else
@form_to_show = Cancerpredictfields.where("title"=>@app_title).first
end
end
end

View File

@ -6,30 +6,44 @@ class Cancerpredictfields
# encoding: utf-8
include OrbitTag::Taggable
include OrbitCategory::Categorizable
field :font_array , :type => Hash, default:{}
field :new_add_font, type: String, default:""
field :delete_font, type: String, default:""
field :used_font , :type => Array, default:[]
field :un_used_font , :type => Array, default:[]
field :title ,type:String ,default:""
field :subtitle, localize: true
field :text, localize: true
# before_destroy :destroy_email
field :form_show , :type=> Hash ,default:{0=>{:variable=>"age",:name=>{"zh_tw"=>"年齡<br/>(Age)","en"=>"Age"},:is_num=>1, :hint=>{'zh_tw'=>'從 18 歲(含)開始至 93 歲','en'=>'Age must be between 18 and 93'} , :comment_text=>{'zh_tw'=>'年齡為該婦女於確診罹患乳癌時之年齡','en'=>'Age at diagnosis'}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[18,93],:right=>0,:is_float=>0},
1=>{:variable=>"size",:name=>{"zh_tw"=>"腫瘤大小<br/>(Tumor size)","en"=>"Tumor size"},:is_num=>1,:hint=>{'zh_tw'=>'','en'=>'The unit of tumor size is millimeter (mm)'}, :comment_text=>{'zh_tw'=>'若有多個原發腫瘤,請輸入最大尺寸之原發腫瘤','en'=>'If there was more than one primary tumor, please enter the size of the largest one.'}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[1,230],:right=>0,:is_float=>0},
2=>{:variable=>"lymph_nodes_examined",:name=>{"zh_tw"=>"區域淋巴結檢查數目<br/>(Regional lymph nodes examined)","en"=>"Regional lymph nodes examined"},:is_num=>1,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['未知'],"en"=>['unknown']},:range=>[0,90],:right=>0,:is_float=>0},
3=>{:variable=>"lymph_nodes_positive",:name=>{"zh_tw"=>"區域淋巴結侵犯數目<br/>(Regional lymph nodes positive)","en"=>"Regional lymph nodes positive"},:is_num=>1,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'此變項為預測重要變數,若無此資訊預測容易失真。','en'=>'Regional lymph nodes positive is a key predictive variable. If this information is omitted, the prediction result would be biased.'}, :choice_fields=> {"zh_tw"=>['未知'],"en"=>['unknown']},:range=>[0,90],:right=>0,:is_float=>0},
4=>{:variable=>"grade",:name=>{"zh_tw"=>"腫瘤分化程度<br/>(Tumor grade)","en"=>"Tumor grade"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'腫瘤級數代表腫瘤組織與正常組織間的分化程度,若無分化級數資訊,請選擇“未知”選項,將以級數 2 進行預測。','en'=>'The grade refers to how different the cancer cells are from normal cells. Please select “unknown” if there is no information about grade. The prediction model would use “grade 2” as the alternative variable.'}, :choice_fields=> {"zh_tw"=>['1','2','3','未知'],"en"=>['1','2','3','unknown']},:range=>[],:right=>0,:is_float=>0},
5=>{:variable=>"ER_status",:name=>{"zh_tw"=>"ER 狀態<br/>(ER status)","en"=>"ER status"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'ER:雌激素受體,若無 ER 資訊請選擇未知,將以佔多數比例陽性作為後續預測。','en'=>'ER status describes the status of estrogen receptor. Please select “unknown” if there is no information about ER status. The prediction model would use “Positive” (the majority class) as the alternative variable.'}, :choice_fields=> {"zh_tw"=>['陽性','陰性','未知'],"en"=>['positive','negative','unknown']},:range=>[],:right=>0,:is_float=>0},
6=>{:variable=>"PR_status",:name=>{"zh_tw"=>"PR 狀態<br/>(PR status)","en"=>"PR status"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'PR:黃體素受體,若無 PR 資訊請選擇未知,將以佔多數比例陽性作為後續預測。','en'=>'PR status describes the status of progesterone receptor. Please select “unknown” if there is no information about PR status. The prediction model would use “Positive” (the majority class) as the alternative variable.'}, :choice_fields=> {"zh_tw"=>['陽性','陰性','未知'],"en"=>['positive','negative','unknown']},:range=>[],:right=>1,:is_float=>0},
7=>{:variable=>"HER2_status",:name=>{"zh_tw"=>"HER2 狀態<br/>(HER2 status)","en"=>"HER2 status"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'HER2:第二型人類上皮成長因子接受器蛋白,若無 HER2 資訊請選擇未知,將以佔多數比例陰性作為後續預測。','en'=>'HER2 status describes the status of human epidermal growth factor receptor 2. Please select “unknown” if there is no information about HER2 status. The prediction model would use “Negative” (the majority class) as the alternative variable.'}, :choice_fields=> {"zh_tw"=>['陽性','陰性','未知'],"en"=>['positive','negative','unknown']},:range=>[],:right=>1,:is_float=>0},
8=>{:variable=>"Distant_Metastasis",:name=>{"zh_tw"=>"遠端轉移<br/>(Distant Metastasis)","en"=>"Distant Metastasis"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無遠轉移資訊請選擇未知,將以佔多數比例未遠端轉移作為後續預測。','en'=>'Please select “unknown” if there is no information about distant Metastasis. The prediction model would use “No” (the majority class) as the alternative variable.'}, :choice_fields=> {"zh_tw"=>['是','否','未知'],"en"=>['yes','no','unknown']},:range=>[],:right=>1,:is_float=>0},
9=>{:variable=>"micrometastasis",:name=>{"zh_tw"=>"淋巴結顯微轉移<br/>(Lymph nodes micrometastasis)","en"=>"Micrometastasis"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無顯微移資訊請選擇未知,將以無顯微轉移作為後續預測。','en'=>'Please select “unknown” if there is no information about lymph nodes micrometastasis. The prediction model would use “No” as the alternative variable.'}, :choice_fields=> {"zh_tw"=>['是','否','未知'],"en"=>['yes','no','unknown']},:range=>[],:right=>1,:is_float=>0},
10=>{:variable=>"tumor_direct_extension",:name=>{"zh_tw"=>"腫瘤浸潤至胸壁和/或皮膚<br/>(Tumor direct extension to the chest wall and/or to the skin)","en"=>"Tumor direct extension to the chest wall and/or to the skin"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'若無腫瘤浸潤至胸壁或皮膚資訊請選擇未知,將以佔多數比例無腫瘤浸潤至胸壁作為後續預測。','en'=>'Please select “unknown” if there is no information about tumor direct extension to the chest wall and/or to the skin. The prediction model would use “No” (the majority class) as the alternative variable'}, :choice_fields=> {"zh_tw"=>['是','否','未知'],"en"=>['yes','no','unknown']},:range=>[],:right=>1,:is_float=>0},
11=>{:variable=>"lvi",:name=>{"zh_tw"=>"淋巴管或血管侵犯<br/>(Lymph vessel or vascular invasion, LVI)","en"=>"Lymph vessel or vascular invasion, LVI"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>'Lymph vessel or vascular invasion'}, :comment_text=>{'zh_tw'=>'若無淋巴管或血管侵犯資訊,請選擇“未知”選項,將以佔多數比例的淋巴管或血管未侵犯進行預測','en'=>'Please select “unknown” if there is no information about Lymph vessel or vascular invasion. The prediction model would use “No” (the majority class) as the alternative variable.'}, :choice_fields=> {"zh_tw"=>['是','否','未知'],"en"=>['yes','no','unknown']},:range=>[],:right=>1,:is_float=>0}
}
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=>[]},
2=>{:variable=>"Radiotherapy",:name=>{"zh_tw"=>"放射治療","en"=>"Radiotherapy"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]},
3=>{:variable=>"Targeted_therapy",:name=>{"zh_tw"=>"標靶治療","en"=>"Targeted therapy"},:is_num=>0,:hint=>{'zh_tw'=>'抗HER2治療','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]}
}
field :form_result_is_right , :type=> Integer ,default: 0
field :text_descibe ,type:Hash ,default:{"zh_tw"=>"歡迎使用台灣準備乳癌預後系統!<br/>本預測系統由台灣癌症登記資料庫2011至2015年間共90,841位乳癌病人所建立 <br/>若要開始 請在下方輸入相關資訊","en"=>"Welcome to the Taiwan Breast Cancer Prediction System!<br/>The prediction system is constructed using 90,841 breast cancer patients clinical data from the Taiwan Cancer Registry database between 2011 and 2015, and validated by using 49,374 breast cancer patients clinical data from the US-based Surveillance, Epidemiology, and End Results (SEER) database.<br/>To start, please enter the information below."}
field :small ,type:Hash ,default:{'font_size'=>"0.825em",'active'=>0}
field :medium ,type:Hash ,default:{'font_size'=>"1em",'active'=>1}
field :large ,type:Hash ,default:{'font_size'=>"1.25em",'active'=>0}
field :head_images_id ,type:Array , default: [BSON::ObjectId('5df62cfc8cd8924e79000009'), BSON::ObjectId('5df745a58cd8924491000006'), BSON::ObjectId('5df745a58cd8924491000007'), BSON::ObjectId('5df745a58cd8924491000008'), BSON::ObjectId('5df745a58cd8924491000009')]
field :title_images_id ,type:Array , default: [BSON::ObjectId('5df87cd88cd8924491000036')]
field :title_texts ,type:Hash ,default:{'zh_tw'=>'華人癌症存活預測','en'=>'Asian breast cancer prediction'}
field :table_above_texts ,type:Hash ,default:{'zh_tw'=>"下表之分析為針對手術後病人根據選定的術後治療分別估計在第1年、3及5年的存活率。",'en'=>'The analysis is for women who had undergone surgery.The table shows the 1-, 3- and 5-year survival rates,based on the treatment you have selected.'}
field :text_above_texts ,type:Hash ,default:{'zh_tw'=>"此研究分析來自已接受根除性手術後之婦女所得之結果,根據您所輸入的資訊以及治療方式,在術後第{{years}}年,",'en'=>'The analysis is for women who had undergone surgery. Base on the information and the treatment you have selected, the predictions of survival status{{years}}'}
field :surgery_only_texts ,type:Hash ,default:{'zh_tw'=>'100 位只接受根除性手術的婦女中,有{{Surgery_only}}位婦女,術後{{surgery_year}}年仍為存活','en'=>'after surgery are as follows:<br/>{{Surgery_only}} out of 100 women treated with surgery only are alive at {{surgery_year}} years.'}
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:[1,3,5]
#field :image_uploader ,type:Object
scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc],[:postdate, :desc])}
scope :is_approved, ->{where(:approved => true)}
before_create :delete_empty_font ,:get_font_to_store,:set_un_used_font , :set_used_font
before_update :delete_empty_font ,:get_font_to_store,:set_un_used_font , :set_used_font
before_save :delete_empty_font ,:get_font_to_store,:set_un_used_font , :set_used_font
after_update :set_config
after_save :set_config
#before_create :set_expire
def delete_empty_font
self.font_array.each do |font,istrue|
if font.strip == ""
self.font_array.delete(font)
end
end
end
def update_user
User.find(update_user_id) rescue nil
end

View File

@ -0,0 +1,21 @@
class Cancerpredictrecord
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include OrbitModel::Impression
# encoding: utf-8
include OrbitTag::Taggable
include OrbitCategory::Categorizable
field :title ,type:String ,default:""
field :submit_time ,type:String ,default:""
field :result , type:Hash , default:{}
field :names , type:Hash , default:{}
field :values , type:Hash , default:{}
field :submit_numbers , type:Fixnum , default: 1
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_save :set_submit_times
def set_submit_times
self.submit_time = Cancerpredictrecord.where(:title=> "cancerpredict").length + 1
end
end

View File

@ -0,0 +1,33 @@
# encoding: utf-8
require 'carrierwave/processing/mime_types'
class HeadImagesUploader < CarrierWave::Uploader::Base
include CarrierWave::MimeTypes
process :set_content_type
# Include RMagick or ImageScience support:
# include CarrierWave::RMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
# storage :file
# storage :s3
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
return "uploads/#{model.class.to_s.underscore}/predict_tool"
end
# override
def filename
@original_filename
end
def cache_dir
"#{Rails.root}/tmp/uploads"
end
end

13
app/models/headimages.rb Normal file
View File

@ -0,0 +1,13 @@
class Headimages
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include OrbitModel::Impression
# encoding: utf-8
include OrbitTag::Taggable
include OrbitCategory::Categorizable
mount_uploader :temp_file, HeadImagesUploader
field :cancerpredictfields_id ,type:String ,default:""
field :title ,type:String ,default:""
field :sort_number ,type:Integer ,default: 0
end

View File

@ -0,0 +1,30 @@
<div class="control-group">
<div class="controls">
<!-- if this page editing please add class "fileupload-edit" -->
<div class="fileupload fileupload-new clearfix" data-provides="fileupload">
<span class="show_span"><%= t('cancerpredict.sort_num')+': ' %></span>
<%= f.text_field 'sort_number',{:class=>'sort_num',:value=>((image_form['sort_number'] == nil) ? i+1 : image_form['sort_number'] ),:style=>'float: left;width: 3em;'} %>
<span class="show_span"><%= t('cancerpredict.logo')+': ' %></span>
<div class="fileupload-new thumbnail pull-left">
<% if image_form.temp_file.file.present? %>
<%= image_tag( image_form.temp_file, :size=>"120x120") rescue ''%>
<% else %>
<%= image_tag "/assets/site-logo.png", :class => "pull-left upload-picture"%>
<% end %>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<% if image_form.temp_file.file.present?%>
<span class="btn btn-file">
<%= f.file_field :temp_file, {:id => "input-upload", :class => 'fileupload-new', :accept=> 'image/png,image/gif,image/jpeg'} %><%= t('preferences.change') %>
</span>
<%= f.check_box :remove_image,{:checked=>false} %>
<%= t(:remove) %> <%= (I18n.locale.to_s == 'en') ? ' this logo' : '該logo' %>
<%else%>
<span class="btn btn-file">
<%= f.file_field :temp_file,{ :id => "input-upload", :class => 'fileupload-new', :accept=> 'image/png,image/gif,image/jpeg'} %><%= t('preferences.select_image') %>
</span>
<%end%>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
</div>
</div>
</div>

View File

@ -1,225 +1,268 @@
<%= stylesheet_link_tag "lib/fileupload"%>
<%= javascript_include_tag 'lib/bootstrap-fileupload' %>
<div style="clear:both;"></div>
<% @i = 0 %>
<button id="clickall"><%= (I18n.locale.to_s == "zh_tw") ? "全選" : "select all" %></button>
<button id="unclickall"><%= (I18n.locale.to_s == "zh_tw") ? "取消全選" : "unselect all" %></button>
<%=form_for @file_to_show ,:url=>{:controller=>"patchfiles" ,:action=>"edit"} do |file|%>
<%= file.fields_for :file_show do |filefield|%>
<div id="fileform">
<% @file_to_show.file_show.each do |name,property| %>
<span style="clear:both;">
<%if property[:status].to_i == 1%>
<%=filefield.check_box name,{:checked=>true,:id=>"checkbox"+@i.to_s,:class=>"checkbox",:style=>"float:left;"}%>
<%else%>
<%=filefield.check_box name,{:checked=>false,:id=>"checkbox"+@i.to_s,:class=>"checkbox",:style=>"float:left;"}%>
<%end%>
<label for="<%="checkbox"+@i.to_s%>" class="checklabel" style="float:left;"><%=name%></label>
<div style="clear:both;"></div>
<% @i = @i+1 %>
<% @j = 0 %>
<%= file.fields_for :sub_file_fields do |each_files|%>
<%= each_files.fields_for name do |each_file|%>
<% property[:files].each do |file_name,sub_property| %>
<%if sub_property[:status].to_i == 1%>
<%=each_file.check_box file_name,{:checked=>true,:id=>"checkbox"+@i.to_s,:class=>"sub_checkbox",:style=>"float:left;margin-left:1em;",:index=>@j}%>
<%else%>
<%=each_file.check_box file_name,{:checked=>false,:id=>"checkbox"+@i.to_s,:class=>"sub_checkbox",:style=>"float:left;margin-left:1em;",:index=>@j}%>
<%end%>
<% file_name = file_name.gsub("@",".") %>
<label for="<%="checkbox"+@i.to_s%>" class="sub_checklabel" style="float:left;"><%=file_name%></label>
<div style="clear:both;"></div>
<% @i = @i+1 %>
<% @j = @j+1 %>
<%=form_for @form_to_show ,:url=>{:controller=>"cancerpredicts" ,:action=>"edit"} do |form|%>
<span class="show_span"><%= t('cancerpredict.title') %></span>
<div style="clear:both;"></div>
<label class="label_left" for="title_text"><%= t('cancerpredict.title_text')+':' %></label>
<%=form.fields_for :title_texts do |locale_fields|%>
<%=locale_fields.text_field I18n.locale.to_s ,{:value => @form_to_show.title_texts[I18n.locale.to_s],:id=>"title_text"} %>
<% end %>
<% if @title_images.length != 0%>
<% @title_images.each_with_index do |temp_image,i| %>
<%= form.fields_for "title_images" do |image_fields| %>
<div class="image_field title_images" value="<%=(i+1).to_s%>">
<%= image_fields.fields_for i.to_s do |image_field| %>
<%= render :partial => 'image_form', :object => temp_image, :locals => {:f => image_field, :i => i} %>
<% if i.to_i == @title_images.length - 1%>
<script>
$(document).on('click', '#add_file.title_images', function(){
var old_id = $('.image_field.title_images').eq(-1).attr('value');
if( old_id == undefined)
old_id = 0;
else
old_id = Number(old_id);
var new_id = old_id + 1;
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => i}).gsub("\"","\'").html_safe %>"
$(this).parent().siblings('.add-target.title_images').before(('<div class="image_field title_images" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
var name = $('.image_field.title_images').eq(-1).find('[type="file"]').attr('name');
$('.image_field.title_images').eq(-1).find('[type="file"]').attr('name',name.replace("<%=i%>",new_id-1));
name = $('.image_field.title_images').eq(-1).find('input.sort_num').attr('name');
$('.image_field.title_images').eq(-1).find('input.sort_num').attr('name',name.replace("<%=i%>",new_id-1));
new_id = $('.image_field.title_images').eq(-2).find('input.sort_num').val();
$('.image_field.title_images').eq(-1).find('input.sort_num').val(Number(new_id)+1);
formTip();
});
</script>
<% end %>
<% end %>
<% end %>
<% end %>
<% else %>
<%= form.fields_for "title_images" do |image_fields| %>
<%= image_fields.fields_for "0" do |image_field| %>
<script>
$(document).on('click', '#add_file.title_images', function(){
var old_id = $('.image_field.title_images').eq(-1).attr('value');
if( old_id == undefined)
old_id = 0;
else
old_id = Number(old_id);
var new_id = old_id + 1;
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => 0}).gsub("\"","\'").html_safe %>"
$(this).parent().siblings('.add-target.title_images').before(('<div class="image_field title_images" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
var name = $('.image_field.title_images').eq(-1).find('[type="file"]').attr('name');
$('.image_field.title_images').eq(-1).find('[type="file"]').attr('name',name.replace("0",new_id-1));
name = $('.image_field.title_images').eq(-1).find('input.sort_num').attr('name');
$('.image_field.title_images').eq(-1).find('input.sort_num').attr('name',name.replace("0",new_id-1));
new_id = $('.image_field.title_images').eq(-2).find('input.sort_num').val();
if(new_id != undefined)
$('.image_field.title_images').eq(-1).find('input.sort_num').val(Number(new_id)+1);
else
$('.image_field.title_images').eq(-1).find('input.sort_num').val(1);
formTip();
});
</script>
<% end %>
<% end %>
<% end %>
<div class="add-target title_images"></div>
<p class="add-btn">
<%= hidden_field_tag 'title_images_count', @title_images.count %>
<a id="add_file" class="title_images trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t('cancerpredict.add_image') %></a>
</p>
<span class="show_span"><%= t('cancerpredict.tool_head_pictures') %></span>
<div style="clear:both;"></div>
<% if @head_images.length != 0%>
<% @head_images.each_with_index do |temp_image,i| %>
<%= form.fields_for "head_images" do |image_fields| %>
<div class="head_images image_field" value="<%=(i+1).to_s%>">
<%= image_fields.fields_for i.to_s do |image_field| %>
<%= render :partial => 'image_form', :object => temp_image, :locals => {:f => image_field, :i => i} %>
<% if i.to_i == @head_images.length - 1%>
<script>
$(document).on('click', '#add_file.head_images', function(){
var old_id = $('.image_field').eq(-1).attr('value');
if( old_id == undefined)
old_id = 0;
else
old_id = Number(old_id);
var new_id = old_id + 1;
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => i}).gsub("\"","\'").html_safe %>"
$(this).parent().siblings('.add-target.head_images').before(('<div class="image_field" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
var name = $('.image_field').eq(-1).find('[type="file"]').attr('name');
$('.image_field').eq(-1).find('[type="file"]').attr('name',name.replace("<%=i%>",new_id-1));
name = $('.image_field').eq(-1).find('input.sort_num').attr('name');
$('.image_field').eq(-1).find('input.sort_num').attr('name',name.replace("<%=i%>",new_id-1));
new_id = $('.image_field').eq(-2).find('input.sort_num').val();
$('.image_field').eq(-1).find('input.sort_num').val(Number(new_id)+1);
formTip();
});
</script>
<% end %>
<% end %>
<% end %>
<% end %>
<% else %>
<%= form.fields_for "head_images" do |image_fields| %>
<%= image_fields.fields_for "0" do |image_field| %>
<script>
$(document).on('click', '#add_file.head_images', function(){
var old_id = $('.image_field.head_images').eq(-1).attr('value');
if( old_id == undefined)
old_id = 0;
else
old_id = Number(old_id);
var new_id = old_id + 1;
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => 0}).gsub("\"","\'").html_safe %>"
$(this).parent().siblings('.add-target.head_images').before(('<div class="image_field head_images" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
var name = $('.image_field.head_images').eq(-1).find('[type="file"]').attr('name');
$('.image_field.head_images').eq(-1).find('[type="file"]').attr('name',name.replace("0",new_id-1));
name = $('.image_field.head_images').eq(-1).find('input.sort_num').attr('name');
$('.image_field.head_images').eq(-1).find('input.sort_num').attr('name',name.replace("0",new_id-1));
new_id = $('.image_field.head_images').eq(-2).find('input.sort_num').val();
if(new_id != undefined)
$('.image_field.head_images').eq(-1).find('input.sort_num').val(Number(new_id)+1);
else
$('.image_field.head_images').eq(-1).find('input.sort_num').val(1);
formTip();
});
</script>
<% end %>
<% end %>
<% end %>
<div class="add-target head_images"></div>
<p class="add-btn">
<%= hidden_field_tag 'head_images_count', @head_images.count %>
<a id="add_file" class="head_images trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t('cancerpredict.add_image') %></a>
</p>
<span class="show_span"><%= t('cancerpredict.text_descibe') %></span>
<div style="clear:both;"></div>
<%= form.fields_for 'text_descibe' do |locale_fields|%>
<%= locale_fields.text_field I18n.locale.to_s,{:value=> @form_to_show.text_descibe[I18n.locale.to_s],:style=>'width:100%;'} %>
<%end%>
<span class="show_span"><%= t('cancerpredict.font_size') %></span>
<div style="clear:both;"></div>
<% @size=['small','medium','large'] %>
<% @size.each do |size|%>
<%= form.fields_for size do |make_size| %>
<div><label class="label_left" for=<%='font_'+size%>><%=t('cancerpredict.'+size)+':'%></label><%= make_size.text_field 'font_size',{:value=> @form_to_show[size]['font_size'],:id=>'font_'+size} %>
<% if @form_to_show[size]['active'].to_i == 1%>
<%= make_size.check_box 'active',{:checked=>true,:class=>"checkbox text_choice",:style=>"float:left;"}%></div>
<% else%>
<%= make_size.check_box 'active',{:checked=>false,:class=>"checkbox text_choice",:style=>"float:left;"}%></div>
<%end%>
<%end%>
<%end%>
<span class="show_span"><%= t('cancerpredict.Input_fields') %></span>
<div style="clear:both;"></div>
<table>
<thead>
<tr>
<% @form_to_show.form_show.values[1].each do |key,vlaue|%>
<th><%=key%></th>
<%end%>
</tr>
</thead>
<tbody>
<%= 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>
<%end%>
<%end%>
</span>
<%end%>
</div>
</tbody>
</table>
<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>
<% if @form_to_show.form_result_is_right.to_i == 1%>
<div><%= form.check_box "form_result_is_right",{:checked=>true,:class=>"checkbox",:style=>"float: left;position: relative;left: 0;transform: none!important;margin-left: 1em;",:id=>"form_result_is_right"}%></div>
<% else%>
<div><%= form.check_box "form_result_is_right",{:checked=>false,:class=>"checkbox",:style=>"float: left;position: relative;left: 0;transform: none!important;margin-left: 1em;",:id=>"form_result_is_right"}%></div>
<%end%>
<%=file.submit "#{t(:updatefont)}",{:id=>"updatebtn",:onclick=>"return updatefcn()"}%>
<%=file.text_field :recovery_btn, {:id=>"hidden-recovery",:type => "hidden",:value=>"false"} %>
<%=file.text_field :refresh_btn, {:id=>"hidden-refresh",:type => "hidden",:value=>"false"} %>
<button id="seemessage" onclick="return seelogfcn()"><%=(I18n.locale.to_s =="zh_tw") ? "查看上次更新的logs" : "see logs of prev update "%></button>
<button id="recoverybtn" onclick="return recoveryfcn()"><%=(I18n.locale.to_s =="zh_tw") ? "復原到上次更新的檔案狀態" : "recovery to prev file status"%></button>
<button id="destroy_mongofield" onclick="return destroy_mongofield_fcn()"><%=(I18n.locale.to_s =="zh_tw") ? "刷新可更新的檔案狀態" : "refresh the status of the update files"%></button>
<div style="clear:both;"></div>
<% @create_items = ['years','table_above_texts','text_above_texts','surgery_only_texts','extra_texts','extra_therapy_texts','danger_texts'] %>
<% @create_items.each do |item|%>
<label for="<%=item%>" style="float: left;margin-right:1em;"><%= t('cancerpredict.'+item)+':' %></label>
<% if @form_to_show[item].class == BSON::Document || @form_to_show[item].class == Hash %>
<%= form.fields_for item do |locale_fields|%>
<%= locale_fields.text_field I18n.locale.to_s,{:value=>@form_to_show[item][I18n.locale.to_s] ,:id=> item} %>
<% end %>
<% else %>
<%= form.text_field item,{:value=>@form_to_show[item],:id=> item} %>
<% end %>
<div style="clear:both;"></div>
<% end %>
<table>
<thead>
<tr>
<% @form_to_show.form_show_in_result.values[1].each do |key,vlaue|%>
<th><%=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|%>
<% @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>
<%end%>
<%end%>
<%end%>
</tbody>
</table>
<%=form.submit "#{t(:updatefont)}",{:id=>"updatebtn"}%>
<%end%>
<a>網站目錄根路徑:<%=Dir.pwd.to_s%></a>
<li id ="ckeditorFont" class="show_li">
<a title="CKEDITOR現有字形">CKEDITOR現有字形</a>
<% @ckicktosee_str = (I18n.locale.to_s == "en") ? "click me to see all font which CKEDITOR have now" : "點擊我來查看編輯器所有目前擁有的字形" %>
<a id="clicktosee" title="<%= @ckicktosee_str %>" class="Toggleclass"><%= @ckicktosee_str %></a>
<ul>
<% @font_array.each do |font|%>
<li><a title="<%= font %>"><%= font %></a></li>
<%end%>
</ul>
</li>
<a></a>
<style type="text/css">
.show_li,.show_li *{
list-style:none;
color:balck;
}
.show_li ul{
display:none;
}
#clicktosee{
color:blue;
cursor:pointer;
}
</style>
<link href="/assets/admin/cancerpredict.css" media="screen" rel="stylesheet">
<script>
$('.Toggleclass').off("click").on("click",function(){
$(this).parent().find(">ul").slideToggle();
$('.text_choice').click(function(){
$('.text_choice').prop('checked' , false);
$(this).prop('checked' , true);
});
$('.checkbox').off('click').on('click',function(){
for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){
if($(this).is(":checked") == false){
if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == true)
$(this).parent().find('.sub_checkbox').eq(i).click();
}else{
if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == false)
$(this).parent().find('.sub_checkbox').eq(i).click();
};
};
});
$('.sub_checkbox').off('click').on('click',function(){
var num = 0;
var index = 0;
for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){
if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == true){
num += 1;
};
};
if( num == $(this).parent().find('.sub_checkbox').length){
if( $(this).parent().find('.checkbox').is(":checked") == false)
$(this).parent().find('.checkbox').click();
}else{
if( $(this).parent().find('.checkbox').is(":checked") == true){
$(this).parent().find('.checkbox').click();
for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){
if($(this).parent().find('.sub_checkbox').eq(i).attr('id') != $(this).attr('id'))
$(this).parent().find('.sub_checkbox').eq(i).click();
}
};
}
});
$("#clickall").off("click").on("click",function(){
for(var i =0;i<$(".sub_checkbox").length ; i++){
if($(".checkbox").eq(i).is(":checked") == false)
$(".checkbox").eq(i).click();
}
});
$("#unclickall").off("click").on("click",function(){
for(var i =0;i<$(".sub_checkbox").length ; i++){
if($(".checkbox").eq(i).is(":checked") == true)
$(".checkbox").eq(i).click();
}
});
function seelogfcn(){
if($( "#dialog-confirm" ).length != 0)
$( "#dialog-confirm" ).remove();
if(I18n.locale == "zh_tw"){
$('body').after("<div id='dialog-confirm' title='上次更新的logs'></div>");
}else{
$('body').after("<div id='dialog-confirm' title='logs of prev update'></div>");
};
$( "#dialog-confirm" ).append($.parseHTML("<%= @file_to_show.last_message.gsub("\"","\'").html_safe %>"));
$( "#dialog-confirm" ).dialog({
resizable: true,
height:200,
modal: true,
buttons: {
<%=(I18n.locale == "zh_tw") ? "確認" : "confirm"%>: function(){
$( this ).dialog( "close" );
},
<%=(I18n.locale == "zh_tw") ? "取消" : "Cancel"%>: function() {
$( this ).dialog( "close" );
}
}
});
return false;
};
function updatefcn(){
var str="";
var num =1;
for(var i =0;i<$(".sub_checkbox").length ; i++){
if($(".sub_checkbox").eq(i).is(":checked") == true){
str += ("</br><i style='color:red;'>"+num+". "+$(".sub_checklabel").eq(i).html()+"</i>");
num += 1;
}
}
if($( "#dialog-confirm" ).length != 0)
$( "#dialog-confirm" ).remove();
if(I18n.locale == "zh_tw"){
$('body').after("<div id='dialog-confirm' title='你確定要更新嗎?'>"+
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+
"按下確認鍵後,你將更新你所選的檔案。"+str+"</p>"
+"</div>");
}else{
$('body').after("<div id='dialog-confirm' title='Are you sure to update'>"+
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+
"After click confirm button,you will update the selected file."+str+"</p>"
+"</div>");
};
$( "#dialog-confirm" ).dialog({
resizable: true,
height:200,
modal: true,
buttons: {
<%=(I18n.locale == "zh_tw") ? "確認" : "confirm"%>: function(){
$( this ).dialog( "close" );
$('.edit_filefield').submit();
},
<%=(I18n.locale == "zh_tw") ? "取消" : "Cancel"%>: function() {
$( this ).dialog( "close" );
}
}
});
return false;
};
function recoveryfcn(){
var str="";
var num =1;
for(var i =0;i<$(".sub_checkbox").length ; i++){
if($(".sub_checkbox").eq(i).is(":checked") == true){
str += ("</br><i style='color:red;'>"+num+". "+$(".sub_checklabel").eq(i).html()+"</i>");
num += 1;
}
}
if($( "#dialog-confirm" ).length != 0)
$( "#dialog-confirm" ).remove();
if(I18n.locale == "zh_tw"){
$('body').after("<div id='dialog-confirm' title='你確定要還原嗎?'>"+
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+
"按下確認鍵後,你將還原你所選的檔案。"+str+"</p>"
+"</div>");
}else{
$('body').after("<div id='dialog-confirm' title='Are you sure to recover'>"+
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+
"After click confirm button,you will recover the selected file."+str+"</p>"
+"</div>");
}
$( "#dialog-confirm" ).dialog({
resizable: true,
height:200,
modal: true,
buttons: {
<%=(I18n.locale == "zh_tw") ? "確認" : "confirm"%>: function(){
$('#hidden-recovery').val("true");
$( this ).dialog( "close" );
$('.edit_filefield').submit();
},
<%=(I18n.locale == "zh_tw") ? "取消" : "Cancel"%>: function() {
$('#hidden-recovery').val("false");
$( this ).dialog( "close" );
}
}
});
return false;
};
function destroy_mongofield_fcn(){
$('#hidden-refresh').val('true');
};
</script>

View File

@ -0,0 +1,81 @@
<table>
<thead>
<tr>
<% if !@results[0].nil? %>
<% @results[0].names.each do |key,name|%>
<th><%=name[I18n.locale.to_s].to_s.html_safe %></th>
<%end%>
<%end%>
</tr>
</thead>
<tbody>
<% @key_len = @results[0].names.length %>
<% @results.each do |result| %>
<% if result.names.length != @key_len %>
</tbody>
</table>
<table>
<thead>
<tr>
<% result.names.each do |key,name|%>
<th><%=name[I18n.locale.to_s].to_s.html_safe %></th>
<%end%>
</tr>
</thead>
<tbody>
<% end %>
<tr>
<% result.result.each do |key,value| %>
<% @key_len %>
<% if key != "locale" %>
<% if result.values[key][I18n.locale.to_s].length == 0 %>
<td><%= value.to_s %></td>
<% else %>
<td><%= result.values[key][I18n.locale.to_s][value.to_i-1] rescue value %></td>
<% end %>
<% end %>
<%end%>
</tr>
<%end%>
</tbody>
</table>
<style type="text/css">
thead > tr > th{
border:1px solid;
background: bisque;
}
tbody{
background:white;
}
tbody > tr > td{
border:1px solid;
position: relative;
}
.show_li,.show_li *{
list-style:none;
color:balck;
}
.show_li ul{
display:none;
}
#clicktosee{
color:blue;
cursor:pointer;
}
.checkbox{
left: 50%;
position: absolute;
transform: translate(-50%, -50%) !important;
top: 50%;
}
#updatebtn{
margin-top: 1em;
position: fixed;
right: 1em;
background-color: rgb(210, 105, 0);
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
}
</style>

View File

@ -1,9 +0,0 @@
<script src="/assets/react.js"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.min.js"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.bootstrap.min.js"></script>
<div id="app">
<div class="loader-overlay">
<div class="loader" id="loader-1">&nbsp;</div>
<div class="loader-text" id="id-loader-text">Loading...</div>
</div>
</div>

View File

@ -1,18 +1,65 @@
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "cancerpredict/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "cancerpredict"
s.version = Cancerpredict::VERSION
s.authors = ["Ruling Digital"]
s.email = ["orbit@rulingcom.com"]
s.homepage = "http://www.rulingcom.com"
s.summary = "Cancer_Predict for Orbit"
s.description = "Cancer_Predict for Orbit"
s.license = "MIT"
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
# -*- encoding: utf-8 -*-
# stub: cancerpredict 0.0.1 ruby lib
routes_text = File.read(ENV['PWD']+'/config/routes.rb')
insert_texts = ['get "cancerpredictResult",to: "cancerpredicts#calculate"','post "cancerpredictResult",to: "cancerpredicts#calculate"']
insert_flag = 0
insert_texts.each do |insert_text|
if !routes_text.include?(insert_text)
insert_index = routes_text.index('get "/admin/license_denied" => "store_api#render_license_denied"')
routes_text.insert(insert_index,insert_text+"\n")
insert_flag = 1
end
end
app_path = File.expand_path(__dir__)
if insert_flag == 1
f = File.open(ENV['PWD']+'/config/routes.rb','w')
f.write(routes_text)
f.close
end
template_path = ENV['PWD'] + '/app/templates'
all_template = Dir.glob(template_path+'/*/')
puts 'copying module'
check_texts = '<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/js/bootstrap.min.js"%>'
edit_texts = '<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"%>'
all_template.each do |folder|
if !folder.include?('mobile')
if folder.split('/')[-1] != 'mobile'
begin
system ('cp -r '+ app_path + '/modules/. ' + folder+'/modules/.')
rescue
puts 'error copy'
end
end
texts = File.read(folder+'partial/_head.html.erb')
insert_flag = 0
if texts.include?(check_texts)
texts = texts.gsub(check_texts,edit_texts)
insert_flag = 1
end
if insert_flag == 1
puts 'editing _head.html.erb'
f = File.open(folder+'partial/_head.html.erb','w')
f.write(texts)
f.close
end
end
end
Gem::Specification.new do |s|
s.name = "cancerpredict"
s.version = "0.0.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["Ruling Digital"]
s.date = "2019-12-09"
s.description = "Cancer_Predict for Orbit"
s.email = ["orbit@rulingcom.com"]
s.files = ["MIT-LICENSE", "README.rdoc", "Rakefile", "app/assets/images/cancerpredict", "app/assets/images/cancerpredict/triangle_add.png", "app/assets/images/cancerpredict/triangle_sub.png", "app/assets/javascripts/admin/cancerpredict.js", "app/assets/javascripts/cancer_predict.js", "app/assets/javascripts/jquery.smartmenus.bootstrap.min.js", "app/assets/javascripts/jquery.smartmenus.min.js", "app/assets/javascripts/react.js", "app/assets/stylesheets/admin/cancerpredict.css", "app/assets/stylesheets/cancer_predict.css", "app/controllers/admin/cancerpredicts_controller.rb", "app/controllers/cancerpredicts_controller.rb", "app/helpers/admin/cancerpredicts_helper.rb", "app/models/cancerpredictfields.rb", "app/views/admin/cancerpredicts", "app/views/admin/cancerpredicts/_form.html.erb", "app/views/admin/cancerpredicts/_form_file.html.erb", "app/views/admin/cancerpredicts/_form_link.html.erb", "app/views/admin/cancerpredicts/_index.html.erb", "app/views/admin/cancerpredicts/index.html.erb", "app/views/admin/cancerpredicts/new.html.erb", "app/views/admin/cancerpredicts/settings.html.erb", "app/views/admin/cancerpredicts/update.html.erb", "app/views/cancerpredicts", "app/views/cancerpredicts/index.html.erb", "config/locales/en.yml", "config/locales/zh_tw.yml", "config/routes.rb", "lib/cancerpredict", "lib/cancerpredict.rb", "lib/cancerpredict/engine.rb", "lib/cancerpredict/version.rb", "lib/tasks/cancerpredict_tasks.rake", "test/cancerpredict_test.rb", "test/controllers/admin/cancerpredicts_controller_test.rb", "test/dummy", "test/dummy/README.rdoc", "test/dummy/Rakefile", "test/dummy/app", "test/dummy/app/assets", "test/dummy/app/assets/images", "test/dummy/app/assets/javascripts", "test/dummy/app/assets/javascripts/application.js", "test/dummy/app/assets/stylesheets", "test/dummy/app/assets/stylesheets/application.css", "test/dummy/app/controllers", "test/dummy/app/controllers/application_controller.rb", "test/dummy/app/controllers/concerns", "test/dummy/app/helpers", "test/dummy/app/helpers/application_helper.rb", "test/dummy/app/mailers", "test/dummy/app/models", "test/dummy/app/models/concerns", "test/dummy/app/views", "test/dummy/app/views/layouts", "test/dummy/app/views/layouts/application.html.erb", "test/dummy/bin", "test/dummy/bin/bundle", "test/dummy/bin/rails", "test/dummy/bin/rake", "test/dummy/config", "test/dummy/config.ru", "test/dummy/config/application.rb", "test/dummy/config/boot.rb", "test/dummy/config/environment.rb", "test/dummy/config/environments", "test/dummy/config/environments/development.rb", "test/dummy/config/environments/production.rb", "test/dummy/config/environments/test.rb", "test/dummy/config/initializers", "test/dummy/config/initializers/backtrace_silencers.rb", "test/dummy/config/initializers/cookies_serializer.rb", "test/dummy/config/initializers/filter_parameter_logging.rb", "test/dummy/config/initializers/inflections.rb", "test/dummy/config/initializers/mime_types.rb", "test/dummy/config/initializers/session_store.rb", "test/dummy/config/initializers/wrap_parameters.rb", "test/dummy/config/locales", "test/dummy/config/locales/en.yml", "test/dummy/config/routes.rb", "test/dummy/config/secrets.yml", "test/dummy/lib", "test/dummy/lib/assets", "test/dummy/log", "test/dummy/public", "test/dummy/public/404.html", "test/dummy/public/422.html", "test/dummy/public/500.html", "test/dummy/public/favicon.ico", "test/helpers/admin/cancerpredicts_helper_test.rb", "test/integration/navigation_test.rb", "test/test_helper.rb"]
s.homepage = "http://www.rulingcom.com"
s.licenses = ["MIT"]
s.rubygems_version = "2.2.2"
s.summary = "Cancer_Predict for Orbit"
s.test_files = ["test/cancerpredict_test.rb", "test/dummy", "test/dummy/README.rdoc", "test/dummy/bin", "test/dummy/bin/bundle", "test/dummy/bin/rake", "test/dummy/bin/rails", "test/dummy/log", "test/dummy/app", "test/dummy/app/assets", "test/dummy/app/assets/javascripts", "test/dummy/app/assets/javascripts/application.js", "test/dummy/app/assets/images", "test/dummy/app/assets/stylesheets", "test/dummy/app/assets/stylesheets/application.css", "test/dummy/app/mailers", "test/dummy/app/helpers", "test/dummy/app/helpers/application_helper.rb", "test/dummy/app/controllers", "test/dummy/app/controllers/application_controller.rb", "test/dummy/app/controllers/concerns", "test/dummy/app/views", "test/dummy/app/views/layouts", "test/dummy/app/views/layouts/application.html.erb", "test/dummy/app/models", "test/dummy/app/models/concerns", "test/dummy/Rakefile", "test/dummy/lib", "test/dummy/lib/assets", "test/dummy/public", "test/dummy/public/422.html", "test/dummy/public/500.html", "test/dummy/public/favicon.ico", "test/dummy/public/404.html", "test/dummy/config.ru", "test/dummy/config", "test/dummy/config/environments", "test/dummy/config/environments/production.rb", "test/dummy/config/environments/development.rb", "test/dummy/config/environments/test.rb", "test/dummy/config/environment.rb", "test/dummy/config/boot.rb", "test/dummy/config/routes.rb", "test/dummy/config/application.rb", "test/dummy/config/secrets.yml", "test/dummy/config/locales", "test/dummy/config/locales/en.yml", "test/dummy/config/initializers", "test/dummy/config/initializers/wrap_parameters.rb", "test/dummy/config/initializers/cookies_serializer.rb", "test/dummy/config/initializers/mime_types.rb", "test/dummy/config/initializers/inflections.rb", "test/dummy/config/initializers/backtrace_silencers.rb", "test/dummy/config/initializers/filter_parameter_logging.rb", "test/dummy/config/initializers/session_store.rb", "test/test_helper.rb", "test/helpers/admin/cancerpredicts_helper_test.rb", "test/controllers/admin/cancerpredicts_controller_test.rb", "test/integration/navigation_test.rb"]
s.installed_by_version = "2.2.2" if s.respond_to? :installed_by_version
end

View File

@ -1,6 +1,27 @@
en:
cancerpredict:
cancerpredict: Predict breast cancer
cancerpredict: adjust the predict breast cancer tool
submitResult: see submit results of the users
result_is_right: Is therapy choices in the right hand side of result block?
text_descibe: text descibe
font_size: font size
small: small
medium: medium
large: large
Input_fields: User input fields' contents
tool_head_pictures: All the logos in the page of predict tool
sort_num: sort num
logo: logo image
title: title of the page of predict tool
title_text: title texts
add_image: add image
years: Years
table_above_texts: Texts above table
text_above_texts: Texts above text
surgery_only_texts: Surgery only texts
extra_texts: Extra texts
extra_therapy_texts: Extra therapy texts
danger_texts: Warning texts
table:
welcome: Welcome to The after breast cancer healing system of Taiwanprepare!\nTo start, please enter the relevant information below.
Reset: Reset
@ -24,4 +45,10 @@ en:
Surgeryonly: Surgery only
Hormonetherapy: Hormone therapy
Chemotherapy: Chemotherapy
years: years
years: years
result: Results
table: Table
curve: Curves
text: Texts
Therapy_choice: Treatment options

View File

@ -1,10 +1,31 @@
zh_tw:
cancerpredict:
cancerpredict: 乳癌預測
cancerpredict: 乳癌預測工具調整
submitResult: 查看用戶繳交表單結果
result_is_right: 治療選項在結果的右邊?
text_descibe: 文字說明
font_size: 字體
small:
medium:
large:
Input_fields: 使用者輸入欄位內容
tool_head_pictures: 預測工具頁面最上方的所有logo
sort_num: 順序號碼
logo: logo圖片
title: 預測工具頁面標題
title_text: 標題文字
add_image: 新增圖片
years:
table_above_texts: 在表格上方的文字
text_above_texts: 在文字區塊上方的文字
surgery_only_texts: 純手術的文字
extra_texts: 額外文字
extra_therapy_texts: 額外治療的文字
danger_texts: 警告文字
table:
welcome: 歡迎使用台灣準備乳癌癒後系統!\n若要開始 請在下方輸入相關資訊
Reset: 重置
Submit: 提交
Submit: 送出
age: 確認年齡
Menopausal: 更年期狀態
ER: ER狀態
@ -25,4 +46,9 @@ zh_tw:
Surgeryonly: 純手術
Hormonetherapy: 賀爾蒙治療
Chemotherapy: 化學治療
years:
years:
result: 結果
table: 列表
curve: 曲線
text: 文字
Therapy_choice: 治療選項

View File

@ -5,7 +5,10 @@ Rails.application.routes.draw do
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do
get 'cancerpredicts' , to: 'cancerpredicts#index'
get 'editCancerpredicts' , to: 'cancerpredicts#edit'
post 'editCancerpredicts' , to: 'cancerpredicts#edit'
patch 'editCancerpredicts' , to: 'cancerpredicts#edit'
get 'cancerpredicts/showSubmit' , to: 'cancerpredicts#showSubmit'
resources :cancerpredicts
end
end

View File

@ -1,230 +0,0 @@
<% if params[:is_frontend_view] == "true" %>
<% OrbitHelper.render_css_in_head(["basic/icon","lib/orbit_bar/orbit-bar"]) %>
<% else %>
<%= stylesheet_link_tag "basic/icon" %>
<%= stylesheet_link_tag "lib/orbit_bar/orbit-bar" %>
<% end %>
<div id="orbit-bar">
<% if current_user.nil? %>
<label for="open-orbit-login" style="display:none;">Open login</label>
<input type="checkbox" title="open login" id="open-orbit-login">
<label for="open-orbit-login" class="cover"></label>
<div class="login-window">
<div class="login-header">
<label for="open-orbit-login" class="close">×</label>
<h3><%= t(:login_orbit) %></h3>
</div>
<div class="login-body">
<%= form_tag "/sessions?locale=#{locale.to_s}", method: "post", :class => "container" do |f| %>
<div class="prepend input-group">
<span class="add input-group-addon"><i class="icon-user"></i></span>
<label for="user_user_id" style="display:none;">Username</label>
<input class="input" id="user_user_id" title="username" name="user_name" placeholder="<%= t("users.user_id") %>" size="30" title="username" type="text">
</div>
<div class="prepend input-group">
<span class="add input-group-addon"><i class="icon-lock"></i></span>
<label for="user_password" style="display:none;">Password</label>
<input class="input" id="user_password" name="password" placeholder="<%= t(:password) %>" title="password" size="30" type="password">
</div>
<div class="login-submit-wrap">
<div class="submit">
<button class="login-btn" type="submit"><%= t(:login) %></button>
</div>
<% if current_site.google_oauth_enabled %>
<div class="google-login">
<a class="login-btn" href="/auth/google_oauth2">
<i class="fa fa-google-plus"></i> Sign in
</a>
</div>
<% end %>
</div>
<% if !current_site.sign_up_roles.empty? %>
<div class="login-sign-up-btn"><a href="/users/new" rel="nofollow">Sign up now</a></div>
<% end %>
<% end %>
</div>
</div>
<% end %>
<input type="checkbox" id="open-orbit-nav" title="orbitbar">
<div class="orbit-bar-inner">
<label for="open-orbit-nav">
<i class="icons-list-2"></i>
</label>
<h2 class="orbit-bar-title">
<a href="/"><%= current_site.mobile_orbit_bar_title.nil? || current_site.mobile_orbit_bar_title == "" ? "Orbit" : current_site.mobile_orbit_bar_title %></a>
</h2>
<ul class="orbit-bar-menu">
<li>
<span class="orbit-bar-logo">
<img src="<%= current_site.default_image.url.nil? ? '/assets/orbit-logo.png' : current_site.default_image.url %>" alt="Orbit Bar Logo" />
</span>
<% if !current_user.nil? %>
<ul>
<li>
<a href="/<%= locale.to_s %>/admin/dashboards">
<i class="icons-gauge"></i> <%= t(:dashboard_) %>
</a>
</li>
<li>
<a href="/<%= locale.to_s %>/admin/members?at=thumbnail">
<i class="icons-users"></i> <%= t(:community_) %>
</a>
</li>
<% if current_user.is_admin? %>
<li class="divider"></li>
<li>
<a href="/<%= locale.to_s %>/admin/sites" tabindex="-1">
<i class="icons-cog"></i> <%= t(:settings) %>
</a>
</li>
<% end %>
</ul>
<% end %>
</li>
<li>
<a href="/" class="orbit-bar-home">
<i class="icons-house"></i>
</a>
</li>
<% if !current_user.nil? && current_user.is_admin? && TicketStatus.unread.count > 0 %>
<li>
<a href="/admin/sites" class="orbit-bar-notification">
<i class="icons-mail"></i>
</a>
</li>
<% end %>
</ul>
<ul class="link1" style="width: 240px;float: left;">
<li><a href="/">回首頁</a></li>
<li><a href="https://www.nccu.edu.tw/app/home.php">政治大學</a></li>
<li><a href="/zh_tw/sitemap">網站導覽</a></li>
</ul>
<ul class="orbit-bar-search-sign-language">
<%
google_search_cx = current_site.search['sitesearch'] rescue nil
is_google_seach_cx = google_search_cx =~ /^[0-9]+\:[0-9A-Za-z]+$/
if !google_search_cx.blank? and is_google_seach_cx
%>
<li>
<form id="search" method="get" action="http://www.google.com/cse" target="_blank">
<input type="hidden" name="cx" value="<%= google_search_cx %>">
<label style="display:none;" for="q">Google Search</label>
<%= text_field_tag 'q', '', {:type => "search", :placeholder => t("search.sitesearch"), 'x-webkit-speech' => '', :title => "search"} %>
</form>
</li>
<%
else
if !google_search_cx.blank? and !is_google_seach_cx
search_domain = google_search_cx
else
search_domain = request.host_with_port
end
%>
<li>
<form id="search" method="get" action="http://www.google.com/custom" target="_blank">
<input type="hidden" name="client" value="pub-&amp" />
<input type="hidden" name="ie" id="ie" value="utf-8" />
<input type="hidden" name="oe" id="oe" value="utf-8" />
<input type="hidden" name="cof" id="cof" value="AH:center;AWFID:03de271f1940eea3;" />
<input type='hidden' name='domains' value='<%= search_domain %>'>
<input type='hidden' name='sitesearch' value='<%= search_domain %>'>
<label style="display:none;" for="q">Google Search</label>
<%= text_field_tag 'q', '', {:type => "search", :placeholder => t("search.sitesearch"), 'x-webkit-speech' => '', :title => "search"} %>
</form>
</li>
<% end %>
<li>
<% if current_site.enable_language_options %>
<% if @site_in_use_locales.count > 1 || current_site.enable_zh_cn %>
<% zh_cn_added = 0 %>
<% locale = session[:zh_cn] ? :zh_cn : I18n.locale %>
<span id="language"><i class="icons-earth orbit-bar-language-icon"></i><span class="orbit-bar-language-text">Language</span></span>
<ul>
<% @site_in_use_locales.each do |l| %>
<%
case l
when :en
accesskey = "e"
when :zh_tw
accesskey = "t"
end
%>
<% if l.to_s == I18n.locale.to_s and !session['zh_cn'] %>
<li class="<%= (l == I18n.locale and !session['zh_cn']) ? "active" : "" %>">
<%= t((l==:zh_tw ? :zh_tw_ : :_locale ), :locale => l) %>
</li>
<% else %>
<li class="<%= (l == I18n.locale and !session['zh_cn']) ? "active" : "" %>">
<a accesskey="<%= accesskey %>" href="<%= switch_language(l) %>"><%= t((l==:zh_tw ? :zh_tw_ : :_locale ), :locale => l) %></a>
</li>
<% end %>
<% if current_site.enable_zh_cn and zh_cn_added == 0 and !request.path.include?("/admin/") %>
<% zh_cn_added = 1 %>
<% accesskey = "s" %>
<% if locale == :zh_cn %>
<li class="active">
<%= t(:zh_cn, :locale => :zh_tw) %>
</li>
<% else %>
<li>
<a accesskey="<%= accesskey %>" href="<%= switch_language(:zh_cn) %>"><%= t(:zh_cn, :locale => :zh_tw) %></a>
</li>
<% end %>
<% end %>
<% end %>
</ul>
<% end %>
<% end %>
</li>
<% if !current_user.nil? %>
<li>
<span id="user"><%= current_user.member_profile.name.nil? ? current_user.user_name : current_user.member_profile.name rescue nil %></span>
<ul>
<li><%= link_to content_tag(:i, nil, class: 'icons-tools') + ' ' + t("users.change_passwd"),admin_member_edit_passwd_path(current_user.member_profile.to_param), tabindex: '-1' rescue nil%></li>
<li><%= link_to content_tag(:i, nil, class: 'icons-vcard') + ' ' + t("users.user_basic_data"),admin_member_path(current_user.member_profile.to_param), tabindex: '-1' rescue nil %></li>
<% if current_user.is_admin? && params[:is_frontend_view] == "true" %>
<li>
<% if params[:editmode] == "on" %>
<a tabindex="-1" href="<%= request.fullpath.split("?").first %>" style="color:red;"><i class="icons-bolt"></i>Edit Mode Off</a>
<% else %>
<a tabindex="-1" href="<%= request.fullpath + "#{(request.query_parameters.empty? ? "?" : "&")}editmode=on" %>"><i class="icons-bolt"></i>Edit Mode On</a>
<% end %>
</li>
<% end %>
<li>
<a href="/logout"><i class="icons-logout"></i><%= t(:logout) %></a>
</li>
</ul>
</li>
<% else %>
<li>
<a id="accesskey_login" class="sr-only" accesskey="L" href="/<%= "#{locale.to_s}" %>/accesskey" title="Login">:::</a>
<label for="open-orbit-login">
<i class="icons-login"></i>
</label>
</li>
<% end %>
</ul>
</div>
</div>
<script type="text/javascript">
$("#open-orbit-login").on("change",function(){
if($(this).is(":checked")){
$("#user_user_id").focus();
}
})
$(".login-body form").on("submit",function(){
$(this).append("<input type='hidden' name='referer_url' value='<%= request.original_url %>'/>");
})
<%
for_js = @site_in_use_locales.map{|l| l.to_s}
for_js << "zh_cn" if current_site.enable_zh_cn
%>
var I18n = {
get locale(){ return "<%= (session[:locale] == 'zh_tw' ? (session[:zh_cn] ? 'zh_cn' : 'zh_tw' ) : session[:locale]) %>"},
get validLocales(){return <%= for_js.to_json.html_safe %>},
set locale(v){return false},
set validLocales(v){return false}
};
</script>

View File

@ -21,6 +21,11 @@ module Cancerpredict
:priority=>1,
:active_for_action=>{'admin/cancerpredicts'=>'index'},
:available_for => 'users'
context_link 'cancerpredict.submitResult',
:link_path=>"admin_cancerpredicts_showSubmit_path" ,
:priority=>1,
:active_for_action=>{'admin/cancerpredicts'=>'show_submit'},
:available_for => 'users'
end
end
end

View File

@ -1,32 +1,7 @@
<div>
<%= javascript_include_tag "react.js"%>
<script type="text/javascript" src="/assets/jquery.smartmenus.min.js"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.bootstrap.min.js"></script>
<h3 class="w-cancer-tool__widget-title">
<span>{{widget-title}}</span>
</h3>
<div class="w-cancer-tool widget-cancerpredict-1">
<div class="w-cancer-tool" data-level="0" data-list="cancerpredict">
<div class="w-cancer-tool" data-level="1" data-list="cancerpredict">
<div id="app">
<div class="loader-overlay">
<div class="loader" id="loader-1">&nbsp;</div>
<div class="loader-text" id="id-loader-text">Loading...</div>
</div>
</div>
</div>
</div>
</div>
</div>
<style>
.form-group.has-error > :nth-child(3) {
border: 3px solid pink !important;
border-radius: 5px !important;
padding: 2px !important;
}
.form-group > :nth-child(3) {
border: 3px solid white !important;
border-radius: 5px !important;
padding: 2px !important;
}
</style>
<script type="text/javascript" src="/assets/jquery.smartmenus.min.js"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/cancer_predict.js"></script>
{{table}}
<link href="/assets/cancer_predict.scss" media="screen" rel="stylesheet">
<link href="/assets/bootstrap.min.print.css" media="print" rel="stylesheet">
<link href="/assets/cancer_predict_print.scss" media="print" rel="stylesheet">

View File

@ -1,28 +1,7 @@
<div>
<script src="/assets/react.js"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.min.js"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.bootstrap.min.js"></script>
<h1 class="i-cancer-title">{{page-title}}</h1>
<div class="i-cancer-tool widget-announcement-1">
<div class="i-cancer-tool" data-level="0" data-list="statuses">
<div id="app">
<div class="loader-overlay">
<div class="loader" id="loader-1">&nbsp;</div>
<div class="loader-text" id="id-loader-text">Loading...</div>
</div>
</div>
</div>
</div>
</div>
<style>
.form-group.has-error > :nth-child(3) {
border: 3px solid pink !important;
border-radius: 5px !important;
padding: 2px !important;
}
.form-group > :nth-child(3) {
border: 3px solid white !important;
border-radius: 5px !important;
padding: 2px !important;
}
</style>
<script type="text/javascript" src="/assets/jquery.smartmenus.min.js"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/cancer_predict.js"></script>
{{table}}
<link href="/assets/cancer_predict.scss" media="screen" rel="stylesheet">
<link href="/assets/bootstrap.min.print.css" media="print" rel="stylesheet">
<link href="/assets/cancer_predict_print.scss" media="print" rel="stylesheet">