ASDSO Dam Safety Toolbox

Template: WhatLinksHere: Difference between revisions

From ASDSO Dam Safety Toolbox
Jump to: navigation, search
No edit summary
No edit summary
 
(54 intermediate revisions by the same user not shown)
Line 1: Line 1:
<noinclude>
== Usage ==
{{WhatLinksHere}}
</noinclude>
----
<html>
<html>
   <iframe id="iframeWin"
   <div id="iframeDiv" style="display:none;">
          src="/wiki/Special:WhatLinksHere/</html>{{PAGENAME}}<html>"
    <hr style="width:5%;">
          style="border:none;width:100%;display:none;"
    <h4>What links here</h4>
          title="What Links Here">
    <iframe id="iframeWin"
   </iframe>
            src="/wiki/Special:WhatLinksHere/</html>{{PAGENAME}}<html>"
            style="border:none;width:100%;"></iframe>
   </div>


   <script type="application/javascript">
   <script>
     document.querySelector("iframe").addEventListener( "load", function(e) {
     document.querySelector("iframe").addEventListener( "load", function(e) {
       var iframeWin = document.getElementById("iframeWin");
       // Add parent to links
       var content = (iframeWin.contentWindow || iframeWin.contentDocument);
      let iframeWin = document.getElementById("iframeWin");
      if (content.document)content = content.document;
       let anchors = iframeWin.contentWindow.document.getElementById('mw-content-text').getElementsByTagName("a");
      // Adjust padding/margin
       for (let i=0; i<anchors.length; i++){
      iframeWin.contentWindow.document.getElementById('maincontentwrapper').style.marginLeft = "0px";
        anchors[i].setAttribute('target', '_parent');
       iframeWin.contentWindow.document.getElementById('maincontentwrapper').style.paddingLeft = "0px";
       }
      // Hide header, heading, back link & footer
      content.body.getElementsByTagName("header")[0].style.display = "none";
      content.body.getElementsByClassName("firstHeading")[0].style.display = "none";
      iframeWin.contentWindow.document.getElementById('contentSub').style.display = "none";
       content.body.getElementsByTagName("footer")[0].style.display = "none";
       // Show iframe
       // Show iframe
       iframeWin.style.display="block";
       document.getElementById('iframeDiv').style.display="block";
     });
     });


     window.onload = function() {
     window.onload = function() {
       var iframe = document.getElementById("iframeWin");
       // Set styles
       iframe.height = iframe.contentWindow.document.body.scrollHeight;
      let iframeStyles = `
        <style>
          #maincontentwrapper {
            margin-left: 0px;
            padding-left: 0px;
          }
          #content {
            padding-top: 0px;
            padding-left: 0px;
          }
          header, #footer,
          form, fieldset,
          .firstHeading,
          #contentSub,
          .usermessage,
          .mw-htmlform-ooui-wrapper {
            display: none;
          }
        </style>`;
      let iframeWin = document.getElementById("iframeWin");
       let doc = iframeWin.contentDocument;
      doc.body.innerHTML = doc.body.innerHTML + iframeStyles;
 
      // Set height
      iframeWin.height = iframeWin.contentWindow.document.body.scrollHeight;
     }
     }
    document.querySelector("iframe").addEventListener("click", function(e){
      debugger;
      console.log("here");
      setTimeout(myGreeting, 50000);
      var iframeWin = document.getElementById("iframeWin");
      iframeWin.contentWindow.postMessage(null, 'https://your-second-site.example');
    });
    window.addEventListener('message', event => {
      debugger;
      console.log("no here");
      setTimeout(myGreeting, 50000);
      console.log(event);
      console.log(event.origin);
      // IMPORTANT: check the origin of the data!
      if (event.origin === 'https://your-first-site.example') {
          // The data was sent from your site.
          // Data sent with postMessage is stored in event.data:
          console.log(event.data);
      } else {
          // The data was NOT sent from your site!
          // Be careful! Do not use it. This else branch is
          // here just for clarity, you usually shouldn't need it.
          return;
      }
    });
   </script>
   </script>
</html>
</html>

Latest revision as of 15:11, 9 August 2023