@mideind/netskrafl-react 1.0.0-beta.5 → 1.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/{src/css/skrafl-explo.css → dist/cjs/css/netskrafl.css} +1068 -174
  2. package/dist/cjs/index.js +32477 -364
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/{cjs/index.css → esm/css/netskrafl.css} +1043 -350
  5. package/dist/esm/index.js +32475 -364
  6. package/dist/esm/index.js.map +1 -1
  7. package/dist/types.d.ts +2 -1
  8. package/package.json +14 -2
  9. package/.eslintignore +0 -8
  10. package/.eslintrc.json +0 -13
  11. package/dist/esm/index.css +0 -6837
  12. package/rollup.config.js +0 -60
  13. package/src/components/index.ts +0 -2
  14. package/src/components/netskrafl/Netskrafl.stories.tsx +0 -66
  15. package/src/components/netskrafl/Netskrafl.tsx +0 -138
  16. package/src/components/netskrafl/Netskrafl.types.ts +0 -7
  17. package/src/components/netskrafl/index.ts +0 -2
  18. package/src/css/fonts.css +0 -4
  19. package/src/css/glyphs.css +0 -224
  20. package/src/fonts/glyphicons-regular.eot +0 -0
  21. package/src/fonts/glyphicons-regular.ttf +0 -0
  22. package/src/fonts/glyphicons-regular.woff +0 -0
  23. package/src/index.ts +0 -2
  24. package/src/messages/messages.json +0 -1576
  25. package/src/mithril/actions.ts +0 -319
  26. package/src/mithril/bag.ts +0 -65
  27. package/src/mithril/bestdisplay.ts +0 -74
  28. package/src/mithril/blankdialog.ts +0 -94
  29. package/src/mithril/board.ts +0 -339
  30. package/src/mithril/buttons.ts +0 -303
  31. package/src/mithril/challengedialog.ts +0 -186
  32. package/src/mithril/channel.ts +0 -162
  33. package/src/mithril/chat.ts +0 -228
  34. package/src/mithril/components.ts +0 -496
  35. package/src/mithril/dragdrop.ts +0 -219
  36. package/src/mithril/elopage.ts +0 -202
  37. package/src/mithril/friend.ts +0 -227
  38. package/src/mithril/game.ts +0 -1378
  39. package/src/mithril/gameview.ts +0 -111
  40. package/src/mithril/globalstate.ts +0 -33
  41. package/src/mithril/i18n.ts +0 -186
  42. package/src/mithril/localstorage.ts +0 -133
  43. package/src/mithril/login.ts +0 -122
  44. package/src/mithril/logo.ts +0 -323
  45. package/src/mithril/main.ts +0 -755
  46. package/src/mithril/mithril.ts +0 -29
  47. package/src/mithril/model.ts +0 -855
  48. package/src/mithril/movelistitem.ts +0 -226
  49. package/src/mithril/page.ts +0 -856
  50. package/src/mithril/playername.ts +0 -91
  51. package/src/mithril/promodialog.ts +0 -82
  52. package/src/mithril/recentlist.ts +0 -148
  53. package/src/mithril/request.ts +0 -52
  54. package/src/mithril/review.ts +0 -634
  55. package/src/mithril/rightcolumn.ts +0 -398
  56. package/src/mithril/searchbutton.ts +0 -118
  57. package/src/mithril/statsdisplay.ts +0 -109
  58. package/src/mithril/tabs.ts +0 -169
  59. package/src/mithril/tile.ts +0 -145
  60. package/src/mithril/twoletter.ts +0 -76
  61. package/src/mithril/types.ts +0 -384
  62. package/src/mithril/userinfodialog.ts +0 -171
  63. package/src/mithril/util.ts +0 -304
  64. package/src/mithril/wait.ts +0 -246
  65. package/src/mithril/wordcheck.ts +0 -102
  66. package/tsconfig.json +0 -28
  67. package/vite.config.ts +0 -12
