2.0.10 • Published 11 months ago

chronlyhms v2.0.10

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

npm bundle size Contributors Forks Stargazers Issues MIT License RepoSize Build StatusDIY Build StatusDIY

'Time Only' means that this control is for time as a unit, or a duration, like for count down timers. Not for time of day nor date on a calendar, so no AM/PM conversions on Safari, no unwanted date-time selectors. Just time up to 999 hrs and down to 1 millisecond.

OS(mobile)BrowserOS(laptop)Browser
AndroidChromeWindows 10, 11Chrome, Edge
iOSSafari, ChromeOsXSafari, Chrome

About The Project

Time inputs are updated by browsers in unwanted ways! Safari on desktop adds AM/PM if the user is in the USA and on mobile the cool scroll time selector does not allow fractions of a second. The best html5 option doesn't cut it, sadly, so ChronlyHMS was designed and buit for a consistant UX no matter the browser, OS, or location settings.

The objective is a minimised vanilla javascript plugin that reproduces the behaviour of the input type=time on Chrome. This way at least two of the major browsers are supported, Safari and Chrome, on desktop and mobile operating systems.

Does this loose any functionality? No! document.querySelector('#bob').value has a getter and setter! So values can be set and retrieved by ID.

Yes! It seems CRAZY in 2022 that there is not a native 'time only' input for HTML. What I mean is there is no user input control for time rendered independantly of date or time of day. Yea, crazy, but now ChronlyHMS is a javascript plugin that creates a UX input control for a value of time simply as hours, minutes, seconds --only! Ever thought, why is it difficult to 'code' a countdown timer? Why can't it be done with one control? Just look at google's timer and other coundown timers! All use multiple inputs, usually designed for integers.

The very worst is Safari on desktop and mobile undermine those snazzy input type=time efforts and update the input depending on OS settings for desktop or provide a control with restricted capability... Shouldn't a user be able to 'scientifically' specify a period of time with one control? The closest HTML5 input type- time when configured with UX for hours to millisecs is very finicky and rendered differently on Chrome and Safari and mobile is different from laptop, so I've simplified that!

There are a few plugins (links to come) that remediate the lack of continuity, but even time controls with the plugin treat time as a date (ex 24hr max). So it seems the current state is the most relable UX is multi input type number (more links to come ). The best example is the Google countdown timer. And that's wrong because time is a basic unit that should be separate from calendar complexities. That got me thinking, why isn't there an input control for it implemented across browsers?? I needed one, so coded ChronlyHMS.

Here's why:

  • Time is hours minutes and seconds (and millisecs) and needn't be associated with part of a day or a date
  • The date association breaks UX and is varied with browser implementation
  • I found no other crossbrowser solution
  • I thought this would be a great open source project
  • End use of number inputs (standard hack) for use with time

Of course, this is functional but in it's infancy. Maybe, with some contribution this is a project that can inspire change to the HTML spec.

Feel free to vote for WhatWG inclusion of a into the HTML spec! (link comming soon)

Built With

This section should lists any major frameworks/libraries used to for this project. Any add-ons/plugins are in the acknowledgements section.

Getting Started

There are no pre-requisites for using ChronlyHMS if you're not compiling/ packaging you javascript. If you are packaging:

Prerequisites

This is an example of how to get started with npm and webpack, other frameworks should work too.

  • npm & webpack

    npm install npm@latest -g
    npm init -y
    npm install webpack webpack-cli --save-dev

Installation

With packaging: This template doesn't rely on any external dependencies or services.

  1. Install from NPM
     npm i chronlyhms
  2. import ChronlyHMS javascript and css
    import ChronlyHMS from 'chronlyhms';
    import 'chronlyhms/src/chrono.css'
  
Without packaging:

1. Add script:
 ```bash
 <script src="https://cdn.jsdelivr.net/npm/chronlyhms@1.0.65/dist/chronoBundle.min.js"></script>
  

Usage

ChronlyHMS requires an input element with the attribute 'data-univHMS'. There's no more code than that needed.

<input id='bob' data-univHMS></input>

If you would like ChronlyHMS to update inputs that are placed on DOM with javascipt (ex. after chronlyhms script is added), then with your js: 1) add a data attribute to the input

data-univHMS [data-univHMS='']

2) call the Chronly boot method

window.ChronlyHMS.boot()

so the inputs are modified.

For more documentation, please refer to the jscocs on ChronlyHMS Docs

Roadmap

  • Emperically determine behaviour of Input (time) on Chrome
  • Reverse engineer input behaviour (arrows, digits, 0 addition, etc.)
  • Cross browser/ cross os manual tests
  • Get Chrome behavioural specification for
  • Add end to end multi-browser, multi-os Selinium tests
  • Update demo page (either PM.com or JSfiddle type)
  • Multi-language documentation (Google translate of this page?)
    • Chinese
    • Spanish
  • Is it worth having a remove function, restoring the original input?

See the open issues for a full list of proposed features (and known issues).

Teststatus

TestStatusDIY TestStatusDIY TestStatusDIY TestStatusDIY TestStatusDIY TestStatusDIY

Tests & Live Status

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Stephan Luis - stephan@learnsense.org

Project Link: https://github.com/StephanLuis/chronlyhms

Acknowledgments

Resources I've found helpful and would like to give credit to:

2.0.3

11 months ago

2.0.2

11 months ago

2.0.5

11 months ago

2.0.4

11 months ago

2.0.7

11 months ago

2.0.6

11 months ago

2.0.9

11 months ago

2.0.8

11 months ago

2.0.1

11 months ago

2.0.0

11 months ago

2.0.10

11 months ago

1.1.1

1 year ago

1.1.0

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.13

1 year ago

1.0.66

2 years ago

1.0.62

2 years ago

1.0.61

2 years ago

1.0.60

2 years ago

1.0.65

2 years ago

1.0.64

2 years ago

1.0.63

2 years ago

1.0.51

2 years ago

1.0.50

2 years ago

1.0.55

2 years ago

1.0.54

2 years ago

1.0.53

2 years ago

1.0.52

2 years ago

1.0.59

2 years ago

1.0.58

2 years ago

1.0.57

2 years ago

1.0.56

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.40

2 years ago

1.0.44

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.49

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago