File tree Expand file tree Collapse file tree 10 files changed +110
-2
lines changed Expand file tree Collapse file tree 10 files changed +110
-2
lines changed Original file line number Diff line number Diff line change 1
- codebox-chrome
1
+ Codebox for Google Chrome
2
2
==============
3
3
4
- Google Chrome Application for Codebox
4
+ Google Chrome Packaged Application for Codebox.
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
1
+ body {
2
+ margin : 0 ;
3
+ padding : 0 ;
4
+ font-family : Lucida Grande, Arial, sans-serif;
5
+ }
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments