Skip to content

Instantly share code, notes, and snippets.

@famulus
Created May 7, 2013 21:40
Show Gist options
  • Save famulus/5536381 to your computer and use it in GitHub Desktop.
Save famulus/5536381 to your computer and use it in GitHub Desktop.
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