Skip to content

Commit

Permalink
Make global variables explicit.
Browse files Browse the repository at this point in the history
Other fixes suggested by jsLint.
  • Loading branch information
bvds committed Dec 31, 2013
1 parent 4cc1739 commit 6598646
Show file tree
Hide file tree
Showing 19 changed files with 211 additions and 212 deletions.
14 changes: 7 additions & 7 deletions web-UI/andes/Combo.js
@@ -1,6 +1,6 @@
dojo.provide("andes.Combo"); dojo.provide("andes.Combo");


andes.Combo = dojox.drawing.util.oo.declare( window.andes.Combo = dojox.drawing.util.oo.declare(
// summary: // summary:
// A special object used to combine an Andes Stencil // A special object used to combine an Andes Stencil
// (Vector, Rect, Ellipse) // (Vector, Rect, Ellipse)
Expand Down Expand Up @@ -35,7 +35,7 @@ andes.Combo = dojox.drawing.util.oo.declare(
var s = this.statement; var s = this.statement;
var m = this.master; var m = this.master;


console.warn("combo statement:", this.statement) console.warn("combo statement:", this.statement);


this.statement.connectMult([ this.statement.connectMult([
[this.statement, "onChangeData", this, "textPositionEdit"], [this.statement, "onChangeData", this, "textPositionEdit"],
Expand Down Expand Up @@ -90,7 +90,7 @@ andes.Combo = dojox.drawing.util.oo.declare(
// split in two parts. First is textEdit which triggers // split in two parts. First is textEdit which triggers
// onChangeData for final text changes. TextPositionEdit handles // onChangeData for final text changes. TextPositionEdit handles
// position changes. // position changes.
var label = andes.variablename.parse(value); var label = window.andes.variablename.parse(value);
var ol = this.master.getLabel(); var ol = this.master.getLabel();
if(label){ if(label){
console.log("textEdit: LABEL=", label," text=",value); console.log("textEdit: LABEL=", label," text=",value);
Expand Down Expand Up @@ -136,7 +136,7 @@ andes.Combo = dojox.drawing.util.oo.declare(
}, },


onDelete: function(value){ // value or 'this' ? onDelete: function(value){ // value or 'this' ?
console.log("combo delete ", value) console.log("combo delete ", value);
// summary: // summary:
// Stub - fires when master or an item is deleted // Stub - fires when master or an item is deleted
// (which makes this _Connection worthless and it // (which makes this _Connection worthless and it
Expand Down Expand Up @@ -201,9 +201,9 @@ andes.Combo = dojox.drawing.util.oo.declare(
dojo.forEach(handles, dojo.disconnect, dojo); dojo.forEach(handles, dojo.disconnect, dojo);
} }
} }
) );


andes.buttonCombo = dojox.drawing.util.oo.declare( window.andes.buttonCombo = dojox.drawing.util.oo.declare(
// summary: // summary:
// A special object used to combine a Button and a Statement. // A special object used to combine a Button and a Statement.
// //
Expand Down Expand Up @@ -237,4 +237,4 @@ andes.buttonCombo = dojox.drawing.util.oo.declare(
} }


} }
) );
10 changes: 5 additions & 5 deletions web-UI/andes/PreferenceRegistry.js
Expand Up @@ -8,9 +8,9 @@ dojo.provide("andes.PreferenceRegistry");
// server to update values that register here. // server to update values that register here.
// Example api: // Example api:
// andes.api.recordAction({type:"set-preference", name: "display-timer", value: true}); // andes.api.recordAction({type:"set-preference", name: "display-timer", value: true});
_prefs = {}; var _prefs = {};


andes.preferenceRegistry = { window.andes.preferenceRegistry = {
// Prefs are name value pairs with scope so that the server // Prefs are name value pairs with scope so that the server
// can update them. // can update them.
registerPref: function(/*String*/pref, /*function*/setter, scope){ registerPref: function(/*String*/pref, /*function*/setter, scope){
Expand All @@ -28,7 +28,7 @@ dojo.provide("andes.PreferenceRegistry");
}else{ }else{
if(_prefs[pref].value != value){ if(_prefs[pref].value != value){
// This is user changed // This is user changed
andes.api.recordAction({type:"set-preference", name:pref, value:value }); window.andes.api.recordAction({type:"set-preference", name:pref, value:value });
} }
return true; return true;
} }
Expand All @@ -51,5 +51,5 @@ dojo.provide("andes.PreferenceRegistry");
return false; return false;
} }
} }
} };
})(); })();
10 changes: 5 additions & 5 deletions web-UI/andes/WordTip.js
Expand Up @@ -31,7 +31,7 @@ dojo.declare("andes.WordTip", null, {
console.log("andes.WordTip.textMonitor this=",this); console.log("andes.WordTip.textMonitor this=",this);
var tx = dojo.trim(this.conEdit.innerHTML);//this.statement.cleanText(conEdit.innerHTML); var tx = dojo.trim(this.conEdit.innerHTML);//this.statement.cleanText(conEdit.innerHTML);
tx = this.removeBreaks(tx); tx = this.removeBreaks(tx);
var symbol = andes.variablename.parse(tx); var symbol = window.andes.variablename.parse(tx);
console.log("---Text for word-suggest----> ", tx,symbol); console.log("---Text for word-suggest----> ", tx,symbol);
this.sendToServer(tx,symbol); this.sendToServer(tx,symbol);
}; };
Expand All @@ -41,7 +41,7 @@ dojo.declare("andes.WordTip", null, {
var cn = dojo.connect(document,"mouseup",this, function(evt){ var cn = dojo.connect(document,"mouseup",this, function(evt){
dojo.disconnect(cn); dojo.disconnect(cn);
dijit.hideTooltip(this.conEdit); dijit.hideTooltip(this.conEdit);
}) });
}, },


