$(function(){ if ($('#myModal1').length == 0) { CKEDITOR.replace('homework_text', { language: 'ru', toolbarGroups: [ {name: 'tools'}, {name: 'links'}, {name: 'basicstyles', groups: ['basicstyles', 'cleanup']}, {name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ]}, {name: 'styles'}, {name: 'others'} ] }); } }); function send_comment(form, root){ // Проверить комментарий // Отправить if (CKEDITOR.instances.homework_text.getData()){ $('[name=homework_text]').val(CKEDITOR.instances.homework_text.getData()); $.ajax({ type: 'POST', url: '/courses/sent_homework_comment', data: $('[name='+form+']').serialize(), success: function(data){ if(data['code'] == '1'){ document.forms[form].reset(); CKEDITOR.instances.homework_text.setData(''); $('[name='+$('#'+root).attr('sketch_place')+']').html(''); if (!$('[name=try_'+data['data']['try']['id']+']').html()){ $('[name=comment_list_place]').append('

' + ' Попыток: (1) :

' + '
'); $('[name=homework_comments_block]').append(new_try(data['data']['try'])) } $('[name=try_comments_'+data['data']['try']['id']+']').append('
'); write_comment($('[name=comment_'+data['data']['comment']['id']+']'), data['data']['comment']); console.log(data['data']) } } }); } else { show_system_message('Введите текст сообщения') } } function send_homework_down_teacher(form, root){ // Проверить комментарий // Отправить if (CKEDITOR.instances.homework_text.getData()){ $('[name=homework_text]').val(CKEDITOR.instances.homework_text.getData()); $.ajax({ type: 'POST', url: '/courses/sent_homework_down_teacher', data: $('[name='+form+']').serialize(), success: function(data){ if(data['code'] == '1'){ window.close(); } else { show_system_message(data['response']) } } }); } else { show_system_message('Введите текст сообщения') } } function show_popup(){ // нужно было сделать быстро - поэтому сделали гавно (с) skillbox // нужно переделать под jquery // сделать тоже самое и для кнопки отказать. // Хороший способ передавать функцию отправки (up & down) сюда и здесь её запускать popup = document.getElementById('teacher_popup') popup.classList.toggle('hidden') popup.onclick = function(e){ if e.target == this{ popup.classList.add('hidden') } } } function send_homework_up_teacher(form, root){ // Проверить комментарий // Отправить document.getElementById('teacher_popup').classList.add('hidden') if (CKEDITOR.instances.homework_text.getData()){ $('[name=homework_text]').val(CKEDITOR.instances.homework_text.getData()); $.ajax({ type: 'POST', url: '/courses/sent_homework_up_teacher', data: $('[name='+form+']').serialize(), success: function(data){ if(data['code'] == '1'){ window.close(); } else { show_system_message(data['response']) } } }); } else { show_system_message('Введите текст сообщения') } } function new_try(data){ if (!window.last_try){ window.last_try = 0 } return '
' + '' + '' + '
' + '
' + '' + 'LMS: ~# ' + '' + 'Попытка №'+(window.last_try+1)+'' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
' + '
' + '
' + '
' } function write_comment(block, data){ var message; var user_status; var reply; if (NotEmpty(data)) { if (!NotEmpty(data['replies'])) { reply = '' } else { reply = '' + '
' + '
'; } if (NotEmpty(data['files']) && !data['closed']) { message = '
' } else { message = ''; } var comment_id = ''; if ($('[name=REQUEST_USER_ROLE]').val() == 'A'){ comment_id = 'ID:'+data['id']+''; } user_status = '' + comment_id; var background; if (data['owner_type']['flag'] == 'A') { background = "#f5fce5;" } else { background = '' } var avatar; if (data['closed']) { avatar = '' } else { avatar = '' + '' + '' } var head; if (data['closed']) { head = '
' + '' + 'КОММЕНТАРИЙ УДАЛЕН' + '' + '
' } else { head = '
' + '' + '' + data['owner'] + '' + '' + user_status + '' + //'' + //'' + '
' } var reply_button; var text; reply_button = ''; if (data['closed']) { text = '