Browse code

Squashed commit of the following:

commit 3f9e9185fe7ee51f2fe55f0fc0d4fffdc4f289dc
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date: Mon Oct 6 10:57:35 2014 -0700

changed the title of back buttons

commit f86934424e85931ec293e711ceaa93ee920828fb
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date: Mon Oct 6 10:53:15 2014 -0700

Finished level 2, refactored tests

commit 8f502bce05293cccaf200b69ce5f5826eee72484
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date: Mon Oct 6 08:52:37 2014 -0700

stylized better and added level 2

commit 07b2276b346c34c0cc0faa57500c40e120e77888
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date: Fri Oct 3 18:17:29 2014 -0700

broke tutorial tests styles

commit 35d84147dc2f65b0ffeea5faf304add903219b1e
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date: Fri Oct 3 17:23:48 2014 -0700

structured test level1 md file

commit 808d01b0d55d67eb1017f290a29da6c7d38565f2
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date: Fri Oct 3 17:15:46 2014 -0700

Modified files and integrated tutorial through new page

commit 0f0093f2882489c3eeb6f8870f2b8aa64dc939a3
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date: Thu Oct 2 14:34:44 2014 -0700

more refactoring

commit 5a9b98e55ebd455ccf2c0ced20f984545a0b6d71
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date: Thu Oct 2 11:46:58 2014 -0700

clean js code

commit af3bbd8d5e1dffdaa1780f83b909ff566906e513
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date: Thu Oct 2 11:26:39 2014 -0700

level 1 cleanup

commit c4852a7766ab4fbd978d65c8352ace05eb427ef5
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date: Thu Oct 2 11:20:17 2014 -0700

fixed up fill-in level1

commit 7f02d80942549dec9c05f784b777fcb32d5bb81b
Author: Nathan Hsieh <hsieh.nathan@gmail.com>
Date: Wed Oct 1 17:45:42 2014 -0700

added dockerfile tut, stylized lesson1 Questions

Signed-off-by: Nathan Hsieh <hsieh.nathan@gmail.com>

Nathan Hsieh authored on 2014/10/07 03:57:09
Showing 9 changed files
... ...
@@ -59,6 +59,8 @@ pages:
59 59
 - ['userguide/dockerlinks.md', 'User Guide', 'Linking containers together' ]
60 60
 - ['userguide/dockervolumes.md', 'User Guide', 'Managing data in containers' ]
61 61
 - ['userguide/dockerrepos.md', 'User Guide', 'Working with Docker Hub' ]
62
+- ['userguide/level1.md', '**HIDDEN**' ]
63
+- ['userguide/level2.md', '**HIDDEN**' ]
62 64
 
63 65
 # Docker Hub docs:
64 66
 - ['docker-hub/index.md', 'Docker Hub', 'Docker Hub' ]
... ...
@@ -168,6 +168,8 @@ update and create images.
168 168
 1. We can update a container created from an image and commit the results to an image.
169 169
 2. We can use a `Dockerfile` to specify instructions to create an image.
170 170
 
171
+Test your understanding [here](/userguide/level1)!
172
+
171 173
 ### Updating and committing an image
172 174
 
173 175
 To update an image we first need to create a container from the image
... ...
@@ -478,6 +480,10 @@ We can then create a container from our new image.
478 478
 > To help you write a clear, readable, maintainable `Dockerfile`, we've also
479 479
 > written a [`Dockerfile` Best Practices guide](/articles/dockerfile_best-practices).
480 480
 
481
+### Test your understanding
482
+
483
+See how well you understand the material by taking [this short quiz](/userguide/level1)!
484
+
481 485
 ## Setting tags on an image
482 486
 
483 487
 You can also add a tag to an existing image after you commit or build it. We
... ...
@@ -535,3 +541,4 @@ by linking together multiple Docker containers.
535 535
 
536 536
 Go to [Linking Containers Together](/userguide/dockerlinks).
537 537
 
