Skip to content

Commit 7a6e61b

Browse files
committed
apply prettier format
1 parent a3fba71 commit 7a6e61b

File tree

7 files changed

+219
-216
lines changed

7 files changed

+219
-216
lines changed

example/Game.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ import { MyConfig } from "./config/MyConfig";
1414
import { RobotlegsView } from "./view/RobotlegsView";
1515

1616
export class Game {
17-
1817
private _canvas: HTMLCanvasElement;
1918
private _stage: createjs.Stage;
2019

2120
private _context: Context;
2221

23-
constructor () {
22+
constructor() {
2423
this.init();
2524
}
2625

2726
private init(): void {
28-
this._canvas = <HTMLCanvasElement>(document.getElementById("canvas"));
27+
this._canvas = <HTMLCanvasElement>document.getElementById("canvas");
2928
this._stage = new createjs.Stage(this._canvas);
3029

3130
this._context = new Context();
32-
this._context.install(MVCSBundle, CreateJSBundle).
33-
configure(new ContextView(this._stage)).
34-
configure(MyConfig).
35-
initialize();
31+
this._context
32+
.install(MVCSBundle, CreateJSBundle)
33+
.configure(new ContextView(this._stage))
34+
.configure(MyConfig)
35+
.initialize();
3636

3737
// enable touch interactions if supported on the current device:
3838
createjs.Touch.enable(this._stage);

static/index.html

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,42 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>RobotlegsJS CreateJS Boilerplate</title>
6+
<link rel="stylesheet" href="styles/main.css" />
7+
<link rel="stylesheet" href="styles/example.css" />
8+
<link rel="manifest" href="manifest.json" />
39

4-
<head>
5-
<meta charset="UTF-8">
6-
<title>RobotlegsJS CreateJS Boilerplate</title>
7-
<link rel="stylesheet" href="styles/main.css">
8-
<link rel="stylesheet" href="styles/example.css">
9-
<link rel="manifest" href="manifest.json">
10+
<script>
11+
if (navigator.serviceWorker) {
12+
navigator.serviceWorker
13+
.register("service-worker.js")
14+
.then(function() {
15+
console.log("service worker installed");
16+
})
17+
.catch(function(err) {
18+
console.log("Error", err);
19+
});
20+
}
21+
</script>
1022

11-
<script>
12-
if (navigator.serviceWorker) {
13-
navigator.serviceWorker.register('service-worker.js')
14-
.then(function () {
15-
console.log('service worker installed');
16-
})
17-
.catch(function (err) {
18-
console.log('Error', err);
19-
});
20-
}
21-
</script>
23+
<script src="<%= htmlWebpackPlugin.files.webpackConcat.createjs %>"></script>
24+
<script src="<%= htmlWebpackPlugin.files.chunks.main.entry %>"></script>
25+
</head>
2226

23-
<script src="<%= htmlWebpackPlugin.files.webpackConcat.createjs %>"></script>
24-
<script src="<%= htmlWebpackPlugin.files.chunks.main.entry %>"></script>
25-
</head>
27+
<body>
28+
<header class="CreateJS">
29+
<h1>integration with <a target="_blank" href="https://createjs.com/">CreateJS</a></h1>
30+
<p>
31+
This example shows how to integrate <code>RobotlegsJS</code> framework with <code>EaselJS</code>. Click on the logo to see
32+
some action!
33+
</p>
34+
</header>
2635

27-
<body>
28-
<header class="CreateJS">
29-
<h1>integration with <a target="_blank" href="https://createjs.com/">CreateJS</a></h1>
30-
<p>This example shows how to integrate <code>RobotlegsJS</code> framework with <code>EaselJS</code>. Click on the logo to see some action!</p>
31-
</header>
32-
33-
<canvas id="canvas" width="960" height="400"></canvas>
34-
35-
<script type="text/javascript">
36-
window.onload = initGame;
37-
</script>
38-
</body>
36+
<canvas id="canvas" width="960" height="400"></canvas>
3937

38+
<script type="text/javascript">
39+
window.onload = initGame;
40+
</script>
41+
</body>
4042
</html>

static/manifest.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
"display": "standalone",
66
"orientation": "landscape",
77
"icons": [
8-
{
9-
"src": "icon.png",
10-
"sizes": "512x512",
11-
"type": "image/png"
12-
},
8+
{
9+
"src": "icon.png",
10+
"sizes": "512x512",
11+
"type": "image/png"
12+
},
1313
{
1414
"src": "launcher-icon-2x.png",
1515
"sizes": "96x96",
@@ -26,4 +26,4 @@
2626
"type": "image/png"
2727
}
2828
]
29-
}
29+
}

static/scripts/cache-polyfill.js

Lines changed: 70 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -16,88 +16,87 @@
1616
*/
1717

1818
(function() {
19-
var nativeAddAll = Cache.prototype.addAll;
20-
var userAgent = navigator.userAgent.match(/(Firefox|Chrome)\/(\d+\.)/);
19+
var nativeAddAll = Cache.prototype.addAll;
20+
var userAgent = navigator.userAgent.match(/(Firefox|Chrome)\/(\d+\.)/);
2121

22-
// Has nice behavior of `var` which everyone hates
23-
if (userAgent) {
24-
var agent = userAgent[1];
25-
var version = parseInt(userAgent[2]);
26-
}
22+
// Has nice behavior of `var` which everyone hates
23+
if (userAgent) {
24+
var agent = userAgent[1];
25+
var version = parseInt(userAgent[2]);
26+
}
2727

28-
if (
29-
nativeAddAll && (!userAgent ||
30-
(agent === 'Firefox' && version >= 46) ||
31-
(agent === 'Chrome' && version >= 50)
32-
)
33-
) {
34-
return;
35-
}
28+
if (nativeAddAll && (!userAgent || (agent === "Firefox" && version >= 46) || (agent === "Chrome" && version >= 50))) {
29+
return;
30+
}
3631

37-
Cache.prototype.addAll = function addAll(requests) {
38-
var cache = this;
32+
Cache.prototype.addAll = function addAll(requests) {
33+
var cache = this;
3934

40-
// Since DOMExceptions are not constructable:
41-
function NetworkError(message) {
42-
this.name = 'NetworkError';
43-
this.code = 19;
44-
this.message = message;
45-
}
35+
// Since DOMExceptions are not constructable:
36+
function NetworkError(message) {
37+
this.name = "NetworkError";
38+
this.code = 19;
39+
this.message = message;
40+
}
4641

47-
NetworkError.prototype = Object.create(Error.prototype);
42+
NetworkError.prototype = Object.create(Error.prototype);
4843

49-
return Promise.resolve().then(function() {
50-
if (arguments.length < 1) throw new TypeError();
44+
return Promise.resolve()
45+
.then(function() {
46+
if (arguments.length < 1) throw new TypeError();
5147

52-
// Simulate sequence<(Request or USVString)> binding:
53-
var sequence = [];
48+
// Simulate sequence<(Request or USVString)> binding:
49+
var sequence = [];
5450

55-
requests = requests.map(function(request) {
56-
if (request instanceof Request) {
57-
return request;
58-
}
59-
else {
60-
return String(request); // may throw TypeError
61-
}
62-
});
51+
requests = requests.map(function(request) {
52+
if (request instanceof Request) {
53+
return request;
54+
} else {
55+
return String(request); // may throw TypeError
56+
}
57+
});
6358

64-
return Promise.all(
65-
requests.map(function(request) {
66-
if (typeof request === 'string') {
67-
request = new Request(request);
68-
}
59+
return Promise.all(
60+
requests.map(function(request) {
61+
if (typeof request === "string") {
62+
request = new Request(request);
63+
}
6964

70-
var scheme = new URL(request.url).protocol;
65+
var scheme = new URL(request.url).protocol;
7166

72-
if (scheme !== 'http:' && scheme !== 'https:') {
73-
throw new NetworkError("Invalid scheme");
74-
}
67+
if (scheme !== "http:" && scheme !== "https:") {
68+
throw new NetworkError("Invalid scheme");
69+
}
7570

76-
return fetch(request.clone());
77-
})
78-
);
79-
}).then(function(responses) {
80-
// If some of the responses has not OK-eish status,
81-
// then whole operation should reject
82-
if (responses.some(function(response) {
83-
return !response.ok;
84-
})) {
85-
throw new NetworkError('Incorrect response status');
86-
}
71+
return fetch(request.clone());
72+
})
73+
);
74+
})
75+
.then(function(responses) {
76+
// If some of the responses has not OK-eish status,
77+
// then whole operation should reject
78+
if (
79+
responses.some(function(response) {
80+
return !response.ok;
81+
})
82+
) {
83+
throw new NetworkError("Incorrect response status");
84+
}
8785

88-
// TODO: check that requests don't overwrite one another
89-
// (don't think this is possible to polyfill due to opaque responses)
90-
return Promise.all(
91-
responses.map(function(response, i) {
92-
return cache.put(requests[i], response);
93-
})
94-
);
95-
}).then(function() {
96-
return undefined;
97-
});
98-
};
86+
// TODO: check that requests don't overwrite one another
87+
// (don't think this is possible to polyfill due to opaque responses)
88+
return Promise.all(
89+
responses.map(function(response, i) {
90+
return cache.put(requests[i], response);
91+
})
92+
);
93+
})
94+
.then(function() {
95+
return undefined;
96+
});
97+
};
9998

100-
Cache.prototype.add = function add(request) {
101-
return this.addAll([request]);
102-
};
103-
}());
99+
Cache.prototype.add = function add(request) {
100+
return this.addAll([request]);
101+
};
102+
})();

