Navigation Menu

Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #233 from darkwing/querystring-next-enhancement
Browse files Browse the repository at this point in the history
Cleaning up the 'next' parameter in AJAX call to prevent empty next
  • Loading branch information
groovecoder committed May 30, 2012
2 parents df5df5e + d481f31 commit 62b9f90
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions media/js/mdn/init.js
Expand Up @@ -43,9 +43,9 @@ jQuery.fn.placeholder = function(new_value) {

/* Parse a querystring into an object */
jQuery.extend({
parseQuerystring: function(){
parseQuerystring: function(str){
var nvpair = {},
qs = window.location.search.replace("?", ""),
qs = (str || window.location.search).replace("?", ""),
pairs = qs.split("&");

$.each(pairs, function(i, v){
Expand Down Expand Up @@ -143,8 +143,16 @@ jQuery.extend({
// then show the signed-out block again
$signedOutList.hide();

$.get($signedOutList.attr('data-browserid-header-signin-html'), {
next: $.parseQuerystring().next || window.location.pathname
// Retrieve the login url
var url = $signedOutList.attr('data-browserid-header-signin-html');

// Split the URL, find the next value
var urlSplit = url.split("?"),
rootUrl = urlSplit.shift(),
qstring = urlSplit.join("?");

$.get(rootUrl, {
next: $.parseQuerystring(qstring).next || $.parseQuerystring().next || window.location.pathname
}, function(content) {
$signedOutList.html(content).each(function() {
$('.toggle', $(this)).click(function() {
Expand Down

0 comments on commit 62b9f90

Please sign in to comment.