PageSourceSearch

https://84race.com/public/js/custom.js

js 84race.com collected 2026-09-24 12:30:40 UTC 14,197 bytes, 506 lines download raw bytes

1$(document).ready(function () {
2  logVisit();
3  $('[data-toggle="tooltip"]').tooltip();
4  delete_my_post();
5  active_menu('.blog-tab');
6  active_menu('.right-header');
7  active_menu('.nav-tabs');
8  if (controller == 'news') {
9    $('.right-header ul li.m-new a').addClass('active');
10  } if (controller == 'clubs') {
11    $('.right-header ul li.m-clubs a').addClass('active');
12  }
13
14  if (controller == 'ranking' || controller == 'medal') {
15    $('nav li.m-ranking').addClass('active');
16    $('nav li.m-ranking a').addClass('active');
17  }
18  if (controller == 'personal') $('.my-activity a').addClass('active');
19  if ($('.my-activity').length > 0) $('.my-activity a').attr('href', hdct);
20
21  if (controller == 'races') {
22    if (methob == 'categoryfaq' || methob == 'detailFaq' || methob == 'faq') {
23      $('.m_faq a').addClass('active');
24       // BOF Thangph S-Race 2022
25    } else if (methob == 'srace') {
26      $('.m-srace a').addClass('active');
27      // EOF Thangph S-Race 2022
28    } else {
29      $('.m-race a').addClass('active');
30    }
31  }
32  if(controller=='clubs')
33  taglimit();
34
35  // xử lý khi click chuông
36  $('.h-notify ').on('click', '.bell', function () {
37    let count = $('.count_notify').text();
38    if (parseInt(count) > 0) {
39      read_notify();
40    }
41  });
42  read_one_notify();
43
44  $('.prf-form').on('click', '.check-medal span', function () {
45    let pr_medal = $(this).data('price');
46    let soluong = $('.prf-form .soluong_medal').val();
47    let total = parseInt(soluong) * parseInt(pr_medal);
48    console.log(soluong);
49    $('[name="price"]').val(total);
50    $('.tongtien').html(number_format(total, 0, ',', '.'));
51  });
52
53  $('.prf-form').on('change', '.soluong_medal', function () {
54    let pr_medal = $('.prf-form .check-medal input:checked').parent().find('span').data('price');
55    let soluong = $(this).val();
56    let total = parseInt(soluong) * parseInt(pr_medal);
57    $('[name="price"]').val(total);
58    $('.tongtien').html(number_format(total, 0, ',', '.'));
59  });
60  if ($('#tao_my_post').length > 0) {
61    $('#tao_my_post').validate({
62      errorClass: 'text-danger',
63      rules: {
64        content: "required",
65      },
66      messages: {
67        content: "Nội dung không được để trống!"
68      }
69    });
70  }
71//chuyen dong menu body
72  $('.right-header ul li a').click(function (event) {
73    let href = $(this).attr('href').replace(base_url, '');
74    if ($(href).length > 0) {
75      $('.right-header ul li a').removeClass('active').parent().removeClass('active');
76      $(this).addClass('active').parent().addClass('active');
77      $('html, body').animate({scrollTop: $(href).offset().top - 100}, 1000);
78    }
79  });
80  if (controller == 'home') {
81    let hrefHome = urlCurrentMenu.replace(base_url, '');
82    if ($(hrefHome).length > 0) {
83      $('.right-header ul li a').removeClass('active').parent().removeClass('active');
84      $('[href="' + urlCurrentMenu + '"]').addClass('active').parent().addClass('active');
85      $('html, body').animate({scrollTop: $(hrefHome).offset().top - 100}, 1000);
86    }
87
88  }
89
90  if ($('.share-pane [name="content"]').length > 0) $('.share-pane [name="content"]').height($('.share-pane [name="content"]')[0].scrollHeight);
91  $("input[type='date']").val(new Date().toISOString().substring(0, 10));
92  instagram();
93  share_social();
94});
95
96function share_social() {
97  $('body').on('click', '.share-ct ._share', function (e) {
98    e.preventDefault();
99    var $link = $(this);
100    var $href = $link.attr('href');
101    var network = $link.attr('data-network');
102
103
104    var popup = function () {
105      var options = 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,';
106      window.open($href, '', options + 'height=300,width=600');
107    }
108
109    popup();
110  });
111}
112
113function chooseLang(lang) {
114  var urlCurrent = urlHref;
115  window.location.href = urlCurrent + "?lang=" + lang;
116}
117
118function instagram() {
119  if ($('.connect-instagram').length > 0) {
120    // get api instagram
121    var token = '9212421839.ed342e3.a0c34ab1308642838369104111b82327',
122      username = 'rudrastyh',
123      num_photos = 11;
124    setTimeout(function () {
125      $.ajax({
126        url: 'https://api.instagram.com/v1/users/self/media/recent',
127        dataType: 'jsonp',
128        type: 'GET',
129        data: {access_token: token, count: num_photos},
130        success: function (data) {
131          //  console.log(data);
132          for (x in data.data) {
133            console.log(data.data[x].images.low_resolution.url);
134            $('.connect-instagram .list-item').append('<a target="_blank" class="item" href="' + data.data[x].link + '"><img class="lazy" style="margin-bottom: 10px" width="85px" height="85px" src="' + data.data[x].images.low_resolution.url + '"></a>');
135          }
136        },
137        error: function (data) {
138          console.log(data);
139        }
140      });
141			setTimeout(function () {
142				$('.connect-face iframe').attr('src',$('.connect-face').data('iframe'));
143			},1000)
144    }, 1000);
145  }
146
147
148}
149
150function load_block(url) {
151  var result = '';
152  $.ajax({
153    type: 'POST',
154    url: url,
155    async: false,
156    success: function (data) {
157      result = data;
158    },
159  });
160  return result;
161}
162
163function active_menu(element) {
164  let menuElementMain = $(element + ' a[href="' + urlCurrentMenu + '"]');
165  menuElementMain.addClass('active');
166  menuElementMain.parent().addClass('active');
167
168  menuElementMain.parent().parent().parent().addClass('active');
169
170  menuElementMain.parent().addClass('active');
171}
172
173function delete_my_post() {
174
175  $('body').on('click', '.delete', function (event) {
176    event.preventDefault();
177    confirm_act($(this), 'Bạn có chắc chắn muốn xóa không?');
178
179
180  });
181  $('body').on('click', '.action_act', function (event) {
182    event.preventDefault();
183    confirm_act($(this), true);
184  });
185}
186
187function confirm_act(_this, type_act) {
188  $('#modal-remove-mypost').modal('show');
189  let current = $(_this);
190  if (current.hasClass('update_act')) {
191    $('#exampleModalCenterTitle').html('Bạn có chắc chắn muốn cập nhật không?');
192    $('.btn-remove-post').on('click', function () {
193      $('.sb_update_hd').trigger('click');
194    });
195  } else {
196    $('#exampleModalCenterTitle').html('Bạn có chắc chắn muốn xóa không?');
197    $('.btn-remove-post').on('click', function () {
198      if (typeof type_act != 'undefined' && type_act == true) {
199        window.location.href = current.attr('href');
200      } else {
201        $.ajax({
202          url: current.attr('href'),
203          type: 'POST',
204          dataType: 'json',
205          success: function (data) {
206            $('#modal-remove-mypost').modal('hide');
207            if (data.type == 'success') {
208              current.closest('.post').fadeOut('slow', function () {
209                current.closest('.post').remove();
210              });
211
212            } else {
213              toastr[data.type](data.message);
214            }
215          }
216        });
217      }
218
219    });
220  }
221
222
223}
224
225function number_format(number, decimals, dec_point, thousands_sep) {
226
227  var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
228  var d = dec_point == undefined ? "," : dec_point;
229  var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
230  var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
231
232  return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
233}
234
235// ajax xử lý phân trang
236function panigation(element, page) {
237  if (typeof page === 'undefined') page = 1;
238  if (typeof paramsPa != 'undefined' && paramsPa != '') {
239    let params = JSON.parse(paramsPa);
240    $.ajax({
241      url: url_panigation + '/' + page,
242      type: "POST",
243      data: {
244        total: params.total,
245        limit: params.limit,
246        base_url: params.base_url,
247        first_url: params.first_url,
248      },
249      dataType: "JSON",
250      success: function (response) {
251        $('#' + element + ' .hc-pagination').html(response.data);
252        $('#' + element + ' .hc-pagination').removeClass('not-active');
253        // flag = true;
254      },
255      error: function (jqXHR, textStatus, errorThrown) {
256        console.log(jqXHR);
257        console.log(textStatus);
258        console.log(errorThrown);
259      }
260    });
261  }
262
263}
264
265
266// ajax xử lý phân trang
267
268function taglimit() {
269  $('.share-pane').on('change', '[name="races_id[]"]', function (e) {
270    if ($('input[type=checkbox]:checked').length > 3) {
271      $(this).prop('checked', false);
272      toastr['warning']('Chỉ được chọn tối đa 3 tags');
273
274    }
275  });
276}
277
278// cảnh báo khi xóa Activity
279
280
281function printDiv(divName) {
282  var printContents = document.getElementById(divName).innerHTML;
283  var originalContents = document.body.innerHTML;
284
285  document.body.innerHTML = printContents;
286
287  window.print();
288
289  document.body.innerHTML = originalContents;
290}
291
292function count_notify() {
293  $.ajax({
294    url: base_url + 'notify/count_notify',
295    type: 'POST',
296    success: function (data) {
297      let count = parseInt(data);
298      if (count > 0) {
299        $('.count_notify').text(count).show();
300      } else {
301        $('.count_notify').text(count).hide();
302      }
303      list_notify(count);
304    }
305  });
306}
307
308function list_notify(count) {
309  $.ajax({
310    url: base_url + 'notify/list_notify/' + count,
311    type: 'POST',
312    dataType: 'html',
313    success: function (data) {
314      $('#list_notify').html(data);
315    }
316  });
317}
318
319function read_notify() {
320  $('.count_notify').text('0').hide();
321  $.ajax({
322    url: base_url + 'notify/update_notify',
323    type: 'POST',
324    success: function (data) {
325      console.log(data);
326    }
327  });
328}
329
330// Cập nhật notify khi người dùng xem chi tiết
331function read_one_notify() {
332  $('#list_notify').on('click', '.unread', function (e) {
333    let id = $(this).data('id');
334    if (typeof id !== typeof undefined && id !== false) {
335      $(this).removeClass('unread');
336      $.ajax({
337        url: base_url + 'notify/update_one_notify',
338        type: 'POST',
339        data: {id: id},
340        success: function (data) {
341          console.log(data);
342        }
343      });
344    }
345  });
346
347}
348
349function validate_search(event) {
350  let keyword = $('#search [name="keyword"]').val();
351  if (keyword == '') {
352    event.preventDefault();
353    toastr.warning('Từ khóa không được để trống');
354    return false;
355  }
356}
357
358function form_add_profile() {
359  $('.text-danger').remove();
360  let form = $('#form-login');
361  $.ajax({
362    type: 'POST', url: form.attr('action'), dataType: 'JSON', data: form.serialize(), beforeSend: function () {
363      $('.icon_load').show();
364    }, success: function (res) {
365      if (res.type == 'success') {
366        $('.btn-flat').attr('disabled', true).after('<div class="alert alert-success fade show text-center" style="margin-top: 10px" role="alert"> ' + res.message + '</div>');
367        $('.icon_load').hide();
368        setTimeout(function () {
369          window.location.href = urlCurrent;
370        }, 2000);
371      } else {
372        $.each(res.validation, function (k, v) {
373          $('#form-login input[name="' + k + '"]').after(v);
374        });
375        $('.icon_load').hide();
376      }
377    }
378  });
379}
380
381function logVisit() {
382  var d = new Date();
383  var h = d.getHours();
384  var m = d.getMinutes();
385  var s = d.getSeconds();
386  var seceod = (24 * 60 * 60) - (h * 60 * 60) - (m * 60) - s;
387
388  arrayPage = ['news'];
389  var i = arrayPage.indexOf(controller);
390  setTimeout(function () {
391    if (i != -1) {// Check page
392      if (parseInt(controller) != "NaN" && typeof $.cookie(controller) == "undefined") {
393
394        $.cookie(controller, currentID, {
395          expires: seceod,
396          path: '/'
397        });
398        callUpdateViewed(currentID, controller);
399
400      } else {
401        var currentValues = $.cookie(controller);
402        currentValues = currentValues.split(',');
403        //Xóa item tồn tại
404        if ($.inArray(currentID, currentValues) > -1) {
405          currentValues.splice($.inArray(currentID, currentValues), 1);
406        } else {
407          callUpdateViewed(currentID, controller);
408        }
409        currentValues.push(currentID)
410        $.cookie(controller, currentValues, {
411          expires: seceod,
412          path: '/'
413        });
414      }
415    }
416  }, 30000);
417}
418
419function callUpdateViewed(currentID, currentPage) {
420  $.ajax({
421    url: base_url + 'news/visit',
422    type: 'POST',
423    data: {currentID: currentID, currentPage: currentPage},
424  })
425    .done(function (data) {
426    });
427}
428
429$(document).ready(function () {
430  $('.medals').slick({
431    slidesToShow: 4,
432    slidesToScroll: 1,
433    nextArrow: '<i class="cas-arrow smooth next"></i>',
434    prevArrow: '<i class="cas-arrow smooth prev"></i>',
435    dots: false,
436    autoplay: true,
437    swipeToSlide: true,
438    autoplaySpeed: 3000,
439    responsive: [
440      {
441        breakpoint: 1199,
442        settings: {
443          slidesToShow: 3,
444        }
445      },
446      {
447        breakpoint: 991,
448        settings: {
449          slidesToShow: 3,
450        }
451      },
452      {
453        breakpoint: 700,
454        settings: {
455          slidesToShow: 2,
456        }
457      },
458      {
459        breakpoint: 480,
460        settings: {
461          slidesToShow: 1,
462        }
463      }
464    ],
465  });
466
467  validate_date();
468});
469
470// ĐỊnh dạng ngày tháng
471function validate_date() {
472  var maskDate = function (val) {
473    val = val.split("-");
474    let ngay = (parseInt(val[0]) > 29) ? "DM" : "DZ";
475    let thang = (parseInt(val[1]) > 9) ? "Mm" : "MZ";
476    return ngay + '-' + thang + '-ZZZZ';
477  }
478
479  spOptionsDate = {
480    onKeyPress: function (val, e, field, options) {
481      field.mask(maskDate.apply({}, arguments), options);
482    },
483    translation: {
484      'D': {pattern: /[0-3]/, optional: false},
485      'M': {pattern: /[0-1]/, optional: false},
486      'Z': {pattern: /[0-9]/, optional: false},
487      'd': {pattern: /[0-3]/, optional: false},
488      'm': {pattern: /[0-2]/, optional: false},
489    },
490    placeholder: "dd-mm-yyyy"
491  };
492  $('.k-date').mask(maskDate, spOptionsDate);
493
494}
495
496// tạo session để bỏ qua ko show popup connect strava
497function setSession() {
498  $.ajax({
499    url: base_url + 'home/setSession',
500    type: 'POST',
501    dataType: 'json',
502    success: function () {
503      console.log('keep thành công');
504    }
505  });
506}

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.