HL = {'MAIN_URL':'http://www.pr25_autocatalog/autolife/'}; HL.blur = function(){ $("input[bl]").attr('value',function(){ if ( $(this).attr('value')!='' ){ return $(this).attr('value'); } return $(this).attr('bl') }).focus( function(){ if ( $(this).attr('value') == $(this).attr('bl') ){ $(this).attr('value','') ; } }).blur(function(){ if ( $(this).attr('value') == '' ){ $(this).attr('value',$(this).attr('bl')) ; } }); $("form").submit( function(){ $("input[bl]").attr('value', function(){ if ( $(this).attr('value')==$(this).attr('bl') ){ return ''; } }) }) } // blur // ищем формы, которые нужно отправлять через ajax HL.submit = {'types':new Array } HL.submit.register = function(obl){ HL.submit.types[ obl.name ]=obl; } HL.submit.search = function(){ $("form[ajax=true]").each(function(index) { $(this).attr('ajax',false); $(this).submit( function(){ form = $(this); obj = HL.submit.types[ form.attr('name') ]; if ( obj.onSubmit ){ obj.onSubmit( form ); } $.ajax( { 'dataType':'xml', 'type': "POST", 'url': form.attr('action'), 'data':form.serializeArray(), 'success': function(msg){ obj.result(msg,form) }, 'error': function(event, jqXHR, ajaxSettings) { obj.error(ajaxSettings,form) } }); return false; }); }); } // submit HL.wysiwyg = function(){ $("textarea[wysiwyg=true]").each(function(index) { type = $(this).attr('type'); if ( !type ){ alert('Ошибка вызова редактора, не указан тип!') } if ( !HL.editor.types[type] ){ alert('Ошибка вызова редактора, не тип "'+type+'" не зарегистрирован!') } link = HL.editor.obj.length; $(this).attr('link_editor',link) if ( $(this).attr('module') ){ HL.editor.obj[link] = HL.editor.types[type].create( $(this).attr('name'),$(this).attr('module') ); }else{ HL.editor.obj[link] = HL.editor.types[type].create( $(this).attr('name'),false ); } }); } /** * класс для регистрации редакторов * */ HL.editor = {'types':new Array,'obj':new Array, } /** * регистрируем новый тип редактора * */ HL.editor.register = function(type,obl){ HL.editor.types[ type ]=obl; } /** * Получаем ссылка на редактор * */ HL.editor.get = function(id){ return HL.editor.obj[id] } /* HL.editor.removeType = function(type){ //HL.editor.types[ type ]=obl; }*/ /** * удалим редактор из элемента * */ HL.editor.remove = function(element){ type = element.attr('type'); if (!type) { return false; } element.attr('wysiwyg',false); element.attr('type',null); HL.editor.types[type].remove(element); } /** * соберём контент со всех редакторов * */ HL.editor.getText = function(){ $("textarea[wysiwyg=true]").each(function(index) { type = $(this).attr('type'); $(this).attr('value', HL.editor.types[type].getText( $(this) ) ); }) } /** * меняем один редактор на другой * */ HL.editor.change = function(name) { HL.editor.remove( $('#p_content') ) if ( name ){ $('#p_content').attr('wysiwyg',true); $('#p_content').attr('type',name); HL.wysiwyg(); } return false; } HL.page = {'p_id':false,'p_name':false,'module':false} HL.page.load = function(){ // module:page:page_id i = HL.cookie.get('HL_info').split(':'); if ( false!=HL.math.is_nan(i[2]) ){ HL.page.p_id = i[2]; HL.page.p_name = i[1]; HL.page.module = i[0]; } } HL.page.control = function(){ HL.page.load(); // глобальный хук на нажатие клавиш /* $('html').keydown( function(e){ if ( e.which==17 ){ $('div[func]').each( function(i,el){ n = $(el).next(); if ( n.size()>0 ){ p = n.position(); $(el).css('left',p.left).css('top',p.top).css('display','block').click( function(){ HL.snippet.edit($(el).attr('module'),$(el).attr('func') ); }); //click } }); // each } }) // keydown $('html').keyup( function(e){ $('div[func]').unbind('click'); $('div[func]').css('display','none'); }) // window keydown */ } // cookie HL.cookie={}; HL.cookie.get = function(name) { var cookie = " " + document.cookie; var search = " " + name + "="; var setStr = ''; var offset = 0; var end = 0; if (cookie.length > 0) { offset = cookie.indexOf(search); if (offset != -1) { offset += search.length; end = cookie.indexOf(";", offset) if (end == -1) { end = cookie.length; } setStr = unescape(cookie.substring(offset, end)); } } return(setStr); } HL.cookie.set = function(name,value,expires,path,domain,secure) { document.cookie = name + "=" + escape (value)+ ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=/": "") + ((domain) ? "" : "") + ((secure) ? "; secure" : ""); } // snippet /*HL.snippet = {} HL.snippet.edit = function(m,f){ HL.window.onload = function(){ editor.create('snippet'); } HL.window.open('/?p_name=admin_tools&act=ajax_snippet_edit&m_path='+m+'&f_func='+f) } HL.snippet.save = function(){ $.ajax( { 'type': "POST", 'url': '/?p_name=admin_tools&act=ajax_snippet_save', 'data':$('#snippet_form').serializeArray(), 'success': function(msg){ HL.window.close() }, 'error': function(event, jqXHR, ajaxSettings) { alert(ajaxSettings ) } }) }*/ HL.getRandomInt = function(min, max){ return Math.floor(Math.random() * (max - min + 1)) + min; } // window HL.window = {'onload':false,'onclose':false,'wtitle':false} //HL.window.keydown=function(e){e=e || window.event;key=e.charCode || e.keyCode;if(key==27)HL.window.close()} HL.window.open = function(server){ // костыль tmp = {'onload':HL.window.onload,'onclose':HL.window.onclose}; HL.window.onload = HL.window.onclose = false; // ожидайте HL.window.lock() // запрос jQuery.get(server, {}, function(data){ HL.window.close(); HL.window.onload = tmp.onload; HL.window.onclose = tmp.onclose; HL.window.show($(data).find('title').text(),$(data).find('content').text()); },'xml').error(function(event, jqXHR, ajaxSettings) { alert(ajaxSettings ) }) } // закрываем окно HL.window.close = function(){ if( $('#wnd_modal').size()>0 ){ $('#wnd_modal').remove()} if( $('#wnd_background').size()>0 ){ $('#wnd_background').remove()} if ( HL.window.onclose ){ HL.window.onclose(); HL.window.onclose =false; } return false; } // показываем окно HL.window.show = function(title,content){ HL.window.background = false; // окно можетбыть только одно if ( $('#wnd_modal').size()>0 ){ HL.window.close(); } if ( $('#wnd_background').size()>0 ){ $('#wnd_background').css('display', 'block' ); }else{ HL.window.background = $('
').click(function(){HL.window.close()}).attr('id','wnd_background').attr('class','background').appendTo( document.body ); // временно кривое решение для перехвата клавиш //window.onkeydown = function(e){ wnd.keydown(e) }; } HL.window.$ = $('
').attr('id','wnd_modal').attr('class','msg').appendTo( document.body ); HL.window.wtitle=title; HL.window.wcontent = content; HL.window.rematch() if ( HL.window.onload ){ HL.window.onload(); HL.window.onload =false; } //HL.window.disabled = false; } HL.window.rematch = function(){ html = ''; if ( HL.window.wtitle!=false){ html+= '

