{"size": 2396, "ext": "js", "max_stars_repo_path": "tray/app.js", "max_stars_repo_name": "dominhhai/electron-examples", "max_stars_repo_stars_event_min_datetime": "2015-06-02T07:02:05.000Z", "max_stars_repo_stars_event_max_datetime": "2015-07-28T14:40:56.000Z", "max_issues_repo_path": "tray/app.js", "max_issues_repo_name": "dominhhai/electron-examples", "max_issues_repo_issues_event_min_datetime": "2015-06-08T02:26:25.000Z", "max_issues_repo_issues_event_max_datetime": "2015-06-08T02:26:25.000Z", "max_forks_repo_path": "tray/app.js", "max_forks_repo_name": "dominhhai/electron-examples", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 4, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 32.8219178082, "max_line_length": 89, "alphanum_fraction": 0.6932387312}
var app = require('app')  // Module to control application life.
var BrowserWindow = require('browser-window')  // Module to create native browser window.
var Menu = require('menu')
var Tray = require('tray')
var path = require('path')

// Report crashes to our server.
require('crash-reporter').start()

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null

// Quit when all windows are closed.
app.on('window-all-closed', function () {
  if (process.platform !== 'darwin') app.quit()
})

// This method will be called when Electron has done everything
// initialization and ready for creating browser windows.
var appIcon = null

app.on('ready', function () {
  var screen = require('screen')
  var size = screen.getPrimaryDisplay().workAreaSize
  // Create the browser window.
  // mainWindow = new BrowserWindow({width: 800, height: 600})
  mainWindow = new BrowserWindow({ width: size.width, height: size.height })

  // and load the index.html of the app.
  mainWindow.loadUrl('file://' + __dirname + '/index.html')

  // Emitted when the window is closed.
  mainWindow.on('closed', function () {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null
  })

  // tray
  var iconPath = path.join(__dirname, 'IconTemplate.png')
  appIcon = new Tray(iconPath);
  var contextMenu = Menu.buildFromTemplate([
    { label: 'Item1', type: 'radio' },
    { label: 'Item2', type: 'radio' },
    { label: 'Item3', type: 'radio', checked: true },
    { label: 'Item4', type: 'radio' },
  ]);
  appIcon.setToolTip('This is my application.');
  appIcon.setContextMenu(contextMenu);

  // check screen information

  // screen events
  screen.on('display-added', function (event, newDisplay) {
    console.log('added a new display')
  })

  screen.on('display-removed', function (event, oldDisplay) {
    console.log('removed a display')
  })

  screen.on('display-metrics-changed', function (event, display, changedMetrics) {
    console.log('display-metrics-changed')
  })
  // screen info
  var cursor = screen.getCursorScreenPoint()
  console.log(cursor)
  var display = screen.getPrimaryDisplay()
  console.log(display)
})
