Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

Commit 9a7f57f

Browse files
committed
Merge pull request #35 from jasonkliu/14652_frontpage_style
14652 frontpage style
2 parents 733197a + 2c3a69e commit 9a7f57f

File tree

4 files changed

+71
-12
lines changed

4 files changed

+71
-12
lines changed

css/style.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
font-weight: 500;
1717
src: local('Fira Sans Medium'), url("../fonts/FiraSans-Medium.woff") format('woff');
1818
}
19+
@font-face {
20+
font-family: 'fontello';
21+
src: url('../fonts/fontello.svg?32953337#fontello') format('svg');
22+
font-weight: normal;
23+
font-style: normal;
24+
}
1925

2026
body {
2127
font-family: 'Fira Sans', "Helvetica Neue", Helvetica, Arial, sans-serif;
@@ -277,6 +283,34 @@ ul.laundry-list {
277283
outline: none;
278284
}
279285

286+
[class^="icon-"]:before, [class*=" icon-"]:before {
287+
font-family: "fontello";
288+
font-style: normal;
289+
font-weight: normal;
290+
speak: none;
291+
292+
display: inline-block;
293+
text-decoration: inherit;
294+
width: 1em;
295+
margin-right: .2em;
296+
text-align: center;
297+
/* opacity: .8; */
298+
299+
/* For safety - reset parent styles, that can break glyph codes*/
300+
font-variant: normal;
301+
text-transform: none;
302+
303+
/* fix buttons height, for twitter bootstrap */
304+
line-height: 1em;
305+
306+
position: relative;
307+
float: right;
308+
font-size: 120%;
309+
310+
}
311+
312+
.icon-link-ext:before { content: '\e800'; } /* '' */
313+
280314
#result {
281315
background-color: #E2EEF6;
282316
margin-top: 10px;

fonts/fontello.svg

Lines changed: 12 additions & 0 deletions
Loading

index.html

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ <h2>Featuring</h2>
4949
<div id="editor">// This code is editable and runnable!
5050
fn main() {
5151
// A simple integer calculator:
52-
// `+` or `-` means add/sub by 1
53-
// `*` or `/` means mul/div by 2
52+
// `+` or `-` means add or subtract by 1
53+
// `*` or `/` means multiply or divide by 2
5454

5555
let program = "+ + * - /";
5656
let mut accumulator = 0;
@@ -65,17 +65,19 @@ <h2>Featuring</h2>
6565
}
6666
}
6767

68-
println!("The program \"{}\" calculates the value {}",
69-
program, accumulator);
68+
println!("The program \"{}\" calculates the value {}",
69+
program, accumulator);
7070
}</div>
71-
<div id="result"></div>
71+
<div id="result">
72+
<a id="playlink" onclick="f1()" href="http://play.rust-lang.org/"><i class="icon-link-ext"></i></a>
73+
</div>
7274
</div>
7375
<div id="static-code">
7476
<pre class='rust'>
7577
<span class='kw'>fn</span> main() {
7678
<span class='comment'>// A simple integer calculator:
77-
// `+` or `-` means add/sub by 1
78-
// `*` or `/` means mul/div by 2</span>
79+
// `+` or `-` means add or subtract by 1
80+
// `*` or `/` means multiply or divide by 2</span>
7981

8082
<span class='kw'>let</span> program = <span class='string'>"+ + * - /"</span>;
8183
<span class='kw'>let</span> <span class='kw'>mut</span> accumulator = <span class='number'>0</span>;
@@ -121,7 +123,7 @@ <h2>Featuring</h2>
121123

122124
return os;
123125
}
124-
126+
125127
var platform = detect_platform();
126128

127129
var rec_package_name = "nightly";
@@ -149,7 +151,7 @@ <h2>Featuring</h2>
149151
var rec_dl_addy = "http://static.rust-lang.org/dist/" + rec_download_file;
150152
var rec_inst_link = document.getElementById("inst-link");
151153
rec_inst_link.setAttribute("href", rec_dl_addy);
152-
154+
153155
</script>
154156
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/ace.js"></script>
155157
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/mode-rust.js"></script>

js/editor.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var editorDiv = document.getElementById("editor");
1414
var staticCode = document.getElementById("static-code");
1515
var runButton = document.getElementById("run-code");
1616
var resultDiv = document.getElementById("result");
17+
var playLink = document.getElementById("playlink");
1718

1819
// Background colors for program result on success/error
1920
var successColor = "#E2EEF6";
@@ -121,10 +122,15 @@ function handleResult(statusCode, message) {
121122
}
122123
}
123124

124-
// Called on successful program run
125+
// Called on successful program run: display output and link to playground
125126
function handleSuccess(message) {
126127
resultDiv.style.backgroundColor = successColor;
127-
resultDiv.innerHTML = escapeHTML(message);
128+
var program = encodeURIComponent(editor.getValue());
129+
playLink.href = "http://play.rust-lang.org/?code=" + program + "&run=1"
130+
// console.log(playLink.href);
131+
resultDiv.innerHTML = ''; // clear resultDiv, then add
132+
resultDiv.appendChild(playLink); // playLink icon and message
133+
resultDiv.innerHTML += escapeHTML(message);
128134
}
129135

130136
// Called when program run results in warning(s)
@@ -164,7 +170,12 @@ function handleProblem(message, problem) {
164170
}).join("<br />");
165171

166172
// Setting message
167-
resultDiv.innerHTML = cleanMessage;
173+
var program = encodeURIComponent(editor.getValue());
174+
playLink.href = "http://play.rust-lang.org/?code=" + program + "&run=1"
175+
// console.log(playLink.href);
176+
resultDiv.innerHTML = ''; // clear resultDiv, then add
177+
resultDiv.appendChild(playLink); // playLink icon and error message
178+
resultDiv.innerHTML += cleanMessage;
168179

169180
// Highlighting the lines
170181
var ranges = parseProblems(lines);

0 commit comments

Comments
 (0)