album.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. var album = {};
  2. album.get = function(album){
  3. axios.get('/api/album/get/' + album)
  4. .then(function (response) {
  5. document.getElementById('title').innerHTML = response.data.title;
  6. document.getElementById('count').innerHTML = response.data.count + ' files';
  7. var container = document.createElement('div');
  8. container.innerHTML = `<div class="columns is-multiline is-mobile" id="table"></div>`
  9. document.getElementById('container').appendChild(container);
  10. var table = document.getElementById('table');
  11. for(var item of response.data.files){
  12. var div = document.createElement('div');
  13. div.className = "column is-2";
  14. if(item.thumb !== undefined)
  15. div.innerHTML = `<a href="${item.file}" target="_blank"><img src="${item.thumb}"/></a>`;
  16. else
  17. div.innerHTML = `<a href="${item.file}" target="_blank"><h1 class="title">.${item.file.split('.').pop()}</h1></a>`;
  18. table.appendChild(div);
  19. }
  20. })
  21. .catch(function (error) {
  22. return swal("An error ocurred", 'There was an error with the request, please check the console for more information.', "error");
  23. console.log(error);
  24. });
  25. }
  26. window.onload = function () {
  27. var identifier = document.location.pathname;
  28. identifier = identifier.substring(3, identifier.length);
  29. album.get(identifier);
  30. };