HTML Table Cell Maintained Dimensions Variably Zoomed Content Primer Tutorial

HTML Table Cell Maintained Dimensions Variably Zoomed Content Primer Tutorial

HTML Table Cell Maintained Dimensions Variably Zoomed Content Primer Tutorial

Yesterday’s Speech to Text LibreOffice Template Tutorial had synergies with process, explained yesterday, and synergies with trying to express zoomed content in a limited space, involving two quite different concepts …

  • Hangman Game
  • LibreOffice Template

… us deciding on a static Zoom=50% (Scale=0.5) display with this in yesterday’s work. This got us wondering if we can design a proof of concept web application where …

  • the Zooming (or Scaling) can be dynamically selected by the user, bit like those magnifier functionalities so popular on fashion eCommerce websites
  • a couple of content choices (as above) can be dynamically selected by the user
  • the display of this content can be created at …
    1. document.body onload event … and/or …
    2. onclick event … shared Javascript code as per …

      function load_zoomed_content(prefix,othis) {
      prefx=prefix;
      if (othis.innerHTML.indexOf('over' + 'flow') == -1) othis.innerHTML+='<div onclick="prefx=' + "'" + prefix + "';" + '" id="' + prefix + 'divhangman" style="background-color:white;overflow:hidden;width:100%;height:100%;"></div>';
      myw=eval(window.getComputedStyle(document.getElementById(prefix + 'divhangman'), null).getPropertyValue('width').replace('px','')); // + myw;
      myh=eval(window.getComputedStyle(document.getElementById(prefix + 'divhangman'), null).getPropertyValue('height').replace('px','')); // + myh;
      document.getElementById(prefix + 'divhangman').innerHTML='<iframe onclick="prefx=' + "'" + prefix + "';" + '" style="border:1px solid red;transform-origin: 0% 0%;transform:scale(' + document.getElementById('scale').value + '); -o-transform: scale(' + document.getElementById('scale').value + '); -moz-transform: scale(' + document.getElementById('scale').value + '); -ms-transform: scale(' + document.getElementById('scale').value + '); -webkit-transform: scale(' + document.getElementById('scale').value + ');width:' + Math.floor(eval(eval(100.0 / document.getElementById('scale').value))) + '%;height:' + Math.floor(eval(eval(100.0 / document.getElementById('scale').value))) + '%;" id="' + prefix + 'ihangman" src="hangman_bg.html?curplayer=' + curplayer + '&tosolve=' + encodeURIComponent(swhatshort) + "&clue=" + encodeURIComponent(clue) + '"></iframe>';
      if (document.getElementById('ohangman').value.indexOf('?') == -1) {
      prefx=prefix;
      docontent('hangman_bg.html?curplayer=' + curplayer + '&tosolve=' + encodeURIComponent(swhatshort) + "&clue=" + encodeURIComponent(clue));
      doscale(document.getElementById('scale').value);
      } else {
      prefx=prefix;
      docontent(document.getElementById('content').value);
      doscale(document.getElementById('scale').value);
      }
      othis.style.width=Math.floor(eval(myw)) + 'px';
      othis.style.height=Math.floor(eval(myh)) + 'px';
      othis.style.maxWidth=Math.floor(eval(myw)) + 'px';
      othis.style.maxHeight=Math.floor(eval(myh)) + 'px';
      document.getElementById(prefix + 'divhangman').style.width=Math.floor(eval(myw)) + 'px';
      document.getElementById(prefix + 'divhangman').style.height=Math.floor(eval(myh)) + 'px';
      document.getElementById(prefix + 'divhangman').style.maxWidth=Math.floor(eval(myw)) + 'px';
      document.getElementById(prefix + 'divhangman').style.maxHeight=Math.floor(eval(myh)) + 'px';
      document.getElementById(prefix + 'ihangman').style.width=Math.floor(eval(eval(1.0 / document.getElementById('scale').value) * myw)) + 'px';
      document.getElementById(prefix + 'ihangman').style.height=Math.floor(eval(eval(1.0 / document.getElementById('scale').value) * myh)) + 'px';
      document.getElementById(prefix + 'ihangman').style.maxWidth=Math.floor(eval(eval(1.0 / document.getElementById('scale').value) * myw)) + 'px';
      document.getElementById(prefix + 'ihangman').style.maxHeight=Math.floor(eval(eval(1.0 / document.getElementById('scale').value) * myh)) + 'px';
      }
  • for a webpage consisting of a 3×3 grid of HTML table cells (td)

Try a live run link into a new window or see it in an HTML iframe below …

… and HTML and Javascript and CSS zoom_in_middle.html code you can download if you like. We hope it is food for thought for you.

If this was interesting you may be interested in this too.

This entry was posted in eLearning, Event-Driven Programming, Tutorials and tagged , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *