From 30c50357bcb53b49823e6b8f9b49e610dc9b6856 Mon Sep 17 00:00:00 2001 From: Jason Liu Date: Thu, 5 Jun 2014 21:25:21 -0700 Subject: [PATCH 1/8] Fix println! spacing, clean up comments The '+'/'-' usage was confusing so I split the lines. In addition, I amended println! to conform to the 4 spaces for indentation as stated in the style guide. --- index.html | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index ef9bcdb9e..fd7f3abf8 100644 --- a/index.html +++ b/index.html @@ -49,8 +49,10 @@

Featuring

// This code is editable and runnable! fn main() { // A simple integer calculator: - // `+` or `-` means add/sub by 1 - // `*` or `/` means mul/div by 2 + // `+` denotes adding 1 + // `-` denotes subtracting 1 + // `*` denotes multiplying by 2 + // `/` denotes dividing by 2 let program = "+ + * - /"; let mut accumulator = 0; @@ -65,8 +67,8 @@

Featuring

} } - println!("The program \"{}\" calculates the value {}", - program, accumulator); + println!("The program \"{}\" calculates the value {}", + program, accumulator); }
@@ -74,8 +76,10 @@

Featuring

 fn main() {
     // A simple integer calculator:
-    // `+` or `-` means add/sub by 1
-    // `*` or `/` means mul/div by 2
+    // `+` denotes adding 1
+    // `-` denotes subtracting 1
+    // `*` denotes multiplying by 2
+    // `/` denotes dividing by 2
 
     let program = "+ + * - /";
     let mut accumulator = 0;

From f5d1755f9b6d60bac4ae2ed57ce759b234a80ee2 Mon Sep 17 00:00:00 2001
From: Jason Liu 
Date: Thu, 5 Jun 2014 21:43:19 -0700
Subject: [PATCH 2/8] Add Playground button

---
 css/style.css | 9 +++++++++
 index.html    | 1 +
 js/editor.js  | 6 ++++++
 3 files changed, 16 insertions(+)

diff --git a/css/style.css b/css/style.css
index be455e1f0..cb9ab6ecf 100644
--- a/css/style.css
+++ b/css/style.css
@@ -277,6 +277,15 @@ ul.laundry-list {
   outline: none;
 }
 
+#playground {
+  position: absolute;
+  z-index: 10;
+  float: right;
+  right: 8px;
+  top: 48px;
+  outline: none;
+}
+
 #result {
   background-color: #E2EEF6;
   margin-top: 10px;
diff --git a/index.html b/index.html
index fd7f3abf8..7ab7d3de9 100644
--- a/index.html
+++ b/index.html
@@ -46,6 +46,7 @@ 

Featuring

+
// This code is editable and runnable! fn main() { // A simple integer calculator: diff --git a/js/editor.js b/js/editor.js index 3b8eb8445..55b71796f 100644 --- a/js/editor.js +++ b/js/editor.js @@ -13,6 +13,7 @@ var activeCode = document.getElementById("active-code"); var editorDiv = document.getElementById("editor"); var staticCode = document.getElementById("static-code"); var runButton = document.getElementById("run-code"); +var playButton = document.getElementById("playground"); var resultDiv = document.getElementById("result"); // Background colors for program result on success/error @@ -210,6 +211,11 @@ runButton.addEventListener("click", function(ev) { runProgram(program, handleResult); }); +// Navigate to playground, TODO: Get code from editor and paste into playground +playButton.addEventListener("click", function(ev) { + window.location = "http://play.rust-lang.org/" +}); + // Highlight active line when focused editor.on('focus', function() { editor.setHighlightActiveLine(true); From 28ec203b1b0fd499ed995f9a9aacac60d55a572f Mon Sep 17 00:00:00 2001 From: Jason Liu Date: Fri, 6 Jun 2014 15:55:31 -0700 Subject: [PATCH 3/8] Add Font-awesome output button to result div --- index.html | 2 +- js/editor.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 7ab7d3de9..296481586 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,7 @@ title: The Rust Programming Language --- +

@@ -46,7 +47,6 @@

Featuring

