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

Unified Diff: tests/ruby/ruby.js

Issue 440018: Ruby for NaCl. Please assign the appropriate reviewer. (Closed) Base URL: http://nativeclient.googlecode.com/svn/trunk/src/native_client/
Patch Set: '' Created 11 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/ruby/ruby.html ('k') | tests/ruby/stdin » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ruby/ruby.js
===================================================================
--- tests/ruby/ruby.js (revision 0)
+++ tests/ruby/ruby.js (revision 0)
@@ -0,0 +1,49 @@
+/* Copyright 2009 The Native Client Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can
+ * be found in the LICENSE file. */
+
+var client;
+var ruby;
+
+var PostInit = function() {
+ if (client == undefined) {
+ alert('Unable to load, try reloading page (or missing plugins?)');
+ return;
+ }
+ if (client.rubyEval === undefined) {
+ setTimeout(PostInit, 100);
+ } else {
+ document.getElementById("output").innerHTML = "Ruby is loaded<br>";
+ }
+}
+
+function escapeHTML(html) {
+ if (html === null || typeof(html) == "undefined") {
+ return "";
+ }
+ return html.replace(/&/g,'&amp;').replace(/>/g,'&gt;').
+ replace(/</g,'&lt;').replace(/"/g,'&quot;');
+}
+
+function start() {
+ client = document.getElementById('client');
+ PostInit();
+}
+
+function doExecute() {
+ var element = document.getElementById('rubyCode');
+ var code = element.value;
+ document.getElementById('output').innerHTML +=
+ ("&gt; " + code + "<br>").replace('\n', '<br>');
+ element.value = '';
+ try {
+ if (code.indexOf("puts ") != 0) {
+ code = "puts " + code;
+ }
+ var result = client.rubyEval(code);
+ document.getElementById('output').innerHTML +=
+ escapeHTML(result).replace('\n', '<br>');
+ } catch (e) {
+ alert('error while executing Ruby code "' + code + '" err:' + e);
+ }
+}
Property changes on: tests/ruby/ruby.js
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « tests/ruby/ruby.html ('k') | tests/ruby/stdin » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698