-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f438ad6
Showing
8 changed files
with
478 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/config.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
DowlSlide(); | ||
function DowlSlide(){ | ||
var messagesDiv = document.querySelector('.messages'); | ||
messagesDiv.scrollTop = messagesDiv.scrollHeight; | ||
} | ||
|
||
// Najděte textovou oblast pomocí její třídy nebo ID | ||
var textarea = document.querySelector('.message'); | ||
|
||
// Přidejte posluchače událostí 'focus', který se spustí, když uživatel klikne na textovou oblast | ||
textarea.addEventListener('focus', function() { | ||
// Změňte šířku a výšku textové oblasti | ||
textarea.style.width = '180px'; | ||
textarea.style.height = '45px'; | ||
document.querySelector('.checkbox').style.display = "none"; | ||
document.querySelector('.send').style.display = "none"; | ||
}); | ||
|
||
textarea.addEventListener('blur', function() { | ||
textarea.style.width = 'auto'; | ||
textarea.style.height = '20px'; | ||
document.querySelector('.checkbox').style.display = "inline-block"; | ||
document.querySelector('.send').style.display = "inline-block"; | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.chat{ | ||
border: 1px black solid; | ||
width: 200px; | ||
height: 400px; | ||
border-radius: 10px; | ||
position: fixed; | ||
right: 20px; | ||
bottom: 20px; | ||
} | ||
.messages{ | ||
margin: 5px; | ||
width: 190px; | ||
height: 330px; | ||
overflow-y: scroll; | ||
} | ||
.chat form{ | ||
height: 70px; | ||
} | ||
.checkbox{ | ||
position: relative; | ||
bottom: 3px; | ||
} | ||
.send{ | ||
position: relative; | ||
bottom: 5px; | ||
} | ||
.user{ | ||
text-align: right; | ||
} | ||
.messages::-webkit-scrollbar{ | ||
display: none; | ||
} | ||
.message{ | ||
margin: 5px; | ||
margin-right: 0px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
include_once("openAiObject.php"); | ||
|
||
?> | ||
<?php | ||
/* | ||
session_start(); | ||
//pod jmenem chatbota | ||
$chatBotID ="asst_qwNsFaZ9AQVNHOKNqC8wRDoz"; | ||
if ($_SERVER['REQUEST_METHOD'] === 'POST') { | ||
if (!isset($_SESSION['array'])) { | ||
$_SESSION['array'] = []; | ||
} | ||
else{ | ||
$array = $_SESSION["array"]; | ||
} | ||
if (isset($array)) { | ||
$array = $test->continue($array,$chatBotID); | ||
}else{ | ||
$array = $test->continue(array(),$chatBotID); | ||
$_SESSION["array"] = $array; | ||
} | ||
} | ||
*/ | ||
?> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="css.css"> | ||
<title>Jednoduchý chat</title> | ||
</head> | ||
|
||
<body> | ||
<div class="chat"> | ||
<div class="messages"> | ||
<?php | ||
if (isset($_POST['message'])) { | ||
if (strlen($_POST['message'])>1) { | ||
$sendMessage = $_POST["message"]; | ||
//$test->AddInstruction($sendMessage,isset($_POST["table"])); | ||
|
||
//$test->NewMessage($sendMessage); | ||
//$a= $test->CheckReply(); | ||
//var_dump($a[0]->content[0]->text); | ||
//var_dump($a); | ||
$a=array( | ||
new Message("zprava jedna","user"), | ||
new Message("zprava dva","assistent"), | ||
new Message("zprava tři","user"), | ||
new Message("zprava čtiři","assistent"), | ||
new Message("zprava pět","user"), | ||
new Message("zprava sest","assistent"), | ||
new Message("zprava sedm","user"), | ||
new Message("zprava osm","assistent"), | ||
new Message("zprava devet","user"), | ||
new Message("zprava deset","assistent") | ||
); | ||
foreach (array_reverse($a) as $key => $value) { | ||
$role = $value->role; | ||
//$message =$value->content[0]->text->value; | ||
//$message = $test->ReplaceInResponse($message,$role); | ||
// $message=preg_replace('/\[(https:\/\/.*?)]\((https:\/\/.*?)\)/i', '<a href="\1">\2</a>', $message); | ||
|
||
$message =$value->message; | ||
echo("<p class=\"$role\"><strong> $role<br></strong> $message</p>"); | ||
} | ||
|
||
} | ||
} | ||
?> | ||
</div> | ||
<form method="post"> | ||
|
||
|
||
<textarea class="message" name="message" cols="23" rows="1"></textarea> | ||
<input type="checkbox" name="table" class="checkbox" title="do tabulky"> | ||
<input type="submit" class="send" value="Odeslat"> | ||
</form> | ||
|
||
|
||
</div> | ||
|
||
<script src="chat.js"></script> | ||
<script> | ||
/* var userId = 'x'; // Nahraďte 'x' ID uživatele, kterého chcete sledovat | ||
|
||
setInterval(function() { | ||
$.ajax({ | ||
url: 'get_messages.php', | ||
data: { 'user_id': userId }, // Přidejte ID uživatele jako parametr požadavku | ||
success: function(data) { | ||
$('.messages').html(data); | ||
|
||
var messagesDiv = document.querySelector('.messages'); | ||
messagesDiv.scrollTop = messagesDiv.scrollHeight; | ||
} | ||
}); | ||
}, 1000); | ||
*/ | ||
</script> | ||
</body> | ||
</html> | ||
|
Oops, something went wrong.