File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ class Manager {
125125 window . addEventListener ( "focus" , this . window . windowFocus . bind ( this . window ) ) ;
126126 window . addEventListener ( "statechange" , this . app . stateChange . bind ( this . app ) ) ;
127127 window . addEventListener ( "popstate" , this . app . popState . bind ( this . app ) ) ;
128+ window . addEventListener ( "message" , this . input . handlePostMessage . bind ( this . input ) ) ;
128129
129130 // Controls
130131 document . getElementById ( "bake" ) . addEventListener ( "click" , this . controls . bakeClick . bind ( this . controls ) ) ;
Original file line number Diff line number Diff line change @@ -1654,6 +1654,22 @@ class InputWaiter {
16541654 this . changeTab ( inputNum , this . app . options . syncTabs ) ;
16551655 }
16561656
1657+ /**
1658+ * Handler for incoming postMessages
1659+ * If the events data has a `type` property set to `dataSubmit`
1660+ * the value property is set to the current input
1661+ * @param {event } e
1662+ * @param {object } e.data
1663+ * @param {string } e.data.type - the type of request, currently the only value is "dataSubmit"
1664+ * @param {string } e.data.value - the value of the message
1665+ */
1666+ handlePostMessage ( e ) {
1667+ if ( "data" in e && "type" in e . data && "value" in e . data ) {
1668+ if ( e . data . type === "dataSubmit" ) {
1669+ this . setInput ( e . data . value ) ;
1670+ }
1671+ }
1672+ }
16571673}
16581674
16591675export default InputWaiter ;
You can’t perform that action at this time.
0 commit comments