'+ HL.window.wtitle+'

'; } HL.window.$.html( html + '
'); $('.msg_content').append( $(HL.window.wcontent) ); // глючит в опере // HL.window.$.css('left', (Math.round(($('body').innerWidth()-HL.window.$.width())/2)+'px') ); //HL.window.$.css('top', (Math.round(($('body').innerHeight()-HL.window.$.height())/2)+'px') ); HL.window.$.css('left', Math.round((window.innerWidth-HL.window.$.width())/2)+'px' ); HL.window.$.css('top',Math.round((window.innerHeight-HL.window.$.height())/2)+'px' ); } HL.window.lock = function(){ HL.window.show('Идёт загрузка','

Сервер обрабатывает ваш запрос.
Не закрывайте это окно если хотите дождаться окончания загрузки.

'); } // сложные контролы системы HL.controls = {}; // таблица для отображения данных HL.controls.table = {'orderBy':new Array(),'where':new Array(),'server':false } /** * перезагрузим данные в таблице * */ HL.controls.table = function(server) { if ( !server ){ alert('Ошибка: нужно указать адрес сервера'); return false; } this.server = server; this.data = new Array(); this.data['page']=1; this.error = this.defaultError; this.result = this.defaultError; this.actions = new Array(); this.setAction('pagenav',this.pagenav); this.setAction('reload',this.reload); this.setAction('edit',this.edit); this.setAction('save',this.save); this.setAction('del',this.del); this.searchAction(); } HL.controls.table.prototype.setAction = function(name,func) { this.actions[name]=func } HL.controls.table.prototype.setWhere = function(where,value) { this.data[where]=value; } HL.controls.table.prototype.setOrder = function(order,value) { this.data[order]=value; } HL.controls.table.prototype.registerError = function(f){ this.error = f; } HL.controls.table.prototype.registerResult = function(f){ this.result = f; } HL.controls.table.prototype.defaultError = function(e){ alert(e); } HL.controls.table.prototype.resultFunc = function(xml){ // ошибка if ( $(xml).find('error').length>0 ){ // alert(11) HL.controls.msg.error( $(xml).find('text').text() ) //this.error( $(data).find('text').text() ); return false; } // показываем окно if ( $(xml).find('window').length>0 ){ // alert(2) HL.window.show( $(xml).find('title').text(), $(xml).find('text').text() ); this.searchAction(); HL.submit.search(); HL.wysiwyg(); return false; } // меняем контент if ( $(xml).find('content').length>0 ){ // alert(3) $('#table_content' ).html( $(xml).find('text').text() ); this.searchAction(); HL.submit.search(); return true; } // сообщение if ( $(xml).find('msg').length>0 ){ // alert(4) HL.controls.msg.system( $(xml).find('text').text() ); return true; } if ( $(xml).find('debug').length>0 ){ HL.window.show('Отладка','') return false; } alert($(xml).text() ) alert('Неверный XML ответ!'); } HL.controls.table.prototype.searchAction = function(){ var t = this; $('a[act]').each( function(i,el){ if ( $(el).data('link_table') ){ return true; } $(el).addClass('js_link'); $(el).data('link_table',t); $(el).click( function(){ action = $(this).attr('act'); $(this).data('link_table').execute(action,$(this) ); }) }); $('form[act]').each( function(i,el){ if ( $(el).data('link_table') ){ return true; } $(el).data('link_table',t); $(el).ajaxForm( { "success" : function(responseText, statusText, xhr, $form){ if ( false != $form.data('link_table').resultFunc(responseText) ){ HL.controls.msg.system( 'Изменения сохранены' ); HL.window.close() } }, 'error' : function(event, jqXHR, ajaxSettings) { alert(ajaxSettings) }, 'beforeSubmit':$(el).data('link_table').executeForm, 'act':$(el).attr('act') , 'link_table':$(el).data('link_table'), 'dataType':'xml', 'url':t.server+'&act='+$(el).attr('act'), 'data' : new Object, //'link':$(el) } ); }); } HL.controls.table.prototype.executeForm = function(formData, jqForm, options){ t = options['link_table'] ; act = options['act']; // пользователь вносит свои 5 копеек if ( t.actions[act] ){ t.actions[act](t); for( i in t.data ){ options['data'][i] = t.data[i]; } return true; } for( i in t.data ){ options['data'][i] = t.data[i]; } // стандартно //HL.window.lock(); HL.editor.getText(); return true; } HL.controls.table.prototype.execute = function(act,link){ if ( !act ){ alert('Не определено действие!'); return false; } if ( this.actions[act] ){ // пользователь обрабатывает this.actions[act](this,link); }else{ send_data = new Array(); for( i in this.data ){ send_data[send_data.length] = {'name':i,'value': this.data[i]}; } send_data[send_data.length] = {'name':'id','value': $(link).attr('row_id')}; // стандартно HL.window.lock(); $.ajax( { 'dataType':'xml', 'type' : "POST", 'url' : this.server+'&act='+act, 'data' : send_data, 'success' : function(xml){ if ( false!=t.resultFunc(xml) ){ HL.window.close() } }, 'error' : function(event, jqXHR, ajaxSettings) { t.error(ajaxSettings); HL.window.close() }, }) } } HL.controls.table.prototype.pagenav = function(t,link) { t.data['page'] = $(link).attr('page'); send_data = new Array(); for( i in t.data ){ send_data[send_data.length] = {'name':i,'value': t.data[i]}; } HL.window.lock(); $.ajax( { 'dataType':'xml', 'type' : "POST", 'url' : t.server+'&act=reload', 'data' : send_data, 'success' : function(xml){ t.resultFunc(xml); HL.window.close() }, 'error' : function(event, jqXHR, ajaxSettings) { t.error(ajaxSettings); HL.window.close() }, }) return false; } HL.controls.table.prototype.reload = function(t,link) { send_data = new Array(); t.data['page'] = $(link).attr('page'); for( i in t.data ){ send_data[send_data.length] = {'name':i,'value': t.data[i]}; } HL.window.lock(); $.ajax( { 'dataType':'xml', 'type' : "POST", 'url' : t.server+'&act=reload', 'data' : send_data, 'success' : function(xml){ t.resultFunc(xml); HL.window.close() }, 'error' : function(event, jqXHR, ajaxSettings) { t.error(ajaxSettings); HL.window.close() }, }) } HL.controls.table.prototype.edit = function(t,link) { HL.window.lock(); send_data = new Array(); for( i in t.data ){ send_data[send_data.length] = {'name':i,'value': t.data[i]}; } send_data[send_data.length] = {'name':'id','value': $(link).attr('row_id')}; // $.ajax( { 'dataType':'xml', 'type' : "POST", 'url' : t.server+'&act=edit', 'data' : send_data, 'success' : function(xml){ t.resultFunc(xml); }, 'error' : function(event, jqXHR, ajaxSettings) { t.error(ajaxSettings); HL.window.close() }, }) } HL.controls.table.prototype.save = function(t) { HL.controls.msg.system( 'Идёт сохранение даных...' ); } HL.controls.table.prototype.del = function(t,link) { if( !confirm('Удалить запись?') ){ return false; } send_data = new Array(); for( i in t.data ){ send_data[send_data.length] = {'name':i,'value': t.data[i]}; } send_data[send_data.length] = {'name':'id','value': $(link).attr('row_id')}; HL.window.lock(); $.ajax( { 'dataType':'xml', 'type' : "POST", 'url' : t.server+'&act=delete', 'data' : send_data, 'success' : function(xml){ if ( false!=t.resultFunc(xml)){ HL.window.close() } }, 'error' : function(event, jqXHR, ajaxSettings) { t.error(ajaxSettings); }, }) } HL.controls.msg = {'d':false} HL.controls.msg.system = function(m,time){ HL.controls.msg.remove = false; if ( HL.controls.msg.d!=false ){ HL.controls.msg.d.parentNode.removeChild( HL.controls.msg.d ); } if ( time!=0 && !time ){ time = 3000; } HL.controls.msg.d = document.createElement('DIV'); HL.controls.msg.d.id = 'message'; HL.controls.msg.d.innerHTML = m; HL.controls.msg.d.className='ajax_system_msg'; document.body.appendChild(HL.controls.msg.d); HL.controls.msg.d.onclick = function(){ HL.controls.msg.remove = true; HL.controls.msg.close()} if ( time!=0 ){ HL.controls.msg.remove = true; window.setTimeout( function(){ HL.controls.msg.close()}, time) } } HL.controls.msg.error = function(m,time){ HL.controls.msg.remove = false; if ( HL.controls.msg.d ){ HL.controls.msg.d.parentNode.removeChild( HL.controls.msg.d ); HL.controls.msg.remove = false; } HL.controls.msg.d = document.createElement('DIV'); HL.controls.msg.d.id = 'message'; HL.controls.msg.d.innerHTML = m; HL.controls.msg.d.className='ajax_red_msg'; document.body.appendChild(HL.controls.msg.d); HL.controls.msg.d.onclick = function(){ HL.controls.msg.remove = true; HL.controls.msg.close()} } HL.controls.msg.close = function(){ if ( HL.controls.msg.remove == false || $('#message').size()==0 ){ return false; } if ( HL.controls.msg.d!=false ){ HL.controls.msg.d.parentNode.removeChild( HL.controls.msg.d ); } HL.controls.msg.d = false; return false; } HL.controls.msg.hidden = function(){ HL.controls.msg.close() } HL.math = {}; HL.math.is_nan = function(val) { if (typeof val == 'number' && isNaN(val)) { return true; } if ( typeof val == 'string' && val.match(/^[0-9]*$/) ) { return true; } return false; } // jquery $(document).ready(function() { // поля ввода с заранее введённым дефолтовым контентом // типа login/pass/search HL.blur(); // управление страницей HL.page.control(); // автоматическое подключение висивиг редактора HL.wysiwyg(); // обработка ajax форм HL.submit.search() }); ///////////////////////////////////////////////////// // старый фонд o = {}; o.d = document; o.$ = function(i){return o.d.getElementById(i)} o.create_element = function(type,props){el = o.d.createElement(type);for( pr in props){el[pr] = props[pr];}return el;} o.center_width = function(cw){ return ((o.d.documentElement.clientWidth-cw)/2); } o.outerHTML = function(e,r){ if (e.outerHTML) { e.outerHTML = r; }else{ var range = document.createRange(); range.setStartBefore(e); var docFrag = range.createContextualFragment(r); e.parentNode.replaceChild(docFrag, e); } } o.msg = {'d':false} o.msg.system = function(m,time){ o.msg.remove = false; if ( o.msg.d ){ o.msg.d.parentNode.removeChild( o.msg.d ); } if ( time!=0 && !time ){ time = 3000; } o.msg.d = document.createElement('DIV'); o.msg.d.id = 'message'; o.msg.d.innerHTML = m; o.msg.d.className='ajax_system_msg'; document.body.appendChild(o.msg.d); o.msg.d.onclick = function(){ o.msg.remove = true; o.msg.close()} if ( time!=0 ){ o.msg.remove = true; window.setTimeout( function(){ o.msg.close()}, time) } } o.msg.error = function(m,time){ o.msg.remove = false; if ( o.msg.d ){ o.msg.d.parentNode.removeChild( o.msg.d ); o.msg.remove = false; } o.msg.d = document.createElement('DIV'); o.msg.d.id = 'message'; o.msg.d.innerHTML = m; o.msg.d.className='ajax_red_msg'; document.body.appendChild(o.msg.d); o.msg.d.onclick = function(){ o.msg.remove = true; o.msg.close()} } o.msg.close = function(){ if ( o.msg.remove == false || $('#message').size()==0 ){ return false; } o.msg.d.parentNode.removeChild( o.msg.d ); o.msg.d = false; } o.msg.hidden = function(){ o.msg.close() } o.block = {} o.block.edit = function(block_id){ wnd.open('/?p_name=admin_blocks&act=ajax_edit_short&block_id='+block_id) } o.block.save = function(){ r = new request( '/?p_name=admin_blocks&act=ajax_save_short_form' ); r.onload = function(rst){ window.location.reload(); } r.error = function(e){ alert(e); } r.form( o.$('block_form') ); } requests = { e:new Array() } requests.set = function(o){ l = requests.e.length; requests.e[ l ]=o return l; } requests.get = function(id){ if (requests.e[ id ]){ return requests.e[ id ] }else{ return false; } } request = function(server){ this.TRANSFER = false; this.server = server this.result = this.error = false; // ждём ответа 30 секунд this.timewait = 30000; // функция обработки ошибки потерянного запроса по умолчанию this.error_func = this.transfer_error; } // событие срабатывает при получении ответа //request.prototype.onload = function(func){this.load_func = func} // событие срабатывает при отправки на сервер //request.prototype.onrequest = function( func ){this.request_func = func} // событие срабатывает если данные от сервера не получены //request.prototype.onerror = function( func ){this.error_func = func} request.prototype.transfer_error = function(o){ o.TRANSFER = true; //alert('Запрос потерян') o.onerror('Запрос потерян'); } request.prototype.send = function(o){ o.id_request = requests.set(this); // посылаем запрос JsHttpRequest.query(this.server,o,this.end,true); // сообщаем клиенту, что запрос ушёл if ( this.onrequest ){ this.onrequest(); } // повисшие запросы нужно удалять через заданный интервал времени if ( this.timewait>0 ){ ob = this; this.time_stop = window.setTimeout( function() { ob.transfer_error(ob) } ,this.timewait); } } // функция обрабатывающая ответ серера request.prototype.end = function(rst,err){ // критическая ошибка обработки запроса if ( err!='' && !rst ){ alert(err) return false; } // номер запроса if ( !rst.id_request ){ alert('Ошибка: устаревшая форма обмена данными'); return false; } // получаем объект из базы ob = requests.get(rst.id_request); // останавливаем счётчик clearTimeout(ob.time_stop); // если время на обработку запроса вышло, то ничего не делаем //if (ob.TRANSFER ){return false;} ob.TRANSFER = true; // если есть ошибка, то выводим её if ( err!='' ){ if ( !ob.error ){ alert(err)} ob.error(err); return false; } // если есть результат, то выводим его if ( !ob.onload ){return false;} ob.onload(rst); } request.prototype.form = function(f){ id_request = requests.set(this); var req = new JsHttpRequest(); req.onreadystatechange = function() { if (req.readyState == 4) { // сервер не смог обработать запрос if ( !req.responseJS ){ alert(req.responseText) return false; } ob = requests.get( req.responseJS.id_request ); ob.end(req.responseJS,req.responseText) } } req.open(null, this.server, true); req.send( { q: f,'id_request':id_request} ); // сообщаем клиенту, что запрос ушёл if ( this.onrequest ){ this.onrequest(); } // повисшие запросы нужно удалять через заданный интервал времени if ( this.timewait>0 ){ ob = this; this.time_stop = window.setTimeout( function() { ob.transfer_error(ob) } ,this.timewait); } } wnd = {'onload':false,'onclose':false,'wtitle':false} wnd.keydown=function(e){e=e || window.event;key=e.charCode || e.keyCode;if(key==27)wnd.close()} wnd.set_content=function(m){wnd.wcontent=m} wnd.set_title=function(m){wnd.wtitle=m} wnd.open = function(server){ r = new request( server ); r.onrequest = function(){ wnd.set_content('

