Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 20.08.2012 */
- var NS = {
- width: 0,
- height: 0,
- z_index: 100,
- mouse_x: 0,
- mouse_y: 0,
- num_alerts: 0,
- num_ajaxed: 0,
- section: '',
- start_query: {},
- ID: 0,
- KEY: '',
- initAjax: function() {
- $.ajaxSetup({
- cashe: false,
- timeout: 30000,
- type: "POST",
- beforeSend: function() {
- },
- complete: function() {
- },
- error: function(xhr, status) {
- }
- });
- this.initNS();
- },
- initConnector: function() {
- var flashvars = {ID: ID, KEY: KEY};
- swfobject.embedSWF("/includes/swf/connector.swf", "connector", "1", "1", "10.2.0", "/includes/js/swf/expressInstall.swf", flashvars);
- this.initNS();
- },
- initNS: function() {
- document.onmousemove = this.mousePageXY;
- this.width = $('body').width();
- this.height = $('body').height();
- this.initModule();
- },
- initModule: function() {},
- sockRead: function(obj) {
- if(obj.module=='system') {
- this.sockHandler(obj);
- }
- else if(obj.module=='error') {
- this.sockError(obj);
- }
- },
- sockHandler: function(obj) {
- if(obj.action == 'init') {
- $('#preloader').hide();
- $('#menu').show();
- this.sockWrite(START_QUERY);
- }
- },
- sockError: function(obj) {
- if(obj.action == 'full') {
- $('body').html(obj.error_text);
- }
- },
- sockWrite: function(obj) {
- document.connector.writeJs(obj);
- },
- post: function(params, onSuccess, onErrors, onComplete) {
- if(typeof params.section == 'undefined')
- params.section = this.section;
- var addr = "/ajax.php";
- $.post(addr, params,
- function(data) {
- if(data.error_code != '0') {
- NSerrorHandler(data.error_code, data.error, data.error_message);
- }
- else {
- if(data.numErrors == '0') {
- if(typeof onSuccess == 'function') {
- onSuccess(data);
- }
- }
- else {
- if(typeof onErrors == 'function') {
- onErrors(data);
- }
- else {
- NSerror('Обнаружены ошибки', NSe(data));
- }
- }
- }
- if(typeof onComplete == 'function') {
- onComplete();
- }
- }, 'JSON');
- },
- e: function(data) {
- var str = "<ul>";
- $.each(data.errors, function(i, error) {
- str += "<li>"+error.text+"</li>";
- });
- str += "</ul>";
- return str;
- },
- ok: function(header, body, top, right) {
- numNSalerts++;
- if(typeof top != 'string') top='40px';
- if(typeof right != 'string') right='10px';
- var str = '<div id="ns_alert_'+numNSalerts+'" class="ns_show_events" style="z-index:11111;display:none; -moz-border-radius:5px; -webkit-border-radius:5px;border-radius:5px;padding:10px;border:1px solid #ffffff;width:300px;top:'+top+';right:'+right+';position:fixed;background:#86e3bd;color:#ffffff;"><b>'+header+'</b><br />'+body+'</div>';
- $('body').append(str);
- $('#ns_alert_'+numNSalerts).fadeIn(800);
- $('#ns_alert_'+numNSalerts).oneTime('3s', function() {
- $(this).fadeOut(800);
- $(this).oneTime('1s', function() {
- $(this).remove();
- });
- });
- },
- mousePageXY: function(e) {
- if (!e) e = window.event;
- if (e.pageX || e.pageY) {
- NS.mouse_x = e.pageX;
- NS.mouse_y = e.pageY;
- }
- else if (e.clientX || e.clientY) {
- NS.mouse_x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
- NS.mouse_y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
- }
- },
- window: function(id, obj) {
- var _this = this;
- this.id = id;
- this.dom = $('#' + id);
- var css = {};
- var def_obj = {
- width: 242,
- close: true
- };
- if(typeof obj == 'undefined') {
- obj = def_obj;
- }
- if(typeof obj.width == 'undefined') {
- obj.width = def_obj.width;
- }
- if(typeof obj.top != 'undefined') {
- css.top = obj.top + 'px';
- }
- if(typeof obj.left != 'undefined') {
- css.left = obj.left + 'px';
- }
- else if(typeof obj.right != 'undefined') {
- css.right = obj.right + 'px';
- }
- else {
- css.left = (NS.width - obj.width) / 2;
- css.left = css.left + 'px';
- }
- css.width = obj.width + 'px';
- $(this.dom).css(css);
- this.open = function(speed) {
- var cl = '';
- obj.speed = speed;
- if(obj.close == true) {
- cl = ' ns_closing';
- }
- NS.z_index++;
- $('body').append('<div id="ns_layer_for_' + this.id + '" class="ns_layer' + cl + '" style="z-index: ' + NS.z_index + ';"></div>');
- NS.z_index++;
- $(this.dom).css('z-index', NS.z_index);
- $(this.dom).show(speed);
- $(this.dom).find('.ns_close_btn').click(function() {
- _this.close();
- });
- $(this.dom).find('.ns_close').click(function() {
- _this.close();
- });
- if(obj.close == true) {
- $('#ns_layer_for_' + this.id).click(function() {
- _this.close();
- });
- }
- }
- this.close = function() {
- $('#ns_layer_for_' + this.id).remove();
- $(this.dom).hide(obj.speed);
- }
- },
- };
- jQuery.preloadImages = function () {
- var images = (typeof arguments[0] == 'object') ? arguments[0] : arguments;
- for (var i = 0; i < images.length; i++) {
- jQuery("<img>").attr("src", images[i]);
- }
- }
- /*jQuery.fn.ajaxed = function(params, onSuccess, onError) {
- NS.num_ajaxed++;
- var obj = $(this);
- var wid = 'ns_ajaxed_'+NS.num_ajaxed;
- var offset = $(this).offset();
- var w = parseInt($(this).css('padding-left'));
- w = w+parseInt($(this).css('padding-right'))+parseInt($(this).width());
- var h = parseInt($(this).css('padding-top'));
- h = h+parseInt($(this).css('padding-bottom'))+parseInt($(this).height());
- var str = '<div class="ns_back" id="'+wid+'" style="display:none;width:'+w+'px;height:'+h+'px;top:'+offset.top+'px;left:'+offset.left+'px;"></div>';
- $('body').append(str);
- $('#'+wid).show();
- NS.post(params, onSuccess, onError, function() {
- $('#'+wid).remove();
- });
- };
- var NS_width = 810;
- var NS_height = 920;
- var NS_z_index = 100;
- var MOUSE_X = 0;
- var MOUSE_Y = 0;
- var numNSalerts = 0;
- var numNSajaxed = 0;
- function initConnector() {
- var flashvars = {ID: ID, KEY: KEY};
- //alert(START_QUERY.action);
- swfobject.embedSWF("/includes/swf/connector.swf", "connector", "1", "1", "10.2.0", "/includes/js/swf/expressInstall.swf", flashvars);
- }
- function nsread(obj) {
- //alert('from_flash: '+obj.module+' '+obj.action);
- if(obj.module=='system') {
- system_handler(obj);
- }
- else if(obj.module=='sup') {
- sup_handler(obj);
- }
- else if(obj.module=='error') {
- error_handler(obj);
- }
- }
- function system_handler(obj) {
- if(obj.action == 'init') {
- //alert('initialize');
- $('#preloader').hide();
- $('#menu').show();
- nswrite(START_QUERY);
- //$('#debug').append('<div><b>end_send:</b>');
- }
- }
- function error_handler(obj) {
- if(obj.action == 'full') {
- $('body').html(obj.error_text);
- }
- }
- function nswrite(obj) {
- //alert('nswrite initialize');
- //alert(obj.module);
- document.connector.writeJs(obj);
- }
- function initAjax() {
- //$("#"+loadingDivId).hide();
- $.ajaxSetup({
- cashe: false,
- timeout: 30000,
- type: "POST",
- beforeSend: function() {
- //$("#loading").show("slow");
- },
- complete: function() {
- //$("#loading").hide("slow");
- },
- error: function(xhr, status) {
- //NSerrorHandler(0, 'Сервер не отвечает', 'Ваш запрос не был обработан сервером, или был обработан неправильно. Пожалуйста, обновите страницу и попробуйте еще раз.');
- }
- });
- initModule();
- }
- function NSget(params, onSuccess, onErrors, onComplete) {
- var addr = "/ajax.php?section="+section;
- $.post(addr, params,
- function(data) {
- if(data.error_code!='0') {
- NSerrorHandler(data.error_code, data.error, data.error_message);
- }
- else {
- if(data.numErrors == '0') {
- if(typeof onSuccess == 'function') {
- onSuccess(data);
- }
- }
- else {
- if(typeof onErrors == 'function') {
- onErrors(data);
- }
- else {
- NSerror('Обнаружены ошибки', NSe(data));
- }
- }
- }
- if(typeof onComplete == 'function') {
- onComplete();
- }
- }, 'JSON');
- }
- function NSe(data) {
- var str = "<ul>";
- $.each(data.errors, function(i, error) {
- str += "<li>"+error.text+"</li>";
- });
- str += "</ul>";
- return str;
- }
- function NSerror(header, body, top, right) {
- numNSalerts++;
- if(typeof top != 'string') top='470px';
- if(typeof right != 'string') right='270px';
- var str = '<div id="ns_alert_'+numNSalerts+'" class="ns_show_events" style="z-index:11111;display:none; -moz-border-radius:5px; -webkit-border-radius:5px;border-radius:5px;padding:10px;border:1px solid #ffffff;width:300px;top:'+top+';right:'+right+';position:fixed;background:#fb8e8f;color:#ffffff;"><b>'+header+'</b><br />'+body+'</div>';
- $('body').append(str);
- $('#ns_alert_'+numNSalerts).fadeIn(800);
- $('#ns_alert_'+numNSalerts).oneTime('3s', function() {
- $(this).fadeOut(800);
- $(this).oneTime('1s', function() {
- $(this).remove();
- });
- });
- }
- function NSok(header, body, top, right) {
- numNSalerts++;
- if(typeof top != 'string') top='40px';
- if(typeof right != 'string') right='10px';
- var str = '<div id="ns_alert_'+numNSalerts+'" class="ns_show_events" style="z-index:11111;display:none; -moz-border-radius:5px; -webkit-border-radius:5px;border-radius:5px;padding:10px;border:1px solid #ffffff;width:300px;top:'+top+';right:'+right+';position:fixed;background:#86e3bd;color:#ffffff;"><b>'+header+'</b><br />'+body+'</div>';
- $('body').append(str);
- $('#ns_alert_'+numNSalerts).fadeIn(800);
- $('#ns_alert_'+numNSalerts).oneTime('3s', function() {
- $(this).fadeOut(800);
- $(this).oneTime('1s', function() {
- $(this).remove();
- });
- });
- }
- function NShelper(body, isclose) {
- //if(USER_ID==8561360) ENABLE_HELPER = 1;
- if(ENABLE_HELPER==1) {
- numNSalerts++;
- if(typeof isclose!= 'string') isclose='yes';
- $('.ns_helper').remove();
- var str2 = '<span style="font-style:italic;">(Клик мышки по окну подсказки закроет ее)</span><br><br><span style="cursor:pointer;font-weight:bold;" onclick="setHelper(0);return false;">Больше не показывать помощь</span>';
- var str = '<div id="ns_alert_'+numNSalerts+'" class="ns_helper" style="cursor:pointer;" onclick="$(this).fadeOut(800);return false;"><div style="width:54px;height:66px;float:left;"><img src="/images/helper.png" /></div><div style="padding-left:10px;width:230px;float:left;">'+body+'<br><br>'+str2+'</div></div>';
- $('body').append(str);
- $('#ns_alert_'+numNSalerts).fadeIn(800);
- if(isclose=='yes') {
- $('#ns_alert_'+numNSalerts).oneTime('15s', function() {
- $(this).fadeOut(800);
- $(this).oneTime('1s', function() {
- $(this).remove();
- });
- });
- }
- }
- }
- function NSerrorHandler(error_code, error, error_message) {
- NSerror('Ошибка '+error_code+': '+error, error_message);
- if(error_code==100 || error_code==202) {
- window.location.reload();
- }
- if(error_code==201) {
- NS_alert_error('Ошибка '+error_code+': '+error, error_message);
- }
- }
- function NSremove(win) {
- $('#'+win).fadeOut(400);
- $('#'+win).oneTime('1s', function() {
- $('#'+win).remove();
- });
- }
- function NS_window(title, width, height, content, window_id, is_closeble, onclose) {
- if(NS_z_index>5000) {
- NS_z_index = 100;
- }
- NS_z_index++;
- var x = (NS_width - width) / 2;
- var y = (NS_height - height) / 2;
- height = height - 20;
- width = width - 20;
- var f_w = NS_width - x;
- var r_c = x + 5;
- var win_id = window_id+'_'+NS_z_index;
- y = 100;
- var str = '<div id="'+win_id+'" class="interface_window" style="width:'+f_w+'px;padding-left:'+x+'px;padding-top:'+y+'px;z-index:'+NS_z_index+';"><div id="'+window_id+'_content" class="interface_window_content" style="width:'+width+'px;height:'+height+'px;">';
- if (is_closeble == true) {
- str +='<div class="interface_window_close_btn" style="right:'+x+'px;top:'+y+'px;width:32px;height:32px;"><span style="cursor:pointer;" onclick="$(\'#'+win_id+'\').remove();"><img id="nsclbtn" src="/sysimages/close.png" /></span></div>';
- }
- str += '<h2>'+title+'</h2><div style="';
- if(window_id=='helpwindow') {
- str += 'overflow-y:scroll;height:680px;padding-left:15px;';
- }
- str +='">'+content+'</div></div></div>';
- $('body').append(str);
- $('#'+win_id).show();
- if(typeof onclose == 'function') {
- $('#nsclbtn').click(function() {
- onclose();
- });
- }
- return win_id;
- }
- function NS_window_p(title, width, height, content, window_id, is_closeble, ptop) {
- if(NS_z_index>5000) {
- NS_z_index = 100;
- }
- NS_z_index++;
- var x = (NS_width - width) / 2;
- var y = (NS_height - height) / 2;
- height = height - 20;
- width = width - 20;
- var f_w = NS_width - x;
- var r_c = x + 5;
- var win_id = window_id+'_'+NS_z_index;
- y = ptop;
- var str = '<div id="'+win_id+'" class="interface_window" style="width:'+f_w+'px;padding-left:'+x+'px;padding-top:'+y+'px;z-index:'+NS_z_index+';"><div id="'+window_id+'_content" class="interface_window_content" style="width:'+width+'px;height:'+height+'px;">';
- if (is_closeble == true) {
- str +='<div class="interface_window_close_btn" style="right:'+x+'px;top:'+y+'px;width:32px;height:32px;"><span style="cursor:pointer;" onclick="$(\'#'+win_id+'\').remove();"><img id="nsclbtn" src="/sysimages/close.png" /></span></div>';
- }
- str += '<h2>'+title+'</h2><div style="';
- if(window_id=='helpwindow') {
- str += 'overflow-y:scroll;height:680px;padding-left:15px;';
- }
- str +='">'+content+'</div></div></div>';
- $('body').append(str);
- $('#'+win_id).show();
- if(typeof onclose == 'function') {
- $('#nsclbtn').click(function() {
- onclose();
- });
- }
- return win_id;
- }
- function NS_alert_error(title, content) {
- NS_window(title, 350, 250, '<div align="center"><img src="/sysimages/error.png"><br />'+content+'</div>', 'error'+NS_z_index, true);
- }
- function NS_alert_ok(title, content) {
- NS_window(title, 300, 200, '<div align="center"><img src="/sysimages/ok.png"><br />'+content+'</div>', 'ok'+NS_z_index, true);
- }
- function mousePageXY(e)
- {
- if (!e) e = window.event;
- if (e.pageX || e.pageY)
- {
- MOUSE_X = e.pageX;
- MOUSE_Y = e.pageY;
- }
- else if (e.clientX || e.clientY)
- {
- MOUSE_X = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
- MOUSE_Y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
- }
- }
- */
Add Comment
Please, Sign In to add comment