Permalink
Browse files

more changes

  • Loading branch information...
bvds committed Dec 31, 2013
1 parent d9cead8 commit a977495d8134c85b5504cd8e54a876e874a333d4
Showing with 30 additions and 27 deletions.
  1. +8 −6 review/consent.html
  2. +13 −12 web-UI/andes/api.js
  3. +9 −9 web-UI/andes/startup.js
View
@@ -4,13 +4,15 @@
-->
<script type="text/javascript">
- consentResponse=function(reply){
- console.log("Dialog button response: ",reply);
- andes.api.recordAction({type:"set-preference", name: "informed-consent",
+ require(["andes/api"],function(api){
+ consentResponse=function(reply){
+ console.log("Dialog button response: ",reply);
+ api.recordAction({type:"set-preference", name: "informed-consent",
value: reply + ":default-consent-asu"});
- dijit.byId("consentDialog").hide();
- };
- </script>
+ dijit.byId("consentDialog").hide();
+ };
+ });
+</script>
<h2 class="tall">Consent Form</h2>
<h3 class="tall">Arizona State University</h3>
View
@@ -15,18 +15,6 @@ define([
var MAX_RETRIES = 5,
RETRY_TIMEOUT = 2000; // milliseconds
- // 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;
- dojo.xhr = function(method,args){
- var headers = args.headers = args.headers || {};
- headers["Client-Id"] = andes.sessionId;
- return andes._originalXhr.apply(dojo,arguments);
- };
- })();
-
function prepRequest(req){
// add common elements to our requests
var tm = ((new Date()).getTime() - (startTime || (new Date()).getTime()))/1000.0;
@@ -122,6 +110,19 @@ define([
}
return {
+
+ // AOP-style function replacement that performs before-advice
+ // to add to the headers on all XHR requests. See dojox/rpc/Client.js
+ setHeaders: function(){
+ console.info("api set headers", andes.sessionId);
+ 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);
+ };
+ },
+
open: function(params){
//console.info("andes.api.open", params);
var dfd = queueRequest("open-problem", params);
View
@@ -7,10 +7,11 @@ define([
'dojo/_base/unload',
"andes/WordTip",
"andes/timer",
+ "andes/api",
"dojo/on",
"andes/defaults",
"dojo/require"
-],function(cookie,ready,ioQuery,json,baseUnload,wordTip,timer,on,defaults,require){ // Pre-AMD version had a function wrapper.
+],function(cookie,ready,ioQuery,json,baseUnload,wordTip,timer,api,on,defaults,require){ // Pre-AMD version had a function wrapper.
// In the pre-AMD version, andes was a global variable
// Here we make it the object returned by this module.
@@ -39,6 +40,11 @@ define([
});
});
};
+
+ // Start timer. Define before sessionId is set
+ var startTime = (new Date()).getTime();
+ andes.timer = new timer(startTime);
+
// FNV-1a for string, 32 bit version, returning hex.
var FNV1aHash = function(x){
var hash = 0x811c9dc5; // 2166136261
@@ -58,6 +64,7 @@ define([
// Andes database requires that clientID be 50 characters.
andes.sessionId = FNV1aHash(andes.userId+andes.projectId) +
'_' + new Date().getTime();
+ console.log("andes.sessionId new value ",andes.sessionId);
var andesCookie = {
u:andes.userId,
p:andes.projectId,
@@ -79,6 +86,7 @@ define([
if(ck.u==andes.userId && ck.p==andes.projectId){
// we can continue the same session
andes.sessionId = ck.sid;
+ console.log("andes.sessionId set from cookie to ",andes.sessionId);
}else{
andes.closeFirst = true;
console.warn("Closing previous session", ck.u, andes.userId, ck.p, andes.projectId);
@@ -89,19 +97,13 @@ define([
}
baseUnload.addOnUnload(function(){
- require(["andes/api"],function(api){
api.close({});
// but don't clear cookie
- });
});
// Load defaults
andes.defaults=defaults;
- // Start timer
- var startTime = (new Date()).getTime();
- andes.timer = new timer(startTime);
-
// WordTip needs to be added before conEdit is removed by drawing
andes.WordTip = new wordTip();
console.log("Got WordTip=",andes.WordTip);
@@ -113,7 +115,6 @@ define([
submitButton=dojo.byId("submitButton");
console.log("About to connect submit button ",submitButton);
on(submitButton, "click", function(){
- require(["andes/api"],function(api){
// Needs to be non-blocking
var closer = api.close({});
closer.then(function(result){
@@ -138,7 +139,6 @@ define([
cookie("andes", null, { expires: -1 });
// should look for url from server that
// can overrride default.
- });
});
// Splash animation

0 comments on commit a977495

Please sign in to comment.