album.js 1.2 KB

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