root.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <!--{
  2. "Path": "/",
  3. "Template": true
  4. }-->
  5. <div class="left">
  6. <div id="learn">
  7. {{if not $.GoogleCN}}
  8. <a class="popout share">Pop-out</a>
  9. {{end}}
  10. <div class="rootHeading">Try Go</div>
  11. <div class="input">
  12. <textarea spellcheck="false" class="code">// You can edit this code!
  13. // Click here and start typing.
  14. package main
  15. import "fmt"
  16. func main() {
  17. fmt.Println("Hello, 世界")
  18. }</textarea>
  19. </div>
  20. <div class="output">
  21. <pre>
  22. Hello, 世界
  23. </pre>
  24. </div>
  25. <div class="buttons">
  26. <a class="run" href="#" title="Run this code [shift-enter]">Run</a>
  27. {{if not $.GoogleCN}}
  28. <a class="share" href="#" title="Share this code">Share</a>
  29. <a class="tour" href="//tour.golang.org/" title="Learn Go from your browser">Tour</a>
  30. {{end}}
  31. </div>
  32. <div class="toys">
  33. <select>
  34. <option value="hello.go">Hello, World!</option>
  35. <option value="life.go">Conway's Game of Life</option>
  36. <option value="fib.go">Fibonacci Closure</option>
  37. <option value="peano.go">Peano Integers</option>
  38. <option value="pi.go">Concurrent pi</option>
  39. <option value="sieve.go">Concurrent Prime Sieve</option>
  40. <option value="solitaire.go">Peg Solitaire Solver</option>
  41. <option value="tree.go">Tree Comparison</option>
  42. </select>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="right">
  47. <div id="about">
  48. Go is an open source programming language that makes it easy to build
  49. simple, reliable, and efficient software.
  50. </div>
  51. <div id="gopher"></div>
  52. <a href="/dl/" id="start">
  53. <span class="big">Download Go</span>
  54. <span class="desc">
  55. Binary distributions available for<br>
  56. Linux, macOS, Windows, and more.
  57. </span>
  58. </a>
  59. </div>
  60. <div style="clear: both"></div>
  61. {{if not $.GoogleCN}}
  62. <div class="left">
  63. <div id="video">
  64. <div class="rootHeading">Featured video</div>
  65. <div class="js-frontpage-video" style="--aspect-ratio-padding: 58.07%;"><iframe width="415" height="241" src="//www.youtube.com/embed/ytEkHepK08c" frameborder="0" allowfullscreen></iframe></div>
  66. </div>
  67. </div>
  68. <div class="right">
  69. <div id="blog">
  70. <div class="rootHeading">Featured articles</div>
  71. <div class="read"><a href="//blog.golang.org/">Read more</a></div>
  72. </div>
  73. </div>
  74. {{end}}
  75. <div style="clear: both;"></div>
  76. <script>
  77. (function() {
  78. 'use strict';
  79. window.initFuncs.push(function() {
  80. // Set up playground if enabled.
  81. if (window.playground) {
  82. window.playground({
  83. "codeEl": "#learn .code",
  84. "outputEl": "#learn .output",
  85. "runEl": "#learn .run",
  86. "shareEl": "#learn .share",
  87. "shareRedirect": "//play.golang.org/p/",
  88. "toysEl": "#learn .toys select"
  89. });
  90. } else {
  91. $('#learn').hide()
  92. }
  93. });
  94. {{if not $.GoogleCN}}
  95. function readableTime(t) {
  96. var m = ["January", "February", "March", "April", "May", "June", "July",
  97. "August", "September", "October", "November", "December"];
  98. var p = t.substring(0, t.indexOf("T")).split("-");
  99. var d = new Date(p[0], p[1]-1, p[2]);
  100. return d.getDate() + " " + m[d.getMonth()] + " " + d.getFullYear();
  101. }
  102. window.feedLoaded = function(result) {
  103. var blog = document.getElementById("blog");
  104. var read = blog.getElementsByClassName("read")[0];
  105. for (var i = 0; i < result.length && i < 2; i++) {
  106. var entry = result[i];
  107. var title = document.createElement("a");
  108. title.className = "title";
  109. title.href = entry.Link;
  110. title.innerHTML = entry.Title;
  111. blog.insertBefore(title, read);
  112. var extract = document.createElement("div");
  113. extract.className = "extract";
  114. extract.innerHTML = entry.Summary;
  115. blog.insertBefore(extract, read);
  116. var when = document.createElement("div");
  117. when.className = "when";
  118. when.innerHTML = "Published " + readableTime(entry.Time);
  119. blog.insertBefore(when, read);
  120. }
  121. }
  122. window.initFuncs.push(function() {
  123. // Load blog feed.
  124. $('<script/>').attr('text', 'text/javascript')
  125. .attr('src', '//blog.golang.org/.json?jsonp=feedLoaded')
  126. .appendTo('body');
  127. // Set the video at random.
  128. var videos = [
  129. {h: 241, s: "//www.youtube.com/embed/ytEkHepK08c"}, // Tour of Go
  130. {h: 241, s: "//www.youtube.com/embed/f6kdp27TYZs"}, // Concurrency Patterns
  131. {h: 233, s: "//player.vimeo.com/video/69237265"} // Simple environment
  132. ];
  133. var v = videos[Math.floor(Math.random()*videos.length)];
  134. $('#video iframe').attr('height', v.h).attr('src', v.s);
  135. // Compute the aspect ratio (as a percentage) of the video
  136. // using the fixed width 415 and the height of the current video, v.h.
  137. var ar = 100*v.h/415;
  138. $('.js-frontpage-video').attr('style', '--aspect-ratio-padding: ' + ar + '%;');
  139. });
  140. {{end}}
  141. })();
  142. </script>