examples.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. function loadNextClip(names) {
  2. if (names.length > 0) {
  3. fetch(`./resources/${names.pop()}.json`).then(response => response.json()).then(clip => {
  4. for (let existingClip of globalState.get('clips')) {
  5. if (existingClip.id == clip.id) return;
  6. }
  7. globalState.mutate('clips', clips => clips.push(clip));
  8. loadNextClip(names);
  9. });
  10. }
  11. }
  12. function loadDefaultClips() {
  13. let defaultClips = ['quinn', 'charlotte', 'jenn', 'lucy', 'bob', 'morgan'].reverse();
  14. fetch('./resources/all.json').then(response => response.json()).then(clip => {
  15. for (let existingClip of globalState.get('clips')) {
  16. if (existingClip.id == clip.id) return;
  17. }
  18. globalState.mutate('clips', clips => clips.push(clip));
  19. globalState.set('previewClip', clip);
  20. globalState.set('playingClip', clip);
  21. loadNextClip(defaultClips);
  22. });
  23. }
  24. function loadExtendedClips() {
  25. let extendedClips = [
  26. 'fern', 'lesley', 'chuck', 'steve', 'david', 'aiden', 'zoe',
  27. 'luna', 'leonard', 'kristen', 'wina', 'chris'
  28. ].reverse();
  29. loadNextClip(extendedClips);
  30. }