]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - assets/common/js/metadata.js
3 function clearLoaders(loaders
) {
4 if (loaders
!= null && loaders
.length
> 0) {
5 [...loaders
].forEach((loader
) => {
6 loader
.classList
.remove('loading-input');
12 const loaders
= document
.querySelectorAll('.loading-input');
13 const inputTitle
= document
.querySelector('input[name="lf_title"]');
14 if (inputTitle
!= null && inputTitle
.value
.length
> 0) {
15 clearLoaders(loaders
);
19 const url
= document
.querySelector('input[name="lf_url"]').value
;
20 const basePath
= document
.querySelector('input[name="js_base_path"]').value
;
22 const xhr
= new XMLHttpRequest();
23 xhr
.open('GET', `${basePath}/admin/metadata?url=${encodeURI(url)}`, true);
24 xhr
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
26 const result
= JSON
.parse(xhr
.response
);
27 Object
.keys(result
).forEach((key
) => {
28 if (result
[key
] !== null && result
[key
].length
) {
29 const element
= document
.querySelector(`input[name="lf_${key}"], textarea[name="lf_${key}"]`);
30 if (element
!= null && element
.value
.length
=== 0) {
31 element
.value
= he
.decode(result
[key
]);
35 clearLoaders(loaders
);