Skip to content

Commit

Permalink
Tools now show up OK.
Browse files Browse the repository at this point in the history
Undo andes3.smd from commit 373786e
Fix errors found by js2-mode.  Mostly missing semicolons.
Still need to clean up module loading in index.html.
Moved WordTip to load earlier, but after dom.
Use return value for messages instead of adding to andes variable.
Some more updating to new Dojo.
  • Loading branch information
bvds committed Dec 27, 2013
1 parent c1266a3 commit a7aeb3e
Show file tree
Hide file tree
Showing 22 changed files with 93 additions and 76 deletions.
8 changes: 4 additions & 4 deletions web-UI/andes/Combo.js
Expand Up @@ -40,7 +40,7 @@ andes.Combo = 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 @@ -141,7 +141,7 @@ andes.Combo = 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 @@ -206,7 +206,7 @@ andes.Combo = oo.declare(
array.forEach(handles, function(handle){handle.remove();},dojo); array.forEach(handles, function(handle){handle.remove();},dojo);
} }
} }
) );


andes.buttonCombo = dojox.drawing.util.oo.declare( andes.buttonCombo = dojox.drawing.util.oo.declare(
// summary: // summary:
Expand Down Expand Up @@ -242,5 +242,5 @@ andes.buttonCombo = dojox.drawing.util.oo.declare(
} }


} }
) );
}); });
2 changes: 1 addition & 1 deletion web-UI/andes/PreferenceRegistry.js
Expand Up @@ -53,5 +53,5 @@ define([
return false; return false;
} }
} }
} };
}); });
16 changes: 10 additions & 6 deletions web-UI/andes/WordTip.js
@@ -1,8 +1,10 @@
define([ define([
'dojo/_base/declare', 'dojo/_base/declare',
'andes/startup', 'andes/startup',
'dojo/on' 'dojo/on',
], function(declare,andes,on){ "dojo/dom",
"dojo/domReady!" // Needed to locate "conEdit"
], function(declare,andes,on,dom){
return declare(null,{ return declare(null,{


// Summary: // Summary:
Expand All @@ -14,7 +16,9 @@ define([
stencil: null, stencil: null,


constructor: function(){ constructor: function(){
this.conEdit = dojo.byId("conEdit"); console.info("Constructing WordTip, this=",this);
this.conEdit = dom.byId("conEdit");
console.assert(this.conEdit,"conEdit is missing (already removed by drawing?).");
on(this.conEdit, "keydown", this, "textMonitor"); on(this.conEdit, "keydown", this, "textMonitor");
console.log("I've got conedit now", this.conEdit); console.log("I've got conedit now", this.conEdit);
}, },
Expand Down Expand Up @@ -45,7 +49,7 @@ define([
var cn = on(document,"mouseup",this, function(evt){ var cn = on(document,"mouseup",this, function(evt){
cn.remove(); cn.remove();
dijit.hideTooltip(this.conEdit); dijit.hideTooltip(this.conEdit);
}) });
}, },


removeBreaks: function(txt){ removeBreaks: function(txt){
Expand Down
2 changes: 1 addition & 1 deletion web-UI/andes/andes3.smd
@@ -1,7 +1,7 @@
{ {
"envelope": "JSON-RPC-2.0", "envelope": "JSON-RPC-2.0",
"transport": "POST", "transport": "POST",
"target": "/help-test", "target": "/help",
"SMDVersion": "2.0", "SMDVersion": "2.0",
"description": "Client-server communication for Andes3. The server is be allowed to make arbitrary changes to graphics objects in the solution-step and seek-help methods. This specification should match web-UI/Documentation/AsuDocs/nokes-example-json.txt. There is a lot of duplication of code in this version. Also, this enforces strict typing for return parameters, by setting additionalProperties to false.", "description": "Client-server communication for Andes3. The server is be allowed to make arbitrary changes to graphics objects in the solution-step and seek-help methods. This specification should match web-UI/Documentation/AsuDocs/nokes-example-json.txt. There is a lot of duplication of code in this version. Also, this enforces strict typing for return parameters, by setting additionalProperties to false.",
"parameters": [ "parameters": [
Expand Down
14 changes: 7 additions & 7 deletions web-UI/andes/api.js
Expand Up @@ -2,10 +2,10 @@ define([
"andes/startup", "andes/startup",
"andes/rpc", "andes/rpc",
"andes/timer", "andes/timer",
"andes/messages",
"andes/api", "andes/api",
"andes/error", "andes/error"
"andes/messages" ],function(andes,rpc,timer,messages){ // Pre-AMD version had a function wrapper.
],function(andes,rpc,timer){ // Pre-AMD version had a function wrapper.


var startTime = null, var startTime = null,
requestInFlight = false, requestInFlight = false,
Expand All @@ -18,7 +18,7 @@ define([
// 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", andes.sessionId);
andes._originalXhr = dojo.xhr; 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 || {};
Expand Down Expand Up @@ -62,7 +62,7 @@ define([
// 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 = 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 + ")";
Expand All @@ -86,8 +86,8 @@ define([
}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 = messages.connection(MAX_RETRIES);
console.dir(mo) console.dir(mo);
andes.error({ 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>",
Expand Down
18 changes: 9 additions & 9 deletions web-UI/andes/convert.js
Expand Up @@ -42,7 +42,7 @@ define([
x:box.x2 + gap, x:box.x2 + gap,
y:box.y1, y:box.y1,
showEmpty:true} showEmpty:true}
} };
}, },


andesToDrawing: function(o){ andesToDrawing: function(o){
Expand All @@ -58,7 +58,7 @@ define([
itemType:o.items[0].type, itemType:o.items[0].type,
items:dojo.map(o.items,andes.convert.andesToDrawing, this), items:dojo.map(o.items,andes.convert.andesToDrawing, this),
checked: o.checked || [] checked: o.checked || []
} };
return obj; return obj;
} }
if(o.x==undefined || o.y===undefined){ if(o.x==undefined || o.y===undefined){
Expand Down Expand Up @@ -87,7 +87,7 @@ define([
cy:o.y + o.height/2, cy:o.y + o.height/2,
rx:o.width/2, rx:o.width/2,
ry:o.height/2 ry:o.height/2
} };
}else if(o.type=="radio"){ }else if(o.type=="radio"){
buttonWidth=defaults.button.radioButtonRadius; buttonWidth=defaults.button.radioButtonRadius;
obj.buttonType=o.type; obj.buttonType=o.type;
Expand Down Expand Up @@ -143,7 +143,7 @@ define([
text:dojox.drawing.util.typeset.convertHTML(o.text) || "" text:dojox.drawing.util.typeset.convertHTML(o.text) || ""
}, },
enabled: false // treat as mode=locked enabled: false // treat as mode=locked
} };
}else if(o.type=="line" || o.type=="vector" || o.type=="rectangle" || o.type=="ellipse"){ }else if(o.type=="line" || o.type=="vector" || o.type=="rectangle" || o.type=="ellipse"){
// separate objects // separate objects
// match logic in drawingToAndes // match logic in drawingToAndes
Expand Down Expand Up @@ -180,7 +180,7 @@ define([
}, },
deleteEmptyCreate: false, deleteEmptyCreate: false,
deleteEmptyModify: false deleteEmptyModify: false
} };
}else if(o.type=="statement" || o.type=="equation"){ }else if(o.type=="statement" || o.type=="equation"){
obj.data.text = o.text; obj.data.text = o.text;
}else if(o.type=="axes"){ }else if(o.type=="axes"){
Expand All @@ -205,7 +205,7 @@ define([
b[nm] = Math.round(b[nm]); b[nm] = Math.round(b[nm]);
} }
return b; return b;
} };
// combo............... // combo...............
var combo, statement, sbox, id = item.id; var combo, statement, sbox, id = item.id;
if(item.type=="andes.Combo"){ if(item.type=="andes.Combo"){
Expand All @@ -225,7 +225,7 @@ define([
type:item.group.type, type:item.group.type,
action:action, action:action,
checked:item.group.checked checked:item.group.checked
} };
return obj; return obj;
}; };


Expand All @@ -237,7 +237,7 @@ define([
type:type, type:type,
id:id, id:id,
mode: "unknown" mode: "unknown"
} };


if(type!="vector" && type!="line" && type!="axes"){ if(type!="vector" && type!="line" && type!="axes"){
obj.width = box.w; obj.width = box.w;
Expand Down Expand Up @@ -295,6 +295,6 @@ define([


return obj; return obj;
} }
} };


}); });
6 changes: 3 additions & 3 deletions web-UI/andes/defaults.js
Expand Up @@ -269,7 +269,7 @@ define([
if(obj.push){ if(obj.push){
o = []; o = [];
for(var i=0; i<obj.length;i++){ for(var i=0; i<obj.length;i++){
o.push(cpy(obj[i])) o.push(cpy(obj[i]));
} }
return o; return o;
} }
Expand All @@ -279,12 +279,12 @@ define([
if(typeof(obj[nm])=="object"){ if(typeof(obj[nm])=="object"){
o[nm] = cpy(obj[nm]); o[nm] = cpy(obj[nm]);
}else{ }else{
o[nm] = obj[nm] o[nm] = obj[nm];
} }
} }
} }
return o; return o;
} };
var o = cpy(this); var o = cpy(this);
o.current = o.norm; o.current = o.norm;
o.currentHit = o.hitNorm; o.currentHit = o.hitNorm;
Expand Down
14 changes: 7 additions & 7 deletions web-UI/andes/drawing.js
Expand Up @@ -135,7 +135,7 @@ define([
// no text. will be deleted. // no text. will be deleted.
return; return;
} }
console.log("ADD EQU OR STT>>>", item.customType) console.log("ADD EQU OR STT>>>", item.customType);
this.add(item, true); this.add(item, true);
} }
}, },
Expand All @@ -159,7 +159,7 @@ define([
} }
}else if(item.buttonType == "radio"){ }else if(item.buttonType == "radio"){
item.group.checked=[item.value]; item.group.checked=[item.value];
var myId=item.id var myId=item.id;
dojo.forEach(item.buttons,function(button){ dojo.forEach(item.buttons,function(button){
if(button.id == myId){ if(button.id == myId){
if(!button.selected){button.select();} if(!button.selected){button.select();}
Expand Down Expand Up @@ -220,14 +220,14 @@ define([
item.mod = true; // disable save to server, else we get a recursive call item.mod = true; // disable save to server, else we get a recursive call
item.attr(andes.defaults["unknown"]); item.attr(andes.defaults["unknown"]);
item.mod = false; // restore save to sever item.mod = false; // restore save to sever
var data = andes.convert.drawingToAndes(item, "modify-object") var data = andes.convert.drawingToAndes(item, "modify-object");
console.info("Save mod to server", data); console.info("Save mod to server", data);
this.save(data); this.save(data);
}); });


if(saveToServer){ if(saveToServer){
// we need to save it to the server // we need to save it to the server
var data = andes.convert.drawingToAndes(item, "new-object") var data = andes.convert.drawingToAndes(item, "new-object");
console.info("Save new to server:", data); console.info("Save new to server:", data);
this.save(data); this.save(data);
} }
Expand Down Expand Up @@ -258,7 +258,7 @@ define([
var ar = m.id.match(/\d/g); var ar = m.id.match(/\d/g);
if(!ar || !ar.length){ return 0; } if(!ar || !ar.length){ return 0; }
return parseInt(ar.join(""),10); return parseInt(ar.join(""),10);
} };
var idNum = 0; var idNum = 0;
dojo.forEach(data, function(m){ dojo.forEach(data, function(m){
idNum = Math.max(getNum(m), idNum); idNum = Math.max(getNum(m), idNum);
Expand Down Expand Up @@ -497,15 +497,15 @@ define([
// //
// setting 'this' // setting 'this'
this.loadProject = function(){ this.loadProject = function(){
console.info("load server data", andes.userId, andes.projectId, andes.sectionId) 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}) andes.api.open({user:andes.userId, problem:andes.projectId,section:andes.sectionId,extra:andes.extra})
.addCallback(this, function(data){ .addCallback(this, function(data){
setTimeout(dojo.hitch(this, function(){ setTimeout(dojo.hitch(this, function(){
this.onLoad(data); this.onLoad(data);
}),0); }),0);
}) })
.addErrback(this, "onError"); .addErrback(this, "onError");
} };
if(andes.closeFirst){ if(andes.closeFirst){
// a previous project session is open. close it. // a previous project session is open. close it.
andes.api.close({}).addCallback(this, "loadProject").addErrback(this, "onError"); andes.api.close({}).addCallback(this, "loadProject").addErrback(this, "onError");
Expand Down
3 changes: 2 additions & 1 deletion web-UI/andes/error.js
Expand Up @@ -96,6 +96,7 @@ define([


if(false){ if(false){
ready(function(){ ready(function(){
console.info("andes/error.js: start logging errors");
dialog = new _Error({ dialog = new _Error({
id: "andesErrorDialog", id: "andesErrorDialog",
title: "Error", title: "Error",
Expand All @@ -111,7 +112,7 @@ define([
console.log("Window error: ",msg,"; url: ",url, "; line: ",line,"."); console.log("Window error: ",msg,"; url: ",url, "; line: ",line,".");
// Returning 'false' triggers the execution of the built-in error handler. // Returning 'false' triggers the execution of the built-in error handler.
return !dojoConfig.isDebug; return !dojoConfig.isDebug;
} };
}); });
}; };
}); });
1 change: 1 addition & 0 deletions web-UI/andes/help.js
Expand Up @@ -131,6 +131,7 @@ define([
} }


ready(function(){ ready(function(){
console.info("andes/help.js: Wire up the help button");
on(dijit.byId("helpSubmit"), "onClick", function(){ on(dijit.byId("helpSubmit"), "onClick", function(){
var q = dijit.byId("helpInput").get("value"), var q = dijit.byId("helpInput").get("value"),
h = q ? {action:"get-help", text:q} : {action:"help-button"}; h = q ? {action:"get-help", text:q} : {action:"help-button"};
Expand Down
3 changes: 2 additions & 1 deletion web-UI/andes/main.js
Expand Up @@ -16,7 +16,8 @@ define([
// Pre-AMD body of main.js moved to startup.js. // Pre-AMD body of main.js moved to startup.js.
// Pre-AMD version had "andes.drawing.load();" at very end of the file. // Pre-AMD version had "andes.drawing.load();" at very end of the file.
console.log("object returned by andes/drawing: ",drawing); console.log("object returned by andes/drawing: ",drawing);
d= new drawing(); var d= new drawing();
d.load(); d.load();
console.info("Finished with andes/main.js");
return d; return d;
}); });
5 changes: 3 additions & 2 deletions web-UI/andes/menu.js
Expand Up @@ -6,11 +6,12 @@ define([
"dojo/on", "dojo/on",
"andes/options", "andes/options",
"dijit/Menu", "dijit/Menu",
"dijit/MenuSeparator", "dijit/MenuSeparator"
],function(dom,registry,andes,ready,on,options){ ],function(dom,registry,andes,ready,on,options){
// In the pre-AMD version, the body was wrapped // In the pre-AMD version, the body was wrapped
// in "dojo.addOnLoad(function(){ ... }) // in "dojo.addOnLoad(function(){ ... })
ready(function(){ ready(function(){
console.info("andes/menu.js: wire up menus");
// Add problem name to menu // Add problem name to menu
dom.byId("problemName").innerHTML = andes.projectId; dom.byId("problemName").innerHTML = andes.projectId;


Expand Down Expand Up @@ -109,7 +110,7 @@ define([


// Setup the menu onScreen // Setup the menu onScreen
var cn = on(_drawing, "onSurfaceReady", function(){ var cn = on(_drawing, "onSurfaceReady", function(){
cn.remove; cn.remove();


var node = null; var node = null;
on(_drawing.mouse, "onDown", function(evt){ on(_drawing.mouse, "onDown", function(evt){
Expand Down
8 changes: 3 additions & 5 deletions web-UI/andes/messages.js
@@ -1,6 +1,4 @@
define([ define([], function(){
"andes/startup"
], function(andes){


// This files contains general message strings // This files contains general message strings
// used for error handling (and could be used // used for error handling (and could be used
Expand All @@ -10,7 +8,7 @@ define([
// mechanism. // mechanism.




andes.messages = { return {
// get message based on error type // get message based on error type
server: function(){ server: function(){
return { return {
Expand All @@ -33,5 +31,5 @@ define([
action:"Check your internet connection and try again. There also may be server problems that will be corrected in a few minutes." action:"Check your internet connection and try again. There also may be server problems that will be corrected in a few minutes."
}; };
} }
} };
}); });
7 changes: 4 additions & 3 deletions web-UI/andes/options.js
Expand Up @@ -45,15 +45,16 @@ return declare(null,{


constructor: function(){ constructor: function(){
// Link up references to the HTML/Dijits // Link up references to the HTML/Dijits
for(var nm in this.userWidgets){ var nm;
for(nm in this.userWidgets){
this[nm] = dijit.byId(this.userWidgets[nm]); this[nm] = dijit.byId(this.userWidgets[nm]);
} }
for(var nm in this.userVisuals){ for(nm in this.userVisuals){
this[nm] = dojo.byId(this.userVisuals[nm]); this[nm] = dojo.byId(this.userVisuals[nm]);
} }


// Register preferences // Register preferences
for(var nm in this._prefs){ for(nm in this._prefs){
preferenceRegistry.registerPref(nm, this[this._prefs[nm]], this); preferenceRegistry.registerPref(nm, this[this._prefs[nm]], this);
} }


Expand Down

0 comments on commit a7aeb3e

Please sign in to comment.