-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
141 lines (124 loc) · 3.98 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
<?php
function e($s, $attr = FALSE) {
echo htmlSpecialChars($s, $attr ? ENT_QUOTES : ENT_NOQUOTES);
}
function is_image($file) {
return !is_dir($file) && in_array(strtolower(pathinfo($file, PATHINFO_EXTENSION)), array('jpg', 'jpeg', 'png', 'gif'));
}
function name($file) {
echo trim(preg_replace_callback('/(^|\\-)+(.)/', function ($match) { return ' '.strtoupper($match[2]); }, pathinfo($file, PATHINFO_FILENAME)));
}
?><!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="robots" content="index, follow, all">
<title>Trolling Images | Comics</title>
<link href="bootstrap.min.css" type="text/css" rel="stylesheet" />
<style>
.container { margin-top: 40px; text-align:center; width:1000px; }
.container .face { display:block; float:left; width: 130px; height: 130px; margin: 10px 10px 0 0; text-align:center; }
.container a { display:block; width: 130px; height: 100px; }
.container a img { max-height:100%; max-width:100%; }
.search-query { width: 600px; height:30px; font-size: 20px; text-align:center; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<form class="well form-search">
<input type="text" id="searchQuery" class="input-medium search-query" placeholder="Search in images.." />
</form>
<?php foreach (glob(__DIR__ . '/images/*') as $file): if(!is_image($file)) continue ?>
<div class="face">
<a href="https://raw.githubusercontent.com/Northys/Trolling/master/images/<?php e(basename($file)) ?>">
<img src="images/<?php e(basename($file)) ?>" alt="<?php e(basename($file)) ?>">
</a>
<?php name($file) ?>
</div>
<?php endforeach ?>
</div>
<script>
$(function () {
var Trolling = {
displayRandom: 210,
carouselDelay: 2000,
Trolling: $('.face'),
input: $('#searchQuery'),
init: function () {
this.Trolling.hide();
this.input.on('keyup', $.proxy(this.search, this));
this.input.focus();
this.createIndex();
this.carouselPlay();
},
index: {},
createIndex: function () {
var me = this;
this.Trolling.each(function () {
me.index[$.trim($(this).text()).toLowerCase()] = $(this);
});
},
search: function () {
var searching = $.trim(this.input.val()).toLowerCase();
if (searching == "") {
this.Trolling.hide();
this.carouselPlay();
} else {
this.carouselStop();
$.each(this.index, function (key, val) {
if (key.indexOf(searching) != -1) {
val.show();
} else {
val.hide();
}
});
}
},
carouselTimer: null,
carouselPlay: function () {
if (this.carouselTimer) {
this.carouselStop();
}
this.carouselTimer = setInterval($.proxy(this.carousel, this), this.carouselDelay);
this.randomTrolling(this.displayRandom).show();
},
carouselStop: function () {
clearInterval(this.carouselTimer);
this.carouselTimer = false;
this.Trolling.stop();
this.Trolling.css({opacity:1});
this.Trolling.hide();
},
carousel: function () {
var hidden = this.randomHidden();
var visible = this.randomVisible();
visible.before(hidden);
visible.fadeOut('slow', $.proxy(function () {
hidden.fadeIn('slow');
}, this));
},
randomVisible: function (){
return this.randomTrolling(1, this.Trolling.find(':visible')).closest('.face');
},
randomHidden: function (){
return this.randomTrolling(1, this.Trolling.find(':hidden')).closest('.face');
},
randomTrolling: function (num, Trolling) {
if (typeof num === 'undefined') {
num = 1;
}
if (typeof Trolling === 'undefined') {
Trolling = this.Trolling;
}
var max = Trolling.length - num;
var start = Math.floor(Math.random() * max);
return Trolling.slice(start, num + start);
}
};
Trolling.init();
});
</script>
</body>
</html>