From 9be83f7fb52d3c71169111202c843f2b2bb92930 Mon Sep 17 00:00:00 2001 From: Akhil Gupta Date: Fri, 30 Oct 2020 17:41:36 +0530 Subject: [PATCH] added code for read more --- client/episodes.html | 5 +++-- client/index.html | 2 +- client/scripts.html | 46 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/client/episodes.html b/client/episodes.html index edad503..f5850ab 100644 --- a/client/episodes.html +++ b/client/episodes.html @@ -38,7 +38,8 @@ hr{ - {{template "navbar" .}} +
+ {{template "navbar" .}}
{{$setting := .setting}} {{range .podcastItems}} @@ -62,7 +63,7 @@ hr{
-

{{ .Summary }}

+

{{ .Summary }}

{{if .DownloadPath}} Download Delete diff --git a/client/index.html b/client/index.html index 63dcb0a..7595a7a 100644 --- a/client/index.html +++ b/client/index.html @@ -44,7 +44,7 @@

{{.Title}}

-

{{ .Summary }}

+

{{ .Summary }}

diff --git a/client/scripts.html b/client/scripts.html index 6ca2b43..45c064c 100644 --- a/client/scripts.html +++ b/client/scripts.html @@ -10,5 +10,51 @@ image.src = "/webassets/blank.png"; return true; } + const limit = 300; + let elements = document.getElementsByClassName("useMore"); + + for (let index = 0; index < elements.length; index++) { + const element = elements[index]; + let display= element.style.display; + let originalText= element.textContent; + if(originalText.length<=limit){ + continue; + } + let newText= originalText.substr(0,limit); + + let newElement = document.createElement(element.tagName); + newElement.textContent=newText; + + + newElement.classList.add("short-version") + element.classList.add("long-version") + + let more =document.createElement("a"); + more.textContent= " show more"; + more.style.cursor="pointer" + more.onclick= function(){ + element.style.display=display; + newElement.style.display="none"; + } + + let less =document.createElement("a"); + less.textContent= " show less"; + less.style.cursor="pointer" + less.onclick= function(){ + element.style.display="none"; + newElement.style.display=display; + } + + + newElement.appendChild(more) + element.appendChild(less) + + element.parentNode.insertBefore(newElement, element.nextSibling) + element.style.display="none"; + } + + + + {{end}} \ No newline at end of file