Skip to content

Commit a905bdf

Browse files
committed
Prettier.io
1 parent 6b335fb commit a905bdf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+13159
-10611
lines changed

assets/javascripts/app/app.js

+191-90
Large diffs are not rendered by default.

assets/javascripts/app/db.js

+214-110
Large diffs are not rendered by default.

assets/javascripts/app/router.js

+101-61
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
const Cls = (app.Router = class Router {
1313
static initClass() {
1414
$.extend(this.prototype, Events);
15-
15+
1616
this.routes = [
17-
['*', 'before' ],
18-
['/', 'root' ],
19-
['/settings', 'settings' ],
20-
['/offline', 'offline' ],
21-
['/about', 'about' ],
22-
['/news', 'news' ],
23-
['/help', 'help' ],
24-
['/:doc-:type/', 'type' ],
25-
['/:doc/', 'doc' ],
26-
['/:doc/:path(*)', 'entry' ],
27-
['*', 'notFound' ]
17+
["*", "before"],
18+
["/", "root"],
19+
["/settings", "settings"],
20+
["/offline", "offline"],
21+
["/about", "about"],
22+
["/news", "news"],
23+
["/help", "help"],
24+
["/:doc-:type/", "type"],
25+
["/:doc/", "doc"],
26+
["/:doc/:path(*)", "entry"],
27+
["*", "notFound"],
2828
];
2929
}
3030

@@ -45,16 +45,16 @@ const Cls = (app.Router = class Router {
4545

4646
triggerRoute(name) {
4747
this.trigger(name, this.context);
48-
this.trigger('after', name, this.context);
48+
this.trigger("after", name, this.context);
4949
}
5050

5151
before(context, next) {
5252
let res;
5353
const previousContext = this.context;
5454
this.context = context;
55-
this.trigger('before', context);
55+
this.trigger("before", context);
5656

57-
if (res = next()) {
57+
if ((res = next())) {
5858
this.context = previousContext;
5959
return res;
6060
} else {
@@ -64,10 +64,14 @@ const Cls = (app.Router = class Router {
6464

6565
doc(context, next) {
6666
let doc;
67-
if (doc = app.docs.findBySlug(context.params.doc) || app.disabledDocs.findBySlug(context.params.doc)) {
67+
if (
68+
(doc =
69+
app.docs.findBySlug(context.params.doc) ||
70+
app.disabledDocs.findBySlug(context.params.doc))
71+
) {
6872
context.doc = doc;
6973
context.entry = doc.toEntry();
70-
this.triggerRoute('entry');
74+
this.triggerRoute("entry");
7175
return;
7276
} else {
7377
return next();
@@ -78,10 +82,13 @@ const Cls = (app.Router = class Router {
7882
let type;
7983
const doc = app.docs.findBySlug(context.params.doc);
8084

81-
if (type = doc != null ? doc.types.findBy('slug', context.params.type) : undefined) {
85+
if (
86+
(type =
87+
doc != null ? doc.types.findBy("slug", context.params.type) : undefined)
88+
) {
8289
context.doc = doc;
8390
context.type = type;
84-
this.triggerRoute('type');
91+
this.triggerRoute("type");
8592
return;
8693
} else {
8794
return next();
@@ -91,111 +98,144 @@ const Cls = (app.Router = class Router {
9198
entry(context, next) {
9299
let entry;
93100
const doc = app.docs.findBySlug(context.params.doc);
94-
if (!doc) { return next(); }
95-
let {
96-
path
97-
} = context.params;
98-
const {
99-
hash
100-
} = context;
101-
102-
if (entry = doc.findEntryByPathAndHash(path, hash)) {
101+
if (!doc) {
102+
return next();
103+
}
104+
let { path } = context.params;
105+
const { hash } = context;
106+
107+
if ((entry = doc.findEntryByPathAndHash(path, hash))) {
103108
context.doc = doc;
104109
context.entry = entry;
105-
this.triggerRoute('entry');
110+
this.triggerRoute("entry");
106111
return;
107-
} else if (path.slice(-6) === '/index') {
112+
} else if (path.slice(-6) === "/index") {
108113
path = path.substr(0, path.length - 6);
109-
if (entry = doc.findEntryByPathAndHash(path, hash)) { return entry.fullPath(); }
114+
if ((entry = doc.findEntryByPathAndHash(path, hash))) {
115+
return entry.fullPath();
116+
}
110117
} else {
111118
path = `${path}/index`;
112-
if (entry = doc.findEntryByPathAndHash(path, hash)) { return entry.fullPath(); }
119+
if ((entry = doc.findEntryByPathAndHash(path, hash))) {
120+
return entry.fullPath();
121+
}
113122
}
114123

115124
return next();
116125
}
117126

118127
root() {
119-
if (app.isSingleDoc()) { return '/'; }
120-
this.triggerRoute('root');
128+
if (app.isSingleDoc()) {
129+
return "/";
130+
}
131+
this.triggerRoute("root");
121132
}
122133

123134
settings(context) {
124-
if (app.isSingleDoc()) { return `/#/${context.path}`; }
125-
this.triggerRoute('settings');
135+
if (app.isSingleDoc()) {
136+
return `/#/${context.path}`;
137+
}
138+
this.triggerRoute("settings");
126139
}
127140

128-
offline(context){
129-
if (app.isSingleDoc()) { return `/#/${context.path}`; }
130-
this.triggerRoute('offline');
141+
offline(context) {
142+
if (app.isSingleDoc()) {
143+
return `/#/${context.path}`;
144+
}
145+
this.triggerRoute("offline");
131146
}
132147

133148
about(context) {
134-
if (app.isSingleDoc()) { return `/#/${context.path}`; }
135-
context.page = 'about';
136-
this.triggerRoute('page');
149+
if (app.isSingleDoc()) {
150+
return `/#/${context.path}`;
151+
}
152+
context.page = "about";
153+
this.triggerRoute("page");
137154
}
138155

139156
news(context) {
140-
if (app.isSingleDoc()) { return `/#/${context.path}`; }
141-
context.page = 'news';
142-
this.triggerRoute('page');
157+
if (app.isSingleDoc()) {
158+
return `/#/${context.path}`;
159+
}
160+
context.page = "news";
161+
this.triggerRoute("page");
143162
}
144163

145164
help(context) {
146-
if (app.isSingleDoc()) { return `/#/${context.path}`; }
147-
context.page = 'help';
148-
this.triggerRoute('page');
165+
if (app.isSingleDoc()) {
166+
return `/#/${context.path}`;
167+
}
168+
context.page = "help";
169+
this.triggerRoute("page");
149170
}
150171

151172
notFound(context) {
152-
this.triggerRoute('notFound');
173+
this.triggerRoute("notFound");
153174
}
154175

155176
isIndex() {
156-
return ((this.context != null ? this.context.path : undefined) === '/') || (app.isSingleDoc() && __guard__(this.context != null ? this.context.entry : undefined, x => x.isIndex()));
177+
return (
178+
(this.context != null ? this.context.path : undefined) === "/" ||
179+
(app.isSingleDoc() &&
180+
__guard__(this.context != null ? this.context.entry : undefined, (x) =>
181+
x.isIndex(),
182+
))
183+
);
157184
}
158185

159186
isSettings() {
160-
return (this.context != null ? this.context.path : undefined) === '/settings';
187+
return (
188+
(this.context != null ? this.context.path : undefined) === "/settings"
189+
);
161190
}
162191

163192
setInitialPath() {
164193
// Remove superfluous forward slashes at the beginning of the path
165194
let path;
166-
if ((path = location.pathname.replace(/^\/{2,}/g, '/')) !== location.pathname) {
195+
if (
196+
(path = location.pathname.replace(/^\/{2,}/g, "/")) !== location.pathname
197+
) {
167198
page.replace(path + location.search + location.hash, null, true);
168199
}
169200

170-
if (location.pathname === '/') {
171-
if (path = this.getInitialPathFromHash()) {
201+
if (location.pathname === "/") {
202+
if ((path = this.getInitialPathFromHash())) {
172203
page.replace(path + location.search, null, true);
173-
} else if (path = this.getInitialPathFromCookie()) {
204+
} else if ((path = this.getInitialPathFromCookie())) {
174205
page.replace(path + location.search + location.hash, null, true);
175206
}
176207
}
177208
}
178209

179210
getInitialPathFromHash() {
180211
try {
181-
return __guard__((new RegExp("#/(.+)")).exec(decodeURIComponent(location.hash)), x => x[1]);
212+
return __guard__(
213+
new RegExp("#/(.+)").exec(decodeURIComponent(location.hash)),
214+
(x) => x[1],
215+
);
182216
} catch (error) {}
183217
}
184218

185219
getInitialPathFromCookie() {
186220
let path;
187-
if (path = Cookies.get('initial_path')) {
188-
Cookies.expire('initial_path');
221+
if ((path = Cookies.get("initial_path"))) {
222+
Cookies.expire("initial_path");
189223
return path;
190224
}
191225
}
192226

193227
replaceHash(hash) {
194-
page.replace(location.pathname + location.search + (hash || ''), null, true);
228+
page.replace(
229+
location.pathname + location.search + (hash || ""),
230+
null,
231+
true,
232+
);
195233
}
196234
});
197235
Cls.initClass();
198236

199237
function __guard__(value, transform) {
200-
return (typeof value !== 'undefined' && value !== null) ? transform(value) : undefined;
201-
}
238+
return typeof value !== "undefined" && value !== null
239+
? transform(value)
240+
: undefined;
241+
}

0 commit comments

Comments
 (0)