Сервер обрабатывает ваш запрос.
Не закрывайте это окно если хотите дождаться окончания загрузки.

'); wnd.set_title('Идёт загрузка'); wnd.onclose = function() { r.TRANSFER = true; } // добавлено для блокировки двойного выполнения onload wnd.disabled = true; wnd.show(100,100); } r.onerror = function(){ wnd.set_content('

Время ожидания ответа вышло. Попробуйте сделат запрос ещё раз.

'); wnd.set_title('Ошибка'); wnd.show(0,0); } r.onload = function(rst) { wnd.close(); // выполняем код js из переданного html /*$(rst.content).filter('script').each( function(i,el){ $(el).attr('defer',true); $('body').append(el ) })*/ //$('body').append( $(rst.content) ) wnd.set_content(rst.content); wnd.set_title(rst.title); wnd.show(0,0); } r.send({}) } wnd.close = function(){ if(o.$('wnd_modal')){o.$('wnd_modal').parentNode.removeChild(o.$('wnd_modal'))} // из-за ошибки оперы пришлось отказаться от удаления слоя, // теперь слой просто скрывается if(o.$('wnd_background')){o.$('wnd_background').style.display='none' } if ( wnd.onclose ){ wnd.onclose(); wnd.onclose =false; } return false; } wnd.show = function(width,height){ if ( !o.d.body ){return false} //IE не поддерживает wnd.$ = false; wnd.background = false; if ( o.$('wnd_modal') ){ wnd.close(); } if ( o.$('wnd_background') ){ o.$('wnd_background').style.display = 'block' }else{ wnd.background = o.d.createElement('div'); wnd.background.onclick = wnd.close; wnd.background.id = 'wnd_background'; wnd.background.className = 'background'; o.d.body.appendChild(wnd.background); // временно кривое решение для перехвата клавиш window.onkeydown = function(e){ wnd.keydown(e) }; } // формируем окно wnd.$ = o.d.createElement("div"); wnd.$.className='msg'; wnd.$.id='wnd_modal'; o.d.body.appendChild(wnd.$); wnd.rematch() if ( wnd.disabled==false && wnd.onload ){ wnd.onload(); wnd.onload =false; } wnd.disabled = false; } wnd.rematch = function(){ if ( wnd.wtitle!=false){ wnd.$.innerHTML+= '

