Permalink
Browse files

clean up innocuous, but confusing variable redefinition, add lots of …

…semi-colons /cc @jedp
  • Loading branch information...
1 parent 213cf7e commit 1ffa1a955d4913899c0a958a0b4b756f04f0590d @lloyd lloyd committed Jun 25, 2012
Showing with 17 additions and 17 deletions.
  1. +17 −17 src/jschannel.js
View
@@ -1,4 +1,4 @@
-/**
+/*
* js_channel is a very lightweight abstraction on top of
* postMessage which defines message formats and semantics
* to support interactions more rich than just message passing
@@ -99,7 +99,7 @@
}
}
if (s_boundChans[origin][scope].length === 0) {
- delete s_boundChans[origin][scope]
+ delete s_boundChans[origin][scope];
}
}
@@ -158,19 +158,19 @@
if (typeof meth === 'string') {
var delivered = false;
if (s_boundChans[o] && s_boundChans[o][s]) {
- for (var i = 0; i < s_boundChans[o][s].length; i++) {
- if (s_boundChans[o][s][i].win === w) {
- s_boundChans[o][s][i].handler(o, meth, m);
+ for (var j = 0; j < s_boundChans[o][s].length; j++) {
+ if (s_boundChans[o][s][j].win === w) {
+ s_boundChans[o][s][j].handler(o, meth, m);
delivered = true;
break;
}
}
}
if (!delivered && s_boundChans['*'] && s_boundChans['*'][s]) {
- for (var i = 0; i < s_boundChans['*'][s].length; i++) {
- if (s_boundChans['*'][s][i].win === w) {
- s_boundChans['*'][s][i].handler(o, meth, m);
+ for (var j = 0; j < s_boundChans['*'][s].length; j++) {
+ if (s_boundChans['*'][s][j].win === w) {
+ s_boundChans['*'][s][j].handler(o, meth, m);
break;
}
}
@@ -226,7 +226,7 @@
try { if (typeof m !== 'string') m = JSON.stringify(m); } catch(e) { }
console.log("["+chanId+"] " + m);
}
- }
+ };
/* browser capabilities check */
if (!window.postMessage) throw("jschannel cannot run this browser, no postMessage");
@@ -260,7 +260,7 @@
if (typeof cfg.scope !== 'undefined') {
if (typeof cfg.scope !== 'string') throw 'scope, when specified, must be a string';
- if (cfg.scope.split('::').length > 1) throw "scope may not contain double colons: '::'"
+ if (cfg.scope.split('::').length > 1) throw "scope may not contain double colons: '::'";
}
/* private variables */
@@ -329,7 +329,7 @@
return completed;
}
};
- }
+ };
var setTransactionTimeout = function(transId, timeout, method) {
return window.setTimeout(function() {
@@ -341,8 +341,8 @@
delete s_transIds[transId];
}
}, timeout);
- }
-
+ };
+
var onMessage = function(origin, method, m) {
// if an observer was specified at allocation time, invoke it
if (typeof cfg.gotMessageObserver === 'function') {
@@ -380,7 +380,7 @@
var cbName = path;
return function(params) {
return trans.invoke(cbName, params);
- }
+ };
})();
}
}
@@ -457,7 +457,7 @@
// what can we do? Also, here we'll ignore return values
}
}
- }
+ };
// now register our bound channel for msg routing
s_addBoundChan(cfg.window, cfg.origin, ((typeof cfg.scope === 'string') ? cfg.scope : ''), onMessage);
@@ -466,7 +466,7 @@
var scopeMethod = function(m) {
if (typeof cfg.scope === 'string' && cfg.scope.length) m = [cfg.scope, m].join("::");
return m;
- }
+ };
// a small wrapper around postmessage whose primary function is to handle the
// case that clients start sending messages before the other end is "ready"
@@ -489,7 +489,7 @@
cfg.window.postMessage(JSON.stringify(msg), cfg.origin);
}
- }
+ };
var onReady = function(trans, type) {
debug('ready msg received');

1 comment on commit 1ffa1a9

jedp commented on 1ffa1a9 Jun 25, 2012

Thanks for pushing this upstream here, @lloyd

Please sign in to comment.