Skip to content

Commit 502c8e5

Browse files
committed
Appending play options as a query string
This will allow games to have access to playOptions at page load and guarantee that they are available when `init` is fired on the Application instance. This will greatly improve the usefulness of the feature, but we'll also maintain backward capability for older versions of the framework.
1 parent e7af5ba commit 502c8e5

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/container/Container.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,24 @@
164164
plugins[i].open.call(this);
165165
}
166166

167+
// append a query parameter to pass play options
168+
if (options.playOptions !== null)
169+
{
170+
var playOptionsQueryString = 'playOptions=' + window.encodeURIComponent(JSON.stringify(options.playOptions));
171+
172+
// if there isn't a query string yet, add the question mark
173+
if (path.indexOf('?') === -1)
174+
{
175+
path += '?' + playOptionsQueryString;
176+
}
177+
178+
// otherwise, there already is a query string, so preserve it by appending a new variable
179+
else
180+
{
181+
path += '&' + playOptionsQueryString;
182+
}
183+
}
184+
167185
//Open the application in the iframe
168186
this.main.classList.add('loading');
169187
this.main.setAttribute('src', path);
@@ -429,4 +447,4 @@
429447
};
430448

431449
namespace('springroll').Container = Container;
432-
})(document);
450+
})(document);

0 commit comments

Comments
 (0)