рабочие приглосы
This commit is contained in:
parent
72343712c4
commit
63c4bc61c3
5 changed files with 218 additions and 17 deletions
9
.env
9
.env
|
@ -1,5 +1,12 @@
|
|||
# at the end without /
|
||||
PUBLIC_URL="https://docs.black-phoenix.ru"
|
||||
PUBLIC_URL="https://chat.black-phoenix.ru/api"
|
||||
|
||||
# api https://chat.black-phoenix.ru/api
|
||||
# main https://docs.black-phoenix.ru
|
||||
|
||||
|
||||
#websocket
|
||||
PUBLIC_WSS="wss://docs.black-phoenix.ru"
|
||||
|
||||
# api wss://docs.black-phoenix.ru/api"
|
||||
# main wss://docs.black-phoenix.ru"
|
|
@ -1,5 +1,46 @@
|
|||
import { PUBLIC_URL } from '$env/static/public';
|
||||
|
||||
export async function GetInviteLink(chatId) {
|
||||
let token = localStorage.getItem("BPChat")
|
||||
const response = await fetch(`${PUBLIC_URL}/api/chat/create_invitation_link?chat_id=${chatId}`,
|
||||
{
|
||||
method:"GET",
|
||||
credentials:"include",
|
||||
headers:{
|
||||
'accept': 'application/json',
|
||||
'Authorization': token,
|
||||
}})
|
||||
|
||||
if(response.ok){
|
||||
let data = await response.json()
|
||||
return data.invitation_link
|
||||
} else {
|
||||
console.log(response.status)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export async function addingToChat(code){
|
||||
|
||||
let token = localStorage.getItem("BPChat")
|
||||
const response = await fetch(`${PUBLIC_URL}/api/chat/invite_to_chat/${code}`,
|
||||
{
|
||||
method:"GET",
|
||||
credentials:"include",
|
||||
headers:{
|
||||
'accept': 'application/json',
|
||||
'Authorization': token,
|
||||
}
|
||||
})
|
||||
|
||||
if(response.ok){
|
||||
window.location.href = '/c'
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export async function getLastMessages(chatId,msgLoaded){
|
||||
|
||||
let token = localStorage.getItem('BPChat')
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
<script>
|
||||
import { getLastMessages, MessagePicToUrl, getAllChats, getPinnedMsg, getMessageById, uploadImages, getAllUsers, createNewChat, deleteChat } from '$lib/chat';
|
||||
import { dictionary } from './../../../.svelte-kit/generated/client-optimized/app.js';
|
||||
import { getLastMessages, MessagePicToUrl, getAllChats, getPinnedMsg, getMessageById, uploadImages, getAllUsers, createNewChat, deleteChat, GetInviteLink } from '$lib/chat';
|
||||
import { UserCheck } from '$lib/userFunction'
|
||||
|
||||
import Header from '../Header.svelte';
|
||||
import createWebSocket from '$lib/websocket';
|
||||
|
||||
import { onMount, tick } from 'svelte';
|
||||
import { fade, slide, fly, scale } from 'svelte/transition';
|
||||
import { fade, slide, fly, scale, blur } from 'svelte/transition';
|
||||
|
||||
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
|
||||
import ruLocale from 'date-fns/locale/ru';
|
||||
|
@ -46,8 +47,13 @@
|
|||
|
||||
let inputArea //объект textarea
|
||||
|
||||
let IsAddPersonHovered = false
|
||||
let copiedInvitedLinkObj = ''
|
||||
|
||||
onMount(async () => {
|
||||
|
||||
copiedInvitedLinkObj = document.getElementById('copiedInvitedLink')
|
||||
|
||||
token = localStorage.getItem('BPChat')
|
||||
|
||||
const userData = await UserCheck();
|
||||
|
@ -76,7 +82,7 @@
|
|||
//if(currentChat == undefined){
|
||||
// window.location.href = '/c'
|
||||
//}
|
||||
//console.log(currentChat, " текущий чат")
|
||||
console.log(currentChat, " текущий чат")
|
||||
pickedChatName = currentChat.chat_name
|
||||
pickedChatImg = currentChat.avatar_image
|
||||
|
||||
|
@ -428,6 +434,21 @@ let pinOrNot = false
|
|||
//console.log(result)
|
||||
//chats = await getAllChats(token)
|
||||
}
|
||||
|
||||
async function addPersonFunc(){
|
||||
let inviteLink = await GetInviteLink(chatId)
|
||||
navigator.clipboard.writeText(inviteLink)
|
||||
console.log(inviteLink)
|
||||
|
||||
copiedInvitedLinkObj.style.top = '-20%'
|
||||
|
||||
setTimeout(() => {
|
||||
copiedInvitedLinkObj.style.top = '60%'
|
||||
console.log("kljh")
|
||||
}, 1500)
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window on:click={hideHelperDiv} />
|
||||
|
@ -505,6 +526,32 @@ let pinOrNot = false
|
|||
</div>
|
||||
<div>
|
||||
<div class="jopa">
|
||||
<div class="ShowedChatMainDiv">
|
||||
|
||||
<div class="ShowedChatNameDiv">
|
||||
<h2 class="ShowedChatName">{pickedChatName} </h2>
|
||||
</div>
|
||||
|
||||
<div class="ShowedChatPicDiv">
|
||||
<img src="{pickedChatImg}" alt="{pickedChatImg}" class="ShowedChatPic">
|
||||
</div>
|
||||
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div class="ShowedChatAddPersonDiv" style="top: {IsAddPersonHovered ? "30%" : "65%" }">
|
||||
<button on:click={addPersonFunc} class="ShowedChatAddPersonButton"
|
||||
on:mouseover= {() => IsAddPersonHovered = true}
|
||||
on:mouseout= {() => IsAddPersonHovered = false}></button>
|
||||
<img src="https://images.black-phoenix.ru/static/images/images/932efb47-8d76-500e-b0a1-55f2ff649810_image.png"
|
||||
alt="{pickedChatImg}" class="ShowedChatAddPerson">
|
||||
|
||||
</div>
|
||||
<img src="https://images.black-phoenix.ru/static/images/images/8e58c161-2cb0-5c32-9614-0369a665d02b_image.png" alt="скопировано"
|
||||
class="copiedInvitedLink" id="copiedInvitedLink">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="gradient">
|
||||
|
||||
|
@ -515,9 +562,11 @@ let pinOrNot = false
|
|||
{/if}
|
||||
|
||||
<div class="chatDiv">
|
||||
|
||||
<img class="backgroundYtka" src="image/BPytka.png" alt="">
|
||||
|
||||
|
||||
|
||||
|
||||
{#if helperDivBoolShow == true}
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<div bind:this={helperDiv} id="helperDiv" class="helperDiv" on:contextmenu={(event) => event.preventDefault()}
|
||||
|
@ -665,18 +714,107 @@ let pinOrNot = false
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div><h1> </h1></div>
|
||||
<div><h1> </h1></div>
|
||||
<di class="PS">
|
||||
<div class="PS">
|
||||
<h2>Made by:</h2>
|
||||
<h3>Uniknow and urec56</h3>
|
||||
</di>
|
||||
<h3>uniknow and Urec56</h3>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
.copiedInvitedLink{
|
||||
height: 30px;
|
||||
width: auto;
|
||||
|
||||
position: absolute;
|
||||
right: 13.727%;
|
||||
top: 100%;
|
||||
|
||||
transition: top 0.322s ease-in-out;
|
||||
|
||||
z-index: -2;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.ShowedChatMainDiv{
|
||||
position: absolute;
|
||||
//background-color: lightblue;
|
||||
height: 60px;
|
||||
width: 100%;
|
||||
margin-top:-60px;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
z-index: 2;
|
||||
|
||||
}
|
||||
|
||||
.ShowedChatPic{
|
||||
border-radius: 8px;
|
||||
width: 50px;
|
||||
|
||||
}
|
||||
|
||||
|
||||
.ShowedChatNameDiv,
|
||||
.ShowedChatPicDiv,
|
||||
.ShowedChatAddPersonDiv{
|
||||
|
||||
border: 1px solid transparent;
|
||||
background:
|
||||
linear-gradient(#101010, #101010) padding-box,
|
||||
var(--gradient) border-box;
|
||||
border-radius: 10px;
|
||||
|
||||
position: absolute;
|
||||
|
||||
padding: 5px 5px 30px 5px;
|
||||
|
||||
transition: 0.3s ease-out;
|
||||
}
|
||||
|
||||
.ShowedChatNameDiv{
|
||||
left: 20%;
|
||||
}
|
||||
|
||||
.ShowedChatPicDiv{
|
||||
right: 20%;
|
||||
}
|
||||
|
||||
.ShowedChatAddPersonDiv{
|
||||
right: 13%;
|
||||
top: 35%;
|
||||
:hover{
|
||||
top: 5%;
|
||||
}
|
||||
}
|
||||
|
||||
.ShowedChatAddPersonButton{
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.ShowedChatAddPerson{
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
background-image: url(https://images.black-phoenix.ru/static/images/images/932efb47-8d76-500e-b0a1-55f2ff649810_image.png);
|
||||
background-repeat: none;
|
||||
background-size: 30px;
|
||||
pointer-events: none;
|
||||
|
||||
}
|
||||
|
||||
.ShowedChatName{
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.warningMessage{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
@ -1234,6 +1372,7 @@ let pinOrNot = false
|
|||
overflow: auto;
|
||||
scroll-behavior: smooth;
|
||||
padding: 0 5px;
|
||||
|
||||
}
|
||||
|
||||
.inputDiv{
|
||||
|
@ -1273,14 +1412,15 @@ let pinOrNot = false
|
|||
|
||||
z-index: 2;
|
||||
margin: 0 10px 5px 10px;
|
||||
|
||||
}
|
||||
.headerDiv{
|
||||
grid-column: span 3;
|
||||
z-index: 3;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.gradient{
|
||||
z-index: 1;
|
||||
z-index: 2;
|
||||
border: 1px solid transparent;
|
||||
background:
|
||||
linear-gradient(#101010, #101010) padding-box,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import { checkExsistingUser } from '$lib/register'
|
||||
import { UserCheck } from '$lib/userFunction';
|
||||
import { uploadImages } from '$lib/chat';
|
||||
import Header from './../Header.svelte';
|
||||
import Header from '../Header.svelte';
|
||||
|
||||
import Cropper from 'cropperjs';
|
||||
import 'cropperjs/dist/cropper.css';
|
||||
|
@ -281,21 +281,21 @@
|
|||
<div class="textDiv">
|
||||
<div class="blockDiv">
|
||||
<h3>ник</h3>
|
||||
<input bind:value={newName} type="name" placeholder={oldName} on:input={existingUser}>
|
||||
<input bind:value={newName} type="name" placeholder={oldName} on:input={existingUser} autocomplete="off">
|
||||
{#if nameError != ""}
|
||||
<h2 class="error">{nameError}</h2>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="blockDiv">
|
||||
<h3>почта</h3>
|
||||
<input bind:value={newEmail} type="email" placeholder={oldEmail} on:input={existingUser}>
|
||||
<input bind:value={newEmail} type="name" placeholder={oldEmail} on:input={existingUser} autocomplete="off">
|
||||
{#if emailError != ""}
|
||||
<h2 class="error">{emailError}</h2>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="blockDiv">
|
||||
<h2>новый пароль</h2>
|
||||
<input on:blur={existingUser} bind:value={newPassword} type="password" placeholder="новый пароль">
|
||||
<input on:blur={existingUser} bind:value={newPassword} type="password" placeholder="новый пароль" autocomplete="new-password">
|
||||
{#if passwordError != ""}
|
||||
<h2 class="error">Пароль от 8 символов</h2>
|
||||
{/if}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import { cubicOut } from 'svelte/easing';
|
||||
import { onMount } from "svelte";
|
||||
import { VerificationEmail } from '$lib/register';
|
||||
import { addingToChat } from '$lib/chat';
|
||||
|
||||
let token
|
||||
let codeExist
|
||||
|
@ -14,9 +15,21 @@
|
|||
codeExist = window.location.hash.startsWith('#code=')
|
||||
|
||||
if(codeExist == true){
|
||||
|
||||
code = window.location.hash.slice(6);
|
||||
if((code[code.length - 1] == "=") && (code[code.length - 2] == "=")){
|
||||
//adding chat
|
||||
let response = addingToChat(code)
|
||||
if(response == false){
|
||||
verifAnswer = false
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
verifAnswer = await VerificationEmail(code,token)
|
||||
if(verifAnswer == false){
|
||||
}
|
||||
console.log(code)
|
||||
if(verifAnswer = false){
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue