Created
May 7, 2013 21:40
-
-
Save famulus/5536381 to your computer and use it in GitHub Desktop.
This file contains 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
calculateUrl: function(){ | |
var original_location = window.location.href; | |
var has_slide_param = original_location.match(/slide=/); | |
var has_name_param = original_location.match(/name=/); | |
var has_query_param = original_location.match(/\?/); | |
var guid = this.collection.get(this.current_page)[0].guid, | |
new_url; | |
if(has_slide_param){ | |
new_url = original_location.replace(/slide=[^&$]+/,"slide="+guid); | |
}else if(has_query_param){ | |
new_url = (window.location +'&slide='+ guid); | |
}else{ | |
new_url = (window.location +'?slide='+ guid); | |
} | |
new_url = new_url.replace(/[\?&]name=[^&$]+/,''); | |
if(this.multi) { | |
new_url += '&name=' + this.name; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment