summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe George <joe@zeroc.com>2014-10-17 16:28:27 -0400
committerJoe George <joe@zeroc.com>2014-10-17 16:33:12 -0400
commitcc9944e8dd541c92dbf553f5a0065670f16c8d54 (patch)
tree155315f48eee6f641e484a34a57b76ca59194dc4
parentFixed (ICE-5747) - Support for THIRDPARTY_HOME on OS X (diff)
downloadice-cc9944e8dd541c92dbf553f5a0065670f16c8d54.tar.bz2
ice-cc9944e8dd541c92dbf553f5a0065670f16c8d54.tar.xz
ice-cc9944e8dd541c92dbf553f5a0065670f16c8d54.zip
Cleanup javascript demos
- Added jshintrc files to browser folders - Linted all of the demos
-rw-r--r--js/.jshintrc8
-rw-r--r--js/demo/.jshint_browser11
-rw-r--r--js/demo/ChatDemo/.jshintrc3
-rw-r--r--js/demo/Glacier2/chat/Client.js22
-rw-r--r--js/demo/Glacier2/chat/browser/.jshintrc3
-rw-r--r--js/demo/Glacier2/chat/browser/Client.js2
-rw-r--r--js/demo/Ice/bidir/browser/.jshintrc3
-rw-r--r--js/demo/Ice/bidir/browser/Client.js2
-rw-r--r--js/demo/Ice/hello/browser/.jshintrc3
-rw-r--r--js/demo/Ice/hello/browser/Client.js44
-rw-r--r--js/demo/Ice/latency/Client.js14
-rw-r--r--js/demo/Ice/latency/browser/.jshintrc3
-rw-r--r--js/demo/Ice/latency/browser/Client.js4
-rw-r--r--js/demo/Ice/minimal/browser/.jshintrc3
-rw-r--r--js/demo/Ice/throughput/Client.js3
-rw-r--r--js/demo/Ice/throughput/browser/.jshintrc3
-rw-r--r--js/demo/Ice/throughput/browser/Client.js13
17 files changed, 88 insertions, 56 deletions
diff --git a/js/.jshintrc b/js/.jshintrc
index d356ee0b89c..a2c6f25b486 100644
--- a/js/.jshintrc
+++ b/js/.jshintrc
@@ -2,12 +2,12 @@
"node": true,
"undef": true,
"evil": true,
- "globals":
+ "globals":
{
- "WebSocket" : false,
- "window": false,
+ "WebSocket" : false,
+ "window": false,
"navigator": false,
- "escape" : false,
+ "escape" : false,
"unescape": false
},
"predef": ["-Promise"]
diff --git a/js/demo/.jshint_browser b/js/demo/.jshint_browser
new file mode 100644
index 00000000000..20532c8ef4f
--- /dev/null
+++ b/js/demo/.jshint_browser
@@ -0,0 +1,11 @@
+{
+ "extends" : "../.jshintrc",
+ "browser" : true,
+ "jquery" : true,
+ "globals": {
+ "Ice" : false,
+ "Glacier2" : false,
+ "Chat" : false,
+ "Demo": false
+ }
+} \ No newline at end of file
diff --git a/js/demo/ChatDemo/.jshintrc b/js/demo/ChatDemo/.jshintrc
new file mode 100644
index 00000000000..650dcf41faf
--- /dev/null
+++ b/js/demo/ChatDemo/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "extends" : "../.jshint_browser"
+} \ No newline at end of file
diff --git a/js/demo/Glacier2/chat/Client.js b/js/demo/Glacier2/chat/Client.js
index 279f88103c9..581d4752e0a 100644
--- a/js/demo/Glacier2/chat/Client.js
+++ b/js/demo/Glacier2/chat/Client.js
@@ -41,7 +41,7 @@ process.once("SIGINT", function() {
});
Ice.Promise.try(
- function()
+ function()
{
//
// Initialize the communicator with Ice.Default.Router property
@@ -51,7 +51,7 @@ Ice.Promise.try(
id.properties = Ice.createProperties();
id.properties.setProperty("Ice.Default.Router", "DemoGlacier2/router:tcp -p 4063 -h localhost");
communicator = Ice.initialize(process.argv, id);
-
+
function createSession()
{
return Ice.Promise.try(
@@ -107,8 +107,8 @@ Ice.Promise.try(
}
});
});
- };
-
+ }
+
function runWithSession(router, session)
{
var p = new Ice.Promise();
@@ -130,9 +130,9 @@ Ice.Promise.try(
var timeout = timeoutA[0];
var category = categoryA[0];
var adapter = adapterA[0];
-
+
//
- // Call refreshSession in a loop to keep the
+ // Call refreshSession in a loop to keep the
// session alive.
//
var refreshSession = function()
@@ -152,13 +152,13 @@ Ice.Promise.try(
});
};
refreshSession();
-
+
//
// Create the ChatCallback servant and add it to the ObjectAdapter.
//
var callback = Demo.ChatCallbackPrx.uncheckedCast(
adapter.add(new ChatCallbackI(), new Ice.Identity("callback", category)));
-
+
//
// Set the chat session callback.
//
@@ -181,7 +181,7 @@ Ice.Promise.try(
{
p.succeed();
}
- else if(msg.indexOf("/") == 0)
+ else if(msg.indexOf("/") === 0)
{
console.log("enter /quit to exit.");
}
@@ -204,7 +204,7 @@ Ice.Promise.try(
p.fail(ex);
});
}
-
+
//
// Start the chat loop
//
@@ -259,7 +259,7 @@ var getline = function()
{
var p = new Ice.Promise();
process.stdin.resume();
- process.stdin.once("data",
+ process.stdin.once("data",
function(buffer)
{
process.stdin.pause();
diff --git a/js/demo/Glacier2/chat/browser/.jshintrc b/js/demo/Glacier2/chat/browser/.jshintrc
new file mode 100644
index 00000000000..5864f15ac92
--- /dev/null
+++ b/js/demo/Glacier2/chat/browser/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "extends" : "../../../.jshint_browser"
+} \ No newline at end of file
diff --git a/js/demo/Glacier2/chat/browser/Client.js b/js/demo/Glacier2/chat/browser/Client.js
index 1f905448325..3ea899f14a1 100644
--- a/js/demo/Glacier2/chat/browser/Client.js
+++ b/js/demo/Glacier2/chat/browser/Client.js
@@ -377,7 +377,7 @@ function dismissError()
transition("#signin-alert");
hasError = false;
return false;
-};
+}
//
// Animate the loading progress bar.
diff --git a/js/demo/Ice/bidir/browser/.jshintrc b/js/demo/Ice/bidir/browser/.jshintrc
new file mode 100644
index 00000000000..5864f15ac92
--- /dev/null
+++ b/js/demo/Ice/bidir/browser/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "extends" : "../../../.jshint_browser"
+} \ No newline at end of file
diff --git a/js/demo/Ice/bidir/browser/Client.js b/js/demo/Ice/bidir/browser/Client.js
index ca44be729be..694701251e9 100644
--- a/js/demo/Ice/bidir/browser/Client.js
+++ b/js/demo/Ice/bidir/browser/Client.js
@@ -163,7 +163,7 @@ var writeLine = function(msg)
{
$("#output").val($("#output").val() + msg + "\n");
$("#output").scrollTop($("#output").get(0).scrollHeight);
-}
+};
var state;
diff --git a/js/demo/Ice/hello/browser/.jshintrc b/js/demo/Ice/hello/browser/.jshintrc
new file mode 100644
index 00000000000..5864f15ac92
--- /dev/null
+++ b/js/demo/Ice/hello/browser/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "extends" : "../../../.jshint_browser"
+} \ No newline at end of file
diff --git a/js/demo/Ice/hello/browser/Client.js b/js/demo/Ice/hello/browser/Client.js
index c1a460ccb56..7b2bb04e018 100644
--- a/js/demo/Ice/hello/browser/Client.js
+++ b/js/demo/Ice/hello/browser/Client.js
@@ -20,8 +20,8 @@ var batch = 0;
function createProxy()
{
var hostname = document.location.hostname || "127.0.0.1";
- var proxy = communicator.stringToProxy("hello" +
- ":ws -h " + hostname + " -p 8080 -r /demows" +
+ var proxy = communicator.stringToProxy("hello" +
+ ":ws -h " + hostname + " -p 8080 -r /demows" +
":wss -h " + hostname + " -p 9090 -r /demowss");
//
@@ -32,7 +32,7 @@ function createProxy()
//
// Set the mode and protocol
- //
+ //
var mode = $("#mode").val();
if(mode == "twoway")
{
@@ -67,13 +67,13 @@ function createProxy()
function sayHello()
{
setState(State.SendRequest);
-
+
var proxy = createProxy();
if(proxy.ice_isBatchOneway())
{
batch++;
}
-
+
return proxy.sayHello($("#delay").val());
}
@@ -99,7 +99,7 @@ function shutdown()
{
batch++;
}
-
+
return proxy.shutdown();
}
@@ -108,7 +108,7 @@ function shutdown()
// event handler calls the given function, handles exceptions
// and resets the state to Idle when the promise returned by
// the function is fulfilled.
-//
+//
var performEventHandler = function(fn)
{
return function()
@@ -130,8 +130,8 @@ var performEventHandler = function(fn)
}
);
return false;
- }
-}
+ };
+};
var sayHelloClickHandler = performEventHandler(sayHello);
var shutdownClickHandler = performEventHandler(shutdown);
var flushClickHandler = performEventHandler(flush);
@@ -140,8 +140,8 @@ var flushClickHandler = performEventHandler(flush);
// Handle the client state.
//
var State = {
- Idle:0,
- SendRequest:1,
+ Idle:0,
+ SendRequest:1,
FlushBatchRequests:2
};
@@ -164,13 +164,13 @@ function setState(newState, ex)
case State.Idle:
{
assert(state === undefined || state === State.SendRequest || state === State.FlushBatchRequests);
-
+
//
// Hide the progress indicator.
//
$("#progress").hide();
$("body").removeClass("waiting");
-
+
//
// Enable buttons.
//
@@ -191,7 +191,7 @@ function setState(newState, ex)
// Reset the output.
//
$("#output").val("");
-
+
//
// Disable buttons.
//
@@ -210,7 +210,7 @@ function setState(newState, ex)
}
}
state = newState;
-};
+}
//
// Start in the idle state
@@ -237,24 +237,24 @@ if(window.location.search.length > 1)
//
// If the mode param is set, initialize the mode select box with that value.
//
-if(_GET["mode"])
+if(_GET.mode)
{
- $("#mode").val(_GET["mode"]);
+ $("#mode").val(_GET.mode);
}
//
-// If the user selects a secure mode, ensure that the page is loaded over HTTPS
+// If the user selects a secure mode, ensure that the page is loaded over HTTPS
// so the web server SSL certificate is obtained.
//
-$("#mode").on("change",
+$("#mode").on("change",
function(e)
{
var newMode = $(this).val();
-
- if(document.location.protocol === "http:" &&
+
+ if(document.location.protocol === "http:" &&
(newMode === "twoway-secure" || newMode === "oneway-secure" || newMode === "oneway-batch-secure"))
{
- var href = document.location.protocol + "//" + document.location.host +
+ var href = document.location.protocol + "//" + document.location.host +
document.location.pathname + "?mode=" + newMode;
href = href.replace("http", "https");
href = href.replace("8080", "9090");
diff --git a/js/demo/Ice/latency/Client.js b/js/demo/Ice/latency/Client.js
index 61781852193..9bc59b28839 100644
--- a/js/demo/Ice/latency/Client.js
+++ b/js/demo/Ice/latency/Client.js
@@ -15,11 +15,11 @@ var communicator;
//
// Asynchronous loop, each call to the given function returns a
// promise that when fulfilled runs the next iteration.
-//
+//
function loop(fn, repetitions)
{
var i = 0;
- var next = function()
+ var next = function()
{
if(i++ < repetitions)
{
@@ -33,13 +33,13 @@ Ice.Promise.try(
function()
{
//
- // Initialize the communicator and create a proxy to the
+ // Initialize the communicator and create a proxy to the
// ping object.
//
communicator = Ice.initialize(process.argv);
var repetitions = 10000;
var proxy = communicator.stringToProxy("ping:default -p 10000");
-
+
//
// Down-cast the proxy to the Demo.Ping interface.
//
@@ -47,9 +47,9 @@ Ice.Promise.try(
function(obj)
{
console.log("pinging server " + repetitions + " times (this may take a while)");
- start = new Date().getTime();
+ var start = new Date().getTime();
return loop(
- function()
+ function()
{
return obj.ice_ping();
},
@@ -60,7 +60,7 @@ Ice.Promise.try(
//
// Write the results.
//
- total = new Date().getTime() - start;
+ var total = new Date().getTime() - start;
console.log("time for " + repetitions + " pings: " + total + "ms");
console.log("time per ping: " + (total / repetitions) + "ms");
});
diff --git a/js/demo/Ice/latency/browser/.jshintrc b/js/demo/Ice/latency/browser/.jshintrc
new file mode 100644
index 00000000000..5864f15ac92
--- /dev/null
+++ b/js/demo/Ice/latency/browser/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "extends" : "../../../.jshint_browser"
+} \ No newline at end of file
diff --git a/js/demo/Ice/latency/browser/Client.js b/js/demo/Ice/latency/browser/Client.js
index b8344cfbfeb..5a99f8f4627 100644
--- a/js/demo/Ice/latency/browser/Client.js
+++ b/js/demo/Ice/latency/browser/Client.js
@@ -38,7 +38,7 @@ function run()
function(obj)
{
writeLine("pinging server " + repetitions + " times (this may take a while)");
- start = new Date().getTime();
+ var start = new Date().getTime();
return loop(
function()
{
@@ -51,7 +51,7 @@ function run()
//
// Write the results.
//
- total = new Date().getTime() - start;
+ var total = new Date().getTime() - start;
writeLine("time for " + repetitions + " pings: " + total + "ms");
writeLine("time per ping: " + (total / repetitions) + "ms");
setState(State.Idle);
diff --git a/js/demo/Ice/minimal/browser/.jshintrc b/js/demo/Ice/minimal/browser/.jshintrc
new file mode 100644
index 00000000000..5864f15ac92
--- /dev/null
+++ b/js/demo/Ice/minimal/browser/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "extends" : "../../../.jshint_browser"
+} \ No newline at end of file
diff --git a/js/demo/Ice/throughput/Client.js b/js/demo/Ice/throughput/Client.js
index 64f17a91dd0..6c3aa9953a5 100644
--- a/js/demo/Ice/throughput/Client.js
+++ b/js/demo/Ice/throughput/Client.js
@@ -32,7 +32,7 @@ function menu()
"x: exit\n" +
"?: help\n" +
"\n");
-};
+}
//
// Asynchronous loop, each call to the given function returns a
@@ -312,7 +312,6 @@ Ice.Promise.try(
else if(key == "s")
{
return twoway.shutdown();
- process.stdout.write("==> ");
}
else if(key == "?")
{
diff --git a/js/demo/Ice/throughput/browser/.jshintrc b/js/demo/Ice/throughput/browser/.jshintrc
new file mode 100644
index 00000000000..5864f15ac92
--- /dev/null
+++ b/js/demo/Ice/throughput/browser/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "extends" : "../../../.jshint_browser"
+} \ No newline at end of file
diff --git a/js/demo/Ice/throughput/browser/Client.js b/js/demo/Ice/throughput/browser/Client.js
index 1978a93045c..dec7eedd1bc 100644
--- a/js/demo/Ice/throughput/browser/Client.js
+++ b/js/demo/Ice/throughput/browser/Client.js
@@ -14,20 +14,21 @@ var ThroughputPrx = Demo.ThroughputPrx;
//
// Initialize sequences.
//
+var i;
var byteSeq = new Uint8Array(Demo.ByteSeqSize);
-for(var i = 0; i < Demo.ByteSeqSize; ++i)
+for(i = 0; i < Demo.ByteSeqSize; ++i)
{
byteSeq[i] = 0;
}
var stringSeq = [];
-for(var i = 0; i < Demo.StringSeqSize; ++i)
+for(i = 0; i < Demo.StringSeqSize; ++i)
{
stringSeq[i] = "hello";
}
var structSeq = [];
-for(var i = 0; i < Demo.StringDoubleSeqSize; ++i)
+for(i = 0; i < Demo.StringDoubleSeqSize; ++i)
{
structSeq[i] = new Demo.StringDouble();
structSeq[i].s = "hello";
@@ -35,7 +36,7 @@ for(var i = 0; i < Demo.StringDoubleSeqSize; ++i)
}
var fixedSeq = [];
-for(var i = 0; i < Demo.FixedSeqSize; ++i)
+for(i = 0; i < Demo.FixedSeqSize; ++i)
{
fixedSeq[i] = new Demo.Fixed();
fixedSeq[i].i = 0;
@@ -66,10 +67,10 @@ function run()
return ThroughputPrx.checkedCast(proxy).then(
function(twoway)
{
- oneway = twoway.ice_oneway();
+ var oneway = twoway.ice_oneway();
var seq;
- var seqSize
+ var seqSize;
var wireSize;
var proxy;
var operation;