krz/vox-populi
A Tumblr web client.
clone: git clone https://gitbay.org/krz/vox-populi.git
1function like(post_id, reblog_key) {
2 $.ajax({
3 url: "https://example.com/vox-populi/action.php?action=like&post_id=" + post_id + "&reblog_key=" + reblog_key,
4 success: function (result) {
5 if (result == "success") {
6 $("a[data-like-id='" + post_id + "'] svg").css("fill", "#dc3545");
7 } else {
8 alert("Error: Failed to like post.");
9 }
10 }
11 });
12}
13
14function unlike(post_id, reblog_key) {
15 $.ajax({
16 url: "https://example.com/vox-populi/action.php?action=unlike&post_id=" + post_id + "&reblog_key=" + reblog_key,
17 success: function (result) {
18 if (result == "success") {
19 $("a[data-unlike-id='" + post_id + "'] svg").css("fill", "none");
20 } else {
21 alert("Error: Failed to unlike post.");
22 }
23 }
24 });
25}
26
27function follow(blog_name, uuid) {
28 $.ajax({
29 url: "https://example.com/vox-populi/action.php?action=follow&blog_name=" + blog_name,
30 success: function (result) {
31 if (result == "success") {
32 $("a[data-follow-id='" + uuid + "']").css("display", "none");
33 } else {
34 alert("Error: Failed to like post.");
35 }
36 }
37 });
38}
39
40function unfollow(blog_name, uuid) {
41 $.ajax({
42 url: "https://example.com/vox-populi/action.php?action=unfollow&blog_name=" + blog_name,
43 success: function (result) {
44 if (result == "success") {
45 alert("Successfully unfollowed blog.");
46 $("a[data-follow-id='" + uuid + "']").css("display", "none");
47 } else {
48 alert("Error: Failed to unlike post.");
49 }
50 }
51 });
52}
53
54function reblog(blog_name, id, reblog_key) {
55 $.ajax({
56 url: "https://example.com/vox-populi/action.php?action=reblog&blog_name=" + blog_name + "&id=" + id + "&reblog_key" + reblog_key,
57 success: function (result) {
58 if (result == "success") {
59 alert("Successfully reblogged post.");
60 $("a[data-reblog-id='" + post_id + "'] svg").css("fill", "#dc3545");
61 } else {
62 alert("Error: Failed to reblog post.");
63 }
64 }
65 });
66}
67
68function unreblog(blog_name, id, reblog_key) {
69 $.ajax({
70 url: "https://example.com/vox-populi/action.php?action=unreblog&blog_name=" + blog_name + "&id=" + id + "&reblog_key" + reblog_key,
71 success: function (result) {
72 if (result == "success") {
73 alert("Successfully reblogged post.");
74 $("a[data-unreblog-id='" + post_id + "'] svg").css("fill", "none");
75 } else {
76 alert("Error: Failed to reblog post.");
77 }
78 }
79 });
80}
81
82function toggleNav() {
83 // If we're on a small screen (sidebar is hidden on small screens)
84 if ($(window).width() <= 768) {
85 // Show the nav button and allow it to open the sidebar
86 $('#sidebarButton').click(function () {
87 // If the sidebar is showing...
88 if ($('.sidebar').width() >= $(document).width()) {
89 // ... then remove the sidebar
90 $('.sidebar').width('0%');
91 $('.sidebar').addClass('d-none');
92 // ... and increase the size of the main area
93 $('.main').width('100%');
94 $('.main').removeClass('d-none');
95 }
96 // If the sidebar is hidden...
97 else {
98 // ... then add the sidebar
99 $('.sidebar').width('100%');
100 $('.sidebar').removeClass('d-none');
101 // ... and remove the main area
102 $('.main').width('0%');
103 $('.main').addClass('d-none');
104 }
105 });
106
107 // Show the nav button and allow it to open the sidebar
108 $('.sidebar-box a').click(function () {
109 // If the sidebar is showing...
110 if ($('.sidebar').width() >= $(document).width()) {
111 // ... then remove the sidebar
112 $('.sidebar').width('0%');
113 $('.sidebar').addClass('d-none');
114 // ... and increase the size of the main area
115 $('.main').width('100%');
116 $('.main').removeClass('d-none');
117 }
118 });
119 }
120}
121
122function toggleSearch() {
123 // If we're on a small screen, we want to take up the whole nav
124 if ($(window).width() <= 768) {
125 $('#search-button').click(function () {
126 $('#search-button').addClass('d-none');
127 $('.navbar-brand').addClass('d-none');
128 $('#search-form').removeClass('d-none');
129 });
130 $('#search-close-button').click(function () {
131 $('#search-button').removeClass('d-none');
132 $('.navbar-brand').removeClass('d-none');
133 $('#search-form').addClass('d-none');
134 });
135 } else {
136 $('#search-button').click(function () {
137 $('#search-button').addClass('d-none');
138 $('#search-form').removeClass('d-none');
139 });
140 $('#search-close-button').click(function () {
141 $('#search-button').removeClass('d-none');
142 $('#search-form').addClass('d-none');
143 });
144 }
145}
146
147$(document).ready(function () {
148 feather.replace({"height": 16,"width": 16});
149
150 $('.btn-to-top').click(function () {$(window).scrollTop(0);});
151
152 toggleNav();
153 toggleSearch();
154});