Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "nw in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'nw' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

submenu.items[0].enabled == false,
  submenu.items[1].enabled == true,
  submenu.items[2].enabled == true,
  submenu.items[3].enabled == true,
  'After flip checked and enabled');

  // Click to flip other items
  var lastone = submenu.items[0];
  submenu.items[0].click = submenu.items[1].click = submenu.items[2].click = submenu.items[3].click = function() {
    lastone.checked = !lastone.checked;
    lastone.enabled = !lastone.enabled;
    this.enabled = !this.enabled;
    lastone = this;
  }

  var tray = new gui.Tray({ title: 'Test Menu', menu: menu });
  menu.items[0].icon = 'icon1.png';
  assert(
  menu.items[0].icon == 'icon1.png',
  'Set Menu Icon');

  menu.items[0].icon = '';
  assert(
  menu.items[0].icon == '',
  'Clear Menu Icon');

  menu.items[1].icon = tray.icon = 'icon1.png';

  menu.items[1].on('click', function() {
    console.log('Item Mama');
  });
'use strict';

var path = require('path');
var nw = require('nw');

exports.config = {
    chromeDriver: './support/chromedriver',
    directConnect: true,
    specs: ['e2e/**/*.js'],
    baseUrl: 'file://' + path.resolve('app/index.html'),
    rootElement: 'html',
    capabilities: {
        browserName: 'chrome',
        chromeOptions: {
            binary: nw.findpath()
        }
    },

    onPrepare: function() {

        // By default, Protractor use data:text/html, as resetUrl, but 
        // location.replace (see http://git.io/tvdSIQ) from the data: to the file: protocol is not allowed
        // (we'll get ‘not allowed local resource’ error), so we replace resetUrl with one
        // with the file: protocol (this particular one will open system's root folder)
        browser.resetUrl = 'file://';

        // This isn't required and used to avoid ‘Cannot extract package’ error showed
        // before Protractor have redirected node-webkit to resetUrl.
        browser.driver.get('file://');
        browser.driver.get('file://' + path.resolve('app/index.html'));
    }
var gui = require('nw.gui');
var win = gui.Window.get();
gui.Screen.Init();
var screens = gui.Screen.screens;
var CustomTrayMenu = require('./custom-tray');

var customTray;

process.on('log', function(msg) { console.log(msg); });

function init() {

  // win.width = screens[0].work_area.width;
  // win.height = screens[0].work_area.height;

  win.showDevTools();

  if (!customTray) {
    customTray = new CustomTrayMenu();
function restoreWindowState() {
    // deltaHeight already saved, so just restore it and adjust window height
    if (deltaHeight !== 'disabled' && typeof winState.deltaHeight !== 'undefined') {
      deltaHeight = winState.deltaHeight;
      winState.height = winState.height - deltaHeight;
    }


    //Make sure that the window is displayed somewhere on a screen that is connected to the PC. 
    //Imagine you run the program on a secondary screen connected to a laptop - and then the next time you start the 
    //program the screen is not connected...
    gui.Screen.Init();
    var screens = gui.Screen.screens;
    var locationIsOnAScreen = false;
    for (var i = 0; i < screens.length; i++) {
      var screen = screens[i];
      if (winState.x > screen.bounds.x && winState.x < screen.bounds.x + screen.bounds.width) {
        if (winState.y > screen.bounds.y && winState.y < screen.bounds.y + screen.bounds.height) {
          console.debug("Location of window (" + winState.x + "," + winState.y + ") is on screen " + JSON.stringify(screen));
          locationIsOnAScreen = true;
        }
      }
    }

    if (!locationIsOnAScreen) {
      console.debug("Last saved position of windows is not usable on current monitor setup. Moving window to center!");
      win.setPosition("center");
    }
    else {
address = args.address,
          parameters = args.parameters,
          options = { 'socket': socket, type:'WebSocket' }

      if( address in __admin ) {
        __admin[ address ]( parameters, options )
      }else{
        global.interface.handleMsgToClients( global.interface.livecodeServer, address, parameters )
      }
    })
  });
  // console.log( global.interface.websocketAdminIn )

  global.interface.count++;

  win = gui.Window.get();

  Mousetrap.bind('command+o', function() {  global.interface.openFile(); });
  Mousetrap.bind('command+s', function() {  global.interface.saveFile(); });
  Mousetrap.bind('command+r', function() {  win.reload(); });
  Mousetrap.bind('command+d', function() {  win.showDevTools(); });
  Mousetrap.bind('command+escape', function() { win.isFullscreen = !win.isFullscreen });

  $(window).on('load', function() {
    win.moveTo(0,0);
    win.resizeTo(1100, 500);
    win.blur();
    win.show();
  });
}
label: 'Save All',
		click: function() {
			$rootScope.$emit('editor.saveall');
		},
		key: 's',
		modifiers: 'cmd+shift'
	}),7);
	
	win.menu.insert(new gui.MenuItem({
		label: 'File',
		submenu: file
	}), 1);
			
			
	// project menu
	var project = new gui.Menu();
	
	project.insert(new gui.MenuItem({
		label: 'Run',
		click: function(){
			$rootScope.$emit('homey.run');
		},
		key: 'r',
		modifiers: 'cmd'
	}), 0);
	
	project.insert(new gui.MenuItem({
		label: 'Run and Break',
		click: function(){
			$rootScope.$emit('homey.runbrk');
		},
		key: 'r',
tray = new gui.Tray({ icon: 'assets/icon2.png'});

	/*
	 *	create the main tray menu and its items
	 */

	trayMenu = new gui.Menu();
	trayMenuItems.lastSlept = new gui.MenuItem({ type: 'normal', label: 'ugh', enabled: false });
	trayMenuItems.lastWoke = new gui.MenuItem({ type: 'normal', label: 'ugh', enabled: false });
	trayMenuItems.duration = new gui.MenuItem({ type: 'normal', label: 'ugh', enabled: false });
	trayMenuItems.sep1 = new gui.MenuItem({type: 'separator'});
	trayMenuItems.reasonLabel = new gui.MenuItem({type: 'normal', label: 'reason for sleep:', enabled: false});
	trayMenuItems.reason = new gui.MenuItem({ type: 'normal', label: 'ugh', enabled: false });
	trayMenuItems.sep2 = new gui.MenuItem({type: 'separator'});
	trayMenuItems.startup = new gui.MenuItem({type: 'checkbox', label: 'run on login?', checked: false});
	trayMenuItems.about = new gui.MenuItem({type: 'normal', label: 'about'});
	trayMenuItems.quit = new gui.MenuItem({ type: 'normal', label: 'quit', enabled: true });

	// TODO: make a button to refresh 
	
	/*
	 *	Logic + Event handling for MenuItems
	 */

	trayMenuItems.about.click = function() {
		var win = gui.Window.get();
		win.show();
		win.focus();
	};
	
	trayMenuItems.quit.click = function() { gui.App.quit(); }
function initSystray(){
 
	console.log("Init systray !\n");

	var ffi = require("ffi");
	/*var libm = new ffi.Library("libm", { "ceil": [ "double", [ "double" ] ] });
	libm.ceil(1.5); // 2

	console.log(" libm ceil(1.5) = "+ libm);*/

	// Create a tray icon
	tray = new gui.Tray({ title: 'Uhuru-AV', icon: 'img/uhuru_systray.png' });
	tray.menu = SystrayMenu();
}
var el = ev.target,
        bTextInput = el.nodeName === 'INPUT' || el.nodeName === 'TEXTAREA',
        iframedoc = getIframeDocument();

    // copy
    menuContext.items[0].enabled = bTextInput || !iframedoc.getSelection().isCollapsed;

    // copy link
    while (!(/^(a|html)$/i).test(el.nodeName)) {
        el = el.parentNode;
    }
    contextURL = 'href' in el ? el.href : '';
    menuContext.items[1].enabled = !!contextURL;

    // paste
    menuContext.items[2].enabled = bTextInput && !!gui.Clipboard.get().get('text');

    menuContext.popup(ev.x, ev.y);
    return false;
}
// :(, fail to register the |key| or couldn't parse the |key|.
          console.log(msg);
        }
      };
      // Create a shortcut with |option|.
      var shortcut = new gui.Shortcut(option);
      gui.App.registerGlobalHotKey(shortcut);
      // ...but turn it off when not focused
      win.on("blur", function() {
        gui.App.unregisterGlobalHotKey(shortcut);
      });
      win.on("focus", function() {
        gui.App.registerGlobalHotKey(shortcut);
      });

      window.clipboard = gui.Clipboard.get();
      Encryptr.prototype.copyToClipboard = function(text) {
        window.clipboard.set(text, 'text');
      };
      /* jshint node: false */
    } else {
      // Fallback to empty browser polyfill
      Encryptr.prototype.copyToClipboard = function() {};
    }
  };

Is your System Free of Underlying Vulnerabilities?
Find Out Now