@@ -1,755 +0,0 @@
1
- /*
2
-
3
- Main.ts
4
-
5
- Main screen component
6
-
7
- Copyright (C) 2024 Miðeind ehf.
8
- Author: Vilhjalmur Thorsteinsson
9
-
10
- The Creative Commons Attribution-NonCommercial 4.0
11
- International Public License (CC-BY-NC 4.0) applies to this software.
12
- For further information, see https://github.com/mideind/Netskrafl
13
-
14
- */
15
-
16
- import { ChallengeAction, ChallengeListItem, IView, UserListItem } from "./types";
17
- import { VnodeChildren, ComponentFunc, m } from "./mithril";
18
- import { gameUrl, glyph, glyphGrayed, nbsp } from "./util";
19
- import { NetskraflLogoOnly } from "./logo";
20
- import { mt, t, ts } from "./i18n";
21
- import { ChallengeButton, Info, LeftLogo, TogglerReady, TogglerReadyTimed, UserId, UserInfoButton } from "./components";
22
- import { logEvent } from "./channel";
23
- import { RecentList } from "./recentlist";
24
- import { EloPage } from "./elopage";
25
- import { StatsDisplay } from "./statsdisplay";
26
- import { SearchButton } from "./searchbutton";
27
- import { makeTabs, updateSelection } from "./tabs";
28
- import { BestDisplay } from "./bestdisplay";
29
-
30
- interface IAttributes {
31
- view: IView;
32
- }
33
-
34
- export const Main: ComponentFunc<IAttributes> = () => {
35
- // Main screen with tabs
36
-
37
- function vwMainTabs(view: IView): VnodeChildren {
38
-
39
- const model = view.model;
40
-
41
- function vwMainTabHeader(): VnodeChildren {
42
- const numGames = model.numGames;
43
- const numChallenges = model.numChallenges;
44
- return [
45
- m(".header-logo",
46
- m(m.route.Link,
47
- {
48
- href: "/page",
49
- class: "backlink"
50
- },
51
- m(NetskraflLogoOnly)
52
- )
53
- ),
54
- m("ul", [
55
- m("li",
56
- m("a[href='#tabs-1']", [
57
- glyph("th"), m("span.tab-legend", t("Viðureignir")),
58
- m("span",
59
- {
60
- id: 'numgames',
61
- style: numGames ? 'display: inline-block' : ''
62
- },
63
- numGames
64
- )
65
- ])
66
- ),
67
- m("li",
68
- m("a[href='#tabs-2']", [
69
- glyph("hand-right"), m("span.tab-legend", t("Áskoranir")),
70
- // Blink if we have timed games where the opponent is ready
71
- m("span" + (model.oppReady ? ".opp-ready" : ""),
72
- {
73
- id: "numchallenges",
74
- style: numChallenges ? 'display: inline-block' : ''
75
- },
76
- numChallenges
77
- )
78
- ])
79
- ),
80
- m("li",
81
- m("a[href='#tabs-3']",
82
- [glyph("user"), m("span.tab-legend", t("Andstæðingar"))]
83
- )
84
- ),
85
- m("li.no-mobile-list",
86
- m("a[href='#tabs-4']",
87
- [glyph("bookmark"), m("span.tab-legend", t("Ferill"))]
88
- )
89
- )
90
- ])
91
- ];
92
- }
93
-
94
- function vwGamelist(): VnodeChildren {
95
-
96
- function vwList(): VnodeChildren {
97
-
98
- function viewGameList(): VnodeChildren {
99
-
100
- if (!model.gameList)
101
- return "";
102
- return model.gameList.map((item, i: number) => {
103
-
104
- // Show a list item about a game in progress (or recently finished)
105
-
106
- function vwOpp(): VnodeChildren {
107
- let arg = item.oppid === null ? [glyph("cog"), nbsp(), item.opp] : item.opp;
108
- return m("span.list-opp", { title: item.fullname }, arg);
109
- }
110
-
111
- function vwTurn(): VnodeChildren {
112
- let turnText = "";
113
- let flagClass = "";
114
- if (item.my_turn) {
115
- turnText = ts("Þú átt leik");
116
- }
117
- else
118
- if (item.zombie) {
119
- turnText = ts("Viðureign lokið");
120
- flagClass = ".zombie";
121
- }
122
- else {
123
- // {opponent}'s move
124
- turnText = ts("opp_move", { opponent: item.opp });
125
- flagClass = ".grayed";
126
- }
127
- return m("span.list-myturn",
128
- m("span.glyphicon.glyphicon-flag" + flagClass, { title: turnText })
129
- );
130
- }
131
-
132
- function vwOverdue(): VnodeChildren {
133
- if (item.overdue)
134
- return glyph("hourglass",
135
- { title: item.my_turn ? "Er að renna út á tíma" : "Getur þvingað fram uppgjöf" }
136
- );
137
- return glyphGrayed("hourglass");
138
- }
139
-
140
- function vwTileCount(): VnodeChildren {
141
- const winLose = item.sc0 < item.sc1 ? ".losing" : "";
142
- return m(".tilecount",
143
- m(".tc" + winLose, { style: { width: item.tile_count.toString() + "%" } })
144
- );
145
- }
146
-
147
- return m(".listitem" + (i % 2 === 0 ? ".oddlist" : ".evenlist"),
148
- [
149
- m(m.route.Link,
150
- { href: gameUrl(item.url) },
151
- [
152
- vwTurn(),
153
- m("span.list-overdue", vwOverdue()),
154
- m("span.list-ts-short", item.ts),
155
- vwOpp()
156
- ]
157
- ),
158
- m(UserInfoButton, {
159
- view,
160
- item: { userid: item.oppid, nick: item.opp, fullname: item.fullname },
161
- }),
162
- m("span.list-s0", item.sc0),
163
- m("span.list-colon", ":"),
164
- m("span.list-s1", item.sc1),
165
- m("span.list-tc", vwTileCount()),
166
- m("span.list-manual",
167
- item.manual
168
- ? glyph("lightbulb", { title: ts("Keppnishamur") })
169
- : glyphGrayed("lightbulb")
170
- )
171
- ]
172
- );
173
- });
174
- }
175
-
176
- if (model.gameList === null)
177
- model.loadGameList();
178
- return m("div", { id: 'gamelist' }, viewGameList());
179
- }
180
-
181
- function vwHint(): VnodeChildren {
182
- // Show some help if the user has no games in progress
183
- if (model.loadingGameList || model.gameList === undefined ||
184
- (model.gameList !== null && model.gameList.length > 0))
185
- // Either we have games in progress or the game list is being loaded
186
- return "";
187
- return m(".hint", { style: { display: "block" } },
188
- [
189
- m("p",
190
- [
191
- "Ef þig vantar einhvern til að skrafla við, veldu flipann ",
192
- m(m.route.Link,
193
- { href: "/main?tab=2" },
194
- [glyph("user"), nbsp(), "Andstæðingar"]
195
- ),
196
- " og skoraðu á tölvuþjarka - ",
197
- glyph("cog"), nbsp(), m("b", "Amlóða"),
198
- ", ",
199
- glyph("cog"), nbsp(), m("b", "Miðlung"),
200
- " eða ",
201
- glyph("cog"), nbsp(), m("b", "Fullsterkan"),
202
- " - eða veldu þér annan leikmann úr stafrófs\u00ADlistunum " + // Soft hyphen
203
- " sem þar er að finna til að skora á."
204
- ]
205
- ),
206
- m("p",
207
- [
208
- "Þú stofnar áskorun með því að smella á bendi-teiknið ",
209
- glyph("hand-right", { style: { "margin-left": "6px", "margin-right": "6px" } }),
210
- " vinstra megin við nafn andstæðingsins."
211
- ]
212
- ),
213
- m("p",
214
- "Tölvuþjarkarnir eru ætíð reiðubúnir að skrafla og viðureign við þá " +
215
- " hefst strax. Aðrir leikmenn þurfa að samþykkja áskorun áður en viðureign hefst."
216
- ),
217
- m("p.no-mobile-block",
218
- [
219
- m(m.route.Link, { href: "/help" }, "Hjálp"),
220
- " má fá með því að smella á bláa ",
221
- glyph("info-sign"), nbsp(), "-", nbsp(),
222
- "teiknið hér til vinstri."
223
- ]
224
- ),
225
- m("p.no-mobile-block",
226
- "Þú kemst alltaf aftur í þessa aðalsíðu með því að smella á " +
227
- "örvarmerkið efst vinstra megin við skraflborðið."
228
- )
229
- ]
230
- );
231
- }
232
-
233
- return [
234
- m(".listitem.listheader",
235
- [
236
- m("span.list-myturn", glyphGrayed("flag", { title: ts('Átt þú leik?') })),
237
- m("span.list-overdue",
238
- glyphGrayed("hourglass", { title: ts('Langt frá síðasta leik?') })
239
- ),
240
- mt("span.list-ts-short", "Síðasti leikur"),
241
- mt("span.list-opp", "Andstæðingur"),
242
- mt("span.list-info-hdr", "Ferill"),
243
- mt("span.list-scorehdr", "Staða"),
244
- mt("span.list-tc", "Framvinda"),
245
- m("span.list-manual", glyphGrayed("lightbulb", { title: ts('Keppnishamur') }))
246
- ]
247
- ),
248
- vwList(),
249
- vwHint()
250
- ];
251
- }
252
-
253
- function vwChallenges(showReceived: boolean): VnodeChildren {
254
-
255
- function vwList(): VnodeChildren {
256
-
257
- if (!model.state) return undefined;
258
- const state = model.state;
259
-
260
- function itemize(item: ChallengeListItem, i: number) {
261
-
262
- // Generate a list item about a pending challenge (issued or received)
263
-
264
- function challengeDescription(json: { duration?: number; }) {
265
- /* Return a human-readable string describing a challenge
266
- according to the enclosed preferences */
267
- if (!json || json.duration === undefined || json.duration === 0)
268
- /* Normal unbounded (untimed) game */
269
- return t("Venjuleg ótímabundin viðureign");
270
- return t("with_clock", { duration: json.duration.toString() });
271
- }
272
-
273
- function markChallenge(ev: Event) {
274
- // Clicked the icon at the beginning of the line,
275
- // to decline a received challenge or retract an issued challenge
276
- const action: ChallengeAction = item.received ? "decline" : "retract";
277
- const param = { destuser: item.userid, action: action, key: item.key };
278
- model.modifyChallenge(param);
279
- ev.preventDefault();
280
- }
281
-
282
- function clickChallenge(ev: Event) {
283
- // Clicked the hotspot area to accept a received challenge
284
- ev.preventDefault();
285
- if (!model.moreGamesAllowed()) {
286
- // User must be a friend to be able to accept more challenges
287
- logEvent("hit_game_limit",
288
- {
289
- userid: state.userId,
290
- locale: state.locale,
291
- limit: model.maxFreeGames
292
- }
293
- );
294
- // Promote a subscription to Netskrafl/Explo
295
- view.showFriendPromo();
296
- return;
297
- }
298
- if (item.received) {
299
- if (item.prefs && item.prefs.duration !== undefined && item.prefs.duration > 0)
300
- // Timed game: display a modal wait dialog
301
- view.pushDialog("wait", {
302
- oppId: item.userid,
303
- oppNick: item.opp,
304
- oppName: item.fullname,
305
- duration: item.prefs.duration,
306
- challengeKey: item.key,
307
- });
308
- else
309
- // Ask the server to create a new game and route to it
310
- model.newGame(item.userid, false);
311
- }
312
- else {
313
- // Clicking on a sent challenge, i.e. a timed game
314
- // where the opponent is waiting and ready to start
315
- view.showAcceptDialog(item.userid, item.opp, item.key);
316
- }
317
- }
318
-
319
- const oppReady = !item.received && item.opp_ready &&
320
- item.prefs && item.prefs.duration !== undefined &&
321
- item.prefs.duration > 0;
322
- const clickable = item.received || oppReady;
323
- const descr = challengeDescription(item.prefs);
324
-
325
- return m(".listitem" + (i % 2 === 0 ? ".oddlist" : ".evenlist"),
326
- [
327
- m("span.list-ch",
328
- { onclick: markChallenge },
329
- item.received ?
330
- glyph("thumbs-down", { title: ts("Hafna") })
331
- :
332
- glyph("hand-right", { title: ts("Afturkalla") })
333
- ),
334
- m(clickable ? "a" : "span",
335
- clickable ? {
336
- href: "#",
337
- onclick: clickChallenge,
338
- class: oppReady ? "opp-ready" : ""
339
- } : {},
340
- [
341
- m("span.list-ts", item.ts),
342
- m("span.list-nick", { title: item.fullname }, item.opp),
343
- m("span.list-chall",
344
- [
345
- item.prefs.fairplay ? m("span.fairplay-btn", { title: ts("Án hjálpartækja") }) : "",
346
- item.prefs.manual ? m("span.manual-btn", { title: ts("Keppnishamur") }) : "",
347
- descr
348
- ]
349
- )
350
- ]
351
- ),
352
- m(UserInfoButton,
353
- {
354
- view,
355
- item: {
356
- userid: item.userid,
357
- nick: item.opp,
358
- fullname: item.fullname,
359
- }
360
- }
361
- ),
362
- ]
363
- );
364
- }
365
-
366
- let cList: ChallengeListItem[] = [];
367
- if (model.challengeList)
368
- cList = showReceived ?
369
- model.challengeList.filter((item) => item.received) :
370
- model.challengeList.filter((item) => !item.received);
371
-
372
- return m("div",
373
- {
374
- id: showReceived ? 'chall-received' : 'chall-sent',
375
- oninit: () => {
376
- if (model.challengeList === null)
377
- model.loadChallengeList();
378
- }
379
- },
380
- cList.map(itemize)
381
- );
382
- }
383
-
384
- const n = vwList();
385
- if (!n) return [];
386
-
387
- if (showReceived)
388
- // Challenges received
389
- return [
390
- m(".listitem.listheader",
391
- [
392
- m("span.list-icon", glyphGrayed("thumbs-down", { title: ts('Hafna') })),
393
- mt("span.list-ts", "Hvenær"),
394
- mt("span.list-nick", "Áskorandi"),
395
- mt("span.list-chall", "Hvernig"),
396
- mt("span.list-info-hdr", "Ferill"),
397
- ]
398
- ),
399
- n
400
- ];
401
- else
402
- // Challenges sent
403
- return [
404
- m(".listitem.listheader",
405
- [
406
- m("span.list-icon", glyphGrayed("hand-right", { title: ts('Afturkalla') })),
407
- mt("span.list-ts", "Hvenær"),
408
- mt("span.list-nick", "Andstæðingur"),
409
- mt("span.list-chall", "Hvernig"),
410
- mt("span.list-info-hdr", "Ferill"),
411
- ]
412
- ),
413
- n
414
- ];
415
- }
416
-
417
- function vwRecentList(): VnodeChildren {
418
-
419
- function vwList(): VnodeChildren {
420
- if (model.recentList === null)
421
- model.loadRecentList();
422
- return m(RecentList,
423
- {
424
- view,
425
- id: "recentlist",
426
- recentList: model.recentList || [],
427
- }
428
- );
429
- }
430
-
431
- return [
432
- m(".listitem.listheader",
433
- [
434
- m("span.list-win", glyphGrayed("bookmark", { title: ts('Sigur') })),
435
- mt("span.list-ts-short", "Viðureign lauk"),
436
- mt("span.list-nick", "Andstæðingur"),
437
- mt("span.list-scorehdr", "Úrslit"),
438
- m("span.list-elo-hdr",
439
- [
440
- m("span.glyphicon.glyphicon-user.elo-hdr-left", { title: ts('Mennskir andstæðingar') }),
441
- t("Elo"),
442
- m("span.glyphicon.glyphicon-cog.elo-hdr-right", { title: ts('Allir andstæðingar') })
443
- ]
444
- ),
445
- mt("span.list-duration", "Lengd"),
446
- m("span.list-manual", glyphGrayed("lightbulb", { title: ts('Keppnishamur') }))
447
- ]
448
- ),
449
- vwList()
450
- ];
451
- }
452
-
453
- function vwUserButton(id: string, icon: string, text: string): VnodeChildren {
454
- // Select the type of user list (robots, fav, alike, elo)
455
- const sel = model.userListCriteria?.query || "robots";
456
- return m("span",
457
- {
458
- className: (id === sel ? "shown" : ""),
459
- id: id,
460
- onclick: (ev: Event) => {
461
- if (id === "elo") {
462
- // Load Elo rating list, defaulting to the human-only rating
463
- model.userListCriteria = { query: "elo", spec: "human" };
464
- model.userList = null;
465
- model.loadEloRatingList("human", true);
466
- }
467
- else {
468
- // Load user list
469
- model.loadUserList({ query: id, spec: "" }, true);
470
- model.eloRatingSpec = null;
471
- model.eloRatingList = null;
472
- }
473
- ev.preventDefault();
474
- }
475
- },
476
- [glyph(icon, { style: { padding: 0 } }), nbsp(), text]
477
- );
478
- }
479
-
480
- function vwUserList(): VnodeChildren {
481
-
482
- function vwList(list: UserListItem[]) {
483
-
484
- function itemize(item: UserListItem, i: number) {
485
-
486
- // Generate a list item about a user
487
-
488
- const isRobot = item.userid.indexOf("robot-") === 0;
489
- let fullname: VnodeChildren = [];
490
-
491
- // Online and accepting challenges
492
- if (item.ready && !isRobot) {
493
- fullname.push(m("span.ready-btn", { title: ts("Álínis og tekur við áskorunum") }));
494
- fullname.push(nbsp());
495
- }
496
- // Willing to accept challenges for timed games
497
- if (item.ready_timed) {
498
- fullname.push(m("span.timed-btn", { title: ts("Til í viðureign með klukku") }));
499
- fullname.push(nbsp());
500
- }
501
- // Fair play commitment
502
- if (item.fairplay) {
503
- fullname.push(m("span.fairplay-btn", { title: ts("Skraflar án hjálpartækja") }));
504
- fullname.push(nbsp());
505
- }
506
- fullname.push(item.fullname);
507
-
508
- function fav(): VnodeChildren {
509
- if (isRobot)
510
- return m("span.list-fav", { style: { cursor: "default" } }, glyph("star-empty"));
511
- return m("span.list-fav",
512
- {
513
- title: ts("Uppáhald"),
514
- onclick: (ev: Event) => {
515
- item.fav = !item.fav;
516
- model.markFavorite(item.userid, item.fav);
517
- ev.preventDefault();
518
- }
519
- },
520
- glyph(item.fav ? "star" : "star-empty")
521
- );
522
- }
523
-
524
- function userLink(): VnodeChildren {
525
- if (isRobot)
526
- return m("a",
527
- {
528
- href: "",
529
- onclick: (ev: Event) => {
530
- // Start a new game against the robot
531
- model.newGame(item.userid, false);
532
- ev.preventDefault();
533
- }
534
- },
535
- [
536
- m("span.list-nick", [glyph("cog"), nbsp(), item.nick]),
537
- m("span.list-fullname-robot", fullname)
538
- ]
539
- );
540
- else
541
- return m.fragment({}, [
542
- m("span.list-nick", item.nick),
543
- m("span.list-fullname", fullname),
544
- m("span.list-human-elo", item.human_elo)
545
- ]);
546
- }
547
-
548
- return m(".listitem" + (i % 2 === 0 ? ".oddlist" : ".evenlist"),
549
- [
550
- m(ChallengeButton, { view, item }),
551
- fav(),
552
- userLink(),
553
- m(UserInfoButton, { view, item }),
554
- ]
555
- );
556
- }
557
-
558
- return m("div", { id: "userlist" }, list.map(itemize));
559
- }
560
-
561
- // The type of list to show; by default it's 'robots'
562
- const query = model.userListCriteria?.query ?? "";
563
- const spec = model.userListCriteria?.spec ?? "";
564
- const loadingElo = model.eloRatingSpec === undefined;
565
- const listType = query || "robots";
566
- if (listType === "elo" || loadingElo)
567
- // Show Elo list
568
- return [
569
- m(EloPage, {
570
- id: "elolist",
571
- view: view,
572
- spec: model.eloRatingSpec ?? null,
573
- key: "elopage",
574
- })
575
- ];
576
- // Show normal user list
577
- let list: UserListItem[] = [];
578
- if (model.userList === undefined) {
579
- // We are loading a fresh user list
580
- /* pass */
581
- }
582
- else
583
- if (model.userList === null || query !== listType)
584
- model.loadUserList({ query: listType, spec: "" }, true);
585
- else
586
- list = model.userList;
587
- const nothingFound = list.length === 0 && listType === "search" && spec !== "";
588
- const robotList = listType === "robots";
589
- return [
590
- m(".listitem.listheader",
591
- [
592
- m("span.list-ch", glyphGrayed("hand-right", { title: ts('Skora á') })),
593
- m("span.list-fav", glyph("star-empty", { title: ts('Uppáhald') })),
594
- mt("span.list-nick", "Einkenni"),
595
- mt("span.list-fullname", "Nafn og merki"),
596
- robotList ? "" : mt("span.list-human-elo[id='usr-list-elo']", "Elo"),
597
- robotList ? "" : mt("span.list-info-hdr[id='usr-list-info']", "Ferill"),
598
- ]
599
- ),
600
- vwList(list),
601
- // Show indicator if search didn't find any users matching the criteria
602
- nothingFound ?
603
- m("div",
604
- { id: "user-no-match", style: { display: "block" } },
605
- [
606
- glyph("search"),
607
- " ",
608
- m("span", { id: "search-prefix" }, spec),
609
- t(" finnst ekki")
610
- ]
611
- )
612
- : undefined
613
- ];
614
- }
615
-
616
- function vwStats(): VnodeChildren {
617
- // View the user's own statistics summary
618
- const ownStats = model.ownStats;
619
- if (ownStats === null)
620
- model.loadOwnStats();
621
- return ownStats && m(StatsDisplay, { view, id: 'own-stats', ownStats });
622
- }
623
-
624
- function vwBest(): VnodeChildren {
625
- // View the user's own best game and word scores
626
- const ownStats = model.ownStats;
627
- if (ownStats === null)
628
- model.loadOwnStats();
629
- return ownStats && m(BestDisplay, { id: 'own-best', ownStats, myself: true });
630
- }
631
-
632
- function tab1(): VnodeChildren {
633
- // Ongoing games
634
- return m("div", { id: 'tabs-1' },
635
- [
636
- mt("p.no-mobile-block",
637
- [
638
- mt("strong", "Viðureignir sem standa yfir"),
639
- "click_on_game", // "Click on a game to view it and make a move if"
640
- glyph("flag"),
641
- " þú átt leik"
642
- ]
643
- ),
644
- vwGamelist()
645
- ]
646
- );
647
- }
648
-
649
- function tab2(): VnodeChildren {
650
- // Challenges received and sent
651
- return m("div", { id: 'tabs-2' },
652
- [
653
- mt("p.no-mobile-block",
654
- [
655
- mt("strong", "Skorað á þig"),
656
- "click_on_challenge", // "Click on a challenge to accept it and start a game, or on"
657
- glyph("thumbs-down", { style: { "margin-left": "6px", "margin-right": "6px" } }),
658
- " til að hafna henni"
659
- ]
660
- ),
661
- vwChallenges(true),
662
- mt("p.no-mobile-block",
663
- [
664
- mt("strong", "Þú skorar á aðra"),
665
- " - smelltu á ",
666
- glyph("hand-right", { style: { "margin-left": "6px", "margin-right": "6px" } }),
667
- " til að afturkalla áskorun"
668
- ]
669
- ),
670
- vwChallenges(false)
671
- ]
672
- );
673
- }
674
-
675
- function tab3(): VnodeChildren {
676
- // Opponent lists
677
- return m("div", { id: 'tabs-3' },
678
- [
679
- m("div", { id: 'initials' },
680
- [
681
- m(".user-cat[id='user-headings']",
682
- [
683
- vwUserButton("robots", "cog", ts("Þjarkar")),
684
- " ",
685
- vwUserButton("fav", "star", ts("Uppáhalds")),
686
- " ",
687
- vwUserButton("live", "flash", ts("Álínis")),
688
- " ",
689
- vwUserButton("alike", "resize-small", ts("Svipaðir")),
690
- " ",
691
- vwUserButton("elo", "crown", ts("Topp 100"))
692
- ]
693
- ),
694
- m(SearchButton, { view })
695
- ]
696
- ),
697
- vwUserList()
698
- ]
699
- );
700
- }
701
-
702
- function tab4(): VnodeChildren {
703
- // Recent games and statistics
704
- return m("div", { id: 'tabs-4' },
705
- [
706
- vwStats(),
707
- vwBest(),
708
- mt("p.no-mobile-block",
709
- [
710
- mt("strong", "Nýlegar viðureignir þínar"),
711
- "click_to_review" // "Click on a game to review it"
712
- ]
713
- ),
714
- vwRecentList()
715
- ]
716
- );
717
- }
718
-
719
- return m(".tabbed-page",
720
- m("div", { id: 'main-tabs' },
721
- [
722
- vwMainTabHeader(),
723
- m("div.tab-scroll-area", [
724
- tab1(),
725
- tab2(),
726
- tab4(),
727
- tab3(),
728
- ]),
729
- ]
730
- )
731
- );
732
- }
733
-
734
- return {
735
- view: (vnode) => {
736
- const view = vnode.attrs.view;
737
- return m.fragment({}, [
738
- m(LeftLogo), // No legend, scale up by 50%
739
- m(UserId, { view }),
740
- m(Info),
741
- m(TogglerReady, { view }),
742
- m(TogglerReadyTimed, { view }),
743
- m("div",
744
- {
745
- oncreate: (vnode) => {
746
- makeTabs(view, "main-tabs", undefined, false, vnode);
747
- },
748
- onupdate: updateSelection
749
- },
750
- vwMainTabs(view),
751
- ),
752
- ]);
753
- }
754
- };
755
- };