files.js 812 B

123456789101112131415161718
  1. const toggleVisible = ele => ele.style.display = ele.style.display === 'none' ? 'block' : 'none'
  2. const toggleClass = (ele, class1, class2) => ele.className = ele.className === class1 ? class2 : class1
  3. const baseUrl = location.protocol + '//' + window.location.host + '/'
  4. window.addEventListener('DOMContentLoaded', () => {
  5. // Display list of files from day folder
  6. // need to parse as `Array`
  7. Array.from(document.getElementsByClassName('files-list')).forEach(item => {
  8. item.addEventListener('click', event => {
  9. event.preventDefault()
  10. currentElem = event.currentTarget
  11. // get list element
  12. let filePath = currentElem.getAttribute('data-redirect-path')
  13. window.location = baseUrl + 'links?filename=' + filePath
  14. })
  15. })
  16. })