일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- node.js
- Statistics
- 김양재 목사
- 김양재 목사님
- 데이터 과학
- 딥러닝
- openCV
- 김양재
- R
- 주일설교
- MongoDB
- data science
- 확률
- No SQL
- 빅데이터
- 빅 데이타
- nodeJS
- Machine Learning
- 빅 데이터
- 통계
- 몽고디비
- WebGL
- probability
- Big Data
- 빅데이타
- 우리들교회
- Deep learning
- 인공지능
- Artificial Intelligence
- c++
Archives
- Today
- Total
Scientific Computing & Data Science
[WebApp / Node Webkit] Example 10 - Using Node Modules 본문
Programming/Web App
[WebApp / Node Webkit] Example 10 - Using Node Modules
cinema4dr12 2016. 2. 8. 21:42목 차
이번 글에서는 Node Module을 활용하는 방법을 알아보도록 하겠다.
Codes
package.json
{ "main": "index.html", "name": "using node modules", "window": { "toolbar": false, "frame" : false, "icon": "./icons/icon.png" } }
index.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | <!doctype html> <html lang='en'> <head> <meta charset='UTF-8'> <title>Using Node Modules Example</title> <link rel='stylesheet' href='reset.css'> <link rel='stylesheet' href='style.css'> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script> var nw = require('nw.gui'); var win = nw.Window.get(); win.isMaximized = false; $(document).ready(function() { // System details (CPU / Memory, etc) var os = require('os'); // File operations var fs = require('fs'); // String which we'll write to file var content = ''; var htmlContent = ''; // Platform Info content += '[Platform]' + os.EOL; content += 'OS Type : ' + os.platform() + os.EOL; // linux, darwin, win32, sunos, freebsd content += 'OS Version : ' + os.release() + os.EOL; content += 'OS Architecture: ' + os.arch() + os.EOL; content += os.EOL; htmlContent += '<p>' + '[Platform]' + '</p>'; htmlContent += '<p>' + 'OS Type : ' + os.platform() + '</p>'; htmlContent += '<p>' + 'OS Version : ' + os.release() + '</p>'; htmlContent += '<p>' + 'OS Architecture: ' + os.arch() + '</p>'; htmlContent += '<p> </p>'; // Memory info content += '[Memory]' + os.EOL; content += 'Total (Bytes) : ' + os.totalmem() + os.EOL; content += 'Free (Bytes) : ' + os.freemem() + os.EOL; content += 'Free (%) : ' + (os.freemem() / os.totalmem() * 100).toFixed(2) + os.EOL; content += os.EOL; htmlContent += '<p>' + '[Memory]' + '</p>'; htmlContent += '<p>' + 'Total (Bytes) : ' + os.totalmem() + '</p>'; htmlContent += '<p>' + 'Free (Bytes) : ' + os.freemem() + '</p>'; htmlContent += '<p>' + 'Free (%) : ' + (os.freemem() / os.totalmem() * 100).toFixed(2) + '</p>'; htmlContent += '<p> </p>'; // CPU Info content += '[CPUs]' + os.EOL; content += 'No. of Cores : ' + os.cpus().length + os.EOL; content += 'Core Type : ' + os.cpus()[0].model + os.EOL; htmlContent += '<p>' + '[CPUs]' + '</p>'; htmlContent += '<p>' + 'No. of Cores : ' + os.cpus().length + '</p>'; htmlContent += '<p>' + 'Core Type : ' + os.cpus()[0].model + '</p>'; htmlContent += '<p> </p>'; $("body").append(htmlContent); // Write to file fs.writeFile('./sysinfo.txt', content, function(err) { if (err) { htmlContent = '<p>Error writing file.</p>' $("body").append(htmlContent); } else { htmlContent = '<p>File successfully written.</p>' $("body").append(htmlContent); } }); }); </script> </head> <body> <header> <ul> <li><a href='#' title='Minimize' id='windowControlMinimize'></a></li> <li><a href='#' title='Maximize' id='windowControlMaximize'></a></li> <li><a href='#' title='Close' id='windowControlClose' ></a></li> </ul> </header> <script> // Min document.getElementById('windowControlMinimize').onclick = function() { win.minimize(); }; // Close document.getElementById('windowControlClose').onclick = function() { win.close(); }; // Max document.getElementById('windowControlMaximize').onclick = function() { if (win.isMaximized) win.unmaximize(); else win.maximize(); }; win.on('maximize', function(){ win.isMaximized = true; }); win.on('unmaximize', function(){ win.isMaximized = false; }); </script> </body> </html> | cs |
Results
On Windows
sysinfo.txt
sysinfo.txt는 자신의 시스템 사양에 따라 다르다.
On MacOS
'Programming > Web App' 카테고리의 다른 글
[WebApp / Node Webkit] Example 12 - Notifications Example (0) | 2016.02.13 |
---|---|
[WebApp / Node Webkit] Example 11 - Using Third Party Modules (0) | 2016.02.09 |
[WebApp / Node Webkit] Example 9 - Window Menus (0) | 2016.02.08 |
[WebApp / Node Webkit] Example 8 - Context Menus (0) | 2016.02.08 |
[WebApp / Node Webkit] Example 7 - Custom Window Control (0) | 2016.02.07 |
Comments