static/service-worker.js

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,56 @@
1-
importScripts('scripts/cache-polyfill.js');
1+
importScripts("scripts/cache-polyfill.js");
22

3-
var CACHE_VERSION = 'app-v1';
4-
var CACHE_FILES = [
5-
'index.html'
6-
];
3+
var CACHE_VERSION = "app-v1";
4+
var CACHE_FILES = ["index.html"];
75

8-
self.addEventListener('install', function (event) {
6+
self.addEventListener("install", function(event) {
97
event.waitUntil(
10-
caches.open(CACHE_VERSION)
11-
.then(function (cache) {
12-
console.log('Opened cache');
13-
return cache.addAll(CACHE_FILES);
14-
})
8+
caches.open(CACHE_VERSION).then(function(cache) {
9+
console.log("Opened cache");
10+
return cache.addAll(CACHE_FILES);
11+
})
1512
);
1613
});
1714

18-
self.addEventListener('activate', function (event) {
15+
self.addEventListener("activate", function(event) {
1916
event.waitUntil(
20-
caches.keys().then(function(keys){
21-
return Promise.all(keys.map(function(key, i){
22-
if(key !== CACHE_VERSION){
23-
return caches.delete(keys[i]);
24-
}
25-
}))
17+
caches.keys().then(function(keys) {
18+
return Promise.all(
19+
keys.map(function(key, i) {
20+
if (key !== CACHE_VERSION) {
21+
return caches.delete(keys[i]);
22+
}
23+
})
24+
);
2625
})
27-
)
26+
);
2827
});
2928

30-
self.addEventListener('fetch', function (event) {
29+
self.addEventListener("fetch", function(event) {
3130
event.respondWith(
32-
caches.match(event.request).then(function(res){
33-
if(res){
31+
caches.match(event.request).then(function(res) {
32+
if (res) {
3433
return res;
3534
}
3635
requestBackend(event);
3736
})
38-
)
37+
);
3938
});
4039

41-
function requestBackend(event){
40+
function requestBackend(event) {
4241
var url = event.request.clone();
43-
return fetch(url).then(function(res){
42+
return fetch(url).then(function(res) {
4443
//if not a valid response send the error
45-
if(!res || res.status !== 200 || res.type !== 'basic'){
44+
if (!res || res.status !== 200 || res.type !== "basic") {
4645
return res;
4746
}
4847

4948
var response = res.clone();
5049

51-
caches.open(CACHE_VERSION).then(function(cache){
50+
caches.open(CACHE_VERSION).then(function(cache) {
5251
cache.put(event.request, response);
5352
});
5453

5554
return res;
56-
})
57-
}
55+
});
56+
}

0 commit comments

Comments
 (0)