因此,我正在尝试将 slimscroll 添加到我的表中以用于我的实时聊天框,但是我什么也没做。我为您提供的来源不包括我添加它的任何尝试,因为我只是指出我的失败没有意义。
聊天框.php
<?php include_once("@header/header.php"); ?>
<div class="wraper container-fluid">
<div class="page-title"> </div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h2>Shoutbox <small>Support is not provided here; open a ticket. <strong>NO ADVERTISING, NO SPAMMING</strong></small></h2>
<?php
$viewUsers = $odb->prepare("SELECT `rank` FROM `users` WHERE `username` = :username");
$viewUsers->execute(array(':username' => $_SESSION['username']));
$rank = $viewUsers->fetch(PDO::FETCH_ASSOC);
if($rank['rank'] == 1) {
?>
<div class="panel-actions">
<button type="button" id="clear" onclick="clearchat()" class="btn btn-danger btn-sm">Clear</button>
</div>
<?php
}
?>
</div>
<div id="logs" style="overflow: hidden; width: auto; height: 450px;">
<table id="chatlogs" class="table table-hover">
<tr>
</tr>
</tbody>
</table>
</div>
<div class="panel-footer">
<div class="input-group">
<input type="text" id="message" class="form-control" placeholder="Message here..">
<span class="input-group-btn"><button type="button" id="send" onclick="send()" class="btn btn-primary">Send</button></span>
<input type="hidden" id="username" value="<?php echo $_SESSION['username']; ?>">
</div>
</div>
</div>
</div>
</div>
<?php include_once("@header/footer.php"); ?>
<script>
function clearchat() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("message").innerHTML = xhttp.responseText;
}
};
xhttp.open("POST", "@ajax/clearchat.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send();
}
</script>
<script>
function send() {
var message=$('#message').val();
var username=$('#username').val();
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("message").innerHTML = xhttp.responseText;
}
};
xhttp.open("POST", "@ajax/sendmessage.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("message=" + message + "&username=" + username);
$('#message').val('');
}
</script>
<script language="JavaScript">
$('#chatlogs').load("@ajax/shoutbox.php").fadeIn("slow");
setInterval("updateContent();", 1000 );
function updateContent()
{
$('#chatlogs').load("@ajax/shoutbox.php").fadeIn("slow");
}
</script>
<script>
$(document).ready(function(){
$('#message').keypress(function(e){
if(e.keyCode==13)
$('#send').click();
});
});
</script>