MCPcopy Create free account
hub / github.com/nwutils/nw-sample-apps / showHtmlNotification

Function showHtmlNotification

notifications/app.js:137–173  ·  view source on GitHub ↗
(icon, title, body, callback)

Source from the content-addressed store, hash-verified

135
136// NW-NOTIFY
137var showHtmlNotification = function (icon, title, body, callback) {
138 var notifier;
139 try {
140 notifier = require('nw-notify');
141 } catch (error) {
142 console.error(error);
143 if (error.message == "Cannot find module 'nw-notify'") {
144 window.alert("Can not load module 'nw-notify'.\nPlease run 'npm install'");
145 return false;
146 }
147 }
148
149 // give it nice look
150 notifier.setConfig({
151 displayTime: 6000
152 });
153
154 if (icon) icon = notifier.getAppPath() + icon;
155
156 notifier.notify({
157 title: title,
158 text: body,
159 image: icon,
160 onShowFunc: function (event) {
161 if (callback) callback(event);
162 writeLog("-----<br>nw-notify: " + title);
163 },
164 onClickFunc: function (event) {
165 writeLog("nw-notify notification clicked");
166 },
167 onCloseFunc: function (event) {
168 if (event.event == 'close') {
169 writeLog("nw-notify notification closed ");
170 }
171 }
172 });
173};

Callers 1

app.jsFile · 0.85

Calls 1

writeLogFunction · 0.70

Tested by

no test coverage detected