extwee 2.3.8 → 2.3.10
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.
- package/build/extwee.core.min.js +1 -1
- package/build/extwee.twine1html.min.js +1 -1
- package/build/extwee.twine2archive.min.js +1 -1
- package/build/extwee.tws.min.js +1 -1
- package/docs/build/extwee.core.min.js +1 -1
- package/docs/build/extwee.twine1html.min.js +1 -1
- package/docs/build/extwee.twine2archive.min.js +1 -1
- package/docs/build/extwee.tws.min.js +1 -1
- package/package.json +7 -7
- package/src/Passage.js +9 -2
- package/src/Story.js +17 -1
- package/test/Objects/Passage.test.js +36 -15
- package/test/Objects/SnowmanCompatibility.test.js +125 -0
- package/test/Objects/Story.test.js +7 -19
- package/test/Twee/Twee.Parse.test.js +18 -3
- package/test/Twee/TweeParser/cycling.twee +75 -0
- package/test/Twee/TweeParser/style.twee +16 -0
- package/test/Twine2HTML/Twine2HTML.Parse.test.js +3 -4
- package/types/src/Story.d.ts +1 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
:: StoryTitle
|
|
2
|
+
Cycling Choices in Snowman
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
:: StoryData
|
|
6
|
+
{
|
|
7
|
+
"ifid": "2A4D6978-93A7-4FD3-96FB-94B995FCBE29"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
:: UserScript[script]
|
|
12
|
+
$(function() {
|
|
13
|
+
|
|
14
|
+
// Create a global object
|
|
15
|
+
window.setup = window.setup || {};
|
|
16
|
+
|
|
17
|
+
// Iterate through all elements with the class 'cycle'
|
|
18
|
+
// For each, save the current 'choices' and 'selection'
|
|
19
|
+
// (This sets all the 'default' values.)
|
|
20
|
+
$('.cycle').each(function() {
|
|
21
|
+
|
|
22
|
+
// Create a global object for each 'id'
|
|
23
|
+
var id = $(this).attr('id');
|
|
24
|
+
setup[id] = {};
|
|
25
|
+
|
|
26
|
+
// Save the current 'choices' for each
|
|
27
|
+
var choices = JSON.parse($(this).attr("data-cycling-choices"));
|
|
28
|
+
setup[id].choices = choices;
|
|
29
|
+
|
|
30
|
+
// Save the current 'selection' for each
|
|
31
|
+
var selection = $(this).attr("data-cycling-selection");
|
|
32
|
+
setup[id].selection = selection;
|
|
33
|
+
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
$('.cycle').click(function(){
|
|
37
|
+
|
|
38
|
+
// Save the 'id'
|
|
39
|
+
var id = $(this).attr('id');
|
|
40
|
+
|
|
41
|
+
// Retrieve the global 'choices'
|
|
42
|
+
var choices = setup[id].choices;
|
|
43
|
+
|
|
44
|
+
// Retrieve the global 'selection'
|
|
45
|
+
var selection = setup[id].selection;
|
|
46
|
+
|
|
47
|
+
// Update the 'selection' number
|
|
48
|
+
selection++;
|
|
49
|
+
|
|
50
|
+
// Check if 'selection' is greater than length of choices
|
|
51
|
+
if(selection >= choices.length) {
|
|
52
|
+
selection = 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Update the 'selection' on the element
|
|
56
|
+
$(this).attr("data-cycling-selection", selection);
|
|
57
|
+
|
|
58
|
+
// Update the text of the element with the choice
|
|
59
|
+
$(this).text(choices[selection]);
|
|
60
|
+
|
|
61
|
+
// Update the global values of 'choices' and 'selection'
|
|
62
|
+
setup[id].choices = choices;
|
|
63
|
+
setup[id].selection = selection;
|
|
64
|
+
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
:: Start
|
|
70
|
+
<a href='javascript:void(0)' id='cycleOne' class='cycle' data-cycling-choices='["One", "Two", "Three"]' data-cycling-selection=0>One</a>
|
|
71
|
+
|
|
72
|
+
[[Submit|Results]]
|
|
73
|
+
|
|
74
|
+
:: Results
|
|
75
|
+
<%= setup["cycleOne"].choices[setup["cycleOne"].selection] %>
|
|
@@ -105,10 +105,9 @@ describe('Twine2HTMLParser', () => {
|
|
|
105
105
|
it('Should have script and style tags normally', () => {
|
|
106
106
|
const fr = readFileSync('test/Twine2HTML/Twine2HTMLParser/Example1.html', 'utf-8');
|
|
107
107
|
const story = parseTwine2HTML(fr);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
expect(
|
|
111
|
-
expect(stylesheetPassages.length).toBe(1);
|
|
108
|
+
// Script-tagged passages are now stored in storyJavaScript, not passages array
|
|
109
|
+
expect(story.storyJavaScript.length).toBeGreaterThan(0);
|
|
110
|
+
expect(story.storyStylesheet.length).toBeGreaterThan(0);
|
|
112
111
|
});
|
|
113
112
|
|
|
114
113
|
it('Should parse HTML without passage start node', () => {
|
package/types/src/Story.d.ts
CHANGED