-
// This code is editable and runnable! fn main() { // A simple integer calculator: diff --git a/js/editor.js b/js/editor.js index 55b71796f..a29611078 100644 --- a/js/editor.js +++ b/js/editor.js @@ -125,7 +125,8 @@ function handleResult(statusCode, message) { // Called on successful program run function handleSuccess(message) { resultDiv.style.backgroundColor = successColor; - resultDiv.innerHTML = escapeHTML(message); + var outputbutton = "" + resultDiv.innerHTML = escapeHTML(message).replace(/(
)*/g,"") + outputbutton + "
"; } // Called when program run results in warning(s) From ee08e9db403c2856a9f42ee0dc54aec664bd1a16 Mon Sep 17 00:00:00 2001 From: Jason Liu Date: Fri, 6 Jun 2014 16:22:32 -0700 Subject: [PATCH 4/8] Take Editor contents and run them in the Rust playground --- css/style.css | 5 +++++ js/editor.js | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/css/style.css b/css/style.css index cb9ab6ecf..da2a6845a 100644 --- a/css/style.css +++ b/css/style.css @@ -286,6 +286,11 @@ ul.laundry-list { outline: none; } +.fa-external-link { + position: relative; + float: right; +} + #result { background-color: #E2EEF6; margin-top: 10px; diff --git a/js/editor.js b/js/editor.js index a29611078..ca93b8140 100644 --- a/js/editor.js +++ b/js/editor.js @@ -122,11 +122,14 @@ function handleResult(statusCode, message) { } } -// Called on successful program run +// Called on successful program run: take edit contents and run in playground function handleSuccess(message) { resultDiv.style.backgroundColor = successColor; - var outputbutton = "" - resultDiv.innerHTML = escapeHTML(message).replace(/(
)*/g,"") + outputbutton + "
"; + var program = encodeURIComponent(editor.getValue()); + var output = "" + // console.log(output); + resultDiv.innerHTML = escapeHTML(message).replace(/(
)*/g,"") + output; } // Called when program run results in warning(s) @@ -213,9 +216,9 @@ runButton.addEventListener("click", function(ev) { }); // Navigate to playground, TODO: Get code from editor and paste into playground -playButton.addEventListener("click", function(ev) { +/*playButton.addEventListener("click", function(ev) { window.location = "http://play.rust-lang.org/" -}); +});*/ // Highlight active line when focused editor.on('focus', function() { From 88aa1ef98825c76066ef50fd2cfbad7813b55560 Mon Sep 17 00:00:00 2001 From: Jason Liu Date: Fri, 6 Jun 2014 16:27:35 -0700 Subject: [PATCH 5/8] Modify comments to add/subtract/multiply/divide, remove playground button --- css/style.css | 9 --------- index.html | 12 ++++-------- js/editor.js | 6 ------ 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/css/style.css b/css/style.css index da2a6845a..68e070151 100644 --- a/css/style.css +++ b/css/style.css @@ -277,15 +277,6 @@ ul.laundry-list { outline: none; } -#playground { - position: absolute; - z-index: 10; - float: right; - right: 8px; - top: 48px; - outline: none; -} - .fa-external-link { position: relative; float: right; diff --git a/index.html b/index.html index 296481586..de4572aa9 100644 --- a/index.html +++ b/index.html @@ -50,10 +50,8 @@

Featuring

// This code is editable and runnable! fn main() { // A simple integer calculator: - // `+` denotes adding 1 - // `-` denotes subtracting 1 - // `*` denotes multiplying by 2 - // `/` denotes dividing by 2 + // `+` or `-` means add or subtract by 1 + // `*` or `/` means multiply or divide by 2 let program = "+ + * - /"; let mut accumulator = 0; @@ -77,10 +75,8 @@