538
+
538 539
new file mode 100644
... ...
@@ -0,0 +1,72 @@
0
+page_title: Docker Images Test
1
+page_description: How to work with Docker images.
2
+page_keywords: documentation, docs, the docker guide, docker guide, docker, docker platform, virtualization framework, docker.io, Docker images, Docker image, image management, Docker repos, Docker repositories, docker, docker tag, docker tags, Docker Hub, collaboration
3
+
4
+<a title="back" class="btn btn-primary back" href="/userguide/dockerimages/#creating-our-own-images">Back</a>
5
+
6
+# Test Yourself
7
+
8
+## Test your Dockerfile skills - Level 1
9
+
10
+### Questions
11
+
12
+<div name="level1_questions">
13
+	What is the Dockerfile instruction to specify the base image ?<br />
14
+	<input type="text" class="level" id="level1_q0"/>
15
+	<div class="alert alert-error level_error" id="level1_error0" style="display:none;">The right answer was <code>FROM</code></div>
16
+	<br>
17
+	What is the Dockerfile instruction to execute any commands on the current image and commit the results?<br />
18
+	<input type="text" class="level" id="level1_q1"/>
19
+	<div class="alert alert-error level_error" id="level1_error1" style="display:none;">The right answer was <code>RUN</code></div>
20
+	<br>
21
+	What is the Dockerfile instruction to specify the maintainer of the Dockerfile?<br />
22
+	<input type="text" class="level" id="level1_q2"/>
23
+	<div class="alert alert-error level_error" id="level1_error2" style="display:none;">The right answer was <code>MAINTAINER</code></div>
24
+	<br>
25
+	What is the character used to add comment in Dockerfiles?<br />
26
+	<input type="text" class="level" id="level1_q3"/>
27
+	<div class="alert alert-error level_error" id="level1_error3" style="display:none;">The right answer was <code>#</code></div>
28
+	<p>
29
+	<div class="alert alert-success" id="all_good" style="display:none;">Congratulations, you made no mistake!<br />
30
+	Tell the world <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.docker.io/learn/dockerfile/level1/" data-text="I just successfully answered questions of the #Dockerfile tutorial Level 1. What's your score?" data-via="docker" >Tweet</a><br />
31
+	And try the next challenge: <a href="#fill_the_dockerfile">Fill the Dockerfile</a>
32
+	</div>
33
+	<div class="alert alert-error" id="no_good" style="display:none;">Your Dockerfile skills are not yet perfect, try to take the time to read this tutorial again.</div>
34
+	<div class="alert alert-block" id="some_good" style="display:none;">You're almost there! Read carefully the sections corresponding to your errors, and take the test again!</div>
35
+	</p>
36
+	<button class="btn btn-primary" id="check_level1_questions">Check your answers</button>
37
+</div>
38
+
39
+### Fill the Dockerfile
40
+Your best friend Eric Bardin sent you a Dockerfile, but some parts were lost in the ocean. Can you find the missing parts?
41
+<div class="form-inline">
42
+<pre>
43
+&#35; This is a Dockerfile to create an image with Memcached and Emacs installed. <br>
44
+&#35; VERSION       1.0<br>
45
+&#35; use the ubuntu base image provided by dotCloud
46
+<input type="text" class="l_fill" id="from" /> ub<input type="text" class="l_fill" id="ubuntu" /><br>
47
+<input type="text" class="l_fill" id="maintainer" /> E<input type="text" class="l_fill" id="eric" /> B<input type="text" class="l_fill" id="bardin" />, eric.bardin@dotcloud.com<br>
48
+&#35; make sure the package repository is up to date
49
+<input type="text" class="l_fill" id="run0"/> echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
50
+<input type="text" class="l_fill" id="run1" /> apt-get update<br>
51
+&#35; install memcached
52
+RUN apt-get install -y <input type="text" class="l_fill" id="memcached" /><br>
53
+&#35; install emacs
54
+<input type="text" class="l_fill" id="run2"/> apt-get install -y emacs23
55
+</pre>
56
+</div>
57
+
58
+<div class="alert alert-success" id="dockerfile_ok" style="display:none;">Congratulations, you successfully restored Eric's Dockerfile! You are ready to containerize the world!.<br />
59
+Tell the world! <a href="https://twitter.com/share" class="twitter-share-button" data-url="https://www.docker.io/learn/dockerfile/level1/" data-text="I just successfully completed the 'Fill the Dockerfile' challenge of the #Dockerfile tutorial Level 1" data-via="docker" >Tweet</a>
60
+</div>
61
+<div class="alert alert-error" id="dockerfile_ko" style="display:none;">Wooops, there are one or more errors in the Dockerfile. Try again.</div>
62
+<br>
63
+<button class="btn btn-primary" id="check_level1_fill">Check the Dockerfile</button></p>
64
+
65
+## What's next?
66
+
67
+<p>In the next level, we will go into more detail about how to specify which command should be executed when the container starts,
68
+which user to use, and how expose a particular port.</p>
69
+
70
+<a title="back" class="btn btn-primary back" href="/userguide/dockerimages/#creating-our-own-images">Back</a>
71
+<a title="next level" class="btn btn-primary" href="/userguide/level2">Go to the next level</a>
0 72
\ No newline at end of file
1 73
new file mode 100644
... ...
@@ -0,0 +1,97 @@
0
+page_title: Docker Images Test
1
+page_description: How to work with Docker images.
2
+page_keywords: documentation, docs, the docker guide, docker guide, docker, docker platform, virtualization framework, docker.io, Docker images, Docker image, image management, Docker repos, Docker repositories, docker, docker tag, docker tags, Docker Hub, collaboration
3
+
4
+<a title="back" class="btn btn-primary back" href="/userguide/dockerimages/#creating-our-own-images">Back</a>
5
+
6
+#Test Yourself
7
+
8
+## Test your Dockerfile skills - Level 2
9
+
10
+### Questions:
11
+
12
+<div class="level_questions">
13
+What is the Dockerfile instruction to specify the base image?<br>
14
+	<input type="text" class="level">
15
+	<div style="display:none;" id="level2_error0" class="alert alert-error level_error">The right answer was <code>FROM</code></div><br>
16
+	Which Dockerfile instruction sets the default command for your image?<br>
17
+	<input type="text" class="level">
18
+	<div style="display:none;" id="level2_error4" class="alert alert-error level_error">The right answer was <code>ENTRYPOINT</code> or <code>CMD</code></div><br>
19
+	What is the character used to add comments in Dockerfiles?<br>
20
+	<input type="text" class="level">
21
+	<div style="display:none;" id="level2_error3" class="alert alert-error level_error">The right answer was <code>#</code></div><br>
22
+    Which Dockerfile instruction sets the username to use when running the image?<br>
23
+	<input type="text" class="level">
24
+	<div style="display:none;" id="level2_error5" class="alert alert-error level_error">The right answer was <code>USER</code></div><br>
25
+	What is the Dockerfile instruction to execute any command on the current image and commit the results?<br>
26
+	<input type="text" class="level">
27
+	<div style="display:none;" id="level2_error1" class="alert alert-error level_error">The right answer was <code>RUN</code></div><br>
28
+	Which Dockerfile instruction sets ports to be exposed when running the image?<br>
29
+	<input type="text" class="level">
30
+	<div style="display:none;" id="level2_error6" class="alert alert-error level_error">The right answer was <code>EXPOSE</code></div><br>
31
+	What is the Dockerfile instruction to specify the maintainer of the Dockerfile?<br>
32
+	<input type="text" class="level">
33
+	<div style="display:none;" id="level2_error2" class="alert alert-error level_error">The right answer was <code>MAINTAINER</code></div><br>
34
+	Which Dockerfile instruction lets you trigger a command as soon as the container starts?<br>
35
+	<input type="text" class="level">
36
+	<div style="display:none;" id="level2_error7" class="alert alert-error level_error">The right answer was <code>ENTRYPOINT</code> or <code>CMD</code></div><br>
37
+	<p>
38
+	
39
+	<div class="alert alert-success" id="all_good" style="display:none;">Congratulations, you made no mistake!<br />
40
+	Tell the world <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.docker.io/learn/dockerfile/level1/" data-text="I just successfully answered questions of the #Dockerfile tutorial Level 1. What's your score?" data-via="docker" >Tweet</a><br />
41
+	And try the next challenge: <a href="#fill_the_dockerfile">Fill the Dockerfile</a>
42
+	</div>
43
+	<div class="alert alert-error" id="no_good" style="display:none;">Your Dockerfile skills are not yet perfect, try to take the time to read this tutorial again.</div>
44
+	<div class="alert alert-block" id="some_good" style="display:none;">You're almost there! Read carefully the sections corresponding to your errors, and take the test again!</div>
45
+	</p>
46
+	<button class="btn btn-primary" id="check_level2_questions">Check your answers</button>
47
+</div>
48
+
49
+### Fill the Dockerfile
50
+<br>
51
+Your best friend Roberto Hashioka sent you a Dockerfile, but some parts were lost in the ocean. Can you find the missing parts?
52
+<div class="form-inline">
53
+<pre>
54
+&#35; Redis
55
+&#35;
56
+&#35; VERSION       0.42
57
+&#35;
58
+&#35; use the ubuntu base image provided by dotCloud
59
+<input id="from" class="l_fill" type="text">  ub<input id="ubuntu" class="l_fill" type="text"><br>
60
+MAINT<input id="maintainer" class="l_fill" type="text"> Ro<input id="roberto" class="l_fill" type="text"> Ha<input id="hashioka" class="l_fill" type="text"> roberto.hashioka@dotcloud.com<br>
61
+&#35; make sure the package repository is up to date
62
+<input id="run0" class="l_fill" type="text"> echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
63
+<input id="run1" class="l_fill" type="text"> apt-get update<br>
64
+&#35; install wget (required for redis installation)
65
+<input id="run2" class="l_fill" type="text"> apt-get install -y wget<br>
66
+&#35; install make (required for redis installation)
67
+<input id="run3" class="l_fill" type="text"> apt-get install -y make<br>
68
+&#35; install gcc (required for redis installation)
69
+RUN apt-get install -y <input id="gcc" class="l_fill" type="text"><br>
70
+&#35; install apache2
71
+<input id="run4" class="l_fill" type="text"> wget http://download.redis.io/redis-stable.tar.gz
72
+<input id="run5" class="l_fill" type="text">tar xvzf redis-stable.tar.gz
73
+<input id="run6" class="l_fill" type="text">cd redis-stable && make && make install<br>
74
+&#35; launch redis when starting the image
75
+<input id="entrypoint" class="l_fill" type="text"> ["redis-server"]<br>
76
+&#35; run as user dameon
77
+<input id="user" class="l_fill" type="text"> daemon<br>
78
+&#35; expose port 6379
79
+<input id="expose" class="l_fill" type="text"> 6379
80
+</pre>
81
+<div class="alert alert-success" id="dockerfile_ok" style="display:none;">Congratulations, you successfully restored Roberto's Dockerfile! You are ready to containerize the world!.<br />
82
+    Tell the world! <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.docker.io/learn/dockerfile/level2/" data-text="I just successfully completed the 'Dockerfill' challenge of the #Dockerfile tutorial Level 2" data-via="docker" >Tweet</a>
83
+</div>
84
+<div class="alert alert-error" id="dockerfile_ko" style="display:none;">Wooops, there are one or more errors in the Dockerfile. Try again.</div>
85
+<br>
86
+<button class="btn btn-primary" id="check_level2_fill">Check the Dockerfile</button></p>
87
+</div>
88
+    
89
+## What's next?
90
+<p>
91
+Thanks for going through our tutorial! We will be posting Level 3 shortly. Follow us on twitter<br>
92
+<a href="https://twitter.com/docker" class="twitter-follow-button" data-show-count="false">Follow @docker</a>
93
+<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
94
+</p>
95
+<p>In the meantime, check out this <a href="http://crosbymichael.com/dockerfile-best-practices.html">blog post</a> by Michael Crosby that describes Dockerfile Best Practices.</p>
96
+<a title="creating our own images" class="btn btn-primary" href="/userguide/dockerimages/#creating-our-own-images">Back to the Docs!</a>
0 97
\ No newline at end of file
... ...
@@ -17,6 +17,7 @@
17 17
   <link href="/css/bootstrap-custom.css" rel="stylesheet">
