Compare commits

...

49 Commits

Author SHA1 Message Date
邱博亞 5eeb34e336 Fix bug. 2024-03-18 21:32:30 +08:00
邱博亞 2f0225db2a remove carrierwave/processing/mime_type for new version 2024-03-18 21:22:15 +08:00
BoHung Chiu 40d63b69b3 Fix js not reload bug. 2022-06-17 21:31:24 +08:00
BoHung Chiu b58d757848 Fix bug. 2022-05-23 18:38:11 +08:00
BoHung Chiu 4116037d83 Fix bug. 2022-05-23 18:21:35 +08:00
BoHung Chiu 8c0d8a955d Fix js bug. 2022-02-25 10:56:10 +08:00
BoHung Chiu e31e1e85e0 Fix js bug. 2022-02-25 10:49:59 +08:00
BoHung Chiu c9d670f796 Fix bug. 2022-02-09 16:04:34 +08:00
BoHung Chiu cdb18dafd8 Fix css. 2022-02-09 15:38:25 +08:00
BoHung Chiu 8b10901dae Fix bug. 2022-02-08 15:43:27 +08:00
BoHung Chiu 3c97c85649 Fix bug. 2022-02-07 19:24:39 +08:00
BoHung Chiu f9f96c5045 Fix bug. 2022-02-07 19:00:39 +08:00
BoHung Chiu 4115a98ecb Fix bug. 2022-02-07 18:30:42 +08:00
BoHung Chiu f157dffc28 Fix bug. 2022-02-07 17:29:17 +08:00
BoHung Chiu d969d02990 Fix bug. 2022-01-28 15:51:58 +08:00
BoHung Chiu 4fd40830be Fix bug. 2022-01-28 15:50:24 +08:00
BoHung Chiu 14deddb4aa Fix bug. 2022-01-28 15:41:17 +08:00
BoHung Chiu a2ffbf9230 Fix backend page bug. 2022-01-28 12:51:21 +08:00
BoHung Chiu cac17bef8c Fix bug. 2022-01-27 17:02:29 +08:00
BoHung Chiu 92345e9ac3 Fix bug. 2022-01-26 19:57:13 +08:00
BoHung Chiu e5205fab5f Fix bug. 2022-01-26 19:40:14 +08:00
BoHung Chiu 05f913f513 Update cancer_predict.js. 2022-01-26 19:28:53 +08:00
BoHung Chiu b8e6e80d81 Update to version2.(Fix all known bugs.) 2022-01-26 19:19:28 +08:00
BoHung Chiu 73c46c2b51 change translations. 2022-01-23 17:17:49 +08:00
BoHung Chiu 9d2872b884 Fix js contents. 2022-01-23 16:58:03 +08:00
BoHung Chiu a56f6ba5e3 Fix bug.(Accelerate most time) 2022-01-23 14:00:57 +08:00
BoHung Chiu 360a86fecd Fix bug. 2022-01-22 18:47:32 +08:00
BoHung Chiu 96465e34f3 Fix bug. 2022-01-22 17:27:15 +08:00
BoHung Chiu 8041af8fd6 Update default settings. 2022-01-22 12:56:22 +08:00
BoHung Chiu 0ff0b42b70 Fix bug. 2022-01-22 12:52:03 +08:00
BoHung Chiu a6bb253f20 Change translation. 2020-10-23 15:05:18 +08:00
chiu 285c543f71 Remove unused file. 2020-10-23 10:53:56 +08:00
chiu 43711808e9 Change a lot,including mapping files and add feature that users can edit calculation formula at backend page by themself. 2020-10-23 10:52:23 +08:00
BOHUNG 4d41c5bce0 change tool name translation 2020-03-18 19:05:36 +08:00
BOHUNG 1561620c83 change tool name translation 2020-03-18 19:03:51 +08:00
BOHUNG 17f3fe623d change translation 2020-03-18 18:24:43 +08:00
BOHUNG 70b66409dd change table in tool. 2020-03-18 18:22:13 +08:00
BOHUNG a1aeeb008a fix bugs and change text for ntu_coph. 2020-03-04 15:37:59 +08:00
bohung 97337b7716 fix 2020-02-27 16:31:32 +08:00
bohung 802c4de893 fix 2020-02-27 16:11:01 +08:00
bohung be40283db0 fix 2020-02-27 16:06:51 +08:00
bohung b813662f4f first edit 2020-02-27 16:04:44 +08:00
BOHUNG 05a2a18763 add module_name to fix translations missing. 2020-02-24 15:29:23 +08:00
BOHUNG 7441a96bc5 fix bug 2020-02-06 15:48:50 +08:00
BOHUNG d1f87a2370 add export record feature 2020-02-03 16:49:00 +08:00
BOHUNG d8255b6ad0 fix 2020-02-03 15:26:04 +08:00
BOHUNG 62045584fc push from final_version to master 2020-01-28 18:29:04 +08:00
BOHUNG 294d98f83f copy from final_version branch to master 2020-01-13 19:35:30 +08:00
BOHUNG 34b4187716 finish reset_btn and set a submit_btn 2019-11-22 17:43:39 +08:00
33 changed files with 4251 additions and 954 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,936 @@
Array.prototype.get_nearest_value = function(goal){
var nearest_value = this.reduce(function(prev, curr) {
return (Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev);
});
return nearest_value;
}
function change_object_variables(obj1,obj2,operator="-",target="new"){
var obj_new = {};
var obj_keys = Object.keys(obj1);
obj_keys.forEach(function(k){
if(obj2[k] == undefined){
if( target == "new"){
obj_new[k] = obj1[k];
}
}else{
if(operator == "-"){
if( target == "new"){
obj_new[k] = obj1[k] - obj2[k];
}else{
obj1[k] = obj1[k] - obj2[k];
}
}else if(operator == "+"){
if( target == "new"){
obj_new[k] = obj1[k] + obj2[k];
}else{
obj1[k] = obj1[k] + obj2[k];
}
}
}
})
if( target == "new"){
return obj_new;
}else{
return obj1;
}
}
$(document).ready(function(){
var head_data = $.post("/cancerpredictResult",{"header":1,locale:I18n.locale});
var data = {};
if(I18n.locale == 'en'){
var window_width = $(window).width();
if(window_width < 520){
$('#cancer_table .cencer_table_name').css('max-width','');
}else if(window_width < 768){
$('#cancer_table .cencer_table_name').css({'max-width':'','width':'11em'});
}else if(window_width < 860){
$('#cancer_table .cencer_table_name').css('max-width','30%');
}else if(window_width < 1130){
$('#cancer_table .cencer_table_name').css('max-width','33%');
}else{
$('#cancer_table .cencer_table_name').css('max-width','39%');
};
};
function round(num,Digit=0){
return Math.round(Number(num)*(10**Digit))/(10**Digit);
};
head_data.done(function(){
if(head_data.responseJSON['head_images'] != ''){
$('.header-nav').html(head_data.responseJSON['head_images']);
}
if(head_data.responseJSON['title'] != ''){
$('.navbar-brand').html(head_data.responseJSON['title']);
}
data['danger_texts'] = head_data.responseJSON['danger_texts'];
$('head title').text(head_data.responseJSON['page_title'])
});
var mapping_data = $.post("/cancerpredictResult",{"get_mapping_data_from_csv":1,locale:I18n.locale});
mapping_data.done(function(){
// $('.header-nav').html(head_images.responseJSON['head_images']);
// $('.navbar-brand').html(head_images.responseJSON['title'])
window.mapping_data_from_csv = mapping_data.responseJSON['mapping_data_from_csv'];
});
Array.prototype.remove_item_from_array = function(){
var result_array = this;
for(var i=0;i<arguments.length;i++){
if(Array.isArray(arguments[i])){
for(var j=0;j<arguments.length;j++){
var index = result_array.indexOf(arguments[i][j]);
if(index == -1)
continue;
else{
result_array = result_array.slice(0, index).concat(result_array.slice(index + 1, result_array.length));
}
}
}else{
var index = result_array.indexOf(arguments[i]);
if(index == -1)
continue;
else{
result_array = result_array.slice(0, index).concat(result_array.slice(index + 1, result_array.length));
};
};
};
result_array.push = this.push;
result_array.remove_item_from_array = this.remove_item_from_array;
return result_array;
};
$('input#lymph_nodes_examined').data('range_new' , $('input#lymph_nodes_examined').data('range'));
$('input#lymph_nodes_positive').data('range_new' , $('input#lymph_nodes_positive').data('range'));
$('.num_only').on('input', function() {
$(this).siblings('.num_only_value').val($(this).val());
if( Number($(this).val()) < $(this).data('range')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range')[1] && $(this).data('range')[1] != undefined) ){
$(this).css('color','#f24a69');
$(this).addClass('cancertable_empty');
}else{
$(this).css('color','#333');
$(this).removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
});
$('input#lymph_nodes_positive').off('input').on('input',function(){
$(this).siblings('.num_only_value').val($(this).val());
if( Number($(this).val()) < $(this).data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range_new')[1] && $(this).data('range_new')[1] != undefined) ){
$(this).css('color','#f24a69');
$(this).addClass('cancertable_empty');
}else{
$(this).css('color','#333');
$(this).removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
});
$('input#lymph_nodes_examined').off('input').on('input',function(){
$(this).siblings('.num_only_value').val($(this).val());
if( Number($(this).val()) < $(this).data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range_new')[1] && $(this).data('range_new')[1] != undefined) ){
$(this).css('color','#f24a69');
$(this).addClass('cancertable_empty');
}else{
$(this).css('color','#333');
$(this).removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
});
$('.cancer_help_btn').off("click").on('click',function(){
var modal_head = "";
try{ modal_head = $(this).parent().find(">label").html()}catch(e){};
var modal_body = "";
try{ modal_body = $(this).parent().find(">input.help_texts").attr('value')}catch(e){};
$('#show_help_modal').html("<div class='modal-dialog'><div class='modal-content'><div class='modal-header'><button type='button' aria-hidden='true' class='close'>×</button><h4 class='modal-title'>"+modal_head+"</h4>"+
"</div><div class='modal-body'>"+modal_body+"</div><div class='modal-footer'><button type='button' class='btn btn-default'>Close</button></div></div></div>")
$('#show_help_modal').modal('show');
$('#show_help_modal .close').off("click").on('click',function(){
$('#show_help_modal').modal('hide');
});
$('#show_help_modal .modal-footer button').off("click").on('click',function(){
$('#show_help_modal').modal('hide');
});
});
$('.btn-add').click(function(){
$(this).parent().find('.num_only').removeClass('cancertable_empty');
if($(this).parent().find('.num_only').val()!=""){
var input_value = Number($(this).parent().find('.num_only').val());
if(Array.isArray($(this).parent().find('.num_only').data('range'))){
var compare_value = $(this).parent().find('.num_only').data('range')[1];
if(compare_value != undefined){
if(input_value+1 <= Number(compare_value))
$(this).parent().find('.num_only').val(input_value+1);
else{
input_value = $(this).parent().find('.num_only').data('range')[0];
if(input_value != undefined)
$(this).parent().find('.num_only').val(input_value);
};
}else{
$(this).parent().find('.num_only').val(input_value+1);
};
compare_value = $(this).parent().find('.num_only').data('range')[0];
if(compare_value != undefined){
if($(this).parent().find('.num_only').val() >= compare_value){
$(this).parent().find('.num_only').removeClass('cancertable_empty');
$(this).parent().find('.num_only').css('color','#333');
};
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
}else{
$(this).parent().find('.num_only').removeClass('cancertable_empty');
$(this).parent().find('.num_only').css('color','#333');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
};
}else{
try{
var input_value = $(this).parent().find('.num_only').data('range')[0];
if(input_value != undefined)
$(this).parent().find('.num_only').val(input_value);
}catch(e){
$(this).parent().find('.num_only').val(0);
};
if($(this).parent().find('.num_only').val() != ""){
$(this).parent().find('.num_only').removeClass('cancertable_empty');
$(this).parent().find('.num_only').css('color','#333');
};
};
});
$('.btn-sub').click(function(){
if($(this).parent().find('.num_only').val()!=""){
var input_value = Number($(this).parent().find('.num_only').val());
if(Array.isArray($(this).parent().find('.num_only').data('range'))){
var compare_value = $(this).parent().find('.num_only').data('range')[0];
if(compare_value != undefined){
if(input_value-1 >= Number(compare_value))
$(this).parent().find('.num_only').val(input_value-1);
else{
input_value = $(this).parent().find('.num_only').data('range')[1];
if(input_value != undefined)
$(this).parent().find('.num_only').val(input_value);
};
}else{
$(this).parent().find('.num_only').val(input_value-1);
};
compare_value = $(this).parent().find('.num_only').data('range')[1];
if(compare_value != undefined){
if($(this).parent().find('.num_only').val() <= compare_value){
$(this).parent().find('.num_only').removeClass('cancertable_empty');
$(this).parent().find('.num_only').css('color','#333');
};
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
}else{
$(this).parent().find('.num_only').removeClass('cancertable_empty');
$(this).parent().find('.num_only').css('color','#333');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
};
}else{
try{
var input_value = $(this).parent().find('.num_only').data('range')[1];
if(input_value != undefined){
$(this).parent().find('.num_only').val(input_value);
}else{
input_value = $(this).parent().find('.num_only').data('range')[0];
if(input_value != undefined)
$(this).parent().find('.num_only').val(input_value);
}
}catch(e){
$(this).parent().find('.num_only').val(0);
};
if($(this).parent().find('.num_only').val() != ""){
$(this).parent().find('.num_only').removeClass('cancertable_empty');
$(this).parent().find('.num_only').css('color','#333');
};
};
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
});
$('.cancer_table_btn').off('click').on('click',function(){
var index = $(this).index()/2;
try{
$(this).parent().find('>input').attr('value',0);
$(this).parent().find('>input').eq(index).attr('value',1);
$(this).parent().find('>button').removeClass('active');
$(this).parent().removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
}catch(e){};
$(this).addClass('active');
});
$('#cancer_table_reset').click(function(){
$('.cancer_table_btn').removeClass('active');
$('.cancer-btn-group input').attr('value',0);
$('.num_only').val('');
$('.num_only_value').val('');
$('#cancer_table .cancer_form_field').removeClass('cancertable_empty');
$('#cancer_predict_result_block').css('display','none');
$('#danger_texts').remove();
$('select.select_num').val('');
});
function get_input_data(){
var flag;
flag = 1;
for(var i = 0;i < $('#cancer_table .cancer_form_field').length;i++){
if($('#cancer_table .cancer_form_field').eq(i).hasClass('num_only')){
if($('#cancer_table .cancer_form_field').eq(i).val()==""){
flag = 0;
$('#cancer_table .cancer_form_field').eq(i).addClass('cancertable_empty');
}else if($('#cancer_table .cancer_form_field').eq(i).val() != "" && !$('#cancer_table .cancer_form_field').eq(i).hasClass('cancertable_empty')){
$('#cancer_table .cancer_form_field').eq(i).removeClass('cancertable_empty');
};
}else{
if($('#cancer_table .cancer_form_field').eq(i).find('[value="1"]').length == 0){
flag = 0;
$('#cancer_table .cancer_form_field').eq(i).addClass('cancertable_empty');
}else{
$('#cancer_table .cancer_form_field').eq(i).removeClass('cancertable_empty');
}
};
};
if( Number($('input#lymph_nodes_examined').siblings('.num_only_value').val()) < Number($('input#lymph_nodes_positive').siblings('.num_only_value').val())){
$('input#lymph_nodes_positive').addClass('cancertable_empty');
$('input#lymph_nodes_positive').css('color','rgb(242, 74, 105)');
};
if($('.cancertable_empty').length != 0){
flag = 0;
($('#danger_texts').length == 0) ? $('#cancer_table_submit').parent().before('<a id="danger_texts" style="color:red;">'+data['danger_texts']+'</a>') : null;
$('#danger_texts').css('margin-left',$(window).width()/2-$('#danger_texts').width()/2);
}else{
$('#danger_texts').remove();
};
if(flag == 1){
var post_json= {};
for(var i = 0;i < $('#cancer_table .cancer_form_field').length;i++){
var name = $('#cancer_table .cancer_form_field').eq(i).attr('id')
if($('#cancer_table .cancer_form_field').eq(i).hasClass('num_only'))
post_json[name] = Number($('#cancer_table .cancer_form_field').eq(i).siblings('.num_only_value').val());
else{
var index = ($('#cancer_table .cancer_form_field').eq(i).find('[value="1"]').index()+1)/2;
post_json[name] = index;
};
};
if( post_json["ER_status"] == 2 && post_json["PR_status"] == 2 ){
$('#hormone_therapy .cancer_table_btn').attr('disabled','disabled');
$('[for="hormone_therapy"]').css('color','rgb(204, 204, 204)');
}else{
$('#hormone_therapy .cancer_table_btn').removeAttr('disabled');
$('[for="hormone_therapy"]').css('color','');
};
/*disable_condition start*/
/*disable_condition end*/
return post_json;
}else{
return null;
}
};
function set_result(result){
if(result.responseJSON.lpv != "error"){
$('#choice_fields .cancer_table_btn').removeClass('active');
var load_heml = $('#result_table_content').html(result.responseJSON.table);
load_heml.ready(function(){
$('#result_table_content .cancer_years').eq(0).addClass('active');
for(var i = 0;i < $('#result_table_content .cancer_years').length;i++){
$('#result_table_content .cancer_years').eq(i).attr('index',i)
};
$('#result_table_content .cancer_years').off('click').on('click',function(){
try{
$(this).parent().find('.cancer_years').removeClass('active');
}catch(e){};
$(this).addClass('active');
$('#current_year').attr('index',$(this).attr('index'));
$('#current_year').attr('value',$(this).html());
$('#current_year').change();
});
});
load_heml = $('#result_text_content').html(result.responseJSON.texts);
load_heml.ready(function(){
$('#result_text_content .cancer_years').eq(0).addClass('active');
for(var i = 0;i < $('#result_text_content .cancer_years').length;i++){
$('#result_text_content .cancer_years').eq(i).attr('index',i)
};
$('#current_year').off('change');
$('#result_text_content .cancer_years').off('click')
$('#result_text_content .cancer_years').click(function(){
try{
$(this).parent().find('.cancer_years').removeClass('active');
}catch(e){};
$(this).addClass('active');
$('#current_year').attr('value',$(this).html());
$('#current_year').attr('index',$(this).attr('index'));
$('.surgery_year').html($(this).html());
$('#current_year').change();
});
$('#cancer_table_right_result .cancer-btn-group .cancer_table_btn').removeClass('active');
$('#cancer_table_right_result .cancer-btn-group >input').attr('value',"0");
for(var i = 0;i < $('#cancer_table_left_result .cancer-btn-group').length;i++){
$('#cancer_table_left_result .cancer-btn-group').eq(i).find('.cancer_table_btn').eq(0).addClass('active');
$('#cancer_table_left_result .cancer-btn-group').eq(i).find('>input').eq(0).attr('value',"1");
};
for(var i = 0;i < $('#cancer_table_right_result .cancer-btn-group').length;i++){
$('#cancer_table_right_result .cancer-btn-group').eq(i).find('.cancer_table_btn').eq(0).addClass('active');
$('#cancer_table_right_result .cancer-btn-group').eq(i).find('>input').eq(0).attr('value',"1");
};
var treatment_method = result.responseJSON.treatment_method;
var treatment_method_active_indices = result.responseJSON.treatment_method_active_indices;
$('tr.'+treatment_method[0]).addClass('tr_show');
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]+'%');
$('span.'+active_treatment[0]+'.Overall_Survival').html(Math.round(servive_ratio_arr[0]));
$('#cancer_predict_result_block').css('display','block');
var lpv_real = [result.responseJSON['lpv_variable']];
var lpv = /*therapy_lpv start*/[0];/*therapy_lpv end*/;
var lpv_dict={};
var lpv_calc=/*lpv_calc_formula_start*/{"1":"0.8095037**( Math.exp(lpv_current) )","1.5":"0.729158**( Math.exp(lpv_current) )","2":"0.6717211**( Math.exp(lpv_current) )","2.5":"0.6056773**( Math.exp(lpv_current) )"};/*lpv_calc_formula_end*/
active_treatment.push = function() {
if(arguments.length == 1){
var year = $('#current_year').attr('value');
console.log(lpv_real);
console.log(lpv_dict[arguments[0]])
var lpv_current = change_object_variables(lpv_real[lpv_real.length-1],{"lpv": lpv_dict[arguments[0]]},'+');
lpv_real.push(lpv_current);
lpv_current = lpv_current['lpv'];
var servive_ratio = round((1 - eval(lpv_calc[year]))*100,2);
var benefit = servive_ratio - servive_ratio_arr[servive_ratio_arr.length - 1];
servive_ratio_arr.push(servive_ratio);
$('tr.'+arguments[0]+' td.Overall_Survival').html(servive_ratio+'%');
$('tr.'+arguments[0]+' td.Additional_Benefit').html(round(benefit,2)+'%');
$('tr.'+arguments[0]).css('display','table-row');
$('tr.tr_show').eq(-1).after($('tr.'+arguments[0]));
$('tr.'+arguments[0]).addClass('tr_show');
if(this.length == 1){
$('.addition').css('display','inline-block');
$('#result_text_content .extra-text').css('display','inline-block');
}
var add_choices = this.slice(1,this.length);
add_choices.push(arguments[0]);
var add_choices_transform = [];
for(var i = 0;i<add_choices.length;i++){
add_choices_transform.push($('[for="'+add_choices[i]+'"]').html())
};
var add_choices_str = (I18n.locale == 'en' ? add_choices_transform.slice(0,add_choices_transform.length-1).join(', ') : add_choices_transform.slice(0,add_choices_transform.length-1).join('、'));
if(add_choices_transform.length >= 2)
add_choices_str += ((I18n.locale == 'en' ? ', and ': '以及')+add_choices_transform[add_choices_transform.length-1])
else
add_choices_str = add_choices_transform[0];
var extra_therapy_texts = result.responseJSON['extra_therapy_texts'];
extra_therapy_texts = extra_therapy_texts.replace('{{extra_therapy}}','</span><span class="'+arguments[0]+' choices">'+add_choices_str+'</span><span>');
extra_therapy_texts = extra_therapy_texts.replace('{{survival_num}}','</span><span class="'+arguments[0]+' Overall_Survival">'+Math.round(servive_ratio)+'</span><span>');
extra_therapy_texts = extra_therapy_texts.replace('{{surgery_year}}','</span><span class="surgery_year">'+year+'</span><span>');
extra_therapy_texts = extra_therapy_texts.replace('{{Additional_Benefit}}','</span><span class="'+arguments[0]+' Additional_Benefit">'+Math.round(benefit)+'</span><span>');
var new_text = '<p class="texts_show"><span>';
new_text += (extra_therapy_texts+'</span></p>');
$('#result_text_content .extra-text .texts_show').eq(-1).after(new_text)
return Array.prototype.push.apply(this, arguments);
}else{
return Array.prototype.push.apply(this, arguments);
}
};
active_treatment.remove_item_from_array = function(){
if(arguments.length == 1 && !Array.isArray(arguments[0])){
var index = this.indexOf(arguments[0])
var year = $('#current_year').attr('value');
if(index < this.length - 1){
for(var i = index + 1;i < this.length; i++){
change_object_variables(lpv_real[i] , {"lpv": lpv_dict[arguments[0]]} , '-' , 'self');
var lpv_current = lpv_real[i];
lpv_current = lpv_current['lpv'];
var servive_ratio = round((1 - eval(lpv_calc[year]))*100,2);
servive_ratio_arr[i] = servive_ratio;
var benefit = servive_ratio - ((i == index+1) ? servive_ratio_arr[index - 1] : servive_ratio_arr[i - 1]);
$('tr.'+active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%');
$('.'+active_treatment[i]+'.Overall_Survival').html(Math.round(servive_ratio));
$('tr.'+active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%');
$('.'+active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit));
};
var add_choices = [];
for(var i = 1;i < this.length; i++){
if(i != index){
add_choices.push(this[i]);
var add_choices_transform = [];
for(var j = 0;j<add_choices.length;j++){
add_choices_transform.push($('[for="'+add_choices[j]+'"]').html())
};
var add_choices_str = (I18n.locale == 'en' ? add_choices_transform.slice(0,add_choices_transform.length-1).join(', ') : add_choices_transform.slice(0,add_choices_transform.length-1).join('、'));
if(add_choices_transform.length >= 2)
add_choices_str += ((I18n.locale == 'en' ? ', and ': '以及')+add_choices_transform[add_choices_transform.length-1])
else
add_choices_str = add_choices_transform[0];
$('.'+active_treatment[i]+'.choices').html(add_choices_str);
}
};
};
$('tr.'+arguments[0]+' td.Overall_Survival').html('-');
$('tr.'+arguments[0]+' td.Additional_Benefit').html('-');
$('tr.'+arguments[0]).css('display','none');
$('tr.'+arguments[0]).removeClass('tr_show');
$('span.'+arguments[0]).eq(0).parent().remove();
lpv_real = lpv_real.remove_item_from_array(lpv_real[index]);
servive_ratio_arr = servive_ratio_arr.remove_item_from_array(servive_ratio_arr[index]);
if(this.length == 2){
$('.addition').css('display','none');
$('#result_text_content .extra-text').css('display','none');
};
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<treatment_method.length;i++){
lpv_dict[treatment_method[i]] = lpv[i];
var click_flag=false;
$('#'+treatment_method[i]+' .cancer_table_btn').off('click').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;
};
};
});
$('#'+treatment_method[i]+' .cancer_table_btn').eq(treatment_method_active_indices[i]).off('click').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;
};
}
});
};
$('#current_year').change(function(){
year = $(this).attr('value');
$('.surgery_year').html(year);
$('.cancer_years').removeClass('active');
$('#result_text_content .cancer_years').eq($(this).attr("index")).addClass('active');
$('#result_table_content .cancer_years').eq($(this).attr("index")).addClass('active');
var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year}
calculate_and_change_result_value(obj);
servive_ratio_arr = obj.servive_ratio_arr;
active_treatment = obj.active_treatment;
lpv_real = obj.lpv_real;
lpv_calc = obj.lpv_calc;
year = obj.year;
});
$('#cancer_table .cancer_form_field').off('change').on('change',function(){
var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year}
after_submit_change_func(obj);
servive_ratio_arr = obj.servive_ratio_arr;
active_treatment = obj.active_treatment;
lpv_real = obj.lpv_real;
lpv_calc = obj.lpv_calc;
year = obj.year;
});
$('#cancer_table .cancer_form_field').click(function(){
$(this).change();
});
$('select.select_num').off('click').on('click',function(){
$(this).change();
var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year}
after_submit_change_func(obj);
servive_ratio_arr = obj.servive_ratio_arr;
active_treatment = obj.active_treatment;
lpv_real = obj.lpv_real;
lpv_calc = obj.lpv_calc;
year = obj.year;
});
$('.num_only').on('input', function() {
if( Number($(this).val()) < $(this).data('range')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range')[1] && $(this).data('range')[1] != undefined) ){
$(this).css('color','#f24a69');
$(this).addClass('cancertable_empty');
}else{
$(this).css('color','#333');
$(this).removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year};
after_submit_change_func(obj);
servive_ratio_arr = obj.servive_ratio_arr;
active_treatment = obj.active_treatment;
lpv_real = obj.lpv_real;
lpv_calc = obj.lpv_calc;
year = obj.year;
};
});
});
};
};
function after_submit_change_func(obj){
var post_json = get_input_data();
if(post_json != null){
var new_lpv = calculate_first_lpv(post_json)['lpv_variable'];
var old_lpv = obj.lpv_real[0];
obj.lpv_real = obj.lpv_real.map(original_value=>(change_object_variables(original_value,change_object_variables(new_lpv,old_lpv,'-'),'+')));
calculate_and_change_result_value(obj);
};
};
/* auto add start */
function calculate_first_lpv(result_json){
result = {};
var map_values , mapping_hash , temp_index ,temp_value , index , closest_value;
result['sex_value'] = (2 - Number(result_json['sex_value']));
result['age'] = Number(result_json['age']);
mapping_hash = mapping_data_from_csv['age'];
temp_index = 0;
temp_value = result['age'];
index = 0;
$.each(mapping_hash,function(k,v){
if( index == 0 ){
var index_val = v.indexOf(temp_value);
if( index_val != -1 ){
temp_index = index_val;
}else{
closest_value = v.get_nearest_value(temp_value);
temp_index = v.indexOf(closest_value)
}
}
result[k] = v[temp_index];
index++;
});
result['calH'] = Number(result_json['calH']);
mapping_hash = mapping_data_from_csv['calH'];
temp_index = 0;
temp_value = result['calH'];
index = 0;
$.each(mapping_hash,function(k,v){
if( index == 0 ){
var index_val = v.indexOf(temp_value);
if( index_val != -1 ){
temp_index = index_val;
}else{
closest_value = v.get_nearest_value(temp_value);
temp_index = v.indexOf(closest_value)
}
}
result[k] = v[temp_index];
index++;
});
result['calAH'] = Number(result_json['calAH']);
mapping_hash = mapping_data_from_csv['calAH'];
temp_index = 0;
temp_value = result['calAH'];
index = 0;
$.each(mapping_hash,function(k,v){
if( index == 0 ){
var index_val = v.indexOf(temp_value);
if( index_val != -1 ){
temp_index = index_val;
}else{
closest_value = v.get_nearest_value(temp_value);
temp_index = v.indexOf(closest_value)
}
}
result[k] = v[temp_index];
index++;
});
result['calDH'] = Number(result_json['calDH']);
mapping_hash = mapping_data_from_csv['calDH'];
temp_index = 0;
temp_value = result['calDH'];
index = 0;
$.each(mapping_hash,function(k,v){
if( index == 0 ){
var index_val = v.indexOf(temp_value);
if( index_val != -1 ){
temp_index = index_val;
}else{
closest_value = v.get_nearest_value(temp_value);
temp_index = v.indexOf(closest_value)
}
}
result[k] = v[temp_index];
index++;
});
result['fat'] = Number(result_json['fat']);
mapping_hash = mapping_data_from_csv['fat'];
temp_index = 0;
temp_value = result['fat'];
index = 0;
$.each(mapping_hash,function(k,v){
if( index == 0 ){
var index_val = v.indexOf(temp_value);
if( index_val != -1 ){
temp_index = index_val;
}else{
closest_value = v.get_nearest_value(temp_value);
temp_index = v.indexOf(closest_value)
}
}
result[k] = v[temp_index];
index++;
});
result['N4'] = (2 - Number(result_json['N4']));
result['N12'] = (2 - Number(result_json['N12']));
result['N20'] = (2 - Number(result_json['N20']));
result['N31'] = (2 - Number(result_json['N31']));
result['O6'] = (2 - Number(result_json['O6']));
result['N34'] = (2 - Number(result_json['N34']));
result['N14'] = (2 - Number(result_json['N14']));
result['N26'] = (2 - Number(result_json['N26']));
result['O3'] = (2 - Number(result_json['O3']));
result['O20'] = (2 - Number(result_json['O20']));
result['O18'] = (2 - Number(result_json['O18']));
result['O11'] = (2 - Number(result_json['O11']));
result['N29'] = (2 - Number(result_json['N29']));
result['N6'] = (2 - Number(result_json['N6']));
result['O14'] = (2 - Number(result_json['O14']));
result['N43'] = (2 - Number(result_json['N43']));
result['O17'] = (2 - Number(result_json['O17']));
result['O9'] = (2 - Number(result_json['O9']));
Object.keys(result).forEach(function(k){
if(Number.isNaN(result[k])){
result[k] = 0;
}
})
;
try{
A = 0.1327868* (result["sex_value"]- 0.4858824) + 0.0371720* (result["age_test1"] - 61.56000) -0.07447278* (result["age_test2"] - 13.10152) + 0.4315686* (result["age_test3"] - 0.9844332) + 0.0009163615*( result["calH_test1"] - 182.9347) -0.0007536899*( result["calH_test2"] - 124.8706) -0.00004697183*( result["calH_test3"] -80.75636) + 0.0001401325*( result["calAH_test1"] - 700.7824) -0.001349783*( result["calAH_test2"] - 634.2167) +0.001753832*( result["calAH_test3"] -419.3361) + 0.0001906046*( result["calDH_test1"] -835.2894) -0.000251567*( result["calDH_test2"] - 213.1630) -0.002173942*( result["fat_test1"] -108.4149)+0.003066541*( result["fat_test2"] - 28.33497) +0.6700708*(result["N4"]-0.3241176) +0.3336162*(result["O3"]-0.4994118) +0.1322476*(result["O20"]-0.1741176) +0.9084972*(result["O18"]-0.008823529) +0.2978388*(result["N12"]-0.1152941) +0.1777935*(result["N20"]-0.3582353) +1.588042*(result["N31"]-0.002352941) +0.2197419*(result["O6"]-0.07823529) +1.791159*(result["N34"]-0.001176471) +0.4305973*(result["N14"]-0.02176471) -0.4472885*(result["N29"]-0.02411765) +0.2601319*(result["N26"]-0.04941176) -0.2364269*(result["O11"]-0.1164706) +0.1784179*(result["N6"]-0.1070588) +0.6023170*(result["O14"]-0.01294118) -1.031959*(result["N43"]-0.007058824) +0.4257809*(result["O17"]-0.01823529) +0.2002546*(result["O9"]-0.06176471)
}catch(e){console.log(e)};
result['lpv_variable'] = {};
result['lpv_variable']['A'] = A;
result['lpv'] = A;
result['lpv_variable']['lpv'] = result['lpv'];
return result;
};
function calculate_and_change_result_value(obj){
obj.servive_ratio_arr = [];
for(var i = 0;i<obj.active_treatment.length;i++){
var servive_ratio = round((1 - calculate_servive_ratio(obj.year,obj.lpv_real[i]))*100,2);
var benefit = servive_ratio - obj.servive_ratio_arr[obj.servive_ratio_arr.length-1];
obj.servive_ratio_arr.push(servive_ratio);
$('tr.'+obj.active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%');
$('.'+obj.active_treatment[i]+'.Overall_Survival').html(Math.round(servive_ratio));
if(i != 0){
$('tr.'+obj.active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%');
$('.'+obj.active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit));
}
}
//$('.'+obj.active_treatment[0]+'.Overall_Survival').html(Math.round(obj.servive_ratio_arr[0]));
};
function calculate_servive_ratio(year,obj){
var servive_ratio;
var A = obj['A'];
switch(year) {
case '1':
servive_ratio = 0.8095037**( Math.exp(A) );
break;
case '1.5':
servive_ratio = 0.729158**( Math.exp(A) );
break;
case '2':
servive_ratio = 0.6717211**( Math.exp(A) );
break;
case '2.5':
servive_ratio = 0.6056773**( Math.exp(A) );
break;
default:
console.log('not found year.');
}
return servive_ratio;
}
/* auto add end */
function submit_fcn(){
var post_json = get_input_data();
if(post_json != null){
post_json['locale'] = I18n.locale;
var result = $.post("/cancerpredictResult",{"data":post_json});
result.done(function(){
console.log(result.responseJSON);
set_result(result);
window.location.hash = '';
window.location.hash = '#cancer_predict_result_block';
});
};
};
$('#cancer_table_submit').click(function(){
submit_fcn();
});
for(var i = 0;i < $('.result_tab').length;i++){
$('.result_tab').eq(i).attr('index',i)
};
for(var i = 0;i < $('.result_content').length;i++){
$('.result_content').eq(i).attr('index',i)
};
$('.result_tab').click(function(){
var index = $(this).attr('index');
$('.result_tab').removeClass('active');
$(this).addClass('active');
$('.result_content').css('display','none');
$('.result_content[index="'+index+'"]').css('display','block');
})
$('.num_only').keypress(function(event){
return event.keyCode>=48&&event.keyCode<=57||(this.value.indexOf('.')<0?event.keyCode==46:false);
});
$('.float_num').off('keyup').on('keyup',function(){
this.value = this.value.replace(/[^\d.]/g,'');
});
$('.num_only').blur(function() {
if( Number($(this).val()) < $(this).data('range')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range')[1] && $(this).data('range')[1] != undefined) ){
$(this).css('color','#f24a69');
$(this).addClass('cancertable_empty');
}else{
$(this).css('color','#333');
$(this).removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
});
$('select.select_num').off('click').on('click',function(){
$(this).change();
});
$('select.select_num').change(function(){
if(this.selectedIndex != 0){
$(this).siblings('input.num_only').val($(this).find('option').eq(this.selectedIndex).text());
$(this).siblings('input.num_only').removeClass('cancertable_empty');
$(this).siblings('input.num_only').css('color','#333');
}else{
$(this).siblings('input.num_only').addClass('cancertable_empty');
$(this).siblings('input.num_only').css('color','rgb(242, 74, 105)');
$(this).siblings('input.num_only').val($(this).val());
}
$(this).siblings('input.num_only_value').val($(this).val());
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
});
$('input#lymph_nodes_examined').siblings('select.select_num').off('change').on('change',function(){
var range = $('input#lymph_nodes_positive').data('range');
range[1] = Number($(this).val());
$('input#lymph_nodes_positive').data('range_new', range);
if(this.selectedIndex != 0){
$(this).siblings('input.num_only').val($(this).find('option').eq(this.selectedIndex).text());
$(this).siblings('input.num_only').removeClass('cancertable_empty');
$(this).siblings('input.num_only').css('color','#333');
}else{
$(this).siblings('input.num_only').addClass('cancertable_empty');
$(this).siblings('input.num_only').css('color','rgb(242, 74, 105)');
$(this).siblings('input.num_only').val($(this).val());
}
$(this).siblings('input.num_only_value').val($(this).val());
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
$(this).siblings('.num_only_value').val($(this).val());
if( Number($('input#lymph_nodes_positive').siblings('.num_only_value').val()) <= Number($(this).val()) ){
$('input#lymph_nodes_positive').css('color','#333');
$('input#lymph_nodes_positive').removeClass('cancertable_empty');
};
if( Number($(this).val()) < $(this).siblings('.num_only').data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).siblings('.num_only').data('range_new')[1] && $(this).siblings('.num_only').data('range_new')[1] != undefined) ){
$(this).siblings('.num_only').css('color','#f24a69');
$(this).siblings('.num_only').addClass('cancertable_empty');
}else{
$(this).siblings('.num_only').css('color','#333');
$(this).siblings('.num_only').removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
});
$('input#lymph_nodes_positive').siblings('select.select_num').off('change').on('change',function(){
var range = $('input#lymph_nodes_examined').data('range');
range[0] = Number($(this).val());
$('input#lymph_nodes_examined').data('range_new', range);
if(this.selectedIndex != 0){
$(this).siblings('input.num_only').val($(this).find('option').eq(this.selectedIndex).text());
$(this).siblings('input.num_only').removeClass('cancertable_empty');
$(this).siblings('input.num_only').css('color','#333');
}else{
$(this).siblings('input.num_only').addClass('cancertable_empty');
$(this).siblings('input.num_only').css('color','rgb(242, 74, 105)');
$(this).siblings('input.num_only').val($(this).val());
}
$(this).siblings('input.num_only_value').val($(this).val());
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
$(this).siblings('.num_only_value').val($(this).val());
if( Number($('input#lymph_nodes_examined').siblings('.num_only_value').val()) >= Number($(this).val()) ){
$('input#lymph_nodes_examined').css('color','#333');
$('input#lymph_nodes_examined').removeClass('cancertable_empty');
};
if( Number($(this).val()) < $(this).siblings('.num_only').data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).siblings('.num_only').data('range_new')[1] && $(this).siblings('.num_only').data('range_new')[1] != undefined) ){
$(this).siblings('.num_only').css('color','#f24a69');
$(this).siblings('.num_only').addClass('cancertable_empty');
}else{
$(this).siblings('.num_only').css('color','#333');
$(this).siblings('.num_only').removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
});
$('select.select_num').blur(function() {
if( Number($(this).siblings('.num_only_value').val()) < $(this).siblings('.num_only').data('range')[0] || $(this).siblings('.num_only_value').val() == "" || (Number($(this).siblings('.num_only_value').val()) > $(this).siblings('.num_only').data('range')[1] && $(this).siblings('.num_only').data('range')[1] != undefined) ){
$(this).siblings('.num_only').css('color','#f24a69');
$(this).siblings('.num_only').addClass('cancertable_empty');
}else{
$(this).siblings('.num_only').css('color','#333');
$(this).siblings('.num_only').removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
});
if($(window).width() < 768)
$('#cancer_predict_result').attr('style','');
});
$(window).resize(function(){
if($(window).width() > 768){
if($('.cancer_table_right_result').length != 0)
$('#cancer_predict_result').css('float','right');
}else{
$('#cancer_predict_result').attr('style','');
};
if(I18n.locale == 'en'){
var window_width = $(window).width();
if(window_width < 520){
$('#cancer_table .cencer_table_name').css('max-width','');
}else if(window_width < 768){
$('#cancer_table .cencer_table_name').css({'max-width':'','width':'11em'});
}else if(window_width < 860){
$('#cancer_table .cencer_table_name').css('max-width','30%');
}else if(window_width < 1130){
$('#cancer_table .cencer_table_name').css('max-width','33%');
}else{
$('#cancer_table .cencer_table_name').css('max-width','39%');
};
};
});

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); return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0) | 0);
} }
} }
/** /**
* React v15.3.1 * React v15.3.1
* *
@ -3026,7 +3025,7 @@ if (typeof Math.imul == "undefined" || (Math.imul(0xffffffff, 5) == 0)) {
QG(function (a) { return Y(IW.c ? IW.c(a) : IW.call(null, a)) }, new R(null, 1, 5, S, [ZG], null), "treatments-received-panel"); QG(function (a) { return Y(IW.c ? IW.c(a) : IW.call(null, a)) }, new R(null, 1, 5, S, [ZG], null), "treatments-received-panel");
QG(function () { return React.createElement("div", { id: "patient-related-help" }, React.createElement("h1", null, "Patient related factors"), React.createElement("h2", null, "<%=%>"), React.createElement("p", null, "Many risk factors depend on the age of the patient."), React.createElement("h2", null, "Surgery", React.createElement("p", null, "May be breast-conserving surgery or a mastectomy."))) }, new R(null, 1, 5, S, [ZG], null), "patient-related-help"); QG(function () { return React.createElement("div", { id: "patient-related-help" }, React.createElement("h1", null, "Patient related factors"), React.createElement("h2", null, "<%=%>"), React.createElement("p", null, "Many risk factors depend on the age of the patient."), React.createElement("h2", null, "Surgery", React.createElement("p", null, "May be breast-conserving surgery or a mastectomy."))) }, new R(null, 1, 5, S, [ZG], null), "patient-related-help");
var JW = QG(function (a) { var JW = QG(function (a) {
var b = function () { var a = new m(null, 1, [nu, jW], null); return null/*nW.c ? nW.c(a) : nW.call(null, a) */}();/*important*/ return gg(React.createElement, "div", M(b) ? EG(b) : null, M(b) ? new R(null, 1, 5, S, [React.createElement("form", { onKeyPress: GW, onSubmit: HW, className: "form-horizontal" }, Y(p(a.c ? a.c(fn) : a.call(null, fn)) ? new R(null, 3, 5, S, [bv, function () { var a = new m(null, 2, [Lx, "Age", hk, fn], null); return LT.c ? LT.c(a) : LT.call(null, a) }(), new R(null, 3, 5, S, [bv, new m(null, 1, [Ru, new m(null, 3, [Bn, "#686868", Aq, "145px", wr, -5], null)], var b = null;/*important*/ return gg(React.createElement, "div", M(b) ? EG(b) : null, M(b) ? new R(null, 1, 5, S, [React.createElement("form", { onKeyPress: GW, onSubmit: HW, className: "form-horizontal" }, Y(p(a.c ? a.c(fn) : a.call(null, fn)) ? new R(null, 3, 5, S, [bv, function () { var a = new m(null, 2, [Lx, "Age", hk, fn], null); return LT.c ? LT.c(a) : LT.call(null, a) }(), new R(null, 3, 5, S, [bv, new m(null, 1, [Ru, new m(null, 3, [Bn, "#686868", Aq, "145px", wr, -5], null)],
null), "Age must be between 25 and 85"], null)], null) : null), Y(B.h(Bm, bH(KQ(eo))) ? function () { var a = new m(null, 2, [Lx, "Post Menopausal", hk, Zk], null); return LT.c ? LT.c(a) : LT.call(null, a) }() : null))], null) : new R(null, 2, 5, S, [Y(b), React.createElement("form", { onKeyPress: GW, onSubmit: HW, className: "form-horizontal" }, Y(p(a.c ? a.c(fn) : a.call(null, fn)) ? new R(null, 3, 5, S, [bv, function () { var a = new m(null, 2, [Lx, "Age", hk, fn], null); return LT.c ? LT.c(a) : LT.call(null, a) }(), new R(null, 3, 5, S, [bv, new m(null, 1, [Ru, new m(null, 3, [Bn, null), "Age must be between 25 and 85"], null)], null) : null), Y(B.h(Bm, bH(KQ(eo))) ? function () { var a = new m(null, 2, [Lx, "Post Menopausal", hk, Zk], null); return LT.c ? LT.c(a) : LT.call(null, a) }() : null))], null) : new R(null, 2, 5, S, [Y(b), React.createElement("form", { onKeyPress: GW, onSubmit: HW, className: "form-horizontal" }, Y(p(a.c ? a.c(fn) : a.call(null, fn)) ? new R(null, 3, 5, S, [bv, function () { var a = new m(null, 2, [Lx, "Age", hk, fn], null); return LT.c ? LT.c(a) : LT.call(null, a) }(), new R(null, 3, 5, S, [bv, new m(null, 1, [Ru, new m(null, 3, [Bn,
"#686868", Aq, "145px", wr, -5], null)], null), "Age must be between 25 and 85"], null)], null) : null), Y(B.h(Bm, bH(KQ(eo))) ? function () { var a = new m(null, 2, [Lx, "Post Menopausal", hk, Zk], null); return LT.c ? LT.c(a) : LT.call(null, a) }() : null))], null)) "#686868", Aq, "145px", wr, -5], null)], null), "Age must be between 25 and 85"], null)], null) : null), Y(B.h(Bm, bH(KQ(eo))) ? function () { var a = new m(null, 2, [Lx, "Post Menopausal", hk, Zk], null); return LT.c ? LT.c(a) : LT.call(null, a) }() : null))], null))
}, new R(null, 1, 5, S, [aH], null), "patient-related-form"), KW = QG(function (a) { return Y(JW.c ? JW.c(a) : JW.call(null, a)) }, new R(null, 1, 5, S, [ZG], null), "patient-related-panel"), LW = QG(function (a) { }, new R(null, 1, 5, S, [aH], null), "patient-related-form"), KW = QG(function (a) { return Y(JW.c ? JW.c(a) : JW.call(null, a)) }, new R(null, 1, 5, S, [ZG], null), "patient-related-panel"), LW = QG(function (a) {
@ -3044,14 +3043,15 @@ if (typeof Math.imul == "undefined" || (Math.imul(0xffffffff, 5) == 0)) {
null)], null) : null) , Y(p(a.c ? a.c(Tp) : a.call(null, Tp)) ? function () { var a = new m(null, 2, [Lx, "HER2 status", hk, Tp], null); return LT.c ? LT.c(a) : LT.call(null, a) }() : null), Y(p(a.c ? a.c(Br) : a.call(null, Br)) ? function () { var a = new m(null, 2, [Lx, "Detected by", hk, Br], null); return LT.c ? LT.c(a) : LT.call(null, a) }() : null), Y(B.h(ln, bH(KQ(Br))) ? new R(null, 4, 5, S, [bv, new m(null, 1, [Ru, new m(null, 3, [Bn, "#686868", Aq, "145px", wr, -5], null)], null), "Detected as part of a preventive ", new R(null, 3, 5, S, [eF, new m(null, 2, [CE, "https://www.nhs.uk/conditions/nhs-screening/", $A, "_blank"], null), "screening programme"], null)], null) : null), Y(p(a.c ? null)], null) : null) , Y(p(a.c ? a.c(Tp) : a.call(null, Tp)) ? function () { var a = new m(null, 2, [Lx, "HER2 status", hk, Tp], null); return LT.c ? LT.c(a) : LT.call(null, a) }() : null), Y(p(a.c ? a.c(Br) : a.call(null, Br)) ? function () { var a = new m(null, 2, [Lx, "Detected by", hk, Br], null); return LT.c ? LT.c(a) : LT.call(null, a) }() : null), Y(B.h(ln, bH(KQ(Br))) ? new R(null, 4, 5, S, [bv, new m(null, 1, [Ru, new m(null, 3, [Bn, "#686868", Aq, "145px", wr, -5], null)], null), "Detected as part of a preventive ", new R(null, 3, 5, S, [eF, new m(null, 2, [CE, "https://www.nhs.uk/conditions/nhs-screening/", $A, "_blank"], null), "screening programme"], null)], null) : null), Y(p(a.c ?
a.c(Pw) : a.call(null, Pw)) ? new R(null, 6, 5, S, [bv, function () { var a = new m(null, 2, [Lx, "Positive nodes", hk, Pw], null); return LT.c ? LT.c(a) : LT.call(null, a) }(), function () { var a = new m(null, 2, [Lx, "Micrometastases only", hk, tC], null); return LT.c ? LT.c(a) : LT.call(null, a) }(), ig("1", b) ? new R(null, 3, 5, S, [bv, new m(null, 1, [Ru, new m(null, 3, [Bn, "#686868", Aq, "145px", wr, -5], null)], null), "Enabled when positive nodes is 1. "], null) : null, B.h("1", b) ? LW.c ? LW.c("“Yes” means the positive node has micrometastases only") : LW.call(null, a.c(Pw) : a.call(null, Pw)) ? new R(null, 6, 5, S, [bv, function () { var a = new m(null, 2, [Lx, "Positive nodes", hk, Pw], null); return LT.c ? LT.c(a) : LT.call(null, a) }(), function () { var a = new m(null, 2, [Lx, "Micrometastases only", hk, tC], null); return LT.c ? LT.c(a) : LT.call(null, a) }(), ig("1", b) ? new R(null, 3, 5, S, [bv, new m(null, 1, [Ru, new m(null, 3, [Bn, "#686868", Aq, "145px", wr, -5], null)], null), "Enabled when positive nodes is 1. "], null) : null, B.h("1", b) ? LW.c ? LW.c("“Yes” means the positive node has micrometastases only") : LW.call(null,
"“Yes” means the positive node has micrometastases only") : null, B.h("0", b) ? LW.c ? LW.c("Why can't I enter micrometastases?") : LW.call(null, "Why can't I enter micrometastases?") : null], null) : null)) "“Yes” means the positive node has micrometastases only") : null, B.h("0", b) ? LW.c ? LW.c("Why can't I enter micrometastases?") : LW.call(null, "Why can't I enter micrometastases?") : null], null) : null))
}, new R(null, 2, 5, S, [aH, ZG], null), "tumour-related-form"), NW = QG(function (a) { return Y(MW.c ? MW.c(a) : MW.call(null, a)) }, new R(null, 1, 5, S, [ZG], null), "tumour-related-panel"),reset_btn = QG(function (a) { a = null != a && (a.v & 64 || h === a.J) ? P(Fi, a) : a; a = y.h(a, nu);console.log(a);return React.createElement("button", { onClick: a, className: "btn navbar-btn btn-danger btn-lg screen-only" }, " Reset ") }, new R(null, 1, 5, S, [ZG], null), "clear-all-button"), OW = QG(function (a) { }, new R(null, 2, 5, S, [aH, ZG], null), "tumour-related-form"), NW = QG(function (a) { return Y(MW.c ? MW.c(a) : MW.call(null, a)) }, new R(null, 1, 5, S, [ZG], null), "tumour-related-panel"),submit_btn = QG(function (a) { a = null != a && (a.v & 64 || h === a.J) ? P(Fi, a) : a; a = y.h(a, nu);return React.createElement("button", { onClick: function(){console.log(p(LG))}, className: "submit-btn screen-only",style:{marginLeft:'1em',float:'right',backgroundColor:"#d26900",color:"white",border:"0em",padding:"0.125em 0.5em",borderRadius:"0.5em"} }, " Submit ") }, new R(null, 1, 5, S, [ZG], null), "clear-all-button"),reset_btn = QG(function (a) { a = null != a && (a.v & 64 || h === a.J) ? P(Fi, a) : a; a = y.h(a, nu);return React.createElement("button", { onClick: a, className: "reset-btn screen-only",style:{float:'right',backgroundColor:"#d26900",color:"white",border:"0em",padding:"0.125em 0.5em",borderRadius:"0.5em"} }, " Reset ") }, new R(null, 1, 5, S, [ZG], null), "clear-all-button"), reset_call = QG(function (a) {
var b = function () { var a = new m(null, 1, [nu, jW], null); return reset_btn.c ? reset_btn.c(a) : reset_btn.call(null, a)}(),b1 = function () { var a = new m(null, 1, [nu, jW], null); return submit_btn.c ? submit_btn.c(a) : submit_btn.call(null, a)}();/*important*/ return gg(React.createElement, "div", M(b) ? EG(b) : null, [Y(b1),Y(b)])}), OW = QG(function (a) {
return React.createElement("form", { onKeyPress: GW, onSubmit: HW, className: "form-horizontal" },Y(p(a.c ? a.c(vu) : a.call(null, vu)) ? function () { var a = new m(null, 2, [Lx, "Size", hk, vu], null); return LT.c ? LT.c(a) : LT.call(null, a) }() : null), Y(p(a.c ? a.c(Qw) : a.call(null, Qw)) ? function () { return React.createElement("form", { onKeyPress: GW, onSubmit: HW, className: "form-horizontal" },Y(p(a.c ? a.c(vu) : a.call(null, vu)) ? function () { var a = new m(null, 2, [Lx, "Size", hk, vu], null); return LT.c ? LT.c(a) : LT.call(null, a) }() : null), Y(p(a.c ? a.c(Qw) : a.call(null, Qw)) ? function () {
var a = new m(null, 2, [Lx, "Grade", var a = new m(null, 2, [Lx, "Grade",
hk, Qw], null); return LT.c ? LT.c(a) : LT.call(null, a) hk, Qw], null); return LT.c ? LT.c(a) : LT.call(null, a)
}() : null)) }() : null))
}, new R(null, 1, 5, S, [ZG], null), "hormone-form"), PW = QG(function (a) { return Y(OW.c ? OW.c(a) : OW.call(null, a)) }, new R(null, 1, 5, S, [ZG], null), "hormone-panel"), QW = QG(function () { }, new R(null, 1, 5, S, [ZG], null), "hormone-form"), PW = QG(function (a) { return Y(OW.c ? OW.c(a) : OW.call(null, a)) }, new R(null, 1, 5, S, [ZG], null), "hormone-panel"), QW = QG(function () {
var a = FW(); return React.createElement("div", { className: "row" }, React.createElement("div", { style: { paddingRight: 0 }, className: "col-sm-6 screen-only" }, Y(KW.c ? KW.c(a) : KW.call(null, a)), Y(PW.c ? PW.c(a) : PW.call(null, a))), React.createElement("div", { style: { paddingRight: 0 }, className: "col-sm-6 screen-only" }, Y(NW.c ? NW.c(a) : NW.call(null, var a = FW(); return React.createElement("div", { className: "row" }, React.createElement("div", { style: { paddingRight: 0 }, className: "col-sm-6 screen-only" }, Y(KW.c ? KW.c(a) : KW.call(null, a)), Y(PW.c ? PW.c(a) : PW.call(null, a))), React.createElement("div", { style: { paddingRight: 0 }, className: "col-sm-6 screen-only" }, Y(NW.c ? NW.c(a) : NW.call(null,
a))),React.createElement("div",{className: "col-sm-6 screen-only"},React.createElement("div",{},Y(reset_btn.l ? reset_btn.l() : reset_btn.call(null))))) a))))
}, new R(null, 2, 5, S, [aH, tU], null), "inputs-row"); QG(function () { var a = FW(); return React.createElement("div", { className: "row" }, React.createElement("div", { style: { paddingRight: 0 }, className: "col-sm-12" }, Y(KW.c ? KW.c(a) : KW.call(null, a)), Y(NW.c ? NW.c(a) : NW.call(null, a)), Y(PW.c ? PW.c(a) : PW.call(null, a)))) }, new R(null, 2, 5, S, [aH, tU], null), "inputs-column"); BT(fg(zT, T, new R(null, 2, 5, S, [new R(null, 2, 5, S, ["div", new m(null, 1, [Do, "12px"], null)], null), new R(null, 3, 5, S, [".treatments-header--G__28384", new m(null, 3, [dr, "rgba(255, 140, 0, 1) !important", Bn, "white !important", Do, "0.625em !important"], null), new R(null, 2, 5, S, ["form", new m(null, 1, [eC, "1px solid red"], null)], null)], null)], null)), "predict3.layout.treatments-panel", "treatments-style"); }, new R(null, 2, 5, S, [aH, tU], null), "inputs-row"); QG(function () { var a = FW(); return React.createElement("div", { className: "row" }, React.createElement("div", { style: { paddingRight: 0 }, className: "col-sm-12" }, Y(KW.c ? KW.c(a) : KW.call(null, a)), Y(NW.c ? NW.c(a) : NW.call(null, a)), Y(PW.c ? PW.c(a) : PW.call(null, a)))) }, new R(null, 2, 5, S, [aH, tU], null), "inputs-column"); BT(fg(zT, T, new R(null, 2, 5, S, [new R(null, 2, 5, S, ["div", new m(null, 1, [Do, "12px"], null)], null), new R(null, 3, 5, S, [".treatments-header--G__28384", new m(null, 3, [dr, "rgba(255, 140, 0, 1) !important", Bn, "white !important", Do, "0.625em !important"], null), new R(null, 2, 5, S, ["form", new m(null, 1, [eC, "1px solid red"], null)], null)], null)], null)), "predict3.layout.treatments-panel", "treatments-style");
BT(fg(zT, T, new R(null, 1, 5, S, [new R(null, 2, 5, S, [".closer--G__28387", new m(null, 1, [YD, "0.625em"], null)], null)], null)), "predict3.layout.treatments-panel", "treatment-input-style"); BT(fg(zT, T, new R(null, 1, 5, S, [new R(null, 2, 5, S, [".closer--G__28387", new m(null, 1, [YD, "0.625em"], null)], null)], null)), "predict3.layout.treatments-panel", "treatment-input-style");
var RW = QG(function (a, b) { var RW = QG(function (a, b) {
@ -3103,8 +3103,8 @@ if (typeof Math.imul == "undefined" || (Math.imul(0xffffffff, 5) == 0)) {
React.createElement("p", null, "Should ", React.createElement("strong", null, "bisphosphonates"), " be included as a treatment option in this tool? "), Y(OQ(eo)), React.createElement("p", null, "If bisphosphonates are not available as a treatment in your area, you may wish to remove this treatment\n option from the tool."), React.createElement("hr", null), React.createElement("p", null, "Should the tool cover ", React.createElement("strong", null, "10 or 15 years"), " from diagnosis?"), Y(OQ(lm)), React.createElement("hr", React.createElement("p", null, "Should ", React.createElement("strong", null, "bisphosphonates"), " be included as a treatment option in this tool? "), Y(OQ(eo)), React.createElement("p", null, "If bisphosphonates are not available as a treatment in your area, you may wish to remove this treatment\n option from the tool."), React.createElement("hr", null), React.createElement("p", null, "Should the tool cover ", React.createElement("strong", null, "10 or 15 years"), " from diagnosis?"), Y(OQ(lm)), React.createElement("hr",
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"))))) 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, }, 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"), aX = QG(function () { 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); 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 = 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], 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") 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 () { }()), " 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 () {
@ -3117,10 +3117,8 @@ if (typeof Math.imul == "undefined" || (Math.imul(0xffffffff, 5) == 0)) {
React.createElement("div", { key: 2, className: "row" }, React.createElement("div", { style: { marginBottom: 20 }, className: "col-xs-12" }, Y(QW.l ? QW.l() : QW.call(null)))))), React.createElement("div", { className: "row screen-only" }, React.createElement("div", { style: { backgroundColor: "#ffffff" }, className: "col-sm-12" }, React.createElement("div", { key: 3, className: "row" }, React.createElement("div", { key: 2, className: "col-sm-10 col-sm-offset-1" }, Y(aX.l ? aX.l() : aX.call(null)))))), Y(uU(0)), function () { React.createElement("div", { key: 2, className: "row" }, React.createElement("div", { style: { marginBottom: 20 }, className: "col-xs-12" }, Y(QW.l ? QW.l() : QW.call(null)))))), React.createElement("div", { className: "row screen-only" }, React.createElement("div", { style: { backgroundColor: "#ffffff" }, className: "col-sm-12" }, React.createElement("div", { key: 3, className: "row" }, React.createElement("div", { key: 2, className: "col-sm-10 col-sm-offset-1" }, Y(aX.l ? aX.l() : aX.call(null)))))), Y(uU(0)), function () {
var a = $W.l ? $W.l() : $W.call(null); var a = $W.l ? $W.l() : $W.call(null);
return gg(React.createElement, "div", M(a) ? EG(rG(C([new m(null, 1, [Rx, new R(null, 1, 5, S, ["screen-only"], null)], null), a]))) : { className: "screen-only" }, M(a) ? new R(null, 1, 5, S, [null], null) : new R(null, 2, 5, S, [Y(a)], null)) return gg(React.createElement, "div", M(a) ? EG(rG(C([new m(null, 1, [Rx, new R(null, 1, 5, S, ["screen-only"], null)], null), a]))) : { className: "screen-only" }, M(a) ? new R(null, 1, 5, S, [null], null) : new R(null, 2, 5, S, [Y(a)], null))
}(), Y(WW.l ? WW.l() : WW.call(null)), Y(ZW.l ? ZW.l() : ZW.call(null)), Y(YW.l ? YW.l() : YW.call(null))], null) : new R(null, 9, 5, S, [Y(b), /*React.createElement("div", { id: "main-content", tabIndex: -1, style: { marginLeft: -30, marginRight: -30 }, className: "row" }, }(), Y(WW.l ? WW.l() : WW.call(null)), Y(ZW.l ? ZW.l() : ZW.call(null)), Y(YW.l ? YW.l() : YW.call(null))], null) : new R(null, 9, 5, S, [Y(b), React.createElement("div", { className: "row screen-only" }, React.createElement("div", { className: "col-md-10 col-md-offset-1" }, React.createElement("div", { key: 2, className: "row" }, React.createElement("div", { style: { marginBottom: 20 }, className: "col-xs-12" }, Y(QW.l ? QW.l() :
React.createElement("div", { className: "col-xs-12" }, React.createElement("div", { style: { position: "relative", width: "100%", backgroundColor: "#d3e7fd" } }, React.createElement("div", { style: { position: "absolute", width: "100%", top: 0, bottom: "20%", opacity: .25, background: "linear-gradient(rgba(255,255,255,0), #fff)" } }), React.createElement("div", QW.call(null)))))),React.createElement("div",{style:{clear:'both'}},reset_call.l ? reset_call.l() : reset_call.call(null))/*important ! here can add items under the form*/, React.createElement("div", { className: "row screen-only" }, React.createElement("div", { style: { backgroundColor: "#ffffff" }, className: "col-sm-12" }, React.createElement("div", { key: 3, className: "row" }, React.createElement("div", { key: 2, className: "col-sm-10 col-sm-offset-1" }, Y(aX.l ? aX.l() : aX.call(null)))))), Y(uU(0)), function () {
{ className: "row print-only" }, gg(React.createElement, "div", M(a) ? EG(rG(C([new m(null, 1, [Rx, new R(null, 2, 5, S, ["col-sm-10", "col-sm-offset-1"], null)], null), a]))) : { className: "col-sm-10 col-sm-offset-1" }, M(a) ? null : new R(null, 1, 5, S, [Y(a)], null)))))),*//*important*/ React.createElement("div", { className: "row screen-only" }, React.createElement("div", { className: "col-md-10 col-md-offset-1" }, React.createElement("div", { key: 2, className: "row" }, React.createElement("div", { style: { marginBottom: 20 }, className: "col-xs-12" }, Y(QW.l ? QW.l() :
QW.call(null)))))),React.createElement("div", { className: "row screen-only" },Y(reset_btn.l ? reset_btn.l() : reset_btn.call(null))), React.createElement("div", { className: "row screen-only" }, React.createElement("div", { style: { backgroundColor: "#ffffff" }, className: "col-sm-12" }, React.createElement("div", { key: 3, className: "row" }, React.createElement("div", { key: 2, className: "col-sm-10 col-sm-offset-1" }, Y(aX.l ? aX.l() : aX.call(null)))))), Y(uU(0)), function () {
var a = $W.l ? $W.l() : $W.call(null); return gg(React.createElement, "div", M(a) ? EG(rG(C([new m(null, 1, [Rx, new R(null, 1, 5, S, ["screen-only"], null)], null), a]))) : { className: "screen-only" }, var a = $W.l ? $W.l() : $W.call(null); return gg(React.createElement, "div", M(a) ? EG(rG(C([new m(null, 1, [Rx, new R(null, 1, 5, S, ["screen-only"], null)], null), a]))) : { className: "screen-only" },
M(a) ? null : new R(null, 2, 5, S, [/*print button*/Y(a)], null)) M(a) ? null : new R(null, 2, 5, S, [/*print button*/Y(a)], null))
}(), Y(WW.l ? WW.l() : WW.call(null)), Y(ZW.l ? ZW.l() : ZW.call(null)), Y(YW.l ? YW.l() : YW.call(null))], null)) }(), Y(WW.l ? WW.l() : WW.call(null)), Y(ZW.l ? ZW.l() : ZW.call(null)), Y(YW.l ? YW.l() : YW.call(null))], null))

