aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets/common
diff options
context:
space:
mode:
Diffstat (limited to 'assets/common')
-rw-r--r--assets/common/js/thumbnails-update.js8
1 files changed, 5 insertions, 3 deletions
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 @@
10 * It contains a recursive call to retrieve the thumb of the next link when it succeed. 10 * It contains a recursive call to retrieve the thumb of the next link when it succeed.
11 * It also update the progress bar and other visual feedback elements. 11 * It also update the progress bar and other visual feedback elements.
12 * 12 *
13 * @param {string} basePath Shaarli subfolder for XHR requests
13 * @param {array} ids List of LinkID to update 14 * @param {array} ids List of LinkID to update
14 * @param {int} i Current index in ids 15 * @param {int} i Current index in ids
15 * @param {object} elements List of DOM element to avoid retrieving them at each iteration 16 * @param {object} elements List of DOM element to avoid retrieving them at each iteration
16 */ 17 */
17function updateThumb(ids, i, elements) { 18function updateThumb(basePath, ids, i, elements) {
18 const xhr = new XMLHttpRequest(); 19 const xhr = new XMLHttpRequest();
19 xhr.open('POST', './?do=ajax_thumb_update'); 20 xhr.open('POST', `${basePath}/?do=ajax_thumb_update`);
20 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 21 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
21 xhr.responseType = 'json'; 22 xhr.responseType = 'json';
22 xhr.onload = () => { 23 xhr.onload = () => {
@@ -40,6 +41,7 @@ function updateThumb(ids, i, elements) {
40} 41}
41 42
42(() => { 43(() => {
44 const basePath = document.querySelector('input[name="js_base_path"]').value;
43 const ids = document.getElementsByName('ids')[0].value.split(','); 45 const ids = document.getElementsByName('ids')[0].value.split(',');
44 const elements = { 46 const elements = {
45 progressBar: document.querySelector('.progressbar > div'), 47 progressBar: document.querySelector('.progressbar > div'),
@@ -47,5 +49,5 @@ function updateThumb(ids, i, elements) {
47 thumbnail: document.querySelector('.thumbnail-placeholder'), 49 thumbnail: document.querySelector('.thumbnail-placeholder'),
48 title: document.querySelector('.thumbnail-link-title'), 50 title: document.querySelector('.thumbnail-link-title'),
49 }; 51 };
50 updateThumb(ids, 0, elements); 52 updateThumb(basePath, ids, 0, elements);
51})(); 53})();