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
|
function like(post_id, reblog_key) {
$.ajax({
url: "https://example.com/vox-populi/action.php?action=like&post_id=" + post_id + "&reblog_key=" + reblog_key,
success: function (result) {
if (result == "success") {
$("a[data-like-id='" + post_id + "'] svg").css("fill", "#dc3545");
} else {
alert("Error: Failed to like post.");
}
}
});
}
function unlike(post_id, reblog_key) {
$.ajax({
url: "https://example.com/vox-populi/action.php?action=unlike&post_id=" + post_id + "&reblog_key=" + reblog_key,
success: function (result) {
if (result == "success") {
$("a[data-unlike-id='" + post_id + "'] svg").css("fill", "none");
} else {
alert("Error: Failed to unlike post.");
}
}
});
}
function follow(blog_name, uuid) {
$.ajax({
url: "https://example.com/vox-populi/action.php?action=follow&blog_name=" + blog_name,
success: function (result) {
if (result == "success") {
$("a[data-follow-id='" + uuid + "']").css("display", "none");
} else {
alert("Error: Failed to like post.");
}
}
});
}
function unfollow(blog_name, uuid) {
$.ajax({
url: "https://example.com/vox-populi/action.php?action=unfollow&blog_name=" + blog_name,
success: function (result) {
if (result == "success") {
alert("Successfully unfollowed blog.");
$("a[data-follow-id='" + uuid + "']").css("display", "none");
} else {
alert("Error: Failed to unlike post.");
}
}
});
}
function reblog(blog_name, id, reblog_key) {
$.ajax({
url: "https://example.com/vox-populi/action.php?action=reblog&blog_name=" + blog_name + "&id=" + id + "&reblog_key" + reblog_key,
success: function (result) {
if (result == "success") {
alert("Successfully reblogged post.");
$("a[data-reblog-id='" + post_id + "'] svg").css("fill", "#dc3545");
} else {
alert("Error: Failed to reblog post.");
}
}
});
}
function unreblog(blog_name, id, reblog_key) {
$.ajax({
url: "https://example.com/vox-populi/action.php?action=unreblog&blog_name=" + blog_name + "&id=" + id + "&reblog_key" + reblog_key,
success: function (result) {
if (result == "success") {
alert("Successfully reblogged post.");
$("a[data-unreblog-id='" + post_id + "'] svg").css("fill", "none");
} else {
alert("Error: Failed to reblog post.");
}
}
});
}
function toggleNav() {
// If we're on a small screen (sidebar is hidden on small screens)
if ($(window).width() <= 768) {
// Show the nav button and allow it to open the sidebar
$('#sidebarButton').click(function () {
// If the sidebar is showing...
if ($('.sidebar').width() >= $(document).width()) {
// ... then remove the sidebar
$('.sidebar').width('0%');
$('.sidebar').addClass('d-none');
// ... and increase the size of the main area
$('.main').width('100%');
$('.main').removeClass('d-none');
}
// If the sidebar is hidden...
else {
// ... then add the sidebar
$('.sidebar').width('100%');
$('.sidebar').removeClass('d-none');
// ... and remove the main area
$('.main').width('0%');
$('.main').addClass('d-none');
}
});
// Show the nav button and allow it to open the sidebar
$('.sidebar-box a').click(function () {
// If the sidebar is showing...
if ($('.sidebar').width() >= $(document).width()) {
// ... then remove the sidebar
$('.sidebar').width('0%');
$('.sidebar').addClass('d-none');
// ... and increase the size of the main area
$('.main').width('100%');
$('.main').removeClass('d-none');
}
});
}
}
function toggleSearch() {
// If we're on a small screen, we want to take up the whole nav
if ($(window).width() <= 768) {
$('#search-button').click(function () {
$('#search-button').addClass('d-none');
$('.navbar-brand').addClass('d-none');
$('#search-form').removeClass('d-none');
});
$('#search-close-button').click(function () {
$('#search-button').removeClass('d-none');
$('.navbar-brand').removeClass('d-none');
$('#search-form').addClass('d-none');
});
} else {
$('#search-button').click(function () {
$('#search-button').addClass('d-none');
$('#search-form').removeClass('d-none');
});
$('#search-close-button').click(function () {
$('#search-button').removeClass('d-none');
$('#search-form').addClass('d-none');
});
}
}
$(document).ready(function () {
feather.replace({"height": 16,"width": 16});
$('.btn-to-top').click(function () {$(window).scrollTop(0);});
toggleNav();
toggleSearch();
});
|