jclic 2.2.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +5 -7
  2. package/dist-node/jclic-node.js +14157 -0
  3. package/dist-node/jclic-node.umd.cjs +530 -0
  4. package/package.json +38 -26
  5. package/.vscode/launch.json +0 -33
  6. package/.vscode/settings.json +0 -13
  7. package/CHANGELOG.md +0 -672
  8. package/TRANSLATIONS.md +0 -11
  9. package/build-locales.mjs +0 -82
  10. package/dist/jclic-node.js +0 -31680
  11. package/dist/jclic-node.js.map +0 -1
  12. package/dist/jclic.components.LICENSE +0 -2254
  13. package/dist/jclic.min.js +0 -27
  14. package/dist/jclic.min.js.map +0 -1
  15. package/eslint.config.mjs +0 -31
  16. package/jsdoc.config.js +0 -71
  17. package/locales/ar.po +0 -244
  18. package/locales/ast.po +0 -246
  19. package/locales/bs.po +0 -247
  20. package/locales/ca.po +0 -248
  21. package/locales/ca_ES@valencia.po +0 -248
  22. package/locales/cs.po +0 -244
  23. package/locales/da.po +0 -244
  24. package/locales/de.po +0 -246
  25. package/locales/el.po +0 -244
  26. package/locales/es.po +0 -248
  27. package/locales/eu.po +0 -244
  28. package/locales/fr.po +0 -244
  29. package/locales/gl.po +0 -244
  30. package/locales/he.po +0 -244
  31. package/locales/hr.po +0 -245
  32. package/locales/it.po +0 -246
  33. package/locales/ja.po +0 -242
  34. package/locales/jclic.js.pot +0 -241
  35. package/locales/nb_NO.po +0 -244
  36. package/locales/nl.po +0 -244
  37. package/locales/pl.po +0 -244
  38. package/locales/pt.po +0 -244
  39. package/locales/pt_BR.po +0 -248
  40. package/locales/ro.po +0 -248
  41. package/locales/ru.po +0 -245
  42. package/locales/ta.po +0 -244
  43. package/locales/tr.po +0 -246
  44. package/locales/uk.po +0 -247
  45. package/locales/vec.po +0 -244
  46. package/locales/zh_TW.po +0 -246
  47. package/patches/po2json+1.0.0-beta-3.patch +0 -12
  48. package/src/AWT.js +0 -2067
  49. package/src/Activity.js +0 -1311
  50. package/src/Deps.js +0 -232
  51. package/src/GlobalData.js +0 -5
  52. package/src/JClic.js +0 -196
  53. package/src/JClicPlayer.js +0 -1308
  54. package/src/PlayerHistory.js +0 -305
  55. package/src/Utils.js +0 -1355
  56. package/src/activities/associations/ComplexAssociation.js +0 -321
  57. package/src/activities/associations/SimpleAssociation.js +0 -519
  58. package/src/activities/memory/MemoryGame.js +0 -423
  59. package/src/activities/panels/Explore.js +0 -349
  60. package/src/activities/panels/Identify.js +0 -356
  61. package/src/activities/panels/InformationScreen.js +0 -262
  62. package/src/activities/panels/Menu.js +0 -209
  63. package/src/activities/panels/icons/ico00.png +0 -0
  64. package/src/activities/panels/icons/ico01.png +0 -0
  65. package/src/activities/panels/icons/ico02.png +0 -0
  66. package/src/activities/panels/icons/ico03.png +0 -0
  67. package/src/activities/panels/icons/icofolder.png +0 -0
  68. package/src/activities/puzzles/DoublePuzzle.js +0 -424
  69. package/src/activities/puzzles/ExchangePuzzle.js +0 -374
  70. package/src/activities/puzzles/HolePuzzle.js +0 -360
  71. package/src/activities/text/Complete.js +0 -127
  72. package/src/activities/text/Evaluator.js +0 -534
  73. package/src/activities/text/FillInBlanks.js +0 -426
  74. package/src/activities/text/IdentifyText.js +0 -253
  75. package/src/activities/text/OrderText.js +0 -421
  76. package/src/activities/text/TextActivityBase.js +0 -557
  77. package/src/activities/text/TextActivityDocument.js +0 -660
  78. package/src/activities/text/WrittenAnswer.js +0 -557
  79. package/src/activities/textGrid/CrossWord.js +0 -565
  80. package/src/activities/textGrid/WordSearch.js +0 -458
  81. package/src/activities/textGrid/icons/hIcon.svg +0 -3
  82. package/src/activities/textGrid/icons/vIcon.svg +0 -3
  83. package/src/automation/AutoContentProvider.js +0 -182
  84. package/src/automation/arith/Arith.js +0 -864
  85. package/src/bags/ActivitySequence.js +0 -318
  86. package/src/bags/ActivitySequenceElement.js +0 -161
  87. package/src/bags/ActivitySequenceJump.js +0 -140
  88. package/src/bags/ConditionalJumpInfo.js +0 -113
  89. package/src/bags/JumpInfo.js +0 -136
  90. package/src/bags/MediaBag.js +0 -215
  91. package/src/bags/MediaBagElement.js +0 -516
  92. package/src/boxes/AbstractBox.js +0 -699
  93. package/src/boxes/ActiveBagContent.js +0 -494
  94. package/src/boxes/ActiveBox.js +0 -810
  95. package/src/boxes/ActiveBoxBag.js +0 -357
  96. package/src/boxes/ActiveBoxContent.js +0 -484
  97. package/src/boxes/ActiveBoxGrid.js +0 -179
  98. package/src/boxes/BoxBag.js +0 -500
  99. package/src/boxes/BoxBase.js +0 -398
  100. package/src/boxes/BoxConnector.js +0 -325
  101. package/src/boxes/TextGrid.js +0 -887
  102. package/src/boxes/TextGridContent.js +0 -215
  103. package/src/init-jsdom.js +0 -65
  104. package/src/jclic-node.js +0 -219
  105. package/src/media/ActiveMediaBag.js +0 -145
  106. package/src/media/ActiveMediaPlayer.js +0 -297
  107. package/src/media/AudioBuffer.js +0 -219
  108. package/src/media/EventSounds.js +0 -169
  109. package/src/media/EventSoundsElement.js +0 -155
  110. package/src/media/MediaContent.js +0 -328
  111. package/src/media/MidiAudioPlayer.js +0 -254
  112. package/src/media/icons/audio.svg +0 -3
  113. package/src/media/icons/generic.svg +0 -3
  114. package/src/media/icons/mic.svg +0 -3
  115. package/src/media/icons/movie.svg +0 -3
  116. package/src/media/icons/music.svg +0 -3
  117. package/src/media/icons/url.svg +0 -3
  118. package/src/media/sounds/actionError.mp3 +0 -0
  119. package/src/media/sounds/actionOk.mp3 +0 -0
  120. package/src/media/sounds/click.mp3 +0 -0
  121. package/src/media/sounds/finishedError.mp3 +0 -0
  122. package/src/media/sounds/finishedOk.mp3 +0 -0
  123. package/src/media/sounds/start.mp3 +0 -0
  124. package/src/project/JClicProject.js +0 -282
  125. package/src/project/ProjectSettings.js +0 -273
  126. package/src/report/ActionReg.js +0 -123
  127. package/src/report/ActivityReg.js +0 -271
  128. package/src/report/EncryptMin.js +0 -210
  129. package/src/report/Reporter.js +0 -727
  130. package/src/report/SCORM.js +0 -272
  131. package/src/report/SequenceReg.js +0 -275
  132. package/src/report/SessionReg.js +0 -340
  133. package/src/report/SessionStorageReporter.js +0 -131
  134. package/src/report/TCPReporter.js +0 -628
  135. package/src/shapers/ClassicJigSaw.js +0 -138
  136. package/src/shapers/Holes.js +0 -77
  137. package/src/shapers/JigSaw.js +0 -161
  138. package/src/shapers/Rectangular.js +0 -78
  139. package/src/shapers/Shaper.js +0 -386
  140. package/src/shapers/TriangularJigSaw.js +0 -121
  141. package/src/skins/BlueSkin.js +0 -80
  142. package/src/skins/Counter.js +0 -152
  143. package/src/skins/CustomSkin.js +0 -412
  144. package/src/skins/DefaultSkin.js +0 -376
  145. package/src/skins/EmptySkin.js +0 -82
  146. package/src/skins/GreenSkin.js +0 -94
  147. package/src/skins/MiniSkin.js +0 -130
  148. package/src/skins/OrangeSkin.js +0 -78
  149. package/src/skins/SimpleSkin.js +0 -92
  150. package/src/skins/Skin.js +0 -1021
  151. package/src/skins/assets/actionsIcon.svg +0 -3
  152. package/src/skins/assets/appLogo.svg +0 -8
  153. package/src/skins/assets/basic.css +0 -41
  154. package/src/skins/assets/closeDialogIcon.svg +0 -3
  155. package/src/skins/assets/closeIcon.svg +0 -3
  156. package/src/skins/assets/copyIcon.svg +0 -3
  157. package/src/skins/assets/fullScreenExitIcon.svg +0 -3
  158. package/src/skins/assets/fullScreenIcon.svg +0 -3
  159. package/src/skins/assets/infoIcon.svg +0 -3
  160. package/src/skins/assets/main.css +0 -43
  161. package/src/skins/assets/mainHalf.css +0 -23
  162. package/src/skins/assets/mainTwoThirds.css +0 -23
  163. package/src/skins/assets/mini.css +0 -15
  164. package/src/skins/assets/nextIcon.svg +0 -3
  165. package/src/skins/assets/okDialogIcon.svg +0 -3
  166. package/src/skins/assets/prevIcon.svg +0 -3
  167. package/src/skins/assets/reports.css +0 -156
  168. package/src/skins/assets/reportsIcon.svg +0 -3
  169. package/src/skins/assets/scoreIcon.svg +0 -3
  170. package/src/skins/assets/simple.css +0 -16
  171. package/src/skins/assets/simpleHalf.css +0 -11
  172. package/src/skins/assets/simpleTwoThirds.css +0 -11
  173. package/src/skins/assets/timeIcon.svg +0 -4
  174. package/src/skins/assets/waitAnim.css +0 -54
  175. package/src/skins/assets/waitImgBig.svg +0 -3
  176. package/src/skins/assets/waitImgSmall.svg +0 -3
  177. package/webpack.config.mjs +0 -169
