commit 6225620ad6064b8627b826994a7f207a9593e594 Author: Ваше Имя Date: Tue Feb 18 13:00:27 2025 +0500 first commit diff --git a/.docker/.token_seed b/.docker/.token_seed new file mode 100644 index 0000000..763a474 --- /dev/null +++ b/.docker/.token_seed @@ -0,0 +1,5 @@ +{ + "registry-1.docker.io": { + "Seed": "ZlGlUhgJYF5cgnn+dd//6Q==" + } +} \ No newline at end of file diff --git a/.docker/.token_seed.lock b/.docker/.token_seed.lock new file mode 100644 index 0000000..e69de29 diff --git a/.docker/buildx/.buildNodeID b/.docker/buildx/.buildNodeID new file mode 100644 index 0000000..dc22710 --- /dev/null +++ b/.docker/buildx/.buildNodeID @@ -0,0 +1 @@ +79a291e8d6fbf402 \ No newline at end of file diff --git a/.docker/buildx/.lock b/.docker/buildx/.lock new file mode 100644 index 0000000..e69de29 diff --git a/.docker/buildx/activity/default b/.docker/buildx/activity/default new file mode 100644 index 0000000..d3b1483 --- /dev/null +++ b/.docker/buildx/activity/default @@ -0,0 +1 @@ +2025-02-18T07:56:48Z \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/0h8grrcwizmr7l8s22bjw9wma b/.docker/buildx/refs/default/default/0h8grrcwizmr7l8s22bjw9wma new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/0h8grrcwizmr7l8s22bjw9wma @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/1jcvlsgtukbeld5ijkxw9nlud b/.docker/buildx/refs/default/default/1jcvlsgtukbeld5ijkxw9nlud new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/1jcvlsgtukbeld5ijkxw9nlud @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/4k3gl3i7fzx4nc6gd8w5j90s8 b/.docker/buildx/refs/default/default/4k3gl3i7fzx4nc6gd8w5j90s8 new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/4k3gl3i7fzx4nc6gd8w5j90s8 @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/4rmjy6ecpph9nfirzahsf7124 b/.docker/buildx/refs/default/default/4rmjy6ecpph9nfirzahsf7124 new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/4rmjy6ecpph9nfirzahsf7124 @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/678dxaplw55li1m2772tyn983 b/.docker/buildx/refs/default/default/678dxaplw55li1m2772tyn983 new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/678dxaplw55li1m2772tyn983 @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/7u4q7b1pa9i8u4mcbiqjn1s95 b/.docker/buildx/refs/default/default/7u4q7b1pa9i8u4mcbiqjn1s95 new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/7u4q7b1pa9i8u4mcbiqjn1s95 @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/9ks7tgm5xprz3mizxau9kxxbn b/.docker/buildx/refs/default/default/9ks7tgm5xprz3mizxau9kxxbn new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/9ks7tgm5xprz3mizxau9kxxbn @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/g0lyc7hz6pmxzpmopjtqa2kp1 b/.docker/buildx/refs/default/default/g0lyc7hz6pmxzpmopjtqa2kp1 new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/g0lyc7hz6pmxzpmopjtqa2kp1 @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/g4vxj2jvv23snlws35bvdlg9x b/.docker/buildx/refs/default/default/g4vxj2jvv23snlws35bvdlg9x new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/g4vxj2jvv23snlws35bvdlg9x @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/gohl5hdcpdapw3tjhboit6ihx b/.docker/buildx/refs/default/default/gohl5hdcpdapw3tjhboit6ihx new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/gohl5hdcpdapw3tjhboit6ihx @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/hxnqmoq5vrx65zv2va6lhlxkw b/.docker/buildx/refs/default/default/hxnqmoq5vrx65zv2va6lhlxkw new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/hxnqmoq5vrx65zv2va6lhlxkw @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/i8dj11occ1ol0ogordrugbfrm b/.docker/buildx/refs/default/default/i8dj11occ1ol0ogordrugbfrm new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/i8dj11occ1ol0ogordrugbfrm @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/qyj1xdfif6k0bzwirtrpw112z b/.docker/buildx/refs/default/default/qyj1xdfif6k0bzwirtrpw112z new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/qyj1xdfif6k0bzwirtrpw112z @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/r13l7906ur1wgbn2yhp3ek9bw b/.docker/buildx/refs/default/default/r13l7906ur1wgbn2yhp3ek9bw new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/r13l7906ur1wgbn2yhp3ek9bw @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/r2xkgvioi88i9qa09by9orc4y b/.docker/buildx/refs/default/default/r2xkgvioi88i9qa09by9orc4y new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/r2xkgvioi88i9qa09by9orc4y @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/rbroobfsqh97f57pyou9fncj3 b/.docker/buildx/refs/default/default/rbroobfsqh97f57pyou9fncj3 new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/rbroobfsqh97f57pyou9fncj3 @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/t8uslnjmbch3mbl2662csj7yx b/.docker/buildx/refs/default/default/t8uslnjmbch3mbl2662csj7yx new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/t8uslnjmbch3mbl2662csj7yx @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/tqydyvz248d489ffj68xx0mtx b/.docker/buildx/refs/default/default/tqydyvz248d489ffj68xx0mtx new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/tqydyvz248d489ffj68xx0mtx @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/um4c7ntbkx6eiomn5gacdraz5 b/.docker/buildx/refs/default/default/um4c7ntbkx6eiomn5gacdraz5 new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/um4c7ntbkx6eiomn5gacdraz5 @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/w168tg9o6z7qgka65pmprgs5g b/.docker/buildx/refs/default/default/w168tg9o6z7qgka65pmprgs5g new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/w168tg9o6z7qgka65pmprgs5g @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/w62zyy2qhya5p25uon11j74th b/.docker/buildx/refs/default/default/w62zyy2qhya5p25uon11j74th new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/w62zyy2qhya5p25uon11j74th @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/w9scuehjckhvhhynzhwljwu3t b/.docker/buildx/refs/default/default/w9scuehjckhvhhynzhwljwu3t new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/w9scuehjckhvhhynzhwljwu3t @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/xpkr1v6m0n7knu6wn6xkuzo6j b/.docker/buildx/refs/default/default/xpkr1v6m0n7knu6wn6xkuzo6j new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/xpkr1v6m0n7knu6wn6xkuzo6j @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/yfw6mh0boeeiqff58st2ny3mc b/.docker/buildx/refs/default/default/yfw6mh0boeeiqff58st2ny3mc new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/yfw6mh0boeeiqff58st2ny3mc @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.docker/buildx/refs/default/default/zdnehu9xl88l8vemk8f1qwk4c b/.docker/buildx/refs/default/default/zdnehu9xl88l8vemk8f1qwk4c new file mode 100644 index 0000000..8117667 --- /dev/null +++ b/.docker/buildx/refs/default/default/zdnehu9xl88l8vemk8f1qwk4c @@ -0,0 +1 @@ +{"Target":"default","LocalPath":"/home/chat","DockerfilePath":""} \ No newline at end of file diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 0000000..693f057 --- /dev/null +++ b/.gitconfig @@ -0,0 +1,3 @@ +[user] + email = you@example.com + name = Ваше Имя diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6647e02 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,58 @@ +name: "CI for builds" + +on: + push: + branches: + - master + tags: + - 'v*' + +env: + IMAGE_NAME: m1k1o/chat + +jobs: + build: + runs-on: ubuntu-latest + # + # do not run on forks + # + if: github.repository_owner == 'm1k1o' + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + - + name: Available platforms + run: echo ${{ steps.buildx.outputs.platforms }} + - + name: Extract metadata (tags, labels) for Docker + uses: docker/metadata-action@v3 + id: meta + with: + images: ${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + - + name: Log in to the Container registry + uses: docker/login-action@v1 + with: + username: ${{ github.actor }} + password: ${{ secrets.DOCKER_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v2 + with: + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64,linux/arm/v7 + push: true \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/.sudo_as_admin_successful b/.sudo_as_admin_successful new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..238e0c4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM node:14-slim + +# +# create app directory +WORKDIR /usr/src/app + +# +# install app dependencies +COPY package*.json ./ +RUN npm install + +# +# copy app +COPY . . + +ENV MAX_HTTP_BUFFER_SIZE_MB=1 + +ENTRYPOINT [ "node", "server.js" ] + +EXPOSE 80 +CMD [ "80" ] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e75d206 --- /dev/null +++ b/README.md @@ -0,0 +1,55 @@ +# chat +Simple plug & play real-time JavaScript chat implemented using Socket.io. + +Where simplicity meets usability: + +* No user accounts - just enter nickname and join. +* No history saved by default - only logged-in users can see recent history. +* No configuration. +* Only one room - you can't create any other rooms or write PM to others. +* Files sharing is possible - without storing any data on server. +* Emojis - just a few of them. + +![screenshot](https://raw.githubusercontent.com/m1k1o/chat/master/screenshot.png) + +## docker + +```sh +docker run -d \ + --name chat \ + -p 80:80 \ + m1k1o/chat:latest +``` + +## docker-compose + +```yml +version: "3" +services: + chat: + image: m1k1o/chat:latest + restart: unless-stopped + ports: + - 80:80 + environment: + CACHE_SIZE: 50 # optional: message count stored. Defaults to zero. + ``` + +## Cache +`CACHE_SIZE` is optional and determines the number of messages stored on the server. When new users join (or reconnect), that cache is sent to give a brief history. This defaults to zero, but can be set as an environment variable. + +If you're not running in a docker container, you can make a `.env` file in the project root with `CACHE_SIZE=50` in. + +Note: This cache will be text or images so be mindful not to set it too high as it could be n images sent to every new user. + +## How to install + +Requirements: `nodejs`, `npm` + +1. Clone this repository. + - `git clone https://github.com/m1k1o/chat .` +2. Install server dependencies. + - `npm install` +3. Run server (default port is `80`). + - `npm start [custom_port]` +4. Done, visit your chat in browser. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a38fae5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: "3" +services: + chat: + build: . + # image: m1k1o/chat:latest + restart: unless-stopped + ports: + - 150:80 + environment: + CACHE_SIZE: 50 # optional: message count stored. Defaults to zero. diff --git a/html/index.html b/html/index.html new file mode 100755 index 0000000..e2a2752 --- /dev/null +++ b/html/index.html @@ -0,0 +1,51 @@ + + + + + + Chat + + + + + + + + + + +
+
+