Featuring

 fn main() {
     // A simple integer calculator:
-    // `+` denotes adding 1
-    // `-` denotes subtracting 1
-    // `*` denotes multiplying by 2
-    // `/` denotes dividing by 2
+    // `+` or `-` means add or subtract by 1
+    // `*` or `/` means multiply or divide by 2
 
     let program = "+ + * - /";
     let mut accumulator = 0;
diff --git a/js/editor.js b/js/editor.js
index ca93b8140..2a14bf71c 100644
--- a/js/editor.js
+++ b/js/editor.js
@@ -13,7 +13,6 @@ var activeCode = document.getElementById("active-code");
 var editorDiv = document.getElementById("editor");
 var staticCode = document.getElementById("static-code");
 var runButton = document.getElementById("run-code");
-var playButton = document.getElementById("playground");
 var resultDiv = document.getElementById("result");
 
 // Background colors for program result on success/error
@@ -215,11 +214,6 @@ runButton.addEventListener("click", function(ev) {
   runProgram(program, handleResult);
 });
 
-// Navigate to playground, TODO: Get code from editor and paste into playground
-/*playButton.addEventListener("click", function(ev) {
-  window.location = "http://play.rust-lang.org/"
-});*/
-
 // Highlight active line when focused
 editor.on('focus', function() {
   editor.setHighlightActiveLine(true);

From 8e003316487ad1cde7aeea68921c7a5689ffaedc Mon Sep 17 00:00:00 2001
From: Jason Liu 
Date: Fri, 6 Jun 2014 16:34:48 -0700
Subject: [PATCH 6/8] Remove the replacement of line breaks by putting output
 button first

---
 js/editor.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/js/editor.js b/js/editor.js
index 2a14bf71c..23b2c73cb 100644
--- a/js/editor.js
+++ b/js/editor.js
@@ -128,7 +128,7 @@ function handleSuccess(message) {
   var output = ""
   // console.log(output);
-  resultDiv.innerHTML = escapeHTML(message).replace(/(
)*/g,"") + output; + resultDiv.innerHTML = output + escapeHTML(message); } // Called when program run results in warning(s) From 6b6f66714f9f692a8c5959d437578be41689c630 Mon Sep 17 00:00:00 2001 From: Jason Liu Date: Tue, 10 Jun 2014 21:44:17 -0700 Subject: [PATCH 7/8] Replace font-awesome css with fontello svg font --- css/style.css | 31 ++++++++++++++++++++++++++++++- fonts/fontello.svg | 12 ++++++++++++ index.html | 1 - js/editor.js | 4 ++-- 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 fonts/fontello.svg diff --git a/css/style.css b/css/style.css index 68e070151..564398013 100644 --- a/css/style.css +++ b/css/style.css @@ -16,6 +16,12 @@ font-weight: 500; src: local('Fira Sans Medium'), url("../fonts/FiraSans-Medium.woff") format('woff'); } +@font-face { + font-family: 'fontello'; + src: url('../fonts/fontello.svg?32953337#fontello') format('svg'); + font-weight: normal; + font-style: normal; +} body { font-family: 'Fira Sans', "Helvetica Neue", Helvetica, Arial, sans-serif; @@ -277,10 +283,33 @@ ul.laundry-list { outline: none; } -.fa-external-link { + [class^="icon-"]:before, [class*=" icon-"]:before { + font-family: "fontello"; + font-style: normal; + font-weight: normal; + speak: none; + + display: inline-block; + text-decoration: inherit; + width: 1em; + margin-right: .2em; + text-align: center; + /* opacity: .8; */ + + /* For safety - reset parent styles, that can break glyph codes*/ + font-variant: normal; + text-transform: none; + + /* fix buttons height, for twitter bootstrap */ + line-height: 1em; + position: relative; float: right; + font-size: 120%; + } + +.icon-link-ext:before { content: '\e800'; } /* '' */ #result { background-color: #E2EEF6; diff --git a/fonts/fontello.svg b/fonts/fontello.svg new file mode 100644 index 000000000..58293ec65 --- /dev/null +++ b/fonts/fontello.svg @@ -0,0 +1,12 @@ + + + +Copyright (C) 2014 by original authors @ fontello.com + + + + + + + + \ No newline at end of file diff --git a/index.html b/index.html index de4572aa9..2f738987f 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,6 @@ title: The Rust Programming Language --- -

diff --git a/js/editor.js b/js/editor.js index 23b2c73cb..8784f5c8d 100644 --- a/js/editor.js +++ b/js/editor.js @@ -121,12 +121,12 @@ function handleResult(statusCode, message) { } } -// Called on successful program run: take edit contents and run in playground +// Called on successful program run: display output and link to playground function handleSuccess(message) { resultDiv.style.backgroundColor = successColor; var program = encodeURIComponent(editor.getValue()); var output = "" + "&run=1\">" // console.log(output); resultDiv.innerHTML = output + escapeHTML(message); } From 2c3a69ea59651f1cbd4c928e5df20bf4c2e0bdce Mon Sep 17 00:00:00 2001 From: Jason Liu Date: Wed, 11 Jun 2014 00:09:10 -0700 Subject: [PATCH 8/8] Modify HTML link from editor.js, add playground link on error --- index.html | 8 +++++--- js/editor.js | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 2f738987f..af86051b0 100644 --- a/index.html +++ b/index.html @@ -68,7 +68,9 @@

Featuring

println!("The program \"{}\" calculates the value {}", program, accumulator); }
-
+
+ +
@@ -121,7 +123,7 @@ 

Featuring

return os; } - + var platform = detect_platform(); var rec_package_name = "nightly"; @@ -149,7 +151,7 @@

Featuring

var rec_dl_addy = "http://static.rust-lang.org/dist/" + rec_download_file; var rec_inst_link = document.getElementById("inst-link"); rec_inst_link.setAttribute("href", rec_dl_addy); - + diff --git a/js/editor.js b/js/editor.js index 8784f5c8d..20ac75179 100644 --- a/js/editor.js +++ b/js/editor.js @@ -14,6 +14,7 @@ var editorDiv = document.getElementById("editor"); var staticCode = document.getElementById("static-code"); var runButton = document.getElementById("run-code"); var resultDiv = document.getElementById("result"); +var playLink = document.getElementById("playlink"); // Background colors for program result on success/error var successColor = "#E2EEF6"; @@ -125,10 +126,11 @@ function handleResult(statusCode, message) { function handleSuccess(message) { resultDiv.style.backgroundColor = successColor; var program = encodeURIComponent(editor.getValue()); - var output = "" - // console.log(output); - resultDiv.innerHTML = output + escapeHTML(message); + playLink.href = "http://play.rust-lang.org/?code=" + program + "&run=1" + // console.log(playLink.href); + resultDiv.innerHTML = ''; // clear resultDiv, then add + resultDiv.appendChild(playLink); // playLink icon and message + resultDiv.innerHTML += escapeHTML(message); } // Called when program run results in warning(s) @@ -168,7 +170,12 @@ function handleProblem(message, problem) { }).join("
"); // Setting message - resultDiv.innerHTML = cleanMessage; + var program = encodeURIComponent(editor.getValue()); + playLink.href = "http://play.rust-lang.org/?code=" + program + "&run=1" + // console.log(playLink.href); + resultDiv.innerHTML = ''; // clear resultDiv, then add + resultDiv.appendChild(playLink); // playLink icon and error message + resultDiv.innerHTML += cleanMessage; // Highlighting the lines var ranges = parseProblems(lines);