app.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <!-- Basic Uppy styles -->
  2. <link rel="stylesheet" href="/uppy/uppy.min.css">
  3. <div class="DashboardOptions">
  4. <input type="checkbox" id="opts-DashboardInline" checked/><label for="opts-DashboardInline">Display inline</label>
  5. <input type="checkbox" id="opts-autoProceed" checked/><label for="opts-autoProceed">Autoproceed</label>
  6. <input type="checkbox" id="opts-restrictions" checked/><label for="opts-restrictions">Restrictions</label>
  7. <input type="checkbox" id="opts-Webcam" checked/><label for="opts-Webcam">Webcam</label>
  8. <input type="checkbox" id="opts-GoogleDrive" checked/><label for="opts-GoogleDrive">Google Drive</label>
  9. <input type="checkbox" id="opts-Dropbox" checked/><label for="opts-Dropbox">Dropbox</label>
  10. <input type="checkbox" id="opts-Instagram" checked/><label for="opts-Instagram">Instagram</label>
  11. </div>
  12. <!-- Modal trigger -->
  13. <button class="UppyModalOpenerBtn">Open Uppy Dashboard Modal</button>
  14. <div class="DashboardContainer"></div>
  15. <script>
  16. function isObjEmpty (obj) {
  17. return Object.keys(obj).length === 0 && obj.constructor === Object
  18. }
  19. var optionInputs = {
  20. DashboardInline: document.querySelector('#opts-DashboardInline'),
  21. Webcam: document.querySelector('#opts-Webcam'),
  22. GoogleDrive: document.querySelector('#opts-GoogleDrive'),
  23. Dropbox: document.querySelector('#opts-Dropbox'),
  24. Instagram: document.querySelector('#opts-Instagram'),
  25. autoProceed: document.querySelector('#opts-autoProceed'),
  26. restrictions: document.querySelector('#opts-restrictions')
  27. }
  28. var defaultOpts = {
  29. DashboardInline: true,
  30. Webcam: true,
  31. GoogleDrive: true,
  32. Instagram: true,
  33. Dropbox: false,
  34. autoProceed: false,
  35. restrictions: false
  36. }
  37. // try to get options from localStorage, if its empty, set to defaultOpts
  38. window.uppyOptions2 = JSON.parse(localStorage.getItem('uppyOptions2')) || {}
  39. if (isObjEmpty(window.uppyOptions2)) {
  40. window.uppyOptions2 = defaultOpts
  41. localStorage.setItem('uppyOptions2', JSON.stringify(window.uppyOptions2))
  42. }
  43. function toggleModalBtn () {
  44. var btn = document.querySelector('.UppyModalOpenerBtn')
  45. window.uppyOptions2.DashboardInline
  46. ? btn.style.display = 'none'
  47. : btn.style.display = 'block'
  48. }
  49. // Map input state to options
  50. Object.keys(optionInputs).forEach(function (item) {
  51. optionInputs[item].checked = window.uppyOptions2[item]
  52. })
  53. // When input value changes, update options
  54. Object.keys(optionInputs).forEach(function (item) {
  55. optionInputs[item].addEventListener('change', function () {
  56. window.uppyOptions2[item] = optionInputs[item].checked
  57. localStorage.setItem('uppyOptions', JSON.stringify(window.uppyOptions))
  58. toggleModalBtn()
  59. window.uppyInit()
  60. })
  61. })
  62. toggleModalBtn()
  63. </script>