/* ===================================================== DLE Forum ----------------------------------------------------- http://dle-files.ru/ ----------------------------------------------------- Copyright (c) 2009 DLE Files Group ===================================================== Данный код защищен авторскими правами ===================================================== Файл: dle_forum.js ===================================================== */ // ******************************************************************************** // POST EDIT // ******************************************************************************** function whenCompletedPostEdit(){ }; function ajax_post_edit( p_id ) { if ( ! c_cache[ p_id ] || c_cache[ p_id ] == '' ) { c_cache[ p_id ] = document.getElementById( 'post-id-'+p_id ).innerHTML; } var ajax = new dle_ajax(); post_id = p_id; ajax.onShow (''); var varsString = ""; ajax.setVar("id", p_id); ajax.setVar("action", "edit"); ajax.requestFile = forum_ajax + "editpost.php"; ajax.method = 'GET'; ajax.element = 'post-id-'+p_id; ajax.onCompletion = whenCompletedPostEdit; ajax.execute = true; ajax.sendAJAX(varsString); return false; }; function ajax_cancel_post_edit( p_id ) { if ( n_cache[ p_id ] != "" ) { document.getElementById( 'post-id-'+p_id ).innerHTML = c_cache[ p_id ]; } return false; }; // ******************************************************************************** // POST SAVE // ******************************************************************************** function whenCompletedSavePost(){ c_cache[ comm_edit_id ] = ''; }; function ajax_save_post_edit( c_id, forum_wysiwyg ) { var ajax = new dle_ajax(); var post_txt = ''; comm_edit_id = c_id; ajax.onShow (''); if (forum_wysiwyg == "1") { post_txt = ajax.encodeVAR( tinyMCE.get('forum_post_'+c_id).getContent() ); } else { post_txt = ajax.encodeVAR( document.getElementById('forum_post_'+c_id).value ); } var varsString = "post_text=" + post_txt; ajax.setVar("id", c_id); ajax.setVar("action", "save"); ajax.setVar("wysiwyg", forum_wysiwyg); ajax.requestFile = forum_ajax + "editpost.php"; ajax.method = 'POST'; ajax.element = 'post-id-'+c_id; ajax.onCompletion = whenCompletedSavePost; ajax.execute = true; ajax.sendAJAX(varsString); return false; }; // ******************************************************************************** // POST ADD // ******************************************************************************** function doAddPost(){ var sec_code = ""; var editor_mode = ""; var post_text = ""; var form = document.getElementById('forum-post-form'); if (forum_wysiwyg == "1") { form.post_text.value = tinyMCE.get('post_text').getContent(); var editor_mode = "wysiwyg"; } else { form.post_text.value = document.getElementById('post_text').value; } if (form.post_text.value == '' || form.post_text.value == '') { alert ( dle_req_field ); return false; } if ( form.sec_code ) { var sec_code = form.sec_code.value; } $.post(forum_ajax + "addpost.php", {editor_mode: editor_mode, topic_id: document.getElementById('topic_id').value, forum_id: form.forum_id.value, topic_title: form.topic_title.value, post_id: form.post_id.value, post_text: form.post_text.value, name: form.name.value, mail: form.mail.value, skin: dle_skin, sec_code: sec_code }, function(data){ $("#ajax-post").html(data); }); return false; }; // ******************************************************************************** // POST DEL // ******************************************************************************** function postDelete(url){ var agree=confirm( 'Вы действительно хотите удалить это сообщение?' ); if (agree) document.location=url; }; // ******************************************************************************** // TOPIC DEL // ******************************************************************************** function topicDelete(url){ var agree=confirm( 'Вы действительно хотите удалить эту тему?' ); if (agree) document.location=url; }; function rowDelete(url){ var agree=confirm( 'Вы действительно хотите удалить эту запись?' ); if (agree) document.location=url; }; // ******************************************************************************** // TOPIC MENU // ******************************************************************************** function TopicMenu( tid, forum_url, moderation ){ var menu=new Array(); if (moderation) { menu[0]='Пересчитать все в теме'; } menu[1]='Подписка на тему'; menu[2]='Сообщить другу'; menu[3]='Версия для печати'; return menu; }; // ******************************************************************************** // FORUM MENU // ******************************************************************************** function ForumMenu( fid, moderation, forum_url ){ var menu=new Array(); if (moderation){ menu[0]='Показать все скрытые темы'; menu[1]='Пересчитать все в форуме'; } menu[3]='Активные темы'; menu[4]='Темы без ответов'; return menu; }; // ******************************************************************************** // POST EDIT MENU // ******************************************************************************** function PostEditMenu( pid, forum_url, page, post_n ){ var menu=new Array(); menu[0]='' + menu_short + ''; menu[1]='' + menu_full + ''; return menu; }; // ******************************************************************************** // USER MENU // ******************************************************************************** function FUserMenu( url, m_id, group, forum_url ){ var menu=new Array(); menu[0]='' + menu_profile + ''; // menu[1]='' + menu_send + ''; menu[2]='Найти темы пользователя'; if (group == '1') { menu[3]='' + menu_uedit + ''; } return menu; }; // ******************************************************************************** // WARN ADD // ******************************************************************************** function FWarn(action, user_id, post_id, forum_id) { var cause = prompt("Введите причину", ""); if (cause) { var ajax = new dle_ajax(); ajax.onShow (''); var varsString = "user_id=" + user_id; ajax.setVar("skin", dle_skin); ajax.setVar("action", action); ajax.setVar("forum_id", forum_id); ajax.setVar("post_id", post_id); ajax.setVar("cause", ajax.encodeVAR(cause)); ajax.requestFile = forum_ajax + "warn.php"; ajax.method = 'POST'; ajax.element = 'warn-' + post_id; ajax.sendAJAX(varsString); } return false; }; // ******************************************************************************** // REPUTATION // ******************************************************************************** function FRep(action, user_id, post_id, forum_id) { var cause = prompt("Введите причину", ""); if (cause) { $.post(forum_ajax + "reputation.php", {skin: dle_skin, action: action, forum_id: forum_id, post_id: post_id, cause: cause, user_id: user_id }, function(data){ $("rep-" + post_id).html(data); }); } return false; }; // ******************************************************************************** // NAVIGATION // ******************************************************************************** function navigation(pages_count, url) { var page = prompt("Перейти к странице", ""); if (page) { if (pages_count >= page) { window.location.href = url + page; } } }; function PostLink(topic_count, link) { url = window.location; var enterCause = prompt("Копирование прямой ссылки", "https://odiscus.com/topic_"+ topic_count + "/#post-" + link); }; // ******************************************************************************** // SELECT ID // ******************************************************************************** function select_id( sid ) { var saved = new Array(); var clean = new Array(); var add = 1; tmp = document.modform.selected_id.value; if( tmp != "" ) { saved = tmp.split(","); } for( i = 0 ; i < saved.length; i++ ) { if ( saved[i] != "" ) { if ( saved[i] == sid ) { add = 0; } else { clean[clean.length] = saved[i]; } } } if ( add ) { clean[ clean.length ] = sid; } newvalue = clean.join(','); document.modform.selected_id.value = newvalue; }; // ******************************************************************************** // SHOW HIDE // ******************************************************************************** function ShowHide( name, open ){ if (document.getElementById( name ).style.display != "none") { document.getElementById( name ).style.display = "none"; } else { document.getElementById( name ).style.display = ""; } if (open) { document.getElementById( name ).style.display = ""; } }; // ******************************************************************************** // POST PREVIEW // ******************************************************************************** function PostPreviewCompleted() { }; function PostPreview() { var post_text = ""; var varsString = ""; if (forum_wysiwyg == "1") { post_text = tinyMCE.get('post_text').getContent(); var editor_mode = "wysiwyg"; } else { post_text = document.getElementById('forum-post-form').post_text.value; } if (post_text == '') { alert('Заполните все необходимые поля');return false } ShowLoading(''); $.post(forum_ajax + "post.preview.php", { post_text: post_text, wysiwyg: forum_wysiwyg, skin: dle_skin }, function(data){ HideLoading(''); $("#post-preview").html(data); }); return false; }; function uploadsform(open_url){ $("#uploads-form").remove(); $("body").append("
"); $('#uploads-form').dialog({ autoOpen: true, width: 470, buttons: { "Закрыть окно": function() { $(this).dialog("close"); $("#uploads-form").remove(); } } }); $.post(forum_ajax + "uploads.form.php", { open_url: open_url}, function(data){ HideLoading(''); $("#uploads-form").html(data); }); return false; }; // PM Photo function uploadsformpm(open_url){ $("#uploads-form").remove(); $("body").append(""); $('#uploads-form').dialog({ autoOpen: true, width: 300, buttons: { "Закрыть окно": function() { $(this).dialog("close"); $("#uploads-form").remove(); } } }); $.post(forum_ajax + "uploads.form.php", { open_url: open_url}, function(data){ HideLoading(''); $("#uploads-form").html(data); }); return false; }; // ******************************************************************************** // FORUM INS // ******************************************************************************** function forum_ins(name) { var input = document.getElementById('forum-post-form').post_text; var finalhtml = ""; if (forum_wysiwyg !== "1") { if (dle_txt!= "") { input.value += dle_txt; } else { input.value += "[b]"+name+"[/b],"+"\n"; } } else { if (dle_txt!= "") { finalhtml = dle_txt; } else { finalhtml = ""+name+","+"