'+ wnd.wtitle+'

'; } wnd.$.innerHTML+= '
'+wnd.wcontent+'
'; wnd.$.style.left = Math.round((window.innerWidth-wnd.$.clientWidth)/2)+'px'; wnd.$.style.top = Math.round((window.innerHeight-wnd.$.clientHeight)/2)+'px'; } cookie={}; cookie.get = function(name) { var cookie = " " + document.cookie; var search = " " + name + "="; var setStr = ''; var offset = 0; var end = 0; if (cookie.length > 0) { offset = cookie.indexOf(search); if (offset != -1) { offset += search.length; end = cookie.indexOf(";", offset) if (end == -1) { end = cookie.length; } setStr = unescape(cookie.substring(offset, end)); } } return(setStr); } cookie.set = function(name,value,expires,path,domain,secure) { document.cookie = name + "=" + escape (value)+ ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=/": "") + ((domain) ? "" : "") + ((secure) ? "; secure" : ""); } users = { 'server' :"", }; users.login = function(){ wnd.open('/?p_name=users_profile&act=ajax_login_form') } users.register = function(){ wnd.open('/?p_name=users_register&act=ajax_form') } users.save = function(){ r = new request( '/?p_name=users_register&act=ajax_save' ); r.onload = function(rst){ o.msg.hidden(); //window.location.reload(); wnd.set_content(rst.msg); wnd.show(); } r.error = function(e){ o.msg.error(e); } r.form( o.$('register_form') ); } users.auth = function(){ r = new request( '/?p_name=users_profile&act=ajax_auth' ); r.onload = function(rst){ o.msg.hidden(); window.location.reload(); } r.error = function(e){ o.msg.error(e); } r.form( o.$('login_form') ); } users.edit = function(id){ wnd.open('/?p_name=users_profile&act=ajax_edit&id='+id) } users.save_mod = function(){ r = new request( '/?p_name=users_profile&act=ajax_save' ); r.onload = function(rst){ o.msg.hidden(); wnd.close(); } r.error = function(e){ o.msg.error(e); } r.form( o.$('profile_form') ); } users.forget = function(){ wnd.open('/?p_name=users_profile&act=ajax_forget') } users.forget_send = function(){ r = new request( '/?p_name=users_profile&act=ajax_forget_send' ); r.onload = function(rst){ o.msg.hidden(); //window.location.reload(); wnd.set_content(rst.msg); wnd.show(); } r.error = function(e){ o.msg.error(e); } r.form( o.$('forget_form') ); } // регестрируем набор функций для работы с окном debug = {}; debug.hidden = function(){ o.$('debug_link').style.display='block'; o.$('debug_wnd').style.display='none'; } debug.show = function(){ o.$('debug_link').style.display='none'; o.$('debug_wnd').style.display='block'; o.$('debug_wnd').style.left = o.center_width( o.$('debug_wnd').clientWidth ); } debug.tab = function(id){ //o.$(id).style.display='block'; o.$('debug_content').innerHTML = ''; o.$('debug_content').innerHTML = o.$(id).innerHTML; o.$('debug_wnd').style.left = o.center_width( o.$('debug_wnd').clientWidth ); } debug.info = function(page){ wnd.open('/?p_name=admin_pages&act=ajax_info&page='+page) } debug.tmpl = function(page){ wnd.open('/?p_name=admin_pages&act=ajax_tmpl&page='+page) } debug.tmpl_save = function(){ r = new request( '/?p_name=admin_pages&act=ajax_tmpl_save' ); r.onload = function(rst){ o.msg.hidden(); wnd.close(); //window.location.reload(); //wnd.set_content(rst.msg); //wnd.show(); } r.error = function(e){ o.msg.error(e); } r.form( o.$('tmpl_form') ); } // редактор окна window.onkeyup = function(event){ var keynum if(window.event) { keynum = event.keyCode }else if(event.which) { keynum = event.which } if ( event.ctrlKey && (keynum==45 ) ){ wnd.open('/?p_name=admin_pages&act=ajax_info&page='+o.page) } }