diff options
author | Frédéric Guillot <fred@miniflux.net> | 2018-01-29 20:46:01 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2018-01-29 20:47:09 -0800 |
commit | c8138351c9737e3286a128c78f39e4f8a23e7bc9 (patch) | |
tree | 3d496f051524a10e1c398f7575d3e8a6e683fae8 /ui | |
parent | 24a2f472ec8593b4734e91ac15ee5503d16ae63a (diff) |
Keep code base tidy
Diffstat (limited to 'ui')
-rw-r--r-- | ui/static/js.go | 14 | ||||
-rw-r--r-- | ui/subscription.go | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/ui/static/js.go b/ui/static/js.go index 7665a2f..45fc161 100644 --- a/ui/static/js.go +++ b/ui/static/js.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2018-01-20 13:23:40.729553481 -0800 PST m=+0.015026127 +// 2018-01-29 20:38:56.472493026 -0800 PST m=+0.027898185 package static @@ -44,10 +44,9 @@ return "";} execute(){fetch(new Request(this.url,this.options)).then((response)=>{if(this.callback){this.callback(response);}});}} 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);});}} -class EntryHandler{static updateEntriesStatus(entryIDs,status,callback){let url=document.body.dataset.entriesStatusUrl;let request=new RequestBuilder(url);request.withBody({entry_ids:entryIDs,status:status});request.withCallback(callback);request.execute();} -static toggleEntryStatus(element){let entryID=parseInt(element.dataset.id,10);let statuses={read:"unread",unread:"read"};for(let currentStatus in statuses){let newStatus=statuses[currentStatus];if(element.classList.contains("item-status-"+currentStatus)){element.classList.remove("item-status-"+currentStatus);element.classList.add("item-status-"+newStatus);this.updateEntriesStatus([entryID],newStatus);if(newStatus==="read"){UnreadCounterHandler.decrement(1);}else{UnreadCounterHandler.increment(1);} -let link=element.querySelector("a[data-toggle-status]");if(link){this.toggleLinkStatus(link);} +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;});}}} +class EntryHandler{static updateEntriesStatus(entryIDs,status,callback){let url=document.body.dataset.entriesStatusUrl;let request=new RequestBuilder(url);request.withBody({entry_ids:entryIDs,status:status});request.withCallback(callback);request.execute();if(status==="read"){UnreadCounterHandler.decrement(1);}else{UnreadCounterHandler.increment(1);}} +static toggleEntryStatus(element){let entryID=parseInt(element.dataset.id,10);let statuses={read:"unread",unread:"read"};for(let currentStatus in statuses){let newStatus=statuses[currentStatus];if(element.classList.contains("item-status-"+currentStatus)){element.classList.remove("item-status-"+currentStatus);element.classList.add("item-status-"+newStatus);this.updateEntriesStatus([entryID],newStatus);let link=element.querySelector("a[data-toggle-status]");if(link){this.toggleLinkStatus(link);} break;}}} static toggleLinkStatus(link){if(link.dataset.value==="read"){link.innerHTML=link.dataset.labelRead;link.dataset.value="unread";}else{link.innerHTML=link.dataset.labelUnread;link.dataset.value="read";}} static toggleBookmark(element){element.innerHTML=element.dataset.labelLoading;let request=new RequestBuilder(element.dataset.bookmarkUrl);request.withCallback(()=>{if(element.dataset.value==="star"){element.innerHTML=element.dataset.labelStar;element.dataset.value="unstar";}else{element.innerHTML=element.dataset.labelUnstar;element.dataset.value="star";}});request.execute();} @@ -74,7 +73,8 @@ let currentItem=document.querySelector(".current-item");if(currentItem!==null){t toggleBookmarkLink(parent){let bookmarkLink=parent.querySelector("a[data-toggle-bookmark]");if(bookmarkLink){EntryHandler.toggleBookmark(bookmarkLink);}} openOriginalLink(){let entryLink=document.querySelector(".entry h1 a");if(entryLink!==null){DomHelper.openNewTab(entryLink.getAttribute("href"));return;} let currentItemOriginalLink=document.querySelector(".current-item a[data-original-link]");if(currentItemOriginalLink!==null){DomHelper.openNewTab(currentItemOriginalLink.getAttribute("href"));let currentItem=document.querySelector(".current-item");this.goToNextListItem();EntryHandler.markEntryAsRead(currentItem);}} -openSelectedItem(){let currentItemLink=document.querySelector(".current-item .item-title a");if(currentItemLink!==null){window.location.href=currentItemLink.getAttribute("href");}} +openSelectedItem(){let currentItemLink=document.querySelector(".current-item .item-title a");if(currentItemLink!==null){let currentItemOriginalLink=document.querySelector(".current-item a[data-original-link]");if(currentItemOriginalLink!==null){let currentItem=document.querySelector(".current-item");EntryHandler.markEntryAsRead(currentItem);} +window.location.href=currentItemLink.getAttribute("href");}} goToPage(page,fallbackSelf){let element=document.querySelector("a[data-page="+page+"]");if(element){document.location.href=element.href;}else if(fallbackSelf){window.location.reload();}} goToPrevious(){if(this.isListView()){this.goToPreviousListItem();}else{this.goToPage("previous");}} goToNext(){if(this.isListView()){this.goToNextListItem();}else{this.goToPage("next");}} @@ -91,5 +91,5 @@ document.addEventListener("DOMContentLoaded",function(){FormHandler.handleSubmit } var JavascriptChecksums = map[string]string{ - "app": "aa432d89d424abf0d19278f72e75ffd98cba203cf3cccb40b80e6d91e7609a17", + "app": "cfeb45231fd784b9eaceefb12ecf7f2543e4c871fb3af3cebf25757446e3eae7", } diff --git a/ui/subscription.go b/ui/subscription.go index ad323ad..a6cb23c 100644 --- a/ui/subscription.go +++ b/ui/subscription.go @@ -69,7 +69,7 @@ func (c *Controller) SubmitSubscription(ctx *handler.Context, request *handler.R return } - logger.Info("[UI:SubmitSubscription] %s", subscriptions) + logger.Debug("[UI:SubmitSubscription] %s", subscriptions) n := len(subscriptions) switch { |