function setStatus(str, color)
{
var set_text;
if(color === undefined)
set_text = str + '...';
else
set_text = '' + str + '...';
$('#line_status').html(set_text);
$('#line_status').stop();
$('#line_status').animate({"opacity": "0"}, 2500,function()
{
$(this).html('').css('opacity', '1');
});
}
var open_key;
var global_graph = 0;
function setSettings(key, value)
{
if(key != "")
{
//setStatus('Сохранение настроек');
//Если нет - вставим
db.transaction(function(tx) {
tx.executeSql("SELECT value FROM WebTicketSettings WHERE key = ?", [key], function(tx, result) {
if (!result.rows.length)
{
db.transaction(function (tx)
{
tx.executeSql("INSERT INTO WebTicketSettings (key, value) VALUES (?, ?)", [key, value], function(tx, result) {
//setStatus('Настройки сохранены');
});
});
}
else
{
db.transaction(function (tx)
{
tx.executeSql("UPDATE WebTicketSettings SET value = ? WHERE key = ?", [value, key], function(tx, result) {
//setStatus('Настройки обновлены');
});
});
}
}, function(tx, error) {
//setStatus('Ошибка сохранения настроек', 'ff0000');
return;
});
});
}
else
setStatus('Ошибка сохранения настроек', 'ff0000');
}
function getEncrypted(val, open_key)
{
var open_key_str = open_key.toString();
var while_var = true;
var k = 0;
while(while_var)
{
var encrypted = CryptoJS.DES.encrypt(val.toString(CryptoJS.enc.Base64), open_key_str).toString();
var encrypted_correct = true;
var encrypted_test_1 = encrypted.replace('+', '');
var encrypted_test_2 = encrypted.replace(' ', '');
if(encrypted_test_1 != encrypted || encrypted_test_2 != encrypted)
encrypted_correct = false;
if(encrypted_correct)
{
var decrypted_test = CryptoJS.DES.decrypt(encrypted.toString(), open_key_str);
var rest_decrypted_test = decrypted_test.toString(CryptoJS.enc.Utf8);
if(val == rest_decrypted_test && val != "")
{
//alert(val + '/' + encrypted + '/' + decrypted_test + '/' + rest_decrypted_test);
return encrypted;
}
if(k == 1000)
return '';
}
k++;
}
return '';
}
function goRePassEl(el, open_key_str)
{
var text = $(el).html();
text_2 = text.replace('text_code_', '');
if(text_2 != text)
{
var count_p = $(el).attr('count_p');
if(count_p > 0)
{
}
else
count_p = 0;
count_p++;
$(el).attr('count_p', count_p);
if(text_2 != "")
{
var decrypted_test = CryptoJS.DES.decrypt(text_2.toString(), open_key_str);
var rest_decrypted_test = decrypted_test.toString(CryptoJS.enc.Utf8);
//alert(text_2 + '/' + decrypted_test + '/' + rest_decrypted_test);
if(rest_decrypted_test == "")
{
var count_p_str = '';
if(count_p > 1)
count_p_str = 'Попыток (' + count_p + ')';
setStatus("Дешефрация... " + count_p_str, "ff0000");
if(count_p > 3)
{
setStatus("Дешефрация не удалась. Попробуйте позже.", "ff0000");
$(el).html("Дешефрация не удалась. Попробуйте позже.");
}
else
{
window.setTimeout(function(){
goRePassEl(el, open_key_str);
}, 5000);
}
}
else
{
$(el).attr('re_code', '1');
$(el).html(rest_decrypted_test);
var c_id = $(el).attr('c_id');
$('.textarea_content_edit[c_id=' + c_id + ']').val(rest_decrypted_test);
}
}
else
{
$(el).attr('re_code', '1');
$(el).html('');
}
}
}
function goRePass()
{
if(open_key != '')
{
var open_key_str = open_key.toString();
$('pre[pass_code=1][re_code=0]').each(function(){
//Смотрим - нужно ли дешефрировать...
if($(this).html().indexOf('text_code_') >= 0)
{
goRePassEl(this, open_key_str);
var par = $(this).parent();
$(par).append('
');
}
else
$(this).attr('re_code', '0');
});
}
}
function save_right_content_Pass(user, type, id, val, textarea_content_edit)
{
if(open_key != "")
{
if(val.length < 200)
{
var msg_send = false;
if(val != "")
{
setStatus("Шифрование...", "00ff00");
var encrypted_res = getEncrypted(val, open_key);
if(encrypted_res != '')
{
val = 'text_code_' + encrypted_res;
msg_send = true;
}
}
else
msg_send = true;
if(msg_send)
{
setStatus("Сохранение...", "00ff00");
$.ajax({
type: 'POST',
url: '/all/content_files/save_right_content.php',
data: 'sid=nnn&user=' + user + '&type=' + type + '&id=' + id + '&val=' + val,
success: function(msg){
if(msg == "iconv_error")
alert("iconv_error!");
$(textarea_content_edit).css("display", "none");
$('#paintRightList_i').click();
}});
}
}
else
{
setStatus("Длина текста превышает 200 симфолов. Шифрование не доступно.", "ff0000");
$.ajax({
type: 'POST',
url: '/all/content_files/save_right_content.php',
data: 'sid=nnn&user=' + user + '&type=' + type + '&id=' + id + '&val=' + val,
success: function(msg){
if(msg == "iconv_error")
alert("iconv_error!");
$(textarea_content_edit).css("display", "none");
$('#paintRightList_i').click();
}});
}
}
else
{
setStatus("Отсутствует отрытый ключ. Пожалуйста переавторизуйтесь.", "ff0000");
alert("Отсутствует отрытый ключ. Пожалуйста переавторизуйтесь.");
}
}
function init_open_key()
{
db.transaction(function(tx) {
tx.executeSql("SELECT value FROM WebTicketSettings WHERE key = ?", ['open_key'], function(tx, result)
{
if(result.rows.length > 0)
{
var row = result.rows.item(0);
open_key = row['value'];
}
});
});
}
function db_tables_init()
{
//setStatus('Инициализация таблицы настроек...', '00ff00');
db.transaction(function(tx) {
tx.executeSql("SELECT COUNT(*) FROM WebTicketSettings", [], function(result) {
init_open_key();
}, function(tx, error) {
tx.executeSql("CREATE TABLE WebTicketSettings (id INTEGER PRIMARY KEY ASC, key TEXT, value TEXT)", [], function(result) {
init_open_key();
});
});
});
}
var db;
$(document).ready(function(){
try {
if (window.openDatabase) {
db = openDatabase("db_vp", "1.0", "HTML5 Database API example", 200000);
if (!db)
setStatus("Failed to open the database on disk. This is probably because the version was bad or there is not enough space left in this domain's quota", "ff0000");
} else
setStatus("Couldn't open the database. Please try with a WebKit nightly with this feature enabled", "ff0000");
} catch(err) {
db = null;
setStatus("Couldn't open the database. Please try with a WebKit nightly with this feature enabled", "ff0000");
}
if(db != null)
{
setStatus('Подключение завершено', '00ff00');
db_tables_init();
}
});
$(document).ready(function() {
window.interval_reload = window.setInterval(interval_reload_fnc, 100);
//================= load_start ======================
var load_href = false;
var href = document.location.href;
var href_mas = href.split('#');
if(href_mas)
{
if(href_mas.length > 1)
{
var load_id = parseInt(href_mas[1]);
parent = load_id;
getMenuAjax(load_id);
load_href = true;
}
}
if(!load_href)
{
parent = 157;//default
var parent_user = parseInt('');
if(parent_user > 0)
parent = parent_user;
getMenuAjax(parent);
}
function lookHelp(help_t)
{
if(help_display == 1)
{
if(help_t == 'menu')
{
$('#help_content').css('display', 'none');
$('#help_menu').css('display', 'block');
}
else
{
$('#help_content').css('display', 'block');
$('#help_menu').css('display', 'none');
}
}
}
$('.help_btn').click(function(e)
{
if(help_display == 1)
{
help_display = 0;
$('#help_content').css('display', 'none');
$('#help_menu').css('display', 'none');
}
else
{
help_display = 1;
if(menu_act == "menu_left")
lookHelp('menu');
else if(menu_act == "menu_content")
lookHelp('content');
}
});
$(document).mouseup(function (e){ // событие клика по веб-документу
var div = $(".help_clss"); // тут указываем ID элемента
if (!div.is(e.target) // если клик был не по нашему блоку
&& div.has(e.target).length === 0) { // и не по его дочерним элементам
help_display = 0;
$('#help_content').css('display', 'none');
$('#help_menu').css('display', 'none');
}
});
var help_display = 0;
var console_mas = new Array();
var console_all_mas = new Array();
var c_o = 0;
var menu_act_save = "";
var number_console = 0;
var content_edit = false;
document.content_list;
function interval_reload_fnc()
{
var right_content = $("#reload").attr("right_content");
//alert(right_content);
if(right_content == 1)
{
$("#reload").attr("right_content", "0");
content_edit = false;
paintRightList();
}
var set_content_edit = $("#regime").attr("content_edit");
if(set_content_edit == 1)
{
$("#regime").attr("content_edit", "0");
content_edit = true;
}
}
$(":input[name='input_line']").focus();
menu_act = "menu_left";
document.menu_el_height = 20;
var menu_left_mas = new Array()
var top = 0;
var bottom = 0;
var act = 0;
var act_con = 0;
var act_find = 0;
var parent = 157;
var user_start_parent = $('#user_start_parent').val();
if(user_start_parent > 0)
parent = user_start_parent;
var top_mas = new Array();
var act_mas = new Array();
var finde_mas = new Array();
//var parents_mas = new Array();
//+++++++++++++++++++++++++++++++++++
$(":input[name='input_line']").keyup(function(event) {
if (event.keyCode == 13)
{
line_send();
}
var val = $(this).val();
var find = false;
var send_mas = val.split(" ");
if(send_mas.length > 1)
{
if(send_mas[0] == "f" && menu_act != "console")
{
find = true;
}
}
if(event.keyCode != 9)//tab
{
if(menu_act == "find_content" && event.keyCode == 13)
{
$("#find_content").html("");
$(".find").css("display", "none");
$(".mc").css("display", "block");
menu_act = "menu_left";
$(".menu_left_el[number='" + act + "']").css("background-color", "#00BBBB");
//alert(finde_mas[act_find]['id']);
//act_find
act = 0;
top = 0;
parent = finde_mas[act_find]['id'];
//alert(parent);
top_mas[parent] = top;
act_mas[parent] = act;
var save_parent;
top = 0;
bottom = 0;
act = 0;
//parents_mas[parent] = 74;
//alert(parent);
getMenuAjax(parent);
finde_mas = new Array();
act_find = 0;
var _parent = finde_mas[act_find]['id'];
setFindSub(_parent);
}
else if(menu_act == "find_content" && event.keyCode == 81)
{
finde_mas = new Array();
act_find = 0;
$("#find_content").html("");
$(".find").css("display", "none");
$(".mc").css("display", "block");
menu_act = "menu_left";
$(".menu_left_el[number='" + act + "']").css("background-color", "#00BBBB");
var _parent = finde_mas[act_find]['id'];
setFindSub(_parent);
}
else
{
if(find)
{
if(menu_act == "find_content")
{
}
else
{
menu_act = "find";
$(".mc").css("display", "none");
$(".find").css("display", "block");
var sid = $("#data").attr("sid");
$.ajax({
type: 'POST',
url: '/all/menu_files/get_find.php',
data: 'sid=' + sid + '&val=' + val,
success: function(msg){
try{
finde_mas = jQuery.parseJSON(msg);
paintFind(finde_mas);
} catch(e) {
$("#find_content").html("Error: " + e + "
Searsh: " + val + "
Finded: " + msg + "
sid: " + sid);
} finally {
}
}});
}
}
else
{
}
}
}
});
function paintFind(finde_mas)
{
//
var str = "";
for(var k = 0; k < finde_mas.length; k++)
{
str += "
" + finde_mas[k]['path'] + "
";
}
$("#find_content").html(str);
if(finde_mas[act_find])
{
var _parent = finde_mas[act_find]['id'];
if(_parent > 0)
setFindSub(_parent);
}
}
function paintConsoleAll()
{
var s = "";
for(var k = 0; k < console_all_mas.length; k++)
{
s += console_all_mas[k] + "
";
}
$("#logo_console_all").html(s);
}
function line_send()
{
var send = $(":input[name='input_line']").val();
if(send != "")
{
var test_go_to = send.replaceAll("goto ", "");
if(test_go_to != send)
{
if(parseInt(test_go_to) > 0)
{
parent = parseInt(test_go_to);
//alert(parseInt(test_go_to));
getMenuAjax(parseInt(test_go_to));
}
}
var url = $("#data").attr("url");
var sid = $("#data").attr("sid");
var number_in_db = $(".menu_left_el[number='" + act + "']").attr("number_in_db");
var id_in_db = $(".menu_left_el[number='" + act + "']").attr("id_in_db");
var file_data_str = "";
var pre = $(".pre[c_k='" + act_con + "']");
var type = $(pre).attr("c_type");
var id = $(pre).attr("c_id");
if(id > 0)
{
file_data_str = '&type=' + type + '&obj7id=' + id;
}
console_mas.push(send);
console_all_mas.push(send);
paintConsoleAll();
number_console++;
send = send.replaceAll("+", "replace_code_plus");
send = send.replaceAll("&", "replace_code_and");
var data = 'val=' + send + '&parent=' + parent + '&act=' + act + '&number_in_db=' + number_in_db + '&sid=' + sid + '&id_in_db=' + id_in_db + file_data_str;
//alert(data);
$.ajax({
type: 'POST',
url: '/all/send.php',
data: data,
success: function(msg){
//alert(msg);
msg = msg.trim();
console_all_mas.push(msg);
paintConsoleAll();
$("#content").html(msg);
if(msg == "login" || msg == "logout")
{
alert("access success");
location.reload();
}
$(":input[name='input_line']").val("");
if(msg == "reload")
{
getMenuAjax("");
}
}
});
}
}
//+++++++++++++++++++++++++++++++++++
var doit;
function resizedw(){
/*
var w = parseInt($(window).width());
if(w >= 700)
{
top = act;
bottom = getMenuLeftBottom(menu_left_mas, top);
paintMenuLeft(menu_left_mas, top, bottom);
setAct(act);
}
else
{
$(".set_regime[regime=\"edit\"]").css("display", "none");
$("#td_help_line_box").css("display", "none");
$("#menu_left").css("display", "none");
$("#content").html("Режим редактирования не доступен
").css('bottom', '0px');
}
*/
}
$(window).resize(function(e){
clearTimeout(doit);
doit = setTimeout(resizedw, 200);
});
setTimeout(resizedw, 800);
$(document).keyup(function(e){
if(menu_act == "menu_left")
{
if(e.keyCode == 38)//top
{
paintRightList();
}
if(e.keyCode == 40)//bottom
{
paintRightList();
}
}
});
function setFindSub(_id)
{
$.ajax({
type: 'POST',
url: '/all/find_files/get_find_sub.php',
data: 'id=' + _id,
success: function(msg){
$("#find_sub_content").html(msg);
}});
}
$(document).keydown(function(e){
//alert(e.keyCode);
if(e.keyCode == 36)//home
{
if(global_graph == 0)
{
global_graph = 1;
var this_id_in_db = parseInt($(".menu_left_el[act_el=1]").attr('id_in_db'));
if(this_id_in_db > 0)
{
$('#box_graf').html('Загрузка графа...');
$('#graph_content').css('display', 'block').attr('graph_load_el', this_id_in_db);
}
}
else
{
global_graph = 0;
$('#graph_content').css('display', 'none').attr('graph_load_el', '0');
}
}
if(e.keyCode == 67)//c
{
$(document.content_list).each(function(e){
var test = $(this).attr("c_id");
//alert(test);
$(this).click();
});
}
if (menu_act == "find_content")
{
var all = finde_mas.length;
if(e.keyCode == 38)//top
{
if(act_find > 0)
{
act_find -= 1;
}
setActFind();
var _parent = finde_mas[act_find]['id'];
setFindSub(_parent);
}
if(e.keyCode == 40)//bottom
{
if(act_find < all - 1)
{
act_find += 1;
}
setActFind();
var _parent = finde_mas[act_find]['id'];
setFindSub(_parent);
}
if(e.keyCode == 33)//pageUp
{
act_find = 0;
setActFind();
var _parent = finde_mas[act_find]['id'];
setFindSub(_parent);
}
if(e.keyCode == 34)//pageDown
{
act_find = all - 1;
setActFind();
var _parent = finde_mas[act_find]['id'];
setFindSub(_parent);
}
}
if(menu_act == "console")
{
if(e.keyCode == 38)//top
{
number_console --;
}
if(e.keyCode == 40)//bottom
{
number_console++;
}
if(e.keyCode == 38 || e.keyCode == 40)
{
if(number_console < 0)
number_console = 0;
if(number_console > console_mas.length)
number_console = console_mas.length;
if(number_console >= 0 && number_console < console_mas.length)
{
$("#input_line").val(console_mas[number_console]);
//alert(console_mas.length + "/" + number_console);
}
else
{
$("#input_line").val("");
}
}
}
if(menu_act == "menu_content")
{
if(e.keyCode == 84)//t text
{
if(!content_edit)
{
var pre = $(".pre[c_k='" + act_con + "']");
var user_id = $(pre).attr("user_id");
var f_id = $(pre).attr("c_id");
$('#file_' + user_id + '_' + f_id).click();
}
}
if(e.keyCode == 13)//enter
{
if(!content_edit)
{
var pre = $(".pre[c_k='" + act_con + "']");
var href = $(pre).attr("href") + '';
if(href != '' && href != 'undefined')
{
if(href == 'All')
{
var div_content = $(".div_content[c_k='" + act_con + "']");
var all_id = $('.textarea_notice_name_edit', div_content).attr("data_id");
$.ajax({
type: 'POST',
url: '/all/content_files/go_to_all_hrefs.php',
data: 'all_id=' + all_id,
success: function(msg){
$(".div_content[c_k='" + act_con + "']").append(msg);
}});
}
else
{
var href_ok = false;
if(href.indexOf('http:') >= 0)
href_ok = true;
if(href.indexOf('https:') >= 0)
href_ok = true;
if(!href_ok)
href = 'http://' + href;
window.open(href, '_blank');
}
return false;
}
}
}
if(e.keyCode == 82)//r rm
{
if(!content_edit)
{
if (confirm("Удалить7"))
{
var sid = $("#data").attr("sid");
var file_data_str = "";
var pre = $(".pre[c_k='" + act_con + "']");
var type = $(pre).attr("c_type");
var id = $(pre).attr("c_id");
if(id > 0)
{
file_data_str = '&type=' + type + '&obj7id=' + id;
}
setStatus('Удаление');
$.ajax({
type: 'POST',
url: '/all/content_files/del_right_content.php',
data: 'sid=' + sid + file_data_str,
success: function(msg){
setStatus('Объект удален');
paintRightList();
$(":input[name='input_line']").val("");
}});
}
}
}
var all = $(".div_content[c_k='0']").attr("all_count");
if(e.keyCode == 69)//e
{
if(!content_edit)
{
content_edit = true;
go_to_id("div_content_" + act_con);
var pre = $(".pre[c_k='" + act_con + "']");
var type = $(pre).attr("c_type");
var id = $(pre).attr("c_id");
var edit = $(".textarea_content_edit[c_type='" + type + "'][c_id='" + id + "']");
$(edit).css("display", "block");
window.setTimeout(function(){$(edit).focus(); go_to_id("textarea_content_edit_" + id);}, 500);
}
}
if(e.keyCode == 78)//n
{
if(!content_edit)
{
content_edit = true;
go_to_id("div_content_" + act_con);
var pre = $(".pre[c_k='" + act_con + "']");
var id = $(pre).attr("data_id");
var edit = $(".textarea_notice_name_edit[data_id='" + id + "']");
$(edit).css("display", "block");
window.setTimeout(function(){$(edit).focus();}, 500)
}
}
if(e.keyCode == 73)//i
{
if(!content_edit)
{
content_edit = true;
go_to_id("div_content_" + act_con);
var pre = $(".pre[c_k='" + act_con + "']");
var id = $(pre).attr("data_id");
var edit = $(".textarea_img7href_edit[data_id='" + id + "']");
$(edit).css("display", "block");
window.setTimeout(function(){$(edit).focus();}, 500)
}
}
if(e.keyCode == 70)//f func
{
if(!content_edit)
{
content_edit = true;
go_to_id("div_content_" + act_con);
var pre = $(".pre[c_k='" + act_con + "']");
var id = $(pre).attr("data_id");
var edit = $(".textarea_fnc_edit[data_id='" + id + "']");
$(edit).css("display", "block");
window.setTimeout(function(){$(edit).focus();}, 500)
}
}
if(e.keyCode == 68)//d data
{
if(!content_edit)
{
content_edit = true;
go_to_id("div_content_" + act_con);
var pre = $(".pre[c_k='" + act_con + "']");
var id = $(pre).attr("data_id");
var edit = $(".textarea_fnc7data_edit[data_id='" + id + "']");
$(edit).css("display", "block");
window.setTimeout(function(){$(edit).focus();}, 500)
}
}
if(e.keyCode == 83)//s sign
{
if(!content_edit)
{
content_edit = true;
go_to_id("div_content_" + act_con);
var pre = $(".pre[c_k='" + act_con + "']");
var id = $(pre).attr("data_id");
var edit = $(".textarea_sign_edit[data_id='" + id + "']");
$(edit).css("display", "block");
window.setTimeout(function(){$(edit).focus();}, 500);
}
}
if(all >= 0)
{
if(!content_edit)
{
if(e.keyCode == 38)//top
{
if(act_con > 0)
{
act_con -= 1;
}
paintContent(true);
}
if(e.keyCode == 40)//bottom
{
if(act_con < all - 1)
{
act_con += 1;
}
paintContent(true);
}
if(e.keyCode == 33)//pageUp
{
act_con = 0;
paintContent(true);
}
if(e.keyCode == 34)//pageDown
{
act_con = all - 1;
paintContent(true);
}
}
else
{
if(e.keyCode == 33 || e.keyCode == 34)
{
content_edit = false;
//Сохраним данные
var pre = $(".pre[c_k='" + act_con + "']");
var type = $(pre).attr("c_type");
var id = $(pre).attr("c_id");
var data_id = $(pre).attr("data_id");
var sid = $("#data").attr("sid");
var user = $("#data").attr("user");
var textarea_content_edit = $(".textarea_content_edit[c_type='" + type + "'][c_id='" + id + "']");
if($(textarea_content_edit).css('display') == 'block')
{
setStatus('Сохранение данных', '00ff00');
var pass_code = $(textarea_content_edit).attr('pass_code');
var val = $(textarea_content_edit).val();
val = val.replaceAll("+", "replace_code_plus");
val = val.replaceAll("&", "replace_code_and");
if(pass_code == 1)
{
save_right_content_Pass(user, type, id, val, textarea_content_edit);
}
else
{
$.ajax({
type: 'POST',
url: '/all/content_files/save_right_content.php',
data: 'sid=' + sid + '&user=' + user + '&type=' + type + '&id=' + id + '&val=' + val,
success: function(msg){
if(msg == "iconv_error")
alert("iconv_error!");
$(textarea_content_edit).css("display", "none");
paintRightList();
}});
}
}
if($(".textarea_notice_name_edit[data_id='" + data_id + "']").css('display') == 'block')
{
setStatus('Сохранение имени', '00ff00');
var edit_name = $(".textarea_notice_name_edit[data_id='" + data_id + "']");
var val = $(edit_name).val();
val = val.replaceAll("+", "replace_code_plus");
val = val.replaceAll("&", "replace_code_and");
$.ajax({
type: 'POST',
url: '/all/content_files/save_right_notice_name.php',
data: 'sid=' + sid + '&user=' + user + '&data_id=' + data_id + '&val=' + val,
success: function(msg){
$(edit).css("display", "none");
paintRightList();
}});
}
if($(".textarea_img7href_edit[data_id='" + data_id + "']").css('display') == 'block')
{
setStatus('Сохранение изображения', '00ff00');
var img7href = $(".textarea_img7href_edit[data_id='" + data_id + "']");
var val = $(img7href).val();
val = val.replaceAll("+", "replace_code_plus");
val = val.replaceAll("&", "replace_code_and");
$.ajax({
type: 'POST',
url: '/all/content_files/save_right_notice_img7href.php',
data: 'sid=' + sid + '&user=' + user + '&data_id=' + data_id + '&val=' + val,
success: function(msg){
$(edit).css("display", "none");
paintRightList();
}});
}
if($(".textarea_fnc_edit[data_id='" + data_id + "']").css('display') == 'block')
{
setStatus('Сохранение функции', '00ff00');
var fnc = $(".textarea_fnc_edit[data_id='" + data_id + "']");
var val = $(fnc).val();
val = val.replaceAll("+", "replace_code_plus");
val = val.replaceAll("&", "replace_code_and");
$.ajax({
type: 'POST',
url: '/all/content_files/save_right_notice_fnc.php',
data: 'sid=' + sid + '&user=' + user + '&data_id=' + data_id + '&val=' + val,
success: function(msg){
$(edit).css("display", "none");
paintRightList();
}});
}
if($(".textarea_fnc7data_edit[data_id='" + data_id + "']").css('display') == 'block')
{
setStatus('Сохранение данных функции', '00ff00');
var fnc7data = $(".textarea_fnc7data_edit[data_id='" + data_id + "']");
var val = $(fnc7data).val();
val = val.replaceAll("+", "replace_code_plus");
val = val.replaceAll("&", "replace_code_and");
$.ajax({
type: 'POST',
url: '/all/content_files/save_right_notice_fnc7data.php',
data: 'sid=' + sid + '&user=' + user + '&data_id=' + data_id + '&val=' + val,
success: function(msg){
$(edit).css("display", "none");
paintRightList();
}});
}
if($(".textarea_sign_edit[data_id='" + data_id + "']").css('display') == 'block')
{
setStatus('Сохранение имени в новостной ленте', '00ff00');
var fnc7data = $(".textarea_sign_edit[data_id='" + data_id + "']");
var val = $(fnc7data).val();
val = val.replaceAll("+", "replace_code_plus");
val = val.replaceAll("&", "replace_code_and");
$.ajax({
type: 'POST',
url: '/all/content_files/save_right_notice_sign.php',
data: 'sid=' + sid + '&user=' + user + '&data_id=' + data_id + '&val=' + val,
success: function(msg){
$(edit).css("display", "none");
paintRightList();
}});
}
}
}
}
}
if(menu_act == "menu_left")
{
if(e.keyCode == 38)//top
{
leftMenuGoTop(0);
}
if(e.keyCode == 40)//bottom
{
leftMenuGoBottom(0);
}
if(e.keyCode == 33)//pageUp
{
//alert("pageUp");
if(act > top)
{
act = top;
setAct(act);
}
else if(act == top)
{
_bottom = getMenuLeftBottom(menu_left_mas, top);
var in_list = _bottom - top + 1;
var menu_h = parseInt($("#menu_left").height());
var count_positions = Math.ceil(menu_h/document.menu_el_height);
count_positions = count_positions - 1;
//alert(count_positions);
if(top - count_positions >= 0)
{
//alert("j");
top = top - count_positions;
bottom = getMenuLeftBottom(menu_left_mas, top);
paintMenuLeft(menu_left_mas, top, bottom);
act = top;
setAct(act);
}
else if(top - in_list <= 0)
{
//alert("w");
top = 0;
bottom = getMenuLeftBottom(menu_left_mas, top);
paintMenuLeft(menu_left_mas, top, bottom);
act = top;
setAct(act);
}
}
}
if(e.keyCode == 34)//pageDown
{
//alert("pageDown");
_bottom = getMenuLeftBottom(menu_left_mas, top);
var in_list = _bottom - top + 1;
if(act < bottom)
{
//alert(top + "/" + act + "/" + bottom + "/" + in_list);
if(bottom - top + 1 == in_list)
{
act = bottom;
setAct(act);
}
else
{
//alert("2");
top = menu_left_mas.length - 2;
bottom = getMenuLeftBottom(menu_left_mas, top);
paintMenuLeft(menu_left_mas, top, bottom);
act = top;
setAct(act);
}
}
else if(act == bottom)
{
//alert(bottom + 1);
//alert(menu_left_mas.length);
if(bottom + 1 < menu_left_mas.length)
{
//alert("j");
top = bottom + 1;
bottom = getMenuLeftBottom(menu_left_mas, top);
paintMenuLeft(menu_left_mas, top, bottom);
act = top;
setAct(act);
}
}
}
if(e.keyCode == 13)//enter
{
$("#content").html("");
var send = $(":input[name='input_line']").val();
if(send == "")
{
enterInPunctMenu();
}
}
if(global_graph == 1)
{
var this_id_in_db = parseInt($(".menu_left_el[act_el=1]").attr('id_in_db'));
if(this_id_in_db > 0)
{
$('#box_graf').html('Загрузка графа...');
$('#graph_content').css('display', 'block').attr('graph_load_el', this_id_in_db);
}
}
}
if(e.keyCode == 45)//Inst
{
if(!content_edit)
{
if(c_o == 1)
{
c_o = 0;
$(".console").css("display", "none");
$(".find").css("display", "none");
$(".mc").css("display", "block");
$("#box_input").css("top", "auto");
$("#box_input").css("bottom", "30px");
menu_act = "menu_left";
paintTabs();
}
else
{
c_o = 1;
menu_act = "console";
$("#logo_console").html("Version: 1.0
" + new Date());
$(".console").css("display", "block");
$(".find").css("display", "none");
$("#box_input").css("bottom", "auto");
$("#box_input").css("top", "30px");
$(".mc").css("display", "none");
number_console = console_mas.length;
$("#input_line").val("");
}
}
}
if(e.keyCode == 9)//tab
{
content_edit = false;
if(menu_act != "find" && menu_act != "find_content")
$("#input_line").val("");
if(menu_act == "menu_left")
{
menu_act = "menu_content";
$(".menu_left_el").css("background-color", "");
lookHelp('content');
}
else if(menu_act == "menu_content")
{
lookHelp('menu');
menu_act = "menu_left";
$(".menu_left_el[number='" + act + "']").css("background-color", "#00BBBB");
$(".textarea_content_edit").css("display", "none");
$(".textarea_notice_name_edit").css("display", "none");
$(".textarea_img7href_edit").css("display", "none");
$(".textarea_fnc_edit").css("display", "none");
$(".textarea_fnc7data_edit").css("display", "none");
$(".textarea_sign_edit").css("display", "none");
}
else if(menu_act == "find")
{
menu_act = "find_content";
act_find = 0;
setActFind();
}
else if(menu_act == "find_content")
{
menu_act = "find";
}
paintTabs();
}
});
function leftMenuGoBottom(paint)
{
if(act < menu_left_mas.length - 1)
{
act += 1;
if(act > bottom)
{
top += 1;
bottom = getMenuLeftBottom(menu_left_mas, top);
paintMenuLeft(menu_left_mas, top, bottom);
}
setAct(act, paint);
var type = $(".menu_left_el[number='" + act + "']").attr("type");
if(type == "hr")
leftMenuGoBottom(paint);
}
}
function leftMenuGoTop(paint)
{
if(act > 0)
{
act -= 1;
if(act < top)
{
top -= 1;
bottom = getMenuLeftBottom(menu_left_mas, top);
paintMenuLeft(menu_left_mas, top, bottom);
}
setAct(act, paint);
var type = $(".menu_left_el[number='" + act + "']").attr("type");
if(type == "hr")
leftMenuGoTop(paint);
}
}
function setActFind()
{
$(".find_content").css("background-color", "#0000BB");
$(".find_content[k='" + act_find + "']").css("background-color", "#00BBBB");
}
function paintTabs()
{
//
var input_line = $(":input[name='input_line']");
var menu_left = $("div[name='menu_left']");
var menu_content = $("div[name='content']");
var find_content = $("div[name='find_content']");
$(":input[name='focus_out']").focus();
window.setTimeout(function(){$(input_line).focus();}, 500);
$(input_line).css("border", "0px");
$(menu_left).css("border", "1px solid #A169BB");
$(menu_content).css("border", "1px solid #A169BB");
$(find_content).css("border", "1px solid #A169BB");
if(menu_act == "menu_left")
{
$(menu_left).css("border", "1px solid #c0c0c0");
}
else if(menu_act == "menu_content")
{
$(menu_content).css("border", "1px solid #c0c0c0");
}
else if(menu_act == "find_content")
{
$(find_content).css("border", "1px solid #c0c0c0");
}
}
function getMenuAjax(r)
{
//var menu_left_mas = new Array();
var url = $("#data").attr("url");
var sid = $("#data").attr("sid");
var user = $("#data").attr("user");
var data = 'url=' + url + '&sid=' + sid + '&user=' + user + '&parent=' + parent;
//alert(data);
$.ajax({
type: 'POST',
url: '/all/menu_files/get_menu.php',
data: data,
success: function(msg){
//alert(msg);
menu_left_mas = jQuery.parseJSON(msg);
if(parseInt(r) > 0)
{
if(act_mas[parent] > 0)
act = act_mas[parent];
else
act = 0;
if(top_mas[parent] > 0)
top = top_mas[parent];
else
top = 0;
}
else
{
top = 0;
}
bottom = getMenuLeftBottom(menu_left_mas, top);
paintMenuLeft(menu_left_mas, top, bottom);
setAct(act);
paintRightList();
paintContent(true);
}
});
}
function getMenuLeftBottom(menu_left_mas, top)
{
var bottom = 0;
var menu_h = parseInt($("#menu_left").height());
var count_positions = Math.floor(menu_h/document.menu_el_height);// ceil no poslednii element ne viden (1 el) t.k. raschitivaet, chto
count_positions = count_positions - 2;
if(count_positions > menu_left_mas.length - top)
count_positions = menu_left_mas.length - top - 1;
bottom = top + count_positions;
//alert(top +"/"+bottom + "/count_positions=" + count_positions + "/" + menu_left_mas.length + "/menu_h = " + menu_h);
//alert(menu_left_mas.length + "/" + bottom);
return bottom;
}
function setAct(set_act, paint)
{
act = set_act;
$(".menu_left_el").css("background-color", "").attr('act_el', '0');
$(".menu_left_el[number='" + set_act + "']").css("background-color", "#00BBBB").attr('act_el', '1');
if (paint === undefined)
{
paint = 1;
}
if(paint == 1)
paintRightList();
}
$('#paintRightList_i').click(function(){
paintRightList();
});
function paintRightList()
{
var url = $("#data").attr("url");
var sid = $("#data").attr("sid");
var user = $("#data").attr("user");
var id_in_db = $(".menu_left_el[number='" + act + "']").attr("id_in_db");
var id_this = $(".menu_left_el[number='" + act + "']").attr("id_this");
var content = $(".menu_left_el[number='" + act + "']").attr("content");
//alert(id_in_db);
$("#content").html("Load...");
var method = 'get';
$.ajax({
type: 'GET',
url: '/all/content_files/get_right_content.php',
data: 'url=' + url + '&sid=' + sid + '&user=' + user + '&parent=' + id_in_db + '&act=' + act + '&id_this=' + id_this + '&method=' + method,
success: function(msg){
if(content != "")
{
$("#content").html(msg);
act_con = 0;
//paintContent(true);
$(".div_content").click(function(){
if(!content_edit)
{
menu_act = "menu_content";
$(".menu_left_el").css("background-color", "");
paintTabs();
act_con = parseInt($(this).attr("c_k"));
paintContent(false);
}
});
$(".div_content_file").click(function(){
if(!content_edit)
{
var f_id = parseInt($(this).attr("f_id"));
var user_id = parseInt($(this).attr("user_id"));
$('#file_' + user_id + '_' + f_id).click();
}
});
/*
$(".div_content_copy").zclip({
path: "js/ZeroClipboard.swf",
copy: function(){
var type = $(this).attr("c_type");
var id = $(this).attr("c_id");
return $(".pre[c_type='" + type + "'][c_id='" + id + "']").html();
},
afterCopy: function(){
}
});
*/
}
else
{
$("#content").html("");
}
}});
var method = 'get';
$.ajax({
type: 'GET',
url: '/all/content_files/get_submenu.php',
data: 'url=' + url + '&sid=' + sid + '&user=' + user + '&parent=' + id_in_db + '&act=' + act + '&id_this=' + id_this + '&method=' + method,
success: function(msg){
if(msg != "")
$("#sub_menu_left").css("display", "block");
else
$("#sub_menu_left").css("display", "none");
$("#sub_menu_left").html(msg);
}});
$("#menu_path").html("path");
}
String.prototype.replaceAll = function(search, replace){
return this.split(search).join(replace);
}
function paintContent(go)
{
$(".div_content").css("background-color", "");
$(".div_content[c_k='" + act_con + "']").css("background-color", "#465E77");
if(go)
go_to_id("div_content_" + act_con);
}
function paintMenuLeft(menu_left_mas, top, bottom)
{
var menu_left_str = "";
var from = 0;
var to = menu_left_mas.length;
for(var k = from; k < to; k++)
{
if(k >= top && k <= bottom)
{
if(menu_left_mas[k]['name'] == "hr")
{
//menu_left_str += "";
menu_left_str += "";
}
else
{
var access = "";
if(menu_left_mas[k]['access'] == 1)
access = "edit | ";
else
access = "edit | ";
var lock = "";
if(menu_left_mas[k]['lock'] > 0)
lock = "look | ";
else
lock = "look | ";
var var_lock = "";
if(menu_left_mas[k]['var_lock'] > 0)
var_lock = "⊄ | ";
else
var_lock = " | ";
var __top_el = false;//..
if(menu_left_mas[k]['name'].indexOf('..') >= 0)
__top_el = true;
if(menu_left_mas[k]['name'] != "hr" && !__top_el)
{
menu_left_str += "";
}
else
{
if(__top_el)
{
menu_left_mas[k]['name'] = menu_left_mas[k]['name'].replace("..", "").trim();
menu_left_str += "";
}
else
{
menu_left_str += "";
}
}
}
}
}
menu_left_str += '';
$("#menu_left").html(menu_left_str);
$(".menu_left_el").dblclick(function(){
enterInPunctMenu();
})
$(".menu_left_el").click(function(){
menu_act = "menu_left";
paintTabs();
var number = parseInt($(this).attr("number"));
setAct(number);
});
}
function go_to_id(id)
{
if($("#"+id).position())
{
var destination = $("#"+id).position().top;
//alert(id + "/" + destination);
$('#content').animate({scrollTop:destination}, 'slow'); return false; //scrollTop
}
}
function enterInPunctMenu()
{
var name = $(".menu_left_el[number='" + act + "']").attr("name");
top_mas[parent] = top;
act_mas[parent] = act;
parent = menu_left_mas[act]['id'];
top = 0;
bottom = 0;
act = 0;
getMenuAjax(parent);
}
});