aboutsummaryrefslogtreecommitdiffhomepage
path: root/ui/static/js/unread_counter_handler.js
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2019-07-17 20:27:39 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net>2019-07-17 20:34:11 -0700
commit2b6e17c1ef7f54f822e37991eaf7a309013182e2 (patch)
tree0c59d78c5a60fe6cae0c6c07935fe51074e216a5 /ui/static/js/unread_counter_handler.js
parent34421dcd496198db82ca7c7fd54362d9b600fbb3 (diff)
Refactoring of Javascript code
Diffstat (limited to 'ui/static/js/unread_counter_handler.js')
-rw-r--r--ui/static/js/unread_counter_handler.js33
1 files changed, 0 insertions, 33 deletions
diff --git a/ui/static/js/unread_counter_handler.js b/ui/static/js/unread_counter_handler.js
deleted file mode 100644
index 87a1aaa..0000000
--- a/ui/static/js/unread_counter_handler.js
+++ /dev/null
@@ -1,33 +0,0 @@
-class UnreadCounterHandler {
- static decrement(n) {
- this.updateValue((current) => {
- return current - n;
- });
- }
-
- static increment(n) {
- this.updateValue((current) => {
- return current + n;
- });
- }
-
- static updateValue(callback) {
- let counterElements = document.querySelectorAll("span.unread-counter");
- counterElements.forEach((element) => {
- let oldValue = parseInt(element.textContent, 10);
- element.innerHTML = callback(oldValue);
- });
-
- if (window.location.href.endsWith('/unread')) {
- let oldValue = parseInt(document.title.split('(')[1], 10);
- let newValue = callback(oldValue);
-
- document.title = document.title.replace(
- /(.*?)\(\d+\)(.*?)/,
- function (match, prefix, suffix, offset, string) {
- return prefix + '(' + newValue + ')' + suffix;
- }
- );
- }
- }
-}