-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint.html
65 lines (50 loc) · 1.84 KB
/
print.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<html>
<head>
<style>
iframe {
border: 0;
height: 745px;
position: relative;
width: 1100px;
}
.first {
top: 20px;
}
.last {
top: 25px;
}
</style>
</head>
<body>
<iframe class="first" scrolling="no" src="page.html"></iframe>
<iframe class="last" name="rotate" id="rot" scrolling="no" src="page.html"></iframe>
</body>
<script>
window.onload = () => {
console.log('loaded');
const frameBody = frames[1].document.querySelector('body');
frameBody.style.transform = 'rotate(180deg)';
frameBody.style.position = 'relative';
frameBody.style.top = '-130px';
const groups = window.location.search.match(/\?first=(?<first>.*)&second=(?<second>.*)&secondLast=(?<secondLast>.*)&last=(?<last>.*)&hasLastPage=(?<hasLastPage>.*)/).groups
const upperLeftPage = frames[0].document.querySelector('.left.page')
const upperRightPage = frames[0].document.querySelector('.right.page')
const upperSeam = frames[0].document.querySelector('.seam')
const lowerLeftPage = frames[1].document.querySelector('.left.page')
const lowerRightPage = frames[1].document.querySelector('.right.page')
const lowerSeam = frames[1].document.querySelector('.seam')
upperLeftPage.setAttribute('data-page-number', groups.last)
upperRightPage.setAttribute('data-page-number', groups.first)
lowerLeftPage.setAttribute('data-page-number', groups.second)
lowerRightPage.setAttribute('data-page-number', groups.secondLast)
if (groups.first === '1') {
upperRightPage.classList.remove('visible')
upperSeam.classList.remove('visible')
}
if (groups.hasLastPage === 'true') {
lowerLeftPage.classList.remove('visible')
lowerSeam.classList.remove('visible')
}
}
</script>
</html>