diff --git a/app/assets/js/index.js b/app/assets/js/index.js index 2042142..e9902b6 100644 --- a/app/assets/js/index.js +++ b/app/assets/js/index.js @@ -8,13 +8,11 @@ ipc.on('params', function(message) { var appArgs = JSON.parse(message); - console.log(appArgs.targetUrl); - console.log(appArgs.name); - document.title = appArgs.name; var webView = document.createElement('webview'); + webView.setAttribute('id', 'webView'); webView.setAttribute('src', appArgs.targetUrl); webView.setAttribute('autosize', 'on'); webView.setAttribute('minwidth', '600'); @@ -23,5 +21,29 @@ ipc.on('params', function(message) { var webViewDiv = document.getElementById('webViewDiv'); webViewDiv.appendChild(webView); + Mousetrap.bind('mod+c', function(e) { + var webView = document.getElementById('webView'); + webView.copy(); + }); + + Mousetrap.bind('mod+x', function(e) { + var webView = document.getElementById('webView'); + webView.cut(); + }); + + Mousetrap.bind('mod+v', function(e) { + var webView = document.getElementById('webView'); + webView.paste(); + }); + + Mousetrap.bind('mod+a', function(e) { + var webView = document.getElementById('webView'); + webView.selectAll(); + }); + + Mousetrap.bind('mod+z', function(e) { + var webView = document.getElementById('webView'); + webView.undo(); + }); }); diff --git a/app/assets/js/libs/mousetrap.min.js b/app/assets/js/libs/mousetrap.min.js new file mode 100644 index 0000000..291aff8 --- /dev/null +++ b/app/assets/js/libs/mousetrap.min.js @@ -0,0 +1,11 @@ +/* mousetrap v1.5.3 craig.is/killing/mice */ +(function(C,r,g){function t(a,b,h){a.addEventListener?a.addEventListener(b,h,!1):a.attachEvent("on"+b,h)}function x(a){if("keypress"==a.type){var b=String.fromCharCode(a.which);a.shiftKey||(b=b.toLowerCase());return b}return l[a.which]?l[a.which]:p[a.which]?p[a.which]:String.fromCharCode(a.which).toLowerCase()}function D(a){var b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");return b}function u(a){return"shift"==a||"ctrl"==a||"alt"==a|| +"meta"==a}function y(a,b){var h,c,e,g=[];h=a;"+"===h?h=["+"]:(h=h.replace(/\+{2}/g,"+plus"),h=h.split("+"));for(e=0;em||l.hasOwnProperty(m)&&(k[l[m]]=m)}e=k[h]?"keydown":"keypress"}"keypress"==e&&g.length&&(e="keydown");return{key:c,modifiers:g,action:e}}function B(a,b){return null===a||a===r?!1:a===b?!0:B(a.parentNode,b)}function c(a){function b(a){a= +a||{};var b=!1,n;for(n in q)a[n]?b=!0:q[n]=0;b||(v=!1)}function h(a,b,n,f,c,h){var g,e,l=[],m=n.type;if(!d._callbacks[a])return[];"keyup"==m&&u(a)&&(b=[a]);for(g=0;g":".","?":"/","|":"\\"},z={option:"alt",command:"meta","return":"enter", +escape:"esc",plus:"+",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},k;for(g=1;20>g;++g)l[111+g]="f"+g;for(g=0;9>=g;++g)l[g+96]=g;c.prototype.bind=function(a,b,c){a=a instanceof Array?a:[a];this._bindMultiple.call(this,a,b,c);return this};c.prototype.unbind=function(a,b){return this.bind.call(this,a,function(){},b)};c.prototype.trigger=function(a,b){if(this._directMap[a+":"+b])this._directMap[a+":"+b]({},a);return this};c.prototype.reset=function(){this._callbacks={};this._directMap= +{};return this};c.prototype.stopCallback=function(a,b){return-1<(" "+b.className+" ").indexOf(" mousetrap ")||B(b,this.target)?!1:"INPUT"==b.tagName||"SELECT"==b.tagName||"TEXTAREA"==b.tagName||b.isContentEditable};c.prototype.handleKey=function(){return this._handleKey.apply(this,arguments)};c.init=function(){var a=c(r),b;for(b in a)"_"!==b.charAt(0)&&(c[b]=function(b){return function(){return a[b].apply(a,arguments)}}(b))};c.init();C.Mousetrap=c;"undefined"!==typeof module&&module.exports&&(module.exports= +c);"function"===typeof define&&define.amd&&define(function(){return c})})(window,document); diff --git a/app/index.html b/app/index.html index 3f5b1e7..c19deef 100644 --- a/app/index.html +++ b/app/index.html @@ -4,6 +4,7 @@ Nativefier + diff --git a/app/main.js b/app/main.js index 34ea2b7..aed08e3 100644 --- a/app/main.js +++ b/app/main.js @@ -31,6 +31,7 @@ app.on('ready', function() { ); mainWindow.loadUrl('file://' + __dirname + '/index.html'); + mainWindow.openDevTools(); mainWindow.webContents.on('did-finish-load', function() { fs.readFile(APP_ARGS_FILE_PATH, 'utf8', function (error, data) { if (error) { @@ -38,6 +39,7 @@ app.on('ready', function() { } else { console.log(data); mainWindow.webContents.send('params', data); + } }) @@ -48,5 +50,4 @@ app.on('ready', function() { mainWindow = null; }) -}); - +}); \ No newline at end of file