-
Notifications
You must be signed in to change notification settings - Fork 0
/
tailjs.js
36 lines (32 loc) · 983 Bytes
/
tailjs.js
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
$(document).ready(function(){
let refreshTime = 1000;
let logUpdaterHandle;
/* Extend jQuery to have toggleText which will check for one passed variable and return the other passed */
$.fn.extend({
toggleText: function(a, b){
return this.val(this.val() == b ? a : b);
}
});
function updateFeed(){
$.get("tailjsLog.php").done(function(data){
$('#feed').html(data);
});
logUpdaterHandle = setTimeout(updateFeed, refreshTime);
}
$('#logControl').on('click', function(){
$("#logControl").toggleText('Pause', 'Start');
if($("#logControl").val() == 'Start'){
clearTimeout(logUpdaterHandle);
}else{
updateFeed(); }
});
$('.colorBox').on('click',function() {
let classList = this.className.split(/\s+/);
if(classList[1]){
$('#feed').removeClass("feedDefaultColor whiteBox blueBox greenBox purpleBox yellowBox redBox orangeBox");
$('#feed').addClass(classList[1]);
$('#feed').css("background-color", "#333");
}
});
updateFeed()
});