Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added another example

  • Loading branch information...
commit cb55051acb6e832deada7bc59eed960c91c58131 1 parent d0ea668
Zack Dever authored
Showing with 25 additions and 6 deletions.
  1. +4 −0 README.md
  2. +21 −6 example.html
4 README.md
View
@@ -21,6 +21,10 @@ Built for [Promt](http://promtapp.com).
var time = require('time');
time('2');
+Examples
+--------
+Some example uses with input boxes can be viewed in examples.html.
+
Parses strings such as "8:20" into a Date-less Time.
new Time('1') // 1:00
27 example.html
View
@@ -3,18 +3,33 @@
<head><title>time example</title></head>
<body>
<p>
- <input autofocus> = <span id="result"></span>
+ instant: <input autofocus> <span></span>
+ <br />
+ validation: <input> <button disabled>submit</button> <span></span>
</p>
<script src="time.js"></script>
<script>
window.onload = function() {
- var result = document.getElementById('result')
- , text = document.getElementsByTagName('input')[0];
+ var results = document.getElementsByTagName('span')
+ , inputs = document.getElementsByTagName('input')
+ , instant = inputs[0]
+ , validation = inputs[1]
+ , instantResult = results[0]
+ , validationResult = results[1]
+ , validationSubmit = document.getElementsByTagName('button')[0];
- result.innerText = Time().toString();
+ instantResult.innerText = Time().toString();
- text.onkeyup = function() {
- result.innerText = Time(text.value);
+ instant.onkeyup = function() {
+ instantResult.innerText = Time(instant.value);
+ };
+
+ validationSubmit.onclick = function() {
+ validationResult.innerText = Time(validation.value);
+ };
+
+ validation.onkeyup = function() {
+ validationSubmit.disabled = !Time.isValid(validation.value);
};
};
</script>
Please sign in to comment.
Something went wrong with that request. Please try again.