-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhuntergram.js
143 lines (121 loc) · 4.68 KB
/
huntergram.js
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
window.addEventListener('DOMContentLoaded', (event) => {
/*disable image dragging*/
addEventListener('dragstart',function(e){e.preventDefault()});
/*store references to select elements*/
cover_sheet = document.getElementById('cover_sheet');
page_container = document.getElementById('page_container');
big_image = document.getElementById('big_image');
bio_container = document.getElementById('bio_container');
description_container = document.getElementById('description_container');
stats_container = document.getElementById('stats_container');
content_container = document.getElementById('content_container');
disappearing_border = document.getElementById('disappearing_border');
heart = document.getElementById('heart');
/*add event listener (and hideable class) to each 'content' div*/
all_content = document.querySelectorAll('.content');
all_content.forEach(content => {
content.addEventListener('mousedown', embiggen);
content.classList.add('fadeable');
});
/*add fadeable class to other divs*/
bio_container.classList.add('fadeable');
huntergram_logo.classList.add('fadeeable');
huntergram_logo_container.classList.add('fadeable');
description_container.classList.add('fadeable');
stats_container.classList.add('fadeable');
});
function embiggen(event) {
/*if it exists, re-enable (the now old) active_content's fadeability*/
if (typeof active_content !== 'undefined') {
active_content.classList.add('fadeable');
}
/*store a reference to the selected 'content' div*/
active_content = event.target.parentNode;
/*temporarily freeze scrolling*/
document.body.classList.add('stop-scrolling');
/*set big_image src to user selection and make it visible*/
big_image.src = event.target.src;
big_image.style.display = "block";
/*enable unbiggen trigger*/
cover_sheet.style.pointerEvents = "auto";
cover_sheet.addEventListener('click', unbiggen);
/*allow big_image to recieve pointerEvents (for liking)*/
big_image.style.cursor = "pointer";
big_image.style.pointerEvents = "auto";
/*fade out UI*/
all_content.forEach(content => {
content.classList.add('hidden');
});
bio_container.classList.add('hidden');
huntergram_logo_container.classList.add('hidden');
description_container.classList.add('hidden');
stats_container.classList.add('hidden');
disappearing_border.style.borderColor = "var(--pure_black)";
}
function unbiggen(event) {
/*"like leak" protection*/
heart.classList.add('no_animation');
/*disable unbiggen trigger*/
cover_sheet.style.pointerEvents = "none";
cover_sheet.removeEventListener('click', unbiggen);
/*disable pointerEvents for big_image (disable liking)*/
big_image.style.cursor = "auto";
big_image.style.pointerEvents = "none";
/*re-enable scrolling*/
document.body.classList.remove('stop-scrolling');
/*fade in UI*/
all_content.forEach(content => {
if (content == active_content) {
content.classList.remove('fadeable');
content.classList.remove('hidden');
}
else {
content.classList.remove('hidden');
}
});
bio_container.classList.remove('hidden');
huntergram_logo_container.classList.remove('hidden');
description_container.classList.remove('hidden');
stats_container.classList.remove('hidden');
disappearing_border.style.borderColor = "var(--dark_grey)";
/*hide big_image*/
big_image.style.display = "none";
}
function incrementFollowerCount() {
var follower_count = document.getElementById('follower_count');
var value = parseInt(follower_count.innerHTML, 10);
value = isNaN(value) ? 0 : value;
value++;
follower_count.innerHTML = value;
}
function toggleLike() {
/*disable "like leak" protection*/
heart.classList.remove('no_animation');
/*update like state and graphic*/
if(active_content.classList.contains('liked')) {
active_content.classList.remove('liked');
heart.src="resources/empty_heart.svg";
}
else {
active_content.classList.add('liked');
heart.src="resources/filled_heart.svg";
}
/*play animation (hacky workaround since quickly removing and re-adding animation classes didn't work)*/
if(!heart.classList.contains('heart_anim')){
heart.classList.add('heart_anim');
}
else {
heart.classList.toggle('alt');
}
}
/* You can use this to obfuscate your email address enough that bots won't bother finding it. */
function rot(str) {
var input = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
var output = 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm';
var index = x => input.indexOf(x);
var translate = x => index(x) > -1 ? output[index(x)] : x;
return str.split('').map(translate).join('');
}
function message() {
window.location.replace("m" + "a" + "i" + "l" + "t" + "o" + ":" + rot("LbheEbgngrqRznvyNqqerffUrer") + "@yoursite.com?subject=( 1 ) Unread Message · huntergram");
}