Skip to content

Commit

Permalink
drive UI can now open playground documents
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmiles committed Jun 17, 2014
1 parent 50f2cef commit a52fe68
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion js/realtime-client-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,20 @@ rtclient.REALTIME_MIMETYPE = 'application/vnd.google-apps.drive-sdk';
rtclient.getParams = function() {
var params = {};
var hashFragment = window.location.hash;
var state = window.location.search;
if (hashFragment) {
// split up the query string and store in an object
var paramStrs = hashFragment.slice(1).split("&");
for (var i = 0; i < paramStrs.length; i++) {
var paramStr = paramStrs[i].split("=");
params[paramStr[0]] = unescape(paramStr[1]);
}
} else if (state) {
// For a state (sent from Drive UI)
params.state = state;
// Replace the coded characters with their originals
}

console.log(params);
return params;
}
Expand Down Expand Up @@ -247,7 +253,18 @@ rtclient.parseState = function(stateParam) {
var stateObj = JSON.parse(stateParam);
return stateObj;
} catch(e) {
return null;
try {
var state = stateParam
.replace(/%22/g,'"')
.replace(/%7B/g,'{')
.replace(/%7D/g,'}')
.replace(/%5B/g,'[')
.replace(/%5D/g,']');
// Grab and parse the parameters from the query
return JSON.parse(/{.+}/.exec(state)[0]);
} catch (err) {
return null;
}
}
}

Expand Down

0 comments on commit a52fe68

Please sign in to comment.