removeBreaks: function(txt){ removeBreaks: function(txt){
Expand All @@ -54,7 +54,7 @@ dojo.declare("andes.WordTip", null, {
sendToServer: function(text,symbol){ sendToServer: function(text,symbol){
console.assert(this.theDrawing,"WordTip needs drawing initialized"); console.assert(this.theDrawing,"WordTip needs drawing initialized");
var current; var current;
var andesTypes = andes.convert.andesTypes; var andesTypes = window.andes.convert.andesTypes;


// The most recent stencil will either be the last selected or the last // The most recent stencil will either be the last selected or the last
// tool. Thus find out the id, if it matches the last selected that's // tool. Thus find out the id, if it matches the last selected that's
Expand All @@ -79,7 +79,7 @@ dojo.declare("andes.WordTip", null, {
}; };
// console.log("current: ",current); // console.log("current: ",current);
if(current && this.hasTip[current]){ if(current && this.hasTip[current]){
andes.api.suggestWord({type: current, text: text, symbol:symbol}); window.andes.api.suggestWord({type: current, text: text, symbol:symbol});
} }
}, },


Expand All @@ -105,4 +105,4 @@ dojo.declare("andes.WordTip", null, {
}; };
},this); },this);
} }
}); });
38 changes: 19 additions & 19 deletions web-UI/andes/api.js
Expand Up @@ -17,12 +17,12 @@ dojo.require("andes.timer");
// AOP-style function replacement that performs before-advice // AOP-style function replacement that performs before-advice
// to add to the headers on all XHR requests. See dojox/rpc/Client.js // to add to the headers on all XHR requests. See dojox/rpc/Client.js
(function(){ (function(){
console.info("api set headers", andes.sessionId) console.info("api set headers", window.andes.sessionId);
andes._originalXhr = dojo.xhr; window.andes._originalXhr = dojo.xhr;
dojo.xhr = function(method,args){ dojo.xhr = function(method,args){
var headers = args.headers = args.headers || {}; var headers = args.headers = args.headers || {};
headers["Client-Id"] = andes.sessionId; headers["Client-Id"] = window.andes.sessionId;
return andes._originalXhr.apply(dojo,arguments); return window.andes._originalXhr.apply(dojo,arguments);
}; };
})(); })();


