From cc0acabfe09abb3652f6b45f4e9e701bed4c894d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Wed, 27 Dec 2017 19:45:59 -0800 Subject: [PATCH] Avoid Javascript error if unable to download full contents --- server/static/js.go | 6 +++--- server/static/js/app.js | 4 +++- server/template/html/edit_feed.html | 6 +++--- server/template/views.go | 10 +++++----- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/server/static/js.go b/server/static/js.go index 61cb18e7..70ddcac2 100644 --- a/server/static/js.go +++ b/server/static/js.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-12-22 11:25:01.967857672 -0800 PST m=+0.032825434 +// 2017-12-27 19:43:16.081100938 -0800 PST m=+0.024187957 package static @@ -48,7 +48,7 @@ static markEntryAsRead(element){if(element.classList.contains("item-status-unrea static saveEntry(element){if(element.dataset.completed){return;} element.innerHTML=element.dataset.labelLoading;let request=new RequestBuilder(element.dataset.saveUrl);request.withCallback(()=>{element.innerHTML=element.dataset.labelDone;element.dataset.completed=true;});request.execute();} static fetchOriginalContent(element){if(element.dataset.completed){return;} -element.innerHTML=element.dataset.labelLoading;let request=new RequestBuilder(element.dataset.fetchContentUrl);request.withCallback((response)=>{element.innerHTML=element.dataset.labelDone;element.dataset.completed=true;response.json().then((data)=>{document.querySelector(".entry-content").innerHTML=data.content;});});request.execute();}} +element.innerHTML=element.dataset.labelLoading;let request=new RequestBuilder(element.dataset.fetchContentUrl);request.withCallback((response)=>{element.innerHTML=element.dataset.labelDone;element.dataset.completed=true;response.json().then((data)=>{if(data.hasOwnProperty("content")){document.querySelector(".entry-content").innerHTML=data.content;}});});request.execute();}} class ConfirmHandler{remove(url){let request=new RequestBuilder(url);request.withCallback(()=>window.location.reload());request.execute();} handle(event){let questionElement=document.createElement("span");let linkElement=event.target;let containerElement=linkElement.parentNode;linkElement.style.display="none";let yesElement=document.createElement("a");yesElement.href="#";yesElement.appendChild(document.createTextNode(linkElement.dataset.labelYes));yesElement.onclick=(event)=>{event.preventDefault();let loadingElement=document.createElement("span");loadingElement.className="loading";loadingElement.appendChild(document.createTextNode(linkElement.dataset.labelLoading));questionElement.remove();containerElement.appendChild(loadingElement);this.remove(linkElement.dataset.url);};let noElement=document.createElement("a");noElement.href="#";noElement.appendChild(document.createTextNode(linkElement.dataset.labelNo));noElement.onclick=(event)=>{event.preventDefault();linkElement.style.display="inline";questionElement.remove();};questionElement.className="confirm";questionElement.appendChild(document.createTextNode(linkElement.dataset.labelQuestion+" "));questionElement.appendChild(yesElement);questionElement.appendChild(document.createTextNode(", "));questionElement.appendChild(noElement);containerElement.appendChild(questionElement);}} class MenuHandler{clickMenuListItem(event){let element=event.target;if(element.tagName==="A"){window.location.href=element.getAttribute("href");}else{window.location.href=element.querySelector("a").getAttribute("href");}} @@ -79,5 +79,5 @@ document.addEventListener("DOMContentLoaded",function(){FormHandler.handleSubmit } var JavascriptChecksums = map[string]string{ - "app": "835ca386dadfc0a7fc3aa6000419051bb8f99f23653c875423f79ff037dcd2da", + "app": "3cb20aac0a3738f1ddc0b5a21ef5537f2ec0526a50047c8c678ed7a0f9016b88", } diff --git a/server/static/js/app.js b/server/static/js/app.js index a28e510f..3d366e45 100644 --- a/server/static/js/app.js +++ b/server/static/js/app.js @@ -354,7 +354,9 @@ class EntryHandler { element.dataset.completed = true; response.json().then((data) => { - document.querySelector(".entry-content").innerHTML = data.content; + if (data.hasOwnProperty("content")) { + document.querySelector(".entry-content").innerHTML = data.content; + } }); }); request.execute(); diff --git a/server/template/html/edit_feed.html b/server/template/html/edit_feed.html index 7a5822e8..0446653e 100644 --- a/server/template/html/edit_feed.html +++ b/server/template/html/edit_feed.html @@ -67,9 +67,9 @@
{{ end }} diff --git a/server/template/views.go b/server/template/views.go index 98c2084f..0d454bee 100644 --- a/server/template/views.go +++ b/server/template/views.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-12-26 20:56:49.130032651 -0800 PST m=+0.032678907 +// 2017-12-27 19:43:16.083344083 -0800 PST m=+0.026431102 package template @@ -432,9 +432,9 @@ var templateViewsMap = map[string]string{
{{ end }} @@ -1339,7 +1339,7 @@ var templateViewsMapChecksums = map[string]string{ "create_category": "2b82af5d2dcd67898dc5daa57a6461e6ff8121a6089b2a2a1be909f35e4a2275", "create_user": "45e226df757126d5fe7c464e295e9a34f07952cfdb71e31e49839850d35af139", "edit_category": "cee720faadcec58289b707ad30af623d2ee66c1ce23a732965463250d7ff41c5", - "edit_feed": "7faf55bc4070b5238f3a41dfcddc19650d8201deb1001a93b1b843a2674fac32", + "edit_feed": "05bc3dc7316bd3b0ef4d8fa23ab585a990fded98ed433ee57b878fb1c7b5a4c0", "edit_user": "82d9749d76ddbd2352816d813c4b1f6d92f2222de678b4afe5821090246735c7", "entry": "6b4405e0c8e4a7d31874659f8835f4e43e01dc3c20686091517ac750196dd70f", "feed_entries": "ac93cb9a90f93ddd9dd8a67d7e160592ecb9f5e465ee9679bb14eecd8d4caf20",