Permalink
Browse files

cleaned up the examples

  • Loading branch information...
zackdever committed Sep 11, 2012
1 parent cb55051 commit e001ac95d3e7afb3a2579bfe0cd3db04e1563f2e
Showing with 44 additions and 24 deletions.
  1. +44 −24 example.html
View
@@ -1,36 +1,56 @@
<!DOCTYPE html>
<html>
- <head><title>time example</title></head>
- <body>
- <p>
- instant: <input autofocus> <span></span>
- <br />
- validation: <input> <button disabled>submit</button> <span></span>
- </p>
+ <head>
+ <title>time example</title>
<script src="time.js"></script>
- <script>
- window.onload = function() {
- 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];
+ </head>
+ <body>
- instantResult.innerText = Time().toString();
+ <!-- instant example -->
+ <p id='instant'>
+ instant: <input autofocus>
+ <span></span>
+ <script>
+ var instant = function() {
+ var root = document.getElementById('instant')
+ , input = root.getElementsByTagName('input')[0]
+ , result = root.getElementsByTagName('span')[0];
- instant.onkeyup = function() {
- instantResult.innerText = Time(instant.value);
- };
+ result.innerText = Time().toString();
- validationSubmit.onclick = function() {
- validationResult.innerText = Time(validation.value);
+ input.onkeyup = function() {
+ result.innerText = Time(input.value);
+ };
};
+ </script>
+ </p>
- validation.onkeyup = function() {
- validationSubmit.disabled = !Time.isValid(validation.value);
+ <!-- validation example -->
+ <p id='validation'>
+ validation: <input> <button disabled>submit</button>
+ <span></span>
+ <script>
+ var validation = function() {
+ var root = document.getElementById('validation')
+ , input = root.getElementsByTagName('input')[0]
+ , result = root.getElementsByTagName('span')[0]
+ , submit = root.getElementsByTagName('button')[0];
+
+ submit.onclick = function() {
+ result.innerText = Time(input.value);
+ };
+
+ input.onkeyup = function() {
+ submit.disabled = !Time.isValid(input.value);
+ };
};
+ </script>
+ </p>
+
+ <script>
+ window.onload = function() {
+ instant();
+ validation();
};
</script>
</body>

0 comments on commit e001ac9

Please sign in to comment.