Community discussions

 
MCI
just joined
Topic Author
Posts: 4
Joined: Thu Jan 31, 2019 10:01 pm
Location: Venezuela

Hotspot status.html

Thu Jan 31, 2019 10:13 pm

Hi!, thanks in advance to those who collaborate with me. =D

My questions is how to make $(uptime) updated in real time on the hotspot status page, without having to refurbish the browser.
 
User avatar
pcunite
Forum Veteran
Forum Veteran
Posts: 945
Joined: Sat May 25, 2013 5:13 am
Location: USA

Re: Hotspot status.html

Tue Feb 05, 2019 5:35 am

If you don't want a page refresh, you might be able to create a JavaScript function that reads that value in a loop. I've not tested it, however.
 
MCI
just joined
Topic Author
Posts: 4
Joined: Thu Jan 31, 2019 10:01 pm
Location: Venezuela

Re: Hotspot status.html

Fri Feb 15, 2019 2:31 am

If you don't want a page refresh, you might be able to create a JavaScript function that reads that value in a loop. I've not tested it, however.
Some example of its implementation?
 
User avatar
pcunite
Forum Veteran
Forum Veteran
Posts: 945
Joined: Sat May 25, 2013 5:13 am
Location: USA

Re: Hotspot status.html

Fri Feb 15, 2019 5:20 am

Replace status.html with the contents of this HTML.

<!DOCTYPE html>

<html lang="en">
<head>
    <title>Status Page</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="expires" content="-1" />

<script type="text/javascript">
function GetUptime()
{
    // Get uptime value
    var sUPTIME = '$(uptime)';

    // if sUPTIME is not parsed, show current time, simply for testing
    sUPTIME = new Date();

    // Get access to element to show uptime
    var eUptime = document.getElementById("UPTIME");

    // refresh html element
    eUptime.innerHTML = sUPTIME;

    // wait 1 second and run again
    setTimeout(function(){GetUptime()}, 1000);
}
</script>
</head>

<body onLoad="GetUptime()">

    <div >
        <p>Your current uptime:</p>
        <p id="UPTIME"></p>
    </div>

</body>
</html>
 
MCI
just joined
Topic Author
Posts: 4
Joined: Thu Jan 31, 2019 10:01 pm
Location: Venezuela

Re: Hotspot status.html

Fri Feb 15, 2019 10:30 am

Replace status.html with the contents of this HTML.

<!DOCTYPE html>

<html lang="en">
<head>
    <title>Status Page</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="expires" content="-1" />

<script type="text/javascript">
function GetUptime()
{
    // Get uptime value
    var sUPTIME = '$(uptime)';

    // if sUPTIME is not parsed, show current time, simply for testing
    sUPTIME = new Date();

    // Get access to element to show uptime
    var eUptime = document.getElementById("UPTIME");

    // refresh html element
    eUptime.innerHTML = sUPTIME;

    // wait 1 second and run again
    setTimeout(function(){GetUptime()}, 1000);
}
</script>
</head>

<body onLoad="GetUptime()">

    <div >
        <p>Your current uptime:</p>
        <p id="UPTIME"></p>
    </div>

</body>
</html>
You do not have the required permissions to view the files attached to this post.
 
User avatar
pcunite
Forum Veteran
Forum Veteran
Posts: 945
Joined: Sat May 25, 2013 5:13 am
Location: USA

Re: Hotspot status.html

Fri Feb 15, 2019 3:01 pm

I apologize, remove these lines:

// if sUPTIME is not parsed, show current time, simply for testing
sUPTIME = new Date();
 
MCI
just joined
Topic Author
Posts: 4
Joined: Thu Jan 31, 2019 10:01 pm
Location: Venezuela

Re: Hotspot status.html

Sun Feb 17, 2019 2:22 pm

I apologize, remove these lines:

// if sUPTIME is not parsed, show current time, simply for testing
sUPTIME = new Date();
the value is still static
 
User avatar
Thor187
newbie
Posts: 46
Joined: Sat Oct 21, 2017 10:21 pm

Re: Hotspot status.html

Sun Feb 17, 2019 3:28 pm

Does mikrotik support javascript to its full extent?

Can I use jquery?
 
User avatar
pcunite
Forum Veteran
Forum Veteran
Posts: 945
Joined: Sat May 25, 2013 5:13 am
Location: USA

Re: Hotspot status.html

Sun Feb 17, 2019 3:58 pm

The value is still static.

Then with META tags or JavaScript, you'll have to reload the page because it seems the embedded web server does not send down new data. If there is another way to query with JavaScript, I don't know how.

If we could AJAX a php file, but I don't think we can. Maybe with JavaScript AJAX, load an HTML file with the uptime in it, then parse the HTML output.

Who is online

Users browsing this forum: No registered users and 54 guests