To install the addon simply copy and paste the contents of the .js
file into your Story's JavaScript
page.
{List Collection: <collection> [, DisplayName: <string>] [, Detailed: <string>] [, AllowCount: true] [, Divider: ]}
Takes in an array or object collection to display it's contents as a list.
Source Code: ListCollection.js
Arguments:
<collection>
[Mandetory] the array or object of the collection which contents you want to be listed.DisplayName
[Optional, onlyObjects
] overwrites the default property.Name
or.name
that it looks for to display as name, which allows you to select any other property.Detailed
[Optional, onlyObjects
] takes in additional object property names to be displayed, multiple property names are simply separated by a space. There is a build in keywordall
which will list all properties (except for theDisplayName
choosen property).AllowCount
[Optional, forArrays
andObjects
] will display a number at the front of the list which represents the index of the item inside the collection.Divider
[Optional, forArrays
andObjects
] will change the default divider" - "
.
inventory: ["An apple", "A banana"] -- {List Collection: inventory}Expected Output:
An apple
A banana
inventory: ["An apple", "A banana"] -- {List Collection: inventory, AllowCount: true}Expected Output:
1 - An apple
2 - A banana
inventory: {Strawberries: {Name: "Strawberries", Count: 2, Color: "red", Value: 10}, Cherries: {Name: "Cherries", Count: 4, Color: "darkred", Value: 36}} -- {List Collection: inventory, DisplayName: "Color"}Expected Output:
red
darkred
inventory: {Strawberries: {Name: "Strawberries", Count: 2, Color: "red", Value: 10}, Cherries: {Name: "Cherries", Count: 4, Color: "darkred", Value: 36}} -- name - color - item count <br> {List Collection: inventory, Detailed: "Color Count"}Expected Output:
name - color - item count
Strawberries - red - 2
Cherries - darkred - 4
inventory: {Strawberries: {Name: "Strawberries", Count: 2, Color: "red", Value: 10}, Cherries: {Name: "Cherries", Count: 4, Color: "darkred", Value: 36}} -- inv. nr. - name - item count - color - value {List Collection: inventory, Detailed: "all", AllowCount: true}Expected Output:
inv. nr. - name - item count - color - value
1 - Strawberries - 2 - red - 10
2 - Cherries - 4 - darkred - 36
inventory: {Strawberries: {Name: "Strawberries", Count: 2, Color: "red", Value: 10}, Cherries: {Name: "Cherries", Count: 4, Color: "darkred", Value: 36}} -- inv. nr. - name - item count - color - value <br> {List Collection: inventory2, Divider: " :: ", AllowCount: true, Detailed: "all"}Expected Output:
inv. nr. - name - item count - color - value
1 :: Strawberries :: 2 :: red :: 10 2 :: Cherries :: 4 :: darkred :: 36