{"id":2091,"date":"2025-03-25T21:44:04","date_gmt":"2025-03-25T18:44:04","guid":{"rendered":"https:\/\/energypsy.ru\/?p=2091"},"modified":"2025-03-25T21:44:05","modified_gmt":"2025-03-25T18:44:05","slug":"true-happiness-is-only-for-the-virtuous","status":"publish","type":"post","link":"https:\/\/energypsy.ru\/?p=2091","title":{"rendered":"True happiness is only for the virtuous!"},"content":{"rendered":"\n\t<style>\n\t.wpSimpleSearchInput\n\t{\n\tborder-radius:4px;width:100%;font-size:105%;\t\n\t}\n\t.wpSimpleSearchButton\n\t{\n\tborder-radius:10px;cursor:pointer;\n\tbackground-color:rgb(240, 240, 240);\t\t\n\t}\n\t.wpSimpleSearchButton:hover\n\t{\n\tbackground-color:silver;\n\t\t\n\t}\n\n\t.wpSimpleSearchResultsDiv{\n\tdisplay:none;\t\n\tposition:fixed;\n\ttop:-10vh;\n\tleft:0px;\n\tmargin:0px;\n\twidth:100vw;\n\theight:110vh;\n\tbackground-color:#fafafa;\n\tz-index:1000;\n\ttext-align:center;\n\tmax-height: none;\n\tmax-width: none;\n\t}\n\n\t.wpSimpleSearchResultsBorderDiv\n\t{\n\tmargin-top:11vh;\n\tdisplay:inline-block;\n\tmargin-left:auto;\n\tmargin-right:auto;\n\tborder-radius:4px;\n\n\tborder: 1px solid silver;\n\tbox-shadow: 4px 4px 8px 0px rgba(34, 60, 80, 0.2);\n\tbackground-color:white;\n\tz-index:1100;\n\tpadding:5vmin;\n\n\t}\n\n\n\t.wpSimpleSearchResultsContentDiv{\n\tdisplay:inline-block;\n\t\n\tmax-height:80vh;\n\toverflow-y:scroll;\n\t\n\t}\n\n\t.wpSimpleSearchResultsCloseButton{\n\tborder: 1px solid silver;\n\tbox-shadow: 4px 4px 8px 0px rgba(34, 60, 80, 0.2);\t\n\tfloat:right;\n\tmargin-right:4vw;\n\tcursor:pointer;\t\n\n\t}\n\n\t.wpSimpleSearchResultsCloseButton:hover{\n\tfont-weight:bold;\n\tcolor:maroon;\t\n\t}\n\n\t.wpSimpleSearchResultsItem{\n\twidth:20vw;\n\tdisplay:inline-block;\n\tfloat:left;\t\n\ttext-align:left;\t\n\t}\n\n\t.wpSimpleSearchResultsItemText{\n\tdisplay:inline-block;\n\twidth:100%;\n\tmax-height:40vh;\t\n\toverflow-y:scroll;\t\n\t}\n\n\t.wpSimpleSearchHref{\n\ttext-decoration:none;\n\tcursor:pointer;\t\n\t\t\n\t}\n\n\t.wpSimpleSearchHref:hover{\n\t\t\n\tcolor:darkblue;\t\n\t}\n\t<\/style>\n\t<div class=\"wpSimpleSearchResultsDiv\" id=\"idSimpleSearchResultsDiv\">\n\t<br>\n\n\n\t<div class=\"wpSimpleSearchResultsBorderDiv\">\n\t<button class=\"wpSimpleSearchResultsCloseButton\" onClick=\"hideSimpleSearchResults();\">&#x2718;<\/button>\t\n\t<br>\n\t<div class=\"wpSimpleSearchResultsContentDiv\" id=\"idSimpleSearchResultsContentDiv\">\n\n\n\n\n\t<\/div>\n\n\t<\/div>\n\t<\/div>\n\n\t <div id=\"wpSimpleSearchDiv\" style=\"opacity:1;margin-top:0px;display:inline-block;float:right;width:18vmin; border-radius:4px;border: 1px solid silver;box-shadow: 4px 4px 8px 0px rgba(34, 60, 80, 0.2);\">\n\t<table style=\"width:100%\">\n\t<tr>\n\t<td>\n\t<input type=\"text\" class=\"wpSimpleSearchInput\" id=\"wpSimpleSearchField\">\n\t<\/td>\n\t<td ><span style=\"margin-left:18px;\" class=\"wpSimpleSearchButton\" onClick=\"wpSimpleSearchReq();\" >&#x1f50d;<\/span><\/td>\n\t<\/tr>\n\t<\/table>\n\t<\/div>\n\t<br><br>\n\t<script>\n\t\t\n\tfunction wpSimpleSearchCheckMarks()\n\t{\n\tconst searchParams = new URLSearchParams(window.location.href);\n\n\tif(searchParams.has('mark'))\n\t{\n\t\t\n\tvar mark=searchParams.get('mark')\n\tvar markInstance = new Mark(document.body);\n\n\tvar options={\n\t'diacritics':false,\n\t'separateWordSearch':false,\t\n\t\t\n\t};\n\n\tmarkInstance.mark(mark , options);\t\n\t}\n\t\t\n\t}\n\n\tdocument.addEventListener(\"DOMContentLoaded\", (event) => {\n\t\n\t  wpSimpleSearchCheckMarks();\n\t});\n\n\tfunction hideSimpleSearchResults()\n\t{\n\tvar rDiv=document.getElementById('idSimpleSearchResultsDiv');\n\tif(!rDiv){console.log('cannot find results Div!');return;}\t\n   \n\n\trDiv.style.display='none';\t\n\t\n\t\/\/document.body.style.overflowY='initial';\n\t\t\n\t}\n\n\tfunction markText(toFind,text)\n\t{\n\tvar toFindL=toFind.toLowerCase();\n\tvar textL=text.toLowerCase();\n\n\tvar rv='';\n\n\tvar fa=textL.split(toFindL);\n\n\tif(fa.length<2)return text;\n\n\tvar index=0;\n\n\tfor(var i=0;i<fa.length;i++)\n\t{\n\trv=rv+text.substr(index,fa[i].length);\n\n\tindex+=fa[i].length;\n\n\tif(i<(fa.length-1)){rv=rv+'<mark class=\"wpSimpleSearchMark\">'+text.substr(index,toFind.length)+'<\/mark>';index=index+toFind.length;}\n\n\t\t\n\t}\n\n\n\treturn rv;\t\n\t}\n\n\n\n\tfunction wpSimpleSearchIsOnTheScreen(elem, allowElemBehind = false, allowElemAhead = false) {\n\t\tconst scrollDist = document.documentElement.scrollTop;\n\t\tconst elemOffset = window.scrollY + elem.getBoundingClientRect().top; \n\n\t\tif (!allowElemBehind && !(elemOffset + elem.offsetHeight > scrollDist))\n\t\t\treturn false;\n\t\t\n\t\tif (!allowElemAhead && !(scrollDist + window.innerHeight > elemOffset))\n\t\t\treturn false;\n\n\t\treturn true;\n\t}\n\n\n\tvar wpSimpleSearchItems=[];\n\n\n\tfunction wpSimpleSearchScrollVisibles()\n\t{\n\n\tfor(var i=0;i<wpSimpleSearchItems.length;i++)\t\n\t{\n\tif(wpSimpleSearchItems[i].scrolled==true)continue;\t\n\n\tif(wpSimpleSearchIsOnTheScreen(wpSimpleSearchItems[i].div)){\n\twpSimpleSearchItems[i].mark.scrollIntoView();\n\twpSimpleSearchItems[i].scrolled=true;\t\n\t}\n\t}\t\n\t}\n\n  \n\n\tfunction showSimpleSearchResults(text,res)\n\t{\n\tvar rDiv=document.getElementById('idSimpleSearchResultsDiv');\n\tvar cDiv=document.getElementById('idSimpleSearchResultsContentDiv');\n\n\tif(!rDiv){console.log('cannot find results Div!');return;}\t\n\tif(!cDiv){console.log('cannot find content Div!');return;}\t\n\n\n\/\/document.body.style.overflowY='hidden';\n\n\tvar rStr='<table style=\"width:100%;  border-collapse: separate; border-spacing: 2em;\">';\n\n\n\n\tfor(var i=0;i<res.length;i++)\n\t{\n\n\tvar title=res[i].title;\n\n\tvar cnt=res[i].preview;\n\n\tvar url=res[i].url;\n\n\tif(url.indexOf('?')!=-1){url=url+'&mark='+encodeURIComponent(text);}\n\telse{\n\tvar lc=url.charAt(url.length - 1);\n\tif(lc!='\/'){url=url+'\/';}\t\n\turl=url+'?mark='+encodeURIComponent(text);}\n\n\trStr=rStr+'<tr >'+\n\t'<td style=\"width:100%;border-radius:4px;border: 1px solid silver;box-shadow: 4px 4px 8px 0px rgba(34, 60, 80, 0.2);\">'+\"\\n\"+\n\t'<b><a class=\"wpSimpleSearchHref\" href=\"'+url+'\" target=\"_blank\">'+markText(text,title)+'<\/a><\/b><br><hr \/>'+\"\\n\"+\n\t'<div class=\"wpSimpleSearchResultsItemText\">'+markText(text,cnt)+'<\/div>'+\"\\n\"+\t\n\t'<\/td>'+\"\\n\";\n\n\n\trStr=rStr+'<\/tr>';\t\n\t}\n\n\trStr=rStr+'<\/table>'+\"\\n\";\n\tcDiv.innerHTML=rStr;\n\trDiv.style.display='inline-block';\n\n\tcDiv.scrollTop = 0;\n\n\tvar items=cDiv.querySelectorAll('.wpSimpleSearchResultsItemText');\n\n\twpSimpleSearchItems=[];\n\n\tfor(var i=0;i<items.length;i++)\n\t{\n\tvar marks=items[i].querySelectorAll('.wpSimpleSearchMark');\t\n\tif(marks.length>0)\n\t{\n\tvar cm=marks[0];\n\twpSimpleSearchItems.push({'div':items[i],'mark':cm,'scrolled':false});\t\n\t}\t\n\t}\n\n\t\/\/cDiv.onscroll=function(){wpSimpleSearchScrollVisibles();}\n\n\twpSimpleSearchScrollVisibles();\n\n\n\tcDiv.scrollTop = 0;\n\t}\n\n\n\tvar wpSimpleSearchFieldAnimationTime=25;\t\n\tvar wpSimpleSearchDivMax=36;\n\tvar wpSimpleSearchDivMin=18;\t\n\n\tvar wpSimpleSearchDivGrowing=false;\n\n\tvar wpSimpleSearchField=document.getElementById('wpSimpleSearchField');\t\n\tvar wpSimpleSearchDiv=document.getElementById('wpSimpleSearchDiv');\t\n\tif(wpSimpleSearchField){\n\twpSimpleSearchField.addEventListener(\"keyup\", ({key}) => {\n\t\tif (key === \"Enter\") {\n\t\t wpSimpleSearchReq();\n\t\t}\n\t});\n\n\twpSimpleSearchField.addEventListener(\"focus\", (event) => {\n\t\t\n\twpSimpleSearchDivGrowing=true;\n\trequestAnimationFrame(wpSimpleSearchDivGrow);});\n\n\twpSimpleSearchField.addEventListener(\"blur\", (event) => {\n\twpSimpleSearchDivGrowing=false;\n\trequestAnimationFrame(wpSimpleSearchDivShrink);});\n\t}\n\n\tvar wpSimpleSearchDivFadingIn=false;\n\n\tfunction wpSimpleSearchDivFadeIn()\n\t{\n\tif(wpSimpleSearchDivFadingIn==false)return;\t\n\tif(!wpSimpleSearchDiv)return;\n\tvar co=parseFloat(wpSimpleSearchDiv.style.opacity);\t\n\tif(co>0){co=co-0.1;wpSimpleSearchDiv.style.opacity=co;requestAnimationFrame(wpSimpleSearchDivFadeIn);}\n\telse{wpSimpleSearchDivFadingIn=false;requestAnimationFrame(wpSimpleSearchDivFadeOut);}\n\t}\n\n\tfunction wpSimpleSearchDivFadeOut()\n\t{\n\tif(wpSimpleSearchDivFadingIn==true)return;\t\n\tif(!wpSimpleSearchDiv)return;\n\tvar co=parseFloat(wpSimpleSearchDiv.style.opacity);\t\n\tif(co<1){co=co+0.1;wpSimpleSearchDiv.style.opacity=co;requestAnimationFrame(wpSimpleSearchDivFadeOut);}\n\t\t\n\t}\n\n\n\tfunction wpSimpleSearchDivGrow()\n\t{\n\tif(wpSimpleSearchDivGrowing==false)return;\n\tif(!wpSimpleSearchDiv)return;\n\tvar cs=parseInt(wpSimpleSearchDiv.style.width);\n\tif(cs<wpSimpleSearchDivMax){cs++;wpSimpleSearchDiv.style.width=cs+'vmin';requestAnimationFrame(wpSimpleSearchDivGrow);}\n\n\t}\n\n\n\tfunction wpSimpleSearchDivShrink()\n\t{\n\tif(wpSimpleSearchDivGrowing==true)return;\t\n\tif(!wpSimpleSearchDiv)return;\n\tvar cs=parseInt(wpSimpleSearchDiv.style.width);\n\tif(cs>wpSimpleSearchDivMin){cs--;wpSimpleSearchDiv.style.width=cs+'vmin';requestAnimationFrame(wpSimpleSearchDivShrink);}\n\t\t\n\t}\n\n\tasync function wpSimpleSearchReq()\n\t{\n\tif(!wpSimpleSearchField)return;\n\n\tif(wpSimpleSearchField.value=='')return;\n\n\tvar toSend=encodeURIComponent(wpSimpleSearchField.value);\n\n\tvar tm=new Date().getTime();\n\n\tvar reqStr=\"https:\/\/energypsy.ru\/wp-content\/plugins\/wpSimpleSearch\/search.php\"+'?q='+toSend+'&tm='+tm;\n\n\t  const response = await fetch(reqStr);\n\t  var cnt = {'q':wpSimpleSearchField.value,'r':[]};\n\t  if(response.ok){cnt=await response.json(); \n\t\t  \n\t\t  var results=cnt.r;\n\t\t  var reqTxt=cnt.q;\n\t\t  if(results.length>0)\n\t\t  {\n\t\t  wpSimpleSearchField.blur();\n\t\t  showSimpleSearchResults(reqTxt,results);\t  \n\t\t\t  \n\t\t  }\n\t\t  else{wpSimpleSearchDivFadingIn=true;requestAnimationFrame(wpSimpleSearchDivFadeIn);}\n\t\t  \n\t\t  }\n\t  else{console.log('Search plugin request error!');return;}\n\n\t\t\n\t}\n\n\t<\/script>\n\t","protected":false},"excerpt":{"rendered":"<p>&#x2718; &#x1f50d;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2091","post","type-post","status-publish","format-standard","hentry","category-1"],"_links":{"self":[{"href":"https:\/\/energypsy.ru\/index.php?rest_route=\/wp\/v2\/posts\/2091","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/energypsy.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/energypsy.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/energypsy.ru\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/energypsy.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2091"}],"version-history":[{"count":1,"href":"https:\/\/energypsy.ru\/index.php?rest_route=\/wp\/v2\/posts\/2091\/revisions"}],"predecessor-version":[{"id":2092,"href":"https:\/\/energypsy.ru\/index.php?rest_route=\/wp\/v2\/posts\/2091\/revisions\/2092"}],"wp:attachment":[{"href":"https:\/\/energypsy.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/energypsy.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/energypsy.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}