8: user data entry

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!-- 
  This example uses a few CameraTag features. First it uses our customizable 
  HTML interface to create a custom start screen that requests an email 
  address from the user. If the user enters a valid email adddress it will 
  attach the email address as metadata on the video and allow the user to 
  record / upload a video. Note- we intentioanlly left any styling out of 
  the xample to keep the code as simple as possible :)
-->

<html>
  <head>
    <script src='//www.cameratag.com/api/v11/js/cameratag.min.js' type='text/javascript'></script>
    <script src='https://code.jquery.com/jquery-2.1.4.min.js' type='text/javascript'></script>
    <link rel='stylesheet' href='//www.cameratag.com/static/11/cameratag.css'></link>
    
    <script>
        $(function(){
            $("#submit").click(function(){
                var user_email = $("#email").val();
                if (validateEmail(user_email)) {
                    CameraTag.cameras["DemoCamera"].setMetadata({
                        email: user_email
                    })
                    $("#step1").hide();
                    $("#step2").show();
                } else {
                    alert("that is not an email")
                }
            })

            function validateEmail(email) {
                var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
                return re.test(email);
            }
        })
    </script>
  </head>

  <body>
    <camera id='DemoCamera' data-app-id='63f9c870-72c4-0130-04c5-123139045d73'></camera>

    <div id="DemoCamera-start-screen" class="cameratag_screen cameratag_start" style="position: absolute; display: none;">
        <div id="step1">
            <input id="email" type="email">
            <button id="submit">Next</button>
        </div>

        <div id="step2" style="display:none">
            <a class="cameratag_record">record from webcam</a>
            <br/>
            <a class="cameratag_upload">upload</a>
            <br/>
            <a class="cameratag_sms">record from phone</a>
        </div>
    </div>
  </body>
</html>