| 1 | <html>
|
|---|
| 2 |
|
|---|
| 3 | <body>
|
|---|
| 4 |
|
|---|
| 5 | <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script>
|
|---|
| 6 | <script>
|
|---|
| 7 |
|
|---|
| 8 | /**
|
|---|
| 9 | * WordPress inline HTML embed
|
|---|
| 10 | *
|
|---|
| 11 | * @since 4.4.0
|
|---|
| 12 | *
|
|---|
| 13 | * This file cannot have ampersands in it. This is to ensure
|
|---|
| 14 | * it can be embedded in older versions of WordPress.
|
|---|
| 15 | * See https://core.trac.wordpress.org/changeset/35708.
|
|---|
| 16 | */
|
|---|
| 17 | (function ( window, document ) {
|
|---|
| 18 | 'use strict';
|
|---|
| 19 |
|
|---|
| 20 | var supportedBrowser = false,
|
|---|
| 21 | loaded = false;
|
|---|
| 22 |
|
|---|
| 23 | if ( document.querySelector ) {
|
|---|
| 24 | if ( window.addEventListener ) {
|
|---|
| 25 | supportedBrowser = true;
|
|---|
| 26 | }
|
|---|
| 27 | }
|
|---|
| 28 | window.wp = window.wp || {};
|
|---|
| 29 |
|
|---|
| 30 | if ( !! window.wp.receiveEmbedMessage ) {
|
|---|
| 31 | return;
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | window.wp.receiveEmbedMessage = function( e ) {
|
|---|
| 35 | var data = e.data;
|
|---|
| 36 | console.log(data);
|
|---|
| 37 | if ( ! ( data.secret || data.message || data.value ) ) {
|
|---|
| 38 | return;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | if ( /[^a-zA-Z0-9]/.test( data.secret ) ) {
|
|---|
| 42 | return;
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | var iframes = document.querySelectorAll( 'iframe[data-secret="' + data.secret + '"]' ),
|
|---|
| 46 | blockquotes = document.querySelectorAll( 'blockquote[data-secret="' + data.secret + '"]' ),
|
|---|
| 47 | i, source, height, sourceURL, targetURL;
|
|---|
| 48 |
|
|---|
| 49 | for ( i = 0; i < blockquotes.length; i++ ) {
|
|---|
| 50 | blockquotes[ i ].style.display = 'none';
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | for ( i = 0; i < iframes.length; i++ ) {
|
|---|
| 54 | source = iframes[ i ];
|
|---|
| 55 |
|
|---|
| 56 | if ( e.source !== source.contentWindow ) {
|
|---|
| 57 | continue;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | source.style.display = '';
|
|---|
| 61 |
|
|---|
| 62 | /* Resize the iframe on request. */
|
|---|
| 63 | if ( 'height' === data.message ) {
|
|---|
| 64 | height = parseInt( data.value, 10 );
|
|---|
| 65 | if ( height > 1000 ) {
|
|---|
| 66 | height = 1000;
|
|---|
| 67 | } else if ( ~~height < 200 ) {
|
|---|
| 68 | height = 200;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | source.height = height;
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | /* Link to a specific URL on request. */
|
|---|
| 75 | if ( 'link' === data.message ) {
|
|---|
| 76 | sourceURL = document.createElement( 'a' );
|
|---|
| 77 | targetURL = document.createElement( 'a' );
|
|---|
| 78 |
|
|---|
| 79 | sourceURL.href = source.getAttribute( 'src' );
|
|---|
| 80 | targetURL.href = data.value;
|
|---|
| 81 |
|
|---|
| 82 | /* Only continue if link hostname matches iframe's hostname. */
|
|---|
| 83 | if ( targetURL.host === sourceURL.host ) {
|
|---|
| 84 | if ( document.activeElement === source ) {
|
|---|
| 85 | window.top.location.href = data.value;
|
|---|
| 86 | }
|
|---|
| 87 | }
|
|---|
| 88 | }
|
|---|
| 89 | }
|
|---|
| 90 | };
|
|---|
| 91 |
|
|---|
| 92 | function onLoad() {
|
|---|
| 93 | if ( loaded ) {
|
|---|
| 94 | return;
|
|---|
| 95 | }
|
|---|
| 96 | loaded = true;
|
|---|
| 97 |
|
|---|
| 98 | var isIE10 = -1 !== navigator.appVersion.indexOf( 'MSIE 10' ),
|
|---|
| 99 | isIE11 = !!navigator.userAgent.match( /Trident.*rv:11\./ ),
|
|---|
| 100 | iframes = document.querySelectorAll( 'iframe.wp-embedded-content' ),
|
|---|
| 101 | blockquotes = document.querySelectorAll( 'blockquote.wp-embedded-content' ),
|
|---|
| 102 | iframeClone, i, source, secret;
|
|---|
| 103 |
|
|---|
| 104 | for ( i = 0; i < blockquotes.length; i++ ) {
|
|---|
| 105 | blockquotes[ i ].style.display = 'none';
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | for ( i = 0; i < iframes.length; i++ ) {
|
|---|
| 109 | source = iframes[ i ];
|
|---|
| 110 | source.style.display = '';
|
|---|
| 111 |
|
|---|
| 112 | if ( source.getAttribute( 'data-secret' ) ) {
|
|---|
| 113 | continue;
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | /* Add secret to iframe */
|
|---|
| 117 | secret = Math.random().toString( 36 ).substr( 2, 10 );
|
|---|
| 118 | source.src += '#?secret=' + secret;
|
|---|
| 119 | source.setAttribute( 'data-secret', secret );
|
|---|
| 120 |
|
|---|
| 121 | /* Remove security attribute from iframes in IE10 and IE11. */
|
|---|
| 122 | if ( ( isIE10 || isIE11 ) ) {
|
|---|
| 123 | iframeClone = source.cloneNode( true );
|
|---|
| 124 | iframeClone.removeAttribute( 'security' );
|
|---|
| 125 | source.parentNode.replaceChild( iframeClone, source );
|
|---|
| 126 | }
|
|---|
| 127 | }
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | if ( supportedBrowser ) {
|
|---|
| 131 | window.addEventListener( 'message', window.wp.receiveEmbedMessage, false );
|
|---|
| 132 | document.addEventListener( 'DOMContentLoaded', onLoad, false );
|
|---|
| 133 | window.addEventListener( 'load', onLoad, false );
|
|---|
| 134 | }
|
|---|
| 135 | })( window, document );
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 | </script>
|
|---|
| 139 |
|
|---|
| 140 | <iframe src="embed-problematic.html#secret=jip" data-secret="jip" width="400" height="100" sandbox="allow-scripts" frameborder="0"></iframe>
|
|---|
| 141 | <iframe src="embed-no-auto-height.html#secret=jip2" data-secret="jip2" width="400" height="100" sandbox="allow-scripts" frameborder="0"></iframe>
|
|---|
| 142 |
|
|---|
| 143 | </body>
|
|---|
| 144 | </html>
|
|---|