-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
153 lines (131 loc) · 3.54 KB
/
index.php
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
$FOX_NUM = (int)file_get_contents('https://randomfox.ca/script/script.js', NULL, NULL, 16, 3);
if (isset($_GET['i'])) {
if (ctype_digit($_GET['i'])) {
$random_fox_index = $_GET['i'];
} else {
$random_fox_index = rand(1, $FOX_NUM);
}
} else {
$random_fox_index = rand(1, $FOX_NUM);
}
?>
<html>
<head>
<title>RandomFox</title>
<meta charset="utf-8">
<meta type="author" content="xinitrc" />
<meta type="description" content="Displaying pictures of random foxes with every click!" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#FF6600" />
<meta http-equiv="Cache-Control" content="max-age=1" />
<meta property="og:image" content="http://randomfox.ca/images/<?= $random_fox_index ?>.jpg" />
<meta property="og:title" content="randomfox.ca" />
<meta property="og:description" content="Random fox on every click!" />
<meta property="og:url" content="http://m.randomfox.ca" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<style>
body {
font-family: "Lato", sans-serif;
text-align: center;
overflow-x: hidden;
}
.sidenav {
height: 0;
width: 100%;
position: fixed;
z-index: 3;
bottom: 0;
left: 0;
background-color: #111;
overflow-y: hidden;
transition: 0.5s;
color: #818181;
}
.sidenav a, #down-btn {
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
transition: 0.3s;
}
.sidenav a-test {
padding: 8px 8px 8px 32px;
}
#down-btn:hover {
color: #111;
}
.sidenav a:hover {
color: #f1f1f1;
}
.sidenav .closebtn {
font-size: 36px;
}
@media screen and (max-height: 450px) {
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
}
#fox-container, #down-btn {
max-height: calc(100% - 40px);
max-width: calc(100% - 16px);
}
#fox-container {
position: relative;
width: auto;
min-height: 1px;
display: inline-block;
border: 2px solid #ccc;
background-image: url('https://randomfox.ca/images/<?= $random_fox_index ?>.jpg');
background-repeat: no-repeat;
background-size: contain;
}
#fox-img {
height: 100%;
max-width: 100%;
position: relative;
z-index: 1;
visibility: hidden;
}
#fox-link {
position: absolute;
z-index: 2;
top: 0px;
left: 0px;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="fox-container">
<img src="https://randomfox.ca/images/<?= $random_fox_index ?>.jpg" alt="" title="" id="fox-img" />
<a href="http://m.randomfox.ca/?i=<?= $random_fox_index ?>" id="fox-link"></a>
</div>
<a href="javascript:void(0)" id="down-btn" tyle="font-size:30px;cursor:pointer" onclick="openNav()">˅ ˯ ⌄</a>
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">˄ ˰ ⌃</a>
<p>STUFF 'N' MORE THINGS</p>
</div>
<script>
function openNav() {
document.getElementById("mySidenav").style.height = "100%";
}
function closeNav() {
document.getElementById("mySidenav").style.height = "0";
}
$('#fox-img').on('bestfit',function(){
var image = new Image();
image.src = $(this).attr('src');
var css;
var ratio=image.naturalWidth / image.naturalHeight;
var perfect_height=$(this).width() / ratio;
if (perfect_height<$(this).height()) {
css={height:perfect_height};
}
$(this).css(css);
}).on('load', function(){
$(this).trigger('bestfit');
}).trigger('bestfit');
</script>
</body>
</html>