From e2e2376b7bcc5aaa370385fedaa8b0cd2e49fcdf Mon Sep 17 00:00:00 2001 From: Tobias Hintze Date: Fri, 2 Nov 2012 14:09:04 +0100 Subject: [PATCH] runtime.js fix closure-compiler complaints --- webodf/lib/runtime.js | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/webodf/lib/runtime.js b/webodf/lib/runtime.js index 8da07e73..02de5dfa 100644 --- a/webodf/lib/runtime.js +++ b/webodf/lib/runtime.js @@ -51,12 +51,20 @@ function Runtime() {"use strict"; } * @param {!number} size */ Runtime.ByteArray = function (size) {"use strict"; }; + +/** + * @param {!string} name + * @return {*} + */ +Runtime.prototype.getVariable = function (name) { "use strict"; }; + /** * @param {!number} start * @param {!number} end * @return {!Runtime.ByteArray} */ Runtime.ByteArray.prototype.slice = function (start, end) {"use strict"; }; + /** * @type {!number} */ @@ -232,6 +240,16 @@ Runtime.byteArrayToString = function (bytearray, encoding) { } return result; }; + +/** + * @param {!string} name + * @return {*} + */ +Runtime.getVariable = function (name) { + "use strict"; + return eval(name); +}; + Runtime.getFunctionName = function getFunctionName(f) { "use strict"; var m; @@ -355,6 +373,12 @@ function BrowserRuntime(logoutput) { }; this.byteArrayToString = Runtime.byteArrayToString; + /** + * @param {!string} name + * @return {*} + */ + this.getVariable = Runtime.getVariable; + /** * @param {!string} msgOrCategory * @param {string=} msg @@ -670,11 +694,11 @@ function BrowserRuntime(logoutput) { return window; }; this.getNetwork = function () { - try { - return now; - } catch (e) { + var now = this.getVariable("now"); + if (now === undefined) { return {networkStatus:"unavailable"}; } + return now; }; } @@ -724,6 +748,12 @@ function NodeJSRuntime() { return bytearray.toString(encoding); }; + /** + * @param {!string} name + * @return {*} + */ + this.getVariable = Runtime.getVariable; + function isFile(path, callback) { if (currentDirectory) { path = currentDirectory + "/" + path; @@ -914,6 +944,13 @@ function RhinoRuntime() { return a; }; this.byteArrayToString = Runtime.byteArrayToString; + + /** + * @param {!string} name + * @return {*} + */ + this.getVariable = Runtime.getVariable; + this.concatByteArrays = function (bytearray1, bytearray2) { return bytearray1.concat(bytearray2); };