Created
July 13, 2016 17:55
-
-
Save avimar/aa7510afea43418dbc5eb78c5ac12ff9 to your computer and use it in GitHub Desktop.
append a value to the query string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkAndSetAccount(){ | |
var q = riot.route.query(); | |
if (Cookies.get('account')==q.account) return;//already done. | |
if (q.account) { | |
Cookies.set('account',q.account); | |
auth.trigger('switchAccount'); | |
} | |
if (!q.account && Cookies.get('account')!==Cookies.get('accountOriginal')) {//nothing in query string: need to set it | |
//console.log(window.location) | |
var newLocation=window.location.hash; | |
if(!newLocation) return riot.route("account?account="+Cookies.get('account'));//if failure, just send to account page | |
newLocation = newLocation.substring(1);//strip the # from the start | |
if(newLocation.indexOf('?')!==-1) return riot.route(newLocation + "&account="+Cookies.get('account'));//already has a ? | |
return riot.route(newLocation + "?account="+Cookies.get('account')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment