New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nw-dialog

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nw-dialog - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

48

index.js

@@ -14,6 +14,3 @@ 'use strict';

var fn = callback;
var node = this._context.getElementById('open-file-dialog');
if (node === null) {
node = this._context.createElement('input');
}
var node = this._context.createElement('input');
node.type = 'file';

@@ -26,3 +23,7 @@ node.id = 'open-file-dialog';

} else if (typeof filter === 'string') {
node.accept = filter;
node.setAttribute('accept', filter);
} else if (this.isArray(filter)) {
node.setAttribute('accept', filter.join(','));
} else if (typeof filter === 'boolean' && filter === true) {
node.setAttribute('multiple', '');
}

@@ -33,3 +34,5 @@

} else if (typeof multiple === 'boolean' && multiple === true) {
node.multiple = multiple;
node.setAttribute('multiple', '');
} else if (typeof multiple === 'string') {
node.setAttribute('nwdirectory', ''); // not work in 0.13
}

@@ -40,2 +43,3 @@

fn(node.value);
node.remove();
});

@@ -46,13 +50,10 @@ node.click();

saveFileDialog: function(name, directory, callback) {
saveFileDialog: function(name, accept, directory, callback) {
var fn = callback;
var node = this._context.getElementById('save-file-dialog');
if (node === null) {
node = this._context.createElement('input');
}
var node = this._context.createElement('input');
node.type = 'file';
node.id = 'save-file-dialog';
node.style = 'display: none';
node.nwsaveas = '';
node.setAttribute('nwsaveas', '');

@@ -62,9 +63,17 @@ if (typeof name === 'function') {

} else if (typeof name === 'string') {
node.nwsaveas = name;
node.setAttribute('nwsaveas', name);
}
if (typeof accept === 'function') {
fn = accept;
} else if (typeof accept === 'string') {
node.setAttribute('accept', accept);
} else if (this.isArray(accept)) {
node.setAttribute('accept', accept.join(','));
}
if (typeof directory === 'function') {
fn = directory;
} else if (typeof directory === 'string') {
node.nwworkingdir = directory;
node.setAttribute('nwdirectory', directory); //not work in 0.13
}

@@ -75,2 +84,3 @@

fn(node.value);
node.remove();
});

@@ -82,6 +92,3 @@ node.click();

folderBrowserDialog: function(callback) {
var node = this._context.getElementById('folder-browser-dialog');
if (node === null) {
node = this._context.createElement('input');
}
var node = this._context.createElement('input');
node.type = 'file';

@@ -95,4 +102,9 @@ node.id = 'folder-browser-dialog';

callback(node.value);
node.remove();
});
node.click();
},
isArray: function(value) {
return Object.prototype.toString.call(value) === '[object Array]';
}

@@ -99,0 +111,0 @@

{
"name": "nw-dialog",
"version": "1.0.3",
"version": "1.0.4",
"description": "Node Webkit Dialog",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,2 +7,5 @@ # nw-dialog

`npm install nw-dialog -S`
```

@@ -20,3 +23,3 @@ var dialog = require('nw-dialog')

// or
window.Dialog.openFileDialog( ... )
Dialog.openFileDialog( ... )
```

@@ -37,13 +40,26 @@

```
dialog.openFileDialog('.zip, .rar', function(result) {
dialog.openFileDialog('.zip,.rar', function(result) {
alert(result)
})
// or
dialog.openFileDialog(['.zip', '.rar'], function(result) {
alert(result)
})
```
Multiple select
```
dialog.openFileDialog('.zip, .rar', true, function(result) {
dialog.openFileDialog(true, function(result) {
alert(result)
})
// with file type
dialog.openFileDialog('.zip,.rar', true, function(result) {
alert(result)
})
```

@@ -60,3 +76,3 @@

With file name
File name

@@ -69,6 +85,20 @@ ```

File name and default directory
With extension
```
dialog.saveFileDialog('name.txt', '/Users/didanurwanda', function(result) {
dialog.saveFileDialog('name', '.txt', function(result) {
alert(result)
})
// or
dialog.saveFileDialog('name', ['.txt', '.srt'], function(result) {
alert(result)
})
```
Default directory
```
dialog.saveFileDialog('name', '.txt', '/Users/didanurwanda', function(result) {
alert(result)

@@ -75,0 +105,0 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc