From bee33239ed444f9724422fe5234cd79997500519 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 23 Jan 2020 22:26:38 +0100 Subject: Fix all relative link to work with new URL --- assets/common/js/thumbnails-update.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'assets/common/js') diff --git a/assets/common/js/thumbnails-update.js b/assets/common/js/thumbnails-update.js index b66ca3ae..060a730e 100644 --- a/assets/common/js/thumbnails-update.js +++ b/assets/common/js/thumbnails-update.js @@ -16,7 +16,7 @@ */ function updateThumb(ids, i, elements) { const xhr = new XMLHttpRequest(); - xhr.open('POST', '?do=ajax_thumb_update'); + xhr.open('POST', './?do=ajax_thumb_update'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.responseType = 'json'; xhr.onload = () => { -- cgit v1.2.3 From 818b3193ffabec57501e3bdfa997206e3c0671ef Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 13 Jun 2020 11:22:14 +0200 Subject: Explicitly define base and asset path in templates With the new routes, all pages are not all at the same folder level anymore (e.g. /shaare and /shaare/123), so we can't just use './' everywhere. The most consistent way to handle this is to prefix all path with the proper variable, and handle the actual path in controllers. --- assets/common/js/thumbnails-update.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'assets/common/js') diff --git a/assets/common/js/thumbnails-update.js b/assets/common/js/thumbnails-update.js index 060a730e..35608169 100644 --- a/assets/common/js/thumbnails-update.js +++ b/assets/common/js/thumbnails-update.js @@ -10,13 +10,14 @@ * It contains a recursive call to retrieve the thumb of the next link when it succeed. * It also update the progress bar and other visual feedback elements. * + * @param {string} basePath Shaarli subfolder for XHR requests * @param {array} ids List of LinkID to update * @param {int} i Current index in ids * @param {object} elements List of DOM element to avoid retrieving them at each iteration */ -function updateThumb(ids, i, elements) { +function updateThumb(basePath, ids, i, elements) { const xhr = new XMLHttpRequest(); - xhr.open('POST', './?do=ajax_thumb_update'); + xhr.open('POST', `${basePath}/?do=ajax_thumb_update`); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.responseType = 'json'; xhr.onload = () => { @@ -40,6 +41,7 @@ function updateThumb(ids, i, elements) { } (() => { + const basePath = document.querySelector('input[name="js_base_path"]').value; const ids = document.getElementsByName('ids')[0].value.split(','); const elements = { progressBar: document.querySelector('.progressbar > div'), @@ -47,5 +49,5 @@ function updateThumb(ids, i, elements) { thumbnail: document.querySelector('.thumbnail-placeholder'), title: document.querySelector('.thumbnail-link-title'), }; - updateThumb(ids, 0, elements); + updateThumb(basePath, ids, 0, elements); })(); -- cgit v1.2.3 From 764d34a7d347d653414e5f5c632e02499edaef04 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 21 Jun 2020 12:21:31 +0200 Subject: Process token retrieve through Slim controller --- assets/common/js/thumbnails-update.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'assets/common/js') diff --git a/assets/common/js/thumbnails-update.js b/assets/common/js/thumbnails-update.js index 35608169..b37a32f3 100644 --- a/assets/common/js/thumbnails-update.js +++ b/assets/common/js/thumbnails-update.js @@ -33,7 +33,7 @@ function updateThumb(basePath, ids, i, elements) { elements.thumbnail.innerHTML = ``; } if (i < ids.length) { - updateThumb(ids, i, elements); + updateThumb(basePath, ids, i, elements); } } }; -- cgit v1.2.3 From 6132d64748dfc6806ed25f71d2e078a5ed29d071 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 27 Jun 2020 12:08:26 +0200 Subject: Process thumbnail synchronize page through Slim controllers --- assets/common/js/thumbnails-update.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'assets/common/js') diff --git a/assets/common/js/thumbnails-update.js b/assets/common/js/thumbnails-update.js index b37a32f3..3cd4c2a7 100644 --- a/assets/common/js/thumbnails-update.js +++ b/assets/common/js/thumbnails-update.js @@ -17,7 +17,7 @@ */ function updateThumb(basePath, ids, i, elements) { const xhr = new XMLHttpRequest(); - xhr.open('POST', `${basePath}/?do=ajax_thumb_update`); + xhr.open('PATCH', `${basePath}/admin/shaare/${ids[i]}/update-thumbnail`); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.responseType = 'json'; xhr.onload = () => { @@ -30,14 +30,14 @@ function updateThumb(basePath, ids, i, elements) { elements.current.innerHTML = i; elements.title.innerHTML = response.title; if (response.thumbnail !== false) { - elements.thumbnail.innerHTML = ``; + elements.thumbnail.innerHTML = ``; } if (i < ids.length) { updateThumb(basePath, ids, i, elements); } } }; - xhr.send(`id=${ids[i]}`); + xhr.send(); } (() => { -- cgit v1.2.3