View File

@ -2,6 +2,87 @@
Place all the styles related to the matching controller here. Place all the styles related to the matching controller here.
They will automatically be included in application.css. They will automatically be included in application.css.
*/ */
.table .expired{ thead > tr > th{
color: #BE2E2E; 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;
}
.PageDetails {
padding-top: 0.1875em;
padding-bottom: 0.1875em;
font-weight: bold;
font-size: 0.875em;
border-bottom: 0.0625em solid #ddd;
overflow: hidden;
text-align: right;
color: black;
font-size: 1.3em;
}
.PageList {
margin: 0em 0em 0 0.5em;
font-weight: bold;
font-size: 0.875em;
overflow: hidden;
list-style: none;
display: inline;
background: none;
color: #999;
}
ol {
margin: 0 0 0.5em 0;
min-height: 0.625em;
height: auto !important;
height: 0.625em;
padding: 0;
clear: both;
float: right;
}
.PageList li {
display: inline;
} }

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,392 @@
#cancer_table *[data-key]{
padding: 0.375em 0;
display: inline-block;
width: 100%;
}
.head_logo{
height: 4em;
}
.texts_under_result{
font-weight: bold;
padding-top: 1em;
color: #5d7ca2;
}
th.cancer_th.Treatment {
width: 39%;
}
@media screen and (max-width: 48em){
.navbar-brand{
width: 100%;
}
}
div.num_group{
position: relative;
float: left;
width: 5.125em;
height: 2.25em;
margin-left: 1.125em;
}
@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: 4.3em;
height: 1.75em;
left: 0em;
clip: rect(0.25em, 4.3em, 1.5em,3.3em);
border:none;
padding: 0.5em;
}
input.num_only{
margin-left: 0;
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;
}
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: 1em;
}
#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: 15%;
margin: 0;
float: left;
}
.result_content_group{
width: 85%;
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;
}
}
.print_only{
display: none;
}

