versions.js 735 B

123456789101112131415161718192021222324252627
  1. vfile = '/cms/versions.txt';
  2. function setversions(data) {
  3. data.split('\n').forEach((item, index) => {
  4. if(item.trim() != '') {
  5. newa = document.createElement('a', );
  6. newa.setAttribute('href', '/cms/' + item + '/');
  7. newa.innerHTML = item;
  8. document.getElementById("other-versions").appendChild(newa);
  9. }
  10. });
  11. }
  12. $(document).ready(function() {
  13. if(sessionStorage.getItem(vfile)) {
  14. setversions(sessionStorage.getItem(vfile));
  15. }
  16. else {
  17. $.ajax({
  18. url: '/cms/versions.txt',
  19. success: function(data) {
  20. sessionStorage.setItem(vfile, data);
  21. setversions(data);
  22. }
  23. });
  24. }
  25. });