18 18
   <link href="/css/main.css" rel="stylesheet">
19 19
   <link href="/css/prettify-1.0.css" rel="stylesheet">
20
+  <link rel="stylesheet" type="text/css" href="/css/dockerfile_tutorial.css">
20 21
   <link href="/tipuesearch/tipuesearch.css" rel="stylesheet">
21 22
   <link href="/css/docs.css" rel="stylesheet">
22 23
   <link rel="shortcut icon" href="{{ site_favicon }}">
... ...
@@ -102,9 +103,12 @@
102 102
 {% include "footer.html" %}
103 103
 
104 104
 <script src="/js/jquery-1.10.2.min.js"></script>
105
+<script src="/js/jquery.cookie.js" ></script>
105 106
 <script src="/js/jquery-scrolltofixed-min.js"></script>
106 107
 <script src="/js/bootstrap-3.0.3.min.js"></script>
107 108
 <script src="/js/prettify-1.0.min.js"></script>
109
+<script src="/js/dockerfile_tutorial.js"></script>
110
+<script src="/js/dockerfile_tutorial_level.js"></script>
108 111
 <script src="/js/base.js"></script>
109 112
 <script src="/tipuesearch/tipuesearch_set.js"></script>
110 113
 <script src="/tipuesearch/tipuesearch.min.js"></script>