View File

@ -0,0 +1,402 @@
@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;
}
.texts_under_result{
font-weight: bold;
padding-top: 1em;
color: #5d7ca2;
}
th.cancer_th.Treatment {
width: 39%;
}
div.num_group{
position: relative;
float: left;
width: 5.125em;
height: 2.25em;
margin-left: 1.125em;
}
.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 !important;
}
#cancer_table .cencer_table_name{
width: 16.25em;
}
#cancer_predict_result_block .cencer_table_name{
width: 5em;
}
.cancer_help_btn{
background-color: rgb(210, 106, 2) !important;
border-color: rgb(210, 106, 2) !important;
color: white !important;
}
.cancer_help_btn i:before {
color: white !important;
}
.cancer_table_btn{
margin-right: 0.5em;
color:#5d7ca2 !important;
border-color: #5d7ca2 !important;
font-weight: 600;
}
.cancer_table_btn::last-of-type{
margin-right:auto;
}
#cancer_table{
font-size:0.825em;
color:#5d7ca2;
}
@media print{
#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: 4.3em;
height: 1.75em;
left: 0em;
clip: rect(0.25em, 4.3em, 1.5em,3.3em);
border:none;
padding: 0.5em;
}
input.num_only{
margin-left: 0;
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) !important;
height: 2.25em;
position: absolute;
left: 0;
}
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) !important;
color: white !important;
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) !important;
color: white !important;
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 !important;
background-color: #9dc3e6 !important;
border-color: #8c8c8c !important;
}
.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) !important;
color: white !important;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
font-size: 1.25em;
float: left;
}
.result_tab{
background: #023d79 !important;
background: linear-gradient(135deg, transparent 0.3em, #023d79 0) !important;
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: 1em;
}
#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 !important;
background: linear-gradient(135deg, transparent 0.3em, #d16801 0) !important;
padding: 0.8em 0.125em 0.5em 1em;
margin-left: -0.5em;
}
.result_tab > a{
writing-mode: vertical-lr !important;
-webkit-writing-mode: vertical-lr !important;
color: white !important;
}
.result_tab_group{
display: none;
}
.result_content_group{
width: 100%;
margin: 0;
float: none;
}
.result_content{
display: block;
min-height: 25em;
border: 0.125em solid #c0cbdd !important;
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 !important;
background-color: #003d79 !important;
border-right: 0.375em solid white;
border-top: 0.375em solid white;
}
.cancer_td {
background-color: #e9eaf5 !important;
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;
}
* {
-webkit-print-color-adjust: exact !important;
}
.layout-content{
background: #fff !important;
}
}

