Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- var last_msg = 0;
- var needsDelay = false;
- function update() {
- $.post("shout_box/action.php?chat=1", {
- last: last_msg
- },
- function(data) {
- if(data.msg_result == "pruned")
- window.location.reload();
- last_msg = data.last_msg;
- if(last_msg == 1)
- $( "div#post-result" ).empty();
- $("div#post-result").append(data.msg_value);
- $("#chat-1").animate({ scrollTop: $('#chat-1').prop("scrollHeight")}, 1000);
- },"json"
- );
- setTimeout('update()', 5000);
- }
- function enableMe()
- {
- $("#button-send").removeClass("disabled");
- }
- $(document).keypress(function(e) {
- if(e.which == 13) {
- if(!needsDelay)
- {
- needsDelay = true;
- setTimeout("needsDelay = false", 4000);
- $.post("shout_box/action.php?chat=1", {
- chat: $("#message").val(),
- last: last_msg
- },
- function(data) {
- if(data.msg_result == "pruned")
- window.location.reload();
- $("div#post-result").append(data.msg_value);
- last_msg = data.last_msg;
- $("#chat-1").animate({ scrollTop: $('#chat-1').prop("scrollHeight")}, 1000);
- $("#message").val("");
- },"json"
- );
- $("#button-send").addClass("disabled");
- setTimeout('enableMe()', 4000);
- }
- }
- });
- $(document).ready(
- function() {
- update();
- $("#button-send").click(
- function() {
- $.post("shout_box/action.php?chat=1", {
- chat: $("#message").val(),
- last: last_msg
- },
- function(data) {
- if(data.msg_result == "pruned")
- window.location.reload();
- $("div#post-result").append(data.msg_value);
- last_msg = data.last_msg;
- $("#chat-1").animate({ scrollTop: $('#chat-1').prop("scrollHeight")}, 1000);
- $("#message").val("");
- },"json"
- );
- $("#button-send").addClass("disabled");
- setTimeout('enableMe()', 4000);
- }
- );
- });
- $(document).ready(function() {
- App.init();
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement