File size: 5,149 Bytes
761f772 7d4c191 bde7c2f 7d4c191 8ff79ad 7d4c191 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Movado ChatBot</title>
<link rel="stylesheet" href="css/normalize.min.css">
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Open+Sans'>
<link rel='stylesheet' href='css/jquery.mCustomScrollbar.min.css'>
<link rel="stylesheet" href="css/style.css">
<script>
window.console = window.console || function (t) { };
</script>
</head>
<body translate="no">
<!-- <img src="bosch-logo-supergraphic.png" class="logo-upright"> -->
<div class="chat">
<div class="chat-title">
<h1>Movado</h1>
<h2>Where Art Meets Time</h2>
<figure class="avatar">
<img src="bot.png" />
</figure>
</div>
<div class="timendate">
<h2 class="timetext">Today ( <span id="today"></span> )</h2>
</div>
<div class="messages">
<div class="messages-content"></div>
</div>
<div class="message-box">
<textarea type="text" class="message-input" placeholder="Type message..."></textarea>
<button type="submit" class="message-submit">Send</button>
</div>
</div>
<div class="bg"></div>
<script src="js/commmenm.js"></script>
<script src='js/jquery.min.js'></script>
<script src='js/jquery.mCustomScrollbar.concat.min.js'></script>
<script id="rendered-js">
var $messages = $('.messages-content'),
d, h, m,
i = 0;
$(window).load(function () {
$messages.mCustomScrollbar();
setTimeout(function () {
fakeMessage();
}, 100);
});
function updateScrollbar() {
$messages.mCustomScrollbar("update").mCustomScrollbar('scrollTo', 'bottom', {
scrollInertia: 10,
timeout: 0
});
}
function setDate() {
d = new Date();
if (m != d.getMinutes()) {
m = d.getMinutes();
$('<div class="timestamp">' + d.getHours() + ':' + m + '</div>').appendTo($('.message:last'));
}
}
function insertMessage() {
msg = $('.message-input').val();
if ($.trim(msg) == '') {
return false;
}
$('<div class="message message-personal"><figure class="avatar user"><img src="user.png" /></figure>' + msg + '</div>').appendTo($('.mCSB_container')).addClass('new');
setDate();
$('.message-input').val(null);
updateScrollbar();
setTimeout(function () {
fakeMessage();
}, 1000 + Math.random() * 20 * 100);
}
$('.message-submit').click(function () {
// Make a GET request to the chatbot API
console.log('clicked');
getResponse();
});
$(window).on('keydown', function (e) {
if (e.which == 13) {
getResponse();
return false;
}
});
var Fake = ['I am Bob'];
function fakeMessage() {
if ($('.message-input').val() != '') {
return false;
}
$('<div class="message loading new"><figure class="avatar"><img src="bot.png" /></figure><span></span></div>').appendTo($('.mCSB_container'));
updateScrollbar();
setTimeout(function () {
$('.message.loading').remove();
$('<div class="message new"><figure class="avatar"><img src="bot.png" /></figure>' + Fake[i] + '</div>').appendTo($('.mCSB_container')).addClass('new');
setDate();
updateScrollbar();
i++;
}, 1000 + Math.random() * 20 * 100);
}
async function getResponse() {
// Get user input from the text input field
// const input = document.getElementById('input').value;//
const input = $('.message-input').val();
$('<div class="message message-personal"><figure class="avatar user"><img src="user.png" /></figure>' + input + '</div>').appendTo($('.mCSB_container')).addClass('new');
setDate();
$('.message-input').val(null);
updateScrollbar();
$('<div class="message loading new"><figure class="avatar"><img src="bot.png" /></figure><span></span></div>').appendTo($('.mCSB_container'));
// Make a POST request to the chatbot API
const response = await fetch("https://sds-bosch-watch-api.hf.space/--replicas/0dobj/api/predict", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
data: [input],
})
});
// Extract the chatbot response from the JSON data
const data = await response.json();
const responseText = data.data[0];
// Update the output textarea with the chatbot response
$('.message.loading').remove();
$('<div class="message new"><figure class="avatar"><img src="bot.png" /></figure>' + responseText + '</div>').appendTo($('.mCSB_container')).addClass('new');
setDate();
updateScrollbar();
// document.getElementById('output').value = responseText;
}
//# sourceURL=pen.js
var datetime = new Date();
month = '' + (datetime.getMonth() + 1),
day = '' + datetime.getDate(),
year = datetime.getFullYear();
day = month + '-' + day + '-' + year;
console.log(day);
document.getElementById("today").textContent = day;
</script>
</body>
</html> |