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

View File

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

View File

@ -33,7 +33,7 @@ const download = () => {
console.log(ids); console.log(ids);
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: '/api/admin/mangadex/download', url: base_url + 'api/admin/mangadex/download',
data: JSON.stringify({chapters: chapters}), data: JSON.stringify({chapters: chapters}),
contentType: "application/json", contentType: "application/json",
dataType: 'json' dataType: 'json'
@ -47,7 +47,7 @@ const download = () => {
const successCount = parseInt(data.success); const successCount = parseInt(data.success);
const failCount = parseInt(data.fail); const failCount = parseInt(data.fail);
UIkit.modal.confirm(`${successCount} of ${successCount + failCount} chapters added to the download queue. Proceed to the download manager?`).then(() => { 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(); styleModal();
}) })
@ -109,7 +109,7 @@ const search = () => {
return; return;
} }
$.getJSON("/api/admin/mangadex/manga/" + int_id) $.getJSON(`${base_url}api/admin/mangadex/manga/${int_id}`)
.done((data) => { .done((data) => {
if (data.error) { if (data.error) {
alert('danger', 'Failed to get manga info. Error: ' + 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); $('#path-text').text(zipPath);
$('#pages-text').text(pages + ' pages'); $('#pages-text').text(pages + ' pages');
$('#beginning-btn').attr('href', '/reader/' + titleID + '/' + entryID + '/1'); $('#beginning-btn').attr('href', `${base_url}reader/${titleID}/${entryID}/1`);
$('#continue-btn').attr('href', '/reader/' + titleID + '/' + entryID); $('#continue-btn').attr('href', `${base_url}reader/${titleID}/${entryID}`);
$('#read-btn').click(function(){ $('#read-btn').click(function(){
updateProgress(titleID, entryID, pages); updateProgress(titleID, entryID, pages);
@ -39,7 +39,7 @@ function showModal(encodedPath, pages, percentage, encodedeTitle, encodedEntryTi
} }
const updateProgress = (tid, eid, page) => { const updateProgress = (tid, eid, page) => {
let url = `/api/progress/${tid}/${page}` let url = `${base_url}api/progress/${tid}/${page}`
const query = $.param({entry: eid}); const query = $.param({entry: eid});
if (eid) if (eid)
url += `?${query}`; url += `?${query}`;
@ -66,7 +66,7 @@ const renameSubmit = (name, eid) => {
} }
const query = $.param({ entry: 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) if (eid)
url += `?${query}`; url += `?${query}`;
@ -130,7 +130,7 @@ const setupUpload = (eid) => {
if (eid) if (eid)
queryObj['entry'] = eid; queryObj['entry'] = eid;
const query = $.param(queryObj); const query = $.param(queryObj);
const url = `/api/admin/upload/cover?${query}`; const url = `${base_url}api/admin/upload/cover?${query}`;
console.log(url); console.log(url);
UIkit.upload('.upload-field', { UIkit.upload('.upload-field', {
url: url, url: url,

View File

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

View File

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