@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,202 +0,0 @@
1
- /*
2
-
3
- EloPage.ts
4
-
5
- Elo status list 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 { EloListSelection, IView, UserListItem } from "./types";
17
- import { Component, ComponentFunc, VnodeChildren, m } from "./mithril";
18
- import { ts, mt } from "./i18n";
19
- import { glyph, glyphGrayed, nbsp } from "./util";
20
- import { ChallengeButton, UserInfoButton } from "./components";
21
-
22
- const EloSelector: Component<
23
- {
24
- sel: EloListSelection;
25
- onchange: (sel: EloListSelection) => void;
26
- },
27
- {
28
- sel: EloListSelection;
29
- }
30
- > = {
31
- oninit: (vnode) => {
32
- vnode.state.sel = vnode.attrs.sel;
33
- },
34
- view: (vnode) => {
35
- return m(".toggler[id='elo-toggler']", { title: ts("elo_list_choice") },
36
- [
37
- m(".option.x-small",
38
- {
39
- // Show ranking for human games only
40
- className: (vnode.state.sel === "human" ? "selected" : ""),
41
- onclick: (ev: Event) => {
42
- vnode.state.sel = "human";
43
- vnode.attrs.onchange(vnode.state.sel);
44
- ev.preventDefault();
45
- },
46
- },
47
- glyph("user")
48
- ),
49
- m(".option.x-small",
50
- {
51
- // Show ranking for all games, including robots
52
- className: (vnode.state.sel === "all" ? "selected" : ""),
53
- onclick: (ev: Event) => {
54
- vnode.state.sel = "all";
55
- vnode.attrs.onchange(vnode.state.sel);
56
- ev.preventDefault();
57
- },
58
- },
59
- glyph("cog")
60
- ),
61
- m(".option.x-small",
62
- {
63
- // Show ranking for manual games only
64
- className: (vnode.state.sel === "manual" ? "selected" : ""),
65
- onclick: (ev: Event) => {
66
- vnode.state.sel = "manual";
67
- vnode.attrs.onchange(vnode.state.sel);
68
- ev.preventDefault();
69
- },
70
- },
71
- glyph("lightbulb")
72
- )
73
- ]
74
- );
75
- }
76
- };
77
-
78
- interface IAttributes {
79
- view: IView;
80
- spec: EloListSelection | null;
81
- id: string;
82
- key: string;
83
- }
84
-
85
- export const EloPage: ComponentFunc<IAttributes> = (initialVnode) => {
86
-
87
- // Show the header of an Elo ranking list and then the list itself
88
-
89
- const { spec, view } = initialVnode.attrs;
90
-
91
- return {
92
- view: (vnode) => {
93
- return m("div", [
94
- m(".listitem.listheader",
95
- [
96
- m("span.list-ch", glyphGrayed("hand-right", { title: ts('Skora á') })),
97
- mt("span.list-rank", "Röð"),
98
- m("span.list-rank-no-mobile", { title: ts('Röð í gær') }, ts("1d")),
99
- m("span.list-rank-no-mobile", { title: ts('Röð fyrir viku') }, ts("7d")),
100
- mt("span.list-nick-elo", "Einkenni"),
101
- m("span.list-elo", { title: ts('Elo-stig') }, ts("Elo")),
102
- m("span.list-elo-no-mobile", { title: ts('Elo-stig í gær') }, ts("1d")),
103
- m("span.list-elo-no-mobile", { title: ts('Elo-stig fyrir viku') }, ts("7d")),
104
- m("span.list-elo-no-mobile", { title: ts('Elo-stig fyrir mánuði') }, ts("30d")),
105
- m("span.list-games", { title: ts('Fjöldi viðureigna') }, glyph("th")),
106
- m("span.list-ratio", { title: ts('Vinningshlutfall') }, glyph("bookmark")),
107
- m("span.list-avgpts", { title: ts('Meðalstigafjöldi') }, glyph("dashboard")),
108
- mt("span.list-info-hdr", "Ferill"),
109
- m(EloSelector,
110
- {
111
- sel: spec || "human",
112
- onchange: (s: EloListSelection) => {
113
- view.model.loadEloRatingList(s, true);
114
- },
115
- }
116
- ),
117
- ]
118
- ),
119
- m(EloList,
120
- {
121
- id: vnode.attrs.id,
122
- sel: spec,
123
- view: vnode.attrs.view,
124
- // key: "elolist",
125
- }
126
- )
127
- ]);
128
- }
129
- };
130
-
131
- };
132
-
133
- const EloList: ComponentFunc<{
134
- view: IView;
135
- id: string;
136
- sel: EloListSelection | null;
137
- }> = (initialVnode) => {
138
-
139
- const outerView = initialVnode.attrs.view;
140
- const model = outerView.model;
141
- const state = model.state;
142
-
143
- return {
144
-
145
- view: (vnode) => {
146
-
147
- function itemize(item: UserListItem, i: number) {
148
-
149
- // Generate a list item about a user in an Elo ranking table
150
-
151
- const isRobot = item.userid.indexOf("robot-") === 0;
152
-
153
- function rankStr(rank: number, ref?: number): string {
154
- // Return a rank string or dash if no rank or not meaningful
155
- // (i.e. if the reference, such as the number of games, is zero)
156
- if (rank === 0 || (ref !== undefined && ref === 0))
157
- return "--";
158
- return rank.toString();
159
- }
160
-
161
- let nick: VnodeChildren = item.nick;
162
- let ch = m("span.list-ch", nbsp());
163
- const userId = state?.userId ?? "";
164
- if (item.userid != userId && !item.inactive) {
165
- ch = m(ChallengeButton, { view: outerView, item });
166
- }
167
- if (isRobot) {
168
- nick = m("span", [glyph("cog"), nbsp(), nick]);
169
- }
170
- if (item.fairplay && !isRobot)
171
- nick = m("span",
172
- [m("span.fairplay-btn", { title: ts("Skraflar án hjálpartækja") }), nick]);
173
-
174
- return m(".listitem",
175
- {
176
- key: (vnode.attrs.sel || "sel") + i,
177
- className: (i % 2 === 0 ? "oddlist" : "evenlist")
178
- },
179
- [
180
- ch, // Challenge icon (right-hand)
181
- m("span.list-rank.bold", rankStr(item.rank)),
182
- m("span.list-rank-no-mobile", rankStr(item.rank_yesterday)),
183
- m("span.list-rank-no-mobile", rankStr(item.rank_week_ago)),
184
- m("span.list-nick-elo", { title: item.fullname }, nick),
185
- m("span.list-elo.bold", item.elo),
186
- m("span.list-elo-no-mobile", rankStr(item.elo_yesterday, item.games_yesterday)),
187
- m("span.list-elo-no-mobile", rankStr(item.elo_week_ago, item.games_week_ago)),
188
- m("span.list-elo-no-mobile", rankStr(item.elo_month_ago, item.games_month_ago)),
189
- m("span.list-games.bold", item.games >= 100000 ? Math.round(item.games / 1000) + "K" : item.games),
190
- m("span.list-ratio", item.ratio + "%"),
191
- m("span.list-avgpts", item.avgpts),
192
- item.userid === userId ? nbsp() : m(UserInfoButton, { view: outerView, item }),
193
- ]
194
- );
195
- }
196
-
197
- const list: UserListItem[] = model.eloRatingList || [];
198
- return m("div", { id: vnode.attrs.id }, list.map(itemize));
199
- }
200
-
201
- };
202
- };
@@ -1,227 +0,0 @@
1
- /*
2
-
3
- Friend.ts
4
-
5
- Code for dialog components used in management of friends
6
-
7
- Copyright (C) 2023 Miðeind ehf.
8
- Original author: Vilhjálmur Þorsteinsson
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
- export {
17
- FriendPromoteDialog, FriendThanksDialog,
18
- FriendCancelDialog, FriendCancelConfirmDialog
19
- };
20
-
21
- import { m, ComponentFunc, VnodeDOM } from "./mithril";
22
- import { IView } from "./types";
23
- import { DialogButton } from "./components";
24
- import { glyph, nbsp, buttonOver, buttonOut, registerSalesCloud } from "./util";
25
-
26
- const FriendPromoteDialog: ComponentFunc<{
27
- view: IView;
28
- }> = (initialVnode) => {
29
-
30
- // A dialog that offers friendship to the user
31
-
32
- const attrs = initialVnode.attrs;
33
- const view = attrs.view;
34
- const model = view.model;
35
-
36
- // Load the friendHTML if not already loaded
37
- model.loadFriendPromo();
38
-
39
- function onUpdate(vnode: VnodeDOM) {
40
- if (!vnode || !vnode.dom)
41
- return;
42
- const noButtons = vnode.dom.getElementsByClassName("btn-promo-no") as HTMLCollectionOf<HTMLElement>;
43
- if (noButtons) {
44
- // Override onclick, onmouseover and onmouseout for No buttons
45
- for (let btn of noButtons) {
46
- btn.onclick = (ev: MouseEvent) => { view.popDialog(); ev.preventDefault(); };
47
- btn.onmouseover = buttonOver;
48
- btn.onmouseout = buttonOut;
49
- }
50
- }
51
- // Override onmouseover and onmouseout for Yes buttons
52
- const yesButtons = vnode.dom.getElementsByClassName("btn-promo-yes") as HTMLCollectionOf<HTMLElement>;
53
- if (yesButtons) {
54
- for (let btn of yesButtons) {
55
- btn.onmouseover = buttonOver;
56
- btn.onmouseout = buttonOut;
57
- }
58
- // We have a 'yes' button: register SalesCloud to handle it
59
- registerSalesCloud();
60
- }
61
- }
62
-
63
- return {
64
- view: () => {
65
- return m(".modal-dialog",
66
- { id: "promo-dialog", style: { visibility: "visible" } },
67
- m(".ui-widget.ui-widget-content.ui-corner-all", { id: "promo-form" },
68
- m(".promo-content",
69
- {
70
- oncreate: (vnode) => onUpdate(vnode),
71
- onupdate: (vnode) => onUpdate(vnode)
72
- },
73
- m.trust(model.friendHTML || "<p>Sæki texta...</p>")
74
- )
75
- )
76
- );
77
- }
78
- }
79
- };
80
-
81
- const FriendThanksDialog: ComponentFunc<{
82
- view: IView;
83
- }> = (initialVnode) => {
84
-
85
- // A dialog that offers friendship to the user
86
-
87
- return {
88
- view: () => {
89
- return m(".modal-dialog",
90
- { id: "thanks-dialog", style: { visibility: "visible" } },
91
- m(".ui-widget.ui-widget-content.ui-corner-all", { id: "thanks-form" },
92
- [
93
- m(".thanks-content", [
94
- m("h3", "Frábært!"),
95
- m("p", [
96
- "Bestu þakkir fyrir að gerast ", glyph("coffee-cup"), nbsp(), m("b", "Vinur Netskrafls"), "."
97
- ]),
98
- m("p", [
99
- "Fríðindi þín virkjast um leið og greiðsla hefur verið staðfest. ",
100
- m("b", "Það getur tekið nokkrar mínútur."),
101
- " Þú færð staðfestingu og kvittun í tölvupósti."
102
- ]),
103
- ]),
104
- m(DialogButton,
105
- {
106
- id: "btn-thanks",
107
- title: "Áfram",
108
- onclick: (ev: Event) => {
109
- // Go back to the main page
110
- // The dialog is popped automatically upon the route change
111
- m.route.set("/main");
112
- ev.preventDefault();
113
- }
114
- },
115
- glyph("ok")
116
- )
117
- ]
118
- )
119
- );
120
- }
121
- }
122
- };
123
-
124
- const FriendCancelDialog: ComponentFunc<{
125
- view: IView;
126
- }> = (initialVnode) => {
127
-
128
- // A dialog that offers friendship to the user
129
-
130
- const attrs = initialVnode.attrs;
131
- const view = attrs.view;
132
-
133
- return {
134
- view: () => {
135
- return m(".modal-dialog",
136
- { id: "cancel-dialog", style: { visibility: "visible" } },
137
- m(".ui-widget.ui-widget-content.ui-corner-all", { id: "cancel-form" }, [
138
- m("div", { id: "cancel-content" }, [
139
- m("h3", "Hætta sem vinur Netskrafls?"),
140
- m("p", [
141
- "Viltu hætta sem ", glyph("coffee-cup"), nbsp(), m("b", "vinur Netskrafls"),
142
- " og missa þar með þau fríðindi sem því tengjast?"
143
- ]),
144
- m("p", "Fríðindin eru:"),
145
- m("ul", [
146
- m("li", [
147
- m("b", "Ótakmarkaður fjöldi viðureigna"), " í gangi samtímis", m("br"),
148
- "(í stað 8 að hámarki)"
149
- ]),
150
- m("li", [
151
- "Aðgangur að ", m("b", "yfirliti"), " í lok viðureignar"
152
- ]),
153
- m("li", [
154
- m("b", "Keppnishamur"), " án \"græna þumalsins\""
155
- ]),
156
- ]),
157
- m(DialogButton,
158
- {
159
- id: "btn-cancel-no",
160
- title: "Nei",
161
- onclick: (ev: Event) => {
162
- ev.preventDefault();
163
- view.popDialog();
164
- }
165
- },
166
- [ glyph("remove"), " Nei" ]
167
- ),
168
- m(DialogButton,
169
- {
170
- id: "btn-cancel-yes",
171
- title: "Já",
172
- onclick: (ev: Event) => {
173
- ev.preventDefault();
174
- view.popDialog();
175
- // Initiate cancellation of the friendship
176
- view.cancelFriendship();
177
- }
178
- },
179
- [ glyph("ok"), " Já, vil hætta" ]
180
- )
181
- ]),
182
- ])
183
- );
184
- }
185
- }
186
- };
187
-
188
- const FriendCancelConfirmDialog: ComponentFunc<{
189
- view: IView;
190
- }> = (initialVnode) => {
191
-
192
- // A dialog that confirms cancellation of friendship
193
-
194
- const attrs = initialVnode.attrs;
195
- const view = attrs.view;
196
-
197
- return {
198
- view: () => {
199
- return m(".modal-dialog",
200
- { id: "confirm-dialog", style: { visibility: "visible" } },
201
- m(".ui-widget.ui-widget-content.ui-corner-all", { id: "confirm-form" },
202
- [
203
- m(".confirm-content", [
204
- m("h3", "Staðfesting"),
205
- m("p", [
206
- "Þú ert ekki lengur skráð(ur) sem ",
207
- glyph("coffee-cup"), nbsp(), m("b", "vinur Netskrafls"), "."
208
- ]),
209
- ]),
210
- m(DialogButton,
211
- {
212
- id: "btn-thanks",
213
- title: "Áfram",
214
- onclick: (ev: Event) => {
215
- ev.preventDefault();
216
- view.popDialog();
217
- }
218
- },
219
- glyph("ok")
220
- )
221
- ]
222
- )
223
- );
224
- }
225
- }
226
- };
227
-