Skip to content


 Zabbix
 Grafana
 Prometheus
 Threejs and TypeScript
 SocketIO and TypeScript
 Blender Topological Earth
 Sweet Home 3D
 Design Patterns Python
 Design Patterns TypeScript
   
 Course Coupon Codes
Three.js and TypeScript
Kindle Edition
$9.99 $14.99 Paperback 
$29.99 $34.99




Design Patterns in TypeScript
Kindle Edition
$9.99 $14.99 Paperback
$19.99 $24.99




Design Patterns in Python
Kindle Edition
$9.99 $14.99 Paperback
$19.99 $24.99




Add Custom CSS

Video Lecture

Add Custom CSS Add Custom CSS Add Custom CSS

./dist/client/index.html

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>TypeScript Socket.IO Course</title>
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" />
        <style>
            .gamePanel {
                position: relative;
                border: solid 1px gray;
                height: 382px;
                border-radius: 0px 20px 4px 20px;
                box-shadow: 15px 10px #dddddd;
            }

            #gamePanel0 {
                display: block;
                background: linear-gradient(
                    180deg,
                    rgba(195, 112, 34, 0.164) 0%,
                    rgba(156, 200, 105, 0.495) 100%
                );
            }

            #gamePanel1 {
                display: none;
                background: linear-gradient(
                    56deg,
                    rgba(225, 238, 255, 0.492) 0%,
                    rgba(122, 67, 250, 0.495) 100%
                );
            }

            #gamePanel2 {
                display: none;
                background: linear-gradient(
                    56deg,
                    rgba(235, 204, 32, 0.492) 0%,
                    rgba(251, 188, 106, 0.495) 100%
                );
            }

            .chatPanel {
                border: solid 1px gray;
                border-radius: 20px 0px 4px 4px;
                box-shadow: 15px 10px #dddddd;
                background: rgb(34, 193, 195);
                background: linear-gradient(
                    56deg,
                    rgba(34, 193, 195, 0.49193275943189773) 0%,
                    rgba(253, 187, 45, 0.494733879880077) 100%
                );
                position: relative;
            }

            .chatMessageInputDiv {
                position: absolute;
                bottom: 0px;
                width: 100%;
            }

            .messages {
                padding-left: 0;
                overflow: hidden;
                height: 340px;
                margin-bottom: 40px;
            }

            .jumbotron {
                margin-top: -40px;
                height: 180px;
            }

            .footer {
                margin-top: 10px;
            }
        </style>
    </head>

    <body>
        <div class="jumbotron text-center" style="margin-bottom:0">
            <h1>Lucky Numbers Mini-Games</h1>
            <p>
                <a href="https://sbcode.net/tssock" target="_blank"
                    >https://sbcode.net/tssock</a
                >
            </p>
        </div>

        <nav class="navbar navbar-expand-sm bg-dark navbar-dark">
            <a class="navbar-brand" href="#">Games</a>
            <button
                class="navbar-toggler"
                type="button"
                data-toggle="collapse"
                data-target="#collapsibleNavbar"
            >
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="collapsibleNavbar">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a
                            class="nav-link"
                            href="#"
                            onclick="client.showGame(0)"
                            >🥉Bronze Game</a
                        >
                    </li>
                    <li class="nav-item">
                        <a
                            class="nav-link"
                            href="#"
                            onclick="client.showGame(1)"
                            >🥈Silver Game</a
                        >
                    </li>
                    <li class="nav-item">
                        <a
                            class="nav-link"
                            href="#"
                            onclick="client.showGame(2)"
                            >🥇Gold Game</a
                        >
                    </li>
                </ul>
            </div>
        </nav>

        <div class="container" style="margin-top:30px">
            <div class="row">
                <div class="col-sm-8">
                    <div class="gamePanel" id="gamePanel0">
                        <h2 id="gameTitle">🥉Bronze Game</h2>
                    </div>
                    <div class="gamePanel" id="gamePanel1">
                        <h2 id="gameTitle">🥈Silver Game</h2>
                    </div>
                    <div class="gamePanel" id="gamePanel2">
                        <h2 id="gameTitle">🥇Gold Game</h2>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="chatPanel">
                        <ol id="messages" class="messages"></ol>
                        <div class="chatMessageInputDiv">
                            <div class="input-group">
                                <input
                                    class="form-control width100"
                                    id="messageText"
                                    placeholder="Enter Chat Message"
                                    onkeyup=""
                                />
                                <span class="input-group-btn">
                                    <button class="btn btn-info">Send</button>
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="footer text-center" style="margin-bottom:0">
            This is an example game from the TypeScript SocketIO course at
            <a href="https://sbcode.net/tssock" target="_blank"
                >https://sbcode.net/tssock</a
            >
        </div>

        <script src="jquery/jquery.min.js"></script>
        <script src="bootstrap/js/bootstrap.bundle.min.js"></script>
        <script src="socket.io/socket.io.js"></script>
        <script src="client.js"></script>
    </body>
</html>

./src/client/client.ts

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Client {
    private socket: SocketIOClient.Socket

    constructor() {
        this.socket = io()

        this.socket.on('connect', function () {
            console.log('connect')
        })

        this.socket.on('disconnect', function (message: any) {
            console.log('disconnect ' + message)
            location.reload()
        })
    }

    public showGame(id: number) {
        switch (id) {
            case 0:
                $('#gamePanel1').fadeOut(100)
                $('#gamePanel2').fadeOut(100)
                $('#gamePanel0').delay(100).fadeIn(100)
                break
            case 1:
                $('#gamePanel0').fadeOut(100)
                $('#gamePanel2').fadeOut(100)
                $('#gamePanel1').delay(100).fadeIn(100)
                break
            case 2:
                $('#gamePanel0').fadeOut(100)
                $('#gamePanel1').fadeOut(100)
                $('#gamePanel2').delay(100).fadeIn(100)
                break
        }
    }
}

const client = new Client()