Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make global variables explicit.

Other fixes suggested by jsLint.
  • Loading branch information...
commit 6598646d2d547c148b37fd49c35ccded68d1688d 1 parent 4cc1739
@bvds authored
View
14 web-UI/andes/Combo.js
@@ -1,6 +1,6 @@
dojo.provide("andes.Combo");
-andes.Combo = dojox.drawing.util.oo.declare(
+window.andes.Combo = dojox.drawing.util.oo.declare(
// summary:
// A special object used to combine an Andes Stencil
// (Vector, Rect, Ellipse)
@@ -35,7 +35,7 @@ andes.Combo = dojox.drawing.util.oo.declare(
var s = this.statement;
var m = this.master;
- console.warn("combo statement:", this.statement)
+ console.warn("combo statement:", this.statement);
this.statement.connectMult([
[this.statement, "onChangeData", this, "textPositionEdit"],
@@ -90,7 +90,7 @@ andes.Combo = dojox.drawing.util.oo.declare(
// split in two parts. First is textEdit which triggers
// onChangeData for final text changes. TextPositionEdit handles
// position changes.
- var label = andes.variablename.parse(value);
+ var label = window.andes.variablename.parse(value);
var ol = this.master.getLabel();
if(label){
console.log("textEdit: LABEL=", label," text=",value);
@@ -136,7 +136,7 @@ andes.Combo = dojox.drawing.util.oo.declare(
},
onDelete: function(value){ // value or 'this' ?
- console.log("combo delete ", value)
+ console.log("combo delete ", value);
// summary:
// Stub - fires when master or an item is deleted
// (which makes this _Connection worthless and it
@@ -201,9 +201,9 @@ andes.Combo = dojox.drawing.util.oo.declare(
dojo.forEach(handles, dojo.disconnect, dojo);
}
}
-)
+);
-andes.buttonCombo = dojox.drawing.util.oo.declare(
+window.andes.buttonCombo = dojox.drawing.util.oo.declare(
// summary:
// A special object used to combine a Button and a Statement.
//
@@ -237,4 +237,4 @@ andes.buttonCombo = dojox.drawing.util.oo.declare(
}
}
-)
+);
View
10 web-UI/andes/PreferenceRegistry.js
@@ -8,9 +8,9 @@ dojo.provide("andes.PreferenceRegistry");
// server to update values that register here.
// Example api:
// 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
// can update them.
registerPref: function(/*String*/pref, /*function*/setter, scope){
@@ -28,7 +28,7 @@ dojo.provide("andes.PreferenceRegistry");
}else{
if(_prefs[pref].value != value){
// 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;
}
@@ -51,5 +51,5 @@ dojo.provide("andes.PreferenceRegistry");
return false;
}
}
- }
-})();
+ };
+})();
View
10 web-UI/andes/WordTip.js
@@ -31,7 +31,7 @@ dojo.declare("andes.WordTip", null, {
console.log("andes.WordTip.textMonitor this=",this);
var tx = dojo.trim(this.conEdit.innerHTML);//this.statement.cleanText(conEdit.innerHTML);
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);
this.sendToServer(tx,symbol);
};
@@ -41,7 +41,7 @@ dojo.declare("andes.WordTip", null, {
var cn = dojo.connect(document,"mouseup",this, function(evt){
dojo.disconnect(cn);
dijit.hideTooltip(this.conEdit);
- })
+ });
},
removeBreaks: function(txt){
@@ -54,7 +54,7 @@ dojo.declare("andes.WordTip", null, {
sendToServer: function(text,symbol){
console.assert(this.theDrawing,"WordTip needs drawing initialized");
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
// tool. Thus find out the id, if it matches the last selected that's
@@ -79,7 +79,7 @@ dojo.declare("andes.WordTip", null, {
};
// console.log("current: ",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});
}
},
@@ -105,4 +105,4 @@ dojo.declare("andes.WordTip", null, {
};
},this);
}
-});
+});
View
38 web-UI/andes/api.js
@@ -17,12 +17,12 @@ dojo.require("andes.timer");
// AOP-style function replacement that performs before-advice
// to add to the headers on all XHR requests. See dojox/rpc/Client.js
(function(){
- console.info("api set headers", andes.sessionId)
- andes._originalXhr = dojo.xhr;
+ console.info("api set headers", window.andes.sessionId);
+ window.andes._originalXhr = dojo.xhr;
dojo.xhr = function(method,args){
var headers = args.headers = args.headers || {};
- headers["Client-Id"] = andes.sessionId;
- return andes._originalXhr.apply(dojo,arguments);
+ headers["Client-Id"] = window.andes.sessionId;
+ return window.andes._originalXhr.apply(dojo,arguments);
};
})();
@@ -37,14 +37,14 @@ dojo.require("andes.timer");
var request = prepRequest(req.params);
requestInFlight = true;
req.startTime = (new Date()).getTime();
- andes.rpc[req.method](request).addCallbacks(
+ window.andes.rpc[req.method](request).addCallbacks(
function(result){
requestInFlight = false;
var dt=(new Date()).getTime()-req.startTime;
// log any server latency larger than cutoff in ms.
// Should match Andes server timeout.
if(dt>15000){
- andes.errorLog({
+ window.andes.errorLog({
title: "latency",
message: dt + " ms for " + req.method
});
@@ -61,16 +61,16 @@ dojo.require("andes.timer");
// the RPC action to open-problemo
//
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;
if(error._rpcErrorObject.code){
msg += "\n(code " + error._rpcErrorObject.code + ")";
}
msg += "</div><div class='action'>"+mo.action+"</div>";
- andes.error({
+ window.andes.error({
title: mo.title,
message: msg,
- errorType: andes.error.OK
+ errorType: window.andes.error.OK
});
}else{
//
@@ -79,18 +79,18 @@ dojo.require("andes.timer");
// Can be generated by changing the SMD URL
//
if(++tries <= MAX_RETRIES){
- setTimeout(function(){
+ window.setTimeout(function(){
sendRequest(req);
}, RETRY_TIMEOUT);
}else{
req.dfd.errback(error);
console.error(error);
- var mo = andes.messages.connection(MAX_RETRIES);
- console.dir(mo)
- andes.error({
+ var mo = window.andes.messages.connection(MAX_RETRIES);
+ console.dir(mo);
+ window.andes.error({
title: mo.title,
message: mo.message+"<div class='action'>"+mo.action+"</div>",
- dialogType: andes.error.OK
+ dialogType: window.andes.error.OK
});
}
}
@@ -120,17 +120,17 @@ dojo.require("andes.timer");
return dfd;
}
- andes.api = {
+ window.andes.api = {
open: function(params){
//console.info("andes.api.open", params);
startTime = (new Date()).getTime();
- andes.timer = new andes.timer(startTime);
+ window.andes.timer = new window.andes.timer(startTime);
var dfd = queueRequest("open-problem", params);
dfd.addCallback(function(result){
// look for help embedded in the returned result, so we can
// queue it up in case the user opens the Tutor pane
- andes.help.processStep(result);
+ window.andes.help.processStep(result);
});
return dfd;
},
@@ -141,7 +141,7 @@ dojo.require("andes.timer");
dfd.addCallback(function(result){
// look for help embedded in the returned result, so we can
// queue it up in case the user opens the Tutor pane
- andes.help.processStep(result);
+ window.andes.help.processStep(result);
});
return dfd;
},
@@ -155,7 +155,7 @@ dojo.require("andes.timer");
//console.info("andes.api.suggestWord", params);
var dfd = queueRequest("suggest-word", params);
dfd.addCallback(function(result){
- andes.WordTip.processResults(result);
+ window.andes.WordTip.processResults(result);
});
return dfd;
},
View
50 web-UI/andes/convert.js
@@ -3,7 +3,7 @@ dojo.provide("andes.convert");
(function(){
- andes.convert = {
+ window.andes.convert = {
// summary:
// The conversion object used to transform objects
// from and ande object to a drawing object and
@@ -41,7 +41,7 @@ dojo.provide("andes.convert");
x:box.x2 + gap,
y:box.y1,
showEmpty:true}
- }
+ };
},
andesToDrawing: function(o){
@@ -51,14 +51,14 @@ dojo.provide("andes.convert");
//console.warn(" ---------------> andesToDrawing:", o.type,o.id)
// Group of objects: call conversion recursively
if(o.items) {
- var obj = {
+ var obj1 = {
id:o.id,
type:o.type,
itemType:o.items[0].type,
- items:dojo.map(o.items,andes.convert.andesToDrawing, this),
+ items:dojo.map(o.items,window.andes.convert.andesToDrawing, this),
checked: o.checked || []
- }
- return obj;
+ };
+ return obj1;
}
if(o.x==undefined || o.y===undefined){
console.error("Imported Object '" + o.id + "' contains no X or Y coordinates.");
@@ -86,9 +86,9 @@ dojo.provide("andes.convert");
cy:o.y + o.height/2,
rx:o.width/2,
ry:o.height/2
- }
+ };
}else if(o.type=="radio"){
- buttonWidth=andes.defaults.button.radioButtonRadius;
+ buttonWidth=window.andes.defaults.button.radioButtonRadius;
obj.buttonType=o.type;
obj.data={
cx:o.x + 0.5*buttonWidth,
@@ -99,7 +99,7 @@ dojo.provide("andes.convert");
};
obj.value = o.value;
}else if(o.type=="checkbox"){
- buttonWidth=andes.defaults.button.checkboxWidth;
+ buttonWidth=window.andes.defaults.button.checkboxWidth;
obj.buttonType=o.type;
obj.data.width = buttonWidth;
obj.data.height = buttonWidth;
@@ -142,7 +142,7 @@ dojo.provide("andes.convert");
text:dojox.drawing.util.typeset.convertHTML(o.text) || ""
},
enabled: false // treat as mode=locked
- }
+ };
}else if(o.type=="line" || o.type=="vector" || o.type=="rectangle" || o.type=="ellipse"){
// separate objects
// match logic in drawingToAndes
@@ -179,12 +179,12 @@ dojo.provide("andes.convert");
},
deleteEmptyCreate: false,
deleteEmptyModify: false
- }
+ };
}else if(o.type=="statement" || o.type=="equation"){
obj.data.text = o.text;
}else if(o.type=="axes"){
obj.label = o['x-label']+" and "+o['y-label'];
- if(andes.defaults.zAxisEnabled){
+ if(window.andes.defaults.zAxisEnabled){
obj.label += " and "+o['z-label'];
}
}
@@ -204,7 +204,7 @@ dojo.provide("andes.convert");
b[nm] = Math.round(b[nm]);
}
return b;
- }
+ };
// combo...............
var combo, statement, sbox, id = item.id;
if(item.type=="andes.Combo"){
@@ -219,13 +219,13 @@ dojo.provide("andes.convert");
if(!item.group){
console.warn("drawingToAndes: invalid button object ",item);
}
- var obj = {
+ var obj1 = {
id:item.group.id,
type:item.group.type,
action:action,
checked:item.group.checked
- }
- return obj;
+ };
+ return obj1;
};
var box = round(item.getBounds(true));
@@ -236,7 +236,7 @@ dojo.provide("andes.convert");
type:type,
id:id,
mode: "unknown"
- }
+ };
if(type!="vector" && type!="line" && type!="axes"){
obj.width = box.w;
@@ -251,18 +251,18 @@ dojo.provide("andes.convert");
obj.text = item.getText() || "";
if(type == "statement"){
// need to add any 'symbol' derived from variablename.js
- obj.symbol = andes.variablename.parse(obj.text);
+ obj.symbol = window.andes.variablename.parse(obj.text);
}
}else if(type != "axes"){
obj["x-statement"] = sbox.x;
obj["y-statement"] = sbox.y;
}else if(type == "axes"){
- var lbl = item.getLabel();
- obj["x-label"] = lbl.x;
- obj["y-label"] = lbl.y;
- if(lbl.z) {
- obj["z-label"] = lbl.z;
+ var lbl1 = item.getLabel();
+ obj["x-label"] = lbl1.x;
+ obj["y-label"] = lbl1.y;
+ if(lbl1.z) {
+ obj["z-label"] = lbl1.z;
}
obj.radius = Math.ceil(item.getRadius());
obj.angle = item.getAngle();
@@ -281,7 +281,7 @@ dojo.provide("andes.convert");
if(txt){
// Variable and symbol mismatch.
// See Bug #1962.
- if(lbl != andes.variablename.parse(txt)){
+ if(lbl != window.andes.variablename.parse(txt)){
console.warn("Symbol '" +lbl+"' does not match text '"+txt+"'.");
}
obj.text = txt;
@@ -294,6 +294,6 @@ dojo.provide("andes.convert");
return obj;
}
- }
+ };
})();
View
12 web-UI/andes/defaults.js
@@ -1,7 +1,7 @@
dojo.provide("andes.defaults");
(function(){
- andes.defaults = {
+ window.andes.defaults = {
// summary:
// The style used for Andes3.
// description:
@@ -267,7 +267,7 @@ dojo.provide("andes.defaults");
if(obj.push){
o = [];
for(var i=0; i<obj.length;i++){
- o.push(cpy(obj[i]))
+ o.push(cpy(obj[i]));
}
return o;
}
@@ -277,12 +277,12 @@ dojo.provide("andes.defaults");
if(typeof(obj[nm])=="object"){
o[nm] = cpy(obj[nm]);
}else{
- o[nm] = obj[nm]
+ o[nm] = obj[nm];
}
}
}
return o;
- }
+ };
var o = cpy(this);
o.current = o.norm;
o.currentHit = o.hitNorm;
@@ -293,11 +293,11 @@ dojo.provide("andes.defaults");
};
// change Drawing defaults to andes defaults
- var a = andes.defaults;
+ var a = window.andes.defaults;
a.norm.fill = a.unknown.fill;
a.norm.color = a.unknown.color;
a.disabled.color = a.locked.color;
a.disabled.fill = a.locked.fill;
a.textDisabled.color = a.locked.fill;
-})();
+})();
View
88 web-UI/andes/drawing.js
@@ -67,38 +67,38 @@ dojo.provide("andes.drawing");
_drawing = dijit.byId(drawingId);
var cn = dojo.connect(_drawing, "onSurfaceReady", function(){
dojo.disconnect(cn);
- andes.WordTip.add(_drawing);
- andes.drawing.onSurfaceReady();
+ window.andes.WordTip.add(_drawing);
+ window.andes.drawing.onSurfaceReady();
if(_drawing.stencils){
console.warn("Label double click connected");
- dojo.connect(_drawing.stencils, "onLabelDoubleClick", andes.drawing, "onLabelDoubleClick");
+ dojo.connect(_drawing.stencils, "onLabelDoubleClick", window.andes.drawing, "onLabelDoubleClick");
}
});
- dojo.connect(_drawing, "onRenderStencil", andes.drawing, "onRenderStencil");
+ dojo.connect(_drawing, "onRenderStencil", window.andes.drawing, "onRenderStencil");
// Track user's focus on Andes. So far only whether they are using the window/tab
// or have left to use another program
if(dojo.isIE){
- dojo.connect(dojo.global, "onfocus", andes.drawing, "onWindowFocus");
- //dojo.connect(dojo.global, "onfocusin", andes.drawing, "onWindowFocus");
+ dojo.connect(dojo.global, "onfocus", window.andes.drawing, "onWindowFocus");
+ //dojo.connect(dojo.global, "onfocusin", window.andes.drawing, "onWindowFocus");
dojo.connect(dojo.doc, "onfocusout", this, function() {
if (this._activeElement != document.activeElement){
this._activeElement = document.activeElement;
}else{
- andes.drawing.onWindowBlur();
+ window.andes.drawing.onWindowBlur();
}
});
}else if(dojo.isSafari){
- dojo.connect(window, "onblur", andes.drawing, "onWindowBlur");
- dojo.connect(window, "onfocus", andes.drawing, "onWindowFocus");
+ dojo.connect(window, "onblur", window.andes.drawing, "onWindowBlur");
+ dojo.connect(window, "onfocus", window.andes.drawing, "onWindowFocus");
}else{
- dojo.connect(dojo.doc, "onblur", andes.drawing, "onWindowBlur");
- dojo.connect(dojo.doc, "onfocus", andes.drawing, "onWindowFocus");
+ dojo.connect(dojo.doc, "onblur", window.andes.drawing, "onWindowBlur");
+ dojo.connect(dojo.doc, "onfocus", window.andes.drawing, "onWindowFocus");
}
});
- andes.drawing = {
+ window.andes.drawing = {
// summary:
// The master object that controls behavior of Drawing items
// and handles transfer of data between server and client
@@ -135,7 +135,7 @@ dojo.provide("andes.drawing");
if(hasLabel[item.type]){
// axes
// default labels for an axes
- props.data.text = andes.defaults.zAxisEnabled?
+ props.data.text = window.andes.defaults.zAxisEnabled?
"x and y and z":"x and y";
}
// create statement for vector, rect, ellipse, or axes
@@ -154,18 +154,18 @@ dojo.provide("andes.drawing");
}else if(hasStatement[item.type]){
// vector, rect, ellipse
- var c = new andes.Combo({master:item, statement:statement, onCreate: dojo.hitch(this, function(){
+ var c = new window.andes.Combo({master:item, statement:statement, onCreate: dojo.hitch(this, function(){
this.add(c, true);
})});
}
}else{
// statement or equation
- if(item.isText && andes.defaults.text.deleteEmptyCreate && !item.getText()){
+ if(item.isText && window.andes.defaults.text.deleteEmptyCreate && !item.getText()){
// no text. will be deleted.
return;
}
- console.log("ADD EQU OR STT>>>", item.customType)
+ console.log("ADD EQU OR STT>>>", item.customType);
this.add(item, true);
}
},
@@ -189,7 +189,7 @@ dojo.provide("andes.drawing");
}
}else if(item.buttonType == "radio"){
item.group.checked=[item.value];
- var myId=item.id
+ var myId=item.id;
dojo.forEach(item.buttons,function(button){
if(button.id == myId){
if(!button.selected){button.select();}
@@ -203,9 +203,9 @@ dojo.provide("andes.drawing");
// Checkboxes only make local modifications
if(item.buttonType != "checkbox"){
// Send result to server
- var data = andes.convert.drawingToAndes(group, "modify-object");
+ var data = window.andes.convert.drawingToAndes(group, "modify-object");
// BvdS: Why doesn't this.save() work?
- andes.drawing.save(data);
+ window.andes.drawing.save(data);
}
});
});
@@ -248,16 +248,16 @@ dojo.provide("andes.drawing");
console.log("----------------> onChangeData andes.drawing", item.id, item.type);
// Until we know server diagnosis, set to unknown.
item.mod = true; // disable save to server, else we get a recursive call
- item.attr(andes.defaults["unknown"]);
+ item.attr(window.andes.defaults["unknown"]);
item.mod = false; // restore save to sever
- var data = andes.convert.drawingToAndes(item, "modify-object")
+ var data = window.andes.convert.drawingToAndes(item, "modify-object");
console.info("Save mod to server", data);
this.save(data);
});
if(saveToServer){
// we need to save it to the server
- var data = andes.convert.drawingToAndes(item, "new-object")
+ var data = window.andes.convert.drawingToAndes(item, "new-object");
console.info("Save new to server:", data);
this.save(data);
}
@@ -288,7 +288,7 @@ dojo.provide("andes.drawing");
var ar = m.id.match(/\d/g);
if(!ar || !ar.length){ return 0; }
return parseInt(ar.join(""),10);
- }
+ };
var idNum = 0;
dojo.forEach(data, function(m){
idNum = Math.max(getNum(m), idNum);
@@ -313,7 +313,7 @@ dojo.provide("andes.drawing");
}*/
if(obj.action =="new-object"){
- var o = andes.convert.andesToDrawing(obj);
+ var o = window.andes.convert.andesToDrawing(obj);
var t = o.stencilType;
// o.stencilType includes: text, image, line, rect, ellipse, vector
@@ -326,7 +326,7 @@ dojo.provide("andes.drawing");
var master = _drawing.addStencil(o.stencilType, o.master);
items[statement.id] = statement; //statement;
items[master.id] = master; //master;
- var combo = new andes.Combo({master:master, statement:statement, id:o.id});
+ var combo = new window.andes.Combo({master:master, statement:statement, id:o.id});
this.add(combo);
}else if(o.type=="button" && o.items){ // button groups don't have stencilType
@@ -343,7 +343,7 @@ dojo.provide("andes.drawing");
var buttOnly = dojo.map(butt,function(x){return x.master;});
dojo.forEach(butt,function(x){x.master.buttons=buttOnly;});
- var buttonCombo=new andes.buttonCombo(butt,o.id);
+ var buttonCombo=new window.andes.buttonCombo(butt,o.id);
buttonCombo.group=o;
this.addGroup(buttonCombo);
}else{
@@ -358,7 +358,7 @@ dojo.provide("andes.drawing");
// Add any color
if(obj.mode){
- items[o.id].attr(andes.defaults[obj.mode]);
+ items[o.id].attr(window.andes.defaults[obj.mode]);
}
}else if(obj.action=="modify-object"){
@@ -377,13 +377,13 @@ dojo.provide("andes.drawing");
}
}else if(obj.action=="set-score"){
- andes.help.score(obj.score);
+ window.andes.help.score(obj.score);
}else if(obj.action=="new-user-dialog" && obj.text){
- andes.error({
+ window.andes.error({
title: "Welcome to Andes!",
message: obj.text,
- dialogType: andes.error.OK,
+ dialogType: window.andes.error.OK,
noLog: true
});
// Add event to Error box default OK button.
@@ -394,7 +394,7 @@ dojo.provide("andes.drawing");
"click",
function(){
// add 10 px padding
- andes.principles.review('vec1a-video.html','IntroVideo',null,"width=650,height=395");
+ window.andes.principles.review('vec1a-video.html','IntroVideo',null,"width=650,height=395");
});
}else if(obj.action=="new-user-dialog" && obj.url){
@@ -412,7 +412,7 @@ dojo.provide("andes.drawing");
}else if(obj.action=="set-preference"){
// Try to set in the preferenceRegistry. All
// values that can be saved should be available there
- andes.preferenceRegistry.setPref(obj["name"],obj["value"]);
+ window.andes.preferenceRegistry.setPref(obj["name"],obj["value"]);
}else if(obj.action=="log"){
// Log actions are ignored by client.
@@ -433,7 +433,7 @@ dojo.provide("andes.drawing");
if(items[obj.id]){
items[obj.id].mod = true; // don't echo back to server
// style
- items[obj.id].attr(andes.defaults[obj.mode]);
+ items[obj.id].attr(window.andes.defaults[obj.mode]);
// x, y
if(obj.x!==undefined){
items[obj.id].attr({
@@ -510,9 +510,9 @@ dojo.provide("andes.drawing");
// summary:
// Save an object to the server.
- var dfd = andes.api.step(data);
+ var dfd = window.andes.api.step(data);
dfd.addCallback(this, function(data){
- setTimeout(dojo.hitch(this, function(){
+ window.setTimeout(dojo.hitch(this, function(){
this.handleServerActions(data);
}),0);
});
@@ -527,18 +527,18 @@ dojo.provide("andes.drawing");
//
// setting 'this'
this.loadProject = function(){
- console.info("load server data", andes.userId, andes.projectId, andes.sectionId)
- andes.api.open({user:andes.userId, problem:andes.projectId,section:andes.sectionId,extra:andes.extra})
+ console.info("load server data", window.andes.userId, window.andes.projectId, window.andes.sectionId);
+ window.andes.api.open({user:window.andes.userId, problem:window.andes.projectId,section:window.andes.sectionId,extra:window.andes.extra})
.addCallback(this, function(data){
- setTimeout(dojo.hitch(this, function(){
+ window.setTimeout(dojo.hitch(this, function(){
this.onLoad(data);
}),0);
})
.addErrback(this, "onError");
- }
- if(andes.closeFirst){
+ };
+ if(window.andes.closeFirst){
// a previous project session is open. close it.
- andes.api.close({}).addCallback(this, "loadProject").addErrback(this, "onError");
+ window.andes.api.close({}).addCallback(this, "loadProject").addErrback(this, "onError");
}else{
this.loadProject();
}
@@ -557,7 +557,7 @@ dojo.provide("andes.drawing");
console.error("There was an error in the project data:", err);
if(!this._initialData){
// apparently an error on open-problem. Try closing session.
- andes.api.close({});
+ window.andes.api.close({});
dojo.cookie("andes", null, { expires: -1 });
}
},
@@ -567,7 +567,7 @@ dojo.provide("andes.drawing");
// Event for when the user leaves this window
// say to open another tab.
console.log("Lost window focus for ",this.name || "canvas","; ",this);
- andes.api.recordAction({type:"window", name: this.name || "canvas", value: "blur"});
+ window.andes.api.recordAction({type:"window", name: this.name || "canvas", value: "blur"});
},
onWindowFocus: function(){
@@ -575,7 +575,7 @@ dojo.provide("andes.drawing");
// Event for when this window is focused, such as
// switching back to this tab from another browser tab
console.log("Gained window focus for ",this.name || "canvas","; ",this);
- andes.api.recordAction({type:"window", name: this.name || "canvas", value: "focus"});
+ window.andes.api.recordAction({type:"window", name: this.name || "canvas", value: "focus"});
}
};
View
26 web-UI/andes/error.js
@@ -7,17 +7,17 @@ dojo.require("dijit.form.Button");
var dialog = null;
- andes.errorLog = function(spec){
+ window.andes.errorLog = function(spec){
dojo.xhrPost({
url: "client_log.php",
content: {
- "Client-Id": andes.sessionId,
+ "Client-Id": window.andes.sessionId,
tag: spec.title,
text: spec.message
}});
};
- andes.error = function(spec){
+ window.andes.error = function(spec){
var message = spec.message || "An unknown error occurred.",
title = spec.title || "Error",
dialogType = spec.dialogType || 0;
@@ -28,7 +28,7 @@ dojo.require("dijit.form.Button");
});
dialog.show();
if(!spec.noLog){
- andes.errorLog({
+ window.andes.errorLog({
title: title,
message: message
});
@@ -36,10 +36,10 @@ dojo.require("dijit.form.Button");
};
// dialogType constants
- andes.error.FATAL = 0;
- andes.error.OK = 1;
+ window.andes.error.FATAL = 0;
+ window.andes.error.OK = 1;
- dojo.declare("andes.error._Error", dijit.Dialog, {
+ dojo.declare("window.andes.error._Error", dijit.Dialog, {
postCreate: function(){
this.inherited(arguments);
var container = dojo.create("div", {className:"dijitDialogPaneContent", style:"border-top:none;"});
@@ -57,7 +57,7 @@ dojo.require("dijit.form.Button");
},
_onKey: function(evt){
- if(this.dialogType == andes.error.FATAL){
+ if(this.dialogType == window.andes.error.FATAL){
if(evt.charOrCode == dojo.keys.ESC || evt.charOrCode == dojo.keys.TAB){
dojo.stopEvent(evt);
}
@@ -80,10 +80,10 @@ dojo.require("dijit.form.Button");
_chooseButtonPageNode: function(){
switch(this.dialogType){
- case andes.error.FATAL:
+ case window.andes.error.FATAL:
return null; // fatal errors won't have any dialog buttons
break;
- case andes.error.OK:
+ case window.andes.error.OK:
default:
return "andesButtonPageDefault";
}
@@ -92,7 +92,7 @@ dojo.require("dijit.form.Button");
});
dojo.addOnLoad(function(){
- dialog = new andes.error._Error({
+ dialog = new window.andes.error._Error({
id: "andesErrorDialog",
title: "Error",
style: "width:400px"
@@ -101,12 +101,12 @@ dojo.require("dijit.form.Button");
// This clobbers any existing onerror handler.
// Perhaps one should use addHandler instead.
window.onerror = function(msg, url, line){
- andes.errorLog({
+ window.andes.errorLog({
title: "javascript-error",
message: url + ":" + line + " " + msg
});
console.log("Window error: ",msg," url: ",url, " line: ",line);
- }
+ };
});
})();
View
29 web-UI/andes/help.js
@@ -8,7 +8,7 @@ dojo.require("andes.api");
// Handles text returned from server
//
if(!dijit.byId("helpPane")){
- setTimeout(function(){
+ window.setTimeout(function(){
handleHelp(result);
}, 500);
return;
@@ -40,7 +40,7 @@ dojo.require("andes.api");
// Escape any html codes on input text echo.
// Should use future function dojo.string.escape
// See http://trac.dojotoolkit.org/ticket/8995
- andes.help.echo(r.text.replace(/\&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"));
+ window.andes.help.echo(r.text.replace(/\&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"));
break;
case "focus-hint-text-box":
dijit.byId("helpPane").open();
@@ -71,13 +71,13 @@ dojo.require("andes.api");
// Escape any html codes on input text echo.
// Should use future function dojo.string.escape
// See http://trac.dojotoolkit.org/ticket/8995
- andes.help.echo(q.replace(/\&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"));
+ window.andes.help.echo(q.replace(/\&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"));
dijit.byId("helpInput").set("value", "");
- andes.api.help(h).addCallback(handleHelp);
+ window.andes.api.help(h).addCallback(handleHelp);
});
});
- andes.help.echo = function(value){
+ window.andes.help.echo = function(value){
// summary:
// Echo any input text in the Tutor pane.
//
@@ -95,22 +95,22 @@ dojo.require("andes.api");
}
};
- andes.help.processStep = function(result){
+ window.andes.help.processStep = function(result){
// summary:
// look for any help coming back from the server (such as in
// the results from andes.api.step()
handleHelp(result);
};
- andes.help.explain = function(s){
- andes.api.help({action:"get-help", value:s}).addCallback(handleHelp);
+ window.andes.help.explain = function(s){
+ window.andes.api.help({action:"get-help", value:s}).addCallback(handleHelp);
};
- andes.help.principles = function(s){
- andes.api.help({action:"principles-menu", value:s}).addCallback(handleHelp);
+ window.andes.help.principles = function(s){
+ window.andes.api.help({action:"principles-menu", value:s}).addCallback(handleHelp);
};
- andes.help.link = function(href){
+ window.andes.help.link = function(href){
// summary:
// Calls api after a link in Tutor pane has been clicked.
dojo.xhrGet({
@@ -123,19 +123,18 @@ dojo.require("andes.api");
});
};
- andes.help.score = function(value){
+ window.andes.help.score = function(value){
// summary:
// updates score
return dijit.byId("helpPane").score(value);
};
- andes.help.link = function(name,value){
+ window.andes.help.link = function(name,value){
var s={type: "tutor-link",name: name};
if(value){
s.value=value; // value is optional
}
- andes.api.recordAction(s);
+ window.andes.api.recordAction(s);
};
})();
-
View
44 web-UI/andes/main.js
@@ -18,17 +18,17 @@ dojo.require("andes.WordTip");
if(!query.u || !query.p){
dojo.addOnLoad(function(){
console.error("FIXME: Finalize the error message for needing to return to WebAssign.");
- andes.error({
+ window.andes.error({
title: "Fatal Error",
message: "No user and/or problem data was provided; cannot continue. Please click on your browser's back button.",
- dialogType: andes.error.FATAL
+ dialogType: window.andes.error.FATAL
});
});
};
// FNV-1a for string, 32 bit version, returning hex.
var FNV1aHash = function(x){
var hash = 0x811c9dc5; // 2166136261
- for (i = 0; i < x.length; i++) {
+ for (var i = 0; i < x.length; i++) {
hash ^= x.charCodeAt(i);
hash *= 0x01000193; // 16777619
}
@@ -42,31 +42,31 @@ dojo.require("andes.WordTip");
};
var setCookie = function(){
// Andes database requires that clientID be 50 characters.
- andes.sessionId = FNV1aHash(andes.userId+andes.projectId) +
+ window.andes.sessionId = FNV1aHash(window.andes.userId+window.andes.projectId) +
'_' + new Date().getTime();
var andesCookie = {
- u:andes.userId,
- p:andes.projectId,
- sid:andes.sessionId,
+ u:window.andes.userId,
+ p:window.andes.projectId,
+ sid:window.andes.sessionId,
closed:false
};
dojo.cookie("andes", dojo.toJson(andesCookie), { expires: 999 });
};
- andes.closeFirst = false;
- andes.userId = query.u;
- andes.projectId = query.p;
- andes.sectionId = query.s || 1234;
- andes.extra = query.e; //extra field for Raj
+ window.andes.closeFirst = false;
+ window.andes.userId = query.u;
+ window.andes.projectId = query.p;
+ window.andes.sectionId = query.s || 1234;
+ window.andes.extra = query.e; //extra field for Raj
var ck = dojo.cookie("andes");
if(ck && ck.u){
// There was already a cookie here
- if(ck.u==andes.userId && ck.p==andes.projectId){
+ if(ck.u==window.andes.userId && ck.p==window.andes.projectId){
// we can continue the same session
- andes.sessionId = ck.sid;
+ window.andes.sessionId = ck.sid;
}else{
- andes.closeFirst = true;
- console.warn("Closing previous session", ck.u, andes.userId, ck.p, andes.projectId)
+ window.andes.closeFirst = true;
+ console.warn("Closing previous session", ck.u, window.andes.userId, ck.p, window.andes.projectId);
setCookie();
}
}else{
@@ -74,18 +74,18 @@ dojo.require("andes.WordTip");
}
dojo.addOnUnload(function(){
- andes.api.close({});
+ window.andes.api.close({});
// but don't clear cookie
});
dojo.addOnLoad(function(){
// WordTip needs to be added before conEdit is removed by drawing
- andes.WordTip = new andes.WordTip();
+ window.andes.WordTip = new window.andes.WordTip();
// Problem close actions set
dojo.connect(dojo.byId("submitButton"), "click", function(){
// Needs to be non-blocking
- var closer = andes.api.close({});
+ var closer = window.andes.api.close({});
closer.then(function(result){
// console.log("Made the trip", result);
// Look for url from server, if it doesn't
@@ -99,11 +99,11 @@ dojo.require("andes.WordTip");
}
});
- found ? window.location = url : history.go(-1);
+ found ? window.location = url : window.history.go(-1);
}, function(error){
console.warn("Server Error", error);
console.log("Returning to previous page");
- history.go(-1);
+ window.history.go(-1);
});
dojo.cookie("andes", null, { expires: -1 });
// should look for url from server that
@@ -133,4 +133,4 @@ dojo.require("andes.api");
dojo.require("andes.error");
dojo.require("andes.variablename");
-andes.drawing.load();
+window.andes.drawing.load();
View
32 web-UI/andes/menu.js
@@ -6,7 +6,7 @@ dojo.require("dijit.MenuSeparator");
dojo.addOnLoad(function(){
// Add problem name to menu
- dojo.byId("problemName").innerHTML = andes.projectId;
+ dojo.byId("problemName").innerHTML = window.andes.projectId;
// shortcut for adding an onClick handler to a dijit
function wireItem(item, fn){
@@ -15,7 +15,7 @@ dojo.addOnLoad(function(){
// Wrapper function which adds logging to server
// when menu item is selected.
var extendfn = function(){
- andes.api.recordAction({
+ window.andes.api.recordAction({
type: "menu-choice",
name: item
});
@@ -32,38 +32,38 @@ dojo.addOnLoad(function(){
// in calls to open-review-window-html.
var spec = {
"menuPrinciples":function(){
- andes.principles.review('principles-tree.html','Principles');
+ window.andes.principles.review('principles-tree.html','Principles');
},
"menuQuantities":function(){
- andes.principles.review('quantities.html','Quantities');
+ window.andes.principles.review('quantities.html','Quantities');
},
"menuUnits":function(){
- andes.principles.review('units.html','Units');
+ window.andes.principles.review('units.html','Units');
},
"menuConstants":function(){
- andes.principles.review('constants.html','Constants');
+ window.andes.principles.review('constants.html','Constants');
},
"menuIntroText":function(){
- andes.principles.review('introduction.html','IntroText');
+ window.andes.principles.review('introduction.html','IntroText');
},
"menuIntroVideo":function(){
// add 10px padding.
// should match call in drawing.js
- andes.principles.review('vec1a-video.html','IntroVideo',null,"width=650,height=395");
+ window.andes.principles.review('vec1a-video.html','IntroVideo',null,"width=650,height=395");
},
"menuIntroSlides":function(){
- andes.principles.review('try11/andes.intro.try11_controller.swf',
+ window.andes.principles.review('try11/andes.intro.try11_controller.swf',
'IntroSlides',null,"width=640,height=385");
},
"menuManual":function(){
- andes.principles.review('manual.html','Manual');
+ window.andes.principles.review('manual.html','Manual');
},
"menuOptions":function(){
@@ -77,7 +77,7 @@ dojo.addOnLoad(function(){
};
// Setup contextMenu and children
- andes.contextMenu = new dijit.Menu();
+ window.andes.contextMenu = new dijit.Menu();
var contextOptions = {};
for(var i in spec){
wireItem(i, spec[i]);
@@ -88,17 +88,17 @@ dojo.addOnLoad(function(){
var label = dijit.byId(desc).get("label");
// Hack I'll fix later
if(label=="Options" || label=="Introduction"){
- andes.contextMenu.addChild(new dijit.MenuSeparator());
+ window.andes.contextMenu.addChild(new dijit.MenuSeparator());
};
contextOptions[label] = new dijit.MenuItem({
label:label,
onClick:fn
});
- andes.contextMenu.addChild(contextOptions[label]);
+ window.andes.contextMenu.addChild(contextOptions[label]);
};
// Set up option menu and right click menu
- andes.options = new andes.options();
+ window.andes.options = new window.andes.options();
var _drawing = dijit.byId("drawing");
// Setup the menu onScreen
@@ -110,9 +110,9 @@ dojo.addOnLoad(function(){
// console.log("On down evt: ", evt);
// Dynamically prepare menu depending on the target
// if it's a stencil, allow delete
- andes.contextMenu.unBindDomNode(node);
+ window.andes.contextMenu.unBindDomNode(node);
node = evt.id=="canvasNode" ? dojo.byId("drawing") : dojo.byId(evt.id);
- andes.contextMenu.bindDomNode(node);
+ window.andes.contextMenu.bindDomNode(node);
});
});
View
4 web-UI/andes/messages.js
@@ -8,7 +8,7 @@ dojo.provide("andes.messages");
// mechanism.
- andes.messages = {
+ window.andes.messages = {
// get message based on error type
server: function(){
return {
@@ -31,4 +31,4 @@ dojo.provide("andes.messages");
action:"Check your internet connection and try again. There also may be server problems that will be corrected in a few minutes."
};
}
- }
+ };
View
20 web-UI/andes/options.js
@@ -47,15 +47,15 @@ dojo.declare("andes.options",null,{
// Register preferences
for(var nm in this._prefs){
- andes.preferenceRegistry.registerPref(nm, this[this._prefs[nm]], this);
+ window.andes.preferenceRegistry.registerPref(nm, this[this._prefs[nm]], this);
}
// Initialize values -- myDrawing is a GLOBAL
- this.angleSnap.set('value', myDrawing.defaults.angleSnap);
- this.clickMode.set('label', myDrawing.defaults.clickMode ? "enabled" : "disabled");
- this.showTimer.set('label', andes.timer.display ? "enabled" : "disabled");
- dojo.style(this.correct, "background", myDrawing.defaults.correct.color);
- dojo.style(this.incorrect, "background", myDrawing.defaults.incorrect.color);
+ this.angleSnap.set('value', window.myDrawing.defaults.angleSnap);
+ this.clickMode.set('label', window.myDrawing.defaults.clickMode ? "enabled" : "disabled");
+ this.showTimer.set('label', window.andes.timer.display ? "enabled" : "disabled");
+ dojo.style(this.correct, "background", window.myDrawing.defaults.correct.color);
+ dojo.style(this.incorrect, "background", window.myDrawing.defaults.incorrect.color);
var ops = this;
this.picker = new dijit.ColorPalette({
@@ -104,7 +104,7 @@ dojo.declare("andes.options",null,{
setShowTimer: function(val){
this.timer = val;
this.showTimer.set('label', val ? "enabled" : "disabled");
- this._setChange("timer", val, andes.timer.displayTimer, andes.timer);
+ this._setChange("timer", val, window.andes.timer.displayTimer, window.andes.timer);
},
// TODO:
@@ -169,11 +169,11 @@ dojo.declare("andes.options",null,{
if(!f){
var o = {};
o[name] = value;
- myDrawing.changeDefaults(o, true);
+ window.myDrawing.changeDefaults(o, true);
}else{
f.call(s, value);
}
- andes.preferenceRegistry.savePref(name, value);
+ window.andes.preferenceRegistry.savePref(name, value);
}
//This should be instantiated in menu
-});
+});
View
4 web-UI/andes/positioning.js
@@ -16,7 +16,7 @@ dojo.provide("andes.positioning");
var textYOffset = 20; // height of text box
//create the namespace
- dojox.drawing.util.positioning = {}
+ dojox.drawing.util.positioning = {};
dojox.drawing.util.positioning.label = function(start, end){
// summary:
// Returns the optimal text positions for annotations.Label.
@@ -65,6 +65,6 @@ dojo.provide("andes.positioning");
y += end.x > start.x ? 0.5*textYOffset : -0.5*textYOffset;
return { x:x, y:y, align:align};
- }
+ };
})();
View
18 web-UI/andes/principles.js
@@ -18,7 +18,7 @@ dojo.ready(function(){ // wait until dom is loaded
// The principles and other review pages can be opened either
// via the menus or via the help system (links in the Tutor pane).
-andes.principles={
+window.andes.principles={
reviewp: [],
review: function(file,title,section,dimensionString){
if(!this.reviewp[file] || this.reviewp[file].closed){
@@ -42,7 +42,7 @@ andes.principles={
body = win.document.getElementsByTagName("body");
if(body[0]==null){
// Not loaded yet, try again
- setTimeout(childLoaded, 20);
+ window.setTimeout(childLoaded, 20);
}else{
var n = win.document.createElement("script");
n.src = "../web-UI/andes/recordIE.js";
@@ -58,10 +58,10 @@ andes.principles={
this.reviewp[file].onload = function(){
var obj=this.document.getElementById(section);
obj.scrollIntoView();
- }
+ };
}
- dojo.connect(this.reviewp[file], "onblur", andes.drawing.onWindowBlur);
- dojo.connect(this.reviewp[file], "onfocus", andes.drawing.onWindowFocus);
+ dojo.connect(this.reviewp[file], "onblur", window.andes.drawing.onWindowBlur);
+ dojo.connect(this.reviewp[file], "onfocus", window.andes.drawing.onWindowFocus);
}
}else if(title=="Principles"){
@@ -108,8 +108,8 @@ dojo.addOnLoad(function() {
var psm=principlesStore.getValue(item,"psm");
// if student clicks on a group, there is no psm.
if(psm){
- andes.help.echo(principlesStore.getValue(item,"label"));
- andes.help.principles(psm);
+ window.andes.help.echo(principlesStore.getValue(item,"label"));
+ window.andes.help.principles(psm);
dijit.byId("majorPrinciples").hide();
}
}
@@ -122,8 +122,8 @@ dojo.addOnLoad(function() {
var psm=principlesStore.getValue(item,"psm");
// if student clicks on a group, there is no psm.
if(psm){
- andes.help.echo(principlesStore.getValue(item,"label"));
- andes.help.principles(psm);
+ window.andes.help.echo(principlesStore.getValue(item,"label"));
+ window.andes.help.principles(psm);
// This is a bit ugly, but close both possible windows:
dijit.byId("allPrinciples").hide();
}
View
16 web-UI/andes/recordIE.js
@@ -3,21 +3,21 @@
var andes = window.opener.andes;
this.onfocus = function(){
//console.log("Window focus, title: ",self.name);
- andes.drawing.onWindowFocus.call(self);
- }
+ window.andes.drawing.onWindowFocus.call(self);
+ };
this.document.onfocusout = function(){
//console.log("Window blur, title: ",self.name);
if (this._activeElement != document.activeElement){
this._activeElement = document.activeElement;
}else{
- andes.drawing.onWindowBlur.call(self);
+ window.andes.drawing.onWindowBlur.call(self);
}
- }
+ };
this.onunload = function(){
//console.log("Window unload, title: ",self.name);
- andes.drawing.onWindowBlur.call(self);
- //andes.api.recordAction({type:"window", name: "IntroVideo", value: "blur"});
- }
-})();
+ window.andes.drawing.onWindowBlur.call(self);
+ //window.andes.api.recordAction({type:"window", name: "IntroVideo", value: "blur"});
+ };
+})();
View
2  web-UI/andes/rpc.js
@@ -7,4 +7,4 @@ dojo.require("dojox.json.schema");
// This stub is in place to make andes.rpc a swappable oject
// for other potential server connections, such as CometD.
- andes.rpc = new dojox.rpc.Service(dojo.moduleUrl("andes", "andes3.smd"));
+ window.andes.rpc = new dojox.rpc.Service(dojo.moduleUrl("andes", "andes3.smd"));
View
4 web-UI/andes/timer.js
@@ -23,10 +23,10 @@ dojo.declare("andes.timer", null, {
var disp;
if(t){
disp = "block";
- this.interval = setInterval(dojo.hitch(this, function(){ this.updateTime(); }), 500);
+ this.interval = window.setInterval(dojo.hitch(this, function(){ this.updateTime(); }), 500);
}else{
disp = "none";
- if(this.interval) clearInterval(this.interval);
+ if(this.interval) window.clearInterval(this.interval);
}
dojo.style(this.node, {"display": disp });
},
View
2  web-UI/andes/variablename.js
@@ -23,7 +23,7 @@ dojo.provide("andes.variablename");
// "H(green house) is the height of the house on Green St."
// "A_{t=0} is the initial area"
-andes.variablename.parse = function(intext){
+window.andes.variablename.parse = function(intext){
if(intext){
// canonicalize whitespace
var cantext = intext.replace(/\s+/g," ");
Please sign in to comment.
Something went wrong with that request. Please try again.