OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <head> |
| 3 <style> |
| 4 body { |
| 5 margin: 0px; |
| 6 } |
| 7 .row { |
| 8 display: table-row; |
| 9 vertical-align: inherit; |
| 10 } |
| 11 #header, #footer { |
| 12 display: table; |
| 13 table-layout:fixed; |
| 14 width: inherit; |
| 15 } |
| 16 #header { |
| 17 vertical-align: top; |
| 18 } |
| 19 #footer { |
| 20 vertical-align: bottom; |
| 21 } |
| 22 .text { |
| 23 display: table-cell; |
| 24 font-family: Sans; |
| 25 padding-left: 0.5cm; |
| 26 padding-right: 0.5cm; |
| 27 vertical-align: inherit; |
| 28 white-space: nowrap; |
| 29 } |
| 30 #page_number { |
| 31 text-align: right; |
| 32 } |
| 33 #title { |
| 34 text-align: center; |
| 35 } |
| 36 #title, #url { |
| 37 overflow: hidden; |
| 38 text-overflow: ellipsis; |
| 39 } |
| 40 #title, #date { |
| 41 padding-bottom: 0cm; |
| 42 padding-top: 0.5cm; |
| 43 } |
| 44 #page_number, #url { |
| 45 padding-bottom: 0.5cm; |
| 46 padding-top: 0cm; |
| 47 } |
| 48 </style> |
| 49 <script> |
| 50 |
| 51 function pixels(value) { |
| 52 return value + 'px'; |
| 53 } |
| 54 |
| 55 function setup(options) { |
| 56 document.styleSheets[0].insertRule( |
| 57 '.text { font-size: ' + pixels(options['fontSize']) + '; }'); |
| 58 var body = document.querySelector('body'); |
| 59 var header = document.querySelector('#header'); |
| 60 var content = document.querySelector('#content'); |
| 61 var footer = document.querySelector('#footer'); |
| 62 |
| 63 body.style.width = pixels(options['width']); |
| 64 body.style.height = pixels(options['height']); |
| 65 header.style.height = pixels(options['topMargin']); |
| 66 content.style.height = pixels(options['height'] - options['topMargin'] - |
| 67 options['bottomMargin']); |
| 68 footer.style.height = pixels(options['bottomMargin']); |
| 69 |
| 70 document.querySelector('#date span').innerText = options['date']; |
| 71 document.querySelector('#title span').innerText = options['title']; |
| 72 document.querySelector('#url span').innerText = options['url']; |
| 73 document.querySelector('#page_number span').innerText = options['pageNumber']; |
| 74 |
| 75 // Reduce date and page number space to give more space to title and url. |
| 76 document.querySelector('#date').style.width = |
| 77 pixels(document.querySelector('#date span').offsetWidth); |
| 78 document.querySelector('#page_number').style.width = |
| 79 pixels(document.querySelector('#page_number span').offsetWidth); |
| 80 |
| 81 // Hide text if it doesn't fit into expected margins. |
| 82 if (header.offsetHeight > options['topMargin'] + 1 || |
| 83 footer.offsetHeight > options['bottomMargin'] + 1) { |
| 84 header.style.display = 'none'; |
| 85 footer.style.display = 'none'; |
| 86 } |
| 87 } |
| 88 |
| 89 </script> |
| 90 </head> |
| 91 <body> |
| 92 <div id="header"> |
| 93 <div class="row"> |
| 94 <div id="date" class="text"><span/></div> |
| 95 <div id="title" class="text"><span/></div> |
| 96 </div> |
| 97 </div> |
| 98 <div id="content"> |
| 99 </div> |
| 100 <div id="footer"> |
| 101 <div class="row"> |
| 102 <div id="url" class="text"><span/></div> |
| 103 <div id="page_number" class="text"><span/></div> |
| 104 </div> |
| 105 </div> |
| 106 </body> |
| 107 </html> |
OLD | NEW |