Доска объявлений для GAME SERVER ЧАТ | minecraft vanila |

+
+
+
Server is offline.
Sorry for that.
+
    +
      +
      +
      + + + + +
        +
        +
        + + + + + + + + \ No newline at end of file diff --git a/html/static/beep.ogg b/html/static/beep.ogg new file mode 100644 index 0000000..8e907ab Binary files /dev/null and b/html/static/beep.ogg differ diff --git a/html/static/beep.ogg.old b/html/static/beep.ogg.old new file mode 100644 index 0000000..6334be6 Binary files /dev/null and b/html/static/beep.ogg.old differ diff --git a/html/static/emic/alien-monster.png b/html/static/emic/alien-monster.png new file mode 100644 index 0000000..312a9ce Binary files /dev/null and b/html/static/emic/alien-monster.png differ diff --git a/html/static/emic/angry-face.png b/html/static/emic/angry-face.png new file mode 100644 index 0000000..5b39b8b Binary files /dev/null and b/html/static/emic/angry-face.png differ diff --git a/html/static/emic/anguished-face.png b/html/static/emic/anguished-face.png new file mode 100644 index 0000000..f91c747 Binary files /dev/null and b/html/static/emic/anguished-face.png differ diff --git a/html/static/emic/astonished-face.png b/html/static/emic/astonished-face.png new file mode 100644 index 0000000..059f417 Binary files /dev/null and b/html/static/emic/astonished-face.png differ diff --git a/html/static/emic/avocado.png b/html/static/emic/avocado.png new file mode 100644 index 0000000..2503cda Binary files /dev/null and b/html/static/emic/avocado.png differ diff --git a/html/static/emic/banana.png b/html/static/emic/banana.png new file mode 100644 index 0000000..7564925 Binary files /dev/null and b/html/static/emic/banana.png differ diff --git a/html/static/emic/cat-face-with-tears-of-joy.png b/html/static/emic/cat-face-with-tears-of-joy.png new file mode 100644 index 0000000..b08061a Binary files /dev/null and b/html/static/emic/cat-face-with-tears-of-joy.png differ diff --git a/html/static/emic/cat-face-with-wry-smile.png b/html/static/emic/cat-face-with-wry-smile.png new file mode 100644 index 0000000..8456754 Binary files /dev/null and b/html/static/emic/cat-face-with-wry-smile.png differ diff --git a/html/static/emic/clown-face.png b/html/static/emic/clown-face.png new file mode 100644 index 0000000..52ff85e Binary files /dev/null and b/html/static/emic/clown-face.png differ diff --git a/html/static/emic/confounded-face.png b/html/static/emic/confounded-face.png new file mode 100644 index 0000000..482901b Binary files /dev/null and b/html/static/emic/confounded-face.png differ diff --git a/html/static/emic/confused-face.png b/html/static/emic/confused-face.png new file mode 100644 index 0000000..1e612f2 Binary files /dev/null and b/html/static/emic/confused-face.png differ diff --git a/html/static/emic/crying-cat-face.png b/html/static/emic/crying-cat-face.png new file mode 100644 index 0000000..e6f08d1 Binary files /dev/null and b/html/static/emic/crying-cat-face.png differ diff --git a/html/static/emic/crying-face.png b/html/static/emic/crying-face.png new file mode 100644 index 0000000..c1d0c80 Binary files /dev/null and b/html/static/emic/crying-face.png differ diff --git a/html/static/emic/disappointed-but-relieved-face.png b/html/static/emic/disappointed-but-relieved-face.png new file mode 100644 index 0000000..8c10af9 Binary files /dev/null and b/html/static/emic/disappointed-but-relieved-face.png differ diff --git a/html/static/emic/disappointed-face.png b/html/static/emic/disappointed-face.png new file mode 100644 index 0000000..7db095d Binary files /dev/null and b/html/static/emic/disappointed-face.png differ diff --git a/html/static/emic/dizzy-face.png b/html/static/emic/dizzy-face.png new file mode 100644 index 0000000..8f35d3d Binary files /dev/null and b/html/static/emic/dizzy-face.png differ diff --git a/html/static/emic/drooling-face.png b/html/static/emic/drooling-face.png new file mode 100644 index 0000000..b0d37b6 Binary files /dev/null and b/html/static/emic/drooling-face.png differ diff --git a/html/static/emic/expressionless-face.png b/html/static/emic/expressionless-face.png new file mode 100644 index 0000000..7eb8467 Binary files /dev/null and b/html/static/emic/expressionless-face.png differ diff --git a/html/static/emic/extraterrestrial-alien.png b/html/static/emic/extraterrestrial-alien.png new file mode 100644 index 0000000..9628ee7 Binary files /dev/null and b/html/static/emic/extraterrestrial-alien.png differ diff --git a/html/static/emic/face-savouring-delicious-food.png b/html/static/emic/face-savouring-delicious-food.png new file mode 100644 index 0000000..924d1c0 Binary files /dev/null and b/html/static/emic/face-savouring-delicious-food.png differ diff --git a/html/static/emic/face-screaming-in-fear.png b/html/static/emic/face-screaming-in-fear.png new file mode 100644 index 0000000..72537ad Binary files /dev/null and b/html/static/emic/face-screaming-in-fear.png differ diff --git a/html/static/emic/face-throwing-a-kiss.png b/html/static/emic/face-throwing-a-kiss.png new file mode 100644 index 0000000..2f45937 Binary files /dev/null and b/html/static/emic/face-throwing-a-kiss.png differ diff --git a/html/static/emic/face-with-cold-sweat.png b/html/static/emic/face-with-cold-sweat.png new file mode 100644 index 0000000..da0845f Binary files /dev/null and b/html/static/emic/face-with-cold-sweat.png differ diff --git a/html/static/emic/face-with-cowboy-hat.png b/html/static/emic/face-with-cowboy-hat.png new file mode 100644 index 0000000..b788d25 Binary files /dev/null and b/html/static/emic/face-with-cowboy-hat.png differ diff --git a/html/static/emic/face-with-head-bandage.png b/html/static/emic/face-with-head-bandage.png new file mode 100644 index 0000000..88ebb02 Binary files /dev/null and b/html/static/emic/face-with-head-bandage.png differ diff --git a/html/static/emic/face-with-look-of-triumph.png b/html/static/emic/face-with-look-of-triumph.png new file mode 100644 index 0000000..23771c2 Binary files /dev/null and b/html/static/emic/face-with-look-of-triumph.png differ diff --git a/html/static/emic/face-with-medical-mask.png b/html/static/emic/face-with-medical-mask.png new file mode 100644 index 0000000..fedca0c Binary files /dev/null and b/html/static/emic/face-with-medical-mask.png differ diff --git a/html/static/emic/face-with-open-mouth-and-cold-sweat.png b/html/static/emic/face-with-open-mouth-and-cold-sweat.png new file mode 100644 index 0000000..acad480 Binary files /dev/null and b/html/static/emic/face-with-open-mouth-and-cold-sweat.png differ diff --git a/html/static/emic/face-with-open-mouth.png b/html/static/emic/face-with-open-mouth.png new file mode 100644 index 0000000..92517bf Binary files /dev/null and b/html/static/emic/face-with-open-mouth.png differ diff --git a/html/static/emic/face-with-rolling-eyes.png b/html/static/emic/face-with-rolling-eyes.png new file mode 100644 index 0000000..77ea78d Binary files /dev/null and b/html/static/emic/face-with-rolling-eyes.png differ diff --git a/html/static/emic/face-with-stuck-out-tongue-and-tightly-closed-eyes.png b/html/static/emic/face-with-stuck-out-tongue-and-tightly-closed-eyes.png new file mode 100644 index 0000000..554a589 Binary files /dev/null and b/html/static/emic/face-with-stuck-out-tongue-and-tightly-closed-eyes.png differ diff --git a/html/static/emic/face-with-stuck-out-tongue-and-winking-eye.png b/html/static/emic/face-with-stuck-out-tongue-and-winking-eye.png new file mode 100644 index 0000000..822ded2 Binary files /dev/null and b/html/static/emic/face-with-stuck-out-tongue-and-winking-eye.png differ diff --git a/html/static/emic/face-with-stuck-out-tongue.png b/html/static/emic/face-with-stuck-out-tongue.png new file mode 100644 index 0000000..68aeb22 Binary files /dev/null and b/html/static/emic/face-with-stuck-out-tongue.png differ diff --git a/html/static/emic/face-with-tears-of-joy.png b/html/static/emic/face-with-tears-of-joy.png new file mode 100644 index 0000000..2fd251c Binary files /dev/null and b/html/static/emic/face-with-tears-of-joy.png differ diff --git a/html/static/emic/face-with-thermometer.png b/html/static/emic/face-with-thermometer.png new file mode 100644 index 0000000..fac82bf Binary files /dev/null and b/html/static/emic/face-with-thermometer.png differ diff --git a/html/static/emic/face-without-mouth.png b/html/static/emic/face-without-mouth.png new file mode 100644 index 0000000..3926c25 Binary files /dev/null and b/html/static/emic/face-without-mouth.png differ diff --git a/html/static/emic/fearful-face.png b/html/static/emic/fearful-face.png new file mode 100644 index 0000000..5df9dd1 Binary files /dev/null and b/html/static/emic/fearful-face.png differ diff --git a/html/static/emic/flushed-face.png b/html/static/emic/flushed-face.png new file mode 100644 index 0000000..7f80477 Binary files /dev/null and b/html/static/emic/flushed-face.png differ diff --git a/html/static/emic/frowning-face-with-open-mouth.png b/html/static/emic/frowning-face-with-open-mouth.png new file mode 100644 index 0000000..8abdba9 Binary files /dev/null and b/html/static/emic/frowning-face-with-open-mouth.png differ diff --git a/html/static/emic/ghost.png b/html/static/emic/ghost.png new file mode 100644 index 0000000..b66963b Binary files /dev/null and b/html/static/emic/ghost.png differ diff --git a/html/static/emic/grimacing-face.png b/html/static/emic/grimacing-face.png new file mode 100644 index 0000000..b333ddc Binary files /dev/null and b/html/static/emic/grimacing-face.png differ diff --git a/html/static/emic/grinning-cat-face-with-smiling-eyes.png b/html/static/emic/grinning-cat-face-with-smiling-eyes.png new file mode 100644 index 0000000..d5dcfe6 Binary files /dev/null and b/html/static/emic/grinning-cat-face-with-smiling-eyes.png differ diff --git a/html/static/emic/grinning-face-with-smiling-eyes.png b/html/static/emic/grinning-face-with-smiling-eyes.png new file mode 100644 index 0000000..ab4f024 Binary files /dev/null and b/html/static/emic/grinning-face-with-smiling-eyes.png differ diff --git a/html/static/emic/grinning-face.png b/html/static/emic/grinning-face.png new file mode 100644 index 0000000..1c94435 Binary files /dev/null and b/html/static/emic/grinning-face.png differ diff --git a/html/static/emic/hear-no-evil-monkey.png b/html/static/emic/hear-no-evil-monkey.png new file mode 100644 index 0000000..c5b16da Binary files /dev/null and b/html/static/emic/hear-no-evil-monkey.png differ diff --git a/html/static/emic/heavy-black-heart.png b/html/static/emic/heavy-black-heart.png new file mode 100644 index 0000000..8f46639 Binary files /dev/null and b/html/static/emic/heavy-black-heart.png differ diff --git a/html/static/emic/hugging-face.png b/html/static/emic/hugging-face.png new file mode 100644 index 0000000..178ee5c Binary files /dev/null and b/html/static/emic/hugging-face.png differ diff --git a/html/static/emic/hushed-face.png b/html/static/emic/hushed-face.png new file mode 100644 index 0000000..204edf6 Binary files /dev/null and b/html/static/emic/hushed-face.png differ diff --git a/html/static/emic/imp.png b/html/static/emic/imp.png new file mode 100644 index 0000000..3eaae85 Binary files /dev/null and b/html/static/emic/imp.png differ diff --git a/html/static/emic/japanese-goblin.png b/html/static/emic/japanese-goblin.png new file mode 100644 index 0000000..473e339 Binary files /dev/null and b/html/static/emic/japanese-goblin.png differ diff --git a/html/static/emic/japanese-ogre.png b/html/static/emic/japanese-ogre.png new file mode 100644 index 0000000..318aafd Binary files /dev/null and b/html/static/emic/japanese-ogre.png differ diff --git a/html/static/emic/kissing-cat-face-with-closed-eyes.png b/html/static/emic/kissing-cat-face-with-closed-eyes.png new file mode 100644 index 0000000..b3df2c2 Binary files /dev/null and b/html/static/emic/kissing-cat-face-with-closed-eyes.png differ diff --git a/html/static/emic/kissing-face-with-closed-eyes.png b/html/static/emic/kissing-face-with-closed-eyes.png new file mode 100644 index 0000000..883268e Binary files /dev/null and b/html/static/emic/kissing-face-with-closed-eyes.png differ diff --git a/html/static/emic/kissing-face-with-smiling-eyes.png b/html/static/emic/kissing-face-with-smiling-eyes.png new file mode 100644 index 0000000..97d0fb2 Binary files /dev/null and b/html/static/emic/kissing-face-with-smiling-eyes.png differ diff --git a/html/static/emic/kissing-face.png b/html/static/emic/kissing-face.png new file mode 100644 index 0000000..49dbe9f Binary files /dev/null and b/html/static/emic/kissing-face.png differ diff --git a/html/static/emic/loudly-crying-face.png b/html/static/emic/loudly-crying-face.png new file mode 100644 index 0000000..cfbb7e3 Binary files /dev/null and b/html/static/emic/loudly-crying-face.png differ diff --git a/html/static/emic/lying-face.png b/html/static/emic/lying-face.png new file mode 100644 index 0000000..ac4113c Binary files /dev/null and b/html/static/emic/lying-face.png differ diff --git a/html/static/emic/money-mouth-face.png b/html/static/emic/money-mouth-face.png new file mode 100644 index 0000000..e6a2a4a Binary files /dev/null and b/html/static/emic/money-mouth-face.png differ diff --git a/html/static/emic/nauseated-face.png b/html/static/emic/nauseated-face.png new file mode 100644 index 0000000..6388f7b Binary files /dev/null and b/html/static/emic/nauseated-face.png differ diff --git a/html/static/emic/nerd-face.png b/html/static/emic/nerd-face.png new file mode 100644 index 0000000..f24de84 Binary files /dev/null and b/html/static/emic/nerd-face.png differ diff --git a/html/static/emic/neutral-face.png b/html/static/emic/neutral-face.png new file mode 100644 index 0000000..37aea30 Binary files /dev/null and b/html/static/emic/neutral-face.png differ diff --git a/html/static/emic/pensive-face.png b/html/static/emic/pensive-face.png new file mode 100644 index 0000000..56c9c06 Binary files /dev/null and b/html/static/emic/pensive-face.png differ diff --git a/html/static/emic/persevering-face.png b/html/static/emic/persevering-face.png new file mode 100644 index 0000000..572edf4 Binary files /dev/null and b/html/static/emic/persevering-face.png differ diff --git a/html/static/emic/pile-of-poo.png b/html/static/emic/pile-of-poo.png new file mode 100644 index 0000000..8fa29f1 Binary files /dev/null and b/html/static/emic/pile-of-poo.png differ diff --git a/html/static/emic/pouting-cat-face.png b/html/static/emic/pouting-cat-face.png new file mode 100644 index 0000000..3eddcbb Binary files /dev/null and b/html/static/emic/pouting-cat-face.png differ diff --git a/html/static/emic/pouting-face.png b/html/static/emic/pouting-face.png new file mode 100644 index 0000000..7714e26 Binary files /dev/null and b/html/static/emic/pouting-face.png differ diff --git a/html/static/emic/relieved-face.png b/html/static/emic/relieved-face.png new file mode 100644 index 0000000..469492f Binary files /dev/null and b/html/static/emic/relieved-face.png differ diff --git a/html/static/emic/robot-face.png b/html/static/emic/robot-face.png new file mode 100644 index 0000000..8c231f4 Binary files /dev/null and b/html/static/emic/robot-face.png differ diff --git a/html/static/emic/rolling-on-the-floor-laughing.png b/html/static/emic/rolling-on-the-floor-laughing.png new file mode 100644 index 0000000..c2abc57 Binary files /dev/null and b/html/static/emic/rolling-on-the-floor-laughing.png differ diff --git a/html/static/emic/see-no-evil-monkey.png b/html/static/emic/see-no-evil-monkey.png new file mode 100644 index 0000000..dcd57b1 Binary files /dev/null and b/html/static/emic/see-no-evil-monkey.png differ diff --git a/html/static/emic/skull-and-crossbones.png b/html/static/emic/skull-and-crossbones.png new file mode 100644 index 0000000..aa838ff Binary files /dev/null and b/html/static/emic/skull-and-crossbones.png differ diff --git a/html/static/emic/skull.png b/html/static/emic/skull.png new file mode 100644 index 0000000..69a2fd4 Binary files /dev/null and b/html/static/emic/skull.png differ diff --git a/html/static/emic/sleeping-face.png b/html/static/emic/sleeping-face.png new file mode 100644 index 0000000..38fa218 Binary files /dev/null and b/html/static/emic/sleeping-face.png differ diff --git a/html/static/emic/sleepy-face.png b/html/static/emic/sleepy-face.png new file mode 100644 index 0000000..c0daf05 Binary files /dev/null and b/html/static/emic/sleepy-face.png differ diff --git a/html/static/emic/slightly-frowning-face.png b/html/static/emic/slightly-frowning-face.png new file mode 100644 index 0000000..36da10d Binary files /dev/null and b/html/static/emic/slightly-frowning-face.png differ diff --git a/html/static/emic/slightly-smiling-face.png b/html/static/emic/slightly-smiling-face.png new file mode 100644 index 0000000..4c15025 Binary files /dev/null and b/html/static/emic/slightly-smiling-face.png differ diff --git a/html/static/emic/smiling-cat-face-with-heart-shaped-eyes.png b/html/static/emic/smiling-cat-face-with-heart-shaped-eyes.png new file mode 100644 index 0000000..d0e3716 Binary files /dev/null and b/html/static/emic/smiling-cat-face-with-heart-shaped-eyes.png differ diff --git a/html/static/emic/smiling-cat-face-with-open-mouth.png b/html/static/emic/smiling-cat-face-with-open-mouth.png new file mode 100644 index 0000000..032e221 Binary files /dev/null and b/html/static/emic/smiling-cat-face-with-open-mouth.png differ diff --git a/html/static/emic/smiling-face-with-halo.png b/html/static/emic/smiling-face-with-halo.png new file mode 100644 index 0000000..78c1431 Binary files /dev/null and b/html/static/emic/smiling-face-with-halo.png differ diff --git a/html/static/emic/smiling-face-with-heart-shaped-eyes.png b/html/static/emic/smiling-face-with-heart-shaped-eyes.png new file mode 100644 index 0000000..30bedf2 Binary files /dev/null and b/html/static/emic/smiling-face-with-heart-shaped-eyes.png differ diff --git a/html/static/emic/smiling-face-with-horns.png b/html/static/emic/smiling-face-with-horns.png new file mode 100644 index 0000000..3b6f570 Binary files /dev/null and b/html/static/emic/smiling-face-with-horns.png differ diff --git a/html/static/emic/smiling-face-with-open-mouth-and-cold-sweat.png b/html/static/emic/smiling-face-with-open-mouth-and-cold-sweat.png new file mode 100644 index 0000000..7649709 Binary files /dev/null and b/html/static/emic/smiling-face-with-open-mouth-and-cold-sweat.png differ diff --git a/html/static/emic/smiling-face-with-open-mouth-and-smiling-eyes.png b/html/static/emic/smiling-face-with-open-mouth-and-smiling-eyes.png new file mode 100644 index 0000000..cca88f9 Binary files /dev/null and b/html/static/emic/smiling-face-with-open-mouth-and-smiling-eyes.png differ diff --git a/html/static/emic/smiling-face-with-open-mouth-and-tightly-closed-eyes.png b/html/static/emic/smiling-face-with-open-mouth-and-tightly-closed-eyes.png new file mode 100644 index 0000000..6c9563d Binary files /dev/null and b/html/static/emic/smiling-face-with-open-mouth-and-tightly-closed-eyes.png differ diff --git a/html/static/emic/smiling-face-with-open-mouth.png b/html/static/emic/smiling-face-with-open-mouth.png new file mode 100644 index 0000000..83c12f2 Binary files /dev/null and b/html/static/emic/smiling-face-with-open-mouth.png differ diff --git a/html/static/emic/smiling-face-with-smiling-eyes.png b/html/static/emic/smiling-face-with-smiling-eyes.png new file mode 100644 index 0000000..b2db81c Binary files /dev/null and b/html/static/emic/smiling-face-with-smiling-eyes.png differ diff --git a/html/static/emic/smiling-face-with-sunglasses.png b/html/static/emic/smiling-face-with-sunglasses.png new file mode 100644 index 0000000..5014d2c Binary files /dev/null and b/html/static/emic/smiling-face-with-sunglasses.png differ diff --git a/html/static/emic/smirking-face.png b/html/static/emic/smirking-face.png new file mode 100644 index 0000000..0881ff0 Binary files /dev/null and b/html/static/emic/smirking-face.png differ diff --git a/html/static/emic/sneezing-face.png b/html/static/emic/sneezing-face.png new file mode 100644 index 0000000..6657017 Binary files /dev/null and b/html/static/emic/sneezing-face.png differ diff --git a/html/static/emic/speak-no-evil-monkey.png b/html/static/emic/speak-no-evil-monkey.png new file mode 100644 index 0000000..85b7f33 Binary files /dev/null and b/html/static/emic/speak-no-evil-monkey.png differ diff --git a/html/static/emic/thinking-face.png b/html/static/emic/thinking-face.png new file mode 100644 index 0000000..0fe5fc6 Binary files /dev/null and b/html/static/emic/thinking-face.png differ diff --git a/html/static/emic/tired-face.png b/html/static/emic/tired-face.png new file mode 100644 index 0000000..bc5b5d8 Binary files /dev/null and b/html/static/emic/tired-face.png differ diff --git a/html/static/emic/unamused-face.png b/html/static/emic/unamused-face.png new file mode 100644 index 0000000..4caa635 Binary files /dev/null and b/html/static/emic/unamused-face.png differ diff --git a/html/static/emic/upside-down-face.png b/html/static/emic/upside-down-face.png new file mode 100644 index 0000000..eec74f7 Binary files /dev/null and b/html/static/emic/upside-down-face.png differ diff --git a/html/static/emic/weary-cat-face.png b/html/static/emic/weary-cat-face.png new file mode 100644 index 0000000..02a5520 Binary files /dev/null and b/html/static/emic/weary-cat-face.png differ diff --git a/html/static/emic/weary-face.png b/html/static/emic/weary-face.png new file mode 100644 index 0000000..60892d8 Binary files /dev/null and b/html/static/emic/weary-face.png differ diff --git a/html/static/emic/white-frowning-face.png b/html/static/emic/white-frowning-face.png new file mode 100644 index 0000000..91c29ef Binary files /dev/null and b/html/static/emic/white-frowning-face.png differ diff --git a/html/static/emic/white-smiling-face.png b/html/static/emic/white-smiling-face.png new file mode 100644 index 0000000..f241d51 Binary files /dev/null and b/html/static/emic/white-smiling-face.png differ diff --git a/html/static/emic/winking-face.png b/html/static/emic/winking-face.png new file mode 100644 index 0000000..b2d0bed Binary files /dev/null and b/html/static/emic/winking-face.png differ diff --git a/html/static/emic/worried-face.png b/html/static/emic/worried-face.png new file mode 100644 index 0000000..82fb183 Binary files /dev/null and b/html/static/emic/worried-face.png differ diff --git a/html/static/emic/zipper-mouth-face.png b/html/static/emic/zipper-mouth-face.png new file mode 100644 index 0000000..e566fc4 Binary files /dev/null and b/html/static/emic/zipper-mouth-face.png differ diff --git a/html/static/images/bender.png b/html/static/images/bender.png new file mode 100644 index 0000000..46a73be Binary files /dev/null and b/html/static/images/bender.png differ diff --git a/html/static/images/dog.png b/html/static/images/dog.png new file mode 100644 index 0000000..c59ed83 Binary files /dev/null and b/html/static/images/dog.png differ diff --git a/html/static/images/favicon-blue.ico b/html/static/images/favicon-blue.ico new file mode 100644 index 0000000..39839ec Binary files /dev/null and b/html/static/images/favicon-blue.ico differ diff --git a/html/static/images/favicon-blue.png b/html/static/images/favicon-blue.png new file mode 100644 index 0000000..e8f0dec Binary files /dev/null and b/html/static/images/favicon-blue.png differ diff --git a/html/static/images/favicon-green.ico b/html/static/images/favicon-green.ico new file mode 100644 index 0000000..cba2106 Binary files /dev/null and b/html/static/images/favicon-green.ico differ diff --git a/html/static/images/favicon-green.png b/html/static/images/favicon-green.png new file mode 100644 index 0000000..c8b1fe0 Binary files /dev/null and b/html/static/images/favicon-green.png differ diff --git a/html/static/images/favicon-red.ico b/html/static/images/favicon-red.ico new file mode 100644 index 0000000..b84f390 Binary files /dev/null and b/html/static/images/favicon-red.ico differ diff --git a/html/static/images/favicon-red.png b/html/static/images/favicon-red.png new file mode 100644 index 0000000..07b2d74 Binary files /dev/null and b/html/static/images/favicon-red.png differ diff --git a/html/static/scripts/chat.js b/html/static/scripts/chat.js new file mode 100755 index 0000000..6537fe7 --- /dev/null +++ b/html/static/scripts/chat.js @@ -0,0 +1,552 @@ +var Chat = { + socket: null, + + loading: document.getElementById("loading"), + chat_box: document.getElementById("chat-box"), + msgs_list: document.getElementById("msgs"), + typing_list: document.getElementById("typing"), + users: document.getElementById("users"), + textarea: document.getElementById("form_input"), + send_btn: document.getElementById("send"), + + is_focused: false, + is_online: false, + is_typing: false, + last_sent_nick: null, + + original_title: document.title, + new_title: "New messages...", + + scroll: function(){ + setTimeout(function(){ + Chat.chat_box.scrollTop = Chat.chat_box.scrollHeight; + }, 0) + }, + + notif: { + enabled: true, + + toggle: function(){ + return Chat.notif.enabled = !Chat.notif.enabled; + }, + + // Title time-out + ttout: undefined, + + active: undefined, + msgs: 0, + + // Beep notification + beep: undefined, + beep_create: function(){ + var audiotypes = { + "mp3": "audio/mpeg", + "mp4": "audio/mp4", + "ogg": "audio/ogg", + "wav": "audio/wav" + }; + + var audios = [ + 'static/beep.ogg' + ]; + + var audio_element = document.createElement('audio'); + if(audio_element.canPlayType){ + for(var i = 0;i < audios.length;i++){ + var source_element = document.createElement('source'); + source_element.setAttribute('src', audios[i]); + if(audios[i].match(/\.(\w+)$/i)){ + source_element.setAttribute('type', audiotypes[RegExp.$1]); + } + audio_element.appendChild(source_element); + } + + audio_element.load(); + audio_element.playclip = function(){ + audio_element.pause(); + audio_element.volume = 0.5; + audio_element.currentTime = 0; + audio_element.play(); + }; + + return audio_element; + } + }, + + // Create new notification + create: function(from, message){ + // If is focused, no notification + if(Chat.is_focused || !Chat.notif.enabled){ + return; + } + + // Increase number in title + Chat.notif.msgs++; + + // Create new ttout, if there is not any + Chat.notif.favicon('blue'); + document.title = '(' + Chat.notif.msgs + ') ' + Chat.new_title; + + if(typeof Chat.notif.ttout === "undefined"){ + Chat.notif.ttout = setInterval(function(){ + if(document.title == Chat.original_title){ + Chat.notif.favicon('blue'); + document.title = '(' + Chat.notif.msgs + ') ' + Chat.new_title; + } else { + Chat.notif.favicon('green'); + document.title = Chat.original_title; + } + }, 1500); + } + + // Do beep + Chat.notif.beep.playclip(); + + // If are'nt allowed notifications + if(Notification.permission !== "granted"){ + Notification.requestPermission(); + return; + } + + // Clear notification + Chat.notif.clear(); + + // Stip tags + from = from.replace(/(<([^>]+)>)/ig, ""); + message = message.replace(/(<([^>]+)>)/ig, ""); + + // Create new notification + Chat.notif.active = new Notification(from, { + icon: 'static/images/favicon-blue.png', + //timeout: 10, + body: message, + }); + + // On click, focus this window + Chat.notif.active.onclick = function(){ + parent.focus(); + window.focus(); + }; + }, + + // Clear notification + clear: function(){ + typeof Chat.notif.active === "undefined" || Chat.notif.active.close(); + }, + + favicon: function(color){ + var link = document.querySelector("link[rel*='icon']") || document.createElement('link'); + link.type = 'image/x-icon'; + link.rel = 'shortcut icon'; + link.href = 'static/images/favicon-' + color + '.ico'; + document.getElementsByTagName('head')[0].appendChild(link); + } + }, + + send_msg: function(text){ + Chat.socket.emit("send-msg", { + m: text + }); + }, + + send_event: function(){ + var value = Chat.textarea.value.trim(); + if(value == "") return; + + console.log("Send message."); + + Chat.send_msg({text: value}); + + Chat.textarea.value = ''; + Chat.typing.update(); + Chat.textarea.focus(); + }, + + typing: { + objects: {}, + + create: function(nick){ + var li = document.createElement('li'); + + var prefix = document.createElement('span'); + prefix.className = 'prefix'; + prefix.innerText = nick; + li.appendChild(prefix); + + var msg = document.createElement('div'); + msg.className = 'message'; + + var body = document.createElement('span'); + body.className = 'body writing' + body.innerHTML = ''; + msg.appendChild(body); + + li.appendChild(msg); + + Chat.typing_list.appendChild(li); + + Chat.typing.objects[nick] = li; + + // Scroll to new message + Chat.scroll(); + }, + + remove: function(nick){ + if(Chat.typing.objects.hasOwnProperty(nick)){ + var element = Chat.typing.objects[nick]; + element.parentNode.removeChild(element); + delete Chat.typing.objects[nick]; + } + }, + + event: function(r){ + if(r.status){ + Chat.typing.create(r.nick); + } else { + Chat.typing.remove(r.nick); + } + }, + + update: function(){ + if(Chat.is_typing && Chat.textarea.value === ""){ + Chat.socket.emit("typing", Chat.is_typing = false); + } + + if(!Chat.is_typing && Chat.textarea.value !== ""){ + Chat.socket.emit("typing", Chat.is_typing = true); + } + } + }, + + new_msg: function(r){ + console.log("New message."); + const fromSelf = sessionStorage.nick == r.f; + + // Notify user + Chat.notif.create(r.f, r.m); + + var li = document.createElement('div'); + li.id = r.id; + + var prefix = document.createElement('span'); + prefix.className = 'prefix'; + prefix.innerText = r.f; + li.appendChild(prefix); + + if(Chat.last_sent_nick === r.f){ + prefix.style.display = "none"; + li.prefix = prefix; + } else { + Chat.last_sent_nick = r.f; + } + + var msg = document.createElement('div'); + msg.className = 'message'; + + var body = document.createElement('span'); + body.className = 'body' + (fromSelf ? ' out' : ' in'); + Chat.append_msg(body, r.m); + + msg.appendChild(body); + + li.appendChild(msg); + + var c = document.createElement('li'); + c.appendChild(li); + if (fromSelf){ + c.classList.add('message-from-self'); + } + + // Prepend because flex-direction: column-reverse + Chat.msgs_list.prepend(c); + + // Scroll to new message + Chat.scroll(); + }, + + append_msg: function(el, msg){ + if(!msg) return; + + // If is object + if(typeof msg.text !== 'undefined'){ + // Escape HTML + el.innerText = msg.text; + var text = el.innerHTML; + + // Parse urls + text = text.replace(/(https?:\/\/[^\s]+)/g, function(url, a, b){ + var link = document.createElement('a'); + link.target = "_blank"; + + // Un-escape + link.innerHTML = url; + url = link.innerText; + link.href = url; + + // If link is image + if(url.match(/.(png|jpe?g|gifv?)([?#].*)?$/g)){ + var img = document.createElement('img'); + img.style = 'max-width:100%;'; + img.src = url; + + link.innerText = ""; + link.appendChild(img); + } + + return link.outerHTML; + }); + + if(typeof Emic !== 'undefined'){ + text = Emic.replace(text); + } + + el.innerHTML = text; + } + + if(typeof msg.type !== 'undefined'){ + // Image + if(msg.type.match(/image.*/)){ + var img = document.createElement('img'); + img.style = 'max-width:100%;'; + img.src = msg.url; + el.appendChild(img); + return; + } + + // Audio / Video + if(m = msg.type.match(/(audio|video).*/)){ + var audio = document.createElement(m[1]); + audio.controls = 'controls'; + + var source = document.createElement("source"); + source.src = msg.url; + source.type = msg.type; + audio.appendChild(source); + + el.appendChild(audio); + return; + } + + // Default + var link = document.createElement('a'); + link.href = msg.url; + link.download = msg.name; + link.innerText = msg.name; + el.appendChild(link); + } + }, + + force_login: function(fail){ + if(typeof fail !== "undefined"){ + alert(fail); + } + + var nick = prompt("Your nick:", sessionStorage.nick || localStorage.nick || ""); + if(typeof nick !== "undefined" && nick){ + sessionStorage.nick = localStorage.nick = nick; + Chat.socket.emit("login", { + nick: nick + }); + } + }, + + reload: function(){ + if(typeof sessionStorage.nick !== "undefined" && sessionStorage.nick){ + Chat.socket.emit("login", { + nick: sessionStorage.nick + }); + } + }, + + user: { + objects: {}, + + // Load all users + start: function(r){ + Chat.users.innerText = ''; + + for(var user in r.users){ + var nick = document.createElement('li'); + nick.innerText = r.users[user]; + Chat.users.appendChild(nick); + Chat.user.objects[r.users[user]] = nick; + } + }, + + previous_messages: function(data){ + console.log(`msgs: ${data}`) + + data.msgs.forEach(element => { + Chat.new_msg(element) + }); + }, + + // User joined room + enter: function(r){ + console.log("User " + r.nick + " joined."); + + var nick = document.createElement('li'); + nick.innerText = r.nick; + Chat.users.appendChild(nick); + Chat.user.objects[r.nick] = nick; + }, + + // User left room + leave: function(r){ + console.log("User " + r.nick + " left."); + + // Is not typing + Chat.typing.remove(r.nick); + + // Remove user + if(Chat.user.objects.hasOwnProperty(r.nick)){ + var element = Chat.user.objects[r.nick]; + element.parentNode.removeChild(element); + delete Chat.user.objects[r.nick]; + } + } + }, + + connect: function(){ + // Set green favicon + Chat.notif.favicon('green'); + Chat.is_online = true; + + document.getElementById('offline').style.display = "none"; + Chat.msgs_list.innerText = ''; + Chat.typing_list.innerText = ''; + Chat.users.innerText = ''; + Chat.last_sent_nick = ''; + + // force user to login + Chat.force_login(); + }, + + disconnect: function(){ + // Set green favicon + Chat.notif.favicon('red'); + Chat.is_online = false; + + document.getElementById('offline').style.display = "block"; + Chat.msgs_list.innerText = ''; + Chat.typing_list.innerText = ''; + Chat.users.innerText = ''; + }, + + init: function(socket){ + // Set green favicon + Chat.notif.favicon('red'); + + // Connect to socket.io + Chat.socket = socket || io(); + + // Create beep object + Chat.notif.beep = Chat.notif.beep_create(); + + // On focus + window.addEventListener('focus', function(){ + Chat.is_focused = true; + + // If chat is not online, dont care. + if(!Chat.is_online){ + return; + } + + // Clear ttout, if there was + typeof Chat.notif.ttout === "undefined" || clearInterval(Chat.notif.ttout); + Chat.notif.ttout = undefined; + + // Clear notifications + Chat.notif.clear(); + Chat.notif.msgs = 0; + Chat.notif.favicon('green'); + + // Set back page title + document.title = Chat.original_title; + }); + + // On blur + window.addEventListener('blur', function(){ + Chat.is_focused = false; + }); + + // On click send message + Chat.send_btn.onclick = Chat.send_event; + + // On enter send message + Chat.textarea.onkeydown = function(e){ + var key = e.keyCode || window.event.keyCode; + + // If the user has pressed enter + if(key === 13){ + Chat.send_event(); + return false; + } + + return true; + }; + + // Check if is user typing + Chat.textarea.onkeyup = Chat.typing.update; + + // On socket events + Chat.socket.on("connect", Chat.connect); + Chat.socket.on("disconnect", Chat.disconnect); + + Chat.socket.on("force-login", Chat.force_login); + Chat.socket.on("typing", Chat.typing.event); + Chat.socket.on("new-msg", Chat.new_msg); + + Chat.socket.on("previous-msg", Chat.user.previous_messages) + Chat.socket.on("start", Chat.user.start); + Chat.socket.on("ue", Chat.user.enter); + Chat.socket.on("ul", Chat.user.leave); + + var dropZone = document.getElementsByTagName("body")[0]; + + // Optional. Show the copy icon when dragging over. Seems to only work for chrome. + dropZone.addEventListener('dragover', function(e){ + e.stopPropagation(); + e.preventDefault(); + + e.dataTransfer.dropEffect = 'copy'; + }); + + // Get file data on drop + dropZone.addEventListener('drop', function(e){ + e.stopPropagation(); + e.preventDefault(); + + var files = e.dataTransfer.files; // Array of all files + for(var i = 0;i < files.length;i++){ + var file = files[i]; + + // Max 10 MB + if(file.size > 10485760){ + alert("Max size of file is 10MB"); + return; + } + + var reader = new FileReader(); + reader.onload = (function(file){ + return function(e){ + Chat.send_msg({ + type: file.type, + name: file.name, + url: e.target.result + }); + }; + })(file); + reader.readAsDataURL(file); + } + }); + + // close socket upon refresh or tab close, free the username + window.addEventListener("beforeunload", () => { + if(!Chat.is_online){ + return; + } + Chat.socket.disconnect(); + }); + } +}; diff --git a/html/static/scripts/emic.js b/html/static/scripts/emic.js new file mode 100755 index 0000000..801e53b --- /dev/null +++ b/html/static/scripts/emic.js @@ -0,0 +1,202 @@ +HTMLTextAreaElement.prototype.insertAtCaret = function(text){ + text = text || ''; + if(document.selection){ + // IE + this.focus(); + var sel = document.selection.createRange(); + sel.text = text; + } else if(this.selectionStart || this.selectionStart === 0){ + // Others + var startPos = this.selectionStart; + var endPos = this.selectionEnd; + this.value = this.value.substring(0, startPos) + + text + + this.value.substring(endPos, this.value.length); + this.selectionStart = startPos + text.length; + this.selectionEnd = startPos + text.length; + } else { + this.value += text; + } +}; + +var Emic = { + container: document.getElementById("emic"), + textarea: document.getElementById("form_input"), + emic_btn: document.getElementById("emic_btn"), + + db: { + "grinning-face": "Grinning Face", + "grinning-face-with-smiling-eyes": "Grinning Face With Smiling Eyes", + "face-with-tears-of-joy": "Face With Tears of Joy", + "rolling-on-the-floor-laughing": "Rolling On The Floor Laughing", + "smiling-face-with-open-mouth": "Smiling Face With Open Mouth", + "smiling-face-with-open-mouth-and-smiling-eyes": "Smiling Face With Open Mouth and Smiling Eyes", + "smiling-face-with-open-mouth-and-cold-sweat": "Smiling Face With Open Mouth and Cold Sweat", + "smiling-face-with-open-mouth-and-tightly-closed-eyes": "Smiling Face With Open Mouth and Tightly-Closed Eyes", + "winking-face": "Winking Face", + "smiling-face-with-smiling-eyes": "Smiling Face With Smiling Eyes", + "face-savouring-delicious-food": "Face Savouring Delicious Food", + "smiling-face-with-sunglasses": "Smiling Face With Sunglasses", + "smiling-face-with-heart-shaped-eyes": "Smiling Face With Heart-Shaped Eyes", + "face-throwing-a-kiss": "Face Throwing a Kiss", + "kissing-face": "Kissing Face", + "kissing-face-with-smiling-eyes": "Kissing Face With Smiling Eyes", + "kissing-face-with-closed-eyes": "Kissing Face With Closed Eyes", + "white-smiling-face": "White Smiling Face", + "slightly-smiling-face": "Slightly Smiling Face", + "hugging-face": "Hugging Face", + "thinking-face": "Thinking Face", + "neutral-face": "Neutral Face", + "expressionless-face": "Expressionless Face", + "face-without-mouth": "Face Without Mouth", + "face-with-rolling-eyes": "Face With Rolling Eyes", + "smirking-face": "Smirking Face", + "persevering-face": "Persevering Face", + "disappointed-but-relieved-face": "Disappointed but Relieved Face", + "face-with-open-mouth": "Face With Open Mouth", + "zipper-mouth-face": "Zipper-Mouth Face", + "hushed-face": "Hushed Face", + "sleepy-face": "Sleepy Face", + "tired-face": "Tired Face", + "sleeping-face": "Sleeping Face", + "relieved-face": "Relieved Face", + "nerd-face": "Nerd Face", + "face-with-stuck-out-tongue": "Face With Stuck-Out Tongue", + "face-with-stuck-out-tongue-and-winking-eye": "Face With Stuck-Out Tongue and Winking Eye", + "face-with-stuck-out-tongue-and-tightly-closed-eyes": "Face With Stuck-Out Tongue and Tightly-Closed Eyes", + "drooling-face": "Drooling Face", + "unamused-face": "Unamused Face", + "face-with-cold-sweat": "Face With Cold Sweat", + "pensive-face": "Pensive Face", + "confused-face": "Confused Face", + "upside-down-face": "Upside-Down Face", + "money-mouth-face": "Money-Mouth Face", + "astonished-face": "Astonished Face", + "white-frowning-face": "White Frowning Face", + "slightly-frowning-face": "Slightly Frowning Face", + "confounded-face": "Confounded Face", + "disappointed-face": "Disappointed Face", + "worried-face": "Worried Face", + "face-with-look-of-triumph": "Face With Look of Triumph", + "crying-face": "Crying Face", + "loudly-crying-face": "Loudly Crying Face", + "frowning-face-with-open-mouth": "Frowning Face With Open Mouth", + "anguished-face": "Anguished Face", + "fearful-face": "Fearful Face", + "weary-face": "Weary Face", + "grimacing-face": "Grimacing Face", + "face-with-open-mouth-and-cold-sweat": "Face With Open Mouth and Cold Sweat", + "face-screaming-in-fear": "Face Screaming in Fear", + "flushed-face": "Flushed Face", + "dizzy-face": "Dizzy Face", + "pouting-face": "Pouting Face", + "angry-face": "Angry Face", + "smiling-face-with-halo": "Smiling Face With Halo", + "face-with-cowboy-hat": "Face With Cowboy Hat", + "clown-face": "Clown Face", + "lying-face": "Lying Face", + "face-with-medical-mask": "Face With Medical Mask", + "face-with-thermometer": "Face With Thermometer", + "face-with-head-bandage": "Face With Head-Bandage", + "nauseated-face": "Nauseated Face", + "sneezing-face": "Sneezing Face", + "smiling-face-with-horns": "Smiling Face With Horns", + "imp": "Imp", + "japanese-ogre": "Japanese Ogre", + "japanese-goblin": "Japanese Goblin", + "skull": "Skull", + "skull-and-crossbones": "Skull and Crossbones", + "ghost": "Ghost", + "extraterrestrial-alien": "Extraterrestrial Alien", + "alien-monster": "Alien Monster", + "robot-face": "Robot Face", + "pile-of-poo": "Pile of Poo", + "smiling-cat-face-with-open-mouth": "Smiling Cat Face With Open Mouth", + "grinning-cat-face-with-smiling-eyes": "Grinning Cat Face With Smiling Eyes", + "cat-face-with-tears-of-joy": "Cat Face With Tears of Joy", + "smiling-cat-face-with-heart-shaped-eyes": "Smiling Cat Face With Heart-Shaped Eyes", + "cat-face-with-wry-smile": "Cat Face With Wry Smile", + "kissing-cat-face-with-closed-eyes": "Kissing Cat Face With Closed Eyes", + "weary-cat-face": "Weary Cat Face", + "crying-cat-face": "Crying Cat Face", + "pouting-cat-face": "Pouting Cat Face", + "see-no-evil-monkey": "See-No-Evil Monkey", + "hear-no-evil-monkey": "Hear-No-Evil Monkey", + "speak-no-evil-monkey": "Speak-No-Evil Monkey", + "heavy-black-heart": "Heavy Black Heart", + "avocado": "Avocado", + "banana": "Banana" + }, + + replace: function(str){ + str = ' ' + str; + + str = str.replace(/\*dog\*/g, ''); + str = str.replace(/\*bender\*/g, ''); + + str = str.replace(/ [O|o]:-?\)+/g, ' *smiling-face-with-halo* '); // O:) + str = str.replace(/ \>:-?\)+/g, ' *smiling-face-with-horns* '); // >:) + str = str.replace(/ \>:-?\(+/g, ' *imp* '); // >:( + str = str.replace(/ :-?D+/g, ' *grinning-face* '); // :D + str = str.replace(/ =-?D+/g, ' *grinning-face-with-smiling-eyes* '); // =D + str = str.replace(/ :-?\)+/g, ' *slightly-smiling-face* '); // :) + str = str.replace(/☻/g, ' *slightly-smiling-face* '); // ☻ + str = str.replace(/ =-?\)+/g, ' *smiling-face-with-open-mouth* '); // =) + str = str.replace(/☺/g, ' *smiling-face-with-open-mouth* '); // ☺ + str = str.replace(/ :-?\(+/g, ' *slightly-frowning-face* '); // :( + str = str.replace(/ :-?\/+/g, ' *confused-face* '); // :/ + str = str.replace(/ :-?[Ppb]+/g, ' *face-with-stuck-out-tongue* '); // :P + str = str.replace(/ ;-?[Ppb]+/g, ' *face-with-stuck-out-tongue-and-winking-eye* '); // ;P + str = str.replace(/ =-?[Ppb]+/g, ' *face-with-stuck-out-tongue-and-tightly-closed-eyes* '); // =P + str = str.replace(/ ;-?\)+/g, ' *winking-face* '); // ;) + str = str.replace(/ :-?\|+/g, ' *neutral-face* '); // :| + str = str.replace(/ :-?O+/g, ' *face-with-open-mouth* '); // :O + str = str.replace(/ :-?o+/g, ' *hushed-face* '); // :o + str = str.replace(/ :-?\>+/g, ' *smiling-face-with-open-mouth-and-tightly-closed-eyes* '); // :> + str = str.replace(/ 8-?\)+/g, ' *smiling-face-with-sunglasses* '); // 8) + str = str.replace(/ :-?\*+/g, ' *kissing-face* '); // :* + str = str.replace(/ ;-?\*+/g, ' *face-throwing-a-kiss* '); // ;* + str = str.replace(/ <3+/g, ' *heavy-black-heart* '); // <3 + str = str.replace(/♥/g, ' *heavy-black-heart* '); // ♥ + str = str.replace(/ \^_\^/g, ' *smiling-face-with-smiling-eyes* '); // ^_^ + str = str.replace(/ -_-/g, ' *expressionless-face* '); // -_- + str = str.replace(/ -\.-/g, ' *pensive-face* '); // -.- + str = str.replace(/ \.[-_]\./g, ' *unamused-face* '); // .-. + str = str.replace(/ :-?c+/g, ' *weary-cat-face* '); // :c + str = str.replace(/ c-?:/g, ' *smiling-cat-face-with-open-mouth* '); // c: + str = str.replace(/ :-?3+/g, ' *grinning-cat-face-with-smiling-eyes* '); // :3 + str = str.replace(/ [Hh]mm[m]+/g, ' *thinking-face* '); // Hmmm + + str = str.replace(/\*([a-z0-9-]+)\*/g, ''); + + return str; + }, + + init: function(){ + for(var slug in Emic.db){ + var obj = document.createElement('li'); + obj.innerHTML = ''; + obj.dataset.slug = slug; + obj.onclick = function(){ + Emic.textarea.insertAtCaret(' *' + this.dataset.slug + '* '); + Emic.textarea.focus(); + }; + + Emic.container.onmousedown = function(e){ + e.preventDefault(); + }; + Emic.container.appendChild(obj); + } + + var toggle = Emic.container.style.display; + Emic.emic_btn.onclick = function(){ + if(toggle == "none"){ + Emic.container.style.display = "inline-block"; + toggle = "block"; + } else { + Emic.container.style.display = "none"; + toggle = "none"; + } + }; + } +}; diff --git a/html/static/styles/dark.css b/html/static/styles/dark.css new file mode 100644 index 0000000..4999dc8 --- /dev/null +++ b/html/static/styles/dark.css @@ -0,0 +1,40 @@ +/* Dark Theme */ +.message { + background: #2f2a2a !important; + color: white; +} + +body, a, +.prefix, .prefix strong, +#users li, #users li strong, +.chat-form .form-control{ + color: white !important; +} + +body, +.chat-form, +.chat-form .form-control { + background: #1f1b1b; + scrollbar-color: rgb(127 63 152) rgb(69, 69, 69); +} + +#send, +.chat-form .form-control, +#emic{ + border-color: #7f3f98; +} + +#emic { + background-color: #1f1b1b; +} + +#emic_btn{ + background:#7f3f98; +} + +.chat { + border: rgb(127 63 152); + border-style: solid; + border-top: none; + border-bottom: none; +} \ No newline at end of file diff --git a/html/static/styles/msgboard.css b/html/static/styles/msgboard.css new file mode 100644 index 0000000..b567b05 --- /dev/null +++ b/html/static/styles/msgboard.css @@ -0,0 +1,23 @@ +.msg-board { + height: 3vh; + background-color: rgb(112, 1, 103); + overflow: hidden; +} + +.msg-board:hover { + transition: all 1s; + height: 30vw; + z-index: 100; +} + +.msg-board:not(:hover) { + transition: all 4s; + height: 3vh; + z-index: 100; +} + +.msg-board h1 { + margin: 0px; + padding: 0px; + text-align: center; +} \ No newline at end of file diff --git a/html/static/styles/style.css b/html/static/styles/style.css new file mode 100644 index 0000000..74799f7 --- /dev/null +++ b/html/static/styles/style.css @@ -0,0 +1,358 @@ +html, +body { + height: 100%; +} + +body { + font-family: Monospace; + background: #fff; + overflow: hidden; + margin: 0; +} + +a { + color: black; + text-decoration: underline; +} + +#offline { + padding: 20px 10px; + font-size: 14px; +} + +#offline .big { + font-size: 32px; + line-height: 32px; +} + +.chat { + padding: 0 10px; + overflow: hidden; + height: 100%; + display: flex; + flex-direction: column; + max-width: 950px; + margin-right: auto; + margin-left: auto; + position: relative; +} + +#msgs { + flex-grow: 1; + overflow-y: auto; + display: flex; + flex-shrink: 0; + flex-direction: column-reverse; +} + +.msgs { + margin: 0; + padding: 0; + padding-bottom: 5px; +} + +.msgs li { + list-style: none; + margin: 0; + overflow: hidden; + margin-bottom: 5px; + display: flex; +} + +.message-from-self { + padding-right: 6px; + justify-content: flex-end; + text-align: right; + display: flex; +} + +#typing li { + display: inline-block; + margin-right: 5px; +} + +.msgs li .body { + display: block; + overflow: hidden; + word-wrap: break-word; +} + +.msgs li .message { + position: relative; + padding: 6px 12px; + border-radius: 1.3em; + text-align: left; + background: #e5e4e4; + display: inline-block; + max-width: 450px; +} + +.msgs li .prefix { + margin-top: 10px; +} + +.msgs li .prefix, +.msgs li .suffix { + padding-left: 12px; + display: block; + color: rgba(0, 0, 0, .40); + font-size: 12px; + clear: both; +} + +@media only screen and (max-width: 600px) { + .msgs li .message { + max-width: 75vw; + } +} + +.msgs li .writing {} + +.msgs li .writing .one, +.msgs li .writing .two, +.msgs li .writing .three { + opacity: .2; + animation: dot 2s infinite; + -webkit-animation: dot 2s infinite; +} + +.msgs li .writing .one { + animation-delay: 0.0s; + -webkit-animation-delay: 0.0s; +} + +.msgs li .writing .two { + animation-delay: 0.5s; + -webkit-animation-delay: 0.5s; +} + +.msgs li .writing .three { + animation-delay: 1s; + -webkit-animation-delay: 1s; + padding-right: 2px; +} + +@-webkit-keyframes dot { + 0% { + opacity: .2; + } + + 25% { + opacity: 1; + } + + 100% { + opacity: .2; + } +} + +@keyframes dot { + 0% { + opacity: .2; + } + + 25% { + opacity: 1; + } + + 100% { + opacity: .2; + } +} + +.msgs li.in .message { + float: left; + margin-left: 20px; +} + +.msgs li.in .message:before, +.msgs li.in .message:after { + right: 100%; + /*top: 50%;*/ + top: 18px; + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; + pointer-events: none; +} + +.msgs li.in .message:after { + border-right-color: #fff; + border-width: 8px; + margin-top: -8px; +} + +.msgs li.in .message:before { + border-right-color: #bbb; + border-width: 9px; + margin-top: -9px; +} + +.msgs li.in .prefix, +.msgs li.in .suffix { + padding-left: 30px; + text-align: left; +} + +.msgs li.out .message { + float: right; + margin-right: 20px; +} + +.msgs li.out .message:before, +.msgs li.out .message:after { + left: 100%; + /*top: 50%;*/ + top: 18px; + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; + pointer-events: none; +} + +.msgs li.out .message:after { + border-left-color: #fff; + border-width: 8px; + margin-top: -8px; +} + +.msgs li.out .message:before { + border-left-color: #bbb; + border-width: 9px; + margin-top: -9px; +} + +.msgs li.out .prefix, +.msgs li.out .suffix { + padding-right: 30px; + text-align: right; +} + +.msgs li.split { + text-align: center; + position: relative; + padding: 20px 0; +} + +.msgs li.split:before { + content: ""; + display: block; + border-top: solid 1px #bbb; + width: 100%; + height: 1px; + position: absolute; + top: 50%; + z-index: 1; +} + +.msgs li.split .text { + display: inline-block; + background: #e5e5e5; + padding: 0 20px; + position: relative; + z-index: 5; + color: #666; +} + +#emic { + position: absolute; + border: 1px solid #bbb; + width: 250px; + height: 210px; + margin: 0; + padding: 0; + font-size: 0; + overflow: auto; + margin-left: auto; + bottom: 88px; + right: 0px; +} + +#emic li { + display: inline-block; + list-style-type: none; + padding: 5px; + cursor: pointer; +} + +#emic li:hover { + box-shadow: 0px 0px 5px 1px white; +} + +.chat-box { + flex-grow: 1; + display: flex; + flex-direction: column; + overflow-y: scroll; + position: relative; +} + +.chat-form { + background: #fff; + padding: 10px; + position: relative; +} + +.chat-form .form-control { + display: inline-block; + width: 100%; + border: 1px solid #bbb; + border-radius: 0; + padding: 10px; + margin: 0; + color: #333; + background-color: #fff; + font-size: 14px; + box-shadow: none; + /*min-height: 100px;*/ + height: 39px; + box-sizing: border-box; +} + +.chat-form .form-control:focus { + outline: 0; + box-shadow: none; +} + +#send { + background: none; + color: white; + text-transform: uppercase; + padding: 5px; + margin: 0 10px 0 0; + border: 1px solid white; + border-radius: 0; +} + +#emic_btn { + float: right; + margin: 0; + position: absolute; + right: 10px; + bottom: 40px; + margin-top: 35px; + z-index: 100; + background: none; + border: none; + padding: 8px; +} + +#users, +#users li { + margin: 0; + padding: 0; + display: inline-block; +} + +#users li:after { + content: "•"; + padding: 0 5px; +} + +#users li:last-child:after { + content: ""; +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..03dd49c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,960 @@ +{ + "name": "chat", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "chat", + "version": "1.0.0", + "license": "GPL-3.0", + "dependencies": { + "dotenv": "^16.4.5", + "express": "^4.21.2", + "socket.io": "^4.8.0" + } + }, + "node_modules/@socket.io/component-emitter": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz", + "integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==" + }, + "node_modules/@types/cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" + }, + "node_modules/@types/cors": { + "version": "2.8.17", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz", + "integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "22.7.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.5.tgz", + "integrity": "sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==", + "dependencies": { + "undici-types": "~6.19.2" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" + }, + "node_modules/base64id": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz", + "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==", + "engines": { + "node": "^4.5.0 || >= 5.9" + } + }, + "node_modules/body-parser": { + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", + "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.13.0", + "raw-body": "2.5.2", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/engine.io": { + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.2.tgz", + "integrity": "sha512-gmNvsYi9C8iErnZdVcJnvCpSKbWTt1E8+JZo8b+daLninywUWi5NQ5STSHZ9rFjFO7imNcvb8Pc5pe/wMR5xEw==", + "dependencies": { + "@types/cookie": "^0.4.1", + "@types/cors": "^2.8.12", + "@types/node": ">=10.0.0", + "accepts": "~1.3.4", + "base64id": "2.0.0", + "cookie": "~0.7.2", + "cors": "~2.8.5", + "debug": "~4.3.1", + "engine.io-parser": "~5.2.1", + "ws": "~8.17.1" + }, + "engines": { + "node": ">=10.2.0" + } + }, + "node_modules/engine.io-parser": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.3.tgz", + "integrity": "sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q==", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/engine.io/node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/engine.io/node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/engine.io/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/engine.io/node_modules/ws": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.3", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.7.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.3.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.12", + "proxy-addr": "~2.0.7", + "qs": "6.13.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.19.0", + "serve-static": "1.16.2", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/finalhandler": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", + "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", + "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", + "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==" + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", + "dependencies": { + "side-channel": "^1.0.6" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/send": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", + "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/serve-static": { + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", + "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.19.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + }, + "node_modules/side-channel": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", + "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", + "dependencies": { + "call-bind": "^1.0.7", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/socket.io": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.8.0.tgz", + "integrity": "sha512-8U6BEgGjQOfGz3HHTYaC/L1GaxDCJ/KM0XTkJly0EhZ5U/du9uNEZy4ZgYzEzIqlx2CMm25CrCqr1ck899eLNA==", + "dependencies": { + "accepts": "~1.3.4", + "base64id": "~2.0.0", + "cors": "~2.8.5", + "debug": "~4.3.2", + "engine.io": "~6.6.0", + "socket.io-adapter": "~2.5.2", + "socket.io-parser": "~4.2.4" + }, + "engines": { + "node": ">=10.2.0" + } + }, + "node_modules/socket.io-adapter": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.2.tgz", + "integrity": "sha512-87C3LO/NOMc+eMcpcxUBebGjkpMDkNBS9tf7KJqcDsmL936EChtVva71Dw2q4tQcuVC+hAUy4an2NO/sYXmwRA==", + "dependencies": { + "ws": "~8.11.0" + } + }, + "node_modules/socket.io-parser": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz", + "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==", + "dependencies": { + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.1" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/socket.io-parser/node_modules/debug": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/socket.io-parser/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/socket.io/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/socket.io/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/ws": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..b1c64b9 --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "chat", + "version": "1.0.0", + "description": "Simple plug & play, zeroconfig chat.", + "main": "server.js", + "scripts": { + "start": "nodejs server.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/m1k1o/chat.git" + }, + "keywords": [ + "chat", + "nodejs", + "javascript" + ], + "author": "m1k1o", + "license": "GPL-3.0", + "bugs": { + "url": "https://github.com/m1k1o/chat/issues" + }, + "homepage": "https://github.com/m1k1o/chat#readme", + "dependencies": { + "dotenv": "^16.4.5", + "express": "^4.21.2", + "socket.io": "^4.8.0" + } +} diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..2f93f61 Binary files /dev/null and b/screenshot.png differ diff --git a/server.js b/server.js new file mode 100755 index 0000000..a04c613 --- /dev/null +++ b/server.js @@ -0,0 +1,126 @@ +require('dotenv').config() +const express = require('express') +const app = express() + +const path = require('path') +const html = path.join(__dirname, '/html'); +app.use(express.static(html)) + +const port = process.argv[2] || 8090; +const http = require("http").Server(app); + +const maxHttpBufferSizeInMb = parseInt(process.env.MAX_HTTP_BUFFER_SIZE_MB || '1'); +const io = require("socket.io")(http, { + maxHttpBufferSize: maxHttpBufferSizeInMb * 1024 * 1024, +}); +let messageCache = []; +// default cache size to zero. override in environment +let cache_size = process.env.CACHE_SIZE ?? 0 + +http.listen(port, function(){ + console.log("Starting server on port %s", port); +}); + +const users = []; +let msg_id = 1; +io.sockets.on("connection", function(socket){ + console.log("New connection!"); + + var nick = null; + + socket.on("login", function(data){ + // Security checks + data.nick = data.nick.trim(); + + // If is empty + if(data.nick == ""){ + socket.emit("force-login", "Nick can't be empty."); + nick = null; + return; + } + + // If is already in + if(users.indexOf(data.nick) != -1){ + socket.emit("force-login", "This nick is already in chat."); + nick = null; + return; + } + + // Save nick + nick = data.nick; + users.push(data.nick); + + console.log("User %s joined.", nick.replace(/(<([^>]+)>)/ig, "")); + socket.join("main"); + + // Tell everyone, that user joined + io.to("main").emit("ue", { + "nick": nick + }); + + // Tell this user who is already in + socket.emit("start", { + "users": users + }); + + // Send the message cache to the new user + console.log(`going to send cache to ${nick}`) + socket.emit("previous-msg", { + "msgs": messageCache + }); + }); + + socket.on("send-msg", function(data){ + // If is logged in + if(nick == null){ + socket.emit("force-login", "You need to be logged in to send message."); + return; + } + + const msg = { + "f": nick, + "m": data.m, + "id": "msg_" + (msg_id++) + } + + messageCache.push(msg); + if(messageCache.length > cache_size){ + messageCache.shift(); // Remove the oldest message + } + + // Send everyone message + io.to("main").emit("new-msg", msg); + + console.log("User %s sent message.", nick.replace(/(<([^>]+)>)/ig, "")); + }); + + socket.on("typing", function(typing){ + // Only logged in users + if(nick != null){ + socket.broadcast.to("main").emit("typing", { + status: typing, + nick: nick + }); + + console.log("%s %s typing.", nick.replace(/(<([^>]+)>)/ig, ""), typing ? "is" : "is not"); + } + }); + + socket.on("disconnect", function(){ + console.log("Got disconnect!"); + + if(nick != null){ + // Remove user from users + users.splice(users.indexOf(nick), 1); + + // Tell everyone user left + io.to("main").emit("ul", { + "nick": nick + }); + + console.log("User %s left.", nick.replace(/(<([^>]+)>)/ig, "")); + socket.leave("main"); + nick = null; + } + }); +});