Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bvds committed Dec 31, 2013
1 parent d9cead8 commit a977495
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
14 changes: 8 additions & 6 deletions review/consent.html
Expand Up @@ -4,13 +4,15 @@
--> -->
<script type="text/javascript"> <script type="text/javascript">
consentResponse=function(reply){ require(["andes/api"],function(api){
console.log("Dialog button response: ",reply); consentResponse=function(reply){
andes.api.recordAction({type:"set-preference", name: "informed-consent", console.log("Dialog button response: ",reply);
api.recordAction({type:"set-preference", name: "informed-consent",
value: reply + ":default-consent-asu"}); value: reply + ":default-consent-asu"});
dijit.byId("consentDialog").hide(); dijit.byId("consentDialog").hide();
}; };
</script> });
</script>


<h2 class="tall">Consent Form</h2> <h2 class="tall">Consent Form</h2>
<h3 class="tall">Arizona State University</h3> <h3 class="tall">Arizona State University</h3>
Expand Down
25 changes: 13 additions & 12 deletions web-UI/andes/api.js
Expand Up @@ -15,18 +15,6 @@ define([
var MAX_RETRIES = 5, var MAX_RETRIES = 5,
RETRY_TIMEOUT = 2000; // milliseconds 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){ function prepRequest(req){
// add common elements to our requests // add common elements to our requests
var tm = ((new Date()).getTime() - (startTime || (new Date()).getTime()))/1000.0; var tm = ((new Date()).getTime() - (startTime || (new Date()).getTime()))/1000.0;
Expand Down Expand Up @@ -122,6 +110,19 @@ define([
} }


return { 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){ open: function(params){
//console.info("andes.api.open", params); //console.info("andes.api.open", params);
var dfd = queueRequest("open-problem", params); var dfd = queueRequest("open-problem", params);
Expand Down
18 changes: 9 additions & 9 deletions web-UI/andes/startup.js
Expand Up @@ -7,10 +7,11 @@ define([
'dojo/_base/unload', 'dojo/_base/unload',
"andes/WordTip", "andes/WordTip",
"andes/timer", "andes/timer",
"andes/api",
"dojo/on", "dojo/on",
"andes/defaults", "andes/defaults",
"dojo/require" "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 // In the pre-AMD version, andes was a global variable
// Here we make it the object returned by this module. // Here we make it the object returned by this module.
Expand Down Expand Up @@ -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. // FNV-1a for string, 32 bit version, returning hex.
var FNV1aHash = function(x){ var FNV1aHash = function(x){
var hash = 0x811c9dc5; // 2166136261 var hash = 0x811c9dc5; // 2166136261
Expand All @@ -58,6 +64,7 @@ define([
// Andes database requires that clientID be 50 characters. // Andes database requires that clientID be 50 characters.
andes.sessionId = FNV1aHash(andes.userId+andes.projectId) + andes.sessionId = FNV1aHash(andes.userId+andes.projectId) +
'_' + new Date().getTime(); '_' + new Date().getTime();
console.log("andes.sessionId new value ",andes.sessionId);
var andesCookie = { var andesCookie = {
u:andes.userId, u:andes.userId,
p:andes.projectId, p:andes.projectId,
Expand All @@ -79,6 +86,7 @@ define([
if(ck.u==andes.userId && ck.p==andes.projectId){ if(ck.u==andes.userId && ck.p==andes.projectId){
// we can continue the same session // we can continue the same session
andes.sessionId = ck.sid; andes.sessionId = ck.sid;
console.log("andes.sessionId set from cookie to ",andes.sessionId);
}else{ }else{
andes.closeFirst = true; andes.closeFirst = true;
console.warn("Closing previous session", ck.u, andes.userId, ck.p, andes.projectId); console.warn("Closing previous session", ck.u, andes.userId, ck.p, andes.projectId);
Expand All @@ -89,19 +97,13 @@ define([
} }


baseUnload.addOnUnload(function(){ baseUnload.addOnUnload(function(){
require(["andes/api"],function(api){
api.close({}); api.close({});
// but don't clear cookie // but don't clear cookie
});
}); });


// Load defaults // Load defaults
andes.defaults=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 // WordTip needs to be added before conEdit is removed by drawing
andes.WordTip = new wordTip(); andes.WordTip = new wordTip();
console.log("Got WordTip=",andes.WordTip); console.log("Got WordTip=",andes.WordTip);
Expand All @@ -113,7 +115,6 @@ define([
submitButton=dojo.byId("submitButton"); submitButton=dojo.byId("submitButton");
console.log("About to connect submit button ",submitButton); console.log("About to connect submit button ",submitButton);
on(submitButton, "click", function(){ on(submitButton, "click", function(){
require(["andes/api"],function(api){
// Needs to be non-blocking // Needs to be non-blocking
var closer = api.close({}); var closer = api.close({});
closer.then(function(result){ closer.then(function(result){
Expand All @@ -138,7 +139,6 @@ define([
cookie("andes", null, { expires: -1 }); cookie("andes", null, { expires: -1 });
// should look for url from server that // should look for url from server that
// can overrride default. // can overrride default.
});
}); });


// Splash animation // Splash animation
Expand Down

0 comments on commit a977495

Please sign in to comment.