Use base url in JS files

This commit is contained in:
Alex Ling 2020-05-23 13:15:54 +00:00
parent eefa8c3982
commit 4a59459773
6 changed files with 15 additions and 15 deletions

View File

@ -5,7 +5,7 @@ function scan() {
$('#scan-status > span').attr('hidden', '');
var color = $('#scan').css('color');
$('#scan').css('color', 'gray');
$.post('/api/admin/scan', function (data) {
$.post(base_url + 'api/admin/scan', function (data) {
var ms = data.milliseconds;
var titles = data.titles;
$('#scan-status > span').text('Scanned ' + titles + ' titles in ' + ms + 'ms');

View File

@ -22,7 +22,7 @@ const loadConfig = () => {
globalConfig.autoRefresh = $('#auto-refresh').prop('checked');
};
const remove = (id) => {
var url = '/api/admin/mangadex/queue/delete';
var url = base_url + 'api/admin/mangadex/queue/delete';
if (id !== undefined)
url += '?' + $.param({id: id});
console.log(url);
@ -43,7 +43,7 @@ const remove = (id) => {
});
};
const refresh = (id) => {
var url = '/api/admin/mangadex/queue/retry';
var url = base_url + 'api/admin/mangadex/queue/retry';
if (id !== undefined)
url += '?' + $.param({id: id});
console.log(url);
@ -67,7 +67,7 @@ const toggle = () => {
$('#pause-resume-btn').attr('disabled', '');
const paused = $('#pause-resume-btn').text() === 'Resume download';
const action = paused ? 'resume' : 'pause';
const url = `/api/admin/mangadex/queue/${action}`;
const url = `${base_url}api/admin/mangadex/queue/${action}`;
$.ajax({
type: 'POST',
url: url,
@ -87,7 +87,7 @@ const load = () => {
console.log('fetching');
$.ajax({
type: 'GET',
url: '/api/admin/mangadex/queue',
url: base_url + 'api/admin/mangadex/queue',
dataType: 'json'
})
.done(data => {

View File

@ -33,7 +33,7 @@ const download = () => {
console.log(ids);
$.ajax({
type: 'POST',
url: '/api/admin/mangadex/download',
url: base_url + 'api/admin/mangadex/download',
data: JSON.stringify({chapters: chapters}),
contentType: "application/json",
dataType: 'json'
@ -47,7 +47,7 @@ const download = () => {
const successCount = parseInt(data.success);
const failCount = parseInt(data.fail);
UIkit.modal.confirm(`${successCount} of ${successCount + failCount} chapters added to the download queue. Proceed to the download manager?`).then(() => {
window.location.href = '/admin/downloads';
window.location.href = base_url + 'admin/downloads';
});
styleModal();
})
@ -109,7 +109,7 @@ const search = () => {
return;
}
$.getJSON("/api/admin/mangadex/manga/" + int_id)
$.getJSON(`${base_url}api/admin/mangadex/manga/${int_id}`)
.done((data) => {
if (data.error) {
alert('danger', 'Failed to get manga info. Error: ' + data.error);

View File

@ -22,8 +22,8 @@ function showModal(encodedPath, pages, percentage, encodedeTitle, encodedEntryTi
$('#path-text').text(zipPath);
$('#pages-text').text(pages + ' pages');
$('#beginning-btn').attr('href', '/reader/' + titleID + '/' + entryID + '/1');
$('#continue-btn').attr('href', '/reader/' + titleID + '/' + entryID);
$('#beginning-btn').attr('href', `${base_url}reader/${titleID}/${entryID}/1`);
$('#continue-btn').attr('href', `${base_url}reader/${titleID}/${entryID}`);
$('#read-btn').click(function(){
updateProgress(titleID, entryID, pages);
@ -39,7 +39,7 @@ function showModal(encodedPath, pages, percentage, encodedeTitle, encodedEntryTi
}
const updateProgress = (tid, eid, page) => {
let url = `/api/progress/${tid}/${page}`
let url = `${base_url}api/progress/${tid}/${page}`
const query = $.param({entry: eid});
if (eid)
url += `?${query}`;
@ -66,7 +66,7 @@ const renameSubmit = (name, eid) => {
}
const query = $.param({ entry: eid });
let url = `/api/admin/display_name/${titleId}/${name}`;
let url = `${base_url}api/admin/display_name/${titleId}/${name}`;
if (eid)
url += `?${query}`;
@ -130,7 +130,7 @@ const setupUpload = (eid) => {
if (eid)
queryObj['entry'] = eid;
const query = $.param(queryObj);
const url = `/api/admin/upload/cover?${query}`;
const url = `${base_url}api/admin/upload/cover?${query}`;
console.log(url);
UIkit.upload('.upload-field', {
url: url,

View File

@ -1,5 +1,5 @@
$(() => {
var target = '/admin/user/edit';
var target = base_url + 'admin/user/edit';
if (username) target += username;
$('form').attr('action', target);
if (error) alert('danger', error);

View File

@ -1,5 +1,5 @@
function remove(username) {
$.post('/api/admin/user/delete/' + username, function(data) {
$.post(base_url + 'api/admin/user/delete/' + username, function(data) {
if (data.success) {
location.reload();
}