chronlyhms
v2.0.10
Published
This is the beginning of 'ChronolyHMS' it is a javascript control widget that provides an hour, minute, second, and millisecond control for HTML5. Cureently the CSS for the control still needs to be 'managed'. So the package CSS bundling is needs develop
Downloads
21
Readme
'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) | Browser | | OS(laptop) | Browser | |-----------------|----------------|--|-------------|-----------| | Android | Chrome | |Windows 10, 11 | Chrome, Edge | | iOS | Safari, Chrome | |OsX | Safari, 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
- Webpack requires configuration for packaging ChronlyHMS CSS see Webpack CSS Loader
Installation
With packaging: This template doesn't rely on any external dependencies or services.
- Install from NPM
npm i chronlyhms
- import ChronlyHMS javascript and css
import ChronlyHMS from 'chronlyhms';
import 'chronlyhms/src/chrono.css'
Without packaging:
- Add script:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/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:
- add a data attribute to the input
data-univHMS [data-univHMS='']
- 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
- [x] Emperically determine behaviour of Input (time) on Chrome
- [x] Reverse engineer input behaviour (arrows, digits, 0 addition, etc.)
- [x] 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
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE.txt
for more information.
Contact
Stephan Luis - [email protected]
Project Link: https://github.com/StephanLuis/chronlyhms
Acknowledgments
Resources I've found helpful and would like to give credit to: