Page 1 of 1

about showing the remaining time in the status page

Posted: Wed Aug 15, 2012 2:54 am
by SubZero
Hello everyone

in sum .. :D

I want to show the time remaining in the status page

So i add the code: $(session-time-left) on it

Everything is fine

the time remaining shows like this: 5w3d9h4m

So in fact this means that remaining 5 weeks and 3 days, 9 hours and 4 minutes

All I want is to replace this: 5w3d9h4m
to this: 5 weeks and 3 days, 9 hours and 4 minutes

I think that it is very easy

Sorry I'm Newbie, And Sorry for my bad English :)

Re: about showing the remaining time in the status page

Posted: Tue Aug 21, 2012 5:58 pm
by SubZero
where are you people!!!???

Re: about showing the remaining time in the status page

Posted: Tue Aug 21, 2012 6:54 pm
by boen_robot
You'd need to parse this with JavaScript.

I think it will be easiest with string.split, like:
<div id="timeLeft">$(session-time-left)</div>
<script type="text/javascript">
var timeLeft = "$(session-time-left)".split(/\d+/);
for (var i =0, l = timeLeft.length; i<l; ++i) {
    switch(timeLeft[i]) {
    case "w":
        timeLeft[i] = " weeks, ";
        break;
    case "d":
        timeLeft[i] = " days, ";
        break;
    case "h":
        timeLeft[i] = " hours, ";
        break;
    case "m":
        timeLeft[i] = " minutes";
        break;
    }
}
document.getElementById("timeLeft").innerHTML = timeLeft.join();
</script>

Re: about showing the remaining time in the status page

Posted: Wed Aug 22, 2012 2:46 am
by SubZero
You'd need to parse this with JavaScript.

I think it will be easiest with string.split, like:
<div id="timeLeft">$(session-time-left)</div>
<script type="text/javascript">
var timeLeft = "$(session-time-left)".split(/\d+/);
for (var i =0, l = timeLeft.length; i<l; ++i) {
    switch(timeLeft[i]) {
    case "w":
        timeLeft[i] = " weeks, ";
        break;
    case "d":
        timeLeft[i] = " days, ";
        break;
    case "h":
        timeLeft[i] = " hours, ";
        break;
    case "m":
        timeLeft[i] = " minutes";
        break;
    }
}
document.getElementById("timeLeft").innerHTML = timeLeft.join();
</script>
thank u 4 reply
but nothing changed after i add the script :(

Re: about showing the remaining time in the status page

Posted: Wed Aug 22, 2012 1:18 pm
by boen_robot
I tested the script, and although it didn't produced the expected results, it did make a difference... maybe JavaScript wasn't enabled in your browser when you tested?

Anyway, here's a simpler script that produces the correct results:
<div id="timeLeft">$(session-time-left)</div>
<script type="text/javascript">
document.getElementById("timeLeft").innerHTML = "$(session-time-left)".replace("w", " weeks, ").replace("d", " days, ").replace("h", " hours and ").replace("m", " minutes.");
</script>

Re: about showing the remaining time in the status page

Posted: Wed Aug 22, 2012 3:44 pm
by SubZero
I tested the script, and although it didn't produced the expected results, it did make a difference... maybe JavaScript wasn't enabled in your browser when you tested?

Anyway, here's a simpler script that produces the correct results:
<div id="timeLeft">$(session-time-left)</div>
<script type="text/javascript">
document.getElementById("timeLeft").innerHTML = "$(session-time-left)".replace("w", " weeks, ").replace("d", " days, ").replace("h", " hours and ").replace("m", " minutes.");
</script>
now it works

thank u very much bro :)

Re: about showing the remaining time in the status page

Posted: Sat Sep 05, 2015 1:33 pm
by navyday
I tested the script, and although it didn't produced the expected results, it did make a difference... maybe JavaScript wasn't enabled in your browser when you tested?

Anyway, here's a simpler script that produces the correct results:
<div id="timeLeft">$(session-time-left)</div>
<script type="text/javascript">
document.getElementById("timeLeft").innerHTML = "$(session-time-left)".replace("w", " weeks, ").replace("d", " days, ").replace("h", " hours and ").replace("m", " minutes.");
</script>
now it works

thank u very much bro :)


how to replace this code and that would put

Sorry I'm Newbie, And Sorry for my bad English :?