-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy patheventPage.js
More file actions
executable file
·57 lines (49 loc) · 1.98 KB
/
eventPage.js
File metadata and controls
executable file
·57 lines (49 loc) · 1.98 KB
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
'use strict';
function startApplication() {
var applicationStartTime = new Date().getTime();
chrome.app.window.create('main.html', {
id: 'main-window',
frame: 'chrome',
innerBounds: {
minWidth: 850,
minHeight: 650
}
}, function (createdWindow) {
createdWindow.onClosed.addListener(function () {
var connectionId = createdWindow.contentWindow.serialDevice.connectionId;
if (connectionId) {
chrome.serialDevice.disconnect(connectionId, function (result) {
console.log('SERIAL: Connection closed - ' + result);
});
}
});
});
}
chrome.app.runtime.onLaunched.addListener(startApplication);
chrome.runtime.onInstalled.addListener(function (details) {
if (details.reason == 'update') {
var previousVersionArr = details.previousVersion.split('.'), currentVersionArr = chrome.runtime.getManifest().version.split('.');
// only fire up notification sequence when one of the major version
// numbers changed
if (currentVersionArr[0] > previousVersionArr[0] || currentVersionArr[1] > previousVersionArr[1]) {
var manifest = chrome.runtime.getManifest();
var options = {
priority: 0,
type: 'basic',
title: manifest.name,
message: 'Application just updated to version: ' + manifest.version,
iconUrl: '/images/icon_128.png',
buttons: [{
'title': 'Click here to start the application'
}]
};
chrome.notifications.create('update', options, function (notificationId) {
// empty
});
}
}
});
chrome.notifications.onButtonClicked.addListener(function (notificationId, buttonIndex) {
if (notificationId == 'update')
startApplication();
});