Move URL building into one function.
This commit is contained in:
parent
95c99948d7
commit
3c4b1911fd
@ -627,18 +627,12 @@ album.share = function(service) {
|
|||||||
|
|
||||||
album.getArchive = function(albumIDs) {
|
album.getArchive = function(albumIDs) {
|
||||||
|
|
||||||
let link = ''
|
let path = `${ api.path }?function=Album::getArchive&albumIDs=${ albumIDs.join(',') }`
|
||||||
let url = `${ api.path }?function=Album::getArchive&albumIDs=${ albumIDs.join(',') }`
|
let url = lychee.getURL(path)
|
||||||
|
|
||||||
var pos = location.href.indexOf('#')
|
if (lychee.publicMode===true) url += `&password=${ encodeURIComponent(password.value) }`
|
||||||
link = pos!=-1 ? location.href.substring(0, pos) : location.href
|
|
||||||
|
|
||||||
if (location.href.indexOf('index.html')>0) link = link.replace('index.html', url)
|
location.href = url
|
||||||
else link += url
|
|
||||||
|
|
||||||
if (lychee.publicMode===true) link += `&password=${ encodeURIComponent(password.value) }`
|
|
||||||
|
|
||||||
location.href = link
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,6 +417,18 @@ lychee.html = function(literalSections, ...substs) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lychee.getURL = function(path) {
|
||||||
|
|
||||||
|
let pos = location.href.indexOf('#')
|
||||||
|
let url = pos!=-1 ? location.href.substring(0, pos) : location.href
|
||||||
|
|
||||||
|
if (location.href.indexOf('index.html')>0) url = url.replace('index.html', path)
|
||||||
|
else url += path
|
||||||
|
|
||||||
|
return url
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
lychee.error = function(errorThrown, params, data) {
|
lychee.error = function(errorThrown, params, data) {
|
||||||
|
|
||||||
console.error({
|
console.error({
|
||||||
|
@ -635,29 +635,23 @@ photo.share = function(photoID, service) {
|
|||||||
|
|
||||||
photo.getPhoto = function(photoID) {
|
photo.getPhoto = function(photoID) {
|
||||||
|
|
||||||
let link
|
let path = `${ api.path }?function=Photo::getPhoto&photoID=${ photoID }`
|
||||||
let url = `${ api.path }?function=Photo::getPhoto&photoID=${ photoID }`
|
let url = lychee.getURL(path)
|
||||||
|
|
||||||
if (location.href.indexOf('index.html')>0) link = location.href.replace(location.hash, '').replace('index.html', url)
|
if (lychee.publicMode===true) url += `&password=${ encodeURIComponent(password.value) }`
|
||||||
else link = location.href.replace(location.hash, '') + url
|
|
||||||
|
|
||||||
if (lychee.publicMode===true) link += `&password=${ encodeURIComponent(password.value) }`
|
location.href = url
|
||||||
|
|
||||||
location.href = link
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
photo.getArchive = function(photoIDs) {
|
photo.getArchive = function(photoIDs) {
|
||||||
|
|
||||||
let link
|
let path = `${ api.path }?function=Photo::getArchive&photoIDs=${ photoIDs.join(',') }`
|
||||||
let url = `${ api.path }?function=Photo::getArchive&photoIDs=${ photoIDs.join(',') }`
|
let url = lychee.getURL(path)
|
||||||
|
|
||||||
if (location.href.indexOf('index.html')>0) link = location.href.replace(location.hash, '').replace('index.html', url)
|
if (lychee.publicMode===true) url += `&password=${ encodeURIComponent(password.value) }`
|
||||||
else link = location.href.replace(location.hash, '') + url
|
|
||||||
|
|
||||||
if (lychee.publicMode===true) link += `&password=${ encodeURIComponent(password.value) }`
|
location.href = url
|
||||||
|
|
||||||
location.href = link
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,9 +667,8 @@ photo.getDirectLink = function() {
|
|||||||
|
|
||||||
photo.getViewLink = function(photoID) {
|
photo.getViewLink = function(photoID) {
|
||||||
|
|
||||||
let url = 'view.php?p=' + photoID
|
let path = 'view.php?p=' + photoID
|
||||||
|
|
||||||
if (location.href.indexOf('index.html')>0) return location.href.replace('index.html' + location.hash, url)
|
return lychee.getURL(path)
|
||||||
else return location.href.replace(location.hash, url)
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user