Giter VIP home page Giter VIP logo

Comments (5)

gazsi51 avatar gazsi51 commented on June 11, 2024 1

Thank you so much. It works very well, as I expected. I appreciate your help very much. I am not a professional coder but fortunately there good guys from this industry like you. TNX..

from easytimer.js.

albert-gonzalez avatar albert-gonzalez commented on June 11, 2024

Hi!

The toString method is very simple and it doesn't allow diferent separators. If you need a custom format, you can write a method to do that. For example:

const timer = Timer();

timer.start({ precision: 'secondTenths' });

const formatValues = (timeValues) => `${timeValues.toString()}.${timeValues.secondTenths}`;
timer.on('secondTenthsUpdated', () => console.log(formatValues(timer.getTimeValues())));

Best regards!

from easytimer.js.

gazsi51 avatar gazsi51 commented on June 11, 2024

Hi,
Thank you for the quick answer. I tried it but it does not work. Where to insert your suggested codes. Here is my original codes

<script src="js/easytimer.min.js"></script>
    <div id="ElapsedTime">
      <p><B>Elapsed time: </B></p>
        <div class="values">00:00:00.0</div>
    	<br>
		<button class="startButton" id="Submit" style="margin-bottom: 10px">Submit</button>
	</div>
   
<script>
var timer = new Timer();
$('#ElapsedTime .startButton').click(function () {
    $("#ajax_stat_result").css({"display":"none"});
    timer.start({precision: 'secondTenths'});
});

timer.addEventListener('secondTenthsUpdated', function (e) {
    $('#ElapsedTime .values').html(timer.getTimeValues().toString(['hours','minutes', 'seconds', 'secondTenths']));
});
</script>

from easytimer.js.

albert-gonzalez avatar albert-gonzalez commented on June 11, 2024

Hi again!

No problem. Try to replace your event listener with this:

timer.addEventListener('secondTenthsUpdated', function (e) {
    var timeValues = timer.getTimeValues();
    $('#ElapsedTime .values').html(timeValues.toString(['hours','minutes', 'seconds']) + '.' + timeValues.secondTenths);
});

This should work.

Best regards!

from easytimer.js.

albert-gonzalez avatar albert-gonzalez commented on June 11, 2024

You are welcome! Glad to help you.

Best regards!

from easytimer.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.