-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexsub.php
359 lines (320 loc) · 9.97 KB
/
indexsub.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<?php
/////////////////////////////////////////////////////////////////////
// This is the only portion of the code you may need to change.
// Indicate the location of your images
$root = '';
// use if specifying path from root
//$root = $_SERVER['DOCUMENT_ROOT'];
$path = 'images/';
// End of user modified section
/////////////////////////////////////////////////////////////////////
function getImagesFromDir($path) {
$images = array();
if ( $img_dir = @opendir($path) ) {
while ( false !== ($img_file = readdir($img_dir)) ) {
// checks for gif, jpg, png
if ( preg_match("/(\.gif|\.jpg|\.png)$/", $img_file) ) {
$images[] = $img_file;
}
}
closedir($img_dir);
}
return $images;
}
function getRandomFromArray($ar) {
mt_srand( (double)microtime() * 1000000 ); // php 4.2+ not needed
$num = array_rand($ar);
return $ar[$num];
}
//CATEGORIE
$subs = array();
$results = scandir($path);
foreach ($results as $result) {
if ($result === '.' or $result === '..') continue;
if (is_dir($path . '/' . $result)) {
$subs[] = $result;
}
}
// Obtain list of images from directory
$imgList = getImagesFromDir($root . $path);
$img = getRandomFromArray($imgList);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PierPaolo Moro</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<style>
@font-face {
font-family: Trade Gothic LT Std Extended;
src: url("assets/TradeGothicLTStd-BoldExt.otf") format("opentype");
font-weight: bold;
}
@font-face {
font-family: Trade Gothic LT Std Extended;
/*src: url("assets/TradeGothicLTStd-BoldExt.otf") format("opentype");*/
src: url("assets/TradeGothicLTStd-Light.otf") format("opentype");
font-weight: lighter;
}
@font-face {
font-family: Trade Gothic LT Std Extended;
/*src: url("assets/TradeGothicLTStd-BoldExt.otf") format("opentype");*/
src: url("assets/TradeGothicLTStd.otf") format("opentype");
font-weight: normal;
}
body{
font-family: Trade Gothic LT Std Extended!important;
line-height: 14px;
font-size: 12px;
-webkit-user-select: none;
-moz-user-select: -moz-none;
-ms-user-select: none;
user-select: none;
}
h1{
text-transform: uppercase;
font-size: 2.5em;
line-height: 0px;
-webkit-margin-after: 0.4em;
-webkit-margin-before: 0.4em;
}
a{
color: black!important;
text-decoration: none;
}
#spotify{
position: absolute;
left: 0;
top: 0;
z-index:2;
}
#nav{
position: absolute;
top: 0;
right: 0;
z-index:2;
/*width: 100px;
height: 100px;
background: red;*/
text-align:right;
}
#img{
cursor: pointer;
/*max-width: 100%;
max-height: 100%;*/
height: -webkit-fill-available;
}
#flex{
padding: 0;
position: absolute;
margin: 0;
list-style: none;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
z-index:1;
}
#container2{
background-repeat:no-repeat;
/*background-size:contain;*/
position: relative;
max-width: 70%;
max-height: 70%;
width: 70%;
height: 70%;
background-position: 50%;
/*top: 15%;
margin: auto;
border: 1px solid black;*/
}
#container2.white{
background-image: none!important;
}
#container2.click{
cursor: pointer;
}
#contactBox, #infoBox{
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
}
body{
margin: 0px;
}
#menu span{
cursor: pointer;
}
#menu span:hover, a.list:hover {
opacity: 0.5;
}
#menu span.active{
text-decoration: underline;
}
@media screen and (max-width: 2560px){
#portfolioBox{
margin-top:3px;
}
}
</style>
<script>
$(document).ready(function(){
var subs = JSON.parse('<?php echo JSON_encode($subs);?>');
//PHP Array to JS
var img = JSON.parse('<?php echo JSON_encode($imgList);?>');
//On click change img
function changeImg(number){
if (!number){var number = Math.floor(Math.random()*img.length);
}
var imgURL = img[number];
var path = "<?php echo $path ?>";
//var imgURL = img[Math.floor(Math.random()*img.length)];
var hidden = '<img style="display:none" id="imagetogetsize" src="'+path+imgURL+'">';
$('#hidden').html(hidden);
image = document.getElementById('imagetogetsize');
//$('#imagetogetsize').load(function(){console.log('cia')});
$('#imagetogetsize').on('load',function(){
var width = image.naturalWidth;
var height = image.naturalHeight;
var box = $('#container2');
var boxwidth = box.width();
var boxheight = box.height();
console.log(width,height,boxwidth,boxheight);
if (width < boxwidth && height < boxheight){
box.css('background-size','auto');
} else {
box.css('background-size','contain');
}
box.css('background-image','url('+ path +imgURL+')');
});
return number;
}
changeImg();
$('#container2').on('click',function(){
//$(this).css('background-image','url(<?php echo $path ?>'+img[Math.floor(Math.random()*img.length)]+')');
var listNum = changeImg();
$('a.list').css('text-decoration','none');
$('a.list').eq(listNum).css('text-decoration','underline');
});
//Make image List and Menu
function pad(n) {
return (n < 10) ? ("0" + n) : n;
}
for (var num in img){
var x = '<a href="#" class="list" number="'+(num) +'" link="images/'+ img[num] +'">'+ pad(parseInt(num)+1) +'</a><br>'
//$(x).append('#categories');
$('#portfolioNum').append(x);
}
//Subcategories
if (0 < subs.length){
for (var sub in subs){
var div= '<div class="sub" id="'+subs[sub]+'">'+subs[sub]+'<div class="num"></div></div>';
$(div).insertBefore('#portfolioNum');
}
$('.sub').each(function(){
//add numbers;
});
}
//Menu Actiov
$('.list').on('click',function(){
$('.list').css('text-decoration','none');
changeImg($(this).attr('number'));
//$('#container2').css('background-image','url('+ $(this).attr('link') +')');
$(this).css('text-decoration','underline');
});
$('#portfolio').on('click',function(){
$('#info.active').removeClass('active');
$('#contact.active').removeClass('active');
if ($(this).hasClass('active')){$('#portfolioBox').hide(); $(this).removeClass('active')}
else {$('#portfolioBox').show(); $(this).addClass('active');};
$('#contactBox').hide();
$('#infoBox').hide();
$('#container2').removeClass('white');
$('#container2').addClass('click');
});
$('#info').on('click',function(){
$('#portfolioBox').hide();
$('#contactBox').hide();
$('#infoBox').show();
$('#container2').addClass('white');
$('#container2').removeClass('click');
$('#menu span.active').removeClass('active');
$('#info').addClass('active');
});
$('#contact').on('click',function(){
$('#portfolioBox').hide();
$('#contactBox').show();
$('#infoBox').hide();
$('#container2').addClass('white');
$('#container2').removeClass('click');
$('#menu span.active').removeClass('active');
$('#contact').addClass('active');
});
$('#logo').on('click',function(){
$('#portfolioBox').hide();
$('#contactBox').hide();
$('#infoBox').hide();
$('#container2').removeClass('white');
$('#container2').addClass('click');
$('#menu span.active').removeClass('active');
//$('#container2').css('background-image','url(<?php echo $path ?>'+img[Math.floor(Math.random()*img.length)]+')');
changeImg();
});
//------------------------------------------------RESIZE
var windowWidth = $(window).innerWidth();
var windowHeight = $(window).innerHeight();
$('body').css('width',windowWidth );
$('body').css('height',windowHeight );
$(window).on('resize',function(){
console.log('RESIZE WINDOW');
var OldwindowWidth = windowWidth;
var OldwindowHeight = windowHeight;
windowWidth = $(window).innerWidth();
windowHeight = $(window).innerHeight();
console.log('width:',windowWidth,'height',windowHeight);
console.log('OLDwidth:',OldwindowWidth,'OLDheight',OldwindowHeight);
$('body').css('width',windowWidth );
$('body').css('height',windowHeight );
});
});
</script>
</head>
<body>
<!--iframe src="https://open.spotify.com/embed/user/21pizt3vxnh7w5hylsktuaawi/playlist/0tWi3asASL07tAM57JP6jc&theme=white&" width="300" height="80" frameborder="0" allowtransparency="true" id="spotify"></iframe-->
<!--iframe src="https://open.spotify.com/embed?uri=spotify%3Auser%3A21pizt3vxnh7w5hylsktuaawi%3APlaylist%3A0tWi3asASL07tAM57JP6jc&theme=white" width="300" height="80" frameborder="0" allowtransparency="true"></iframe-->
<iframe src="https://open.spotify.com/embed?uri=spotify%3Auser%3A21pizt3vxnh7w5hylsktuaawi%3Aplaylist%3A0tWi3asASL07tAM57JP6jc&theme=white" width="300" height="80" frameborder="0" allowtransparency="true" id="spotify"></iframe>
<div id="nav">
<div id="menu">
<img id="logo" src="assets/nome.png" style="max-width: 27.5em; cursor: pointer"><br>
<!--h1>PierPaoloMoro</h1-->
<span id="portfolio">portfolio</span> \ <span id="info">info</span> \ <span id="contact">contact</span>
<div id="portfolioBox" style="display:none">
<div id="portfolioNum"></div>
</div>
<!--a href="#">information</a><br-->
</div>
</div>
<div id="flex"><div id="container2" class="click"><div id="contactBox" style="display:none"><a href="mailto:[email protected]">[email protected]</a></div><div id="infoBox" style="display: none"><!--I’m Pier.<br>
I live in London.<br>
I love Violence.<br>
Normal Life exite me.<br>
Nothing is more Vicious<br>
than Reality-->
1994 Born.<br>
2013 IUAV university of Design.<br>
2016 Internship at Pitis (Paris) Erasmus+ Winner.<br>
2016 BA Degree in Graphic and Industrial Design.<br>
2016 Moved to London.<br>
2016 Internship at Guru Graphics Limited (London) Erasmus+ Winner.<br>
2017 Graphic Designer at Guru Graphics Limited (Full Time).<br>
2017 Visual Designer at GVC Holding (London).
</div></div>
</div>
</body>
<div style="display:none; opacity: 0; width: 0px; height: 0px" id="hidden"></div>
</html>