Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: src/site/_includes/samples.html

Issue 10788006: new site (Closed) Base URL: https://code.google.com/p/dartlang-site/@master
Patch Set: final patch Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/site/_includes/nav.html ('k') | src/site/_layouts/default.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 {% comment %}
2 So you want to add more samples:
3 1 - Create a new pre element below containing the code you want to show.
4 2 - Give it a unique id of the form "sample-name"
5 3 - In the main page, add a new option to the select element and make sure value matches
6 the name from step #2.
7
8 TODO: These samples are just place holders and should be replaced with something real.
9 {% endcomment %}
10 <div style="display:none">
11
12 {% comment %} hello dart {% endcomment %}
13 <pre id="sample-hello">main() {
14 print('Hello, Dart!');
15 }</pre>
16
17
18 {% comment %} fibonacci {% endcomment %}
19 <pre id="sample-fib">int fib(int n) {
20 if (n &lt;= 1) return n;
21 return fib(n - 1) + fib(n - 2);
22 }
23
24 main() {
25 print('fib(20) = ${fib(20)}');
26 }</pre>
27
28
29 {% comment %} point{% endcomment %}
30 <pre id="sample-point">class Point {
31 Point(this.x, this.y);
32 distanceTo(Point other) {
33 var dx = x - other.x;
34 var dy = y - other.y;
35 return Math.sqrt(dx * dx + dy * dy);
36 }
37 var x, y;
38 }
39
40 main() {
41 Point p = new Point(2, 3);
42 Point q = new Point(3, 4);
43 print('distance from p to q = ${p.distanceTo(q)}');
44 }
45 </pre>
46
47 </div>
48
49 <script type="text/javascript">
50 function show(name) {
51 var editor = document.getElementById('samples-editor');
52 var code = document.getElementById('sample-' + name);
53 if (editor.setCode)
54 editor.setCode(code.textContent);
55 else if (editor.textContent)
56 editor.textContent = code.textContent;
57 else
58 editor.innerText = code.innerText;
59 }
60
61 window.addEventListener('load', function(e) {
62 var list = document.getElementById('samples-list');
63 document.getElementById('samples-list').addEventListener('change', functio n(e) {
64 show(list.value);
65 }, false);
66 }, false);
67 </script>
68
OLDNEW
« no previous file with comments | « src/site/_includes/nav.html ('k') | src/site/_layouts/default.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698