Commit f2652351 authored by Milan's avatar Milan
Browse files

replace basic logviewer with websocket based one

parent cacc5bc9
<% if logged_in? %>
<% content_for :title, 'Admin' %>
<style type="text/css">#tail{height:600px;background-color:#333333;color:#fff;border-radius:4px;font-family:'Ubuntu Mono Bold', monospace;}@font-face{font-family:'Ubuntu Mono Bold';src:url(//assets.illuna-minetest.tk/fonts/ubuntu/UbuntuMono-B.ttf) format("opentype")}</style>
<h1>Admin</h1>
<button type="button" class="btn btn-primary pull-right" style="margin-top:-5rem;">Refresh</button>
<pre id="tail" style="height:600px;"><%= @logs %></pre>
<% content_for(:after) do %>
<script>
tailScroll();
<pre id="tail" class="scroll"></pre>
function updateDiv(){
$('#tail').triggerevent(function(){
$('#tail').html(newContent);
});
setInterval(updateDiv, 1000);
}
$("button").click(function (e) {
window.location.reload(true);
});
function tailScroll() {
var height = $("#tail").get(0).scrollHeight;
$("#tail").animate({
scrollTop: height
}, 500);
}
</script>
<% end %>
<% content_for(:after) do %>
<script src="https://illuna:1llun4forFun@illuna-minetest.tk/socket/socket.io.js"></script>
<script>var Application=function(){var t=io("https://user:password@illuna-minetest.tk",{path:"/socket/socket.io"});t.connect();var o=0;return t.on("connect",function(){console.log("Connected to:",t.host)}),t.on("message",function(t){console.log("Received message:",t),t.tail&&($("#tail").html($("#tail").html()+t.tail),o++,$("#tail").scrollTop(100*o))}),{socket:t}};$(function(){Application()});</script>
<% end %>
<% else %>
<h1> nope </h1>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment