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