{"size": 2222, "ext": "js", "max_stars_repo_path": "src/public/src/js/config.js", "max_stars_repo_name": "kedawung/lunixx", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/public/src/js/config.js", "max_issues_repo_name": "kedawung/lunixx", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/public/src/js/config.js", "max_forks_repo_name": "kedawung/lunixx", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.1619047619, "max_line_length": 65, "alphanum_fraction": 0.4774977498}
;(function () {
  /**
   * Configuration manager
   * @constructor
  */
  function _Config () {
    var self = this
    this.config = {
      theme: 'default'
    }

    this.vuePopup = new App.Vue({
      el: '.popup .config-pop',
      data: {
        config: self.config
      }
    })

    this.setConfig(App.Storage.readData('config'))

    $('.parameter .button').click(function () {
      self.showConfig()
    })
    $('.config-pop .submit').click(function () { self.submit() })

    // Logout

    $('.top-menu .logout').click(function () {
      $.ajax({
        type: 'post',
        url: '/auth?todo=logout',
        data: {},
        dataType: 'json',
        success: function (data) {
          if (data.err) {
            $.notify.error({
              title: 'Error',
              text: data.err,
              duration: 10
            })
          } else {
            $.notify.success({
              title: 'Logout',
              text: 'Successfully logged out.'
            })
            setTimeout(function () {
              document.location = '/login.html'
            }, 2000)
          }
        }
      }).done(function () {
        App.Loading.hide('action')
      }).fail(function (err) {
        App.Loading.hide('action')
        $.notify.error({
          title: 'Error in Config.logout()',
          text: err.statusText,
          duration: 5
        })
      })
    })
  }

  /**
   * Display the config popup
  */
  _Config.prototype.showConfig = function () {
    $.popupjs.init({
      pos: {
        x: null,
        y: '5%'
      },
      width: '90%',
      height: '90%',
      title: 'Configuration',
      html: $('.popup .config-pop'),
      closeBut: true
    })
    $.popupjs.draw()
  }

  /**
   * Submit config form.
  */
  _Config.prototype.submit = function () {
    var config = {}
    this.setConfig(config)
    $.popupjs.remove()
  }

  /**
   * Set config and save it.
   * @param {object} config - Configuration.
  */
  _Config.prototype.setConfig = function (config) {
    if (config) {
      for (var key in config) {
        this.config[key] = config[key]
      }
      App.Storage.storeData('config', this.config)
    }
  }
  App.Config = new _Config()
})()
