{"id":99,"date":"2020-05-12T14:30:40","date_gmt":"2020-05-12T12:30:40","guid":{"rendered":"http:\/\/wiki.hogs.live\/?page_id=99"},"modified":"2020-07-22T07:12:47","modified_gmt":"2020-07-22T05:12:47","slug":"eventy","status":"publish","type":"page","link":"https:\/\/wiki.hogs.live\/en\/eventy\/","title":{"rendered":"Eventy"},"content":{"rendered":"<p>There is a possibility to send information without reloading the iframe. In the same way you can receive information from the iframe. <\/p>\n\n\n\n<p> Sending event: <\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>\n<code>\n&lt;body&gt;\n<br>\n&nbsp;&lt;iframe id=\"iframe\" src=\"https:\/\/iframe.hogs.live\/\"&gt;&lt;\/iframe&gt;\n<br>\n&lt;\/body&gt;\n<br>\n&lt;script&gt;\n<br>\n&nbsp;const iframe = document.getElementById('iframe');\n<br>\n&nbsp;function sendEventToIframe(data) {\n<br>\n&nbsp;&nbsp;iframe.contentWindow.postMessage(data, '*');\n<br>\n&nbsp;}\n<br>\n\n&nbsp;sendEventToIframe('sth');\n<br>\n&lt;\/script&gt;\n<\/code>\n<\/p><\/blockquote>\n\n\n\n<p>Receiving event<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code>\nwindow.addEventListener('message', (event) =&gt; {\n<br>\n&nbsp;&nbsp;console.log('Dane z iframe: ', event.data);\n<br>\n});\n<\/code><\/p><\/blockquote>\n\n\n\n<p> Event model <\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>\n<code>\n<em>interface<\/em>&nbsp;Event&nbsp;{<br>&nbsp;&nbsp;type:&nbsp;string;<br>&nbsp;&nbsp;data:&nbsp;<em>any<\/em>;<br>} \n<\/code><\/p><\/blockquote>\n\n\n\n<h4>Eventy przyjowane przez iframe&#8217;a<\/h4>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td><strong>Name<\/strong><\/td><td><strong>Data<\/strong><\/td><td><strong>Comments<\/strong><\/td><\/tr><tr><td> calculateRoute <\/td><td class=\" translation-block\"><strong>option<\/strong> parameter value for <strong>mode= calculateRoute<\/strong><\/td><td>Route plotting request<\/td><\/tr><tr><td>setLang<\/td><td> ENG&nbsp;|&nbsp;DEU&nbsp;|&nbsp;CZE&nbsp;|&nbsp;ESP&nbsp;|&nbsp;FRA&nbsp;|&nbsp;POL&nbsp;|&nbsp;RUS&nbsp;|&nbsp;UKR  <\/td><td>Dynamic languege change. Requesting new map render<\/td><\/tr><\/tbody><\/table>\n\n\n\n<h4>Eventy emitowane<\/h4>\n\n\n\n<table class=\"wp-block-table post-6\"><tbody><tr><td><strong>Name<\/strong><\/td><td><strong>Data<\/strong><\/td><td><strong>Comments<\/strong><\/td><\/tr><tr><td> calculationSucces <\/td><td class=\" translation-block\">format described <a href=\"http:\/\/wiki.hogs.live\/en\/wyznaczanie-trasy-2\/\" target=\"_self\">here<\/a><\/td><td>Emit with information about plotted route<\/td><\/tr><tr><td>error<\/td><td><\/td><td>Error message<\/td><\/tr><tr><td>warning<\/td><td><\/td><td>Warning message<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Istnieje tak\u017ce mo\u017cliwo\u015b\u0107 przes\u0142ania informacji bez potrzeby prze\u0142adowywania iframe&#8217;a. W analogiczny spos\u00f3b mo\u017cna odebra\u0107 informacje od iframe&#8217;a. Wys\u0142anie eventu: &lt;body&gt; &nbsp;&lt;iframe id=&#8221;iframe&#8221; src=&#8221;https:\/\/iframe.hogs.live\/&#8221;&gt;&lt;\/iframe&gt; &lt;\/body&gt; &lt;script&gt; &nbsp;const iframe = document.getElementById(&#8217;iframe&#8217;); &nbsp;function sendEventToIframe(data) { &nbsp;&nbsp;iframe.contentWindow.postMessage(data, '*&#8217;); &nbsp;} &nbsp;sendEventToIframe(&#8217;sth&#8217;); &lt;\/script&gt; Odebranie eventu: window.addEventListener(&#8217;message&#8217;, (event) =&gt; { &nbsp;&nbsp;console.log(&#8217;Dane z iframe: &#8217;, event.data); }); Model eventu interface&nbsp;Event&nbsp;{&nbsp;&nbsp;type:&nbsp;string;&nbsp;&nbsp;data:&nbsp;any;} Eventy przyjowane przez ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/wiki.hogs.live\/en\/eventy\/\" title=\"read more...\">Read more<\/a><\/p>","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/wiki.hogs.live\/en\/wp-json\/wp\/v2\/pages\/99"}],"collection":[{"href":"https:\/\/wiki.hogs.live\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/wiki.hogs.live\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/wiki.hogs.live\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wiki.hogs.live\/en\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":6,"href":"https:\/\/wiki.hogs.live\/en\/wp-json\/wp\/v2\/pages\/99\/revisions"}],"predecessor-version":[{"id":161,"href":"https:\/\/wiki.hogs.live\/en\/wp-json\/wp\/v2\/pages\/99\/revisions\/161"}],"wp:attachment":[{"href":"https:\/\/wiki.hogs.live\/en\/wp-json\/wp\/v2\/media?parent=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}