Guest User

Untitled

a guest
Sep 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.16 KB | None | 0 0
  1. /* 20.08.2012 */
  2. var NS = {
  3. width: 0,
  4. height: 0,
  5. z_index: 100,
  6. mouse_x: 0,
  7. mouse_y: 0,
  8. num_alerts: 0,
  9. num_ajaxed: 0,
  10. section: '',
  11.  
  12. start_query: {},
  13. ID: 0,
  14. KEY: '',
  15.  
  16. initAjax: function() {
  17. $.ajaxSetup({
  18. cashe: false,
  19. timeout: 30000,
  20. type: "POST",
  21. beforeSend: function() {
  22.  
  23. },
  24. complete: function() {
  25.  
  26. },
  27. error: function(xhr, status) {
  28.  
  29. }
  30. });
  31. this.initNS();
  32. },
  33.  
  34. initConnector: function() {
  35. var flashvars = {ID: ID, KEY: KEY};
  36. swfobject.embedSWF("/includes/swf/connector.swf", "connector", "1", "1", "10.2.0", "/includes/js/swf/expressInstall.swf", flashvars);
  37. this.initNS();
  38. },
  39.  
  40. initNS: function() {
  41. document.onmousemove = this.mousePageXY;
  42. this.width = $('body').width();
  43. this.height = $('body').height();
  44. this.initModule();
  45. },
  46.  
  47. initModule: function() {},
  48.  
  49. sockRead: function(obj) {
  50. if(obj.module=='system') {
  51. this.sockHandler(obj);
  52. }
  53. else if(obj.module=='error') {
  54. this.sockError(obj);
  55. }
  56. },
  57.  
  58. sockHandler: function(obj) {
  59. if(obj.action == 'init') {
  60. $('#preloader').hide();
  61. $('#menu').show();
  62. this.sockWrite(START_QUERY);
  63. }
  64. },
  65.  
  66. sockError: function(obj) {
  67. if(obj.action == 'full') {
  68. $('body').html(obj.error_text);
  69. }
  70. },
  71.  
  72. sockWrite: function(obj) {
  73. document.connector.writeJs(obj);
  74. },
  75.  
  76. post: function(params, onSuccess, onErrors, onComplete) {
  77. if(typeof params.section == 'undefined')
  78. params.section = this.section;
  79.  
  80. var addr = "/ajax.php";
  81. $.post(addr, params,
  82. function(data) {
  83. if(data.error_code != '0') {
  84. NSerrorHandler(data.error_code, data.error, data.error_message);
  85. }
  86. else {
  87. if(data.numErrors == '0') {
  88. if(typeof onSuccess == 'function') {
  89. onSuccess(data);
  90. }
  91. }
  92. else {
  93. if(typeof onErrors == 'function') {
  94. onErrors(data);
  95. }
  96. else {
  97. NSerror('Обнаружены ошибки', NSe(data));
  98. }
  99. }
  100. }
  101. if(typeof onComplete == 'function') {
  102. onComplete();
  103. }
  104. }, 'JSON');
  105.  
  106. },
  107.  
  108. e: function(data) {
  109. var str = "<ul>";
  110. $.each(data.errors, function(i, error) {
  111. str += "<li>"+error.text+"</li>";
  112. });
  113. str += "</ul>";
  114. return str;
  115. },
  116.  
  117. ok: function(header, body, top, right) {
  118. numNSalerts++;
  119. if(typeof top != 'string') top='40px';
  120. if(typeof right != 'string') right='10px';
  121. 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>';
  122. $('body').append(str);
  123. $('#ns_alert_'+numNSalerts).fadeIn(800);
  124. $('#ns_alert_'+numNSalerts).oneTime('3s', function() {
  125. $(this).fadeOut(800);
  126. $(this).oneTime('1s', function() {
  127. $(this).remove();
  128. });
  129. });
  130. },
  131.  
  132. mousePageXY: function(e) {
  133. if (!e) e = window.event;
  134. if (e.pageX || e.pageY) {
  135. NS.mouse_x = e.pageX;
  136. NS.mouse_y = e.pageY;
  137. }
  138. else if (e.clientX || e.clientY) {
  139. NS.mouse_x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
  140. NS.mouse_y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
  141. }
  142. },
  143.  
  144. window: function(id, obj) {
  145. var _this = this;
  146. this.id = id;
  147. this.dom = $('#' + id);
  148.  
  149. var css = {};
  150. var def_obj = {
  151. width: 242,
  152. close: true
  153. };
  154.  
  155. if(typeof obj == 'undefined') {
  156. obj = def_obj;
  157. }
  158. if(typeof obj.width == 'undefined') {
  159. obj.width = def_obj.width;
  160. }
  161. if(typeof obj.top != 'undefined') {
  162. css.top = obj.top + 'px';
  163. }
  164. if(typeof obj.left != 'undefined') {
  165. css.left = obj.left + 'px';
  166. }
  167. else if(typeof obj.right != 'undefined') {
  168. css.right = obj.right + 'px';
  169. }
  170. else {
  171. css.left = (NS.width - obj.width) / 2;
  172. css.left = css.left + 'px';
  173. }
  174. css.width = obj.width + 'px';
  175.  
  176. $(this.dom).css(css);
  177.  
  178. this.open = function(speed) {
  179. var cl = '';
  180. obj.speed = speed;
  181. if(obj.close == true) {
  182. cl = ' ns_closing';
  183. }
  184. NS.z_index++;
  185. $('body').append('<div id="ns_layer_for_' + this.id + '" class="ns_layer' + cl + '" style="z-index: ' + NS.z_index + ';"></div>');
  186. NS.z_index++;
  187. $(this.dom).css('z-index', NS.z_index);
  188. $(this.dom).show(speed);
  189. $(this.dom).find('.ns_close_btn').click(function() {
  190. _this.close();
  191. });
  192. $(this.dom).find('.ns_close').click(function() {
  193. _this.close();
  194. });
  195. if(obj.close == true) {
  196. $('#ns_layer_for_' + this.id).click(function() {
  197. _this.close();
  198. });
  199. }
  200. }
  201. this.close = function() {
  202. $('#ns_layer_for_' + this.id).remove();
  203. $(this.dom).hide(obj.speed);
  204. }
  205. },
  206.  
  207.  
  208. };
  209.  
  210. jQuery.preloadImages = function () {
  211. var images = (typeof arguments[0] == 'object') ? arguments[0] : arguments;
  212. for (var i = 0; i < images.length; i++) {
  213. jQuery("<img>").attr("src", images[i]);
  214. }
  215. }
  216.  
  217. /*jQuery.fn.ajaxed = function(params, onSuccess, onError) {
  218. NS.num_ajaxed++;
  219. var obj = $(this);
  220. var wid = 'ns_ajaxed_'+NS.num_ajaxed;
  221. var offset = $(this).offset();
  222. var w = parseInt($(this).css('padding-left'));
  223. w = w+parseInt($(this).css('padding-right'))+parseInt($(this).width());
  224. var h = parseInt($(this).css('padding-top'));
  225. h = h+parseInt($(this).css('padding-bottom'))+parseInt($(this).height());
  226. 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>';
  227. $('body').append(str);
  228. $('#'+wid).show();
  229. NS.post(params, onSuccess, onError, function() {
  230. $('#'+wid).remove();
  231. });
  232.  
  233. };
  234.  
  235. var NS_width = 810;
  236. var NS_height = 920;
  237. var NS_z_index = 100;
  238. var MOUSE_X = 0;
  239. var MOUSE_Y = 0;
  240. var numNSalerts = 0;
  241. var numNSajaxed = 0;
  242.  
  243. function initConnector() {
  244. var flashvars = {ID: ID, KEY: KEY};
  245. //alert(START_QUERY.action);
  246. swfobject.embedSWF("/includes/swf/connector.swf", "connector", "1", "1", "10.2.0", "/includes/js/swf/expressInstall.swf", flashvars);
  247. }
  248.  
  249. function nsread(obj) {
  250. //alert('from_flash: '+obj.module+' '+obj.action);
  251. if(obj.module=='system') {
  252. system_handler(obj);
  253. }
  254. else if(obj.module=='sup') {
  255. sup_handler(obj);
  256. }
  257. else if(obj.module=='error') {
  258. error_handler(obj);
  259. }
  260. }
  261.  
  262. function system_handler(obj) {
  263. if(obj.action == 'init') {
  264. //alert('initialize');
  265. $('#preloader').hide();
  266. $('#menu').show();
  267. nswrite(START_QUERY);
  268. //$('#debug').append('<div><b>end_send:</b>');
  269. }
  270. }
  271.  
  272. function error_handler(obj) {
  273. if(obj.action == 'full') {
  274. $('body').html(obj.error_text);
  275. }
  276. }
  277.  
  278.  
  279. function nswrite(obj) {
  280. //alert('nswrite initialize');
  281. //alert(obj.module);
  282. document.connector.writeJs(obj);
  283. }
  284.  
  285.  
  286. function initAjax() {
  287. //$("#"+loadingDivId).hide();
  288. $.ajaxSetup({
  289. cashe: false,
  290. timeout: 30000,
  291. type: "POST",
  292. beforeSend: function() {
  293. //$("#loading").show("slow");
  294. },
  295. complete: function() {
  296. //$("#loading").hide("slow");
  297. },
  298. error: function(xhr, status) {
  299. //NSerrorHandler(0, 'Сервер не отвечает', 'Ваш запрос не был обработан сервером, или был обработан неправильно. Пожалуйста, обновите страницу и попробуйте еще раз.');
  300. }
  301. });
  302.  
  303. initModule();
  304. }
  305.  
  306. function NSget(params, onSuccess, onErrors, onComplete) {
  307. var addr = "/ajax.php?section="+section;
  308. $.post(addr, params,
  309. function(data) {
  310. if(data.error_code!='0') {
  311. NSerrorHandler(data.error_code, data.error, data.error_message);
  312. }
  313. else {
  314. if(data.numErrors == '0') {
  315. if(typeof onSuccess == 'function') {
  316. onSuccess(data);
  317. }
  318. }
  319. else {
  320. if(typeof onErrors == 'function') {
  321. onErrors(data);
  322. }
  323. else {
  324. NSerror('Обнаружены ошибки', NSe(data));
  325. }
  326. }
  327. }
  328. if(typeof onComplete == 'function') {
  329. onComplete();
  330. }
  331. }, 'JSON');
  332.  
  333. }
  334.  
  335. function NSe(data) {
  336. var str = "<ul>";
  337. $.each(data.errors, function(i, error) {
  338. str += "<li>"+error.text+"</li>";
  339. });
  340. str += "</ul>";
  341. return str;
  342. }
  343.  
  344. function NSerror(header, body, top, right) {
  345. numNSalerts++;
  346. if(typeof top != 'string') top='470px';
  347. if(typeof right != 'string') right='270px';
  348. 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>';
  349. $('body').append(str);
  350. $('#ns_alert_'+numNSalerts).fadeIn(800);
  351. $('#ns_alert_'+numNSalerts).oneTime('3s', function() {
  352. $(this).fadeOut(800);
  353. $(this).oneTime('1s', function() {
  354. $(this).remove();
  355. });
  356. });
  357. }
  358.  
  359. function NSok(header, body, top, right) {
  360. numNSalerts++;
  361. if(typeof top != 'string') top='40px';
  362. if(typeof right != 'string') right='10px';
  363. 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>';
  364. $('body').append(str);
  365. $('#ns_alert_'+numNSalerts).fadeIn(800);
  366. $('#ns_alert_'+numNSalerts).oneTime('3s', function() {
  367. $(this).fadeOut(800);
  368. $(this).oneTime('1s', function() {
  369. $(this).remove();
  370. });
  371. });
  372. }
  373.  
  374. function NShelper(body, isclose) {
  375. //if(USER_ID==8561360) ENABLE_HELPER = 1;
  376. if(ENABLE_HELPER==1) {
  377. numNSalerts++;
  378. if(typeof isclose!= 'string') isclose='yes';
  379. $('.ns_helper').remove();
  380. var str2 = '<span style="font-style:italic;">(Клик мышки по окну подсказки закроет ее)</span><br><br><span style="cursor:pointer;font-weight:bold;" onclick="setHelper(0);return false;">Больше не показывать помощь</span>';
  381.  
  382. 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>';
  383. $('body').append(str);
  384. $('#ns_alert_'+numNSalerts).fadeIn(800);
  385.  
  386. if(isclose=='yes') {
  387. $('#ns_alert_'+numNSalerts).oneTime('15s', function() {
  388. $(this).fadeOut(800);
  389. $(this).oneTime('1s', function() {
  390. $(this).remove();
  391. });
  392. });
  393. }
  394. }
  395.  
  396. }
  397.  
  398. function NSerrorHandler(error_code, error, error_message) {
  399. NSerror('Ошибка '+error_code+': '+error, error_message);
  400. if(error_code==100 || error_code==202) {
  401. window.location.reload();
  402. }
  403. if(error_code==201) {
  404. NS_alert_error('Ошибка '+error_code+': '+error, error_message);
  405. }
  406. }
  407.  
  408. function NSremove(win) {
  409. $('#'+win).fadeOut(400);
  410. $('#'+win).oneTime('1s', function() {
  411. $('#'+win).remove();
  412. });
  413. }
  414.  
  415. function NS_window(title, width, height, content, window_id, is_closeble, onclose) {
  416. if(NS_z_index>5000) {
  417. NS_z_index = 100;
  418. }
  419. NS_z_index++;
  420.  
  421. var x = (NS_width - width) / 2;
  422. var y = (NS_height - height) / 2;
  423. height = height - 20;
  424. width = width - 20;
  425. var f_w = NS_width - x;
  426. var r_c = x + 5;
  427. var win_id = window_id+'_'+NS_z_index;
  428. y = 100;
  429. 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;">';
  430. if (is_closeble == true) {
  431. 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>';
  432. }
  433. str += '<h2>'+title+'</h2><div style="';
  434. if(window_id=='helpwindow') {
  435. str += 'overflow-y:scroll;height:680px;padding-left:15px;';
  436. }
  437. str +='">'+content+'</div></div></div>';
  438. $('body').append(str);
  439. $('#'+win_id).show();
  440. if(typeof onclose == 'function') {
  441. $('#nsclbtn').click(function() {
  442. onclose();
  443. });
  444. }
  445. return win_id;
  446. }
  447.  
  448. function NS_window_p(title, width, height, content, window_id, is_closeble, ptop) {
  449. if(NS_z_index>5000) {
  450. NS_z_index = 100;
  451. }
  452. NS_z_index++;
  453.  
  454. var x = (NS_width - width) / 2;
  455. var y = (NS_height - height) / 2;
  456. height = height - 20;
  457. width = width - 20;
  458. var f_w = NS_width - x;
  459. var r_c = x + 5;
  460. var win_id = window_id+'_'+NS_z_index;
  461. y = ptop;
  462. 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;">';
  463. if (is_closeble == true) {
  464. 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>';
  465. }
  466. str += '<h2>'+title+'</h2><div style="';
  467. if(window_id=='helpwindow') {
  468. str += 'overflow-y:scroll;height:680px;padding-left:15px;';
  469. }
  470. str +='">'+content+'</div></div></div>';
  471. $('body').append(str);
  472. $('#'+win_id).show();
  473. if(typeof onclose == 'function') {
  474. $('#nsclbtn').click(function() {
  475. onclose();
  476. });
  477. }
  478. return win_id;
  479. }
  480.  
  481. function NS_alert_error(title, content) {
  482. NS_window(title, 350, 250, '<div align="center"><img src="/sysimages/error.png"><br />'+content+'</div>', 'error'+NS_z_index, true);
  483. }
  484.  
  485. function NS_alert_ok(title, content) {
  486. NS_window(title, 300, 200, '<div align="center"><img src="/sysimages/ok.png"><br />'+content+'</div>', 'ok'+NS_z_index, true);
  487. }
  488.  
  489. function mousePageXY(e)
  490. {
  491. if (!e) e = window.event;
  492.  
  493. if (e.pageX || e.pageY)
  494. {
  495. MOUSE_X = e.pageX;
  496. MOUSE_Y = e.pageY;
  497. }
  498. else if (e.clientX || e.clientY)
  499. {
  500. MOUSE_X = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
  501. MOUSE_Y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
  502. }
  503.  
  504. }
  505. */
Add Comment
Please, Sign In to add comment