String.prototype.replaceAt = function () { | |
var rlen = arguments[2] == null ? 1 : arguments[2]; | |
return this.substring(0, arguments[0]) + arguments[1] + this.substring(arguments[0] + rlen); | |
}; | |
var currentItem = SDL.Client.UI.ApplicationHost.ViewModels.Navigation.currentNavigationItem(); | |
var navHappy = { | |
init: function () { | |
this.newSrc = this.getNewSrc(); | |
}, | |
getCurrentItem: function () { | |
return SDL.Client.UI.ApplicationHost.ViewModels.Navigation.currentNavigationItem(); | |
}, | |
getCurrentSrc: function () { | |
var currentItem = this.getCurrentItem(); | |
return currentItem.targetDisplay.src; | |
}, | |
getCurrentTCM: function () { | |
var currentSrc = this.getCurrentSrc(); | |
return currentSrc.slice(currentSrc.indexOf("tcm:")+4, currentSrc.length); | |
}, | |
getCurrentPublicationNumber: function () { | |
var currentTCM = this.getCurrentTCM(); | |
return currentTCM.slice(0, currentTCM.indexOf("-")); | |
}, | |
getNewPublicationNumber: function () { | |
return parseInt(this.getCurrentPublicationNumber(), 10) -1; | |
}, | |
getNewTCM: function () { | |
var currentTCM = this.getCurrentTCM(); | |
return currentTCM.replaceAt(0, this.getNewPublicationNumber()); | |
}, | |
getNewSrc: function () { | |
var currentSrc = this.getCurrentSrc(), | |
currentTCM = this.getCurrentTCM(), | |
newTCM = this.getNewTCM(); | |
return currentSrc.replace(currentTCM, newTCM ); | |
}, | |
goToNewPublication: function () { | |
window.location = this.getNewSrc(); | |
} | |
}; | |
navHappy.init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment