window.load_process_interval = null;
window.comments_stack = [];
$(function(){
load_lesson_comments();
CKEDITOR.replace( 'comment_sent_text' );
});
function send_comment(form, root){
// Проверить комментарий
// Отправить
if (CKEDITOR.instances.comment_sent_text.getData()){
$('[name=sent_comment_progress]').show();
$('[name=comment_sent_text]').val(CKEDITOR.instances.comment_sent_text.getData());
$.ajax({
type: 'POST',
url: '/courses/sent_lesson_comment',
data: $('[name='+form+']').serialize(),
success: function(data){
if(data['code'] == '1'){
$('[name=sent_comment_progress]').hide();
document.forms[form].reset();
CKEDITOR.instances.comment_sent_text.setData('');
reload_lesson_comments(data['data']);
$('[name='+$('#'+root).attr('sketch_place')+']').html('')
}
}
});
} else {
show_system_message('Введите текст сообщения')
}
}
function get_comment_text(id) {
var r = '';
$.ajax({
type: 'GET',
url: '/courses/get_comment_text/',
async: false,
data: {'comment': id},
success: function (data) {
if (data['code'] == '1') {
r = data['data']
}
}
});
return r;
}
function load_process(){
if (!window.load_process_interval){
start_load();
}
function start_load(){
window.load_process_interval = setInterval( function(){load(window.comments_stack.pop())}, 1000);
}
function stop_load_process(){
clearInterval(window.load_process_interval);
delete window.load_process_interval;
}
function load(data){
if (window.comments_stack.length > 0){
$('[readable_comment='+data+']').html('');
} else {
stop_load_process();
}
}
}
function read_lesson(id){
$.ajax({
type: 'POST',
url: '/courses/read_lesson/',
data: {'lesson': id},
success: function(data){
if (data['code'] == '1'){
$('[name=current_button]').fadeOut('slow', function(){
$('[name=next_button]').fadeIn('slow');
});
}
}
});
}
function write_comment(block, data){
var message;
var user_status;
var reply;
if (NotEmpty(data)) {
if (!NotEmpty(data['replies'])) {
reply = ''
} else {
reply = '
' +
'
' +
'
'
} else {
avatar = '' +
'