HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //proc/self/root/home/arjun/projects/buyercall/buyercall/assets/scripts/app_new.js
/*
Template Name: Skote - Admin & Dashboard Template
Author: Themesbrand
Version: 3.1.0
Website: https://themesbrand.com/
Contact: themesbrand@gmail.com
File: Main Js File
*/

var App = (function () {
  function initMetisMenu() {
    //metis menu
    $('#side-menu').metisMenu();
  }

  function initLeftMenuCollapse() {
    $('#vertical-menu-btn').on('click', function (event) {
      event.preventDefault();
      $('body').toggleClass('sidebar-enable');
      if ($(window).width() >= 992) {
        $('body').toggleClass('vertical-collpsed');
      } else {
        $('body').removeClass('vertical-collpsed');
      }
    });
  }

  function initActiveMenu() {
    // === following js will activate the menu in left side bar based on url ====
    $('#sidebar-menu a').each(function () {
      var pageUrl = window.location.href.split(/[?#]/)[0];
      if (this.href == pageUrl) {
        $(this).addClass('active');
        $(this)
          .parent()
          .addClass('mm-active'); // add active to li of the current link
        $(this)
          .parent()
          .parent()
          .addClass('mm-show');
        $(this)
          .parent()
          .parent()
          .prev()
          .addClass('mm-active'); // add active class to an anchor
        $(this)
          .parent()
          .parent()
          .parent()
          .addClass('mm-active');
        $(this)
          .parent()
          .parent()
          .parent()
          .parent()
          .addClass('mm-show'); // add active to li of the current link
        $(this)
          .parent()
          .parent()
          .parent()
          .parent()
          .parent()
          .addClass('mm-active');
      }
    });
  }

  function initMenuItemScroll() {
    // focus active menu in left sidebar
    $(document).ready(function () {
      if (
        $('#sidebar-menu').length > 0 &&
        $('#sidebar-menu .mm-active .active').length > 0
      ) {
        var activeMenu = $('#sidebar-menu .mm-active .active').offset().top;
        if (activeMenu > 300) {
          activeMenu = activeMenu - 300;
          $('.vertical-menu .simplebar-content-wrapper').animate(
            {
              scrollTop: activeMenu,
            },
            'slow',
          );
        }
      }
    });
  }

  function initHoriMenuActive() {
    $('.navbar-nav a').each(function () {
      var pageUrl = window.location.href.split(/[?#]/)[0];
      if (this.href == pageUrl) {
        $(this).addClass('active');
        $(this)
          .parent()
          .addClass('active');
        $(this)
          .parent()
          .parent()
          .addClass('active');
        $(this)
          .parent()
          .parent()
          .parent()
          .addClass('active');
        $(this)
          .parent()
          .parent()
          .parent()
          .parent()
          .addClass('active');
        $(this)
          .parent()
          .parent()
          .parent()
          .parent()
          .parent()
          .addClass('active');
        $(this)
          .parent()
          .parent()
          .parent()
          .parent()
          .parent()
          .parent()
          .addClass('active');
      }
    });
  }

  function initFullScreen() {
    $('[data-toggle="fullscreen"]').on('click', function (e) {
      e.preventDefault();
      $('body').toggleClass('fullscreen-enable');
      if (
        !document.fullscreenElement &&
        /* alternative standard method */ !document.mozFullScreenElement &&
        !document.webkitFullscreenElement
      ) {
        // current working methods
        if (document.documentElement.requestFullscreen) {
          document.documentElement.requestFullscreen();
        } else if (document.documentElement.mozRequestFullScreen) {
          document.documentElement.mozRequestFullScreen();
        } else if (document.documentElement.webkitRequestFullscreen) {
          document.documentElement.webkitRequestFullscreen(
            Element.ALLOW_KEYBOARD_INPUT,
          );
        }
      } else {
        if (document.cancelFullScreen) {
          document.cancelFullScreen();
        } else if (document.mozCancelFullScreen) {
          document.mozCancelFullScreen();
        } else if (document.webkitCancelFullScreen) {
          document.webkitCancelFullScreen();
        }
      }
    });
    document.addEventListener('fullscreenchange', exitHandler);
    document.addEventListener('webkitfullscreenchange', exitHandler);
    document.addEventListener('mozfullscreenchange', exitHandler);

    function exitHandler() {
      if (
        !document.webkitIsFullScreen &&
        !document.mozFullScreen &&
        !document.msFullscreenElement
      ) {
        console.log('pressed');
        $('body').removeClass('fullscreen-enable');
      }
    }
  }

  function initDropdownMenu() {
    if (document.getElementById('topnav-menu-content')) {
      var elements = document
        .getElementById('topnav-menu-content')
        .getElementsByTagName('a');
      for (var i = 0, len = elements.length; i < len; i++) {
        elements[i].onclick = function (elem) {
          if (elem.target.getAttribute('href') === '#') {
            elem.target.parentElement.classList.toggle('active');
            elem.target.nextElementSibling.classList.toggle('show');
          }
        };
      }
      window.addEventListener('resize', updateMenu);
    }
  }

  function updateMenu() {
    var elements = document
      .getElementById('topnav-menu-content')
      .getElementsByTagName('a');
    for (var i = 0, len = elements.length; i < len; i++) {
      if (
        elements[i].parentElement.getAttribute('class') ===
        'nav-item dropdown active'
      ) {
        elements[i].parentElement.classList.remove('active');
        if (elements[i].nextElementSibling !== null) {
          elements[i].nextElementSibling.classList.remove('show');
        }
      }
    }
  }

  function initComponents() {
    var tooltipTriggerList = [].slice.call(
      document.querySelectorAll('[data-bs-toggle="tooltip"]'),
    );
    var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
      return new bootstrap.Tooltip(tooltipTriggerEl);
    });

    var popoverTriggerList = [].slice.call(
      document.querySelectorAll('[data-bs-toggle="popover"]'),
    );
    var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
      return new bootstrap.Popover(popoverTriggerEl);
    });

    var offcanvasElementList = [].slice.call(
      document.querySelectorAll('.offcanvas'),
    );
    var offcanvasList = offcanvasElementList.map(function (offcanvasEl) {
      return new bootstrap.Offcanvas(offcanvasEl);
    });
  }

  function initPreloader() {
    $(window).on('load', function () {
      $('#status').fadeOut();
      $('#preloader')
        .delay(350)
        .fadeOut('slow');
    });
  }

  function initSettings() {
    if (window.sessionStorage) {
      var alreadyVisited = sessionStorage.getItem('is_visited');
      if (!alreadyVisited) {
        // sessionStorage.setItem("is_visited", "light-mode-switch");
      } else {
        $('.right-bar input:checkbox').prop('checked', false);
        $('#' + alreadyVisited).prop('checked', true);
        // updateThemeSetting(alreadyVisited);
      }
    }
    $(
      '#light-mode-switch, #dark-mode-switch, #rtl-mode-switch, #dark-rtl-mode-switch',
    ).on('change', function (e) {
      updateThemeSetting(e.target.id);
    });

    // show password input value
    $('#password-addon').on('click', function () {
      if ($(this).siblings('input').length > 0) {
        $(this)
          .siblings('input')
          .attr('type') == 'password'
          ? $(this)
            .siblings('input')
            .attr('type', 'input')
          : $(this)
            .siblings('input')
            .attr('type', 'password');
        $(this)
          .siblings('input')
          .attr('type') == 'password'
          ? $('#pass-button')
            .attr('icon', 'ion:eye-off-outline')
          : $('#pass-button')
            .attr('icon', 'ion:eye-outline');
      }
    });
    $('.password-addon').on('click', function () {
      if ($(this).siblings('input').length > 0) {
        $(this)
          .siblings('input')
          .attr('type') == 'password'
          ? $(this)
            .siblings('input')
            .attr('type', 'input')
          : $(this)
            .siblings('input')
            .attr('type', 'password');
      }
    });
  }

  function updateThemeSetting(id) {
    if (
      $('#dark-mode-switch').prop('checked') == true &&
      id === 'dark-mode-switch'
    ) {
      $('html').removeAttr('dir');
      $('#light-mode-switch').prop('checked', false);
      $('#rtl-mode-switch').prop('checked', false);
      $('#dark-rtl-mode-switch').prop('checked', false);
      $('#bootstrap-style').attr('href', 'assets/css/bootstrap-dark.min.css');
      $('#app-style').attr('href', 'assets/css/app-dark.min.css');
      sessionStorage.setItem('is_visited', 'dark-mode-switch');
    } else if (
      $('#rtl-mode-switch').prop('checked') == true &&
      id === 'rtl-mode-switch'
    ) {
      $('#light-mode-switch').prop('checked', false);
      $('#dark-mode-switch').prop('checked', false);
      $('#dark-rtl-mode-switch').prop('checked', false);
      $('#bootstrap-style').attr('href', 'assets/css/bootstrap-rtl.min.css');
      $('#app-style').attr('href', 'assets/css/app-rtl.min.css');
      $('html').attr('dir', 'rtl');
      sessionStorage.setItem('is_visited', 'rtl-mode-switch');
    } else if (
      $('#dark-rtl-mode-switch').prop('checked') == true &&
      id === 'dark-rtl-mode-switch'
    ) {
      $('#light-mode-switch').prop('checked', false);
      $('#rtl-mode-switch').prop('checked', false);
      $('#dark-mode-switch').prop('checked', false);
      $('#bootstrap-style').attr(
        'href',
        'assets/css/bootstrap-dark-rtl.min.css',
      );
      $('#app-style').attr('href', 'assets/css/app-dark-rtl.min.css');
      $('html').attr('dir', 'rtl');
      sessionStorage.setItem('is_visited', 'dark-rtl-mode-switch');
    }
  }

  function initCheckAll() {
    $('#checkAll').on('change', function () {
      $('.table-check .form-check-input').prop(
        'checked',
        $(this).prop('checked'),
      );
    });
    $('.table-check .form-check-input').change(function () {
      if (
        $('.table-check .form-check-input:checked').length ==
        $('.table-check .form-check-input').length
      ) {
        $('#checkAll').prop('checked', true);
      } else {
        $('#checkAll').prop('checked', false);
      }
    });
  }

  function loader() {
    if (window.sessionStorage) {
      var alreadyVisited = sessionStorage.getItem('is_loader');
      if (alreadyVisited == 'true') {
        $(this).attr('value', 'true');
        sessionStorage.setItem('is_loader', true);
        $('#show-loader-switch').prop('checked', true);
      }

      $('#show-loader-switch').on('change', function () {
        if ($(this).is(':checked')) {
          $(this).attr('value', 'true');
          sessionStorage.setItem('is_loader', true);
          $('#show-loader-switch').prop('checked', true);
        } else {
          $(this).attr('value', 'false');
          sessionStorage.setItem('is_loader', false);
          $('#show-loader-switch').prop('checked', false);
        }
      });
    }
  }

  function changeMode() {
    if (window.sessionStorage) {
      var lightmode = sessionStorage.getItem('light_mode');
      if (lightmode == null) {
        $('#change-mode-switch').prop('checked', true);
        sessionStorage.setItem('light_mode', 'true');
        $('#bootstrap-style').attr('href', 'assets/css/bootstrap.min.css');
        $('#app-style').attr('href', 'assets/css/app.min.css');
      } else {
        if (lightmode == 'true') {
          $('#mode-label').html('Light Mode');
          $('#change-mode-switch').prop('checked', true);
          $('head').append(
            '<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">',
          );
          $('head').append(
            '<link rel="stylesheet" type="text/css" href="assets/css/app.min.css">',
          );
          sessionStorage.setItem('light_mode', true);
        } else {
          $('#mode-label').html('Dark Mode');
          $('#change-mode-switch').prop('checked', false);
          $('head').append(
            '<link rel="stylesheet" type="text/css" href="assets/css/bootstrap-dark.min.css">',
          );
          $('head').append(
            '<link rel="stylesheet" type="text/css" href="assets/css/app-dark.min.css">',
          );
          sessionStorage.setItem('light_mode', false);
        }
      }

      $('#change-mode-switch').on('change', function () {
        if ($(this).is(':checked')) {
          $('#mode-label').html('Light Mode');
          $(this).attr('value', 'true');
          $('head').append(
            '<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">',
          );
          $('head').append(
            '<link rel="stylesheet" type="text/css" href="assets/css/app.min.css">',
          );
          sessionStorage.setItem('light_mode', true);
          $('#change-mode-switch').prop('checked', true);
        } else {
          $('#mode-label').html('Dark Mode');
          $(this).attr('value', 'false');
          sessionStorage.setItem('light_mode', false);
          $('head').append(
            '<link rel="stylesheet" type="text/css" href="assets/css/bootstrap-dark.min.css">',
          );
          $('head').append(
            '<link rel="stylesheet" type="text/css" href="assets/css/app-dark.min.css">',
          );
          $('#change-mode-switch').prop('checked', false);
        }
      });
    }
  }

  function init() {
    initMetisMenu();
    initLeftMenuCollapse();
    initActiveMenu();
    initMenuItemScroll();
    initHoriMenuActive();
    initFullScreen();
    // initRightSidebar();
    initDropdownMenu();
    initComponents();
    initSettings();
    // initLanguage();
    initPreloader();
    Waves.init();
    initCheckAll();
    loader();
    // changeMode();
  }

  return {
    init: () => init(),
  };
})();
module.exports = App;
// Expose 'App' to the scripts on the page
var global = Function('return this;')();
global.App = App;