From e0c77df44cdba885963b2f547ce11c6cc347ba63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz> Date: Mon, 8 Jun 2020 00:59:47 +0200 Subject: [PATCH] jQuery --- templates/index.html.ep | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/templates/index.html.ep b/templates/index.html.ep index 4256a88..b853a5f 100644 --- a/templates/index.html.ep +++ b/templates/index.html.ep @@ -1,32 +1,12 @@ % layout 'default'; % title 'Piratské vysílání'; -<div id="streams-container"> +<div id="streams"> </div> <script> -// pure js, vole :) -var getHTML = function ( url, callback ) { - if ( !window.XMLHttpRequest ) return; - var xhr = new XMLHttpRequest(); - - xhr.onload = function() { - if ( callback && typeof( callback ) === 'function' ) { - callback( this.responseXML ); - } - } - - xhr.open( 'GET', url ); - xhr.responseType = 'document'; - xhr.send(); -}; - -function Streams () { - getHTML( '/streams', function (response) { - var target = document.querySelector( '#streams-container' ); - target.innerHTML = response.documentElement.innerHTML; - }); +function load_streams() { + $( "#streams" ).load( "/streams" ); } - -Streams(); -setInterval(Streams, 5000); - +load_streams(); +setInterval(load_streams, 5000); </script> + -- GitLab