111 114
new file mode 100644
... ...
@@ -0,0 +1,59 @@
0
+pre {
1
+    background-color: #F5F5F5;
2
+    border: 1px solid rgba(0, 0, 0, 0.15);
3
+    border-radius: 4px 4px 4px 4px;
4
+    display: block;
5
+    font-size: 13px;
6
+    line-height: 20px;
7
+    margin: 0 0 10px;
8
+    padding: 9.5px;
9
+    white-space: pre-wrap;
10
+    word-break: break-all;
11
+    word-wrap: break-word;
12
+}
13
+code, pre {
14
+    border-radius: 3px 3px 3px 3px;
15
+    color: #333333;
16
+    font-family: Monaco,Menlo,Consolas,"Courier New",monospace;
17
+    font-size: 12px;
18
+    padding: 0 3px 2px;
19
+}
20
+
21
+.terminal {
22
+	color: #AAAAAA;
23
+	background-color: black;
24
+}
25
+
26
+.terminal  span.command {
27
+	color: white;
28
+	font-weight: bold;
29
+}
30
+
31
+.error_input {
32
+    border-color: #B94A48 !important;
33
+    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset !important;
34
+}
35
+
36
+input.level {
37
+    width: 150px;
38
+    height: 2.5em;
39
+    display: inline-block;
40
+}
41
+div.level_error {
42
+    width: 300px;
43
+    display: inline-block;
44
+    padding: 7px 12px;
45
+}
46
+.alert {
47
+    text-align:center;
48
+}
49
+#check_level_questions {
50
+    margin-top: 10px;
51
+}
52
+.form-inline input.l_fill {
53
+    height: 20px;
54
+    border-radius: 0;
55
+    width: 90px;
56
+    margin-right: 0;
57
+    padding: 0 0 2px 0;
58
+}
0 59
\ No newline at end of file
1 60
new file mode 100755
... ...
@@ -0,0 +1,74 @@
0
+function clean_input(i) {
1
+    return i.replace(/^\s+|\s+$/g, '');
2
+}
3
+
4
+function clean_up(str){
5
+    return clean_input(str).toUpperCase();
6
+}
7
+
8
+function dockerfile_log(level, item, errors)
9
+{
10
+	var logUrl = '/tutorial/api/dockerfile_event/';
11
+	$.ajax({
12
+			url: logUrl,
13
+			type: "POST",
14
+			cache:false,
15
+			data: {
16
+				'errors': errors,
17
+				'level': level,
18
+				'item': item,
19
+			},
20
+		}).done( function() { } );
21
+}
22
+
23
+function validate_email(email)
24
+{ 
25
+	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,}))$/;
26
+	return re.test(email);
27
+} 
28
+
29
+$(document).ready(function() {
30
+
31
+    /* prepare to send the csrf-token on each ajax-request */
32
+    var csrftoken = $.cookie('csrftoken');
33
+    $.ajaxSetup({
34
+        headers: { 'X-CSRFToken': csrftoken }
35
+    });
36
+
37
+    $("#send_email").click( function()
38
+    {
39
+        $('#email_invalid').hide();
40
+        $('#email_already_registered').hide();
41
+        $('#email_registered').hide();
42
+
43
+        email = $('#email').val();
44
+        if (!validate_email(email))
45
+        {
46
+            $('#email_invalid').show();
47
+            return (false);
48
+        }
49
+
50
+        var emailUrl = '/tutorial/api/subscribe/';
51
+
52
+        $.ajax({
53
+                url: emailUrl,
54
+                type: "POST",
55
+                cache:false,
56
+                data: {
57
+                    'email': email,
58
+                    'from_level': $(this).data('level')
59
+                },
60
+            }).done( function(data ) {
61
+                    if (data == 1) // already registered
62
+                    {
63
+                        $('#email_already_registered').show();
64
+                    }
65
+                    else if (data == 0) // registered ok
66
+                    {
67
+                        $('#email_registered').show();
68
+                    }
69
+
70
+                } );
71
+        return (true);
72
+    });
73
+})
0 74
new file mode 100644
... ...
@@ -0,0 +1,176 @@
0
+function check_form1 ()
1
+{
2
+	$('#level1_error0').hide();
3
+	$('#level1_error1').hide();
4
+	$('#level1_error2').hide();
5
+	$('#level1_error3').hide();
6
+	
7
+	$('#no_good').hide();	
8
+	$('#some_good').hide();		
9
+	$('#all_good').hide();
10
+
11
+	var a = clean_input($('#level1_q0').val()).toUpperCase();
12
+	var b = clean_input($('#level1_q1').val()).toUpperCase();
13
+	var c = clean_input($('#level1_q2').val()).toUpperCase();
14
+	var d = clean_input($('#level1_q3').val());
15
+	var points = 0;
16
+	
17
+	if (a == 'FROM'){
18
+		points = points + 1;
19
+	} else {
20
+		$('#level1_error0').show();
21
+	}
22
+	if (b == 'RUN') {
23
+		points = points + 1;
24
+	} else {
25
+		$('#level1_error1').show();
26
+	}
27
+	if (c == 'MAINTAINER') {
28
+		points = points + 1;
29
+	} else {
30
+		$('#level1_error2').show();
31
+	}
32
+	if (d == '#') {
33
+		points = points + 1;
34
+	} else {
35
+		$('#level1_error3').show();
36
+	}
37
+	if (points == 4) {// all good
38
+		$('#all_good').show();
39
+	} else if (points == 0) { // nothing good
40
+		$('#no_good').show();	
41
+	} else {// some good some bad
42
+		$('#some_good').show();
43
+	}
44
+	return (4 - points);
45
+}
46
+
47
+function check_form2 ()
48
+{
49
+    $('.level_questions .alert').hide();
50
+
51
+    var answers = {};
52
+    answers[0] = ['FROM'];
53
+    answers[1] = ['ENTRYPOINT', 'CMD'];
54
+    answers[2] = ['#'];
55
+    answers[3] = ['USER'];
56
+    answers[4] = ['RUN'];
57
+    answers[5] = ['EXPOSE'];
58
+    answers[6] = ['MAINTAINER'];
59
+    answers[7] = ['ENTRYPOINT', 'CMD'];
60
+
61
+	var points = 0;
62
+
63
+    $.each($(".level"), function(num, input){
64
+        var cleaned = clean_up(input.value);
65
+        if ($.inArray(cleaned, answers[num]) == -1) {
66
+            $( $(".level_error")[num]).show()
67
+            $(input).addClass("error_input");
68
+        } else {
69
+            $( $(".level_error")[num]).hide()
70
+            $(input).removeClass("error_input");
71
+            points += 1;
72
+        }
73
+    })
74
+	if (points == 8) // all good
75
+	{
76
+		$('#all_good').show();
77
+	}
78
+	else if (points == 0) // nothing good
79
+	{
80
+		$('#no_good').show();
81
+	}
82
+	else // some good some bad
83
+	{
84
+		$('#some_good').show();
85
+	}
86
+	return (8- points);
87
+}
88
+
89
+function check_fill(answers)
90
+{
91
+	$('#dockerfile_ok').hide();
92
+	$('#dockerfile_ko').hide();
93
+
94
+	var errors = 0;
95
+
96
+    $.each($(".l_fill"), function(num, input){
97
+        var cleaned = clean_up(input.value);
98
+        var id = input.id;
99
+        if (answers[id] != cleaned) {
100
+            $(input).addClass("error_input");
101
+            errors += 1;
102
+        } else {
103
+            $(input).removeClass("error_input");
104
+        }
105
+    });
106
+
107
+	if (errors != 0)
108
+	{
109
+		$('#dockerfile_ko').show();
110
+	}
111
+	else
112
+	{
113
+		$('#dockerfile_ok').show();
114
+	}
115
+	return (errors);
116
+}
117
+
118
+$(document).ready(function() {
119
+
120
+    $("#check_level1_questions").click( function(){
121
+        errors = check_form1();
122
+        dockerfile_log(1, '1_questions', errors);
123
+       }
124
+    );
125
+
126
+    $("#check_level1_fill").click( function(){
127
+        var answers = {};
128
+        answers['from'] = 'FROM';
129
+        answers['ubuntu'] = 'UNTU';
130
+        answers['maintainer'] = 'MAINTAINER';
131
+        answers['eric'] = 'RIC';
132
+        answers['bardin'] = 'ARDIN';
133
+        answers['run0'] = 'RUN';
134
+        answers['run1'] = 'RUN';
135
+        answers['run2'] = 'RUN';
136
+        answers['memcached'] = 'MEMCACHED';
137
+
138
+        var errors = check_fill(answers);
139
+        dockerfile_log(1, '2_fill', errors);
140
+    });
141
+
142
+    $("#check_level2_questions").click( function(){
143
+        errors = check_form2();
144
+        dockerfile_log(2, '1_questions', errors);
145
+       }
146
+    );
147
+
148
+    $("#check_level2_fill").click( function(){
149
+        var answers = {};
150
+        answers['from'] = "FROM";
151
+        answers['ubuntu'] = "UNTU";
152
+        answers['maintainer'] = "AINER";
153
+        answers['roberto'] = "BERTO";
154
+        answers['hashioka'] = "SHIOKA";
155
+        answers['run0'] = "RUN";
156
+        answers['run1'] = "RUN";
157
+        answers['run2'] = "RUN";
158
+        answers['run3'] = "RUN";
159
+        answers['run4'] = "RUN";
160
+        answers['run5'] = "RUN";
161
+        answers['run6'] = "RUN";
162
+        answers['entrypoint'] = "ENTRYPOINT";
163
+        answers['user'] = "USER";
164
+        answers['expose'] = "EXPOSE";
165
+        answers['gcc'] = "GCC";
166
+
167
+        var errors = check_fill(answers);
168
+        dockerfile_log(2, '2_fill', errors);
169
+    });
170
+
171
+    $(".btn.btn-primary.back").click( function(event){
172
+        event.preventDefault();
173
+        window.history.back();
174
+    })
175
+});
0 176
new file mode 100644
... ...
@@ -0,0 +1,90 @@
0
+/*!
1
+ * jQuery Cookie Plugin v1.3.1
2
+ * https://github.com/carhartl/jquery-cookie
3
+ *
4
+ * Copyright 2013 Klaus Hartl
5
+ * Released under the MIT license
6
+ */
7
+(function ($, document, undefined) {
8
+
9
+	var pluses = /\+/g;
10
+
11
+	function raw(s) {
12
+		return s;
13
+	}
14
+
15
+	function decoded(s) {
16
+		return unRfc2068(decodeURIComponent(s.replace(pluses, ' ')));
17
+	}
18
+
19
+	function unRfc2068(value) {
20
+		if (value.indexOf('"') === 0) {
21
+			// This is a quoted cookie as according to RFC2068, unescape
22
+			value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
23
+		}
24
+		return value;
25
+	}
26
+
27
+	function fromJSON(value) {
28
+		return config.json ? JSON.parse(value) : value;
29
+	}
30
+
31
+	var config = $.cookie = function (key, value, options) {
32
+
33
+		// write
34
+		if (value !== undefined) {
35
+			options = $.extend({}, config.defaults, options);
36
+
37
+			if (value === null) {
38
+				options.expires = -1;
39
+			}
40
+
41
+			if (typeof options.expires === 'number') {
42
+				var days = options.expires, t = options.expires = new Date();
43
+				t.setDate(t.getDate() + days);
44
+			}
45
+
46
+			value = config.json ? JSON.stringify(value) : String(value);
47
+
48
+			return (document.cookie = [
49
+				encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
50
+				options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
51
+				options.path    ? '; path=' + options.path : '',
52
+				options.domain  ? '; domain=' + options.domain : '',
53
+				options.secure  ? '; secure' : ''
54
+			].join(''));
55
+		}
56
+
57
+		// read
58
+		var decode = config.raw ? raw : decoded;
59
+		var cookies = document.cookie.split('; ');
60
+		var result = key ? null : {};
61
+		for (var i = 0, l = cookies.length; i < l; i++) {
62
+			var parts = cookies[i].split('=');
63
+			var name = decode(parts.shift());
64
+			var cookie = decode(parts.join('='));
65
+
66
+			if (key && key === name) {
67
+				result = fromJSON(cookie);
68
+				break;
69
+			}
70
+
71
+			if (!key) {
72
+				result[name] = fromJSON(cookie);
73
+			}
74
+		}
75
+
76
+		return result;
77
+	};
78
+
79
+	config.defaults = {};
80
+
81
+	$.removeCookie = function (key, options) {
82
+		if ($.cookie(key) !== null) {
83
+			$.cookie(key, null, options);
84
+			return true;
85
+		}
86
+		return false;
87
+	};
88
+
89
+})(jQuery, document);