Expand All @@ -37,14 +37,14 @@ dojo.require("andes.timer");
var request = prepRequest(req.params); var request = prepRequest(req.params);
requestInFlight = true; requestInFlight = true;
req.startTime = (new Date()).getTime(); req.startTime = (new Date()).getTime();
andes.rpc[req.method](request).addCallbacks( window.andes.rpc[req.method](request).addCallbacks(
function(result){ function(result){
requestInFlight = false; requestInFlight = false;
var dt=(new Date()).getTime()-req.startTime; var dt=(new Date()).getTime()-req.startTime;
// log any server latency larger than cutoff in ms. // log any server latency larger than cutoff in ms.
// Should match Andes server timeout. // Should match Andes server timeout.
if(dt>15000){ if(dt>15000){
andes.errorLog({ window.andes.errorLog({
title: "latency", title: "latency",
message: dt + " ms for " + req.method message: dt + " ms for " + req.method
}); });
Expand All @@ -61,16 +61,16 @@ dojo.require("andes.timer");
// the RPC action to open-problemo // the RPC action to open-problemo
// //
req.dfd.errback(error); req.dfd.errback(error);
var mo = andes.messages.server(); var mo = window.andes.messages.server();
var msg = "<p>"+mo.message+"</p><div class='errMsg'>" + error.name + ": " + error.message; var msg = "<p>"+mo.message+"</p><div class='errMsg'>" + error.name + ": " + error.message;
if(error._rpcErrorObject.code){ if(error._rpcErrorObject.code){
msg += "\n(code " + error._rpcErrorObject.code + ")"; msg += "\n(code " + error._rpcErrorObject.code + ")";
} }
msg += "</div><div class='action'>"+mo.action+"</div>"; msg += "</div><div class='action'>"+mo.action+"</div>";
andes.error({ window.andes.error({
title: mo.title, title: mo.title,
message: msg, message: msg,
errorType: andes.error.OK errorType: window.andes.error.OK
}); });
}else{ }else{
// //
Expand All @@ -79,18 +79,18 @@ dojo.require("andes.timer");
// Can be generated by changing the SMD URL // Can be generated by changing the SMD URL
// //
if(++tries <= MAX_RETRIES){ if(++tries <= MAX_RETRIES){
setTimeout(function(){ window.setTimeout(function(){
sendRequest(req); sendRequest(req);
}, RETRY_TIMEOUT); }, RETRY_TIMEOUT);
}else{ }else{
req.dfd.errback(error); req.dfd.errback(error);
console.error(error); console.error(error);
var mo = andes.messages.connection(MAX_RETRIES); var mo = window.andes.messages.connection(MAX_RETRIES);
console.dir(mo) console.dir(mo);
andes.error({ window.andes.error({
title: mo.title, title: mo.title,
message: mo.message+"<div class='action'>"+mo.action+"</div>", message: mo.message+"<div class='action'>"+mo.action+"</div>",
dialogType: andes.error.OK dialogType: window.andes.error.OK
}); });
} }
} }
Expand Down Expand Up @@ -120,17 +120,17 @@ dojo.require("andes.timer");
return dfd; return dfd;
} }


andes.api = { window.andes.api = {
open: function(params){ open: function(params){
//console.info("andes.api.open", params); //console.info("andes.api.open", params);
startTime = (new Date()).getTime(); startTime = (new Date()).getTime();
andes.timer = new andes.timer(startTime); window.andes.timer = new window.andes.timer(startTime);
var dfd = queueRequest("open-problem", params); var dfd = queueRequest("open-problem", params);


dfd.addCallback(function(result){ dfd.addCallback(function(result){
// look for help embedded in the returned result, so we can // look for help embedded in the returned result, so we can
// queue it up in case the user opens the Tutor pane // queue it up in case the user opens the Tutor pane
andes.help.processStep(result); window.andes.help.processStep(result);
}); });
return dfd; return dfd;
}, },
Expand All @@ -141,7 +141,7 @@ dojo.require("andes.timer");
dfd.addCallback(function(result){ dfd.addCallback(function(result){
// look for help embedded in the returned result, so we can // look for help embedded in the returned result, so we can
// queue it up in case the user opens the Tutor pane // queue it up in case the user opens the Tutor pane
andes.help.processStep(result); window.andes.help.processStep(result);
}); });
return dfd; return dfd;
}, },
Expand All @@ -155,7 +155,7 @@ dojo.require("andes.timer");
//console.info("andes.api.suggestWord", params); //console.info("andes.api.suggestWord", params);
var dfd = queueRequest("suggest-word", params); var dfd = queueRequest("suggest-word", params);
dfd.addCallback(function(result){ dfd.addCallback(function(result){
andes.WordTip.processResults(result); window.andes.WordTip.processResults(result);
}); });
return dfd; return dfd;
}, },
Expand Down

0 comments on commit 6598646

Please sign in to comment.