jclic 2.2.0 → 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 -664
  8. package/TRANSLATIONS.md +0 -11
  9. package/build-locales.mjs +0 -82
  10. package/dist/jclic-node.js +0 -31678
  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 -658
  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,113 +0,0 @@
1
- /**
2
- * File : bags/ConditionalJumpInfo.js
3
- * Created : 05/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 Catalan Educational Telematic Network (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 JumpInfo from './JumpInfo.js';
33
- import { getAttr, isEmpty } from '../Utils.js';
34
-
35
- /**
36
- * This special case of {@link module:bags/JumpInfo.JumpInfo JumpInfo} is used in {@link module:bags/ActivitySequenceJump.ActivitySequenceJump ActivitySequenceJump} objects to decide
37
- * the type of jump or action to be performed, based on the results obtained by the user when
38
- * playing previous JClic activities.
39
- *
40
- * In addition to the standard {@link module:bags/JumpInfo.JumpInfo JumpInfo} fields and methods, this class has two public
41
- * members where score and time thresholds are stored.
42
- *
43
- * The exact meaning of this members will depend on the type of `ConditionalJumpInfo` in the
44
- * {@link module:bags/ActivitySequenceJump.ActivitySequenceJump ActivitySequenceJump} (it can be `upperJump` or `lowerJump`).
45
- * @extends module:bags/JumpInfo.JumpInfo
46
- */
47
- export class ConditionalJumpInfo extends JumpInfo {
48
- /**
49
- * ConditionalJumpInfo constructor
50
- * @param {string} action - Must be one of the described actions.
51
- * @param {number|string} [sq] - Can be the tag of the sequence element to jump to, or its
52
- * cardinal number in the list.
53
- * @param {number} [threshold] - Threshold above or below which the action will be triggered,
54
- * depending on the type of JumpInfo.
55
- * @param {number} [time] - Delay to be applied in automatic jumps.
56
- */
57
- constructor(action, sq, threshold, time) {
58
- super(action, sq);
59
- this.threshold = typeof threshold === 'number' ? threshold : -1;
60
- this.time = typeof threshold === 'number' ? time : -1;
61
- }
62
-
63
- /**
64
- * Loads this object settings from a specific JQuery XML element
65
- * @param {external:jQuery} $xml - The XML element to parse
66
- */
67
- setProperties($xml) {
68
- super.setProperties($xml);
69
- if ($xml.attr('threshold') !== undefined)
70
- this.threshold = $xml.attr('threshold');
71
- if ($xml.attr('time') !== undefined)
72
- this.time = $xml.attr('time');
73
- return this;
74
- }
75
-
76
- /**
77
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
78
- * parent references, constants and also attributes retaining the default value.
79
- * The resulting object is commonly usued to serialize elements in JSON format.
80
- * @returns {object} - The resulting object, with minimal attrributes
81
- */
82
- getAttributes() {
83
- return Object.assign(super.getAttributes(), getAttr(this, ['threshold', 'time']));
84
- }
85
-
86
- /**
87
- * Loads this conditional jump settings from a data object
88
- * @param {object} data - The data object to parse
89
- */
90
- setAttributes(data) {
91
- super.setAttributes(data);
92
- ['threshold', 'time'].forEach(t => {
93
- if (!isEmpty(data[t]))
94
- this[t] = data[t];
95
- });
96
- return this;
97
- }
98
- }
99
-
100
- Object.assign(ConditionalJumpInfo.prototype, {
101
- /**
102
- * Threshold above or below which the action will be triggered, depending on the type of JumpInfo.
103
- * @name module:bags/ConditionalJumpInfo.ConditionalJumpInfo#threshold
104
- * @type {number} */
105
- threshold: -1,
106
- /**
107
- * Delay to be applied in automatic jumps.
108
- * @name module:bags/ConditionalJumpInfo.ConditionalJumpInfo#time
109
- * @type {number} */
110
- time: -1,
111
- });
112
-
113
- export default ConditionalJumpInfo;
@@ -1,136 +0,0 @@
1
- /**
2
- * File : bags/JumpInfo.js
3
- * Created : 05/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 Catalan Educational Telematic Network (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 { nSlash, getAttr, isEmpty } from '../Utils.js';
33
-
34
- /**
35
- * This class contains information about what things JClic sequence manager has to do in certain
36
- * circumstances, such as:
37
- * - an activity finishes
38
- * - the user clicks on the "next" or "prev" buttons
39
- * - the user clicks or a cell with special "active content"
40
- *
41
- * Different kinds of actions are possible for each of these events:
42
- * - RETURN: to go back to a previous point in the sequence.
43
- * - EXIT: to exit the program (thus navigating to another URL)
44
- * - STOP: to do nothing.
45
- * - JUMP: to jump to a specific point in the sequence of activities, or to another JClic project.
46
- * @see {@link module:bags/ActivitySequenceJump.ActivitySequenceJump ActivitySequenceJump}
47
- * @see {@link module:bags/ConditionalJumpInfo.ConditionalJumpInfo ConditionalJumpInfo}
48
- */
49
- export class JumpInfo {
50
- /**
51
- * JumpInfo constructor
52
- * @param {string} action - Must be one of the described actions.
53
- * @param {number|string} [sq] - Can be the tag of the sequence element to jump to, or its
54
- * cardinal number in the list.
55
- */
56
- constructor(action, sq) {
57
- this.action = action;
58
- switch (typeof sq) {
59
- case 'string':
60
- this.sequence = sq;
61
- break;
62
- case 'number':
63
- this.actNum = sq;
64
- break;
65
- }
66
- }
67
-
68
- /**
69
- * Loads the object settings from a specific JQuery XML element
70
- * @param {external:jQuery} $xml - The XML element to parse
71
- */
72
- setProperties($xml) {
73
- this.id = $xml.attr('id');
74
- this.action = $xml.attr('action') || 'JUMP';
75
- if ($xml.attr('tag'))
76
- this.sequence = nSlash($xml.attr('tag'));
77
- if ($xml.attr('project'))
78
- this.projectPath = nSlash($xml.attr('project'));
79
- return this;
80
- }
81
-
82
- /**
83
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
84
- * parent references, constants and also attributes retaining the default value.
85
- * The resulting object is commonly usued to serialize elements in JSON format.
86
- * @returns {object} - The resulting object, with minimal attrributes
87
- */
88
- getAttributes() {
89
- return getAttr(this, ['id', 'action', 'actNum', 'sequence', 'projectPath']);
90
- }
91
-
92
- /**
93
- * Loads the object settings from a data object
94
- * @param {object} data - The data object to parse
95
- */
96
- setAttributes(data) {
97
- ['id', 'action', 'actNum', 'sequence', 'projectPath'].forEach(t => {
98
- if (!isEmpty(data[t]))
99
- this[t] = data[t];
100
- });
101
- return this;
102
- }
103
- }
104
-
105
- Object.assign(JumpInfo.prototype, {
106
- /**
107
- * The JumpInfo identifier
108
- * - For regular jumps: 'forward', 'back'
109
- * - For conditional jumps: 'upper', 'lower'
110
- * @name module:bags/JumpInfo.JumpInfo#id
111
- * @type {string} */
112
- id: null,
113
- /**
114
- * The current action.
115
- * Possible values are: `JUMP`, `STOP`, `RETURN` and `EXIT`.
116
- * @name module:bags/JumpInfo.JumpInfo#action
117
- * @type {string} */
118
- action: null,
119
- /**
120
- * Activity number in the sequence list
121
- * @name module:bags/JumpInfo.JumpInfo#actNum
122
- * @type {number} */
123
- actNum: -1,
124
- /**
125
- * Current sequence tag
126
- * @name module:bags/JumpInfo.JumpInfo#sequence
127
- * @type {string} */
128
- sequence: null,
129
- /**
130
- * Path of another JClic project to jump to
131
- * @name module:bags/JumpInfo.JumpInfo#projectPath
132
- * @type {string} */
133
- projectPath: null,
134
- });
135
-
136
- export default JumpInfo;
@@ -1,215 +0,0 @@
1
- /**
2
- * File : bags/MediaBag.js
3
- * Created : 07/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 MediaBagElement from './MediaBagElement.js';
34
- import Skin from '../skins/Skin.js';
35
- import { log, nSlash } from '../Utils.js';
36
-
37
- /**
38
- * This class stores and manages all the media components (images, sounds, animations, video,
39
- * MIDI files, etc.) needed to run the activities of a {@link module:project/JClicProject.JClicProject JClicProject}. The main member of
40
- * the class is `elements`. This is where {@link module:bads/MediaBagElement.MediaBagElement} objects are stored.
41
- */
42
- export class MediaBag {
43
- /**
44
- * MediaBag constructor
45
- * @param {module:project/JClicProject.JClicProject} project - The JClic project to which this media bag belongs
46
- */
47
- constructor(project) {
48
- this.project = project;
49
- this.elements = {};
50
- }
51
-
52
- /**
53
- * Loads this object settings from a specific JQuery XML element
54
- * @param {external:jQuery} $xml - The XML element to parse
55
- */
56
- setProperties($xml) {
57
- $xml.children('media').each((_n, child) => {
58
- const mbe = new MediaBagElement(this.project.basePath, null, this.project.zip);
59
- mbe.setProperties($(child));
60
- this.elements[mbe.name] = mbe;
61
- });
62
- return this;
63
- }
64
-
65
- /**
66
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
67
- * parent references, constants and also attributes retaining the default value.
68
- * The resulting object is commonly usued to serialize elements in JSON format.
69
- * @returns {object} - The resulting object, with minimal attrributes
70
- */
71
- getAttributes() {
72
- return Object.keys(this.elements).map(k => this.elements[k].getAttributes());
73
- }
74
-
75
- /**
76
- * Loads the MediaBag content from a data object
77
- * @param {object} data - The data object to parse
78
- */
79
- setAttributes(data) {
80
- if (data && data.length)
81
- data.forEach(el => {
82
- const mbe = new MediaBagElement(this.project.basePath, null, this.project.zip);
83
- mbe.setAttributes(el);
84
- this.elements[mbe.name] = mbe;
85
- });
86
- return this;
87
- }
88
-
89
- /**
90
- * Finds a {@link module:bads/MediaBagElement.MediaBagElement} by its name, creating a new one if not found and requested.
91
- * @param {string} name - The name of the element
92
- * @param {boolean} [create] - When `true`, a new MediaBagElement will be created if not found,
93
- * using 'name' as its file name.
94
- * @returns {module:bags/MediaBagElement.MediaBagElement}
95
- */
96
- getElement(name, create) {
97
- name = nSlash(name);
98
- let result = this.elements[name];
99
- if (create && !result)
100
- result = this.getElementByFileName(name, create);
101
- return result;
102
- }
103
-
104
- /**
105
- * Gets a {@link module:bads/MediaBagElement.MediaBagElement} by its file name.
106
- * @param {string} file - The requested file name
107
- * @param {boolean} [create] - When `true`, a new {@link module:bads/MediaBagElement.MediaBagElement} will be created if not
108
- * found.
109
- * @returns {module:bags/MediaBagElement.MediaBagElement}
110
- */
111
- getElementByFileName(file, create) {
112
- let result = null;
113
- if (file) {
114
- file = nSlash(file);
115
- for (let name in this.elements) {
116
- if (this.elements[name].file === file) {
117
- result = this.elements[name];
118
- break;
119
- }
120
- }
121
- if (!result && create) {
122
- result = new MediaBagElement(this.project.basePath, null, this.project.zip);
123
- result.name = file;
124
- result.file = file;
125
- result.ext = file.toLowerCase().split('#')[0].split('.').pop();
126
- result.type = result.getFileType(result.ext);
127
- this.elements[result.name] = result;
128
- }
129
- }
130
- return result;
131
- }
132
-
133
- /**
134
- * Get the names of the media elements that are of the given type.
135
- * When the search type is `font`, the `fontName` property is used instead of `name`
136
- * @param {string} type - The type of elements to search
137
- * @returns {string[]}
138
- */
139
- getElementsOfType(type) {
140
- const result = [];
141
- $.each(this.elements, (name, element) => {
142
- if (element.type === type)
143
- result.push(type === 'font' ? element.fontName : name);
144
- });
145
- return result;
146
- }
147
-
148
- /**
149
- * Preloads all resources.
150
- *
151
- * __Use with care!__ Calling this method will start loading all the resources defined in the
152
- * MediaBag, whether used or not in the current activity.
153
- * @param {string} type - The type of media to be build. When `null` or `undefined`, all
154
- * resources will be build.
155
- * @param {function} [callback] - Function to be called when each element is ready.
156
- * @param {module:JClicPlayer.JClicPlayer} [ps] - An optional `PlayStation` (currently a {@link module:JClicPlayer.JClicPlayer JClicPlayer}) used to dynamically load fonts
157
- * @returns {number} - The total number of elements that will be built
158
- */
159
- buildAll(type, callback, ps) {
160
- let count = 0;
161
- $.each(this.elements, (name, element) => {
162
- if (!type || element.type === type) {
163
- element.build(callback, ps, false);
164
- count++;
165
- }
166
- });
167
- return count;
168
- }
169
-
170
- /**
171
- * Checks if there are media waiting to be loaded
172
- * @returns {number} - The amount of media elements already loaded, or -1 if all elements are ready
173
- */
174
- countWaitingElements() {
175
- let
176
- ready = 0,
177
- allReady = true;
178
-
179
- // Only for debug purposes: return always 'false'
180
- // TODO: Check loading process!
181
- $.each(this.elements, (name, element) => {
182
- if (element.data && !element.ready && !element.checkReady() && !element.checkTimeout()) {
183
- log('debug', '... waiting for: %s', name);
184
- allReady = false;
185
- } else
186
- ready++;
187
- });
188
- return allReady ? -1 : ready;
189
- }
190
-
191
- /**
192
- * Loads a {@link module:skins/Skin.Skin Skin} object
193
- * @param {string} name - The skin name to be loaded
194
- * @param {string} ps - The {@link module:JClicPlayer.JClicPlayer JClicPlayer} linked to the skin
195
- * @returns {module:skins/Skin.Skin}
196
- */
197
- getSkinElement(name, ps) {
198
- return Skin.getSkin(name, ps);
199
- }
200
- }
201
-
202
- Object.assign(MediaBag.prototype, {
203
- /**
204
- * The collection of {@link module:bads/MediaBagElement.MediaBagElement} objects
205
- * @name module:bags/MediaBag.MediaBag#elements
206
- * @type {object} */
207
- elements: null,
208
- /**
209
- * The JClic project to which this MediaBag belongs
210
- * @name module:bags/MediaBag.MediaBag#project
211
- * @type {module:project/JClicProject.JClicProject} */
212
- project: null,
213
- });
214
-
215
- export default MediaBag;