index.html 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <html>
  2. <head>
  3. <script src="../../../script/jquery.min.js"></script>
  4. <script src="../../../script/ao_module.js"></script>
  5. <title>NotepadA Test Window</title>
  6. <style>
  7. body{
  8. font-family: Arial !important;
  9. background-color:#ebebeb;
  10. }
  11. .menu{
  12. position:fixed;
  13. top:0;
  14. left:0;
  15. width:100%;
  16. height:18px;
  17. background-color:#3d3d3d;
  18. padding:5px;
  19. color:white;
  20. font-size:80%;
  21. }
  22. .urlinput{
  23. display:inline;
  24. }
  25. .toRight{
  26. position:absolute;
  27. right:15px;
  28. top:3px;
  29. }
  30. .previewArea{
  31. width:100%;
  32. position:fixed;
  33. top:27px;
  34. left:0px;
  35. }
  36. #previewWindow{
  37. position:absolute;
  38. left:0px;
  39. top:0px;
  40. }
  41. </style>
  42. </head>
  43. <body>
  44. <div id="toolbar" class="menu">
  45. Window Size:   <div id="windowsize" style="display:inline;">loading...</div><button class="toRight" onClick="document.getElementById('previewWindow').contentWindow.location.reload();">Refresh</button>
  46. </div>
  47. <div class="previewArea">
  48. <iframe id="previewWindow" frameBorder="0" width="100%" src="nothing.html"></iframe>
  49. </div>
  50. </body>
  51. <script>
  52. var bottomPadding = 8; //In pixel
  53. adjustIframeSize();
  54. function adjustIframeSize(){
  55. var w = window.innerWidth;
  56. var h = window.innerHeight;
  57. $("#windowsize").html(w + "px x " + (h - parseInt($("#toolbar").height()) - bottomPadding) + "px");
  58. $("#previewWindow").attr("width",w + "px");
  59. $("#previewWindow").attr("height",(h - parseInt($("#toolbar").height()) - bottomPadding) + "px")
  60. }
  61. $( window ).resize(function() {
  62. adjustIframeSize();
  63. });
  64. //Check if anyfile are passed in
  65. var inputFile = ao_module_loadInputFiles();
  66. if (inputFile != null){
  67. inputFile = inputFile[0];
  68. //Contains input file. Check if it can be opened (.html / .htm)
  69. var ext = inputFile.filename.split(".");
  70. ext = ext.pop();
  71. if (ext == "html" || ext == "htm"){
  72. //Open it
  73. $("#previewWindow").attr('src', "../../../media?file=" + inputFile.filepath)
  74. }else{
  75. $("#previewWindow").attr('src', "./notviewable.html");
  76. }
  77. }
  78. </script>
  79. </html>