Nw czy to dobre miejsce do zadania tego pytania
Chciałbym dodać do shoutboxa opartego na daddy-shoutbox dodać dzwięk po nadejściu nowej widomości lub przynajmniej po odświeżeniu pola z wiadomościami ale nie mam pojęcia jak js dopiero się uczę
bazuje na kilku plikach
index
<!DOCTYPE html>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-2">
body {
background: url('http://tag.16mb.com/bg.jpg') repeat fixed;
font-size: 18px;
font-family: Arial,Helvetica,sans-serif;
}
#daddy-shoutbox {
padding: 5px;
background: url('http://tag.16mb.com/bgs.jpg') repeat fixed;
color: white;
width: 500px;
font-family: Arial,Helvetica,sans-serif;
font-size: 11px;
}
#tab {
font-size: 14px;
}
.shoutbox-list {
border-bottom: 1px solid #083030;
padding: 5px;
display: none;
}
#daddy-shoutbox-list {
text-align: left;
margin: 0px auto;
}
#daddy-shoutbox-form {
text-align: left;
}
.shoutbox-list-time {
color: #8DA2B4;
}
.shoutbox-list-nick {
margin-left: 15px;
font-weight: bold;
}
.shoutbox-list-message {
margin-left: 15px;
}
<script type="text/javascript" src="Czat_pliki/jquery.js"></script> <script type="text/javascript" src="Czat_pliki/jquery_002.js"></script> <body alink="white" link="white" vlink="white"> <table align="center" border="0" cellspacing="1" height="25" width="512"> <td align="center" background="Czat_pliki/bgs.jpg"> <a href="http://tag.16mb.com/" style="text-decoration: none;">ZWZST
</a> <td align="center" background="Czat_pliki/bgs.jpg"> <a href="http://tag.16mb.com/2/" style="text-decoration: none;">Kanał 2
</a> <td align="center" background="Czat_pliki/bgs.jpg"> <a href="http://tag.16mb.com/3/" style="text-decoration: none;">Kanał 3
</a> <td align="center" background="Czat_pliki/bgs.jpg"> <a href="http://tag.16mb.com/4/" style="text-decoration: none;">Kanał 4
</a> <div id="daddy-shoutbox"> <div id="daddy-shoutbox-list"></div> <center><form id="daddy-shoutbox-form" action="daddy-shoutbox.php?action=add" method="post"> Tekst:
<input name="message" style="white-space:pre-wrap; margin-left: 20px; width:400px"> Nick:
<input name="nickname" style="margin-left: 25px;" type="text"> <input value="Wyslij" type="submit"> <span id="daddy-shoutbox-response"></span> <div id="clear-button" style="text-align: right;">
<script type="text/javascript"> var count = 0;
var files = '';
var lastTime = 0;
function prepare(response) {
var d = new Date();
count++;
d.setTime(response.time*1000);
var mytime = d.getHours()+':'+d.getMinutes()+':'+d.getSeconds();
var string = '
<div class="shoutbox-list" id="list-'+count+'">'
+ '
<span class="shoutbox-list-time">'+mytime+'
</span>'
+ '
<span class="shoutbox-list-nick">'+response.nickname+':
</span>'
+ '
<span class="shoutbox-list-message">'+response.message+'
</span>'
return string;
}
function success(response, status) {
if(status == 'success') {
lastTime = response.time;
$('#daddy-shoutbox-response').html('
<img src="'+files+'images/accept.png" />');
$('#daddy-shoutbox-list').append(prepare(response));
$('input[@name=message]').attr('value', '').focus();
$('#list-'+count).fadeIn('slow');
timeoutID = setTimeout(refresh, 3000);
}
}
function validate(formData, jqForm, options) {
for (var i=0; i < formData.length; i++) {
if (!formData[i].value) {
alert('UzupeĹnij wszystkie pola!');
$('input[@name='+formData[i].name+']').css('background', 'red');
return false;
}
}
$('#daddy-shoutbox-response').html('<img src="http://tag.16mb.com/loader.gif" />');
clearTimeout(timeoutID);
}
function refresh() {
$.getJSON(files+"daddy-shoutbox.php?action=view&time="+lastTime, function(json) {
if(json.length) {
for(i=0; i < json.length; i++) {
$('#daddy-shoutbox-list').append(prepare(json[i]));
$('#list-' + count).fadeIn('slow');
}
var j = i-1;
lastTime = json[j].time;
}
//alert(lastTime);
});
timeoutID = setTimeout(refresh, 3000);
}
// wait for the DOM to be loaded
$(document).ready(function() {
var options = {
dataType: 'json',
beforeSubmit: validate,
success: success
};
$('#daddy-shoutbox-form').ajaxForm(options);
timeoutID = setTimeout(refresh, 100);
});
<center><a style="text-decoration: none; color: black;"><font color="#083030" size="10">IP:
<script language="JavaScript" type="text/javascript" src="Czat_pliki/adres_ip.htm"></script>91.206.211.201
</font></a></center>
link do czatu
Czatlink do plików użytych w Shutbox
pliki
Ten post edytował maciek9669 4.02.2015, 11:09:49