@@ -1,254 +0,0 @@
1
- /**
2
- * File : media/MidiAudioPlayer.js
3
- * Created : 11/10/2018
4
- * By : Francesc Busquets <francesc@gmail.com>
5
- *
6
- * JClic.js
7
- * An HTML5 player of JClic activities
8
- * https://projectestac.github.io/jclic.js
9
- *
10
- * @source https://github.com/projectestac/jclic.js
11
- *
12
- * @license EUPL-1.2
13
- * @licstart
14
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
15
- *
16
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
17
- * the European Commission- subsequent versions of the EUPL (the "Licence");
18
- * You may not use this work except in compliance with the Licence.
19
- *
20
- * You may obtain a copy of the Licence at:
21
- * https://joinup.ec.europa.eu/software/page/eupl
22
- *
23
- * Unless required by applicable law or agreed to in writing, software
24
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
25
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
26
- * Licence for the specific language governing permissions and limitations
27
- * under the Licence.
28
- * @licend
29
- * @module
30
- */
31
-
32
- /* global window */
33
-
34
- import MidiPlayer from '@francesc/basic-midi-player-js';
35
- import { log } from '../Utils.js';
36
-
37
- // TODO: Use multiple instruments, at least one for each track
38
- // TODO: Use multiple midi channels (currently flattened to a single channel)
39
- // TODO: Use of channel 10 for percussion instruments
40
- // TODO: ... build a real MIDI player!!
41
-
42
- /**
43
- * A simple MIDI player based on MidiPlayerJS
44
- * https://github.com/grimmdude/MidiPlayerJS
45
- * See also: http://www.midijs.net (https://github.com/babelsberg/babelsberg-js/tree/master/midijs)
46
- */
47
- export class MidiAudioPlayer {
48
- /**
49
- * MidiAudioPlayer constructor
50
- * @param {external:ArrayBuffer} data - The MIDI file content, in ArrayBuffer format
51
- * @param {object} [options={}] - Optional params related to the type of soundfont used. Valid options inside this object are:<br>
52
- * - `MIDISoundFontObject`: An object containing the full soundfont data. When this param is provided, no other one will be used.
53
- * - `MIDISoundFontBase`: The URL used as base for the current collection of MIDI soundfonts. Defaults to `https://clic.xtec.cat/dist/jclic.js/soundfonts/MusyngKite`
54
- * - `MIDISoundFontName`: The MIDI instrument name. Defaults to `acoustic_grand_piano`. See [MIDI.js Soundfonts](https://github.com/gleitz/midi-js-soundfonts) for full lists of MIDI instrument names.
55
- * - `MIDISoundFontExtension`: An extension to be added to `MIDISoundFontName` in order to build the full file name of the soundfont JS file. Defaults to `-mp3.js`
56
- */
57
- constructor(data, options = {}) {
58
- const AudioContext = window && (window.AudioContext || window.webkitAudioContext);
59
- if (AudioContext) {
60
- // Build instrument on first call to constructor
61
- MidiAudioPlayer.prepareInstrument(options, new AudioContext());
62
- this.data = data;
63
- this.player = new MidiPlayer.Player(ev => this.playEvent(ev));
64
- if (this.player)
65
- this.player.loadArrayBuffer(data);
66
- }
67
- }
68
-
69
- /**
70
- * Initializes the soundfont instrument, loading data from GitHub
71
- * NOTE: This will not work when off-line!
72
- * TODO: Provided a basic, simple, static soundfont
73
- * @param {object} options - Optional param with options related to the MIDI soundfont. See details in `constructor` description.
74
- * @param {external:AudioContext} audioContext - The AudioContext object (see: https://developer.mozilla.org/en-US/docs/Web/API/AudioContext)
75
- */
76
- static prepareInstrument(options = {}, audioContext) {
77
- if (MidiAudioPlayer.loadingInstrument === false) {
78
- MidiAudioPlayer.loadingInstrument = true;
79
- MidiAudioPlayer.audioContext = audioContext;
80
- MidiPlayer.Soundfont.instrument(
81
- MidiAudioPlayer.audioContext,
82
- options.MIDISoundFontObject || MidiAudioPlayer.MIDISoundFontObject ||
83
- `${options.MIDISoundFontBase || MidiAudioPlayer.MIDISoundFontBase}/${options.MIDISoundFontName || MidiAudioPlayer.MIDISoundFontName}${options.MIDISoundFontExtension || MidiAudioPlayer.MIDISoundFontExtension}`)
84
- .then(instrument => {
85
- log('info', 'MIDI soundfont instrument loaded');
86
- MidiAudioPlayer.instrument = instrument;
87
- })
88
- .catch(err => {
89
- log('error', `Error loading soundfont base instrument: ${err}`);
90
- });
91
- }
92
- }
93
-
94
- /**
95
- * Pauses the player
96
- */
97
- pause() {
98
- if (this.player) {
99
- this.player.pause();
100
- this.startedNotes = [];
101
- }
102
- }
103
-
104
- /**
105
- * Starts or resumes playing
106
- */
107
- play() {
108
- if (this.player) {
109
- this.startedNotes = [];
110
- this.player.play();
111
- }
112
- }
113
-
114
- /**
115
- * Gets the ' paused' state of the current player
116
- * @returns boolean
117
- */
118
- get paused() {
119
- return this.player && !this.player.isPlaying();
120
- }
121
-
122
- /**
123
- * Checks if the current player has ended or is already playing
124
- * @returns boolean
125
- */
126
- get ended() {
127
- return this.player && this.player.getSongTimeRemaining() <= 0;
128
- }
129
-
130
- /**
131
- * Gets the current time
132
- * @returns number
133
- */
134
- get currentTime() {
135
- return this.player && (this.player.getSongTime() * 1000) || 0;
136
- }
137
-
138
- /**
139
- * Sets the current time of this player (in milliseconds)
140
- * @param {number} time - The time position where the player pointer must be placed
141
- */
142
- set currentTime(time) {
143
- if (this.player)
144
- this.player.skipToSeconds(time / 1000);
145
- }
146
-
147
- /**
148
- * Plays a MIDI event
149
- * @param {object} ev - The event data. See http://grimmdude.com/MidiPlayerJS/docs/index.html for details
150
- */
151
- playEvent(ev) {
152
- if (this.player && MidiAudioPlayer.instrument) {
153
- // Check for specific interval
154
- if (this.playTo > 0 && this.currentTime >= this.playTo)
155
- this.pause();
156
- // Set main volume
157
- else if (ev.name === 'Controller Change' && ev.number === 7)
158
- this.mainVolume = ev.value / 127;
159
- // Process 'Note on' messages. Max gain set to 2.0 for better results with the used soundfont
160
- else if (ev.name === 'Note on' && ev.velocity > 0)
161
- this.startedNotes[ev.noteNumber] = MidiAudioPlayer.instrument.play(ev.noteName, MidiAudioPlayer.audioContext.currentTime, { gain: 2 * (this.mainVolume * ev.velocity / 100) });
162
- // Process 'Note off' messages
163
- else if (ev.name === 'Note off' && ev.noteNumber && this.startedNotes[ev.noteNumber]) {
164
- this.startedNotes[ev.noteNumber].stop();
165
- delete (this.startedNotes[ev.noteNumber]);
166
- }
167
- }
168
- }
169
- }
170
-
171
- Object.assign(MidiAudioPlayer.prototype, {
172
- /**
173
- * The MIDI file data used by this MIDI player
174
- * @name module:media/MidiAudioPlayer.MidiAudioPlayer#data
175
- * @type {external:ArrayBuffer} */
176
- data: null,
177
- /**
178
- * The grimmdude's MidiPlayer used by this player
179
- * @name module:media/MidiAudioPlayer.MidiAudioPlayer#player
180
- * @type {external:MidiPlayerJS} */
181
- player: null,
182
- /**
183
- * When >0, time position at which the music must end
184
- * @name module:media/MidiAudioPlayer.MidiAudioPlayer#playTo
185
- * @type {number} */
186
- playTo: 0,
187
- /**
188
- * Main volume of this track (set with a MIDI message of type `Controller Change` #7)
189
- * @name module:media/MidiAudioPlayer.MidiAudioPlayer#mainVolume
190
- * @type {number} */
191
- mainVolume: 1.0,
192
- /**
193
- * This array is used when processing 'Note off' events to stop notes that are currently playing.
194
- * It contains a collection of 'instrument.play' instances, one for each active note
195
- * @name module:media/MidiAudioPlayer.MidiAudioPlayer#startedNotes
196
- * @type {function[]} */
197
- startedNotes: [],
198
- });
199
-
200
- /**
201
- * The {@link external:AudioContext} used by this MIDI player.
202
- * @type {external:AudioContext}
203
- */
204
- MidiAudioPlayer.audioContext = null;
205
-
206
- /**
207
- * The "Instrument" object used by this MIDI player.
208
- * See: https://github.com/danigb/soundfont-player
209
- * @type {external:Instrument}
210
- */
211
- MidiAudioPlayer.instrument = null;
212
-
213
- /**
214
- * A flag used to avoid re-entrant calls to {@link module:media/MidiAudioPlayer.MidiAudioPlayer#prepareInstrument prepareInstrument}
215
- * @type {boolean}
216
- */
217
- MidiAudioPlayer.loadingInstrument = false;
218
-
219
- /**
220
- * An object containing the full soundfont data used by {@link module:media/MidiAudioPlayer.MidiAudioPlayer#instrument instrument}
221
- * When this member is set, no other settings related to the sounfFont will be used.
222
- * This value can be overwritten by the global parameter `MIDISoundFontObject`
223
- * @type {object}
224
- */
225
- MidiAudioPlayer.MIDISoundFontObject = null;
226
-
227
- /**
228
- * The URL used as base for the current collection of MIDI soundfonts.
229
- * This value can be overwritten by the global parameter `MIDISoundFontBase`
230
- * @type {string}
231
- */
232
- MidiAudioPlayer.MIDISoundFontBase = 'https://clic.xtec.cat/dist/jclic.js/soundfonts/MusyngKite';
233
- // Alternative sites are:
234
- // 'https://clic.xtec.cat/dist/jclic.js/soundfonts/FluidR3_GM'
235
- // 'https://raw.githubusercontent.com/gleitz/midi-js-soundfonts/gh-pages/FluidR3_GM'
236
- // 'https://raw.githubusercontent.com/gleitz/midi-js-soundfonts/gh-pages/MusyngKite'
237
-
238
- /**
239
- * The MIDI instrument name.
240
- * This value can be overwritten by the global parameter `MIDISoundFontName`
241
- * See [MIDI.js Soundfonts](https://github.com/gleitz/midi-js-soundfonts) for full lists of MIDI instrument names.
242
- * @type {string}
243
- */
244
- MidiAudioPlayer.MIDISoundFontName = 'acoustic_grand_piano';
245
-
246
- /**
247
- * An extension to be added to `MIDISoundFontName` in order to build the full file name of the soundfont JS file.
248
- * Current valid options are `-mp3.js` and `-ogg.js`
249
- * This value can be overwritten by the global parameter `MIDISoundFontExtension`
250
- * @type {string}
251
- */
252
- MidiAudioPlayer.MIDISoundFontExtension = '-mp3.js';
253
-
254
- export default MidiAudioPlayer;
@@ -1,3 +0,0 @@
1
- <svg fill="#000000" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z" />
3
- </svg>
@@ -1,3 +0,0 @@
1
- <svg height="48" viewBox="0 0 48 48" width="48" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M28.8 12L28 8H10v34h4V28h11.2l.8 4h14V12z" />
3
- </svg>
@@ -1,3 +0,0 @@
1
- <svg fill="#000000" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z" />
3
- </svg>
@@ -1,3 +0,0 @@
1
- <svg fill="#000000" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M18 4l2 4h-3l-2-4h-2l2 4h-3l-2-4H8l2 4H7L5 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4h-4z" />
3
- </svg>
@@ -1,3 +0,0 @@
1
- <svg fill="#000000" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M12 3v10.55c-.59-.34-1.27-.55-2-.55-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3h-6z" />
3
- </svg>
@@ -1,3 +0,0 @@
1
- <svg fill="#000000" height="48" viewBox="0 0 24 24" width="48" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z" />
3
- </svg>
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,282 +0,0 @@
1
- /**
2
- * File : project/JClicProject.js
3
- * Created : 01/04/2015
4
- * By : Francesc Busquets <francesc@gmail.com>
5
- *
6
- * JClic.js
7
- * An HTML5 player of JClic activities
8
- * https://projectestac.github.io/jclic.js
9
- *
10
- * @source https://github.com/projectestac/jclic.js
11
- *
12
- * @license EUPL-1.2
13
- * @licstart
14
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
15
- *
16
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
17
- * the European Commission- subsequent versions of the EUPL (the "Licence");
18
- * You may not use this work except in compliance with the Licence.
19
- *
20
- * You may obtain a copy of the Licence at:
21
- * https://joinup.ec.europa.eu/software/page/eupl
22
- *
23
- * Unless required by applicable law or agreed to in writing, software
24
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
25
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
26
- * Licence for the specific language governing permissions and limitations
27
- * under the Licence.
28
- * @licend
29
- * @module
30
- */
31
-
32
- import $ from 'jquery';
33
- import ProjectSettings from './ProjectSettings.js';
34
- import ActivitySequence from '../bags/ActivitySequence.js';
35
- import MediaBag from '../bags/MediaBag.js';
36
- import Activity from '../Activity.js';
37
- import { getBasePath, nSlash, getAttr, settings } from '../Utils.js';
38
- import { Font } from '../AWT.js';
39
-
40
- /**
41
- * JClicProject contains all the components of a JClic project: activities, sequences, media
42
- * files, descriptors and metadata.
43
- *
44
- * This encapsulation is achieved by three auxiliary objects:
45
- * - {@link module:project/ProjectSettings.ProjectSettings ProjectSettings}: stores metadata like full title, description, authors, languages,
46
- * educational topics...
47
- * - {@link module:bags/ActivitySequence.ActivitySequence ActivitySequence}: defines the order in which the activities must be shown.
48
- * - {@link module:bags/MediaBag.MediaBag MediaBag}: contains the list of all media files used by the activities
49
- */
50
- export class JClicProject {
51
- /**
52
- * JClicProject constructor
53
- */
54
- constructor() {
55
- this.settings = new ProjectSettings(this);
56
- this.activitySequence = new ActivitySequence(this);
57
- this._activities = {};
58
- this.mediaBag = new MediaBag(this);
59
- }
60
-
61
- /**
62
- * Loads the project settings from a main jQuery XML element
63
- * @param {external:jQuery} $xml - The XML element
64
- * @param {string} path - The full path of this project
65
- * @param {external:JSZip} [zip] - An optional JSZip object where this project is encapsulated
66
- * @param {object} [options] - An object with miscellaneous options
67
- * @returns {module:project/JClicProject.JClicProject}
68
- */
69
- setProperties($xml, path, zip, options) {
70
- if (path) {
71
- this.path = path;
72
- if (path.file)
73
- this.basePath = path;
74
- else
75
- this.basePath = getBasePath(path);
76
- }
77
- this.zip = zip;
78
- this.name = $xml.attr('name');
79
- this.version = $xml.attr('version');
80
- if ($xml.attr('type') !== undefined && $xml.attr('type') !== '')
81
- this.type = $xml.attr('type');
82
- if ($xml.attr('code') !== undefined && $xml.attr('code') !== '')
83
- this.code = $xml.attr('code');
84
- this.settings.setProperties($xml.children('settings'));
85
- this.activitySequence.setProperties($xml.children('sequence'));
86
- this.mediaBag.setProperties($xml.children('mediaBag'));
87
- this.reportableActs = 0;
88
- this._activities = {};
89
- const $node = $xml.children('activities');
90
- const $acts = $node.children('activity');
91
- const ownFonts = this.mediaBag.getElementsOfType('font');
92
- if (ownFonts.length > 0)
93
- options.ownFonts = (options.ownFonts || []).concat(ownFonts);
94
- // Skip checkTree when in NodeJS, due to a JSDOM error with jQuery in XML mode
95
- if (!settings.NODEJS)
96
- Font.checkTree($acts, options);
97
- $acts.each((_n, act) => {
98
- const $act = $(act);
99
- this._activities[nSlash($act.attr('name'))] = $act;
100
- if ($act.children('settings').attr('report') === 'true')
101
- this.reportableActs++;
102
- });
103
- return this;
104
- }
105
-
106
- /**
107
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
108
- * parent references, constants and also attributes retaining the default value.
109
- * The resulting object is commonly usued to serialize elements in JSON format.
110
- * @returns {object} - The resulting object, with minimal attrributes
111
- */
112
- getAttributes() {
113
- const keys = Object.keys(this._activities);
114
- this.activities = {};
115
- keys.forEach(k => {
116
- const act = this._activities[k];
117
- this.activities[k] = act.jquery ? Activity.getActivity(act, this) : act;
118
- });
119
-
120
- return getAttr(this, ['name', 'version', 'type', 'code', 'settings', 'activitySequence', 'activities', 'mediaBag']);
121
- }
122
-
123
- /**
124
- * Gets a JSON string representing the content of this project. This string can be transformed later into a data
125
- * object suitable for `setAttributes`.
126
- * @param {number} [space] - The number of white spaces to place between items. Defaults to zero (meaning all the JSON rendered in one single line)
127
- * @returns {string} - The JSON text
128
- */
129
- getJSON(space = 0) {
130
- return JSON.stringify(
131
- this.getAttributes(),
132
- (_key, val) => val.toFixed ? Number(val.toFixed(4)) : val,
133
- space
134
- );
135
- }
136
-
137
- /**
138
- * Loads the project settings from a data object
139
- * @param {object} data - The data object
140
- * @param {string} path - The full path of this project
141
- * @param {external:JSZip} [zip] - An optional JSZip object where this project is encapsulated
142
- * @param {object} [options] - An object with miscellaneous options
143
- * @returns {module:project/JClicProject.JClicProject}
144
- */
145
- setAttributes(data, path, zip, options) {
146
- if (path) {
147
- this.path = path;
148
- if (path.file)
149
- this.basePath = path;
150
- else
151
- this.basePath = getBasePath(path);
152
- }
153
- this.zip = zip;
154
- this.name = data.name;
155
- this.version = data.version;
156
- if (data.type)
157
- this.type = data.type;
158
- if (data.code)
159
- this.code = data.code;
160
- this.settings.setAttributes(data.settings);
161
- this.activitySequence.setAttributes(data.activitySequence);
162
- this.mediaBag.setAttributes(data.mediaBag);
163
- this.reportableActs = 0;
164
- this._activities = data.activities;
165
-
166
- const ownFonts = this.mediaBag.getElementsOfType('font');
167
- if (ownFonts.length > 0)
168
- options.ownFonts = (options.ownFonts || []).concat(ownFonts);
169
- // TODO: Check fonts
170
- Font.checkTree(this._activities, options);
171
- this.reportableActs = Object.keys(this._activities)
172
- .filter(k => this._activities[k].includeInReports)
173
- .length;
174
- return this;
175
- }
176
-
177
- /**
178
- * Finds activities by name and builds the corresponding {@link module:Activity.Activity Activity} object.
179
- * @param {string} name - The name of the requested activity
180
- * @returns {module:Activity.Activity}
181
- */
182
- getActivity(name) {
183
- return Activity.getActivity(this._activities[nSlash(name)], this);
184
- }
185
-
186
- /**
187
- *
188
- * Builds the {@link module:skins/Skin.Skin Skin}, {@link module:media/EventSounds.EventSounds EventSounds} and {@link module:bags/MediaBag.MediaBag MediaBag} fonts associated to this project.
189
- * @param {module:JClicPlayer.JClicPlayer} ps - The PlayStation (usually a {@link module:JClicPlayer.JClicPlayer JClicPlayer}) linked to this project.
190
- */
191
- realize(ps) {
192
- // Build skin
193
- if (this.skin === null && this.settings.skinFileName !== null && this.settings.skinFileName.length > 0)
194
- this.skin = this.mediaBag.getSkinElement(this.settings.skinFileName, ps);
195
-
196
- this.settings.eventSounds.realize(ps, this.mediaBag);
197
-
198
- // Build all elements of type `font`
199
- this.mediaBag.buildAll('font', null, ps);
200
- }
201
-
202
- /**
203
- * Run finalizers on realized objects
204
- */
205
- end() {
206
- // TODO: Implement JClicProject.end()
207
- }
208
- }
209
-
210
- Object.assign(JClicProject.prototype, {
211
- /**
212
- * The project's name
213
- * @name module:project/JClicProject.JClicProject#name
214
- * @type {string} */
215
- name: 'unknown',
216
- /**
217
- * The version of the XML file format used to save the project (currently 0.1.3)
218
- * @name module:project/JClicProject.JClicProject#version
219
- * @type {string} */
220
- version: '0.1.3',
221
- /**
222
- * Optional property that can be used by reporting systems
223
- * @name module:project/JClicProject.JClicProject#type
224
- * @type {string} */
225
- type: null,
226
- /**
227
- * Optional property that can be used by reporting systems
228
- * @name module:project/JClicProject.JClicProject#code
229
- * @type {string} */
230
- code: null,
231
- /**
232
- * Object containing the project settings
233
- * @name module:project/JClicProject.JClicProject#settings
234
- * @type {module:project/ProjectSettings.ProjectSettings} */
235
- settings: null,
236
- /**
237
- * Object containing the order in which the activities should be played
238
- * @name module:project/JClicProject.JClicProject#activitySequence
239
- * @type {module:bags/ActivitySequence.ActivitySequence} */
240
- activitySequence: null,
241
- /**
242
- * Array of jQuery xml elements containing the data of each activity. Don't rely on this object
243
- * to retrieve real activities. Use the method {@link module:project/JClicProject.JClicProject#getActivity getActivity} instead.
244
- * @name module:project/JClicProject.JClicProject#_activities
245
- * @private
246
- * @type {external:jQuery[]} */
247
- _activities: null,
248
- /**
249
- * Number of activities suitable to be included reports
250
- * @name module:project/JClicProject.JClicProject#reportableActs
251
- * @type {number}
252
- */
253
- reportableActs: 0,
254
- /**
255
- * The collection of all media elements used in this project
256
- * @name module:project/JClicProject.JClicProject#mediaBag
257
- * @type {module:bags/MediaBag.MediaBag} */
258
- mediaBag: null,
259
- /**
260
- * The object that builds and manages the visual interface presented to users
261
- * @name module:project/JClicProject.JClicProject#skin
262
- * @type {module:skins/Skin.Skin} */
263
- skin: null,
264
- /**
265
- * Relative path or absolute URL to be used as a base to access files, usually in conjunction
266
- * with {@link module:JClicPlayer.JClicPlayer#basePath}
267
- * @name module:project/JClicProject.JClicProject#basePath
268
- * @type {string} */
269
- basePath: '',
270
- /**
271
- * Full path of this project
272
- * @name module:project/JClicProject.JClicProject#path
273
- * @type {string} */
274
- path: null,
275
- /**
276
- * The JSZip object where this project is stored (can be `null`)
277
- * @name module:project/JClicProject.JClicProject#zip
278
- * @type {external:JSZip} */
279
- zip: null,
280
- });
281
-
282
- export default JClicProject;