Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- count = 0;
- function ajax_get(id) {
- $.ajax({
- type: "POST",
- url: "php/bungeelog.php",
- data: id + "=",
- success: function(data) {
- var replaced = data.replace(/\\n/g, '<br />').replace(/['"]+/g, '').replace(/§r|§e|§a|\\u001b/g, '').replace(/\\\/help\\/g, "\/help");
- return replaced;
- }
- });
- }
- function get_content(box, checkbox, ajax_get) {
- count++;
- //Make ajax call. and on return(complete); run it like this:
- ajax_return(box, checkbox, ajax_get);
- }
- function add_to_box(id) {
- if (typeof id == "undefined") {
- return;
- }
- var box = $('#' + id);
- var checkbox = $('#autoscroll' + id);
- var ajax_get = ajax_get(id);
- if (box.length < 1) {
- console.log('No box found');
- return //we did not find a valid box.
- }
- //Here we do all our checks and get our content.
- content = get_content(box, checkbox, ajax_get);
- }
- function ajax_return(box, checkbox, content) {
- if (content == "") return;
- current_content = box.html();
- if (current_content.indexOf(content) > 0) return; //Don't do anything if the content has changed.
- box.append(content);
- if (checkbox.length < 1) return;
- //Now, we check that our checkbox is checked, if it is, we auto scroll to the bottom
- if (checkbox.prop('checked')) {
- box.scrollTop(box.prop("scrollHeight")); //Scroll to the bottom.
- }
- }
- setInterval(function() {
- add_to_box('logb');
- add_to_box('logm');
- }, 500); //Adds a new line every second to both boxes.
- $('input[type=checkbox]').change(function(){
- if($(this).prop('checked')){
- boxid=this.id.replace('autoscroll','');
- box=$('#' + boxid);
- box.scrollTop(box.prop("scrollHeight")); //Scroll to the bottom.
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement