PageSourceSearch

https://centerstart.ru/themes/new_start/js/main.js?v=10.1.0

js centerstart.ru collected 2026-10-02 04:58:11 UTC 20,289 bytes, 605 lines download raw bytes

1var $ = jQuery.noConflict();
2// function OnLoadFunction(){
3//   $( ".view-filters" ).nextAll().addBack().wrapAll( "<div class='nsmp_wrapper' />" );
4//   $( ".view-filters" ).wrap( "<div class='filters' />" );
5//   $( ".filters" ).nextAll().wrapAll( "<div class='news_content' />" );
6// }
7// $( document ).ready(OnLoadFunction);
8
9if(window.location.pathname === '/calendar' && ((drupalSettings.path.currentQuery === undefined) ||
10  !(drupalSettings.path.currentQuery.field_tip_materiala_value === 'Новости' || 
11  drupalSettings.path.currentQuery.field_tip_materiala_value === 'Мероприятия'))){
12  window.location.href = 'http://drupal10.ru/calendar?field_tip_materiala_value=Новости'
13}
14
15function arrowUp(){
16  let arrowElement = document.querySelector('#block-new-start-strelkavverkh')
17  let appended = false
18
19  window.onscroll = function() {
20    let scrollTop = document.body.parentNode.scrollTop
21
22    if( scrollTop > 0 ){
23      if (!appended) {
24        arrowElement.classList.remove('dispnone');
25        appended = true;        
26      }
27    }
28    else{
29      if (appended) {
30        arrowElement.classList.add('dispnone');
31        appended = false;
32      } 
33    }
34  }
35  arrowElement.onclick = function(){
36    document.body.parentNode.scrollTop = 0
37  }
38}
39window.onresize = callFullWindowMenu
40//Вызов меню во весь экран, при нажатии на изображение 3 палочки
41//По совместительству является основным мобильным меню 
42function callFullWindowMenu(){
43  let menuButton = document.querySelectorAll('.full-menu')
44  let closeMenuButton = document.querySelectorAll('.close-full-menu')
45  let fullMenu = document.querySelector('.region-full-menu')
46  let logo = document.querySelector('.mob_logo')
47  let firstText = document.querySelector('.polosatxt')
48  let secondText = document.querySelector('.polosa_menu_txt')
49  let windowWidth = window.innerWidth 
50
51  menuButton.forEach((el)=>{
52    el.onclick = function(e){ 
53      logo.classList.remove('dispnone')
54      logo.classList.remove('mob_logo_dispnone')
55      windowWidth<768 || firstText.classList.add('dispnone')
56      secondText.classList.remove('dispnone')
57      fullMenu.classList.add('open-full-page-menu')
58
59      document.querySelector('html').classList.add('overflow_hidden')
60      if(windowWidth < 768){
61        closeMenuButton[0].classList.remove('dispnone')
62        menuButton[0].classList.add('dispnone')
63      }
64      else{
65        closeMenuButton[1].classList.remove('dispnone')
66      }
67  }})
68  closeMenuButton.forEach((el)=>{
69    el.onclick = function(e){
70      if(windowWidth < 768){ 
71        closeMenuButton[0].classList.add('dispnone')
72        menuButton[0].classList.remove('dispnone')
73      }
74      else{
75        closeMenuButton[1].classList.add('dispnone')
76      }
77      document.querySelector('html').classList.remove('overflow_hidden')
78      fullMenu.classList.remove('open-full-page-menu')
79      secondText.classList.add('dispnone')
80      windowWidth<768 || firstText.classList.remove('dispnone')
81      logo.classList.add('mob_logo_dispnone')
82      logo.classList.add('dispnone')
83  }})
84}
85
86//Вызов логин панели по клику на картинку силуэта в правом верхнеми углу
87function callLoginPanel(){
88  let loginPanel = document.querySelector('.region-login-page')
89  //querySelectorAll по причине наличия 2 одинаковых кнопок на сайте, в мобильной и полной версии
90  let loginButton = document.querySelectorAll('.login_window')
91  let loginWindow = document.querySelector('.region-login-page')
92
93  loginButton.forEach((button)=>{
94      button.onclick = function(){
95      loginPanel.classList.remove('dispnone')
96    }
97  })
98
99  if(loginPanel){
100    loginPanel.onclick = function(e){
101      if(e.target === loginPanel){
102        loginPanel.classList.add('dispnone')
103      }
104    }
105  }
106}
107
108
109//Дает ссылку для Div элементов на главной
110//Сделано по причине устаревшей версии html в ядре и чтобы не городить кучи <a /> блоков
111function hrefForDiv() {
112  
113  document.querySelectorAll(".block_button .div_href").forEach((el) => {
114    el.addEventListener(
115      "mousedown",
116      (e) => {
117        (e.button === 0) && (location.href = el.getAttribute("href"));
118        (e.button === 1) && (window.open(el.getAttribute("href")));
119      }
120    );
121  });
122}
123
124
125
126function clearFilters(){
127  let clearButton = document.querySelector('.clear-filters')
128  if(clearButton){
129    clearButton.addEventListener("click", ()=>window.location.search = '')
130  }
131}
132
133$(document).ready(function () {
134  
135  AjaxInit();
136  metodicFilters();
137  hrefForDiv(); 
138  createCalendar();
139  itemsOnPage();
140  callLoginPanel();
141  callFullWindowMenu();
142  if (document.querySelector(".fw")) {
143    footerPosition();
144  }
145  collapser();
146  arrowUp();
147  clearFilters();
148  console.log(drupalSettings.allNewsDates)
149});
150
151$(document).ajaxComplete(function () {
152  AjaxInit();
153  hrefForDiv();
154  
155  createCalendar();
156  collapser();
157  itemsOnPage();
158  clearFilters();
159});
160
161
162
163//переписал работу фильтров на странице методические материалы и school
164//для того чтобы создать ссылку с переходом на страницу с включенными фильтрами 
165function metodicFilters(){
166  let locator = window.location
167  if((locator.pathname.includes('metodic') || locator.pathname.includes('school')) && locator.search !== ''){
168    
169    let filtersArray = []
170    let filters = locator.search.slice(1,).split('&').map((el)=>{
171      if(Number.isInteger(Number(el))){
172        filtersArray.push(Number(el));
173      }
174      else if(Number.isInteger(Number(el.slice(0, el.indexOf('='))))){
175        filtersArray.push(Number(el.slice(0, el.indexOf('='))))
176      }
177    })
178
179    filtersArray.forEach((el)=>{
180        document.querySelectorAll(".form-checkbox")[el].checked = true
181        //document.querySelectorAll(".form-checkbox")[el].click() в таком решении проблема заключается в том, что галочки все ставятся сразу, а ajax в drupal засчитывает не все сразу, а по одной
182        //в результате чего все галочки кроме самой первой будут стерты    
183    })
184    //Тригерим ивент лисенер чтобы сработал ajax и обновил фильтр на странице
185    $('.views-exposed-form ').trigger('change')
186  } 
187  
188}
189
190function AjaxInit() {
191  let filterOnPage = document.querySelector(".page-with-filters");
192
193  if (filterOnPage) {
194    //защита от двойного срабатывания
195    if ($(".kfilters").length > 0) {
196    }
197    
198    //добавляем дополнительную разметку нашим фильтрам(в том числе и календарю)
199    //После полной прогрузки фильтров они отображаются на странице чтобы не было лишнего на экране
200    else {
201      $(".view-filters").wrap("<div class='kfilters' />");
202      $(".kfilters").nextAll().wrapAll("<div class='page_content' />");
203      $(".kfilters")
204        .nextAll()
205        .addBack()
206        .wrapAll("<div class='page_wrapper' />");
207      $(".preloader").addClass("done");
208      filterOnPage.classList.remove("dispnone");
209    }
210  }
211
212  if (window.location.pathname == "/school" || window.location.pathname == "/embed/school") {
213    okrugg();
214  }
215
216  if ($(".contact-message-form").length > 0) {
217    if ($(".form_bottom").length == 0) {
218      $(".deletecol").insertAfter(".field--name-field-vash-vopros");
219      $(".captcha").insertAfter(".field--name-field-vash-vopros");
220      $(".field--type-file")
221        .nextAll()
222        .addBack()
223        .wrapAll("<div class='form_bottom' />");
224    }
225  }
226}
227
228function wrap(el, wrapper) {
229  el.parentNode.insertBefore(wrapper, el);
230  wrapper.appendChild(el);
231}
232
233// $(document).ready ( function(){
234//   wrap(document.querySelector('.mydots'), document.createElement('div'));
235//   checkCookies();
236// });
237
238function checkCookies() {
239  let cookieDate = localStorage.getItem("cookieDate");
240  let cookieNotification = document.getElementById("cookiie");
241  let cookieBtn = cookiie.querySelector(".button_wraper .cookiie_accept");
242
243  if (!cookieDate || +cookieDate + 1209600000 < Date.now()) {
244    cookieNotification.classList.add("show");
245  }
246
247  cookieBtn.addEventListener("click", function () {
248    localStorage.setItem("cookieDate", Date.now());
249    cookieNotification.classList.remove("show");
250  });
251}
252if (document.querySelector(".button_wraper .cookiie_accept")) {
253  checkCookies();
254}
255
256function okrugg() {
257  const okrel = document.querySelectorAll(".views-field-field-okrug");
258  var translate = { К: "k", З: "z", П: "p", Ц: "c" };
259
260  okrel.forEach((element) => {
261    let kubdiv = element.prepend(document.createElement("div"));
262    let elema = element.lastElementChild.querySelector("a");
263    let q = elema.textContent[0];
264    element.firstChild.classList.add("kubik", translate[q]);
265    elema.textContent = q + "ВО";
266  });
267}
268
269const convertRestArgsIntoStylesArr = ([...args]) => {
270  return args.slice(1);
271};
272
273const getStyles = function () {
274  const args = [...arguments];
275  const [element] = args;
276
277  let stylesProps =
278    [...args][1] instanceof Array
279      ? args[1]
280      : convertRestArgsIntoStylesArr(args);
281
282  const styles = window.getComputedStyle(element);
283  const stylesObj = stylesProps.reduce((acc, v) => {
284    acc[v] = styles.getPropertyValue(v);
285    return acc;
286  }, {});
287
288  return stylesObj;
289};
290
291let cutpx = (n) => parseInt(n.replace(/px/, ""));
292
293if ($(".trigger").length > 0) {
294  document.querySelector(".trigger").addEventListener("click", menuTop.bind(1));
295}
296
297var topcheck = document.querySelectorAll(".fuW");
298var topcheck2 = document.querySelector(".layout-container");
299var bodyy2 = document.querySelector(".path-frontpage");
300
301let style1 = getStyles(document.body, "padding-top")["padding-top"];
302let style2 = getStyles(topcheck2, "height")["height"];
303
304//позиционирование меню
305function menuTop(q) {
306  // document.querySelector(".trigger").click()
307  // document.querySelector(".trigger").click()
308  var topcheck = document.querySelectorAll(".fuW");
309  var topcheck2 = document.querySelector(".layout-container");
310  var bodyy2 = document.querySelector(".path-frontpage");
311  let topLen = topcheck.length
312
313  style1 = getStyles(document.body, "padding-top")["padding-top"];
314  style2 = getStyles(topcheck2, "height")["height"];
315  
316  if (q == 0) {
317    if (
318      document.body.classList.contains("toolbar-horizontal") ||
319      document.body.classList.contains("toolbar-vertical")
320    ) {
321      for (let index = 0; index < topLen; index++) {
322        rastoyan = cutpx(style1) + cutpx(style2) + 1;
323        topcheck[index].style.top = rastoyan + "px";
324      }
325    } else {
326      for (let index = 0; index < topLen; index++) {
327        topcheck[index].style.top = cutpx(style2) + 1 + "px";
328      }
329    }
330  } else {
331    if (document.body.classList.contains("toolbar-tray-open")) {
332      for (let index = 0; index < topLen; index++) {
333        rastoyan = 39 + cutpx(style2) + 1;
334        topcheck[index].style.top = rastoyan + "px";
335      }
336    } else {
337      for (let index = 0; index < topLen; index++) {
338        for (let index = 0; index < topLen; index++) {
339          rastoyan = 79 + cutpx(style2) + 1;
340          if (window.innerWidth < 1173) {
341            rastoyan += 39;
342          }
343          if (window.innerWidth < 976) {
344            rastoyan -= 79;
345          }
346          topcheck[index].style.top = rastoyan + "px";
347        }
348      }
349    }
350  }
351}
352
353function checkedFilters(){
354  let q = []
355  document.querySelectorAll(".form-checkbox").forEach((element, index) => (element.checked === true ? q.push(index): ''))
356  return(q.join('&'))
357}
358
359function filterAdd(fullFilter) {
360  let nameFilter = fullFilter.slice(fullFilter.indexOf("&")+1, fullFilter.indexOf("="));
361  let filtersNotFiltred = window.location.search.split("&");
362  let filters = filtersNotFiltred.filter((object)=>(object.includes('value') || object.includes('items')));
363  for(let i = 0; i<filters.length; i++){
364    if (filters[i].includes(nameFilter)) {
365      if(fullFilter.indexOf('publictime')!=-1){
366        filters[i+1] = '';
367      }
368      filters[i] = fullFilter.slice(1,);
369      window.location.search = (filters.join('&').replace('&&', '&'));
370      return true;
371    }  
372  }
373  filters.push(fullFilter.slice(1,));
374  window.location.search = (filters.join('&').replace('&&', '&'));
375  return false;
376}
377
378function itemsOnPage(){
379  document.querySelectorAll('.ipp').forEach((elem)=>{
380    elem.addEventListener('click', (e)=> {
381      let attribute = e.target //получаем все атрибуты кнопки на которую мы нажимаем чтобы использовать значение и имя фильтра
382        filterAdd(`&${attribute.name}=${attribute.value}${checkedFilters() ? '&' + checkedFilters() : ''}`)
383    })
384})
385}
386
387function createDateMSK(time){
388  return(new Date(new Date(time).getTime() + (180 * 60 * 1000)))
389}
390
391function createCalendar() {
392  let min = '&field_publictime_value%5Bmin%5D='
393  let max = '&field_publictime_value%5Bmax%5D='
394
395  menuTop(0);
396  if ($(".calendar").length > 0) {
397    
398
399    let mapDate =[];
400    if(window.location.pathname === '/calendar'){
401      let materialType = drupalSettings.path.currentQuery.field_tip_materiala_value
402      drupalSettings.allNewsDates.forEach((el)=>{            
403        (el[1] == materialType) ? mapDate.push(createDateMSK(el[0])) : '';
404      })  
405      console.log(mapDate)
406    }
407    if(window.location.pathname === '/metodic-materials'){
408      drupalSettings.allNewsDates.forEach((el)=>{            
409         mapDate.push(createDateMSK(el[0]))
410      })  
411      console.log(mapDate)
412    }
413
414
415    const currentDate = document.querySelector(".calendar_date");
416    const prevnext = document.querySelectorAll(".alig");
417    const daysTag = document.querySelector(".days");
418
419    let todayDate = new Date(),
420      todayYear = todayDate.getFullYear(),
421      todayMonth = todayDate.getMonth(),
422      todayDay = todayDate.getDate();
423
424    let date = new Date(),
425      currYear = date.getFullYear(),
426      currMonth = date.getMonth(),
427      currDay = date.getDate();
428
429      let locationSearch = window.location.search
430    //Меняем заголовок календаря после того как выбрали фильтр
431    if (locationSearch.indexOf("publictime") != -1) {
432      window.location.search.split('&').some((el)=>{
433        if(el.includes('field_publictime_value%5Bmin%5D=')){
434            currYear = (el.slice(el.indexOf('=')+1,).split('-')[0])
435            currMonth = (el.slice(el.indexOf('=')+1,).split('-')[1])-1
436        }
437      })
438      // locationSearch.split('&')
439      // currMonth = locationSearch.split("=")[2].split("-")[1] - 1;
440      // currYear = locationSearch.split("=")[2].split("-")[0];
441    }
442
443    const months = [
444      "Январь",
445      "Февраль",
446      "Март",
447      "Апрель",
448      "Май",
449      "Июнь",
450      "Июль",
451      "Август",
452      "Сентябрь",
453      "Октябрь",
454      "Ноябрь",
455      "Декабрь",
456    ];
457
458    //b Нужен чтобы в фильтре при нажатии на последнюю дату месяца min стал данной датой а max первым числом след месяца
459    function dateGet(y, m, d, b){
460      if(b){
461        filterAdd(
462          `${min+y}-${(Number(m)+1).toString()}-${d+max+y}-${(Number(m)+1).toString()}-${(Number(d)+1).toString()}`
463          )
464      }
465      else{
466        filterAdd(
467          `${min+y}-${(Number(m)+1).toString()}-${d+max+y}-${(Number(m)+2).toString()}-1`
468          )
469      }
470    }
471
472
473    const renderCalendar = () => {
474      let lastDateOfMonth = new Date(currYear, currMonth + 1, 0).getDate();
475      let weekDate = new Date(currYear, currMonth, 0).getDay();
476      let divTag = "";
477      let mapFiltred = []
478        mapDate.map((el)=>{
479            if(el.getMonth()==currMonth && el.getFullYear()==currYear){
480              mapFiltred.push(el)
481            }
482          }
483        )
484      //Числа до начала идут блоки без даты, после мы заполняем числа до последнего дня месяца
485      for (let i = 0; i < weekDate; i++) {
486        divTag += `<div class='no_date'> </div>`;
487      }
488
489      for (let i = 1; i <= lastDateOfMonth; i++) {
490        divTag += `<div class='date_day'> ${i} </div>`;
491      }
492      
493      let filterOnPage = document.querySelector(".page-with-filters");
494      filterOnPage.classList.remove("dispnone");
495
496      //МЕСЯЦ И ГОД
497
498      currentDate.innerText = `${months[currMonth]} ${currYear}`;
499
500      // console.log(todayYear, todayMonth, todayDay)
501      // console.log(currYear, currMonth)
502
503      daysTag.innerHTML = divTag;
504
505      if(todayYear == currYear & todayMonth == currMonth){
506        let selectedElement = document.querySelectorAll(".date_day")[todayDay - 1];
507        selectedElement.classList.add('current');
508
509      }
510
511      if(mapFiltred.length>0){
512        
513        mapFiltred.forEach((value, index)=>{
514          let dayNumber = value.getDate()
515          let selectedElement = document.querySelectorAll(".date_day")[dayNumber - 1]
516          
517          if (dayNumber != lastDateOfMonth) {            
518            selectedElement.addEventListener("click", () => {
519                dateGet(currYear, currMonth, dayNumber, 1);
520              });
521            selectedElement.classList.add('with_news')
522          } else {
523            selectedElement.addEventListener("click", () => {
524                dateGet(currYear, currMonth, dayNumber, 0);
525              });
526            selectedElement.classList.add('with_news')
527          }
528        })
529
530      }
531    };
532    renderCalendar();
533
534    prevnext.forEach((icon) => {
535      icon.addEventListener("click", () => {
536        currMonth = icon.id === "prev" ? currMonth - 1 : currMonth + 1;
537        if (currMonth < 0 || currMonth > 11) {
538          date = new Date(currYear, currMonth);
539          currYear = date.getFullYear();
540          currMonth = date.getMonth();
541        } else {
542          date = new Date();
543        }
544        renderCalendar();
545      });
546    });
547  }
548}
549
550function collapseEllement(){
551  let filterCollapse = document.querySelector('.form--inline')
552  this.nextElementSibling.classList.toggle("collapsed_element");
553  this.firstElementChild.classList.toggle("rotate_arrow");
554  if (this.nextElementSibling.classList.contains("collapsed_element")) {
555    this.nextElementSibling.style.height =
556      this.nextElementSibling.firstChild.clientHeight + "px";
557      if(filterCollapse){
558        let heightSum = 0
559        heightSum+=filterCollapse.lastElementChild.offsetTop + filterCollapse.lastElementChild.clientHeight ?? 0
560        this.nextElementSibling.style.height = heightSum + "px"
561      }
562  } else {
563    this.nextElementSibling.style.height = "0px";
564  }
565}
566
567function collapser(){
568  if ($(".collapse_arrow").length > 0) {
569    
570    let arrs = document.querySelectorAll(".collapse_title");
571    for (let index = 0; index < arrs.length; index++) {
572      const element = arrs[index];
573      element.addEventListener("click", collapseEllement);
574  
575    }
576  }
577}
578
579window.onload = function ChangeTag() {
580  const tagsSlid = document.querySelectorAll(
581    ".block-views-blockactual-materials-block-1 .slick-slide li a"
582  );
583  var TagToSvg = { 0: "ok", 5: "sad", 7: "eyeb", 3: "saitOO" };
584  for (let index = 0; index < tagsSlid.length; index++) {
585    tagsSlid[index].innerHTML = `<img src='/sites/default/files/${
586      TagToSvg[tagsSlid[index].innerText]
587    }.svg'>`;
588  }
589};
590
591
592
593$(document).ajaxComplete(function () {
594  if (document.querySelector(".fw")) {
595    footerPosition();
596  }
597});
598
599function footerPosition() {
600  let footpos = document.querySelector(".fw");
601  footpos.classList.remove("dispnone");
602  if (document.documentElement.scrollHeight >= document.body.clientHeight + 2) {
603    footpos.classList.add("fw_bot");
604  }
605}

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.