forked from jomurgel/PocketCaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
executable file
·85 lines (69 loc) · 2.43 KB
/
background.js
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
/**
* Listens for the app launching then creates the window
*
* @see http://developer.chrome.com/apps/app.runtime.html
* @see http://developer.chrome.com/apps/app.window.html
*/
chrome.app.runtime.onLaunched.addListener(function () {
// Center this shiz. Boom.
var screenWidth = screen.availWidth;
var screenHeight = screen.availHeight;
var width = 1100;
var height = 700;
var mainWindow = chrome.app.window.create('index.html', {
id: "mainWindowID",
bounds: {
width: width,
height: height,
left: Math.round((screenWidth - width) / 2),
top: Math.round((screenHeight - height) / 2)
}
},
function(window) {
window.contentWindow.onload = function () {
// Retrieve the webview element
var webview = window.contentWindow.document.querySelector('#pcast');
webview.addEventListener('newwindow', function (e) {
// Event handler for when external links are clicked because of
// the Chrome packaged app security restriction on opening links in the regular browser
e.preventDefault();
window.open(e.targetUrl);
});
};
});
});
// function creationCallback(notID) {
// console.log("Succesfully created " + notID + " notification");
// }
// window.webkitNotifications.createNotification
// ("images/antartica-400x400.png","Notifications App", "Notifications App started").show();
// // When new or updated!
// chrome.app.runtime.onInstalled.addListener(function() {
// //
// });
//https://github.com/aaroncrespo/chrome-packaged-music/blob/master/player.js
// function buttonClick(callback) {
// }
// function pausePlay() {
// pcTabs = [];
// chrome.app.window.getAll({ populate : true }, getWindows);
// }
// function getWindows(windows) {
// document.getElementById("pcasts").executeScript({ file : "pcasts.js" }, onMainExecuted);
// }
// function onMainExecuted(result) {
// if(result == "jqueryIsNotExists")
// chrome.tabs.executeScript(pcTabs[0].id, { file : "jquery.js" }, onJqueryExecuted);
// else
// playPause(result);
// }
// function onJqueryExecuted(result) {
// chrome.tabs.executeScript(pcTabs[0].id, { file : "pcasts.js" }, onMainExecuted);
// }
// function playPause(result){
// if (result != "nothingToPlay") {
// console.log('music');
// } else { // nothing to play
// console.log('nothing');
// }
// }