38 lines
932 B
JavaScript
38 lines
932 B
JavaScript
'use strict';
|
|
|
|
angular.module('copayApp.services').factory('nodeWebkit', function nodeWebkitFactory() {
|
|
var root = {};
|
|
|
|
var isNodeWebkit = function() {
|
|
var isNode = (typeof process !== "undefined" && typeof require !== "undefined");
|
|
if(isNode) {
|
|
try {
|
|
return (typeof require('nw.gui') !== "undefined");
|
|
} catch(e) {
|
|
return false;
|
|
}
|
|
}
|
|
};
|
|
|
|
root.readFromClipboard = function() {
|
|
if (!isNodeWebkit()) return;
|
|
var gui = require('nw.gui');
|
|
var clipboard = gui.Clipboard.get();
|
|
return clipboard.get();
|
|
};
|
|
|
|
root.writeToClipboard = function(text) {
|
|
if (!isNodeWebkit()) return;
|
|
var gui = require('nw.gui');
|
|
var clipboard = gui.Clipboard.get();
|
|
return clipboard.set(text);
|
|
};
|
|
|
|
root.openExternalLink = function(url) {
|
|
if (!isNodeWebkit()) return;
|
|
var gui = require('nw.gui');
|
|
return gui.Shell.openExternal(url);
|
|
};
|
|
|
|
return root;
|
|
});
|