1 2Notification.requestPermission(function (status) { 3 console.log('Notification permission status:', status); 4}); 5 6function displayNotification(msg, options) { 7 if (Notification.permission == 'granted') { 8 navigator.serviceWorker.getRegistration().then(function (reg) { 9 reg.showNotification(msg, options); 10 //update table clickedpushes 11 }); 12 } 13} 14 15//displayNotification('ÐобилÑÐ½Ð°Ñ ÐкадемиÑ',{body:'ÐаполниÑе даннÑе',data: {'link':'/ffffffffffff'}}); 16//displayNotification('alert',{data: {'link':'/me/data'}}); 17 18$.fn.modal.Constructor.prototype.enforceFocus = function () { 19 modal_this = this 20 $(document).on('focusin.modal', function (e) { 21 if (modal_this.$element[0] !== e.target && !modal_this.$element.has(e.target).length 22 && !$(e.target.parentNode).hasClass('cke_dialog_ui_input_select') 23 && !$(e.target.parentNode).hasClass('cke_dialog_ui_input_text')) { 24 modal_this.$element.focus() 25 } 26 }) 27}; 28var switcher = 0; 29var tID = null; // иденÑиÑикаÑÐ¾Ñ ÑаймаÑÑа 30var intervals = []; //инÑеÑÐ²Ð°Ð»Ñ 31String.prototype.in_array = function (arr) { 32 for (var i = 0, l = arr.length; i < l; i++) { 33 if (arr[i] == this) { return true; } 34 } 35 return false; 36} 37Array.prototype.remove = function (value) { 38 var idx = this.indexOf(value); 39 if (idx != -1) { return this.splice(idx, 1); } 40 return false; 41} 42 43function isPWA() { 44 return window.matchMedia('(display-mode: standalone)').matches; 45} 46 47// полÑÑиÑÑ Ð·Ð½Ð°Ñение cookie по имени 48function getCookie(name) { 49 var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)')); 50 if (match) return match[2]; 51} 52 53//полÑÑиÑÑ Ð·Ð½Ð°Ñение ÑлеменÑа 54function getElemValue(elem) { 55 console.log(elem.tagName); 56 switch (elem.tagName) { 57 case "TEXTAREA": 58 return $(elem).text().trim(); 59 default: 60 return "1"; 61 } 62 63} 64 65//пеÑÐ²Ð°Ñ Ð±Ñква заглавнаÑ, (оÑÑалÑнÑе Ð½ÐµÑ DEL) 66function cap(input) { 67 //return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase(); 68 return input.charAt(0).toUpperCase() + input.slice(1); 69} 70 71 72//еÑÑÑ Ð¿ÑокÑÑÑка впÑаво 73function hasScroll() { 74 //alert($(".infoblock").width() + " " + $(".infoblock").prop('scrollWidth')); 75 return $(".infoblock").width() + 100 < $(".infoblock").prop('scrollWidth'); 76 //alert($("body").width() + " " + $(window).width()); 77 //return $("body").width() > $(window).width(); 78} 79 80function isINNValid($inn) { 81 $summ = 0; 82 $N = 1; 83 $crc = { 1: null, 2: null }; 84 85 //базовÑе множиÑели 86 var $base = { 87 10: { 1: [2, 4, 10, 3, 5, 9, 4, 6, 8] }, 88 12: { 2: [7, 2, 4, 10, 3, 5, 9, 4, 6, 8], 1: [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8] }, 89 } 90 91 $length = $inn.length; 92 93 //колиÑеÑÑво ÑиÑÑ ÐºÐ¾Ð½ÑÑолÑной ÑÑÐ¼Ð¼Ñ 94 switch ($length) { 95 case 10: 96 $N = 1; 97 break; 98 case 12: 99 $N = 2; 100 break; 101 default: 102 return false; 103 } 104 105 //вÑÑиÑление конÑÑолÑной ÑÑÐ¼Ð¼Ñ 106 for ($k = 1; $k <= $N; $k++) { 107 108 $summ = 0; 109 for ($i = 0; $i < $length - $k; $i++) { 110 if (isNaN($inn.charAt($i))) return false; 111 112 $summ += $inn.charAt($i) * $base[$length][$k][$i]; 113 } 114 $crc[$k] = ($summ % 11) % 10; 115 116 } 117 118 return $inn[$length - 1] == $crc[1] && ($crc[2] == null || $inn[$length - 2] == $crc[2]); 119} 120 121//ÑвлÑеÑÑÑ Ð»Ð¸ даÑа валидной 122function isDateValid($date, $format = 'DD.MM.YYYY') { 123 return moment($date, $format, true).isValid(); 124} 125 126//ÑвлÑеÑÑÑ Ð»Ð¸ возÑаÑÑ Ð²Ð°Ð»Ð¸Ð´Ð½Ñм 127function isAgeValid($date, $format = 'DD.MM.YYYY') { 128 var birth = moment($date, $format); //даÑа ÑÐ¾Ð¶Ð´ÐµÐ½Ð¸Ñ 129 var now = moment(moment().format($format), $format); //ÑекÑÑÐ°Ñ Ð´Ð°Ñа 130 131 var age = moment.duration(now.diff(birth)).asYears(); 132 return age >= 18 && age <= 80; 133} 134 135//инÑеÑÐ²Ð°Ð»Ñ 136function class_intervals() { 137 try { 138 intervals.push(setInterval(function () { infowidgets(".zchat", false); }, 60000)); //ÑÐ°Ñ 139 intervals.push(setInterval(function () { prompt(); }, 30000)); //ÑÑаÑÑÑ 140 intervals.push(setInterval(function () { 141 if ($(".interval").length) ajax_asynq($(".interval").attr("link"), null, 142 function (json) { try { if (JSON.parse["result"] == "OK") location.href = $(".interval").attr("redirect"); } catch { } } 143 ); 144 }, 145 $(".interval").attr("interval") * 1000)); //ÑÑаÑÑÑ 146 } 147 catch (e) { } 148} 149 150//кÑаÑивое оÑоÑмление 151function class_nice() { 152 153 154 $(".more0").each(function () { 155 ($(this).parent().offsetHeight < $(this).parent().scrollHeight || 156 $(this).parent().offsetWidth < $(this).parent().scrollWidth) 157 $(this).show(); 158 159 }); 160 161 162 $("table, img").each(function () { 163 if ($(this).width() > $("body").width()) { 164 //return; 165 $(this).width($("body").width() - 70); 166 $(this).css("height", "auto"); 167 168 $(this).find("img").each( 169 function () { 170 $(this).width(Math.floor($(this).width() / 3)); 171 $(this).css("height", "auto"); 172 } 173 ); 174 175 $(this).find("td").each( 176 function () { 177 //$(this).find("ol").contents().unwrap(); 178 $(this).width(Math.floor($(this).width() / 3)); 179 $(this).css("height", "auto"); 180 $(this).css("word-break", "break-all"); 181 } 182 ); 183 184 185 } 186 }); 187 188 189 190 $(".htmls >
190 option").each( 191 function () { 192 $(this).html($.parseHTML($(this).text())); 193 } 194 ) 195 196 $(".fonts > option").each( 197 function () { 198 $(this).css("font-family", $(this).val()); 199 } 200 ) 201 //вÑÐ±Ð¾Ñ ÑвеÑа 202 $('.colorpickerField').ColorPicker({ 203 onSubmit: function (hsb, hex, rgb, el) { 204 $(el).val("#" + hex); 205 $(el).ColorPickerHide(); 206 }, 207 onBeforeShow: function () { 208 209 $(this).ColorPickerSetColor(this.value); 210 }, 211 onChange: function (hsb, hex, rgb, el) { 212 var textColor; 213 $(el).css('background-color', '#' + hex); 214 if (rgb.g < 140) textColor = '#FFFFFF'; 215 else textColor = '#000000'; 216 $(el).css('color', textColor); 217 $(el).val("#" + hex); 218 } 219 }); 220 221 //авÑопÑокÑÑÑка вниз 222 $(".scrolldown").each( 223 function () { 224 $(this).scrollTop($(this).prop('scrollHeight')); 225 //$(this).animate({ scrollTop: $(this).children(":first").height() }, "fast"); 226 return false; 227 } 228 ); 229 230 //модалÑÐ½Ð°Ñ ÐºÐ°ÑÑинка 231 $('.fancybox').off().fancybox({ 232 prevEffect: 'none', 233 nextEffect: 'none', 234 235 closeBtn: true, 236 arrows: true, 237 nextClick: true, 238 239 helpers: { 240 thumbs: { 241 width: 50, 242 height: 50 243 } 244 } 245 }); 246 247 $('.nicescroll').off().niceScroll({ mousescrollstep: 20, scrollspeed: 200, smoothscroll: false }); 248 249 var dateformat = $('.calendar,.datepicker').attr("dateformat"); 250 $('.calendar,.datepicker').not(".blocked").not(".hasdatepicker").addClass("hasdatepicker").datepicker({ 251 showButtonPanel: true, 252 dateFormat: dateformat ? dateformat : 'yy-mm-dd', 253 closeText: 'ÐакÑÑÑÑ', 254 prevText: 'ÐÑед', 255 nextText: 'След', 256 currentText: 'СегоднÑ', 257 monthNames: ['ЯнваÑÑ', 'ФевÑалÑ', 'ÐаÑÑ', 'ÐпÑелÑ', 'Ðай', 'ÐÑнÑ', 258 'ÐÑлÑ', 'ÐвгÑÑÑ', 'СенÑÑбÑÑ', 'ÐкÑÑбÑÑ', 'ÐоÑбÑÑ', 'ÐекабÑÑ'], 259 monthNamesShort: ['Янв', 'Фев', 'ÐаÑ', 'ÐпÑ', 'Ðай', 'ÐÑн', 260 'ÐÑл', 'Ðвг', 'Сен', 'ÐкÑ', 'ÐоÑ', 'Ðек'], 261 dayNames: ['воÑкÑеÑенÑе', 'понеделÑник', 'вÑоÑник', 'ÑÑеда', 'ÑеÑвеÑг', 'пÑÑниÑа', 'ÑÑббоÑа'], 262 dayNamesShort: ['вÑк', 'пнд', 'вÑÑ', 'ÑÑд', 'ÑÑв', 'пÑн', 'ÑбÑ'], 263 dayNamesMin: ['ÐÑ', 'Ðн', 'ÐÑ', 'СÑ', 'ЧÑ', 'ÐÑ', 'Сб'], 264 changeMonth: true, 265 changeYear: true, 266 showOtherMonths: true, 267 selectOtherMonths: true, 268 yearRange: "1930:2021" 269 }); 270 271 /*$('.calendar,.datepicker').inputmask( 272 { 273 mask: "99.99.9999", 274 alias: "date", 275 placeholder: "ÐÐ/ÐÐ/ÐÐÐÐ", 276 insertMode: false 277 } 278 );*/ 279 280 $('.datetimepicker').not(".hasdatetimepicker").addClass("hasdatetimepicker").datetimepicker({ 281 step: 5, format: 'Y-m-d H:i:s', lang: 'ru', withoutCopyright: true 282 }); 283 284 285 $("textarea.cketextarea").not(".hascke").addClass("hascke").each(function () { CKEDITOR.replace($(this).attr("id")) }); 286 287 $('.changes-select').not(".hasselectchangehandler").addClass("hasselectchangehandler").on("change blur", function () { 288 var obj = this; 289 var value = $(obj).val(); 290 var namefield = $(obj).attr('name'); 291 var target = $(obj).attr("target-change"); 292 var targetcontainerid = $(obj).attr("target-container"); 293 var form = $(this).closest('#imitationform'); 294 if (form.length == 0) form = $(this).closest('form'); 295 if (form.length == 0) return; 296 var targetcontainer = form.find('#' + targetcontainerid); 297 var div = $(this).closest('div.form-group'); 298 var data = {}; data = $('form[name=menuitemform]').length ? $('form[name=menuitemform]').serialize() : form.serialize(); 299 data += "from_ajax=true"; 300 //var data = {}; data = $('form[name=menuitemform]').serialize(); 301 var beforeselect = $(form).find('[this-target=' + target + ']'); 302 var events = $._data(beforeselect.get(0), "events"); 303 $.ajax({ 304 url: form.attr('action'), type: 'POST', data: data, 305 beforeSend: function () { targetcontainer.html(spinner); }, 306 success: function (html) { 307 var targetselect = $(html).find('[this-target=' + target + ']'); 308 if (typeof events !== "undefined") { 309 if (typeof events["change"] !== "undefined") { 310 events["change"].forEach(function (item, i, arr) { 311 targetselect.change(item.handler) 312 }); 313 } 314 } 315 targetcontainer.html(targetselect); 316 targetcontainer.find(targetselect).chosen({ allow_single_deselect: true }); 317 targetcontainer.find(targetselect).trigger("change"); 318 } 319 }); 320 }); 321 322 $('.changes-select.autostart').change(); 323 $('.inputregexmask').not(".hasinputregexmask").addClass("hasinputregexmask").inputmask('Regex'); 324 $('.inputmask').not(".hasinputmask").addClass("hasinputmask").inputmask(); 325 $('select.chosen').not(".haschosen").addClass("haschosen").chosen(); 326 327 autocomplete(); 328 dropZoneInit(); // dz1 329 330 $(".dz2").each(function () { dz(this) }); //dz2 331 $(".dz3").each(function () { dz3(this) }); //dz2 332 333 334} 335 336function curler($elem) { 337 var _this = $elem; 338 var $link = $(_this).attr("link"); 339 var $startmsg = $(_this).attr("startmsg"); 340 var $endmsg = $(_this).attr("endmsg"); 341 var $errormsg = $(_this).attr("errormsg") ? $(_this).attr("errormsg") : "ERR!"; 342 var $for = $($(_this).attr("for")); 343 var $result = $($(_this).attr("result")); 344 var $format = $(_this).attr("format") ? $(_this).attr("format") : "html"; 345 var $files = false;
346 //alert($format); 347 var $ser = ""; 348 349 /*$(_this).find("[required],[required=required],[required=ok]").each(function () { 350 alert('ffdf'); 351 //cancel = false; 352 $(this).removeClass("error").removeClass("ok"); 353 var value = $(this).val(); 354 //alert($(this).attr("test")); 355 if (!value) { 356 //alert("1"); 357 cancel = true; 358 $(this).addClass("error"); 359 360 $(this).parent().focus().tooltip('show'); 361 $(".modal").animate({ scrollTop: $(this).get(0).offsetTop }, 500); 362 363 } 364 else 365 $(this).addClass("ok"); 366 }); 367 if (cancel) return;*/ 368 369 console.log($for.length); 370 if ($for.hasClass("serializable")) 371 $for.each(function () { $ser += $(this).attr("name") + "=" + $(this).attr("value") + "&"; }); 372 else 373 if ($for.hasClass("formdatable")) { 374 $ser = new FormData(); 375 $ser.append($for.attr("name"), $for[0].files[0]); 376 $files = true; 377 } 378 else 379 $ser = $for.serialize() + "&"; 380 //console.log($ser); 381 //$ser = 382 //console.log($($(_this).attr("for")).serialize()); 383 //var reload = $(_this).attr("reload")=="yes"; 384 385 ajax_asynq($link, function () { 386 $(_this).attr("disabled", "disabled"); 387 if ($result.length) $result.html(spinner); 388 serversuccess($startmsg, 0) 389 }, 390 function (data) { 391 serversuccess($endmsg); 392 if ($result.length) { 393 if ($format == "html") 394 $result.html(data); 395 else { 396 //alert('json'); 397 data = JSON.parse(data); 398 $.each(data, function (key1, value1) { 399 $.each(value1, function (key2, value2) { $result.filter(`[name='json_${key1}_${key2}']`).html(value2); }); 400 }); 401 } 402 } 403 class_nice(); 404 renew(); 405 infowidgets('.zchat', false); 406 $(_this).removeAttr("disabled"); 407 }, 408 $.type($ser) === "string" ? $ser + $(_this).attr("post") : $ser, function () { servererror($errormsg); $(_this).removeAttr("disabled"); }, $files); 409} 410 411//ÑобÑÑÐ¸Ñ ÐºÐ»Ð°ÑÑов 412function class_events() { 413 414 $("body").on('show.bs.collapse', '.collapse', function () { 415 $("body").find('.collapse.in').collapse('hide'); 416 }); 417 418 419 $("body").on("click", ".more0", 420 function (e) { 421 e.preventDefault(); 422 $parent = $(this).parent(); 423 console.log($(this).attr("step")); 424 $parent.animate({ 425 scrollTop: $parent.scrollTop() + parseInt($(this).attr("step")) 426 }, 200); 427 } 428 ); 429 430 431 432 $("body").on("click", ".remover", 433 function (e) { 434 e.preventDefault(); 435 $($(this).attr("target")).remove(); 436 } 437 ); 438 439 $("body").on("submit", ".form_change", 440 function (e) { 441 e.preventDefault(); 442 curler(this); 443 } 444 ); 445 446 $("body").on("click", ".curler_click", 447 function (e) { 448 curler(this); 449 } 450 ); 451 452 $("body").on("change", ".curler_change", 453 function (e) { 454 //curler($(this)); 455 curler($(this).find("option:selected")); 456 } 457 ); 458 459 $("body").on("click", ".verify", function (e) { 460 event.preventDefault(); 461 $(".myredirect").removeClass("active"); 462 $(".myredirect.exh" + $(this).attr("exh")).addClass("active"); 463 if ($(this).attr("dataverificated") || $(this).hasClass("verified")) { 464 location.href = $(this).attr("href"); 465 } 466 else { 467 if ($(this).attr("mobile") == "true") 468 modalWin('ÐодвеÑждение даннÑÑ ', this); 469 else 470 show_modal(this, true); 471 } 472 }); 473 474 $("body").on("blur", ".numbering", function (e) { 475 $(this).removeClass("error"); 476 var min = parseInt($(this).attr("min")); 477 var max = parseInt($(this).attr("max")); 478 var val = parseInt($(this).val()); 479 if ((val - min) * (val - max) > 0 || isNaN(val)) { $(this).addClass("error"); servererror($(this).attr("errormsg")); return; }; 480 $(this).addClass("ok"); 481 }); 482 483 $("body.mobile").on("click", ".horisontal", function (e) { 484 $(".infoblock").scrollLeft($(".infoblock").scrollLeft() + $(this).attr('direction') * $(this).attr('step')); 485 }); 486 487 $("body.__mobile").on("click", "a:not('.mobile_menu')", function (e) { 488 e.preventDefault(); 489 location.href = $(this).attr("href").startsWith("http") ? "/iframe/https://xn--80aecacfeba0abackn4ckn8amixbo8g.xn--p1ai/redirect/" + $(this).attr("href") : $(this).attr("href"); 490 }); 491 492 // 493 $("body").on("click", ".mobile_menu", function (e) { 494 $(".mobile_main").html(spinner); 495 //$(".mobile_menu").css("font-weight",""); 496 //$(this).css("font-weight","bold"); 497 }); 498 499 $("body").on("input", ".validate", function (e) {
500 var valid = $(this).parent().find("span.valid"); 501 valid.text('').hide(); 502 $(this).removeClass('error').removeClass('ok'); 503 }); 504 // 505 $("body").on("click", ".fasttest", function (e) { 506 507 if ($(this).attr("correct") == 1) 508 $(this).parent().addClass("bg-green"); 509 else 510 $(this).parent().addClass("bg-red"); 511 }); 512 513 // 514 $("body").on("change", ".ajax_file", function (e) { 515 ajax_file($(this)); 516 }); 517 518 //пÑедоÑвÑаÑиÑÑ Ð¾Ð±ÑÑнÑй submit ÑоÑÐ¼Ñ 519 $("body").on("submit", "form.dontsubmit", function (e) { 520 e.preventDefault(); 521 }); 522 523 //оÑеÑÑа 524 $("body").on("submit", "form.ofertable", function (e) { 525 show_modal(this, true); 526 e.preventDefault(); 527 528 $("#user_data_REGISTRATION").removeAttr("disabled"); 529 }); 530 531 $("body").on("focus blur", "input[type=text],input[type=password],textarea", function (e) { 532 if ($(this).is(":focus")) { 533 if ($(this).hasClass("scrollto")) SCROLL_TO($(this), $(".bcontent")); 534 $(".mobile-items").hide(); 535 } else $(".mobile-items").show(); 536 }); 537 538 $("body").on("click", ".lookingglass", function (e) { 539 e.preventDefault(); 540 _this = this; 541 ajax_asynq(window.location.href + "/", function () { 542 $('.simple_search_result').html(spinner) 543 }, 544 function (html) { 545 $('.simple_search_result').html(html); 546 }, $(_this).closest("form").serialize()); 547 }); 548 549 $("body").on("keydown", "[name=user_data]", function (e) { 550 if (e.keyCode == 13) { 551 e.preventDefault(); 552 $(this).find(".enter").click(); 553 } 554 }); 555 556 $("body").on("keyup", ".waitenter", function (e) { 557 if (e.keyCode == 13) { 558 $(this).blur(); 559 $($(this).attr("submit")).click(); 560 } 561 }); 562 563 $("body").on("keydown", ".enter", function (e) { 564 if (e.keyCode == 13) { 565 console.log('enter'); 566 e.preventDefault(); 567 $(this).blur(); 568 $(this).click(); 569 } 570 }); 571 572 $("body").on("keyup", ".noenter", function (e) { 573 if (e.keyCode == 13) { 574 e.preventDefault(); 575 } 576 }); 577 578 $("body").on("click", "button.loginneeded", function () { 579 curl("/session/referer:123", "referer=" + window.location.href); 580 confirm_modal3("/login/", false, "ÐакÑÑÑÑ", function () { }); 581 }); 582 583 $("body").on("click", "button.regneeded", function () { 584 location.href = `/main/registration/${$(this).attr('participant')}?redirect=${$(this).attr('redirect')}&product_type=${$(this).attr('product_type')}&passport=${$(this).attr('passport')}`; 585 }); 586 587 $("body").on("click", "button.logneeded", function () { 588 location.href = `/me/basket/product_type=${$(this).attr('product_type')}/passport=${$(this).attr('passport')}`; 589 }); 590 591 $("body").on("click", "button.basket-button", function () { 592 var _this = this; 593 if (isNaN($(this).attr("passport"))) return; 594 ajax_asynq($(this).attr("link"), function () { 595 }, function (data) { 596 var json = JSON.parse(data); 597 if (json.hasOwnProperty("exists")) 598 serversuccess($(_this).attr("exists")); 599 else { 600 serversuccess($(_this).attr("success")); 601 $('#basket_cost').text(json["cost"]); 602 $('#basket_count').text(json["count"]); 603 $(_this).next(".toshow").removeClass('d-n'); 604 if ($(_this).attr("reload") == "1") location.href = location.href + "?reloaded=true"; 605 renew(); 606 } 607 608 }, $(this).attr("post")); 609 }); 610 611 $("body").on("change", ".saveable", 612 function (event) { 613 var value = $(this).val(); 614 switch ($(this).attr("type")) { 615 case "checkbox": 616 value = $(this).prop("checked") ? 1 : 0; 617 break; 618 default: 619 value = $(this).val(); 620 } 621 ajax_asynq($(this).attr("action"), function () { serversuccess('Ð¡Ð¾Ñ Ñанение...'); }, function () { serversuccess('Ð¡Ð¾Ñ Ñанено'); }, `idfield=${$(this).attr('idfield')}&${$(this).attr("property")}=${value}`); 622 } 623 ); 624 625 $("body").on("change", ".confirm_select", 626 function (event) { 627 628 if ($(this).find("option:selected").attr("target") == "confirm") 629 confirm_modal2($(this).attr("confirmsg"), $(this).attr("confirmyes"), $(this).attr("confirmno"), function () { }); 630 } 631 ); 632 633 $("body").on("click", ".informable", 634 function (event) { 635 if ($(this).attr("type") == "checkbox" && !$(this).is(':checked')) return; 636 confirm_modal3($(this).attr('link'), "ÐÑпÑавиÑÑ", "Ðазад", function () { sendForm($('#3453454')); }); 637 } 638 ); 639 640 $("body").on("click", ".zoomable", 641 function (event) { 642 643 document.body.style['zoom'] = $(this).attr("zoom"); 644 } 645 ); 646 647 $("body").on("click", ".refreshable", 648 function (event) { 649 window.location.href = window.location.href; 650 } 651 ); 652 653 $("body").on("click", ".backable", 654 function (event) { 655 window.location.href = document.referrer; 656 } 657 ); 658 659 $("body").on("click", ".hrefable", 660 function (event) { 661 event.preventDefault(); 662 if ($(this).hasClass("href")) 663 location.href = $(this).attr("_href"); 664 else 665 window.open($(this).attr("_href"), $(this).attr("target")); 666 667 //prompt(); 668 } 669 ); 670 671 //$("*").not(".hasinputmask").off(); // оÑиÑÑка пÑедÑдÑÑÐ¸Ñ 672 673 //оÑпÑавка ÑоÑÐ¼Ñ 674 $("body").on("click", ".submitter:not([disabled])", 675 function (e) { 676 if (e.keyCode && e.keyCode != 13) return; 677 sendForm(this); 678 } 679 ); 680 681 //оÑпÑавка запÑоÑа 682 $("body").on("click", ".curler", 683 function (e) { 684 var _this = this; 685 var start = $(_this).attr("start"); 686 var end = $(_this).attr("end"); 687 var error = $(_this).attr("error"); 688 var reload = $(_this).attr("reload") == "yes"; 689 confirm_modal3($(_this).attr("confirmlink"), "Ðа", "ÐеÑ", 690 function () { 691 ajax_asynq($(_this).attr("link"), function () { serversuccess(start) }, function (json) { 692 var result = JSON.parse(json); 693 if (result["result"] == "OK") { 694 serversuccess(end);
695 if (reload) location.reload(); 696 } 697 else 698 servererror(error); 699 }, $($(_this).attr("for")).serialize()) 700 }, $($(_this).attr("for")).serialize()); 701 702 } 703 ); 704 705 //ÑкаÑаÑÑ Ñайл 706 $("body").on("click", ".downloader", 707 function (e) { 708 event.preventDefault(); 709 var _this = this; 710 ajax_asynq($(_this).attr("link"), function () { $($(_this).attr("handler")).hide(); }, function (response) { 711 var json = JSON.parse(response); 712 $($(_this).attr("handler")).show(); $($(_this).attr("handler")).attr('href', json["href"]) 713 }, $($(_this).attr("for")).serialize()); 714 715 } 716 ); 717 718 $("body").on("click", ".cas", function () { 719 create_and_submit($(this).attr('data')); 720 }); 721 722 //trim 723 $("body").on("blur", ".form-control[type=text]", 724 function () { 725 $(this).val($(this).val().trim()); 726 $(this).val($(this).val().replace(/[\s\t]+/g, " ")); 727 } 728 ) 729 730 //бÑÑÑÑÐ°Ñ Ð¿ÑовеÑка regex 731 $("body").on("keyup blur", ".fastcheck", 732 function () { 733 var regexp = new RegExp(/.*/i); 734 regexp = $(this).attr("regex") ? new RegExp($(this).attr("regex"), "i") : regexp; 735 736 if (!regexp.exec($(this).val())) { 737 $(this).popover("enable"); 738 $(this).addClass('error'); 739 $(this).popover("show"); 740 } 741 else { 742 $(this).popover("disable"); 743 $(this).removeClass('error'); 744 $(this).popover("hide"); 745 } 746 } 747 ); 748 749 //бÑÑÑÑое иÑпÑавление имени 750 $("body").on("blur", ".autofix[user='user']", 751 function () { 752 $(this).val(cap($(this).val())); 753 754 $(this).val($(this).val().replace(/[ ]+/g, " ")); 755 756 $(this).val($(this).val().replace(/[-]+/g, "-")); 757 758 /*if ($(this).val().includes("-")) 759 $(this).val($(this).val().split('-').map(cap).join('-')); 760 761 if ($(this).val().includes(" ")) 762 $(this).val($(this).val().split(' ').map(cap).join(' '));*/ 763 } 764 ); 765 766 //ÑеÑвеÑÐ½Ð°Ñ Ð¿ÑовеÑка 767 $("body").on("blur", ".serverchk", 768 function () { 769 serverchk(this); 770 } 771 ); 772 773 774 //оÑмениÑÑ Ð¾Ð±ÑзаÑелÑное поле 775 $("body").on("change", ".notreq", 776 function () { 777 $($(this).attr('ref')).removeClass('error'); 778 $($(this).attr('ref')).popover("hide"); 779 if ($(this).prop("checked")) { 780 $($(this).attr('ref')).val("ÐÐТ"); 781 782 $($(this).attr('ref')).attr("readonly", "readonly"); 783 } 784 else { 785 $($(this).attr('ref')).removeAttr("readonly"); 786 } 787 // $(".fastcheck").blur(); 788 789 } 790 ); 791 $(".notreq").change(); 792 793 //ÑмениÑÑ Ð¼Ð°ÑÐºÑ Ð²Ð²Ð¾Ð´Ð° 794 $("body").on("change", ".maskchanger", function (e) { 795 if (($($(this).attr("action"))).attr("readonly")) return; 796 797 $($(this).attr("action")).val(''); 798 799 $masks = { "Username": "(^[A-z0-9_.\-]{1,50}@[A-z0-9_.\-]{1,50}\.(ru|com|net|su|ua|info|org|edu))*$", "Phone": "8\\(\\d{3}\\)\\d{3}-\\d{2}-\\d{2}", "Fio": "[Ð-ÑÑ\\s-]*" }; 800 $($(this).attr("action")).attr("regex", "^" + $masks[$(this).val()] + "$"); 801 $($(this).attr("action")).attr("data-inputmask-regex", ".*"); 802 if ($(this).val() == "Phone") { 803 $($(this).attr("action")).attr("data-inputmask-regex", $masks[$(this).val()]); 804 } 805 $($(this).attr("action")).next('.valid').text('').hide(); 806 $($(this).attr("action")).inputmask(); 807 }); 808 809 $("body").on("click", ".modaling", function () { show_modal(this, true); }); 810 811 $("body").on("click", ".mini-modal", function () { modalWin($(this).attr("header"), $(this)); }); 812 813 $("body").on("click", ".uploading:not('.blocked'):not('[disabled]')", function () { 814 $("input[for=#" + $(this).attr("id") + "]").click(); 815 816 $("input[for=#" + $(this).attr("id") + "]").not(".mychat").unbind("change").change( 817 function () { 818 ajax_file(this); 819 }); 820 } 821 ); 822 823 //checkbox 824 $("body").on("click", ".checkval", 825 function (event) { 826 if ($(this).is(':checked')) 827 $(this).val($(this).attr("onval")); 828 else 829 $(this).val($(this).attr("offval")); 830 } 831 ); 832 833 834} 835 836//аÑÑÑибÑÑÑ ÐºÐ»Ð°ÑÑов 837function class_attrs() { 838 if ($(".dataverificated").val() == 1) { 839 $(".toremove").remove(); 840 $(".blaver[type=text]").addClass("blocked"); 841 $(".blaver[type=text]").attr("readonly", "readonly"); 842 $(".blaver[type=text]").attr("title", "ÐÑ Ð¿Ð¾Ð´ÑвеÑдили даннÑе. РедакÑиÑование ÑÑого Ð¿Ð¾Ð»Ñ ÑепеÑÑ Ð½ÐµÐ´Ð¾ÑÑÑпно."); 843 $(".blaver[type=checkbox]").attr("disabled", "disabled"); 844 //$("select.blaver").attr("disabled", "disabled"); 845 } 846 847 /*$(".form-group").each( 848 function(){ 849 if ($(this).find("[class=hidden]").length>0) 850 $(this).addClass("hidden"); 851 } 852 );*/ 853 854 855} 856 857function onBatteryStatus(status) {
858 alert("Level1: " + status.level + " isPlugged1: " + status.isPlugged); 859} 860 861function initialization() { 862 863 window.addEventListener("batterystatus", onBatteryStatus, false); 864 865 866 867 868 console.log("ÐниÑиализаÑÐ¸Ñ Ð¿Ð»Ð°Ð³Ð¸Ð½Ð¾Ð²"); 869 captcha(); 870 entity(); 871 json_params(); 872 class_events(); 873 class_attrs(); 874 class_intervals(); 875 class_nice(); 876 blockmodal(); // блокиÑÑÑÑее обÑÑвление 877 popup(); // вÑплÑваÑÑие окна 878 prompt(); 879 infowidgets(); // вÑвод виджеÑов 880 $(".autoclick").removeClass("d-n").click(); 881 882 883 renew(); 884 uploading(); 885 886 $('h4.section:empty').hide(); 887 CKEDITOR.config.allowedContent = true; // оÑклÑÑиÑÑ ÑилÑÑÑаÑÐ¸Ñ Ñегов 888 CKEDITOR.config.filebrowserUploadUrl = "/admin/cke" 889 890 891 $('.mobile-hints').hide(); 892 if ($('.mobile-hints').not('.viewer').length > 0) $('.viewer').show(); 893 if (hasScroll()) $('.horisontal').removeClass("d-n"); 894 $(".reloader").each(function () { location.reload(); }); 895 896 new isvek.Bvi({ 897 target: '.impaired', 898 fontSize: 24, 899 theme: 'black', 900 panelHide: true 901 //...etc 902 }); 903 904 //new isvek.Bvi(); 905 906} 907 908//поле загÑÑзки Ñайла 909function uploading($class = "") { 910 911 $(".uploading" + $class).each(function () { 912 $(this).after("<input ztype=" + $(this).attr("ztype") + " accept='image/*,application/pdf' class='hidden' dest='" + ($(this).attr("prefix") && false ? $(this).attr("storage") : "") + "/" + $(this).attr("who") + "/loadfiles/attachments?remote=1&prefix=" + $(this).attr("prefix") + "' type=file for=#" + $(this).attr("id") + ">"); 913 914 if ($("div[for=#" + $(this).attr("id") + "]").length == 0) 915 $(this).closest('form').after("<div class='f-l formfiles' for=#" + $(this).attr("id") + "></div>"); 916 917 if ($(this).val() && $(this).val().includes("/")) 918 $("div[for=#" + $(this).attr("id") + "]").html("<a class=fancybox href='" + 919 ($(this).val().includes($(this).attr("prefix")) ? $(this).attr("storage") + "/web/ext/mime.php?host=local&file=" + $(this).attr("prefix") : "") 920 + "/web/upload/attachments/" + 921 $(this).val().trim().replace($(this).attr("prefix"), "") + 922 "'><img class=imgerr width=300 height=300 src='" + 923 ($(this).val().includes($(this).attr("prefix")) ? $(this).attr("storage") + "/web/ext/mime.php?host=local&file=" + $(this).attr("prefix") : "") 924 + "/web/upload/attachments/" + 925 $(this).val().trim().replace($(this).attr("prefix"), "") + 926 "'></a><i title='УдалиÑÑ' onclick='$($(this).parent().attr(\"for\")).val(\"\");$(this).parent().html(\"\");' class='toremove cursor-p fa fa-times fa-2x'></i>") 927 } 928 ); 929 930 $('.imgerr').unbind("error").error( 931 function () { 932 $(this).attr('src', "/web/graphics/pdf2.png"); 933 } 934 ); 935} 936 937//поле загÑÑзки Ñайла 938function uploading_old($class = "") { 939 940 $(".uploading" + $class).each(function () { 941 $(this).after("<input ztype=" + $(this).attr("ztype") + " accept='image/*,application/pdf' class='hidden' dest='/" + $(this).attr("who") + "/loadfiles/attachments' type=file for=#" + $(this).attr("id") + ">"); 942 943 if ($("div[for=#" + $(this).attr("id") + "]").length == 0) 944 $(this).closest('form').after("<div class='f-l formfiles' for=#" + $(this).attr("id") + "></div>"); 945 946 if ($(this).val() && $(this).val().includes("/")) 947 $("div[for=#" + $(this).attr("id") + "]").html("<a class=fancybox href='/web/upload/attachments/" + $(this).val().trim() + "'><img class=imgerr width=300 height=300 src='/web/upload/attachments/" + $(this).val() + "'></a><i title='УдалиÑÑ' onclick='$($(this).parent().attr(\"for\")).val(\"\");$(this).parent().html(\"\");' class='toremove cursor-p fa fa-times fa-2x'></i>") 948 } 949 ); 950 951 $('.imgerr').unbind("error").error( 952 function () { 953 $(this).attr('src', "/web/graphics/pdf2.png"); 954 } 955 ); 956} 957 958 959//вÑпадаÑÑий ÑпиÑок 960function autocomplete() { 961 var selected = false; 962 function split(val) { 963 return val.split(/,\s*/); 964 } 965 function extractLast(term) { 966 return split(term).pop(); 967 } 968 969 $(".autocomplete") 970 .on("keydown", function (event) { 971 if (event.keyCode === $.ui.keyCode.TAB && 972 $(this).autocomplete("instance").menu.active) { 973 event.preventDefault(); 974 } 975 }) 976 .autocomplete({ 977 source: function (request, response) { 978 $.getJSON($(".autocomplete").attr("jsource") + extractLast(request.term), { 979 }, response); 980 }, 981 search: function () { 982 selected = false;
983 // custom minLength 984 var term = extractLast(this.value); 985 if (term.length < 2) { 986 return false; 987 } 988 }, 989 focus: function () { 990 // prevent value inserted on focus 991 return false; 992 }, 993 select: function () { 994 selected = true; 995 } 996 }); 997} 998function randtimer(func = function () { }) { 999 setTimeout(function () { func(); randtimer(func) }, (Math.floor(Math.random() * 81 + 20) * 1000)); 1000} 1001function toogleColor(panel) { 1002 panel.toggleClass('bg-blue').toggleClass('bg-green'); 1003 if (panel.hasClass('bg-blue') && panel.hasClass('bg-green')) 1004 panel.removeClass('bg-blue'); 1005} 1006 1007function setprop(check) // ÑÑÑановка ÑвойÑÑв 1008{ 1009 1010 var data = {}; 1011 var check = $(check); 1012 var link = check.attr("link"); 1013 var user = check.attr("user"); 1014 var prop = check.attr("name"); 1015 var checked = check.prop("checked"); 1016 var onVal = check.val(); 1017 var offVal = check.attr("offval"); 1018 var ajaxLink = link + user; 1019 data[prop] = checked ? onVal : offVal; 1020 ajax_asynq( 1021 ajaxLink, 1022 function () { }, 1023 function (response) { console.log(response) }, 1024 data 1025 ); 1026} 1027 1028function disattach(button) { 1029 var attach = button.attr('file'); 1030 if (typeof attach === 'undefined' || !attach) return; 1031 if (swap && (swap == attach)) return; 1032 button.prev().toggleClass('hidden'); 1033 button.children().toggleClass(cplus).last().parent().parent().next().toggleClass('br-red'); 1034 var attachments = $(".attachments").val().split(","); 1035 1036 var attachcontainer = button.closest('.attachcontainer'); 1037 var clone = attachcontainer.clone(true, true); 1038 if (!attachments.remove(attach)) { 1039 attachments.push(attach); 1040 attachments.remove("!" + attach) 1041 attachcontainer.parent().children('.removed').first().before(clone.removeClass('removed')); 1042 } 1043 else { 1044 attachments.push("!" + attach); 1045 attachcontainer.parent().append(clone.addClass('removed')); 1046 } 1047 attachcontainer.remove(); 1048 $(".attachments").val(attachments.join(",")); 1049} 1050function swapattachs(attach1 = "", attach2 = "") { 1051 if (attach1 == attach2) { return; } 1052 var attachments = $(".attachments").val().split(","); 1053 var key1 = attachments.indexOf(attach1); 1054 var key2 = attachments.indexOf(attach2); 1055 1056 if (key1 == '-1' || key2 == '-1') { return; } 1057 var moveb1 = $('[action=moveattach][file="' + attach1 + '"]').find('i'); 1058 var moveb2 = $('[action=moveattach][file="' + attach2 + '"]').find('i'); 1059 if ( 1060 typeof moveb1.attr('movable') === 'undefined' || typeof moveb2.attr('movable') === 'undefined' || 1061 !moveb1.attr('movable') && !moveb2.attr('movable') || (moveb1.attr('movable') != moveb2.attr('movable')) 1062 ) { return; } 1063 var attachcontainer1 = moveb1.closest('.attachcontainer'); 1064 var attachcontainer2 = moveb2.closest('.attachcontainer'); 1065 var clone1 = attachcontainer1.clone(true, true); 1066 var clone2 = attachcontainer2.clone(true, true); 1067 attachments[key1] = attach2; 1068 attachments[key2] = attach1; 1069 attachcontainer1.replaceWith(clone2); 1070 attachcontainer2.replaceWith(clone1); 1071 $(".attachments").val(attachments.join(",")); 1072} 1073function manageattachs(movable = "images") { 1074 return $("<div></div>").addClass("btn-group p-a z-i-1 t-r-0") 1075 .append( 1076 $("<span></span>").attr('action', 'moveattach').attr('attachtype', movable).addClass('btn btn-primary b-t-l-r-0') 1077 .click(function () { 1078 if (swaptype && (swaptype != $(this).attr('attachtype'))) return false; 1079 $('[movable=' + movable + ']').toggleClass('fa-spin'); 1080 if (swap) { swapattachs(swap, $(this).attr('file')); swap = false; swaptype = undefined; } 1081 else { swap = $(this).attr('file'); swaptype = movable; } 1082 return false; 1083 }).append($('<i></i>').attr('movable', movable).addClass('fa fa-retweet')) 1084 ) 1085 .append( 1086 $("<span></span>").attr('action', 'disattach').addClass('btn btn-primary b-r-0') 1087 .click(function () { disattach($(this)); return false; }) 1088 .append($('<i></i>').addClass('fa fa-times')) 1089 ); 1090} 1091function crosstoprightelem1() { 1092 return $("<span><span>").attr("target", "actions").addClass("fa fa-times f-r m-l-10") 1093 .attr("style", "margin-right:-5px") 1094 .attr("onclick", "$(this).toggleClass(cplus).parent().toggleClass('br-red');"); 1095} 1096function setflowplayer(idplayer = "") { 1097 if (idplayer) { 1098 flowplayer( 1099 idplayer 1100 , 1101 { 1102 src: "/web/flash/flowplayer-3.2.16.swf", 1103 wmode: "opaque" 1104 1105 }, 1106 { 1107 plugins: { controls: { url: '/web/flash/flowplayer.controls-3.2.15.swf' } }, 1108 clip: 1109 {
1110 autoPlay: false, 1111 autoBuffering: false, 1112 scaling: "fit" 1113 } 1114 } 1115 ); 1116 } 1117} 1118function unescapeHtml(safe) { 1119 return safe 1120 .replace(/&/g, "&") 1121 .replace(/</g, "<") 1122 .replace(/>/g, ">") 1123 .replace(/"/g, "\"") 1124 .replace(/'/g, "'"); 1125} 1126function clear_carousel() { 1127 $("#big-modal .carousel-inner").html(""); 1128} 1129function add_body_padding() { 1130 /* 1131 * var w1 = self.innerWidth; // ШиÑина вмеÑÑе Ñ Ð¿Ð¾Ð»Ð¾Ñой пÑокÑÑÑки var w2 = 1132 * $('body').width(); // ШиÑина без полоÑÑ Ð¿ÑокÑÑÑки var ww = w1 - w2; // 1133 * ШиÑина вмеÑÑе Ñ Ð¿Ð¾Ð»Ð¾Ñой пÑокÑÑÑки var sliderWidth = 1134 * $('.slide-panel-carousel').css('width'); // ШиÑина ÑлайдеÑной панели // 1135 * ÐолÑÑаем изнаÑалÑнÑе ÑиÑÐ¸Ð½Ñ ÑлеменÑов ( без Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ Ð±Ð¾Ð´Ð¸ ) 1136 * $('.changable-width').each(function(){ var width = $(this).css('width'); 1137 * $(this).attr('wid', width); }); 1138 * $('body,.navbar-fixed-top').css('padding-right', ww); // ÐобавлÑем 1139 * паддинг к боди, ÑÑÐ¾Ð±Ñ Ð½Ðµ бÑло ÑкаÑка // УÑÑанавливаем изнаÑалÑнÑе ÑиÑÐ¸Ð½Ñ 1140 * ÑлеменÑов, ÑÑÐ¾Ð±Ñ Ð½Ðµ бÑло ÑкаÑка $('.changable-width').each(function(){ 1141 * $(this).css('width', $(this).attr('wid')); }); 1142 * 1143 * $('.slide-panel,.slide-panel-carousel').css('width', sliderWidth); // 1144 * УбиÑаем ÑкаÑок ÑиÑÐ¸Ð½Ñ ÑлайдеÑной панели return w2; 1145 */ 1146} 1147function delete_body_padding() { 1148 // $('body,.navbar-fixed-top').css('padding-right', 0); 1149} 1150function formOrder(f) { 1151 var form = $(f); 1152 var orderData = form.find('input[name=orderData]'); 1153 var checked = $('input[type=checkbox][target=order]:checked'); 1154 var amount = checked.length + 1; 1155 var dataString = ''; 1156 var arr = new Array(); 1157 1158 checked.each(function () { 1159 arr.push($(this).prev('span').html()); 1160 }); 1161 dataString = arr.join('-+-+-+-+-+-+-+-+-'); 1162 1163 orderData.val(dataString); 1164 1165 1166} 1167 1168//дополниÑелÑÐ½Ð°Ñ Ð¿ÑовеÑка email 1169function emailValidation() { 1170 var mail = $("#user_data_username"); 1171 if (mail.length && mail.val().includes("gmail.ru")) { 1172 mail.closest("form").find("#valid").text('ÐÑибка. Ðе найден поÑÑовÑй ÑеÑÐ²ÐµÑ gmail.ru. Ðозможно, ÐÑ Ð¸Ð¼ÐµÐ»Ð¸ в Ð²Ð¸Ð´Ñ gmail.com?').show(); 1173 mail.removeClass('ok').addClass('error'); 1174 return false; 1175 } 1176 else { 1177 mail.closest("form").find("#valid").text('').hide(); 1178 mail.removeClass('error').addClass('ok'); 1179 return true; 1180 } 1181 1182 /*var re2=new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); 1183 var mail = $("input[data-mask=mail]"); 1184 if( mail.length == 0 ) return true; 1185 var submit = mail.closest("form").find("button"); 1186 var valid = mail.closest("form").find("#valid"); 1187 if(!mail.val()){ 1188 valid.text('Ðоле не должно бÑÑÑ Ð¿ÑÑÑÑм!').show(); 1189 mail.removeClass('ok').addClass('error'); 1190 } 1191 else{ 1192 if(!re2.exec(mail.val())){ 1193 valid.text('ÐведиÑе, пожалÑйÑÑа, коÑÑекÑнÑй e-mail').show(); 1194 mail.removeClass('ok').addClass('error'); 1195 }else{ 1196 valid.text('').hide(); 1197 mail.removeClass('error').addClass('ok'); 1198 return true; 1199 } 1200 } 1201 return false*/ 1202} 1203 1204//пÑовеÑка индекÑа на ÑеÑвеÑе 1205function serverchk(_this, warning = false) { 1206 if ($(_this).attr("readonly")) return true; 1207 var result = true; 1208 var valid = $(_this).next(".valid"); 1209 var checkfailed = $(_this).attr('chkfailed'); 1210 var checkresult = $($(_this).attr('chkresult')); 1211 if (!(new RegExp($(_this).attr("regex"), "i")).exec($(_this).val())) { 1212 valid.text($(_this).attr('invalid')).show(); 1213 return false; 1214 } 1215 ajax_synq($(_this).attr("chkurl"), function () { }, function (data) { 1216 //еÑли Ð¸Ð½Ð´ÐµÐºÑ Ð½Ð° найден, Ñо ÑообÑение 1217 obj = JSON.parse(data); 1218 if (!obj.length) { 1219 //result = $(_this).hasClass("warning") || false; 1220 valid.text(checkfailed).show(); 1221 //$(_this).addClass('error'); 1222 //checkresult.val(''); 1223 checkresult.removeAttr("readonly"); 1224 } 1225 else { 1226 checkresult.val(obj.join(", ")); 1227 $(_this).addClass('ok'); 1228 valid.text('').hide(); 1229 checkresult.attr("readonly","readonly"); 1230 } 1231 } 1232 ,
1233 $("form[name=user_data]").serialize() 1234 1235 ); 1236 1237 return result; 1238} 1239 1240 1241function serverchk2(_this, warning = false) { 1242 var result = true; 1243 ajax_synq($(_this).attr("chkurl"), function () { }, function (data) { 1244 //еÑли Ð¸Ð½Ð´ÐµÐºÑ Ð½Ð° найден, Ñо ÑообÑение 1245 obj = JSON.parse(data); 1246 if (!obj.length) { 1247 result = false; 1248 confirm_modal3("/user/html/fio/", "OK", "Ðазад", function () { 1249 if (compare(".compfirst", ".compsecond")) //еÑли знаÑÐµÐ½Ð¸Ñ ÑовпадаÑÑ (ÑоÑма закÑÑваеÑÑÑ, в ÑледÑÑÑий Ñаз не оÑкÑÑваеÑÑÑ) 1250 { 1251 $(".zvalid").text("").hide(); 1252 $(".compfirst").addClass("compared"); 1253 1254 $("#user_data_REGISTRATION").click(); 1255 $("#user_data_personaldata").focus(); 1256 //SCROLL_TO("#user_data_personaldata"); 1257 //$("#user_data_personaldata").blur(function () { $(this).focus(); }); 1258 return true; 1259 } 1260 $(".zvalid").text("ÐведÑннÑе Ðами даннÑе не ÑовпадаÑÑ Ñ Ð²Ð²ÐµÐ´ÑннÑми Ñанее даннÑми. ÐÑовеÑÑÑе еÑÑ Ñаз.").show(); //(ÑоÑма не закÑÑваеÑÑÑ) 1261 return false; 1262 } 1263 ); 1264 } 1265 } 1266 , 1267 $("form[name=user_data]").serialize() 1268 1269 ); 1270 return result; 1271} 1272 1273//ÑвеÑиÑÑ Ð·Ð½Ð°ÑÐµÐ½Ð¸Ñ Ð´Ð²ÑÑ ÐºÐ»Ð°ÑÑов 1274function compare(class1, class2) { 1275 if ($(class1).length != $(class2).length) return false; 1276 for (i = 0; i <= $(class1).length; i++) { 1277 //if ($($(class1 + ":eq(" + i + ")")).val().trim()=="") return false; 1278 if ($($(class1 + ":eq(" + i + ")")).val() != $($(class2 + ":eq(" + i + ")")).val()) return false; 1279 } 1280 return true; 1281} 1282 1283//валидаÑÐ¸Ñ ÐºÐ°Ð¶Ð´Ð¾Ð³Ð¾ Ð¿Ð¾Ð»Ñ Ð¿Ð¾ ÑегÑкÑÐ¿Ñ 1284function validate() { 1285 event.preventDefault(); 1286 //serversuccess('ÐодождиÑе, идÑÑ Ð¿ÑовеÑка даннÑÑ ...',0); 1287 var result = true; 1288 1289 var regexp = new RegExp(/.*/i); 1290 $("span.valid").text("").hide(); 1291 $("button.report").hide(); 1292 $("input.error").removeClass("error"); 1293 $("input.ok").removeClass("ok"); 1294 1295 //пÑовеÑка required 1296 $("form[name='user_data']").find("[required='required']").each( 1297 function () { 1298 var valid = $(this).parent().find("span.valid"); 1299 if ($(this).val().trim() == "") { 1300 valid.text('ÐÑо поле обÑзаÑелÑно Ð´Ð»Ñ Ð·Ð°Ð¿Ð¾Ð»Ð½ÐµÐ½Ð¸Ñ.').show(); 1301 $(this).removeClass('ok').addClass('error'); 1302 1303 result = false;
1304 } 1305 else { 1306 valid.text('').hide(); 1307 $(this).removeClass('error').addClass('ok'); 1308 } 1309 } 1310 ); 1311 1312 1313 $("form[name='user_data']").find(".validate[type=text]").not(".error").each( 1314 function () { 1315 //var valid = $(this).next(".valid"); 1316 var valid = $(this).parent().find("span.valid"); 1317 var report = $(this).next().next(".report"); 1318 var equal = true; 1319 //ÑÐ¸Ð¿Ñ ÑегÑлÑÑнÑÑ Ð²ÑÑажений 1320 1321 regexp = $(this).attr("regex") ? new RegExp($(this).attr("regex"), "i") : regexp; 1322 1323 equal = !$($(this).attr("equal1")).val() && !$($(this).attr("equal2")).val() || ($(this).val() == $($(this).attr("equal1")).val() || $(this).val() == $($(this).attr("equal2")).val()); 1324 1325 if (!regexp.exec($(this).val()) || $(this).val().includes("gmail.ru") || !equal) { 1326 valid.text($(this).attr('invalid')).show(); 1327 if (!equal) report.show(); 1328 $(this).removeClass('ok').addClass('error'); 1329 result = false; 1330 } 1331 else { 1332 valid.text('').hide(); 1333 report.hide(); 1334 $(this).removeClass('error').addClass('ok'); 1335 } 1336 } 1337 ); 1338 1339 1340 // пÑовеÑка валидноÑÑи ÐÐÐ 1341 $(".validate.innchk").each( 1342 1343 function () { 1344 1345 var valid = $(this).parent().find("span.valid"); 1346 if (isINNValid($(this).val())) { 1347 valid.text('').hide(); 1348 $(this).removeClass('error').addClass('ok'); 1349 } 1350 else { 1351 valid.text($(this).attr('invalid')).show(); 1352 $(this).removeClass('ok').addClass('error'); 1353 result = false;
1354 } 1355 } 1356 ) 1357 1358 // пÑовеÑка валидноÑÑи даÑÑ 1359 $(".validate.datechk").each( 1360 1361 function () { 1362 var valid = $(this).parent().find("span.valid"); 1363 if (isDateValid($(this).val()) && isAgeValid($(this).val())) { 1364 valid.text('').hide(); 1365 $(this).removeClass('error').addClass('ok'); 1366 } 1367 else { 1368 valid.text($(this).attr('invalid')).show(); 1369 $(this).removeClass('ok').addClass('error'); 1370 result = false; 1371 } 1372 } 1373 ) 1374 1375 // ÑеÑвеÑÐ½Ð°Ñ Ð¿ÑовеÑка 1 (индекÑ) 1376 $(".validate.serverchk").each( 1377 function () { 1378 var _result = serverchk($(this)); 1379 result = result && _result; 1380 } 1381 ) 1382 1383 // ÑеÑвеÑÐ½Ð°Ñ Ð¿ÑовеÑка 2 1384 if (result) 1385 $(".validate.serverchk2").each( 1386 function () { 1387 var _result = ($(this).hasClass("compared") || serverchk2($(this))); 1388 result = result && _result; 1389 } 1390 ) 1391 1392 $("input[type=text].form-control").not(".error").addClass('ok'); 1393 1394 if (result) { 1395 $(".error").removeClass('error').addClass('ok'); 1396 } 1397 else 1398 SCROLL_TO($(document).find(".error").eq(0).parent().prev()); 1399 1400 return result; 1401} 1402 1403//ÑÐ¾Ð·Ð´Ð°ÐµÑ ÑоÑÐ¼Ñ Ð¸ Ð´ÐµÐ»Ð°ÐµÑ submit 1404function create_and_submit(json) { 1405 var form = document.createElement("form"); 1406 var params = JSON.parse(json); 1407 form.setAttribute("method", "post"); 1408 form.setAttribute("action", params["path"]); 1409 _domain = params["domain"]; 1410 //form.setAttribute("target", "_blank"); 1411 for (var key in params) { 1412 if (params.hasOwnProperty(key)) { 1413 var hiddenField = document.createElement("input"); 1414 hiddenField.setAttribute("type", "hidden"); 1415 hiddenField.setAttribute("name", key); 1416 hiddenField.setAttribute("value", params[key]); 1417 1418 form.appendChild(hiddenField); 1419 } 1420 } 1421 1422 document.body.appendChild(form); 1423 form.submit(); 1424} 1425 1426// оÑпÑавлÑÐµÑ Ð´Ð°Ð½Ð½Ñе ÑоÑÐ¼Ñ 1427function sendForm(elem) { 1428 event.preventDefault(); 1429 var form = $(elem).closest("form"); 1430 var reset = $(elem).attr("trigger") === "reset"; // ÑбÑÐ¾Ñ ÑоÑÐ¼Ñ 1431 var nopopup = $(elem).attr("popup") === "no"; //инÑо popup 1432 var startmsg = $(elem).attr("startmsg") === undefined ? "ÐÑпÑавка даннÑÑ ..." : $(elem).attr("startmsg"); //ÑÑаÑÑ 1433 var endmsg = $(elem).attr("endmsg") === undefined ? "ÐаннÑе оÑпÑавленÑ!" : $(elem).attr("endmsg"); //end 1434 var errormsg = $(elem).attr("errormsg") === undefined ? "ÐÑибка оÑпÑавки даннÑÑ . ÐопÑобÑйÑе еÑе Ñаз." : $(elem).attr("errormsg"); //оÑибка 1435 var cancel = false; //Ñлаг оÑÐ¼ÐµÐ½Ñ 1436 1437 1438 form.find("[required],[required=required],[required=ok]").each(function () { 1439 //cancel = false; 1440 $(this).removeClass("error").removeClass("ok"); 1441 var value = $(this).val(); 1442 //alert($(this).attr("test")); 1443 if (!value) { 1444 //alert("1"); 1445 cancel = true; 1446 $(this).addClass("error"); 1447 1448 $(this).parent().focus().tooltip('show'); 1449 $(".modal").animate({ scrollTop: $(this).get(0).offsetTop }, 500); 1450 1451 } 1452 else 1453 $(this).addClass("ok"); 1454 }); 1455 if (cancel) return; 1456 ajax_with_form( 1457 form, 1458 function () { 1459 $(".form-button,.form-elements").attr("disabled", true); 1460 if (!nopopup) serversuccess(startmsg, 0); 1461 }, 1462 function (response) { 1463 1464 var json = JSON.parse(response); 1465 1466 1467 if (json.callback) eval(json.callback); 1468 if (!json.response.trim().startsWith('!!!')) { 1469 if (reset) { 1470 $(form).next(".formfiles").html(''); 1471 form.trigger('reset'); 1472 form.find("input.zhidden").val(''); 1473 } 1474 if (!nopopup) serversuccess(endmsg); 1475 } 1476 else 1477 servererror(json.response.trim().replace('!!!', '')); 1478 1479 $(".form-button,.form-elements").removeAttr("disabled"); 1480 1481 1482 }, 1483 function (request, status, error) { 1484 servererror(errormsg); 1485 $(".form-button,.form-elements").removeAttr("disabled"); 1486 } 1487 ); 1488 return false; 1489} 1490 1491function search(bSubm, out) { 1492 1493 var bSubm = $(bSubm); 1494 var form = bSubm.closest("form"); 1495 var searchlink = bSubm.attr("link"); 1496 var linksuff = bSubm.attr("linksuff"); 1497 var partsLink = searchlink.split("/"); 1498 form.find("[target=search]").each(function () { 1499 if ($(this).val()) searchlink += ("/" + $(this).attr("search") + "=" + $(this).val()); 1500 }); 1501 form.find("[target=choicevalue]").each(function () { 1502 $('[choice-input-id=' + $(this).attr('choice-input') + ']').val($(this).val() ? '/' + $(this).val() : ''); 1503 }); 1504 form.find("[target=filter]").each(function () { 1505 var filter = $(this).prop('checked'), val = $(this).val(); 1506 if (val && filter) searchlink += $(this).val(); 1507 }); 1508 form.find("[target=hiddenfilter]").each(function () { 1509 if ($(this).val()) searchlink += $(this).val(); 1510 }); 1511 searchlink = searchlink.replace("enter_by_passport_input", '/' + form.find("[id*=passport_input]").val()); // поиÑк 1512 // по 1513 // паÑпоÑÑÑ 1514 ajax_asynq( 1515 searchlink + linksuff, 1516 function () { $("#" + out).html(spinner) }, 1517 function (response) { $("#" + out).html(spinner).html(response); infowidgets(); } 1518 ); 1519} 1520 1521//Ñпиок загÑÑженнÑÑ Ñайлов 1522function files_ready(uploaded) { 1523 var attachments = $("input[type=hidden].attachments"); 1524 var filename = uploaded.split(".")[0]; 1525 var ext = uploaded.split(".")[1]; 1526 if (attachments.val()) attachments.val(attachments.val() + ','); 1527 attachments.val(attachments.val() + "~tmp~_" + uploaded); 1528 if (ext.in_array(["jpeg", "jpg", "png", "gif"])) { 1529 if (ext == "png") $(".giftimage").val(filename); 1530 var imgs = $("#attachments_images_edit"); 1531 var imgf = imgs.attr("imgf");
1532 $("<div></div>").addClass("p-r attachcontainer").append(manageattachs("images")) 1533 .children().last().children().attr("file", "~tmp~_" + uploaded).last().parent().after("<img>") 1534 .next().addClass("w-100").attr("src", imgf + uploaded) 1535 .parent().appendTo(imgs); 1536 } 1537 else if (ext.in_array(["mp4", "flv", "f4v", "mov", "m4v"])) { 1538 var vds = $("#attachments_videos_edit"); 1539 var vdsf = vds.attr("vdsf"); 1540 var vurl = vds.attr("vurl"); 1541 var rand = '_' + Math.random().toString(36).substr(2, 16); 1542 $("<div></div>").addClass("p-r attachcontainer").append(manageattachs("videos")).children().last() 1543 .children().attr("file", "~tmp~_" + uploaded).last().parent().parent() 1544 .append('<video controls></video>').children().last() 1545 .attr("id", "videotag" + rand).attr("width", "100%").attr("height", "400px") 1546 .append('<source>').children().last().attr("src", vdsf + uploaded) 1547 .parent().append('<div></div>').children().last().attr("href", vurl + uploaded) 1548 .attr("style", "width:100%;height:400px").attr("id", "flowplayer" + rand).parent().parent().appendTo(vds); 1549 } 1550 else if (ext.in_array(["mp3", "a4a", "wav", "ogg", "acc", "mpga", "ogg", "oga", "audios-unk"])) { 1551 var ads = $("#attachments_audios_edit"); 1552 var adsf = ads.attr("adsf"); 1553 var aurl = ads.attr("aurl"); 1554 var rand = '_' + Math.random().toString(36).substr(2, 16); 1555 $("<div></div>").addClass("p-r attachcontainer").append(manageattachs("audios")).children().last() 1556 .children().attr("file", "~tmp~_" + uploaded).last().parent().parent() 1557 .append('<audio controls></audio>').children().last() 1558 .attr("id", "audiotag" + rand).attr("width", "100%") 1559 .append('<source>').children().last().attr("src", adsf + uploaded) 1560 .parent().append('<div></div>').children().last().attr("href", aurl + uploaded) 1561 .parent().parent().appendTo(ads); 1562 } 1563 else { 1564 1565 var fls = $("#attachments_files_edit"); 1566 var flsf = fls.attr("flsf"); 1567 var spltr = "-_-_-_-_-_-"; 1568 var parts = uploaded.split(spltr); 1569 var dwnld = parts[0].replace(/_/g, " "); 1570 var ext = parts[1].split(".")[1]; 1571 $('<a target=_blank class="list-group-item p-r attachcontainer p-t-50"></a>') 1572 .append(manageattachs("files")).children().last() 1573 .children().attr("file", "~tmp~_" + uploaded).last().parent().parent() 1574 .append('<span class=badge></span>').attr("href", flsf + parts[1]) 1575 .attr("download", dwnld + "." + ext).find("span.badge").html(ext) 1576 .after(dwnld).parent().appendTo(fls); 1577 } 1578} 1579 1580function dz3(dz) { 1581 _this = $(dz); 1582 var $row = null; 1583 var $result = null; 1584 var $realInput = _this.next("input"); 1585 _this.click(function () { 1586 event.preventDefault(); 1587 $realInput.not(".working").click(); 1588 } 1589 ); 1590 // иниÑиализаÑÐ¸Ñ Ð¿Ð»Ð°Ð³Ð¸Ð½Ð° jQuery File Upload 1591 $realInput.fileupload({ 1592 dropZone: $(dz), 1593 add: function (e, data) { 1594 //e.preventDefault(); 1595 //Ð¸Ð¼Ñ 1596 //ÑÐ°Ð·Ð¼ÐµÑ 1597 $realInput.addClass("working"); 1598 $result = $($(dz).attr("result")); 1599 //$row = $result.find('.info_base').first().clone().show().appendTo($result); 1600 $row = $result.find('.info_base').first().show(); 1601 $row.find(".filename").html(data.files[0].name); 1602 $row.find(".size").html(data.files[0].size); 1603 $row.find(".progress").show().knob(); 1604 $row.find(".cancel").show(); 1605 data.context = $row; 1606 //tpl.find('span.filename').html(data.files[0].name); 1607 var jqXHR = data.submit(); 1608 $row.find(".cancel").unbind("click").click(function () { 1609 jqXHR.abort(); 1610 $realInput.removeClass("working"); 1611 $row.find(".progress").hide() 1612 $row.find(".cancel").hide(); 1613 }); 1614 1615 }, 1616 1617 progress: function (e, data) { 1618 // ÐÑÑиÑление пÑоÑенÑа загÑÑзки 1619 var progress = parseInt(data.loaded / data.total * 100, 10); 1620 1621 // обновлÑем ÑÐºÐ°Ð»Ñ 1622 data.context.find(".progress").val(progress).change(); 1623 serversuccess("ÐбÑабоÑка Ñайла...", 0); 1624 }, 1625 1626 fail: function (e, data) { 1627 try { 1628 //$json = JSON.parse(data.response().result); 1629 //$msg = $json["errmsg"]; 1630 servererror("ÐÑибка!"); 1631 //alert("ÐденÑиÑикаÑÐ¾Ñ Ð¼Ð°Ð³Ð°Ð·Ð¸Ð½Ð° в вÑгÑÑзке не ÑÐ¾Ð²Ð¿Ð°Ð»Ð°ÐµÑ Ñ Ð¸Ð½Ð´ÐµÐ½ÑиÑикаÑоÑом Ð´Ð»Ñ Ð´Ð°Ð½Ð½Ð¾Ð¹ оÑганизаÑии! ÐбÑабоÑка невозможна."); 1632 //console.log($msg); 1633 } catch { 1634 //alert(""); 1635 //console.log("123"); 1636 alert("ÐÑибка обÑабоÑки JSON...") 1637 //servererror("ÐÑибка обÑабоÑки JSON..."); 1638 } 1639 serversuccess(""); 1640 $realInput.removeClass("working"); 1641 //servererror($msg); 1642 }, 1643 done: function (e, data) { 1644 $realInput.removeClass("working"); 1645 //console.log(data.response().result); 1646 try { 1647 $json = JSON.parse(data.response().result); 1648 $row.find(".url").attr("href", $json["url"]); 1649 $row.find(".cancel").hide(); 1650 $row.find(".success").html($json["success"]).show(); 1651 } catch { } 1652 serversuccess("ÐбÑабоÑка завеÑÑена!"); 1653 //$row.find(".success").show().html($json["success"]); 1654 } 1655 1656 1657 1658 }); 1659 1660 $(document).on('drop dragover', function (e) { 1661 e.preventDefault(); 1662 }); 1663 1664} 1665 1666//dz2 1667function dz(dz) { 1668 $(dz).on("dragover", function () { $(this).addClass("ok"); }); 1669 1670 $(dz).on("dragleave", function () { $(this).removeClass("ok"); }); 1671 1672 // иниÑиализаÑÐ¸Ñ Ð¿Ð»Ð°Ð³Ð¸Ð½Ð° jQuery File Upload 1673 $(dz).fileupload({ 1674 1675 // ÑÑÐ¾Ñ ÑÐ»ÐµÐ¼ÐµÐ½Ñ Ð±ÑÐ´ÐµÑ Ð¿ÑинимаÑÑ Ð¿ÐµÑеÑаÑкиваемÑе на него ÑÐ°Ð¹Ð»Ñ 1676 dropZone: $(dz), 1677 1678 // ФÑнкÑÐ¸Ñ Ð±ÑÐ´ÐµÑ Ð²Ñзвана пÑи помеÑении Ñайла в оÑеÑÐµÐ´Ñ 1679 add: function (e, data) { 1680 //console.log(''); 1681 ajax_file($(`input[for='#${$(dz).attr("id")}']`), data); 1682 }, 1683 1684 progress: function (e, data) { 1685 1686 }, 1687 1688 fail: function (e, data) { 1689 }, 1690 done: function (e, data) { 1691 1692 } 1693 1694 1695 1696 }); 1697 1698 $(document).on('drop dragover', function (e) { 1699 e.preventDefault(); 1700 }); 1701 1702} 1703 1704function dropZoneInit(formId = "multiple_d_d_upload_file", dropZoneId = "drop") { 1705 var ul = $('#' + formId + ' ul'); 1706 1707 $('#' + dropZoneId + ' a').click(function () { 1708 // имиÑаÑÐ¸Ñ Ð½Ð°Ð¶Ð°ÑÐ¸Ñ Ð½Ð° поле вÑбоÑа Ñайла 1709 $(this).parent().find('input').click(); 1710 }); 1711 1712 // иниÑиализаÑÐ¸Ñ Ð¿Ð»Ð°Ð³Ð¸Ð½Ð° jQuery File Upload 1713 $('#' + formId).fileupload({ 1714 1715 // ÑÑÐ¾Ñ ÑÐ»ÐµÐ¼ÐµÐ½Ñ Ð±ÑÐ´ÐµÑ Ð¿ÑинимаÑÑ Ð¿ÐµÑеÑаÑкиваемÑе на него ÑÐ°Ð¹Ð»Ñ 1716 dropZone: $('#' + dropZoneId), 1717 1718 // ФÑнкÑÐ¸Ñ Ð±ÑÐ´ÐµÑ Ð²Ñзвана пÑи помеÑении Ñайла в оÑеÑÐµÐ´Ñ 1719 add: function (e, data) { 1720 1721 var tpl = $('<li class="list-group-item">
1721<input type="text" value="0" data-width="48" data-height="48"' + 1722 ' data-fgColor="#0788a5" data-readOnly="1" data-bgColor="#3e4043" /><span class=badge></span><span class="filename fnt1"></span></li>'); 1723 1724 // вÑвод имени и ÑазмеÑа Ñайла 1725 tpl.find('span.badge').html(formatFileSize(data.files[0].size)); 1726 if (parseInt(data.files[0].size) > 260 * 1024 * 1024) { alert("Ð Ð°Ð·Ð¼ÐµÑ Ñайла пÑевÑÑÐ°ÐµÑ 250 ÐÐ!"); return; } 1727 tpl.find('span.filename').html(data.files[0].name); 1728 1729 data.context = tpl.appendTo(ul); 1730 1731 // иниÑиализаÑÐ¸Ñ Ð¿Ð»Ð°Ð³Ð¸Ð½Ð° jQuery Knob 1732 tpl.find('input').knob(); 1733 1734 // оÑÑлеживание нажаÑÐ¸Ñ Ð½Ð° Ð¸ÐºÐ¾Ð½ÐºÑ Ð¾ÑÐ¼ÐµÐ½Ñ 1735 tpl.find('span').click(function () { 1736 1737 if (tpl.hasClass('working')) { 1738 jqXHR.abort(); 1739 } 1740 1741 tpl.fadeOut(function () { 1742 tpl.remove(); 1743 }); 1744 1745 }); 1746 1747 // ÐвÑомаÑиÑеÑки загÑÑжаем Ñайл пÑи добавлении в оÑеÑÐµÐ´Ñ 1748 var jqXHR = data.submit(); 1749 }, 1750 1751 progress: function (e, data) { 1752 1753 // ÐÑÑиÑление пÑоÑенÑа загÑÑзки 1754 var progress = parseInt(data.loaded / data.total * 100, 10); 1755 1756 // обновлÑем ÑÐºÐ°Ð»Ñ 1757 data.context.find('input').val(progress).change(); 1758 1759 if (progress == 100) { 1760 data.context.removeClass('working'); 1761 } 1762 }, 1763 1764 fail: function (e, data) { 1765 // ÑÑо-Ñо поÑло не Ñак 1766 data.context.addClass('error'); 1767 }, 1768 done: function (e, data) { 1769 var uploaded = data.response().result.replace(/[\n\r\s]/g, ''); 1770 var li = data.context; 1771 var msg_el = li.find("span.filename"); 1772 var msg = "<br><i class='fa fa-spinner fa-spin fa-2x'></i> ÐодождиÑе, Ð¸Ð´ÐµÑ ÐºÐ¾Ð½Ð²ÐµÑÑаÑÐ¸Ñ Ð²Ð¸Ð´ÐµÐ¾Ñайла..."; 1773 var old_text = msg_el.html(); 1774 if (uploaded.substr(0, 3) == "err") // конвеÑÑаÑÐ¸Ñ Ð²Ð¸Ð´ÐµÐ¾ 1775 ajax_asynq("/convertvideo/" + uploaded.split("_")[1], function () { msg_el.html(msg_el.html() + msg); }, 1776 function (data) { msg_el.html(old_text); li.addClass('ok'); files_ready(data) }); 1777 else { 1778 li.addClass('ok') 1779 files_ready(uploaded); 1780 } 1781 1782 } 1783 1784 1785 1786 }); 1787 1788 $(document).on('drop dragover', function (e) { 1789 e.preventDefault(); 1790 }); 1791 1792 // вÑпомогаÑелÑÐ½Ð°Ñ ÑÑнкÑиÑ, коÑоÑÐ°Ñ ÑоÑмаÑиÑÑÐµÑ ÑÐ°Ð·Ð¼ÐµÑ Ñайла 1793 function formatFileSize(bytes) { 1794 if (typeof bytes !== 'number') { 1795 return ''; 1796 } 1797 1798 if (bytes >= 1000000000) { 1799 return (bytes / 1000000000).toFixed(2) + ' GB'; 1800 } 1801 1802 if (bytes >= 1000000) { 1803 return (bytes / 1000000).toFixed(2) + ' MB'; 1804 } 1805 1806 return (bytes / 1000).toFixed(2) + ' KB'; 1807 } 1808} 1809function fullresetform(form) { 1810 $(form).trigger('reset'); 1811 $('.chosen').trigger("chosen:updated"); 1812 $(form).find("[type=hidden]").val(""); 1813 $(form).find("textarea").each(function () { 1814 1815 var ckeinst = $(this).attr("id"); 1816 if (CKEDITOR.instances[ckeinst]) CKEDITOR.instances[ckeinst].setData(""); 1817 1818 }); 1819 swap = swaptype = false;
1820 $('.fa-spin').removeClass('fa-spin'); 1821 $('#attachments_images_edit,#attachments_videos_edit,#attachments_files_edit').html(""); 1822} 1823 1824function servererror(request, status, error, time = 6000) { // ÑообÑение еÑли оÑибка ÑеÑвеÑа 1825 if (request.status === 0) return; 1826 serversuccess(); 1827 var msg = (request.status === undefined ? request : 'ÐÑибка ' + request.status); 1828 if (time) 1829 $('.servererror').html(msg).slideToggle( 1830 'fast', 1831 'linear', 1832 function () { 1833 setTimeout( 1834 function () { 1835 $('.servererror').slideToggle( 1836 'fast', 1837 'linear', 1838 function () { 1839 $('.servererror').html('').hide(); 1840 } 1841 ); 1842 }, 1843 time 1844 ); 1845 } 1846 ); 1847 1848 1849} 1850 1851function serversuccess(msg = "", time = 6000) { // вÑвеÑÑи ÑообÑение 1852 1853 var after = (time ? // ÑеÑез ÑколÑко ÑбÑаÑÑ; 0- навÑегда 1854 function () { 1855 $('.serversuccess').slideToggle( 1856 'fast', 1857 'linear', 1858 function () { 1859 $('.serversuccess').html('').hide(); 1860 } 1861 ); 1862 } 1863 : 1864 function () { } 1865 ); 1866 1867 if (tID) { clearTimeout(tID) }; // ÑбÑаÑÑ Ð¿ÑедÑдÑÑие ÑообÑÐµÐ½Ð¸Ñ 1868 1869 if (time) 1870 $('.serversuccess').slideUp('fast', 'linear'); 1871 else 1872 $('.serversuccess').hide(); 1873 if (!msg) return; 1874 if (time) 1875 $('.serversuccess').html(msg).slideToggle( 1876 'fast', 1877 'swing', 1878 function () { 1879 tID = setTimeout( 1880 after, 1881 time 1882 ); 1883 } 1884 ); 1885 else 1886 $('.serversuccess').html(msg).show(); 1887} 1888 1889//оÑпÑавиÑÑ Ñайл из инпÑÑа 1890function ajax_file( 1891 input, 1892 data = null, 1893 error = function (request, status, error) { 1894 servererror("ÐÑибка загÑÑзки Ñайла. ÐопÑобÑйÑе еÑÑ Ñаз."); 1895 //servererror(request, status, error) 1896 } 1897) { 1898 var fd = new FormData; 1899 var _input = input; 1900 var file = data == null ? $(input).prop('files')[0] : data.files[0]; 1901 1902 if (file == undefined) { return; } 1903 1904 if (parseInt(file.size) > 100 * 1024 * 1024) { alert("Ð Ð°Ð·Ð¼ÐµÑ Ñайла пÑевÑÑÐ°ÐµÑ 100 ÐÐ!"); return; } 1905 1906 if (parseInt(file.size) == 0) { alert("Ð Ð°Ð·Ð¼ÐµÑ Ñайла 0 ÐÐ!"); return; } 1907 1908 if (!file.type.match("(application\/pdf|image\/jpeg|image\/png)") && !file.type.match($(input).attr("extensions"))) { alert("ÐеподдеÑживаемÑй ÑоÑÐ¼Ð°Ñ Ñайла!"); return; } 1909 1910 fd.append($(input).attr('name'), file); // добавление даннÑÑ 1911 1912 fd.append('param', $(input).attr('param')); // добавление даннÑÑ 1913 1914 1915 1916 $.ajax({ 1917 url: $(input).attr('dest'), 1918 type: "POST", 1919 data: fd, 1920 cache: false, 1921 processData: false, 1922 contentType: false, 1923 beforeSend: function () { $($(_input).attr("for")).attr("disabled", "disabled"); $($(_input).attr('result')).html("Ðжидание..."); $($(_input).attr("for")).val('ÐодождиÑе, Ñайл загÑÑжаеÑÑÑ...'); }, 1924 success: function (html) { 1925 $($(_input).attr("for")).removeAttr("disabled"); 1926 $($(_input).attr("for")).removeClass("error"); 1927 $($(_input).attr('result')).html(html); 1928 $(_input).val(''); 1929 html = html.split("-_-_-_-_-_-").reverse()[0]; 1930 $($(_input).attr("for")).val(html); 1931 if ($(_input).next(".zhidden").length > 0) $(_input).next(".zhidden").val(html); 1932 var href = $(_input).attr("ztype") == "simple" ? 1933 "<div class='cursor-p' title='УдалиÑÑ'><a target=_blank href='/web/upload/attachments/" + html.trim() + "'>Ðложение</a><i onclick='$(this).parent().remove();$(\".zhidden\").val(\"\")' class='fa fa-times fa-1x'></i></div>" : 1934 "<a class='fancybox ' target=_blank href='" + 1935 (html.includes($($(_input).attr("for")).attr("prefix")) ? $($(_input).attr("for")).attr("storage") + "/web/ext/mime.php?host=local&file=" + $($(_input).attr("for")).attr("prefix") : "") 1936 + "/web/upload/attachments" + 1937 html.trim().replace($($(_input).attr("for")).attr("prefix"), "") + 1938 "'><img class=imgerr width=300 height=300 src='" + 1939 (html.includes($($(_input).attr("for")).attr("prefix")) ? $($(_input).attr("for")).attr("storage") + "/web/ext/mime.php?host=local&file=" + $($(_input).attr("for")).attr("prefix") : "") 1940 + "/web/upload/attachments/" + 1941 html.trim().replace($($(_input).attr("for")).attr("prefix"), "") + 1942 "'></a><i title = 'УдалиÑÑ' onclick='$($(this).parent().attr(\"for\")).val(\"\");$(this).parent().html(\"\");' class='cursor-p fa fa-times fa-2x'></i>"; 1943 $("div[for=" + $(_input).attr("for") + "]").html(href); 1944 1945 $('.imgerr').unbind("error").error( 1946 function () { 1947 $(this).attr('src', "/web/graphics/pdf2.png"); 1948 } 1949 ); 1950 }, 1951 error: function () { 1952 servererror("ÐÑибка загÑÑзки Ñайла. ÐопÑобÑйÑе еÑÑ Ñаз."); 1953 $($(_input).attr("for")).val("ÐÑибка загÑÑзки Ñайла. ÐопÑобÑйÑе еÑÑ Ñаз."); 1954 $($(_input).attr("for")).addClass("error"); 1955 $($(_input).attr("for")).blur(); 1956 $(_input).val(''); 1957 $($(_input).attr("for")).removeAttr("disabled"); 1958 } 1959 }); 1960} 1961 1962//оÑпÑавиÑÑ Ñайл из инпÑÑа 1963function ajax_file_old( 1964 input, 1965 data = null, 1966 error = function (request, status, error) { 1967 servererror(request, status, error) 1968 } 1969) { 1970 var fd = new FormData; 1971 var _input = input; 1972 var file = data == null ? $(input).prop('files')[0] : data.files[0]; 1973 1974 if (file == undefined) { return; } 1975 1976 if (parseInt(file.size) > 100 * 1024 * 1024) { alert("Ð Ð°Ð·Ð¼ÐµÑ Ñайла пÑевÑÑÐ°ÐµÑ 100 ÐÐ!"); return; } 1977 1978 if (!file.type.match("(application\/pdf|image\/jpeg|image\/png)")) { alert("ÐеподдеÑживаемÑй ÑоÑÐ¼Ð°Ñ Ñайла!"); return; } 1979 1980 fd.append($(input).attr('name'), file); // добавление даннÑÑ 1981 1982 1983 1984 $.ajax({ 1985 url: $(input).attr('dest'), 1986 type: "POST", 1987 data: fd, 1988 cache: false, 1989 processData: false, 1990 contentType: false, 1991 beforeSend: function () { $($(_input).attr("for")).val('ÐодождиÑе, Ñайл загÑÑжаеÑÑÑ...'); }, 1992 success: function (html) { 1993 $(_input).val(''); 1994 html = html.split("-_-_-_-_-_-").reverse()[0]; 1995 $($(_input).attr("for")).val(html); 1996 $(".zhidden").val(html); 1997 var href = $(_input).attr("ztype") == "simple" ? 1998 "<div class='cursor-p' title='УдалиÑÑ'><a target=_blank href='/web/upload/attachments/" + html.trim() + "'>Ðложение</a><i onclick='$(this).parent().remove();$(\".zhidden\").val(\"\")' class='fa fa-times fa-1x'></i></div>" : 1999 "<a class='fancybox ' target=_blank href='/web/upload/attachments/" + html.trim() + "'><img class=imgerr width=300 height=300 src='/web/upload/attachments/" + html.trim() + "'></a><i title = 'УдалиÑÑ' onclick='$($(this).parent().attr(\"for\")).val(\"\");$(this).parent().html(\"\");' class='cursor-p fa fa-times fa-2x'></i>"; 2000 $("div[for=" + $(_input).attr("for") + "]").html(href); 2001 2002 $('.imgerr').unbind("error").error( 2003 function () { 2004 $(this).attr('src', "/web/graphics/pdf2.png"); 2005 } 2006 ); 2007 }, 2008 error: error 2009 }); 2010} 2011 2012function ajax_asynq( 2013 script, 2014 start = function () { }, 2015 end = function () { }, 2016 data = {}, 2017 error = function (request, status, error) { 2018 servererror(request, status, error) 2019 } 2020) { 2021 if (script == "nolink") return false;
2022 $.ajax({ 2023 url: script, 2024 type: "POST", 2025 data: data, 2026 cache: false, 2027 beforeSend: start, 2028 success: end, 2029 error: error 2030 }); 2031} 2032 2033function ajax_asynq_simple(script) { 2034 $.ajax({ url: script, cache: false }); 2035} 2036function benefitSubmit(bSubm) { 2037 var data = {}; 2038 var bSubm = $(bSubm); 2039 var benefit = bSubm.prev("input[data-type=benefit]"); 2040 data["number"] = benefit.val(); 2041 ajax_asynq( 2042 '/benefit', 2043 function () { bSubm.next('#valid').removeClass('valid').html(spinner) }, 2044 function (response) { 2045 if (response == "00000") { 2046 bSubm.next('#valid').addClass('valid').text('ÐевеÑнÑй номеÑ'); 2047 } 2048 if (response != "00000" && response != "") { 2049 location.href = response; 2050 } 2051 }, 2052 data 2053 ); 2054} 2055 2056//пÑовеÑка логина (иÑполÑзÑеÑÑÑ Ð¿Ñи ÑегиÑÑÑаÑии) 2057function checklogin(bSubm) { 2058 event.preventDefault(); 2059 var data = {}; 2060 var form = $(bSubm).closest("form"); 2061 var bSubm = $(bSubm); 2062 var login = form.find("input[data-type=login]"); 2063 var answer = form.find("#user_data_user_answer").val(); 2064 var mask = form.find("#user_data_mask").val(); 2065 if (!emailValidation()) return false; 2066 2067 /*form.find("[required],[required=ok]").each(function () { 2068 var value = $(this).val(); 2069 if (!value) { 2070 2071 } 2072 });*/ 2073 2074 data = $("form[name=user_data]").serialize(); 2075 2076 ajax_asynq( 2077 '/chk', 2078 function () { $("#user_data_REGISTRATION").attr("disabled", "disabled"); serversuccess('ÐодождиÑе, пожалÑйÑÑа. ÐÐ´ÐµÑ ÑегиÑÑÑаÑиÑ...', 0) }, 2079 function (response) { 2080 //$(form).find("[type=submit]").click(); 2081 login.addClass('ok').removeClass('error'); 2082 form.find('#valid').text('').hide(); 2083 2084 if (form.find("#user_data_user_answer").length > 0) 2085 ajax_asynq('/captcha', null, function (response) { 2086 bSubm.removeAttr("disabled"); 2087 if (response == 1) $(form).find("[type=submit]").trigger("click"); else servererror('ÐепÑавилÑно Ð²Ð²ÐµÐ´ÐµÐ½Ñ ÑÐ¸Ð¼Ð²Ð¾Ð»Ñ Ñ ÐºÐ°ÑÑинки!'); 2088 }, "answer=" + answer); 2089 else 2090 $(form).find("[type=submit]").trigger("click"); 2091 }, 2092 data, 2093 function (request, status, error) { 2094 var json = JSON.parse(request.responseText.trim()); 2095 var msgs = { "username": "ÐÑÐ¾Ñ Ð»Ð¾Ð³Ð¸Ð½ Ñже иÑполÑзÑеÑÑÑ Ð² ÑиÑÑеме. ÐведиÑе дÑÑгой.", "phone": "ÐÑÐ¾Ñ ÑелеÑон Ñже иÑполÑзÑеÑÑÑ Ð² ÑиÑÑеме. ÐведиÑе дÑÑгой." }; 2096 2097 for (var key in msgs) 2098 2099 if (json[key] == 1) { 2100 2101 2102 $(`#user_data_${key}`).removeClass('ok').addClass('error'); 2103 2104 $(`#user_data_${key}`).next('.valid').text(msgs[key]).show(); 2105 2106 SCROLL_TO($(document).find(".error").eq(0).parent().prev()); 2107 2108 } 2109 2110 2111 //login.next('.valid').text(msg).show(); 2112 $("#user_data_REGISTRATION").removeAttr("disabled"); 2113 serversuccess(""); 2114 } 2115 ); 2116} 2117 2118/*function submitlogin(event, bSubm, admin = 0) // ÑоÑма логина (Ñ ÑÐ¸Ð½Ñ ÑонизаÑией 2119// паÑолÑ) 2120{ 2121 2122 var data = {}; 2123 var form = $(document).find("#login_form"); 2124 var bSubm = $(bSubm); 2125 var login = form.find("input[data-type=login]"); 2126 $('#username').val($('#username').val().trim()); 2127 $('#password').val($('#password').val().trim()); 2128 event.preventDefault(); // пÑедоÑвÑаÑиÑÑ Ð¾Ð±ÑÑнÑй submit 2129 data["username"] = $('#username').val(); 2130 if (admin) // Ð°Ð´Ð¼Ð¸Ð½Ñ Ð½Ðµ надо ÑÐ¸Ð½Ñ ÑонизиÑоваÑÑ Ð¿Ð°ÑÐ¾Ð»Ñ 2131 { 2132 2133 $(bSubm).prop("disabled", true); 2134 ajax_asynq('/chk',null,function(){form.find("[type=submit]").click();},$(form).serialize(), function (request, status, error) { 2135 var msg = (request.responseText.trim() == "checked" ? 2136 'ÐÑÐ¾Ñ Ð»Ð¾Ð³Ð¸Ð½ Ñже иÑполÑзÑеÑÑÑ Ð² ÑиÑÑеме' 2137 : 2138 'ÐÑибка Ð²Ñ Ð¾Ð´Ð°. ÐопÑобÑйÑе еÑе Ñаз.' 2139 ) 2140 $(bSubm).prop("disabled", false); 2141 login.removeClass('ok').addClass('error'); 2142 login.next('.valid').text(msg).show(); 2143 2144 serversuccess(""); 2145 }); 2146 } 2147 else 2148 ajax_asynq( 2149 '/syncpsw', 2150 function () { serversuccess("Ð¡Ð¸Ð½Ñ ÑонизаÑÐ¸Ñ Ð´Ð°Ð½Ð½ÑÑ Ñ Ð¿Ð¾ÑÑÑолио..."); $(bSubm).attr("disabled", "disabled"); }, 2151 function () { 2152 serversuccess(""); 2153 form.submit(); 2154 }, 2155 data, 2156 function (request, status, error) { 2157 servererror("ÐÑибка Ð²Ñ Ð¾Ð´Ð°. ÐопÑобÑйÑе еÑе Ñаз."); 2158 $(bSubm).removeAttr("disabled"); 2159 } 2160 ); 2161}*/ 2162 2163 2164function submitlogin(event, bSubm, admin = 0) // ÑоÑма логина (Ñ ÑÐ¸Ð½Ñ ÑонизаÑией 2165// паÑолÑ) 2166{ 2167 var data = {}; 2168 var form = $(document).find("#login_form"); 2169 var bSubm = $(bSubm); 2170 var login = form.find("input[data-type=login]"); 2171 $('#username').val($('#username').val().trim()); 2172 $('#password').val($('#password').val().trim()); 2173 event.preventDefault(); // пÑедоÑвÑаÑиÑÑ Ð¾Ð±ÑÑнÑй submit 2174 data["username"] = $('#username').val(); 2175 if (admin) // Ð°Ð´Ð¼Ð¸Ð½Ñ Ð½Ðµ надо ÑÐ¸Ð½Ñ ÑонизиÑоваÑÑ Ð¿Ð°ÑÐ¾Ð»Ñ 2176 { 2177 form.find("[type=submit]").click(); 2178 $(bSubm).attr("disabled", "disabled"); 2179 } 2180 else 2181 ajax_asynq( 2182 '/syncpsw', 2183 function () { serversuccess("Ð¡Ð¸Ð½Ñ ÑонизаÑÐ¸Ñ Ð´Ð°Ð½Ð½ÑÑ Ñ Ð¿Ð¾ÑÑÑолио..."); $(bSubm).attr("disabled", "disabled"); }, 2184 function () { 2185 serversuccess(""); 2186 form.submit(); 2187 }, 2188 data, 2189 function (request, status, error) { 2190 servererror("ÐÑибка Ð²Ñ Ð¾Ð´Ð°. ÐопÑобÑйÑе еÑе Ñаз."); 2191 $(bSubm).removeAttr("disabled"); 2192 } 2193 ); 2194} 2195 2196 2197function clickrecoverybutton(bSubm) { 2198 var data = {}; 2199 var form = $(bSubm).closest("form"); 2200 var bSubm = $(bSubm); 2201 var mail = form.find("input[data-type=login]"); 2202 mail.val(mail.val().trim()); 2203 data["username"] = mail.val(); 2204 if (!emailValidation()) { 2205 if (mail.val()) form.find('#valid').text('ÐбÑаÑиÑеÑÑ Ðº ÑегиÑÑÑиÑÑÑÑÐµÐ¼Ñ Ð´Ð»Ñ Ð²Ð¾ÑÑÑÐ°Ð½Ð¾Ð²Ð»ÐµÐ½Ð¸Ñ Ð¿Ð°ÑолÑ').show(); 2206 return; 2207 } 2208 mail.removeClass('error').addClass('ok'); 2209 form.find('#valid').text('').addClass('d-n'); 2210 ajax_asynq( 2211 '/chk', 2212 function () { }, 2213 function (response) { 2214 mail.removeClass('ok').addClass('error'); 2215 form.find('#valid').text('Такого логина Ð½ÐµÑ Ð² ÑиÑÑеме').removeClass('d-n'); 2216 }, 2217 form.serialize(), 2218 function (request, status, error) { 2219 ajax_with_file( 2220 $(bSubm).closest("form").attr("id"), 2221 function () { 2222 $("#updated").hide(); 2223 $("#loading").show(); 2224 }, 2225 function () { 2226 $("#loading").hide(); 2227 $("#updated").slideDown(); 2228 } 2229 ); 2230 } 2231 ); 2232} 2233 2234function modalWin(header, _this) { 2235 var elem = $(_this); 2236 2237 var ajaxLink = elem.attr('editlink'); 2238 2239 $('#mini-modal .modal-title').html(header) 2240 2241 ajax_asynq( 2242 ajaxLink, 2243 function () { 2244 $('#mini-modal .modal-body').html(spinner); 2245 }, 2246 function (html) { 2247 $('#mini-modal .modal-body').html(html); 2248 class_nice(); 2249 uploading(); 2250 }, 2251 elem.attr("post") 2252 ); 2253 2254 elem.addClass('___active_window_caller___'); 2255 2256 $('#mini-modal').modal({ backdrop: 'static', keyboard: false }); 2257 2258 2259} 2260 2261 2262function sendformfrommodal( 2263 elem, 2264 beginmessage = "ÐодождиÑе, дейÑÑвие вÑполнÑеÑÑÑ...", 2265 endmessage = "ÐÑполнено!", 2266 errorcallback = function (request, status, error) { 2267 servererror(request, status, error) 2268 } 2269) { 2270 var form = $(elem).closest("form"); 2271 var flag = true; 2272 2273 form.find("[required],[required=ok]").each(function () { 2274 if (flag) { 2275 var input = $(this).closest("div"); 2276 var value = $(this).val(); 2277 /* 2278 * if(this.tagName=="SELECT" && $(this).hasClass("chosen")) { input = 2279 * $("#" + $(this).attr("id") + "_chosen"); } 2280 */ 2281 if (!value) { 2282 2283 flag = false;
2284 input.attr("title", $(this).attr("title")) 2285 .attr("data-placement", $(this).attr("data-placement")) 2286 .focus().tooltip('show'); 2287 $(".modal").animate({ scrollTop: input.get(0).offsetTop }, 500); 2288 2289 } 2290 2291 } 2292 }); 2293 form.find(".cketextarea[limited=ok]").each(function () { 2294 if (flag) { 2295 if (this.tagName == "TEXTAREA") { 2296 var ckeDiv = $("#cke_" + $(this).attr("id")); 2297 var ckeTop = ckeDiv.get(0).offsetTop; 2298 var ckeStringLength = CKEDITOR.instances[$(this).attr("id")].getData().length; 2299 var limit = $(this).attr('lmt'); 2300 var title = $(this).attr('title'); 2301 var dataPlacement = $(this).attr('data-placement'); 2302 var overlimit = ckeStringLength >= limit; 2303 var blank = $(this).attr('nonblank') == "ok" && ckeStringLength == 0; 2304 if (overlimit || blank) { 2305 flag = false; 2306 ckeDiv.attr("title", title).attr("data-placement", dataPlacement).focus().tooltip('show'); 2307 $(".modal").animate({ scrollTop: ckeTop }, 500); 2308 2309 } 2310 } 2311 } 2312 }); 2313 if (flag) { 2314 $(form).find(".cketextarea").each(function () { 2315 2316 var ckeinst = $(this).attr("id"); 2317 if (CKEDITOR.instances[ckeinst]) CKEDITOR.instances[ckeinst].updateElement(); 2318 2319 }); 2320 ajax_with_form( 2321 form, 2322 function () { 2323 $("div#onsendmessage").find("#___beginmessage").html(beginmessage); 2324 $("div#onsendmessage").show().next().hide(); 2325 $(".postupdate").html(spinner); 2326 $(elem).prop('disabled', true); 2327 }, 2328 function (response) { 2329 var firstresponse = response; 2330 var window_caller = $(".___active_window_caller___"); 2331 if (window_caller.length == 1) { 2332 if (window_caller.hasClass("add-button-norenew")) { 2333 $("div#onsentmessage").find("#___endmessage").html(endmessage); 2334 $("div#onsentmessage").slideDown().prev().hide(); 2335 $(elem).prop('disabled', false); fullresetform(form); 2336 return; 2337 } 2338 var itsEditButton = window_caller.hasClass("edit-button"); 2339 var itsAddButton = window_caller.hasClass("add-button"); 2340 if (itsEditButton || itsAddButton) { 2341 var renewlink = window_caller.attr("renew"); 2342 if (renewlink) { 2343 var editableid = window_caller.attr("editableitem"), editablebodies = false, 2344 editablefullbodies = false; 2345 2346 if (itsEditButton && editableid) { 2347 editablebodies = $(".resoursebody" + editableid); 2348 editablefullbodies = $(".fullresoursebody" + editableid); 2349 } 2350 if (itsEditButton || itsAddButton) { 2351 if (itsAddButton) { 2352 var idadded = firstresponse.replace(/[\n\r\s]/g, ''); 2353 var numeric = idadded.match(/\d+/g); 2354 if (numeric) renewlink = renewlink.replace(/(\[ID\])/g, idadded); 2355 } 2356 ajax_asynq( 2357 renewlink, 2358 function () { 2359 if (itsEditButton) console.log("обновление"); 2360 else if (itsAddButton) console.log("добавление"); 2361 if (itsEditButton) editablebodies.html(spinner); 2362 if (itsEditButton) editablefullbodies.html(spinner); 2363 }, 2364 function (response) { 2365 if (itsEditButton) { 2366 var slidehtml = $(response), bodyslide; 2367 slidehtml.find(".edit-button").first().addClass('___active_window_caller___'); 2368 bodyslide = slidehtml.find(".resoursebody" + editableid); 2369 editablebodies.replaceWith(bodyslide.clone(true, true)); 2370 editablefullbodies.replaceWith(slidehtml); 2371 } 2372 else if (itsAddButton) { 2373 var addtop = window_caller.hasClass("add-top"); 2374 var adddown = window_caller.hasClass("add-down"); 2375 if (addtop) 2376 added = window_caller.before(response).prev(); 2377 else if (adddown) 2378 added = window_caller.after(response).next(); 2379 SCROLL_TO(added); 2380 } 2381 }, 2382 {}, 2383 errorcallback 2384 ); 2385 } 2386 } 2387 } 2388 } 2389 $("div#onsentmessage").find("#___endmessage").html(endmessage); 2390 $("div#onsentmessage").slideDown().prev().hide(); 2391 $(elem).prop('disabled', false); 2392 if (itsAddButton) fullresetform(form); 2393 2394 $(".postupdate").html("ÐÑвеÑÑ ÑÐ¾Ñ ÑаненÑ"); // Ð´Ð»Ñ Ð¾ÑвеÑов ÑеÑÑа 2395 }, 2396 {}, 2397 errorcallback 2398 2399 ); 2400 return; 2401 } 2402} 2403 2404 2405function startSlidingProcess() { 2406 slidingProcess = true; 2407} 2408function stopSlidingProcess() { 2409 slidingProcess = false;
2410} 2411function sliding() { 2412 return slidingProcess; 2413} 2414// ФÑнкÑÐ¸Ñ Ð¿Ð¾Ð´Ð³ÑÑзки Ñлайдов. ÐÑи пÑомоÑке подгÑÑÐ¶Ð°ÐµÑ ÑлайдÑ, еÑли они еÑÑÑ Ð¸ 2415// еÑли они еÑÑ Ð½Ðµ бÑли подгÑÑÐ¶ÐµÐ½Ñ 2416function slide(to) { 2417 // alert("ÐеÑемоÑка Ñ Ð¿Ð¾Ð´Ð³ÑÑзкой Ñлайдов"); 2418 $currentIdent = $("#big-modal .carousel-inner div.item.active").attr("slide-identificator"); 2419 if (to == "prev") { 2420 // alert("ÐоÑаем назад"); 2421 add_right_narrow(); 2422 $prevSlidesNum = $("#big-modal .carousel-inner div.item.active[slide-identificator=" + $currentIdent + "]").prev().prev().length; 2423 2424 if (!$prevSlidesNum) { 2425 // alert("ÐÑедÑдÑÑие ÑÐ»Ð°Ð¹Ð´Ñ Ð½Ðµ бÑли еÑÑ Ð¿Ð¾Ð´Ð³ÑÑженÑ. СейÑÐ°Ñ Ð¿ÑовеÑим, 2426 // имеÑÑÑÑ Ð»Ð¸ они вообÑе"); 2427 $prevPrevDivLink = $("div[identificator=" + $currentIdent + "]").prev().prev().attr("more"); 2428 if ($prevPrevDivLink) { 2429 // alert("ÐÑÑÑ ÐµÑÑ Ð¿ÑедÑдÑÑие ÑлайдÑ, подгÑÑжаем Ð¸Ñ "); 2430 $prevPrevDivIdent = $("div[identificator=" + $currentIdent + "]").prev().prev().attr("identificator"); 2431 ajax_asynq( 2432 $prevPrevDivLink, 2433 function () { 2434 $("#big-modal .carousel-inner").prepend('<div slide-identificator="' + $prevPrevDivIdent + '" class="item"></div>'); 2435 }, 2436 function (html) { 2437 $("div[slide-identificator=" + $prevPrevDivIdent + "]").html(html); 2438 } 2439 ); 2440 2441 } else {/* alert("ÐÑедÑдÑÑÐ¸Ñ Ñлайдов болÑÑе неÑ"); */remove_left_narrow(); } 2442 }// else alert("ÐÑедÑдÑÑие неÑколÑко Ñлайдов Ñже бÑли подгÑÑженÑ"); 2443 } 2444 if (to == "next") { 2445 // alert("ÐоÑаем впеÑÑд"); 2446 add_left_narrow(); 2447 $nextSlidesNum = $("#big-modal .carousel-inner div.item.active[slide-identificator=" + $currentIdent + "]").next().next().length; 2448 if (!$nextSlidesNum) { 2449 // alert("СледÑÑÑие ÑÐ»Ð°Ð¹Ð´Ñ Ð½Ðµ бÑли еÑÑ Ð¿Ð¾Ð´Ð³ÑÑженÑ. СейÑÐ°Ñ Ð¿ÑовеÑим, 2450 // имеÑÑÑÑ Ð»Ð¸ они вообÑе"); 2451 $nextNextDivLink = $("div[identificator=" + $currentIdent + "]").next().next().attr("more"); 2452 if ($nextNextDivLink) { 2453 // alert("ÐÑÑÑ ÐµÑÑ ÑледÑÑÑие ÑлайдÑ, подгÑÑжаем Ð¸Ñ "); 2454 $nextNextDivIdent = $("div[identificator=" + $currentIdent + "]").next().next().attr("identificator"); 2455 ajax_asynq( 2456 $nextNextDivLink, 2457 function () { 2458 $("#big-modal .carousel-inner").append('<div slide-identificator="' + $nextNextDivIdent + '" class="item"></div>'); 2459 }, 2460 function (html) { 2461 $("div[slide-identificator=" + $nextNextDivIdent + "]").html(html); 2462 } 2463 ); 2464 } else {/* alert("СледÑÑÑÐ¸Ñ Ñлайдов болÑÑе неÑ"); */remove_right_narrow(); } 2465 }// else alert("СледÑÑÑие неÑколÑко Ñлайдов Ñже бÑли подгÑÑженÑ"); 2466 } 2467 2468} 2469 2470function confirm_modal(msgtype, btnYes, btnNo, callback) { 2471 msg = definedmsg[msgtype]; 2472 bootbox.confirm({ 2473 message: msg, 2474 buttons: { 2475 cancel: { 2476 label: btnNo, 2477 className: 'btn-danger pull-right' 2478 }, 2479 confirm: { 2480 label: btnYes, 2481 className: 'btn-success pull-left' 2482 } 2483 2484 }, 2485 callback: function (result) { 2486 if (result) callback(); 2487 } 2488 }); 2489 2490} 2491 2492function confirm_modal2(msg, btnYes, btnNo, callback) { 2493 2494 bootbox.confirm({ 2495 message: msg, 2496 centerVertical: true, 2497 buttons: { 2498 cancel: { 2499 label: btnNo, 2500 className: 'btn-danger pull-right' 2501 }, 2502 confirm: { 2503 label: btnYes, 2504 className: 'btn-success pull-left' 2505 } 2506 2507 }, 2508 callback: function (result) { 2509 if (result) callback(); 2510 } 2511 }); 2512 2513} 2514 2515function confirm_modal3(link, btnYes = "OK", btnNo = "Ðазад", callback = function () { }, data = null) { 2516 event.preventDefault(); 2517 bootbox.confirm({ 2518 message: curl(link, data), 2519 buttons: { 2520 cancel: { 2521 label: btnNo, 2522 className: 'btn-danger pull-right' 2523 }, 2524 confirm: { 2525 label: btnYes, 2526 className: 'btn-success pull-left' 2527 } 2528 2529 }, 2530 callback: function (result) { 2531 if (result) { 2532 return callback(); 2533 } 2534 } 2535 }); 2536 //$(".modal-dialog").css('width','90%'); 2537 2538 if (btnYes === false) $("[data-bb-handler=confirm]").addClass('d-n'); 2539 if (btnNo === false) $("[data-bb-handler=cancel]").addClass('d-n'); 2540 2541} 2542 2543 2544function close_modal(identificator = "undefined") { 2545 $('#big-modal').modal("hide"); 2546} 2547 2548 2549function show_modal(elem, one = false, url = "", options = { backdrop: 'static', keyboard: false }) { 2550 2551 elem = one ? $(elem) : $(elem).closest("div.infoblock"); 2552 2553 $thisLink = (url ? url : $(elem).attr("more")); 2554 $post = $(elem).attr("post"); 2555 $thisIdent = $(elem).attr("identificator"); 2556 2557 // загÑÑзиÑÑ ÑоÑедние ÑÑÐµÐ¹Ð¼Ñ 2558 $prevLink = (one ? false : $(elem).prev().attr("more")); 2559 $nextLink = (one ? false : $(elem).next().attr("more")); 2560 2561 $prevIdent = $(elem).prev().attr("identificator"); 2562 $nextIdent = $(elem).next().attr("identificator"); 2563 2564 $("#big-modal .carousel-inner").html(""); 2565 2566 $("#big-modal .carousel-inner").attr("more", $thisLink); 2567 // alert("ÐаÑинаеÑÑÑ Ð¿Ð¾Ð´Ð³ÑÑзка новоÑÑей"); 2568 2569 $(".cross-modal-close").click(function(){ 2570 console.log('closed'); 2571 }); 2572 2573 if ($thisLink) { 2574 ajax_asynq( 2575 $thisLink, 2576 function () { 2577 $("#big-modal .carousel-inner").html(spinner); 2578 // <i class="fa fa-spinner fa-spin fa-2x"></i> 2579 }, 2580 function (html) { 2581 $("#big-modal .carousel-inner").html(""); 2582 $("#big-modal .carousel-inner").append('<div slide-identificator="' + $thisIdent + '" class="item active"><div class=animated></div></div>'); 2583 $("div[slide-identificator=" + $thisIdent + "] div.animated").html(html); 2584 $("div[slide-identificator=" + $thisIdent + "] div.animated").show(400, 'swing'); 2585 if ($prevLink) { 2586 ajax_asynq( 2587 $prevLink, 2588 function () { 2589 $("#big-modal .carousel-inner").prepend('<div slide-identificator="' + $prevIdent + '" class="item"></div>'); 2590 add_left_narrow(); 2591 }, 2592 function (html) { 2593 $("div[slide-identificator=" + $prevIdent + "]").html(html); 2594 } 2595 ); 2596 } 2597 if ($nextLink) { 2598 ajax_asynq( 2599 $nextLink, 2600 function () { 2601 $("#big-modal .carousel-inner").append('<div slide-identificator="' + $nextIdent + '" class="item"></div>'); 2602 add_right_narrow(); 2603 }, 2604 function (html) { 2605 $("div[slide-identificator=" + $nextIdent + "]").html(html); 2606 } 2607 ); 2608 } 2609 class_nice(); 2610 uploading(); 2611 }, 2612 $post 2613 ); 2614 // alert("СейÑÐ°Ñ Ð¾ÑкÑоеÑÑÑ Ð¾ÐºÐ½Ð¾"); 2615 2616 if ($thisLink) $('#big-modal').modal(options); 2617 2618 2619 // alert("Ðкно оÑкÑÑлоÑÑ"); 2620 2621 } 2622} 2623 2624function show_modal_slide(elem, id, event) { // вÑвод конкÑеÑного Ñлайда 2625 2626 infoblock = $(elem).closest("div.infoblock"); 2627 2628 var oldmore = $(infoblock).attr("more"); 2629 2630 $(infoblock).attr("more", "/main/lenta/info/id=" + id + "/"); 2631 2632 show_modal(elem, event); 2633 2634 $(infoblock).attr("more", oldmore); 2635} 2636 2637 2638function check_narrows() { 2639 // alert("ÐÑовеÑка ÑÑÑелок"); 2640 2641 if ($("#big-modal div.item:first").hasClass("active")) { 2642 $("a.left-narrow").removeClass("otk_str"); 2643 } 2644 else 2645 $("a.left-narrow").addClass("otk_str"); 2646 if ($("#big-modal div.item:last").hasClass("active")) { 2647 $("a.right-narrow").removeClass("otk_str"); 2648 } 2649 else 2650 $("a.right-narrow").addClass("otk_str"); 2651 2652} 2653function add_left_narrow() { 2654 // alert("ÐобавлÑем левÑÑ ÑÑÑелкÑ"); 2655 $("a.left-narrow").addClass("otk_str"); 2656} 2657function add_right_narrow() { 2658 // alert("ÐобавлÑем пÑавÑÑ ÑÑÑелкÑ"); 2659 $("a.right-narrow").addClass("otk_str"); 2660} 2661function remove_left_narrow() { 2662 // alert("УдалÑем левÑÑ ÑÑÑелкÑ"); 2663 $("a.left-narrow").removeClass("otk_str"); 2664} 2665function remove_right_narrow() { 2666 // alert("УдалÑем пÑавÑÑ ÑÑÑелкÑ"); 2667 $("a.right-narrow").removeClass("otk_str"); 2668} 2669 2670 2671function alertObject(obj) { 2672 for (var key in obj) { 2673 alert('key: ' + key + '\n' + 'value: ' + obj[key]); 2674 if (typeof obj[key] === 'object') { 2675 alertObject(obj[key]); 2676 } 2677 } 2678} 2679 2680 2681 2682function ajax_with_message(script, start, end) { 2683 $.ajax({ 2684 url: script, 2685 cache: false, 2686 beforeSend: function (html) { $(".plup_msg").html(start); $(".plup_fade,.plup_msg").fadeIn(500); }, 2687 success: function (html) { $(".plup_msg").html(end); setTimeout(function () { $(".plup_fade,.plup_msg").fadeOut(1000) }, 2000); } 2688 }); 2689} 2690function ajax_with_file(form, start = function () { }, end = function () { }) { 2691 $$f({ 2692 formid: form, 2693 url: $("#" + form).attr("action"), 2694 onstart: start, 2695 onsend: end 2696 }); 2697 2698} 2699 2700function curl( 2701 script, 2702 data = {} 2703) { 2704 var result = ""; 2705 $.ajax({ 2706 url: script, 2707 type: "POST", 2708 data: data, 2709 async: false, 2710 cache: false, 2711 beforeSend: function () { }, 2712 success: function (html) { result = html; }, 2713 error: function (html) { result = ""; } 2714 }); 2715 2716 return result.trim(); 2717} 2718 2719function ajax_synq( 2720 script, 2721 start = function () { }, 2722 end = function () { }, 2723 data = {}, 2724 error = function (request, status, error) { 2725 servererror(request, status, error) 2726 } 2727) { 2728 $.ajax({ 2729 url: script, 2730 type: "POST", 2731 data: data, 2732 async: false, 2733 cache: false, 2734 beforeSend: start, 2735 success: end, 2736 error: error 2737 }); 2738 2739 return 2740} 2741 2742function ajax_with_form(form, start = function () { }, end = function () { }, error = function (request, status, error) { 2743 servererror(request, status, error) 2744}) { 2745 $.ajax({ 2746 type: "POST", 2747 url: $(form).attr("action"), 2748 cache: false, 2749 data: $(form).serialize(), 2750 beforeSend: start, 2751 success: end, 2752 error: error 2753 }); 2754} 2755function ajax_return(script, p1, p2, p3) { 2756 var r; 2757 $.ajax({ 2758 async: false, 2759 type: "POST", 2760 url: script, 2761 cache: false, 2762 data: { p1: p1, p2: p2, p3: p3 }, 2763 success: function (html) { 2764 r = html; 2765 } 2766 }); 2767 return r; 2768} 2769 2770function ajax_return_trim(script, p1, p2) { 2771 var r; 2772 $.ajax({ 2773 async: false, 2774 type: "POST", 2775 url: script, 2776 cache: false, 2777 data: { p1: p1, p2: p2 }, 2778 success: function (html) { 2779 r = html; 2780 r = r.replace(/[\n\r\s]/g, ''); 2781 } 2782 }); 2783 return r; 2784} 2785function PHP_END_FUNCTION(script, key, val, func = function () { }) { 2786 var arr = {}; 2787 arr[key] = val; 2788 $.ajax({ 2789 async: false, 2790 type: "POST", 2791 url: script, 2792 cache: false, 2793 data: arr, 2794 success: func 2795 }); 2796} 2797 2798//пÑокÑÑÑка вниз 2799function scrolldown(elem) { 2800 elem.scrollTop(elem.prop('scrollHeight')); 2801} 2802 2803function scrollright() { 2804 $(window).scrollRight($(window).scrollRight() + 150); 2805} 2806 2807 2808function SCROLL_TO(elem, source = "body,html") { 2809 if (elem.length == 1) { 2810 console.log("ÐоÑаем"); 2811 //alert("ÐоÑаем"); 2812 //alert('ssss'); 2813 2814 var destination = elem.offset().top - 1000; 2815 var hiddenElement = document.getElementById("box"); 2816 $(elem).get(0).scrollIntoView(); 2817 //$(source).animate({ scrollTop: destination }, 800); 2818 } 2819} 2820 2821 2822function preview(field, image) { 2823 console.log("n=" + $(field).length); 2824 $(field).change(function () { 2825 var input = $(this)[0]; 2826 if (input.files && input.files[0]) { 2827 if (input.files[0].type.match('image.*')) { 2828 var reader = new FileReader(); 2829 reader.onload = function (e) { $(image).attr('src', e.target.result); }
2830 reader.readAsDataURL(input.files[0]); 2831 } 2832 else { 2833 console.log('ÐагÑÑжено не изобÑажение'); 2834 } 2835 2836 } 2837 else 2838 console.log('Ðе бÑло загÑÑжено Ñайлов либо API не поддеÑживаеÑÑÑ'); 2839 }); 2840} 2841 2842function captcha() // вÑвод капÑи 2843{ 2844 ajax_asynq( 2845 "/captcha", 2846 function () { $('.captcha').html(spinner) }, 2847 function (src) { $('.captcha').attr("src", src); } 2848 ); 2849} 2850 2851function testanswers(key = 0, id = "new", title = "", checked = "", elem = null) // ваÑианÑÑ 2852// оÑвеÑа 2853// Ð´Ð»Ñ 2854// ÑеÑÑа 2855// (добавление 2856// Ñдаление 2857// полей) 2858{ 2859 if (elem) { 2860 var val = $(elem).closest(".myAnswer-admin").children("input:hidden").val(); 2861 // console.log($(elem).closest(".myAnswer").children(".hid").html()); 2862 $(elem).closest(".myAnswer-admin").children("input:hidden").val(-1 * val); 2863 // console.log($(elem).closest(".myAnswer").children(".hid").html()); 2864 $(elem).closest(".myAnswer-admin").css("display", "none"); 2865 2866 } 2867 else { 2868 if (!key) key = $(".myAnswer-admin").length; 2869 2870 $(".myAnswers-admin").append("<div class=myAnswer-admin><input type=hidden id=id_" + key + " name=id_" + key + " value=" + id + "><input type=radio " + checked + " value=" + key + " id=correct_" + key + " name=correct><input type=text id=question_" + key + " name=question_" + key + " class='form-control d-i-b v-a-t' value='" + title + "'><a onclick=testanswers(0,0,'','',this) class=btn btn-alert>X</a></div>"); 2871 } 2872 2873} 2874 2875function finishtest(division, test) // ваÑианÑÑ Ð¾ÑвеÑа Ð´Ð»Ñ ÑеÑÑа (добавление 2876// Ñдаление полей) 2877{ 2878 var data = ""; // post data 2879 if ($(".finishtest").hasClass("finished")) return 0; // еÑли ÑеÑÑ Ñже 2880 // завеÑÑен 2881 $(".myAnswer > input:radio:checked").each(function (key, value) { 2882 data += (data ? "&" : "") + "answer_" + key + "=" + $(this).val(); 2883 } 2884 ); 2885 2886 ajax_asynq( 2887 "/me/" + division + "tests/" + test + "/check", 2888 function () { $(".finishtest").html(spinner); }, 2889 function (data) { 2890 data = JSON.parse(data); 2891 if (isNaN(data["score"])) 2892 $(".finishtest").html("ÐÑибка завеÑÑÐµÐ½Ð¸Ñ ÑеÑÑа. ÐопÑобÑйÑе еÑе Ñаз."); 2893 else { 2894 $(".finishtest").html("ÐÐ°Ñ ÑезÑлÑÑаÑ: " + data["score"] + " б."); 2895 $(".finishtest").addClass("finished"); 2896 prompt(true); 2897 } 2898 }, 2899 data 2900 ); 2901 2902 return 0; 2903 2904} 2905 2906function blockmodal() // блокиÑÑÑÑее модалÑное окно 2907{ 2908 /*ajax_asynq("/session/control"); 2909 2910 setInterval(function () { ajax_asynq("/session/control") }, 30000); 2911 2912 $(".blockmodal.on").each(function () { 2913 if ($(this).attr("more").trim() == "") return; 2914 2915 countdown("ÐÑоÑмоÑÑ ÑайÑа бÑÐ´ÐµÑ Ð´Ð¾ÑÑÑпен ÑеÑез {sec} Ñек.", $(this).attr("time")); 2916 2917 show_modal($(this), true, "", { backdrop: 'static', keyboard: false }); 2918 $(".cross-modal-close").hide(); 2919 // оÑклÑÑиÑÑ Ð²Ð¾Ð·Ð¼Ð¾Ð¶Ð½ÑÑÑ Ð·Ð°ÐºÑÑÑÐ¸Ñ 2920 } 2921 );*/ 2922} 2923 2924function popup() // вÑплÑваÑÑее окно 2925{ 2926 return; 2927 $(".popup.on").each(function () { 2928 if ($(this).attr("more").trim() == "") return; 2929 2930 show_modal($(this), true); 2931 } 2932 ); 2933 //initialization(); 2934} 2935 2936//полÑÑиÑÑ Ð¿ÑÑи 2937function getPushes() { 2938 return; 2939 return JSON.parse(curl("/myservice/reg/getPushes/")); 2940} 2941 2942//пÑовеÑиÑÑ ÑÑаÑÑÑ 2943function checkstatus() { 2944 return curl("/myservice/reg/getModal/", "passport=" + $("input.passport").val()); 2945} 2946 2947function prompt($force = false) // вÑплÑваÑÑÐ°Ñ Ð¿Ð¾Ð´Ñказка 2948{ 2949 //return; 2950 /*$(".prompt.on").each(function () { 2951 if ($(this).attr("msg").trim() == "") return; 2952 var redirect = $(this).attr("redirect"); 2953 var passport = $(this).attr("passport"); 2954 confirm_modal2($(this).attr("msg"), "OK", "Ðазад", function () {ajax_asynq(`/session/modal:${passport}`,null,function(){location.href = redirect;}); }); 2955 } 2956 );*/ 2957 2958 if (window.location.href.includes('admin')) return; 2959 2960 var passport = $("input.passport").val(); 2961 2962 var result = checkstatus(); 2963 2964 var pushes = getPushes(); 2965 2966 if (pushes) $.each(pushes, function (key, value) { 2967 //console.log(value["Msg"]); 2968 displayNotification(value["Msg"], { data: { 'link': value["Link"] } }); 2969 curl("/myservice/reg/addPush/", `id=${key}`); 2970 }); 2971 2972 result = JSON.parse(result); 2973 2974 // 2975 2976 _this = $(".prompt"); 2977 2978 //if ($(_this).attr("msg").trim() == "") return; 2979 $(".hintitem").each( 2980 function () { 2981 //displayNotification('123'); 2982 var status = result[$(this).attr("passport")]["status"]; 2983 var redirect = result[$(this).attr("passport")]["redirect"]; 2984 var msg = result[$(this).attr("passport")]["msg"]; 2985 $(this).html(`<a href='${redirect}'>${msg}</a>`); 2986 2987 if (status && status != $(this).attr("status")) { 2988 2989 $(this).attr("status", status); // бÑло ли изменение ÑÑаÑÑÑа 2990 displayNotification(msg, { data: { 'link': redirect } }); 2991 //confirm_modal2(msg, "OK", "Ðазад", function () {location.href = redirect;}); 2992 } 2993 2994 }); 2995 2996 //initialization(); 2997} 2998 2999function entity() // виджеÑÑ 3000{ 3001 $(".entity").each(function () { 3002 var link = "/json"; 3003 var _this = this; 3004 ajax_asynq( 3005 link, 3006 function () { $(_this).html(spinner); }, 3007 function (data) { 3008 3009 } 3010 ); 3011 "entity=" + $(this).attr("entity") + "&filter=user&field=" + $(this).attr("field"), 3012 function () { 3013 console.log("widget error"); 3014 } 3015 } 3016 ); 3017} 3018 3019function infowidgets(_class = "", _spinner = true) // виджеÑÑ 3020{ 3021 //event.preventDefault(); 3022 $(`.infowidget${_class}`).each(function () { 3023 var link = $(this).attr("link"); 3024 var _this = this; 3025 if (!link || !link.trim().length || ($(this).hasClass("authonly") && !$("input.session").val())) return; 3026 if ($(this).attr("type") && $(this).attr("type") != $("input.usertype").val()) return; 3027 ajax_asynq( 3028 link, 3029 function () { if (_spinner) $(_this).html(spinner); }, 3030 function (html) { 3031 $(_this).html(html.indexOf("notfound") == -1 ? html : ""); 3032 class_nice(); 3033 //$(".chatmain").focus(); 3034 //autoscroll($(".chatmain").eq(0)); 3035 //SCROLL_TO($(".chatitem").last(),$(".chatmain")); 3036 }, 3037 $(this).attr("post") + "&passport=" + $('.passport').val(), 3038 function () { 3039 console.log("widget error"); 3040 } 3041 ); 3042 3043 } 3044 ); 3045} 3046 3047function renew() // обновление ÑлеменÑа 3048{ 3049 //event.preventDefault(); 3050 $(`.renewable`).each(function () { 3051 var link = $(this).attr("link"); 3052 var _this = this; 3053 ajax_asynq( 3054 link, 3055 function () { $(_this).html(spinner); }, 3056 function (html) { 3057 $(_this).html(html); 3058 } 3059 ); 3060 } 3061 ); 3062} 3063 3064function columnsum(elems, attr = "") // ÑÑмма ÑлеменÑов 3065{ 3066 var total = 0; 3067 $(elems).each(function () { 3068 total += parseInt(attr ? (attr == "value" ? $(this).val() : $(this).attr(attr)) : parseInt($(this).text())); 3069 }); 3070 // console.log(total); 3071 return total; 3072 3073} 3074 3075function countdown(msg, time = 30) // ÑÐ°Ð¹Ð¼ÐµÑ ÑÐ»ÐµÐ¼ÐµÐ½Ñ 3076{ 3077 time = (isNaN(time) ? 30 : time); 3078 msg = msg.replace("{sec}", time); 3079 var tID = setInterval(function () { if (!time) { clearInterval(tID); ajax_asynq("/session/reset"); $('#big-modal').data('bs.modal').options.backdrop = false; $('#big-modal').data('bs.modal').options.keyboard = true; serversuccess(); $(".cross-modal-close").show(); } else { msg = msg.replace(time, time - 1);/*serversuccess(msg,0);*/time--; } }, 1000); 3080} 3081 3082 3083//заполниÑÑ html ÑлеменÑÑ Ð¿Ð¾Ð»Ñми из json 3084function json_html(json, _class = ".dbfield") { 3085 //var json = JSON.parse(data); 3086 if (json.length == 0) return false;
3087 $(_class).each(function (key) { 3088 if ($(this).prop("tagName").toLowerCase() == "input") 3089 $(this).val(json[$(this).attr("id")]); 3090 else 3091 $(this).text(json[$(this).attr("id")]); 3092 }); 3093 3094 return true; 3095 3096 3097} 3098 3099 3100//паÑамеÑÑÑ Ð¾ÑобÑÐ°Ð¶ÐµÐ½Ð¸Ñ 3101function json_params() { 3102 3103 return; 3104 ajax_asynq("/myservice/project/getButtons/", function () { }, 3105 function (json) { 3106 json = JSON.parse(json); 3107 //json_html(json, ".parse"); 3108 $(".substitute").each(function (key) { 3109 $(this).text(json[$(this).attr("from")].trim() != "" ? json[$(this).attr("from")] : $(this).text()); 3110 }); 3111 3112 //json_html(json,".parse"); 3113 } 3114 ); 3115} 3116 3117function save_as_pdf() { 3118 3119 var doc = new jsPDF($("#orientation").val() ? "landscape" : "portrait"); 3120 var options = {}; 3121 var page = $('.a4').get(0); 3122 3123 doc.addHTML(page, 0, 0, options, function () { doc.save('a4-award.pdf') }); 3124 //doc.text('Hello world!', 10, 10); 3125} 3126 3127//ÑедиÑÐµÐºÑ 3128function redirect($class = "") { 3129 //console.log($class); 3130 var url = $('.myredirect' + $class).val(); 3131 if (url === undefined) return; 3132 location.href = url; 3133} 3134 3135function mustache(obj, attr) { 3136 return $(obj).attr(attr).replace(/{{([^]+)}}/, function (a, b) { 3137 return eval(b).trim(); 3138 }); 3139} 3140 3141//полÑÑиÑÑ Ð°ÑÑÑибÑÑÑ 3142function jqattrs($class, $attr, $unique = false) { 3143 var $attr = $attr; 3144 var $result = $($class).map(function () { 3145 return $(this).attr($attr); 3146 }).get(); 3147 return $unique ? jQuery.unique($result) : $result; 3148} 3149 3150 3151//ÑаблиÑа из json 3152function json_table(data, container = "body") { 3153 /*var data = '{"aaa":{"xxx":111,"yyy":222,"zzz":333},"bbb":{"xxx":444,"yyy":555,"zzz":666},"ccc":{"xxx":777,"yyy":888,"zzz":999}}';*/ 3154 //["field1"=>"value1","field2"=>"value2"]; 3155 var json = JSON.parse(data); 3156 var headers = false; 3157 var nodata = $('<div><h4>ÐÐ ÐÐÐÐÐÐÐ</h4></div>'); 3158 var table = $('<table>'); 3159 var thead = $('<thead>'); 3160 var tbody = $('<tbody>'); 3161 var total = json.length; 3162 if (total == 0) { 3163 nodata.appendTo(container); 3164 return true; 3165 } 3166 $.each(json, function (index1, value1) { 3167 3168 var tr = $('<tr>'); 3169 $("<th>" + index1 + "</th>").appendTo(tr); 3170 if (!headers) { $("<th>ÐСÐÐÐ: " + total + "</th>").appendTo(thead); } 3171 $.each(value1, function (index2, value2) { 3172 if (!headers) { $("<th>" + index2 + "</th>").appendTo(thead); } 3173 $("<td>" + value2 + "</td>").appendTo(tr); 3174 }); 3175 headers = true; 3176 tr.appendTo(tbody); 3177 }); 3178 3179 thead.appendTo(table); 3180 tbody.appendTo(table); 3181 table.appendTo(container); 3182 return true; 3183} 3184 3185 3186
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.