Skip to content

Commit 3322526

Browse files
committed
First version
1 parent b9bda85 commit 3322526

File tree

10 files changed

+110
-2
lines changed

10 files changed

+110
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
codebox-chrome
1+
Codebox for Google Chrome
22
==============
33

4-
Google Chrome Application for Codebox
4+
Google Chrome Packaged Application for Codebox.

icons/128.png

2.43 KB
Loading

icons/32.png

863 Bytes
Loading

icons/48.png

1.54 KB
Loading

icons/72.png

1.85 KB
Loading

main.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Listens for the app launching then creates the window
3+
*
4+
* @see http://developer.chrome.com/trunk/apps/app.runtime.html
5+
* @see http://developer.chrome.com/trunk/apps/app.window.html
6+
*/
7+
chrome.app.runtime.onLaunched.addListener(function() {
8+
runApp();
9+
});
10+
11+
/**
12+
* Listens for the app restarting then re-creates the window.
13+
*
14+
* @see http://developer.chrome.com/trunk/apps/app.runtime.html
15+
*/
16+
chrome.app.runtime.onRestarted.addListener(function() {
17+
runApp();
18+
});
19+
20+
/**
21+
* Creates the window for the application.
22+
*
23+
* @see http://developer.chrome.com/trunk/apps/app.window.html
24+
*/
25+
function runApp() {
26+
chrome.app.window.create('window.html', {
27+
bounds: {
28+
'width': 1364,
29+
'height': 768,
30+
}
31+
});
32+
}

manifest.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"manifest_version": 2,
3+
"minimum_chrome_version": "24.0.1307.0",
4+
"name": "Codebox",
5+
"description": "Cloud IDE as a Service.",
6+
"permissions": [
7+
"unlimitedStorage", "webview"
8+
],
9+
"version": "1",
10+
"app": {
11+
"background": {
12+
"scripts": ["main.js"]
13+
}
14+
},
15+
"icons": {
16+
"128": "icons/128.png",
17+
"32": "icons/32.png"
18+
}
19+
}

window.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
body {
2+
margin: 0;
3+
padding: 0;
4+
font-family: Lucida Grande, Arial, sans-serif;
5+
}

window.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Codebox</title>
5+
<link rel="stylesheet" href="window.css">
6+
<script src="window.js"></script>
7+
<body>
8+
<webview style="width:640px; height:480px" partition="persist:codebox"></webview>
9+
</body>
10+
</html>

window.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
window.onresize = doLayout;
2+
var baseHost = "https://www.codebox.io";
3+
var userAgent = "codebox-app";
4+
5+
onload = function() {
6+
var webview = getWebview();
7+
8+
doLayout();
9+
webview.setUserAgentOverride(userAgent);
10+
webview.addEventListener('newwindow', function(e) {
11+
window.open(e.targetUrl);
12+
});
13+
webview.addEventListener('loadredirect', function(e) {
14+
if (e.originalEvent.targetUrl.indexOf(baseHost) == 0) {
15+
return;
16+
}
17+
e.preventDefault();
18+
window.open(e.newUrl);
19+
return;
20+
});
21+
22+
navigateTo(baseHost);
23+
};
24+
25+
function getWebview() {
26+
return document.querySelector('webview');
27+
}
28+
29+
function navigateTo(url) {
30+
document.querySelector('webview').src = url;
31+
}
32+
33+
function doLayout() {
34+
var webview = getWebview();
35+
var windowWidth = document.documentElement.clientWidth;
36+
var windowHeight = document.documentElement.clientHeight;
37+
var webviewWidth = windowWidth;
38+
var webviewHeight = windowHeight;
39+
40+
webview.style.width = webviewWidth + 'px';
41+
webview.style.height = webviewHeight + 'px';
42+
}

0 commit comments

Comments
 (0)