View File

@ -1,21 +1,718 @@
# encoding: utf-8 # encoding: utf-8
require 'rubyXL'
class Admin::CancerpredictsController < OrbitAdminController class Admin::CancerpredictsController < OrbitAdminController
require 'spreadsheet'
require 'rubyXL'
require 'fileutils'
require "axlsx"
require "csv"
#include Admin::CancerpredictsHelper #include Admin::CancerpredictsHelper
before_action ->(module_app = @app_title) { set_variables module_app } before_action ->(module_app = @app_title) { set_variables module_app }
before_action :create_first_field
helper Admin::CancerpredictsHelper
#before_action :load_access_levels #before_action :load_access_levels
def initialize def initialize
super super
@app_title = "cancerpredict" @app_title = "cancerpredict"
end end
def index def index
@tags = @module_app.tags @tags = @module_app.tags
@categories = @module_app.categories.enabled @categories = @module_app.categories.enabled
@filter_fields = filter_fields(@categories, @tags) @filter_fields = filter_fields(@categories, @tags)
@table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified] @table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified]
if request.xhr? @head_images_id = @form_to_show.head_images_id
render :partial => "index" @title_images_id = @form_to_show.title_images_id
end @head_images = []
@title_images = []
@head_images_id.each{|image_id| @head_images.push Headimages.find_by(:id=>image_id.to_s)} rescue nil
@title_images_id.each{|image_id| @title_images.push Headimages.find_by(:id=>image_id.to_s)} rescue nil
@head_new_image = Headimages.new(:cancerpredictfields_id => @form_to_show.id)
end end
def edit
other_in_use_locales = Site.first.in_use_locales.map{|l| l.to_s}
other_in_use_locales.delete(params[:locale])
if !(params["cancerpredictfields"].nil?)
if !(params["cancerpredictfields"]["form_show"].nil?)
params["cancerpredictfields"]["form_show"].each do |num,property|
property.each do |key,value|
if key.include?("_file") && (!value[:temp_file].blank? rescue false)
if value[:id].nil?
mapping_file = CancerPredictMappingFile.create(value)
else
mapping_file = CancerPredictMappingFile.find(value[:id])
mapping_file.temp_file = value[:temp_file]
mapping_file.save
end
@form_to_show.form_show[num.to_s][key.to_s] = mapping_file.id
elsif key.include?("_file")
if value[:_destroy] == "1"
mapping_file = CancerPredictMappingFile.find(value[:id])
mapping_file.destroy
@form_to_show.form_show[num.to_s][key.to_s] = ""
end
end
next if key.include?("_file")
if (key != "old_num")
if key != params[:locale]
@form_to_show.form_show[num.to_s] = {} if @form_to_show.form_show[num.to_s].nil?
type = Cancerpredictfields::FIELDINFO[key.to_s]
if type && Cancerpredictfields::Field_relations[type]
type = Cancerpredictfields::Field_relations[type]
end
type = type.constantize rescue String
if type != Array
if type == Fixnum
@form_to_show.form_show[num.to_s][key.to_s] = value.to_i rescue 0
elsif type == Float
@form_to_show.form_show[num.to_s][key.to_s] = value.to_f rescue 0.0
else
@form_to_show.form_show[num.to_s][key.to_s] = value
end
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|
type = Cancerpredictfields::FIELDINFO[sub_property.to_s]
if type && Cancerpredictfields::Field_relations[type]
type = Cancerpredictfields::Field_relations[type]
end
type = type.constantize rescue String
@form_to_show.form_show[ num.to_s ][ sub_property ] = {} if @form_to_show.form_show[num.to_s][ sub_property ].nil?
if type != Array
if type == Fixnum
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value.to_i rescue 0
elsif type == Float
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value.to_f rescue 0.0
else
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value
end
else
if sub_value.length > 2
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = YAML.load(sub_value)
else
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = []
end
end
if(property["old_num"].present? && property["old_num"] != num.to_s)
other_in_use_locales.each do |locale|
@form_to_show.form_show[ num.to_s ][ sub_property ][locale] = @form_to_show.form_show_was[ property["old_num"] ][ sub_property ][locale]
end
end
end
end
end
end
end
org_nums = @form_to_show.form_show_was.keys
remain_org_nums = params["cancerpredictfields"]["form_show"].values.map{|property| property["old_num"]}.select{|n| n.present?}
delete_nums = org_nums - remain_org_nums
if !delete_nums.blank?
delete_nums.each do |delete_num|
@form_to_show.form_show.delete(delete_num)
end
end
@form_to_show.form_show = @form_to_show.form_show.values.map.with_index{|v,i| [i.to_s, v]}.to_h
else
@form_to_show.form_show = {}
end
if !params["cancerpredictfields"]["form_show_in_result"].nil?
params["cancerpredictfields"]["form_show_in_result"].each do |num,property|
property.each do |key,value|
if key.include?("_file") && (!value[:temp_file].blank? rescue false)
if value[:id].nil?
mapping_file = CancerPredictMappingFile.create(value)
else
mapping_file = CancerPredictMappingFile.find(value[:id])
mapping_file.temp_file = value[:temp_file]
mapping_file.save
end
@form_to_show.form_show[num.to_s][key.to_s] = mapping_file.id
elsif key.include?("_file")
if value[:_destroy] == "1"
mapping_file = CancerPredictMappingFile.find(value[:id])
mapping_file.destroy
@form_to_show.form_show_in_result[num.to_s][key.to_s] = ""
end
end
next if key.include?("_file")
if (key != "old_num")
if key != params[:locale]
@form_to_show.form_show_in_result[num.to_s] = {} if @form_to_show.form_show_in_result[num.to_s].nil?
type = Cancerpredictfields::FIELDINFO[key.to_s]
if type && Cancerpredictfields::Field_relations[type]
type = Cancerpredictfields::Field_relations[type]
end
type = type.constantize rescue String
if type != Array
if type == Fixnum
@form_to_show.form_show_in_result[num.to_s][key.to_s] = value.to_i rescue 0
elsif type == Float
@form_to_show.form_show_in_result[num.to_s][key.to_s] = value.to_f rescue 0.0
else
@form_to_show.form_show_in_result[num.to_s][key.to_s] = value
end
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|
type = Cancerpredictfields::FIELDINFO[sub_property.to_s]
if type && Cancerpredictfields::Field_relations[type]
type = Cancerpredictfields::Field_relations[type]
end
type = type.constantize rescue String
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ] = {} if @form_to_show.form_show_in_result[num.to_s][ sub_property ].nil?
if type != Array
if type == Fixnum
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value.to_i rescue 0
elsif type == Float
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value.to_f rescue 0.0
else
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value
end
else
if sub_value.length > 2
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = YAML.load(sub_value)
else
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = []
end
end
if(property["old_num"].present? && property["old_num"] != num.to_s)
other_in_use_locales.each do |locale|
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][locale] = @form_to_show.form_show_was[ property["old_num"] ][ sub_property ][locale]
end
end
end
end
end
end
end
org_nums = @form_to_show.form_show_in_result_was.keys
remain_org_nums = params["cancerpredictfields"]["form_show_in_result"].values.map{|property| property["old_num"]}.select{|n| n.present?}
delete_nums = org_nums - remain_org_nums
if !delete_nums.blank?
delete_nums.each do |delete_num|
@form_to_show.form_show_in_result.delete(delete_num)
end
end
@form_to_show.form_show_in_result = @form_to_show.form_show_in_result.values.map.with_index{|v,i| [i.to_s, v]}.to_h
else
@form_to_show.form_show_in_result = {}
end
@create_items = ['title_texts','form_result_is_right','text_descibe','years','table_above_texts','text_above_texts','surgery_only_texts','extra_texts','extra_therapy_texts','danger_texts','texts_between_Result_and_result_block','prediction_formula','hidden_variables','advance_mode','years_settings']
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)
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
if params_cancer[item].class != Array
@form_to_show[item] = YAML.load(params_cancer[item]) rescue []
else
@form_to_show[item] = params_cancer[item]
end
@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
file_ids = (@form_to_show.form_show.values + @form_to_show.form_show_in_result.values).map{|property| [property[:variable],property[:cancer_predict_mapping_file]]}.select{|k,f| f.present?}.to_h
mapping_data_from_csv = {}
if !file_ids.blank?
file_ids.each do |k,v|
mapping_data_from_csv[k] = read_mapping_file(v)
end
end
@form_to_show.mapping_data_from_csv = mapping_data_from_csv.to_json
@form_to_show.save
fork do
@form_to_show.auto_write_predict_js
end
end
@index = 0
Dir.chdir("public") do
while File.exist?('cancerfield_back'+@index.to_s+'.txt')
@index += 1
end
end
Dir.chdir("public") do
@site_locales = Site.last.in_use_locales.each do |locale|
I18n.with_locale(locale) do
@file_tmp = File.new('cancer_tool_table_tmp_'+locale.to_s+'.txt', 'w')
tmp_table_texts = create_table(locale)
@file_tmp.write(tmp_table_texts)
@file_tmp.close
end
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 create_table(current_locale)
create_first_field
current_site = Site.last
@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[current_locale] +'</div>'
@table_str += '<div id="font_size_choices">'+'<label id="font_texts">'+t('cancerpredict.font_size').titleize+':</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).titleize+'</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
@disp_value
if @value.class == BSON::Document || @value.class == Hash
@disp_value = @value[current_locale] rescue ""
else
@disp_value = @value
end
@disp_value = "" if @disp_value.nil?
@field_property[key] = @disp_value
end
if @field_property['right'] == 0
next if @field_property["name"].blank?
@table_str_left += '<div data-key='+num.to_s+'>'
@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"].present?
@table_str_left += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_str_left += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@site_locales = current_site.in_use_locales
@site_locales.delete(current_locale)
@site_locales.each do |locale|
next if property["comment_text"][locale.to_s].blank?
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"].present?
@table_str_left += '<button tabindex="0" class="cancer_help_btn" data-target="#show_help_modal" style="float:left;cursor: pointer;padding: 0em 0.475em;font-size: 1.25em;border-radius: 15px;background-color: rgb(210, 106, 2);border-color: rgb(210, 106, 2);color: white;"><i aria-hidden="true" class="fa fa-question"></i></button>'
@table_str_left += '<input class="help_texts" type="hidden" value="'+@field_property["comment_text"]+'" name='+@field_property["variable"]+'/>'
else
@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+'"/><input class="num_only_value" type="hidden" /></div>'
else
if @field_property["range"] == []
@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 = (current_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.titleize + '</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
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.titleize+'</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"].present?
@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(current_locale)
@site_locales.each do |locale|
next if property["comment_text"][locale.to_s].blank?
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"].present?
@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+'"/><input class="num_only_value" type="hidden" /></div>'
else
if @field_property["range"] == []
@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_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 = (current_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.titleize + '</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
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.titleize+'</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 class="texts_under_result">' + @form_to_show.texts_between_Result_and_result_block[current_locale]+'</div>'
@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[current_locale.to_s] rescue ""
else
@disp_value = @value
end
@disp_value = "" if @disp_value.nil?
@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"].present?
@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(current_locale)
@site_locales.each do |locale|
next if property["comment_text"][locale.to_s].blank?
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"].present?
@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+'"/><input class="num_only_value" type="hidden" /></button>'
else
if @field_property["range"] == []
@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_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 = (current_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.titleize + '</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
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.titleize+'</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>')
return @table_str
end
def showSubmit
@page_num = params[:page] || 1
@results = Cancerpredictrecord.where("title"=>@app_title).desc(:id).page(@page_num).per(10)
@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=[]
@choicenames=[]
if @results.length != 0
@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
@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
@pagination = create_pagination(@page_num.to_i)
end
def export_cancer_tool_record
cancer_records = Cancerpredictrecord.where("title"=>@app_title).desc(:id)
dir_path = 'tmp/cancer_tool/'
#FileUtils.rm_r(dir_path, :force => true) if Dir.exist?(dir_path)
FileUtils.mkdir dir_path if !Dir.exist?(dir_path) #create dir for storing tmp_file if dir doesn't exist
@filename = ("#{Time.now.year}_%02s_%02s_export_cancer_tool_record.xlsx"%[Time.now.month,Time.now.day]).gsub(" ","0")
Dir.chdir(dir_path) do
File.open(@filename, 'w') do |f|
f.write render_to_string( :handlers=> [:axlsx], :formats=> [:xlsx] ,:partial=> 'export_cancer_tool_record.xlsx',:locals=> {:results=> cancer_records} )
end
end
tmp_filename_data = File.read(dir_path +@filename)
send_data(tmp_filename_data, type: 'application/xlsx', disposition: 'attachment', filename: @filename)
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
Dir.chdir("public") do
@site_locales = Site.last.in_use_locales.each do |locale|
I18n.with_locale(locale) do
@file_tmp = File.new('cancer_tool_table_tmp_'+locale.to_s+'.txt', 'w')
tmp_table_texts = create_table(locale)
@file_tmp.write(tmp_table_texts)
@file_tmp.close
end
end
end
else
@form_to_show = Cancerpredictfields.where("title"=>@app_title).first
end
end
def create_pagination(page=1,fields=Cancerpredictrecord.all,extra_params="")
page = 1 if page == 0
per_page_num = 10.0
all_page_num = (fields.count / per_page_num).ceil
all_page_num = 1 if all_page_num == 0
pagination = '<div class="PageDetails">'+((I18n.locale.to_s == 'zh_tw') ? "#{page}" : "page #{page}") +'/'+ ((I18n.locale.to_s == 'zh_tw') ? "#{all_page_num}" : "Total #{all_page_num} page(s)")+'<ol class="PageList">'+
((page == 1) ? '<li>['+I18n.t('cancerpredict.prev_page')+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+(page-1).to_s+'"> ['+I18n.t('cancerpredict.prev_page')+'] </a></li>')
if all_page_num > 7
if page <= (all_page_num / 2)
if page <= 7
(1..page).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
else
(1..3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(page-3..page).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
end
(page+1..page+3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(all_page_num-2..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
else
(1..3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(page-3..page).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
if all_page_num - page <= 7
(page+1..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
else
(page+1..page+3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(all_page_num-2..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
end
end
else
(1..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
end
pagination += (((page==all_page_num) ? '<li>['+I18n.t('cancerpredict.next_page')+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+(page+1).to_s+'"> ['+I18n.t('cancerpredict.next_page')+'] </a></li>')+'</ol></div>')
end
def read_mapping_file(mapping_file_id)
mapping_file = CancerPredictMappingFile.find(mapping_file_id) rescue nil
if !mapping_file.nil?
csv_rows = CSV.read(mapping_file.temp_file.file.path)
titles = csv_rows[0]
infos = {}
titles.each_with_index do |title,i|
infos[title] = []
csv_rows[1..-1].each do |row|
infos[title] << row[i].to_f
end
end
return infos
else
return {}
end
end
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,221 @@
# encoding: utf-8 # encoding: utf-8
require 'rubyXL' require 'rubyXL'
require "json"
class CancerpredictsController < ApplicationController class CancerpredictsController < ApplicationController
before_filter :set_I18n
before_action ->(module_app = @app_title) { set_variables module_app }
#before_action :load_access_levels
def initialize def initialize
super super
@app_title = "cancerpredict" @app_title = "cancerpredict"
end end
def calculate
create_first_field
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]]
elsif params['get_mapping_data_from_csv'].to_i == 1
result = {}
result['mapping_data_from_csv'] = JSON.parse(@form_to_show.mapping_data_from_csv) rescue {}
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[:is_num] == 1) ? [] : 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 = {}
mapping_data_from_csv = JSON.parse(@form_to_show.mapping_data_from_csv) rescue {}
@form_to_show.all_variables.each do |v|
result[v] = 0
end
@form_to_show.form_show.each do |num,property|
@variable = property[:variable]
if @variable.present?
if property[:is_num] == 1
if property[:is_float] == 1
result[@variable] = params['data'][@variable].to_f rescue 0.0
else
result[@variable] = params['data'][@variable].to_i rescue 0
end
elsif property[:choice_fields].present?
if !(@form_to_show.advance_mode)
result[@variable] = params['data'][@variable].to_i rescue 0
else
if property[:need_map_values] == 1
result[@variable] = property[:map_values][params['data'][@variable].to_i - 1]
else
if property[:revert_value] != 1
result[@variable] = params['data'][@variable].to_i - 1
else
result[@variable] = ((property[:choice_fields].length - params['data'][@variable].to_i) rescue params['data'][@variable].to_i)
end
end
end
end
if @form_to_show.advance_mode && property[:cancer_predict_mapping_file].present?
if (mapping_data_from_csv != {})
mapping_hash = mapping_data_from_csv[@variable]
temp_index = 0
temp_value = result[@variable]
mapping_hash.each_with_index do |(k,v),i|
if i == 0
index_val = v.index(temp_value) rescue nil
if !index_val.nil?
temp_index = index_val
else
closest_value = v.min_by{|x| (temp_value-x).abs}
temp_index = v.index(closest_value)
end
end
result[k] = v[temp_index]
end
end
end
end
end
formula_variables = @form_to_show.tmp_lpv_variables
begin
eval_hidden_variables(result)
rescue => e
@form_to_show.generate_eval_formula
eval_hidden_variables(result)
end
begin
eval_formula(result)
rescue => e
@form_to_show.generate_eval_formula
eval_formula(result)
end
result['lpv'] = result[formula_variables.last]
result['lpv_variable'] = {}
formula_variables.each do |variable_name|
result['lpv_variable']["#{variable_name}"] = result[variable_name]
end
@years = @form_to_show.years
result['years'] = @years
@therapy_choices = [I18n.t('cancerpredict.table.Surgeryonly')]
@form_to_show.form_show_in_result.values.each{|choice| @therapy_choices.push choice["name"][locale]}
@therapy_names = @form_to_show.treatment_method
result['treatment_method'] = @therapy_names
result['treatment_method_active_indices'] = @form_to_show.treatment_method_active_indices
result['table'] = @form_to_show.result_table_translations[locale]
year = params['data']['year'] rescue nil
if year.nil?
year = @years.first.to_f
else
year = year.to_f
end
year_index = @years.index(year)
@servive_ratio = eval(@form_to_show.tmp_years_settings_for_ruby[year_index])
@servive_ratio = ((1 - @servive_ratio) * 100).round(2)
result['texts'] = @form_to_show.result_text_translations[locale]
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
end
def index def index
uid = OrbitHelper.params[:uid] rescue "" uid = OrbitHelper.params[:uid] rescue ""
tags = OrbitHelper.widget_tags tags = OrbitHelper.widget_tags
categories = OrbitHelper.widget_categories || [] categories = OrbitHelper.widget_categories || []
locale = OrbitHelper.get_site_locale.to_s @table_str = File.read('public/cancer_tool_table_tmp_'+I18n.locale.to_s+'.txt')
preidct_js_url = '/assets/cancer_predict.js'
if File.exist?('public/cancer_tool_js_filename.txt')
js_filename = File.read('public/cancer_tool_js_filename.txt')
if js_filename.match(/cancer_predict\.js$/)
asset = Rails.application.assets[js_filename]
preidct_js_url = "#{Rails.application.config.assets.prefix}/#{asset.digest_path}"
else
preidct_js_url = "#{Rails.application.config.assets.prefix}/#{File.basename(js_filename)}"
end
end
{
"cancerpredict" => [],
"extras"=>{"table"=> @table_str,'preidct_js_url'=>preidct_js_url}
}
end end
def widget def widget
uid = OrbitHelper.params[:uid] rescue "" uid = OrbitHelper.params[:uid] rescue ""
tags = OrbitHelper.widget_tags tags = OrbitHelper.widget_tags
categories = OrbitHelper.widget_categories || [] categories = OrbitHelper.widget_categories || []
locale = OrbitHelper.get_site_locale.to_s @table_str = File.read('public/cancer_tool_table_tmp_'+I18n.locale.to_s+'.txt')
preidct_js_url = '/assets/cancer_predict.js'
if File.exist?('public/cancer_tool_js_filename.txt')
js_filename = File.read('public/cancer_tool_js_filename.txt')
if js_filename.match(/cancer_predict\.js$/)
asset = Rails.application.assets[js_filename]
preidct_js_url = "#{Rails.application.config.assets.prefix}/#{asset.digest_path}"
else
preidct_js_url = "#{Rails.application.config.assets.prefix}/#{File.basename(js_filename)}"
end
end
{
"cancerpredict" => [],
"extras"=>{"table"=> @table_str,'preidct_js_url'=>preidct_js_url}
}
end end
def set_I18n def create_first_field
I18n.locale = params[:lang] if params[:lang].present? if Cancerpredictfields.where("title"=>(@app_title + "_back")).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).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
def read_mapping_file(mapping_file)
if mapping_file.class != CancerPredictMappingFile
mapping_file = CancerPredictMappingFile.find(mapping_file_id) rescue nil
end
if !mapping_file.nil?
csv_rows = CSV.read(mapping_file.temp_file.file.path)
titles = csv_rows[0]
infos = {}
titles.each_with_index do |title,i|
infos[title] = []
csv_rows[1..-1].each do |row|
infos[title] << row[i].to_f
end
end
return infos
else
return {}
end
end end
end end

View File

@ -1,7 +1,37 @@
require "net/http"
require "uri"
require 'json'
module Admin::CancerpredictsHelper module Admin::CancerpredictsHelper
def create_pagination(page=1,fields=Cancerpredictrecord.all,extra_params="")
page = 1 if page == 0
per_page_num = 10.0
all_page_num = (fields.count / per_page_num).ceil
pagination = '<div class="PageDetails">'+((I18n.locale.to_s == 'zh_tw') ? "#{page}" : "page #{page}") +'/'+ ((I18n.locale.to_s == 'zh_tw') ? "#{all_page_num}" : "Total #{all_page_num} page(s)")+'<ol class="PageList">'+
((page == 1) ? '<li>['+I18n.t('cancerpredict.prev_page')+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+(page-1).to_s+'"> ['+I18n.t('cancerpredict.prev_page')+'] </a></li>')
if all_page_num > 7
if page <= (all_page_num / 2)
if page <= 7
(1..page).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
else
(1..3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(page-3..page).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
end
(page+1..page+3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(all_page_num-2..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
else
(1..3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(page-3..page).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
if all_page_num - page <= 7
(page+1..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
else
(page+1..page+3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(all_page_num-2..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
end
end
else
(1..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
end
pagination += (((page==all_page_num) ? '<li>['+I18n.t('cancerpredict.next_page')+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+(page+1).to_s+'"> ['+I18n.t('cancerpredict.next_page')+'] </a></li>')+'</ol></div>')
end
end end

View File

@ -0,0 +1,10 @@
# encoding: utf-8
class CancerPredictMappingFile
include Mongoid::Document
include Mongoid::Timestamps
mount_uploader :temp_file, HeadImagesUploader
def file_identifier
filename = self.temp_file.file.original_filename rescue ""
end
end

View File

@ -1,64 +1,525 @@
class Cancerpredictfields class Cancerpredictfields
require "pathname"
require 'json'
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
include OrbitModel::Status Field_relations = {"number_field"=>"Fixnum","text_area"=>"String"}
include OrbitModel::Impression FIELDINFO = {"variable"=>"String","name"=>"String","is_num"=>"Fixnum","hint"=>"String","comment_text"=>"String","choice_fields"=>"Array","range"=>"Array","right"=>"Fixnum","is_float"=>"Fixnum","revert_value"=>"Fixnum","map_values"=>"Array","cancer_predict_mapping_file"=>"String","lpv_impact"=>"Float","active_choice"=>"number_field","disable_condition"=>"text_area"}
# encoding: utf-8 NonLoclaized = ["variable","is_num","range","right","is_float","revert_value","map_values","cancer_predict_mapping_file","lpv_impact","active_choice","disable_condition"]
include OrbitTag::Taggable AdvanceFields = ["revert_value","map_values","cancer_predict_mapping_file"]
include OrbitCategory::Categorizable TherapyFields = ["variable","name","hint","comment_text","choice_fields","lpv_impact","active_choice","disable_condition"]
field :font_array , :type => Hash, default:{} TherapyOnly = ["lpv_impact","active_choice","disable_condition"]
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 :title ,type:String ,default:""
field :subtitle, localize: true field :advance_mode, type: Boolean, default: true
field :text, localize: true field :form_show , :type=> Hash ,default:{
# before_destroy :destroy_email "0"=>{"variable"=>"sex_value", "name"=>{"zh_tw"=>"性別<br/>(Sex)", "en"=>"Sex"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", ""], "en"=>["Male", "Female"]}, "range"=>[], "right"=>0, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "cancer_predict_mapping_file"=>"", "need_map_values"=>0},
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])} "1"=>{"variable"=>"age", "name"=>{"zh_tw"=>"年齡<br/>(Age)", "en"=>"Age"}, "is_num"=>1, "hint"=>{"zh_tw"=>"從 20 歲(含)開始至 98 歲", "en"=>"Age must be between 20 and 98"}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>[], "en"=>[]}, "range"=>[20, 98], "right"=>0, "is_float"=>0, "revert_value"=>0, "map_values"=>[], "cancer_predict_mapping_file"=>BSON::ObjectId('5f8e60441d41c801f600011a'), "need_map_values"=>0},
scope :is_approved, ->{where(:approved => true)} "2"=>{"variable"=>"calH", "name"=>{"zh_tw"=>"心臟鈣化分數<br/>(Heart Calcification score)", "en"=>"Heart Calcification score"}, "is_num"=>1, "hint"=>{"zh_tw"=>"請輸入0到5000的數字", "en"=>"Please enter a number between 0 and 5000"}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>[], "en"=>[]}, "range"=>[0, 5000], "right"=>0, "is_float"=>1, "revert_value"=>0, "map_values"=>[], "cancer_predict_mapping_file"=>BSON::ObjectId('5f8e66c71d41c801f6000139'), "need_map_values"=>0},
before_create :delete_empty_font ,:get_font_to_store,:set_un_used_font , :set_used_font "3"=>{"variable"=>"calAH", "name"=>{"zh_tw"=>"升主動脈鈣化分數", "en"=>"Aorta ascendens Calcification score"}, "hint"=>{"zh_tw"=>"請輸入0到10000的數字", "en"=>"Please enter a number between 0 and 10000"}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>[], "en"=>[]}, "is_num"=>1, "range"=>[0, 10000], "right"=>0, "is_float"=>1, "revert_value"=>0, "map_values"=>[], "cancer_predict_mapping_file"=>BSON::ObjectId('5f8e6ded1d41c801f600013d'), "need_map_values"=>0},
before_update :delete_empty_font ,:get_font_to_store,:set_un_used_font , :set_used_font "4"=>{"variable"=>"calDH", "name"=>{"zh_tw"=>"降主動脈鈣化分數", "en"=>"Aorta descendens Calcification score"}, "hint"=>{"zh_tw"=>"請輸 入0到10000的數字", "en"=>"Please enter a number between 0 and 10000"}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>[], "en"=>[]}, "is_num"=>1, "range"=>[0, 10000], "right"=>0, "is_float"=>1, "revert_value"=>0, "map_values"=>[], "cancer_predict_mapping_file"=>BSON::ObjectId('5f8e6ded1d41c801f600013e'), "need_map_values"=>0},
before_save :delete_empty_font ,:get_font_to_store,:set_un_used_font , :set_used_font "5"=>{"variable"=>"fat", "name"=>{"zh_tw"=>"脂肪分數", "en"=>"Fat"}, "hint"=>{"zh_tw"=>"請輸入20到408的數字", "en"=>"Please enter a number between 20 and 408"}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>[], "en"=>[]}, "is_num"=>1, "range"=>[20, 408], "right"=>0, "is_float"=>1, "revert_value"=>0, "map_values"=>[], "cancer_predict_mapping_file"=>BSON::ObjectId('5f8e6ded1d41c801f600013f'), "need_map_values"=>0},
after_update :set_config "6"=>{"variable"=>"N4", "name"=>{"zh_tw"=>"腫瘤", "en"=>"Neoplasia"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>["yes", "no"]}, "is_num"=>0, "range"=>[], "right"=>0, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "cancer_predict_mapping_file"=>"", "need_map_values"=>0},
after_save :set_config "7"=>{"variable"=>"N12", "name"=>{"zh_tw"=>"癡呆症", "en"=>"Dementias"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>["yes", "no"]}, "is_num"=>0, "range"=>[], "right"=>0, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "cancer_predict_mapping_file"=>"", "need_map_values"=>0},
"8"=>{"variable"=>"N20", "name"=>{"zh_tw"=>"慢性肝炎", "en"=>" Chronic hepatitis"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>["yes", "no"]}, "is_num"=>0, "range"=>[], "right"=>0, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "cancer_predict_mapping_file"=>"", "need_map_values"=>0},
"9"=>{"variable"=>"N31", "name"=>{"zh_tw"=>"垂體侏儒症", "en"=>" Pituitary dwarfism"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>["yes", "no"]}, "is_num"=>0, "range"=>[], "right"=>0, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "cancer_predict_mapping_file"=>"", "need_map_values"=>0},
"10"=>{"variable"=>"O6", "name"=>{"zh_tw"=>"慢性腎病", "en"=>" Chronic Kidney Disease"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>["yes", "no"]}, "is_num"=>0, "range"=>[], "right"=>1, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "cancer_predict_mapping_file"=>"", "need_map_values"=>0},
"11"=>{"variable"=>"N34", "name"=>{"zh_tw"=>"克羅恩病和潰瘍性結腸炎", "en"=>"Crohn's disease and ulcerative colitis"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>["yes", "no"]}, "is_num"=>0, "range"=>[], "right"=>1, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "cancer_predict_mapping_file"=>"", "need_map_values"=>0},
"12"=>{"variable"=>"N14", "name"=>{"zh_tw"=>"帕金森氏", "en"=>"Parkinson's disease"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>["yes", "no"]}, "is_num"=>0, "range"=>[], "right"=>1, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "cancer_predict_mapping_file"=>"", "need_map_values"=>0},
"13"=>{"variable"=>"N26", "name"=>{"zh_tw"=>"多發性硬化症", "en"=>"Multiple sclerosis"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>["yes", "no"]}, "is_num"=>0, "range"=>[], "right"=>1, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "cancer_predict_mapping_file"=>"", "need_map_values"=>0},
"14"=>{"variable"=>"O3", "name"=>{"zh_tw"=>"高血壓", "en"=>"Multiple sclerosis"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>["yes", "no"]}, "is_num"=>0, "range"=>[], "right"=>1, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "cancer_predict_mapping_file"=>"", "need_map_values"=>0},
"15"=>{"variable"=>"O20", "name"=>{"zh_tw"=>"嚴重精神疾病", "en"=>"Severe mental illness"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>["yes", "no"]}, "is_num"=>0, "range"=>[], "right"=>1, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "cancer_predict_mapping_file"=>"", "need_map_values"=>0},
"16"=>{"variable"=>"O18", "name"=>{"zh_tw"=>"類風溼關節炎", "en"=>"Rheumatoid arthritis"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>["yes", "no"]}, "is_num"=>0, "range"=>[], "right"=>1, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "cancer_predict_mapping_file"=>"", "need_map_values"=>0},
"17"=>{"variable"=>"O11", "name"=>{"zh_tw"=>"非出血性腦血管疾病", "en"=>"Non-Hemorrhagic Cerebrovascular Disease"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>["yes", "no"]}, "is_num"=>0, "range"=>[], "right"=>1, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "need_map_values"=>0},
"18"=>{"variable"=>"N29", "name"=>{"zh_tw"=>"強直性脊柱炎", "en"=>"Ankylosing spondylitis"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>["yes", "no"]}, "is_num"=>0, "range"=>[], "right"=>1, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "need_map_values"=>0},
"19"=>{"variable"=>"N6", "name"=>{"zh_tw"=>"動脈血管", "en"=>"Arterial vasculopathy"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>["yes", "no"]}, "range"=>[], "right"=>1, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "need_map_values"=>0},
"20"=>{"variable"=>"O14", "name"=>{"zh_tw"=>"葡萄糖不耐症", "en"=>nil}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>nil}, "comment_text"=>{"zh_tw"=>"", "en"=>nil}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>nil}, "range"=>[], "right"=>1, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "need_map_values"=>0},
"21"=>{"variable"=>"N43", "name"=>{"zh_tw"=>"Basedow's disease", "en"=>nil}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>nil}, "comment_text"=>{"zh_tw"=>"", "en"=>nil}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>nil}, "range"=>[], "right"=>1, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "need_map_values"=>0},
"22"=>{"variable"=>"O17", "name"=>{"zh_tw"=>"偏頭痛", "en"=>nil}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>nil}, "comment_text"=>{"zh_tw"=>"", "en"=>nil}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>nil}, "range"=>[], "right"=>1, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "need_map_values"=>0},
"23"=>{"variable"=>"O9", "name"=>{"zh_tw"=>"心臟衰竭", "en"=>nil}, "hint"=>{"zh_tw"=>"", "en"=>nil}, "comment_text"=>{"zh_tw"=>"", "en"=>nil}, "choice_fields"=>{"zh_tw"=>["", "沒有"], "en"=>nil}, "is_num"=>0, "range"=>[], "right"=>1, "is_float"=>0, "revert_value"=>1, "map_values"=>[], "need_map_values"=>0}
}
field :form_show_in_result , :type=> Hash ,default: {}
field :form_result_is_right , :type=> Integer ,default: 0
field :text_descibe ,type:Hash ,default: {
"zh_tw"=>"歡迎使用台灣心血管 疾病預後預測系統<br />\r\n本預測系統由全民健保資料庫2017年~2020年間共1700位病人電腦斷層影像所建立之預測模型<br />\r\n請 在下方填入相關資訊",
"en"=>"Welcome to the Taiwan cardiovascular disease prognosis prediction&nbsp;System!<br />\r\nThe prediction system is a prediction model established by CT images of 1,700 patients form the National Health Insurance Database&nbsp;between 2017 to 2020.<br />\r\nTo start, please select 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: []
field :title_images_id ,type:Array , default: []
field :title_texts ,type:Hash ,default: {"zh_tw"=>"臺灣心血管疾病存活預測", "en"=>"Cardiovascular Disease Survival Forecast in Taiwan"}
field :table_above_texts ,type:Hash ,default: {"zh_tw"=>"下表之分析為針對手術後病人,根據選定的術後治療,分別估計在一年、一年半、兩年及兩年半的心血管疾病住院或死亡機率。", "en"=>"The analysis is for women who had undergone surgery.The table shows the 1,1.5, 2 and 2.5 year survival rates,based on the treatment you have selected."}
field :text_above_texts ,type:Hash ,default: {"zh_tw"=>"此研究分析來自於照射胸部電腦斷層所得之結果,根據您所輸入的資訊,在第{{years}}年內,有{{Surgery_only}}%的 機率可能心血管疾病住院或死亡。", "en"=>"This research comes from the results obtained by irradiating the chest CT. According to the information you entered that you have the {{Surgery_only}}% of hospitalization or death for cardiovascular disease within {{years}} years."}
field :surgery_only_texts ,type:Hash ,default: {"zh_tw"=>"", "en"=>""}
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, 1.5, 2, 2.5]
field :texts_between_Result_and_result_block ,type:Hash ,default: {"zh_tw"=>"如果欲將預測結果應用於臨床上,請務必與您的主治醫師討論後再做最後決定。", "en"=>"Please note that the patients need to consult with their medical doctors before making any decision."}
#field :image_uploader ,type:Object
field :prediction_formula , type: String ,default: "A = 0.1327868* (sex_value- 0.4858824)
+ 0.0371720* (age_test1 - 61.56000) -0.07447278* (age_test2 - 13.10152)
+ 0.4315686* (age_test3 - 0.9844332)
+ 0.0009163615*( calH_test1 - 182.9347)
-0.0007536899*( calH_test2 - 124.8706) -0.00004697183*( calH_test3 -80.75636)
+ 0.0001401325*( calAH_test1 - 700.7824)
-0.001349783*( calAH_test2 - 634.2167) +0.001753832*( calAH_test3 -419.3361)
+ 0.0001906046*( calDH_test1 -835.2894) -0.000251567*( calDH_test2 - 213.1630)
-0.002173942*( fat_test1 -108.4149)+0.003066541*( fat_test2 - 28.33497)
+0.6700708*(N4-0.3241176)
+0.3336162*(O3-0.4994118)
+0.1322476*(O20-0.1741176)
+0.9084972*(O18-0.008823529)
+0.2978388*(N12-0.1152941)
+0.1777935*(N20-0.3582353)
+1.588042*(N31-0.002352941)
+0.2197419*(O6-0.07823529)
+1.791159*(N34-0.001176471)
+0.4305973*(N14-0.02176471)
-0.4472885*(N29-0.02411765)
+0.2601319*(N26-0.04941176)
-0.2364269*(O11-0.1164706)
+0.1784179*(N6-0.1070588)
+0.6023170*(O14-0.01294118)
-1.031959*(N43-0.007058824)
+0.4257809*(O17-0.01823529)
+0.2002546*(O9-0.06176471)"
field :years_settings , type: Array , default: ["0.8095037^( exp(A) )", "0.729158^( exp(A) )", "0.6717211^( exp(A) )", "0.6056773^( exp(A) )"]
field :tmp_years_settings , type: Array , default: []
field :tmp_years_settings_for_ruby , type: Array , default: []
field :hidden_variables, type: String, default: ""
field :fix_hidden_variables, type: Array, default: []
field :tmp_hidden_variables_for_ruby, type: String, default: ""
field :tmp_hidden_variables_for_js, type: String, default: ""
field :lpv_calc, type: Hash, default: {} #for js code
field :tmp_lpv_ruby_code, type: String, default: ""
field :tmp_lpv_variables, type: Array, default: []
field :mapping_data_from_csv , type: String ,default: ""
field :all_variables, type: Array, default: []
field :treatment_method, type: Array, default: ['Surgery_only']
field :treatment_method_active_indices, type: Array, default: [1]
field :result_table, type: String, default: "", localize: true
field :result_text, type: String, default: "", localize: true
field :therapy_lpv, type: Array, default: [0]
#before_create :set_expire #before_create :set_expire
def delete_empty_font before_save do
self.font_array.each do |font,istrue| self.form_show.each do |num,property|
if font.strip == "" property[:need_map_values] = (property[:map_values].class == Array && property[:choice_fields].class == Array && property[:map_values].length == property[:choice_fields].length) ? 1 : 0
self.font_array.delete(font) end
end result_keys = []
end self.form_show.each do |num,property|
variable_name = property[:variable]
if variable_name.present?
result_keys << variable_name
end
end
self.form_show_in_result.each do |num,property|
variable_name = property[:variable]
if variable_name.present?
result_keys << variable_name
end
end
mapping_data = JSON.parse(self.mapping_data_from_csv) rescue {}
if self.advance_mode && mapping_data.present?
mapping_data.each do |k,v|
result_keys += (v.keys rescue [])
end
end
result_keys = result_keys.uniq
self.all_variables = result_keys
formula = text_to_math(self.prediction_formula)
tmp_hidden_variables = text_to_math(self.hidden_variables)
result_keys.each do |k|
formula = formula.gsub(/(\A|[^\w])#{k}($|[^\w])/){|f| "#{$1}result[\"#{k.strip}\"]#{$2}" }
tmp_hidden_variables = tmp_hidden_variables.gsub(/(\A|[^\w])#{k}($|[^\w])/){|f| "#{$1}result[\"#{k.strip}\"]#{$2}" }
end
self.tmp_hidden_variables_for_js = tmp_hidden_variables.rstrip.gsub(/\n\s+/,"\n ").gsub("\n",";\n") + ";"
self.fix_hidden_variables = []
self.tmp_hidden_variables_for_ruby = tmp_hidden_variables.split(/^([^=!]+)=([^=!])/).select{|s| s.present?}.each_slice(2).map do |a,b|
a = a.strip
self.fix_hidden_variables << a
if b
("result[\"#{a}\"]=" + b.gsub("\n",""))
else
a
end
end.join("\n")
self.fix_hidden_variables = self.fix_hidden_variables.uniq
formula = formula.split(/^([^=!]+)=([^=!])/).select{|s| s.present?}.each_slice(2).map do |a,b|
a = a.strip
if b
("result[\"#{a}\"]=" + b.gsub("\n",""))
else
a
end
end.join("\n")
self.fix_hidden_variables.each do |v|
formula = formula.gsub(/(\A|[^\w\"])#{v}($|[^\w])/){|f| "#{$1}result[\"#{v.strip}\"]#{$2}"}
self.tmp_hidden_variables_for_ruby = self.tmp_hidden_variables_for_ruby.gsub(/(\A|[^\w\"])#{v}($|[^\w])/){|f| "#{$1}result[\"#{v.strip}\"]#{$2}"}
end
self.tmp_lpv_ruby_code = formula
formula_variables = formula.enum_for(:scan,/([^\=\(\)]+)?=[^=]/).map {|x| x[-1] }.compact.map{|s| s.strip[8..-3]}
self.tmp_lpv_variables = formula_variables
self.tmp_years_settings = self.years_settings.map do |s|
text_to_math(s)
end
self.tmp_years_settings_for_ruby = self.tmp_years_settings.clone
formula_variables.each do |variable_name|
self.tmp_years_settings_for_ruby = self.tmp_years_settings_for_ruby.map do |y|
y.gsub(variable_name,"result[\"#{variable_name}\"]")
end
end
self.treatment_method = ['Surgery_only']
self.form_show_in_result.values.each do |choice|
variable = choice["variable"]
if variable.present?
self.treatment_method << variable
end
end
tmp_table_translations = {}
tmp_text_translations = {}
@years = self.years
# @head_name = ['Treatment','Additional_Benefit','Overall_Survival']
@head_name = ['Treatment','Overall_Survival']
@therapy_names = self.treatment_method
I18n.available_locales.each do |locale|
I18n.with_locale(locale) do
@table_head = @head_name.map{|name| I18n.t('cancerpredict.table.'+name)}
@therapy_choices = [I18n.t('cancerpredict.table.Surgeryonly')]
self.form_show_in_result.values.each{|choice| @therapy_choices.push choice["name"][locale].to_s}
tmp_table = "<span class=\"result_title print_only\">#{I18n.t("cancerpredict.table.table")}</span><div style=\"clear: both\"></div>"
tmp_table += '<input id="current_year" type="hidden" value="'+@years[0].to_s+'" index="0"/><p id="cancer_table_texts">'+self.table_above_texts[locale].to_s+'</p>'
tmp_table += ('<a style="display: inline-block;">'+(locale.to_s == 'zh_tw' ? '第' : '')+'</a><a style="display: inline-block;">')
@years.each{|year| tmp_table += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm">'+year.to_s+'</button>')}
tmp_table += ('</a><a style="display: inline-block;">'+(locale == 'zh_tw' ? '年' : '')+'</a>')
tmp_table += '<table><thead><tr>'
@table_head.each_with_index{|head,index| tmp_table += ('<th class="cancer_th '+@head_name[index]+'">' + head + '</th>')}
tmp_table += '</tr></thead><tbody>'
@therapy_choices.each_with_index do |choice,i|
tmp_table += '<tr class="'+@therapy_names[i].to_s+'">'
@table_head.each_with_index do |head,index|
tmp_table += ('<td class="cancer_td '+ @head_name[index]+'">' + ((index == 0) ? (((i==0)? '' : '+') + choice) : '-') + '</td>')
end
tmp_table += '</tr>'
end
tmp_table_translations[locale] = tmp_table
@texts = self.text_above_texts[locale].to_s.gsub('<br/>','</span><br/><span>').gsub('{{Surgery_only}}','<span class="'+@therapy_names[0]+' Overall_Survival"></span>')
@texts = @texts.split('{{years}}')
@texts.delete('')
tmp_text = "<span class=\"result_title print_only\">#{I18n.t("cancerpredict.table.text")}</span><div style=\"clear: both\"></div>"
tmp_text += ('<span>'+@texts[0].to_s)
@years.each{|year| tmp_text += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm" style="float:none;">'+year.to_s+'</button>')}
if @texts.count > 1
tmp_text += (@texts[1]+'</span>') if @texts.count > 1
else
tmp_text += '</span>'
end
if !self.surgery_only_texts[locale].blank?
@surgery_only_texts = self.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"></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>'
else
@surgery_only_texts = ''
end
tmp_text += @surgery_only_texts
tmp_text += '<span class="addition">'+(self.extra_texts[locale].to_s rescue '')+'</span><div class="extra-text" style="display:none;"><div class="texts_show" style="clear:both;"></div></div></p>'
tmp_text_translations[locale] = tmp_text
end
end
self.result_table_translations = tmp_table_translations
self.result_text_translations = tmp_text_translations
self.treatment_method_active_indices = [1]
self.form_show_in_result.each do |num, property|
v = property[:active_choice]
if v.present?
self.treatment_method_active_indices << (v - 1)
else
self.treatment_method_active_indices << 1
end
end
self.lpv_calc = get_years_settings_dict
self.generate_eval_formula
end end
def update_user def reload_any_asset(path, type=nil, force_reload=false)
User.find(update_user_id) rescue nil env = Rails.application.assets
end new_env = Sprockets::Environment.new(Rails.root.to_s) do |env|
def update_user=(user) env.version = ::Rails.env
self.update_user_id = user.id tmp_path = "#{Rails.application.config.root}/tmp/cache/assets/#{::Rails.env}"
end env.cache = ::Sprockets::Cache::FileStore.new(tmp_path)
def email_members env.context_class.class_eval do
MemberProfile.find(self.email_member_ids) rescue [] include ::Sprockets::Rails::Helper
end end
def email_addresses end
addresses = self.email_members.collect{|member| member.email} rescue [] new_env.config = env.config
addresses = addresses +[self.other_mailaddress] if !self.other_mailaddress.blank? stats = env.cached.instance_variable_get(:@stats)
addresses.flatten new_path = path.sub(/\.erb$/,'')
end if force_reload || (stats && stats[path]) #Need reload asset
def email if type.nil?
mail = Email.find(self.email_id) rescue nil ext = File.extname(new_path)
end env.mime_types.each do |t, h|
def expired? if h[:extensions].include?(ext)
(self.deadline < Time.now) rescue false type = t
end break
def destroy_email end
mail = Email.find(self.email_id) rescue nil end
mail.destroy if !mail.nil? end
end if type
def self.remove_expired_status full_path = 'file://'+path+'?type='+type
self.where(:is_top => true, :top_end_date.ne => nil, :top_end_date.lt => Time.now).each do |b| uris = env.cached.instance_variable_get(:@uris)
b.is_top = false keys = uris.keys.select{|k| k.include?(full_path)}
b.top_end_date = nil asset = new_env.load(full_path)
b.save if keys.count != 0
keys.each do |k|
uris[k] = asset
end
end
new_path = new_path.sub(/\.[^.]+$/){|ext| '-' + asset.digest + ext}
File.binwrite(new_path, asset.to_s)
yield new_path if block_given?
end
end end
end end
def reload_js_asset(path, force_reload=false)
reload_any_asset(path, 'application/javascript', force_reload) do |new_path|
File.open("#{Rails.root}/public/cancer_tool_js_filename.txt",'w+'){|f| f.write(new_path)}
end
end
def generate_eval_formula
eval_hidden_variables = "def eval_hidden_variables(result); #{self.tmp_hidden_variables_for_ruby}; end"
CancerpredictsController.module_eval(eval_hidden_variables)
eval_formula = "def eval_formula(result); #{self.tmp_lpv_ruby_code}; end"
CancerpredictsController.module_eval(eval_formula)
end
def generate_jscode
js_code = "var map_values , mapping_hash , temp_index ,temp_value , index , closest_value;\r\n"
mapping_data_from_csv = JSON.parse(self.mapping_data_from_csv) rescue {}
tmp_hash = self.form_show.values + self.form_show_in_result.values
tmp_hash.each do |property|
@variable = property[:variable]
if @variable.present?
if property[:is_num] == 1
js_code += " result['#{@variable}'] = Number(result_json['#{@variable}']);\r\n"
elsif property[:choice_fields].present?
if !(self.advance_mode)
js_code += " result['#{@variable}'] = Number(result_json['#{@variable}']);\r\n"
else
if property[:need_map_values] == 1
js_code += " map_values = #{property[:map_values]};\r\n"
js_code += " result['#{@variable}'] = map_values[Number(result_json['#{@variable}'']) - 1];\r\n"
else
if property[:revert_value] != 1
js_code += " result['#{@variable}'] = Number(result_json['#{@variable}']) - 1;\r\n"
else
js_code += " result['#{@variable}'] = (#{property[:choice_fields].length} - Number(result_json['#{@variable}']));\r\n"
end
end
end
end
if self.advance_mode && property[:cancer_predict_mapping_file].present?
if (mapping_data_from_csv != {} && !mapping_data_from_csv[@variable].blank?)
js_code += " mapping_hash = mapping_data_from_csv['#{@variable}'];\r\n"
js_code += " temp_index = 0;\r\n"
js_code += " temp_value = result['#{@variable}'];\r\n"
js_code += " index = 0;
$.each(mapping_hash,function(k,v){
if( index == 0 ){
var index_val = v.indexOf(temp_value);
if( index_val != -1 ){
temp_index = index_val;
}else{
closest_value = v.get_nearest_value(temp_value);
temp_index = v.indexOf(closest_value)
}
}
result[k] = v[temp_index];
index++;
});\r\n"
end
end
end
end
js_code += "\n Object.keys(result).forEach(function(k){
if(Number.isNaN(result[k])){
result[k] = 0;
}
})"
js_code += "\n #{self.tmp_hidden_variables_for_js}"
formula = text_to_math(self.prediction_formula)
self.all_variables.each do |k|
formula = formula.gsub(/(\A|[^\w])#{k}($|[^\w])/){|f| "#{$1}result[\"#{k.strip}\"]#{$2}" }
end
formula_variables = self.tmp_lpv_variables.map{|v| v}
js_code = "\n function calculate_first_lpv(result_json){
result = {};
#{js_code}
try{
#{formula.gsub(/\s{2,10}/," ").gsub("\n","\n ")}
}catch(e){console.log(e)};
result['lpv_variable'] = {};
#{formula_variables.map{|v| "result['lpv_variable']['#{v}'] = #{v};"}.join("\n ") }
result['lpv'] = #{formula_variables.count == 0 ? 0 : formula_variables.last};
result['lpv_variable']['lpv'] = result['lpv'];
return result;
};
function calculate_and_change_result_value(obj){
obj.servive_ratio_arr = [];
for(var i = 0;i<obj.active_treatment.length;i++){
var servive_ratio = round((1 - calculate_servive_ratio(obj.year,obj.lpv_real[i]))*100,2);
var benefit = servive_ratio - obj.servive_ratio_arr[obj.servive_ratio_arr.length-1];
obj.servive_ratio_arr.push(servive_ratio);
$('tr.'+obj.active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%');
$('.'+obj.active_treatment[i]+'.Overall_Survival').html(Math.round(servive_ratio));
if(i != 0){
$('tr.'+obj.active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%');
$('.'+obj.active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit));
}
}
//$('.'+obj.active_treatment[0]+'.Overall_Survival').html(Math.round(obj.servive_ratio_arr[0]));
};"
@years = self.years
switch_texts = "
#{formula_variables.map{|v| "var #{v} = obj['#{v}'];"}.join("\n ")}
switch(year) {"
@years.each do |year|
year_index = @years.index(year)
switch_texts +=
"
case '#{year}':
servive_ratio = #{text_to_math(self.years_settings[year_index])};
break;"
end
switch_texts += "
default:
console.log('not found year.');
}"
js_code = js_code +"
function calculate_servive_ratio(year,obj){
var servive_ratio;#{switch_texts}
return servive_ratio;
}
"
return js_code
end
def text_to_math(text)
text.gsub("\r\n","\n").gsub('^','**').gsub('exp','Math.exp').gsub('log','Math.log')
end
def replace_str_with_idx(org_str,st, ed, replace_str)
org_str.slice!(st, ed - st + 1)
org_str.insert(st, replace_str)
org_str
end
def auto_write_predict_js(force_reload=true)
js_codes = generate_jscode
module_app_path = Pathname.new(File.expand_path(__dir__)).dirname.dirname.to_s
save_path = module_app_path + '/app/assets/javascripts/cancer_predict.js'
file_texts = File.read(save_path)
need_write = false
str1 = "/* auto add start */"
index1 = file_texts.index(str1)
str2 = "/* auto add end */"
index2 = file_texts.index(str2)
if (!index1.nil? && !index2.nil?)
file_texts = replace_str_with_idx(file_texts, index1 + str1.length, index2 - 1, js_codes)
need_write = true
end
str3 = "/*lpv_calc_formula_start*/"
index3 = file_texts.index(str3)
str4 = "/*lpv_calc_formula_end*/"
index4 = file_texts.index(str4)
if (!index3.nil? && !index4.nil?)
file_texts = replace_str_with_idx(file_texts, index3 + str3.length, index4 - 1, self.lpv_calc.to_json.gsub("@",".") + ';')
need_write = true
end
tmp_disable_jscodes = ""
str5 = "/*disable_condition start*/"
index5 = file_texts.index(str5)
str6 = "/*disable_condition end*/"
index6 = file_texts.index(str6)
self.form_show_in_result.each do |num,property|
if property[:disable_condition].present?
tmp = property[:disable_condition].clone
self.all_variables.each do |k|
tmp = tmp.gsub(/(\A|[^\w])#{k}($|[^\w])/){|f| "#{$1}post_json[\"#{k}\"]#{$2}" }
end
variable = property[:variable]
tmp_disable_jscodes += "\n if(#{tmp}){
$('##{variable} .cancer_table_btn').attr('disabled','disabled');
$('[for=\"#{variable}\"]').css('color','rgb(204, 204, 204)');
}else{
$('##{variable} .cancer_table_btn').removeAttr('disabled');
$('[for=\"#{variable}\"]').css('color','');
}"
end
end
if (!index5.nil? && !index6.nil?)
tmp_disable_jscodes += "\n\t\t\t"
file_texts = replace_str_with_idx(file_texts, index5 + str5.length, index6 - 1, tmp_disable_jscodes)
need_write = true
end
str7 = "/*therapy_lpv start*/"
index7 = file_texts.index(str7)
str8 = "/*therapy_lpv end*/"
index8 = file_texts.index(str8)
self.therapy_lpv = [0]
self.form_show_in_result.each do |num,property|
if property[:lpv_impact].present?
self.therapy_lpv << property[:lpv_impact]
else
self.therapy_lpv << 0
end
end
if (!index7.nil? && !index8.nil?)
file_texts = replace_str_with_idx(file_texts, index7 + str7.length, index8 - 1, self.therapy_lpv.to_s + ';')
need_write = true
end
if need_write
File.write(save_path,file_texts)
reload_js_asset(save_path, force_reload)
elsif !(File.exist?("#{Rails.root}/public/cancer_tool_js_filename.txt"))
File.open("#{Rails.root}/public/cancer_tool_js_filename.txt",'w+'){|f| f.write(save_path)}
end
end
def get_years_settings_dict
lpv_variable_name = (prediction_formula.include?("=") ? prediction_formula.split("=")[0].strip : "" rescue "")
res = self.years.map.with_index do |y, i|
tmp_formula = self.tmp_years_settings[i]
if lpv_variable_name.present?
tmp_formula = tmp_formula.gsub(lpv_variable_name, "lpv_current")
else
tmp_formula = tmp_formula.gsub("lpv", "lpv_current")
end
[y.to_s.sub(".","@"), tmp_formula]
end
res.to_h
end
end end

View File

@ -0,0 +1,25 @@
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.all.count + 1
end
def check_missing_data
missing_keys = self.names.keys - self.result.keys rescue []
missing_keys.each{|k| self.result[k] = "" }
end
end

View File

@ -0,0 +1,28 @@
# encoding: utf-8
class HeadImagesUploader < CarrierWave::Uploader::Base
# 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,38 @@
# encoding: utf-8
wb = xlsx_package.workbook
wb.add_worksheet(name: "cancer_tool") do |sheet|
if !results[0].nil?
row = []
title = sheet.styles.add_style(:bg_color => "FFFF00",:border=>{ :style => :thin, :color => "666666" },:alignment=>{ :horizontal => :center,:vertical => :center ,:wrap_text => true})
column = sheet.styles.add_style(:alignment=>{ :horizontal => :center,:vertical => :center ,:wrap_text => true},:border=>{ :style => :thin, :color => "666666" })
row << ((I18n.locale=="en") ? 'submit time' : '提交時間')
@fields = results.first.names.keys
@fields.each do |field_name|
row << results.first.names[field_name][I18n.locale.to_s].split('<br/>')[0]
end
#export data start
export_data_rows = []
results.each do |result|
temp_row = []
temp_row << result.created_at.to_s
result.result.each do |key,value|
if key != "locale"
if (result.values[key][I18n.locale.to_s].length == 0 rescue true)
temp_row << value
else
v = result.values[key][I18n.locale.to_s][value.to_i-1] rescue nil
temp_row << (v.nil? ? value : v)
end
end
end
export_data_rows << temp_row
end
#export data end
sheet.add_row row , :style=> title,:widths => row.map{|cell| (cell.length* 11/ 2).round}
export_data_rows.each do |infos_row|
sheet.add_row infos_row , :style=> column
end
end
end

View File

@ -1,472 +1,37 @@
<% content_for :page_specific_css do %> <tr>
<%= stylesheet_link_tag "lib/main-forms" %> <td class="remove_div">❌</td>
<%= stylesheet_link_tag "lib/fileupload" %> <td class="sort_div"></td>
<%= stylesheet_link_tag "lib/main-list" %> <% keys.each do |key| %>
<% end %> <td class="<%=key%>">
<% content_for :page_specific_javascript do %> <% if key.include? "_file" %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %> <%= render :partial => 'form_file', :object => (CancerPredictMappingFile.where(:id=> property[key]).first rescue nil), :locals => {:f => make_fields, :key=>key} %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %> <% else %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> <% value = property[key] %>
<%= javascript_include_tag "lib/file-type" %> <% value_type = Cancerpredictfields::FIELDINFO[key] %>
<%= javascript_include_tag "lib/module-area" %> <% value = "[]" if property == {} && value_type == 'Array' %>
<% end %> <% is_localized = Cancerpredictfields::NonLoclaized.exclude?(key) %>
<% @value= value %>
<!-- Input Area --> <% if is_localized %>
<div class="input-area"> <% @disp_value = @value[I18n.locale.to_s] rescue "" %>
<%else%>
<!-- Module Tabs --> <% @disp_value = @value %>
<div class="nav-name"><strong><%= t(:module) %></strong></div> <%end%>
<ul class="nav nav-pills module-nav"> <% field_type = ((value_type == 'String' || value_type == 'Array' || value_type == 'Float') ? "text_field" : value_type) %>
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li> <% if value_type == 'Fixnum' %>
<li><a href="#status" data-toggle="tab"><%= t(:status) %></a></li> <% if @value == 1%>
<li><a href="#tag" data-toggle="tab"><%= t(:tags) %></a></li> <%= make_fields.check_box key,{:checked=>true,:class=>"checkbox",:style=>"float:left;"}%>
<li><a href="#imageupload" data-toggle="tab"><%= t(:image) %></a></li> <% else%>
<li><a href="#mail-group" data-toggle="tab"><%= t('announcement.email_reminder')%></a></li> <%= make_fields.check_box key,{:checked=>false,:class=>"checkbox",:style=>"float:left;"}%>
</ul> <%end%>
<!-- Module --> <% elsif is_localized %>
<div class="tab-content module-area"> <%=make_fields.fields_for I18n.locale.to_s do |locale_fields|%>
<%= locale_fields.send(field_type, key,{:value=>@disp_value}) %>
<!-- Basic Module --> <%end%>
<div class="tab-pane fade in active" id="basic"> <% else %>
<%= make_fields.send(field_type, key,{:value=>@disp_value})%>
<!-- Category --> <%end%>
<div class="control-group"> <%end%>
<label class="control-label muted"><%= t(:category) %></label> </td>
<div class="controls"> <%end%>
<%= select_category(f, @module_app) %> <td><%= make_fields.hidden_field :old_num,:value=>num.to_s %></td>
</div> </tr>
</div>
<!-- Date Time Picker -->
<div class="control-group">
<label class="control-label muted"><%= t(:start_date) %></label>
<div class="controls">
<%= f.datetime_picker :postdate, :no_label => true, :new_record => @bulletin.new_record?, :data=>{"picker-type" => "range", "range" => "start"} %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t(:end_date) %></label>
<div class="controls">
<%= f.datetime_picker :deadline, :no_label => true, :new_record => @bulletin.new_record?, :data=>{"picker-type" => "range", "range" => "end"} %>
</div>
</div>
<div class="control-group">
<%= f.label :is_external_link, t("announcement.is_external_link"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :is_external_link %>
</div>
</div>
<div class="control-group" style="display: none;" id="external_link_box">
<%= f.label :external_link, t("announcement.external_link"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :external_link %>
<div class="hint"><%= t("announcement.external_link_hint") %></div>
</div>
</div>
</div>
<!-- Status Module -->
<div class="tab-pane fade" id="status">
<!-- Status -->
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @bulletin.is_top? || (!@bulletin.top_end_date.nil? && @bulletin.top_end_date > Time.now) %>">
<%= f.check_box :is_top %> <%= t(:top) %>
</label>
<label class="checkbox inline btn <%= 'active' if @bulletin.is_hot? %>">
<%= f.check_box :is_hot %> <%= t(:hot) %>
</label>
<label class="checkbox inline btn <%= 'active' if @bulletin.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
<div class="controls">
<% if !@bulletin.is_top? && !AnnouncementSetting.check_limit_for_user((@bulletin.new_record? ? current_user.id : @bulletin.create_user_id)) %>
<span>Top limit has been reached. The bulletin wont be marked as top even if you click on it.</span>
<% end %>
</div>
</div>
<div class="control-group <%= @bulletin.is_top? || (!@bulletin.top_end_date.nil? && @bulletin.top_end_date > Time.now) ? "" : "hide" %>" data-for="is_top">
<label for="" class="control-label muted">Top end time</label>
<div class="controls">
<%= f.datetime_picker :top_end_date, :no_label => true, :new_record => @bulletin.new_record? %>
</div>
</div>
</div>
<%# end %>
<!-- Tag Module -->
<div class="tab-pane fade" id="tag">
<div class="control-group">
<label class="control-label muted"><%= t(:tags) %></label>
<%= select_tags(f, @module_app) %>
</div>
</div>
<!-- Images Module -->
<div class="tab-pane fade" id="imageupload">
<!-- Images Upload -->
<div class="control-group">
<label class="control-label muted"><%= t(:image) %></label>
<div class="controls">
<div class="fileupload fileupload-new clearfix <%= 'fileupload-edit' if @bulletin.image.file %>" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left">
<% if @bulletin.image.file %>
<%= image_tag @bulletin.image %>
<% else %>
<img src="http://www.placehold.it/50x50/EFEFEF/AAAAAA" />
<% end %>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<span class="btn btn-file">
<span class="fileupload-new"><%= t(:select_image) %></span>
<span class="fileupload-exists"><%= t(:change) %></span>
<%= f.file_field :image %>
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn btn-danger fileupload-remove">
<%= f.check_box :remove_image %><%= t(:remove) %>
</label>
</div>
</div>
</div>
</div>
<% @site_in_use_locales.each do |locale| %>
<%= f.fields_for :image_description_translations do |f| %>
<div class="control-group">
<label class="control-label muted" for="image_description_<%= locale.to_s %>"><%= t(:description) + " (#{t(locale.to_s)})" %></label>
<div class="controls">
<%= f.text_field locale, value: (@bulletin.image_description_translations[locale.to_s] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
<!-- Mail Group Module -->
<div class="tab-pane fade" id="mail-group">
<!-- Mail Group -->
<div class="control-group">
<label class="control-label muted"><%= t("announcement.email_to") %></label>
<div class="controls">
<label class="checkbox inline">
<%= check_box_tag('bulletin[email_sent]', '1', (!@bulletin.email_sent.blank? ? true : false), :id=>'remind-check') %><%= t('announcement.activate_email_reminder')%>
</label>
<div class="content-box">
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'bulletin[email_member_ids][]', email_members: @bulletin.email_members} %>
</div>
</div>
</div>
<div class="control-group">
<label class="control-label muted"></label>
<div class="controls">
<div class="content-box">
<span class="help-block"><%= "#{t("announcement.other_mailaddress")}(#{t("announcement.other_mailaddress_note")})"%> </span>
<%= f.text_area :other_mailaddress, :class=>"span12", :cols=>"25", :rows=>"10" %>
</div>
</div>
</div>
<div class="content-box">
<div class="control-group">
<label class="control-label muted"><%= t("announcement.email_sentdate") %></label>
<div class="controls">
<%= f.datetime_picker :email_sentdate, :no_label => true %>
</div>
</div>
</div>
<% if (@bulletin.email.is_sent rescue false) %>
<div class="content-box">
<div class="control-group">
<label class="control-label muted"><%= t("announcement.resend_mail") %></label>
<div class="controls">
<input type="checkbox" name="resend_mail" value="true">
</div>
</div>
</div>
<% end %>
</div>
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- Title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t(:title) %></label>
<div class="controls">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t(:title), value: (@bulletin.title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- Sub Title -->
<div class="control-group input-subtitle">
<label class="control-label muted"><%= t(:subtitle) %></label>
<div class="controls">
<div class="textarea">
<%= f.fields_for :subtitle_translations do |f| %>
<%= f.text_area locale, rows: 2, class: "input-block-level", value: (@bulletin.subtitle_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<!-- Content -->
<div class="control-group input-content">
<label class="control-label muted"><%= t(:content) %></label>
<div class="controls">
<div class="textarea">
<%= f.fields_for :text_translations do |f| %>
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@bulletin.text_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
</div>
<% end %>
<!-- Link -->
<div class="control-group">
<label class="control-label muted"><%= t(:link) %></label>
<div class="controls add-input">
<!-- Exist -->
<% if @bulletin && !@bulletin.bulletin_links.blank? %>
<div class="exist">
<% @bulletin.bulletin_links.each_with_index do |bulletin_link, i| %>
<%= f.fields_for :bulletin_links, bulletin_link do |f| %>
<%= render :partial => 'form_link', :object => bulletin_link, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'bulletin_link_field_count', @bulletin.bulletin_links.count %>
<a id="add_link" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
<!-- File -->
<div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<!-- Exist -->
<% if @bulletin && !@bulletin.bulletin_files.blank? %>
<div class="exist">
<% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %>
<%= f.fields_for :bulletin_files, bulletin_file do |f| %>
<%= render :partial => 'form_file', :object => bulletin_file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= get_referer_url[:action] rescue "" %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<input type="hidden" name="referer_url" value="<%= get_referer_url %>">
<%= button_tag t("preview"), id: "button_for_preview", name: "commit", class: 'btn', type: :button %>
<%= link_to t('cancel'), admin_announcements_path, :class=>"btn" %>
</div>
<span id='show_preview'>
<div class="modal hide fade in banner-preview" id="">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t(:preview) %></h3>
</div>
<div class="modal-body">
<iframe id="preview-iframe" src=""></iframe>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
</div>
</div>
</span>
<% if !@module_app.tags.empty? %>
<script type="text/javascript">
$("form.previewable").on("submit", function(){
if(!$("input[name='bulletin[tags][]']").is(":checked")){
if(!confirm("You have selected no tag, do you wish to continue?")){
return false;
}
}
})
</script>
<% end %>
<% content_for :page_specific_javascript do %>
<script>
function Appendzero(obj)
{
if(obj<10) return "0" +""+ obj;
else return obj;
}
$(function() {
if (location.pathname.substr(-3)=='new'){
var getDate = new Date();
var toDay = getDate.getFullYear()+"/"+ (Appendzero(getDate.getMonth()+1))+"/"+Appendzero(getDate.getDate())+" "+Appendzero(getDate.getHours())+":"+Appendzero(getDate.getMinutes());
$('input[name="bulletin[postdate]"]').val(toDay);
}
$("#main-wrap").after("");
$(document).on('click', '#add_link', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_bulletin_links", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_link', f, :bulletin_links) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.tab-content').children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
formTip();
});
$(document).on('click', '#add_file', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_bulletin_files", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :bulletin_files) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
});
formTip();
});
$(document).on('click', '.delete_link', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
$('#remind-check').prop('checked') ? '':$('.content-box').addClass('hide')
$('#remind-check').on('change', function() {
$(this).prop('checked') ? $('.content-box').removeClass('hide'):$('.content-box').addClass('hide')
})
$('#button_for_preview').click(function(){
var method = $('.main-forms input[name="_method"]').val();
$('.main-forms input[name="_method"]').val("post");
for ( instance in CKEDITOR.instances )
CKEDITOR.instances[instance].updateElement();
var formData = new FormData( $('.main-forms')[0] );
formData.append("preview_type", ( (method==undefined) ? "new" : "edit" ));
formData.append("bulletin_id", '<%= @bulletin.id.to_s %>');
$.ajax({
type: "post",
url: '<%= admin_announcement_preview_path %>',
data : formData,
processData: false,
contentType: false
}).done(function(data){
if(window.location.protocol === "https:"){
data = data.replace("http:","https:");
}
$('.modal-body iframe').attr('src',data);
$('#show_preview .modal').modal();
$('#show_preview .modal').height(function() {
return $(window).height() * 0.7;
});
var slug = data.split('/')[(data.split('/').length-1)];
// $('#preview-iframe').on('load', function(){
// $.get('/admin/announcement/destroy_preview/'+slug,function(data){
// });
// });
});
$('.main-forms input[name="_method"]').val(method);
return false;
});
$("#bulletin_is_top").parent().on("click",function(){
setTimeout(function(){
if($("#bulletin_is_top").parent().hasClass("active")){
$("div[data-for=is_top]").removeClass("hide");
}else{
$("div[data-for=is_top]").addClass("hide");
$("div[data-for=is_top]").find("input[type=text]").val("");
}
},100)
})
$("#bulletin_is_external_link").on("click",function(){
if($(this).is(":checked")){
$("#external_link_box").show();
}else{
$("#external_link_box").hide();
}
})
});
</script>
<% end %>

View File

@ -1,69 +1,33 @@
<% if form_file.new_record? %> <% if form_file.nil? %>
<div class="fileupload fileupload-new start-line" data-provides="fileupload"> <div class="fileupload fileupload-new start-line" data-provides="fileupload">
<% else %> <% else %>
<div class="fileupload fileupload-exist start-line" data-provides="fileupload"> <div class="fileupload fileupload-exist start-line" data-provides="fileupload">
<% if form_file.file.blank? %> <% if form_file.temp_file.blank? %>
<%= t(:no_file) %> <%= t(:no_file) %>
<% else %> <% else %>
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %> <%= link_to content_tag(:i) + form_file.file_identifier, form_file.temp_file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
<% end %> <% end %>
<% end %> <% end %>
<%= f.fields_for key do |f|%>
<div class="input-prepend input-append"> <div class="input-prepend input-append">
<label> <label>
<span class="add-on btn btn-file" title='<%= t(:file_) %>'> <span class="add-on btn btn-file" title='<%= t(:file_) %>'>
<i class="icons-paperclip"></i> <i class="icons-paperclip"></i>
<%= f.file_field :file %> <%= f.file_field :temp_file %>
</span> </span>
<div class="uneditable-input input-medium"> <div class="uneditable-input input-medium">
<i class="icon-file fileupload-exists"></i> <i class="icon-file fileupload-exists"></i>
<span class="fileupload-preview"><%= (form_file.new_record? || form_file.file.blank?) ? t(:select_file) : t(:change_file) %></span> <span class="fileupload-preview"><%= (form_file.nil? || form_file.temp_file.blank?) ? t(:select_file) : t(:change_file) %></span>
</div> </div>
</label> </label>
<span class="add-on icons-pencil" title='<%= t(:alternative) %>'></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_file.title_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span> </span>
<span class="add-on icons-pencil" title='<%= t(:description) %>'></span> <% if !form_file.nil? %>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :description_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:description), :value => (form_file.description_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
</span>
<span class="add-on btn-group btn" title="<%= t('archive.show_lang') %>">
<i class="icons-earth"></i> <span class="caret"></span>
<ul class="dropdown-menu">
<% @site_in_use_locales.each do |locale| %>
<li>
<label class="checkbox">
<%= check_box_tag "bulletin[bulletin_files_attributes][#{( form_file.new_record? ? 'new_bulletin_files' : "#{i}" )}][choose_lang][]", locale, form_file.choose_lang.include?(locale.to_s) %>
<%= t(locale.to_s) %>
</label>
</li>
<% end %>
</ul>
<%= hidden_field_tag 'bulletin[bulletin_files_attributes][0][choose_lang][]', '' %>
</span>
<% if form_file.new_record? %>
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>"> <span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %> <%= f.hidden_field :id,:value=>(form_file.id) %>
<a class="icon-remove"></a> <a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %> <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span> </span>
<% end %> <% end %>
</div> </div>
</div> </div>
<% 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,477 @@
<div style="clear:both;"></div> <%= stylesheet_link_tag "lib/fileupload"%>
<% @i = 0 %> <%= stylesheet_link_tag "lib/togglebox"%>
<button id="clickall"><%= (I18n.locale.to_s == "zh_tw") ? "全選" : "select all" %></button> <% content_for :page_specific_javascript do %>
<button id="unclickall"><%= (I18n.locale.to_s == "zh_tw") ? "取消全選" : "unselect all" %></button> <%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%=form_for @file_to_show ,:url=>{:controller=>"patchfiles" ,:action=>"edit"} do |file|%> <%#= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= file.fields_for :file_show do |filefield|%> <%#= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<div id="fileform"> <%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<%= javascript_include_tag "form" %>
<% end %>
<% @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 %>
<% end %>
<%end%>
<%end%>
</span>
<%end%>
</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>
<%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"> <style type="text/css">
.show_li,.show_li *{ .sort_div:before{
list-style:none; content: "\e096";
color:balck; font-family: 'entypo';
cursor: pointer;
} }
.show_li ul{ .sort_div{
display:none; padding: 1em;
} }
#clicktosee{ .sort_table tbody td:last-child{
color:blue; display: none;
cursor:pointer; }
.remove_div{
cursor: pointer;
}
.remove_div:hover{
font-size: 1.3em;
}
<% Cancerpredictfields::AdvanceFields.each do |field| %>
table .<%=field%>{
display: none;
}
table.advance_mode .<%=field%>{
display: table-cell;
}
<% end%>
.solid_line_hr{
margin: 0.3em;
border-top: 0.2em dashed;
}
.sort_table input, .sort_table textarea{
font-family: sans-serif;
}
.advance_mode_help_btn{
float:left;
cursor: pointer;
padding: 0em 0.475em;
font-size: 1.25em;
border-radius: 1.5em;
background-color: rgb(210, 106, 2);
border-color: rgb(210, 106, 2);
color: white;
width: 1.8em;
height: 1.8em;
line-height: 1em;
}
#show_advance_mode_modal {
display: none;
} }
</style> </style>
<div id="show_advance_mode_modal" class="modal fade">
<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'>
<%= t("cancerpredict.module_mode") %>
</h4>
</div>
<div class="modal-body">
<%= t("cancerpredict.advance_mode_hint2").html_safe %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default">Close</button>
</div>
</div>
</div>
</div>
<div style="clear:both;"></div>
<%=form_for @form_to_show ,:url=>{:controller=>"cancerpredicts" ,:action=>"edit"} do |form|%>
<span class="show_span"><%= t('cancerpredict.title') %></span>
<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>
<textarea class="ckeditor" id="cancerpredictfields_text_descibe_<%=I18n.locale.to_s%>" name="cancerpredictfields[text_descibe][<%=I18n.locale.to_s%>]">
<%= @form_to_show.text_descibe[I18n.locale.to_s] %>
</textarea>
<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.module_mode') %></span>
<div style="clear:both;"></div>
<div class="control-group">
<label class="control-label" for="advance_mode" style="float: left; line-height: 30px;margin-right: 1em;">
<span style="float: left;"><%= t('cancerpredict.advance_mode') %></span>
<button type="button" class="advance_mode_help_btn" data-target="#show_advance_mode_modal"><i aria-hidden="true" class="fa fa-question"></i></button>
</label>
<div class="controls">
<input id="advance_mode" name="<%=form.object_name%>[advance_mode]" type="checkbox" class="toggle-check" data-disabled="<%=!(form.object.advance_mode)%>">
</div>
</div>
<div style="clear:both;"></div>
<span class="show_span"><%= t('cancerpredict.Input_fields') %></span>
<div style="clear:both;"></div>
<table id="fields_table" class="sort_table <%=@form_to_show.advance_mode ? 'advance_mode' : '' %>">
<% keys = Cancerpredictfields::FIELDINFO.keys - Cancerpredictfields::TherapyOnly %>
<thead>
<tr>
<th></th>
<th></th>
<% keys.each do |key|%>
<th class="<%=key%>"><%=t("cancerpredict.table.#{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|%>
<%= render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>property,:num=>num,:keys => keys} %>
<%end%>
<%end%>
<%end%>
</tbody>
</table>
<button id="add_field" type="button" class="btn btn-primary"><%= t('cancerpredict.table.add_field') %></button>
<div style="clear:both;"></div>
<span class="show_span"><%=t('cancerpredict.table.Results')%></span>
<div style="clear:both;"></div>
<label for="form_result_is_right" style="float: left;"><%= t('cancerpredict.result_is_right') %></label>
<% 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%>
<div style="clear:both;"></div>
<% @create_items = ['years','table_above_texts','text_above_texts','surgery_only_texts','extra_texts','extra_therapy_texts','danger_texts','texts_between_Result_and_result_block'] %>
<% @create_items.each do |item|%>
<label for="<%=item%>" style="float: left;margin-right:1em;width:11em;"><%= 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,:style=>'width:calc(100% - 16em)'} %>
<% end %>
<% else %>
<%= form.text_field item,{:value=>@form_to_show[item],:id=> item,:style=>'width:calc(100% - 16em)'} %>
<% end %>
<div style="clear:both;"></div>
<% end %>
<table id="therapies_table" class="sort_table <%=@form_to_show.advance_mode ? 'advance_mode' : '' %>">
<thead>
<tr>
<th></th>
<th></th>
<% keys = Cancerpredictfields::TherapyFields %>
<% keys.each do |key,vlaue|%>
<th class="<%=key%>"><%=t("cancerpredict.table.#{key}")%></th>
<%end%>
</tr>
</thead>
<tbody>
<%= form.fields_for :form_show_in_result do |formfield|%>
<% @form_to_show.form_show_in_result.each do |num,property| %>
<%=formfield.fields_for num.to_s do |make_fields|%>
<%= render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>property,:num=>num,:keys => Cancerpredictfields::TherapyFields} %>
<%end%>
<%end%>
<%end%>
</tbody>
</table>
<button id="add_therapy" type="button" class="btn btn-primary"><%= t('cancerpredict.table.add_therapy') %></button>
<div style="clear:both;"></div>
<span class="show_span"><%=t('cancerpredict.table.calculate_settings')%></span>
<div style="clear:both;"></div>
<div class="control-group">
<div class="control-label" style="float: left;margin-right: 1em;width: 11em;">
<label><%= t('cancerpredict.hidden_variables') %></label>
</div>
<div class="controls">
<%= form.text_area :hidden_variables, :rows=>"5", :style=> 'width: 100%;font-family: sans-serif;' %>
</div>
</div>
<div style="clear:both;"></div>
<div class="control-group">
<div class="control-label" style="float: left;margin-right: 1em;width: 11em;">
<label><%= t('cancerpredict.table.prediction_formula') %></label>
</div>
<div class="controls">
<%= form.text_area :prediction_formula, :rows=>"5", :style=> 'width: 100%;font-family: sans-serif;' %>
</div>
</div>
<div id="years_settings">
<% years = @form_to_show.years %>
<% years.each_with_index do |year,i| %>
<div data-year="<%= year.to_s.strip %>">
<div class="control-label" style="float: left;margin-right: 1em;width: 13em;">
<label style="font-family: sans-serif;"><%=t("cancerpredict.Overall_Survival")%>(t=<%=year%> Year)</label>
</div>
<div class="controls">
<textarea name="<%= form.object_name %>[years_settings][]" style= "width: calc(100% - 16em);" value="<%= @form_to_show.years_settings[i] rescue '' %>"><%= @form_to_show.years_settings[i] rescue '' %></textarea>
</div>
</div>
<% end %>
</div>
<%=form.submit "#{t(:updatefont)}",{:id=>"updatebtn"}%>
<%end%>
<link href="/assets/admin/cancerpredict.css" media="screen" rel="stylesheet">
<script> <script>
$('.Toggleclass').off("click").on("click",function(){ $(".advance_mode_help_btn").click(function(){
$(this).parent().find(">ul").slideToggle(); $("#show_advance_mode_modal").modal();
})
$("#show_advance_mode_modal button").click(function(){
$("#show_advance_mode_modal").modal("hide");
})
$("#advance_mode").click(function(){
if(window.confirm("<%=t('cancerpredict.advance_mode_hint1').gsub("\n","\\n")%>")){
$("#fields_table,#therapies_table").toggleClass("advance_mode");
}else{
return false;
}
})
$('.text_choice').click(function(){
$('.text_choice').prop('checked' , false);
$(this).prop('checked' , true);
}); });
$('.checkbox').off('click').on('click',function(){ $("#add_field").click(function(){
for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){ var index = $("#fields_table tbody tr").length.toString();
if($(this).is(":checked") == false){ <%= fields_for :cancerpredictfields do |form|%>
if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == true) <%= form.fields_for :form_show do |formfield|%>
$(this).parent().find('.sub_checkbox').eq(i).click(); <%=formfield.fields_for :new_index do |make_fields|%>
}else{ <% keys = Cancerpredictfields::FIELDINFO.keys - Cancerpredictfields::TherapyOnly %>
if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == false) var html = "<%= "#{render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>{},:num=>'',:keys => keys}}".gsub(/(\r\n|\n)/,"").gsub("\"","\\\"").html_safe %>";
$(this).parent().find('.sub_checkbox').eq(i).click(); $("#fields_table tbody").append(html.replaceAll('new_index',index));
}; <% end %>
}; <% end %>
<% end %>
$(".remove_div").off("click").on("click",function(){
$el = $(this).parent().siblings("tr").not($(this)).eq(0);
$(this).parent().remove();
update_key($el);
})
})
$("#add_therapy").click(function(){
var index = $("#therapies_table tbody tr").length.toString();
<%= fields_for :cancerpredictfields do |form|%>
<%= form.fields_for :form_show_in_result do |formfield|%>
<%=formfield.fields_for :new_index do |make_fields|%>
<% keys = Cancerpredictfields::TherapyFields %>
var html = "<%= "#{render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>{},:num=>'',:keys => keys}}".gsub(/(\r\n|\n)/,"").gsub("\"","\\\"").html_safe %>";
$("#therapies_table tbody").append(html.replaceAll('new_index',index));
<% end %>
<% end %>
<% end %>
$(".remove_div").off("click").on("click",function(){
$el = $(this).parent().siblings("tr").not($(this)).eq(0);
$(this).parent().remove();
update_key($el);
})
})
function update_key(ele){
console.log($(ele))
var ui_child=$(ele).parent().find('> tr');
console.log(ui_child);
for (var i=0;i<ui_child.length;i++){
var now_ele = ui_child.eq(i);
var $inputs = now_ele.find('input');
$inputs.each(function(input_index,input){
var name = input.name;
name = $.map(name.split(/(\[|\])/),function(v,ii){
var vv = v;
var num = Number.parseInt(vv);
if(!Number.isNaN(num)){
vv = i.toString();
}
return vv;
}).join("");
console.log(name)
input.name = name;
})
}
}
$( ".sort_table > tbody" ).sortable({
axis: "y",
revert: true,
placeholder: "sortable-placeholder",
handle: ".sort_div",
update: function(event, ui) {
update_key($(ui.item[0]))
}
}); });
$('.sub_checkbox').off('click').on('click',function(){ $(".remove_div").click(function(){
var num = 0; $el = $(this).parent().siblings("tr").not($(this)).eq(0);
$(this).parent().remove();
update_key($el);
})
$(".remove_existing_record").click(function(){
if(window.confirm("Are you sure want to remove this file?")){
$(this).find(".should_destroy").val("1");
$(this).parent().siblings(".file-link").remove();
}
})
$("#years").on('blur',function(){
var years = [];
try{
years = $(this).val().split(/\[|,|\]/).filter(function(aa){return aa !="" && aa != undefined}).map(function(aa){return aa.trim()});
}catch(e){};
var index = 0; var index = 0;
for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){ years.forEach(function(year){
if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == true){ if($("#years_settings [data-year='"+year+"']").length == 0){
num += 1; var year_text = ('<div data-year="'+year+'">'+
}; '<div class="control-label" style="float: left;margin-right: 1em;width: 13em;">'+
}; '<label style="font-family: sans-serif;"><%=t("cancerpredict.Overall_Survival")%>(t='+year+' Year)</label>'+
if( num == $(this).parent().find('.sub_checkbox').length){ '</div>'+
if( $(this).parent().find('.checkbox').is(":checked") == false) '<div class="controls">'+
$(this).parent().find('.checkbox').click(); '<textarea name="cancerpredictfields[years_settings][]" style= "width: calc(100% - 16em);"></textarea>'+
}else{ '</div>'+
if( $(this).parent().find('.checkbox').is(":checked") == true){ '</div>');
$(this).parent().find('.checkbox').click(); if(index != 0){
for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){ $("#years_settings [data-year='"+years[index - 1]+"']").after(year_text);
if($(this).parent().find('.sub_checkbox').eq(i).attr('id') != $(this).attr('id')) }else{
$(this).parent().find('.sub_checkbox').eq(i).click(); $("#years_settings").html(year_text+$("#years_settings").html());
} }
};
}
});
$("#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" );
} }
} index++;
}); })
return false; var all_years = $("#years_settings [data-year]").map(function(i,aa){return $(aa).attr("data-year").toString().trim() }).toArray();
}; all_years.forEach(function(a_year){
function updatefcn(){ if(years.indexOf(a_year) == -1){
var str=""; $("#years_settings [data-year='"+a_year+"']").remove()
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> </script>

View File

@ -0,0 +1,87 @@
<link href="/assets/admin/cancerpredict.css" media="print" rel="stylesheet">
<link href="/assets/admin/cancerpredict.css" media="screen" rel="stylesheet">
<% if !@results[0].nil? %>
<table>
<thead>
<tr>
<th><%=((I18n.locale=="en") ? 'submit time' : '提交時間') %></th>
<% @results[0].names.each do |key,name|%>
<th><%=name[I18n.locale.to_s].to_s.html_safe %></th>
<%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>
<th><%=((I18n.locale=="en") ? 'submit time' : '提交時間') %></th>
<% result.names.each do |key,name|%>
<th><%=name[I18n.locale.to_s].to_s.html_safe %></th>
<%end%>
</tr>
</thead>
<tbody>
<% end %>
<tr>
<td><%= result.created_at %></td>
<% result.result.each do |key,value| %>
<% @key_len %>
<% if key != "locale" %>
<% if (result.values[key][I18n.locale.to_s].length == 0 rescue true) %>
<td><%= value.to_s %></td>
<% else %>
<td><% v = result.values[key][I18n.locale.to_s][value.to_i-1] rescue nil %><%= v.nil? ? value : v %></td>
<% end %>
<% end %>
<%end%>
</tr>
<%end%>
</tbody>
</table>
<% end %>
<%=@pagination.html_safe%>
<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,59 @@
$:.push File.expand_path("../lib", __FILE__) # -*- encoding: utf-8 -*-
# stub: cancerpredict 0.0.1 ruby lib
# Maintain your gem's version: bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
require "cancerpredict/version" if bundle_update_flag
# Describe your gem and declare its dependencies: insert_flag = 0
Gem::Specification.new do |s| app_path = File.expand_path(__dir__)
s.name = "cancerpredict" template_path = ENV['PWD'] + '/app/templates'
s.version = Cancerpredict::VERSION all_template = Dir.glob(template_path+'/*/')
s.authors = ["Ruling Digital"] puts 'copying module'
s.email = ["orbit@rulingcom.com"] check_texts = '<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/js/bootstrap.min.js"%>'
s.homepage = "http://www.rulingcom.com" edit_texts = '<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"%>'
s.summary = "Cancer_Predict for Orbit" all_template.each do |folder|
s.description = "Cancer_Predict for Orbit" if !folder.include?('mobile')
s.license = "MIT" begin
if folder.split('/')[-1] != 'mobile'
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] begin
s.test_files = Dir["test/**/*"] system ('cp -r '+ app_path + '/modules/. ' + folder+'/modules/.')
puts "finish copy module cancerpredict to #{folder}"
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
rescue
puts "not found _head.html.erb in #{folder}"
end
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 end

View File

@ -1,6 +1,39 @@
en: en:
module_name:
cancerpredict: Cardiovascular Disease Survival Forecast in Taiwan Tool
cancerpredict: cancerpredict:
cancerpredict: Predict breast cancer hidden_variables: "Hidden Variables"
advance_mode_hint1: "After opening advance modecalculation will change!\nAre you sure switch to advance mode?"
advance_mode_hint2: "一般模式: 選項設定在計算時對應到的值由1開始。(例如: 選項設定為[\"是\",\"否\"],則\"是\"在計算時對應到1而\"否\"在計算時對應到2)。<br><hr class=\"solid_line_hr\">進階模式: 選項設定在計算時對應到的值由0開始。<br>而若開啟選項值從大到小則0對應到選項設定中的最後一項。<br>選項對應到的值的意思為當前述的計算值為0時則對應到定義的Array的第1個元素的值以此類推。<br>欄位對應檔案可上傳一個csv檔案在計算時會先依照csv中的第1直行找到對應的變數1(生成的變數名稱為csv中的第1列)的值,其餘生成的變數值則為對應之後的同一橫列的值。"
module_mode: Module Mode
advance_mode: Advance Mode
Overall_Survival: Probability
cancerpredict: Adjust Cardiovascular Disease Survival Forecast in Taiwan 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
texts_between_Result_and_result_block: Texts between "Result" and "Result block"
prev_page: Previous page
next_page: Next page
export_cancer_predict_tool_records: Export Cardiovascular Disease Survival Forecast in Taiwan Tool records
table: table:
welcome: Welcome to The after breast cancer healing system of Taiwanprepare!\nTo start, please enter the relevant information below. welcome: Welcome to The after breast cancer healing system of Taiwanprepare!\nTo start, please enter the relevant information below.
Reset: Reset Reset: Reset
@ -19,9 +52,18 @@ en:
no: no no: no
unknown: unknown unknown: unknown
Results: Results Results: Results
AdditionalBenefit: Additional Benefit Treatment: Event
OverallSurvival: Overall Survival(%) Additional_Benefit: Additional Benefit
Surgeryonly: Surgery only Overall_Survival: Probability(%)
Surgeryonly: Readmission or death
Hormonetherapy: Hormone therapy Hormonetherapy: Hormone therapy
Chemotherapy: Chemotherapy Chemotherapy: Chemotherapy
years: years years: years
result: Results
table: Table
curve: Curves
text: Texts
Therapy_choice: Treatment options
lpv_impact: "lpv Impact(Input: Float)"
active_choice: "Active choice(input 1 present choice 1 is regarded as therapy enable)"
disable_condition: "Disable Condition"

View File

@ -1,10 +1,43 @@
zh_tw: zh_tw:
module_name:
cancerpredict: 臺灣心血管疾病存活預測工具
cancerpredict: cancerpredict:
cancerpredict: 乳癌預測 hidden_variables: "隱藏的變數"
advance_mode_hint1: "開啟進階模式後,計算方式有差異。\n您確定要開啟進階模式?"
advance_mode_hint2: "一般模式: 選項設定在計算時對應到的值由1開始。(例如: 選項設定為[\"是\",\"否\"],則\"是\"在計算時對應到1而\"否\"在計算時對應到2)。<br><hr class=\"solid_line_hr\">進階模式: 選項設定在計算時對應到的值由0開始。<br>而若開啟選項值從大到小則0對應到選項設定中的最後一項。<br>選項對應到的值的意思為當前述的計算值為0時則對應到定義的Array的第1個元素的值以此類推。<br>欄位對應檔案可上傳一個csv檔案在計算時會先依照csv中的第1直行找到對應的變數1(生成的變數名稱為csv中的第1列)的值,其餘生成的變數值則為對應之後的同一橫列的值。"
module_mode: 模組模式
advance_mode: 進階模式
Overall_Survival: Probability
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: 警告文字
texts_between_Result_and_result_block: 在"結果"和"結果區塊"之間的文字
prev_page: 上一頁
next_page: 下一頁
export_cancer_predict_tool_records: 匯出臺灣心血管疾病存活預測工具的使用者紀錄
table: table:
welcome: 歡迎使用台灣準備乳癌癒後系統!\n若要開始 請在下方輸入相關資訊 welcome: 歡迎使用台灣準備乳癌癒後系統!\n若要開始 請在下方輸入相關資訊
Reset: 重置 Reset: 重置
Submit: 提交 Submit: 送出
age: 確認年齡 age: 確認年齡
Menopausal: 更年期狀態 Menopausal: 更年期狀態
ER: ER狀態 ER: ER狀態
@ -19,10 +52,34 @@ zh_tw:
no: no:
unknown: 未知 unknown: 未知
Results: 結果 Results: 結果
Treatment: 治療 Treatment: Event(事件)
AdditionalBenefit: 額外治療效益 Additional_Benefit: 額外治療效益
OverallSurvival: 總生存率(%) Overall_Survival: Probability(機率)(%)
Surgeryonly: 純手術 Surgeryonly: 純手術
Hormonetherapy: 賀爾蒙治療 Hormonetherapy: 賀爾蒙治療
Chemotherapy: 化學治療 Chemotherapy: 化學治療
years: years:
result: 結果
table: 列表
curve: 曲線
text: 文字
Therapy_choice: 治療選項
variable: 變數名稱
name: 名稱
is_num: 數字欄位
hint: 提示文字
comment_text: 說明文字
choice_fields: '選項設定([]代表無選項)'
range: '數字範圍設定([]代表無範圍限制)'
right: 顯示在右側
is_float: 可輸入小數
revert_value: 選項值從大到小(ex:有兩個選項則選項值依序為1和0)
map_values: 選項對應到的值(若無,則會使用初始值)
cancer_predict_mapping_file: 欄位對應檔案
calculate_settings: 計算設定
prediction_formula: 預測公式
add_field: 新增填寫欄位
add_therapy: 新增治療選項
lpv_impact: "lpv 影響(輸入浮點數)"
active_choice: "啟用治療選項(輸入1代表第1個選項視為啟用治療)"
disable_condition: "禁用條件"

View File

@ -1,12 +1,27 @@
Rails.application.routes.draw do Rails.application.routes.draw do
if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console')
Thread.new do
c = Cancerpredictfields.last
if c
sleep(5)
c.save
c.auto_write_predict_js
end
end
end
locales = Site.first.in_use_locales rescue I18n.available_locales locales = Site.first.in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do namespace :admin do
get 'cancerpredicts' , to: 'cancerpredicts#index' 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'
get 'cancerpredicts/export_cancer_tool_record' , to: 'cancerpredicts#export_cancer_tool_record'
resources :cancerpredicts resources :cancerpredicts
end end
get "cancerpredictResult", to: "cancerpredicts#calculate"
post "cancerpredictResult", to: "cancerpredicts#calculate"
end end
end end

View File

@ -9,19 +9,30 @@ module Cancerpredict
authorizable authorizable
widget_methods ["widget"] widget_methods ["widget"]
widget_settings [{"data_count"=>1}] widget_settings [{"data_count"=>1}]
frontend_enabled set_keyword_contstraints ['cancerpredictResult']
side_bar do frontend_enabled
head_label_i18n 'cancerpredict.cancerpredict', icon_class: "icons-megaphone" side_bar do
available_for "users" head_label_i18n 'cancerpredict.cancerpredict', icon_class: "icons-megaphone"
active_for_controllers (['admin/cancerpredicts']) available_for "users"
head_link_path "admin_cancerpredicts_path" active_for_controllers (['admin/cancerpredicts'])
head_link_path "admin_cancerpredicts_path"
context_link 'cancerpredict.cancerpredict', context_link 'cancerpredict.cancerpredict',
:link_path=>"admin_cancerpredicts_path" , :link_path=>"admin_cancerpredicts_path" ,
:priority=>1, :priority=>1,
:active_for_action=>{'admin/cancerpredicts'=>'index'}, :active_for_action=>{'admin/cancerpredicts'=>'index'},
:available_for => 'users' :available_for => 'users'
end context_link 'cancerpredict.submitResult',
:link_path=>"admin_cancerpredicts_showSubmit_path" ,
:priority=>1,
:active_for_action=>{'admin/cancerpredicts'=>'show_submit'},
:available_for => 'users'
context_link 'cancerpredict.export_cancer_predict_tool_records',
:link_path=>"admin_cancerpredicts_export_cancer_tool_record_path" ,
:priority=>1,
:active_for_action=>{'admin/cancerpredicts'=>'export_cancer_tool_record'},
:available_for => 'users'
end
end end
end end
end end

View File

@ -1,32 +1,7 @@
<div> <script type="text/javascript" src="/assets/jquery.smartmenus.min.js"></script>
<%= javascript_include_tag "react.js"%> <script type="text/javascript" src="/assets/jquery.smartmenus.bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.min.js"></script> <script type="text/javascript" src="{{preidct_js_url}}"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.bootstrap.min.js"></script> {{table}}
<h3 class="w-cancer-tool__widget-title"> <%= stylesheet_link_tag "cancer_predict", media: "screen" %>
<span>{{widget-title}}</span> <%= stylesheet_link_tag "bootstrap.min.print", media: "print" %>
</h3> <%= stylesheet_link_tag "cancer_predict_print", media: "print" %>
<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>

View File

@ -1,28 +1,7 @@
<div> <script type="text/javascript" src="/assets/jquery.smartmenus.min.js"></script>
<script src="/assets/react.js"></script> <script type="text/javascript" src="/assets/jquery.smartmenus.bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.min.js"></script> <script type="text/javascript" src="{{preidct_js_url}}"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.bootstrap.min.js"></script> {{table}}
<h1 class="i-cancer-title">{{page-title}}</h1> <%= stylesheet_link_tag "cancer_predict", media: "screen" %>
<div class="i-cancer-tool widget-announcement-1"> <%= stylesheet_link_tag "bootstrap.min.print", media: "print" %>
<div class="i-cancer-tool" data-level="0" data-list="statuses"> <%= stylesheet_link_tag "cancer_predict_print", media: "print" %>
<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>

View File

@ -3,8 +3,8 @@
{ {
"filename" : "cancer_predict_index", "filename" : "cancer_predict_index",
"name" : { "name" : {
"zh_tw" : "1. 乳癌預測工具", "zh_tw" : "1. 臺灣心血管疾病存活預測工具",
"en" : "1. Breast cancer predict tool" "en" : "1. Cardiovascular Disease Survival Forecast Tool"
}, },
"thumbnail" : "thumb.png" "thumbnail" : "thumb.png"
} }
@ -13,8 +13,8 @@
{ {
"filename" : "cancer_predict_widget", "filename" : "cancer_predict_widget",
"name" : { "name" : {
"zh_tw" : "1. 乳癌預測工具", "zh_tw" : "1. 臺灣心血管疾病存活預測工具",
"en" : "1. Breast cancer predict tool" "en" : "1. Cardiovascular Disease Survival Forecast Tool"
}, },
"thumbnail" : "thumb.png" "thumbnail" : "thumb.png"
} }