Postgres 12.1 uses Index Only Scan Backward instead of index when LIMIT is present

I have a medium sized table (~4M rows) of “functionCalls” which consists of 2 columns, input and function (both ids for another table):

  Column  |  Type   | Collation | Nullable | Default  ----------+---------+-----------+----------+---------  input    | integer |           | not null |   function | integer |           | not null |  Indexes:     "functionCall_pkey" PRIMARY KEY, btree (input, function) CLUSTER     "functionCallSearch" btree (function, input) Foreign-key constraints:     "fkey1" FOREIGN KEY (function) REFERENCES function(id) ON UPDATE CASCADE ON DELETE CASCADE     "fkey2" FOREIGN KEY (input) REFERENCES input(id)  

I want to find all rows that match a certain function, which is why I added the functionCallSearch index. Here is my query:

SELECT c.input FROM "functionCall" c INNER JOIN "function" ON (function.id = c.function) WHERE function.text LIKE 'getmyinode' ORDER BY c.input DESC LIMIT 25 OFFSET 0; 

This takes forever (currently ~ 20s) because pg refuses to use the index, and decides to do a Index Only Scan Backward on the primary key instead:

 Limit  (cost=0.71..2178.97 rows=25 width=4) (actual time=12903.294..19142.568 rows=8 loops=1)    Output: c.input    Buffers: shared hit=59914 read=26193 written=54    ->  Nested Loop  (cost=0.71..135662.48 rows=1557 width=4) (actual time=12903.292..19142.561 rows=8 loops=1)          Output: c.input          Inner Unique: true          Join Filter: (c.function = function.id)          Rows Removed by Join Filter: 3649900          Buffers: shared hit=59914 read=26193 written=54          ->  Index Only Scan Backward using "functionCall_pkey" on public."functionCall" c  (cost=0.43..80906.80 rows=3650225 width=8) (actual time=0.040..17083.489 rows=3649908 loops=1)                Output: c.input, c.function                Heap Fetches: 3649909                Buffers: shared hit=59911 read=26193 written=54          ->  Materialize  (cost=0.28..2.30 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=3649908)                Output: function.id                Buffers: shared hit=3                ->  Index Scan using function_text on public.function  (cost=0.28..2.30 rows=1 width=4) (actual time=0.023..0.026 rows=1 loops=1)                      Output: function.id                      Index Cond: ((function.text)::text = 'getmyinode'::text)                      Buffers: shared hit=3  Planning Time: 0.392 ms  Execution Time: 19143.967 ms 

When I remove the LIMIT this query is blazingly fast:

 Sort  (cost=5247.53..5251.42 rows=1557 width=4) (actual time=3.762..3.763 rows=8 loops=1)    Output: c.input    Sort Key: c.input DESC    Sort Method: quicksort  Memory: 25kB    Buffers: shared hit=6 read=4    ->  Nested Loop  (cost=0.71..5164.97 rows=1557 width=4) (actual time=0.099..3.739 rows=8 loops=1)          Output: c.input          Buffers: shared hit=6 read=4          ->  Index Scan using function_text on public.function  (cost=0.28..2.30 rows=1 width=4) (actual time=0.054..0.056 rows=1 loops=1)                Output: function.id                Index Cond: ((function.text)::text = 'getmyinode'::text)                Buffers: shared hit=2 read=1          ->  Index Only Scan using "functionCallSearch" on public."functionCall" c  (cost=0.43..5103.71 rows=5897 width=8) (actual time=0.039..3.670 rows=8 loops=1)                Output: c.function, c.input                Index Cond: (c.function = function.id)                Heap Fetches: 8                Buffers: shared hit=4 read=3  Planning Time: 0.514 ms  Execution Time: 3.819 ms 

Why is this? And how can I fix this?

I’ve checked https://dba.stackexchange.com/a/249676/106982 but n_distinct is not that far off, pg_stats says n_distinct: 623 while SELECT COUNT(*) FROM (SELECT DISTINCT function FROM "functionCall") returns 1065

When an artificer uses its action to create two Cannons, how can it easily expend a spell slot between the creation of the first and second cannon?

While writing an answer for this question I came across a problem with how the Eldritch Cannon and the Fortified Position features interract.

Eldritch Cannon states:

Once you create a cannon, you can’t do so again until you finish a long rest or until you expend a spell slot of 1st level or higher.

Fortified Position states:

You can now have two cannons at the same time. You can create two with the same action (but not the same spell slot), and you can activate both of them with the same bonus action.

I use an action to create two cannons:

  • Cannon#1 is not a problem. It’s either the first cannon I’m creating since I took a long rest, or I expended a 1st level spell slot some time prior to the current action.
  • Cannon#2 is a problem. I have not taken a long rest, nor have I expended a 1st level spell slot since creating cannon#1.

The Eldritch Cannon feature doesn’t provide me with a way to expend a spellslot, but it prevents me from creating a second cannon before I expend a spellslot.

The Artificer has no means to expend a spell slot other than to cast spells. So I need to somehow cast a spell in the middle of my action.

My understanding is that I cannot generally break up my action with a bonus action, so I cannot expend a spell slot by casting a bonus action spell between the creation of two cannons.

A reaction can interrupt an action so it could occur between the creation of two cannons, but getting the opportunity to cast a reaction spell at the right time seems excessivily unlikely and difficult.

Therefore my question is:

When an artificer uses its action to create two Cannons, how can it easily expend a spell slot between the creation of the first and second cannon?

When a mystic theurge uses combined spells, whats the spell level?

I asked a related question but different here.

In the following scenario, how does a mystic theurge combine spells ability work. Cleric 3 / wizard 3 / MT 3. They use a second level wizard slot to cast a first level cleric spell. Lets assume that the character has wisdom 18 for +4 and int 20 for +5.

  • Which attribute is used in calculating the save DC, the clerics +4 due to cleric spell, or wizards +5 due to wizard spell slot?
  • What is the DC per the level of spell? Since its Cleric 1 is it +1 or slot 2 for +2?

The end DC can be 15, 15, 16, or 17 depending on how the abilities work.

grub-mkconfig uses linux instead of linuxefi

I have a dual boot Windows 10 + Ubuntu 18.04, I wanted to install Centos 7 which I did. That broke my Ubuntu boot!

  • I deleted Centos 7 (partitions), deleted /boot/efi/EFI/ubuntu folder
  • Ran grub-mkconfig -O /boot/grub/grub.cfg
  • It keeps generating using linux, initrd instead of linuxefi, initrdefi.

Why?

FYI, my secure boot is disabled in the bios.

I’d like to just delete the whole /boot/efi partition and reinstall grub and the config. Is that possible? How about windows 10’s boot? I wish grub’s information was much cleaner, it’s so confusing.

Would it be unbalanced to increase a druid’s number of uses of Wild Shape based on level?

Wild Shape is the prominent feature of the Druid class, but it allows only two uses until level 20, when Archdruid makes it limitless. This scaling feels quite odd to me and it appears to impact Moon Druids the most, since they rely on it for their combat prowess, while Land Druids have their superior spellcasting abilities. I’m aware that it can be maintained for an amount of hours equal to half the druid’s level and that the two uses are regained after a short or long rest, but the scaling of 2 uses between levels 1-19, then infinite at 20 feels weird and underwhelming, especially between levels 8 (when the feature gets the last power-up) and 20.

Is my concern sound? As a DM, I thought about increasing the uses by 1 at level 12 and 16 (total of 4). Would this make the Druid overpowered, outshining his party members (a Bard, a Barbarian and a Paladin) too much, either in fight or in utility contexts?

Note: the environment is pure core books.

I was given a XML web part that uses SharePoint Services. I need to convert it into an ajax/JSON webpart

I was given an old webpart using SP services and XML. I was requested to use Ajax. This is the first time I do this kind of conversion and I am not sure if I am doing it correctly.

<?xml version="1.0" encoding="utf-8"?> <WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">   <Title>LeftNav MultiTopic Accordion Webpart</Title>   <FrameType>None</FrameType>   <Description>TLeftNav MultiTopic Accordion Webpart</Description>   <IsIncluded>true</IsIncluded>   <ZoneID>wpz</ZoneID>   <PartOrder>0</PartOrder>   <FrameState>Normal</FrameState>   <Height />   <Width />   <AllowRemove>true</AllowRemove>   <AllowZoneChange>true</AllowZoneChange>   <AllowMinimize>true</AllowMinimize>   <AllowConnect>true</AllowConnect>   <AllowEdit>true</AllowEdit>   <AllowHide>true</AllowHide>   <IsVisible>true</IsVisible>   <DetailLink />   <HelpLink />   <HelpMode>Modeless</HelpMode>   <Dir>Default</Dir>   <PartImageSmall />   <MissingAssembly>Cannot import this Web Part.</MissingAssembly>   <PartImageLarge>/_layouts/images/mssfwp.gif</PartImageLarge>   <IsIncludedFilter />   <Assembly>Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>   <TypeName>Microsoft.SharePoint.WebPartPages.SimpleFormWebPart</TypeName>   <Content xmlns="http://schemas.microsoft.com/WebPart/v2/SimpleForm"><![CDATA[<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml" xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"> <head> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap4.min.css"/>     <script type="text/javascript" src="/Style%20Library/V6/js/vendor/mdb/jquery-3.2.1.min.js"></script> <style type="text/css">         #topicNav select{             display: none!important;         }          @media (max-width: 767px) {             #topicNav{                 text-align:center;             }             #topicNav ul {                 display: none;             }             #topicNav select {                 display: inline-block!important;             }         }          #accordionEx .accordion .card{     border-bottom: 1px #81D4FA solid !important; } #accordionColumn span{     ;     float:right;     margin-bottom:2.5rem;  } #accordionColumn span:after{     content: "\f067";     font-family: FontAwesome;     ;     right: 0;     top: 0;     left:100%;     color:black;     display: block;     width: 32px;     height: 32px;     line-height: 32px;     background:#4FC3F7;     border-radius:50%;     vertical-align: middle;     text-align: center;     -webkit-transition: all .35s;     -o-transition: all .35s;     transition: all .35s; }  #accordionColumn span.down:after {     -ms-transform: rotate(135deg);     -moz-transform: rotate(135deg);     -webkit-transform: rotate(135deg);     transform: rotate(135deg);  }     </style> </head> <body> <form id="form1" runat="server">     <section aria-label="Main Page Content" id="td">         <div class="container py-3">         <div class="row justify-content-center justify-content-md-end my-2">                 <div class="col-md-4 col-10 pr-1">                     <div class="z-depth-1 bg-white pr-3" style="border-radius:4px;">                         <input class="form-control pl-3" id="tdSearch" style="border-radius:4px;" type="text" placeholder="Search" aria-label="Search" data-search/>                     </div>                 </div>                 <div class="col-md-1 col-2 d-flex px-0 justify-content-md-end justify-content-start">                     <button class="btn btn-sm px-4 d-flex justify-content-center" style="background-color:#039BE5; margin-top:4px; margin-bottom:16px" type="button" data-search-button><i class="fal fa-search" style="font-size:24px"></i></button>                 </div>             </div>             <div class="row justify-content-between">                 <div class="col-md-3 col-12 pr-md-4">                     <h4 class="pb-md-3 font-weight-bold text-center text-md-left">CATEGORY</h4>                     <div id="topicNav" class="pb-md-3 py-md-0">                         <ul class="px-0" id="topicOptions" style="list-style-type:none; border-left:solid medium #eaeaea;">                             <!--Options injected here-->                         </ul>                     </div>                 </div>                 <div class="col-md-9 col-12 pt-3 pt-md-0 px-3 px-md-0">                     <h2 id="tdTopicTitle" class="pb-3 font-weight-bold text-center text-md-left text-uppercase">Airlines</h2>                 <!-- Grid row -->                     <div class="row d-flex justify-content-center">                          <!-- Grid column -->                         <div class="col-md-12 pb-5 mr-1" id="accordionColumn">                          </div>                         <!-- Grid column -->                      </div>                     <!-- Grid row -->                 </div>             </div>             </div>     </section>   </form> <script type="text/javascript" src="/Style%20Library/V6/js/vendor/mdb/jquery-3.2.1.min.js"></script> <script type="text/javascript"> //Webpart Scripts  var accID = 'AIRLINES'; var searchVal = ''; $  (document).ready(function () {      tdResults = $  ().SPServices.SPGetListItemsJson({         webURL: "/airport/business",         listName: "TenantDirectory",         viewName: "",         CAMLQuery: "",         CAMLViewFields: "",         CAMLRowLimit: "",         CAMLQueryOptions: "",         changeToken: "",         contains: "",         mapping: {             ows_Title: {                 mappedName: "Title",                 objectType: "Text"             },             ows_Address: {                 mappedName: "Address",                 objectType: "Text"             },             ows_Numbers: {                 mappedName: "Numbers",                 objectType: "Text"             },             ows_Categories: {                 mappedName: "Categories",                 objectType: "Text"             },             ows_link: {                 mappedName: "Link",                 objectType: "Text"             },             ows_ID: {                 mappedName: "ID",                 objectType: "Text"             },          },         mappingOverrides: null,         debug: false     });      $  .when(tdResults).done(function () {         var thistdResults = this.data;         function onlyUnique(value, index, self) {             return self.indexOf(value) === index;         }         var tdItems = $  .each(thistdResults, function (ind, tdItems) {             return tdItems;         });          var allTopics = [];         for (i = 0; i < tdItems.length; i++) {             var filterTopics = tdItems[i];             allTopics.push(filterTopics.Categories);         };         allTopics.sort();          var topicList = allTopics.filter(onlyUnique);         for (i = 0; i < topicList.length; i++) {             var topicName = topicList[i]             $  ('#topicOptions').append('<li class="py-1 pl-3"><a href="#" class="text-dark">' + topicName + '</a></li>');         }         var effectIn = function () {             $  ('#tdTopicTitle').html(accID).fadeTo(500, 1);             return $  ("#accordionColumn").fadeTo(500, 1);         };          var effectOut = function () {             $  ('#tdTopicTitle').fadeTo(500, 0);             return $  ("#accordionColumn").fadeTo(500, 0);         };         //includes Polyfill         if (!String.prototype.includes) {           Object.defineProperty(String.prototype, 'includes', {             value: function(search, start) {               if (typeof start !== 'number') {                 start = 0               }                if (start + search.length > this.length) {                 return false               } else {                 return this.indexOf(search, start) !== -1               }             }           })         }         function createAccordion() {             var tdItems = $  .each(thistdResults, function (ind, tdItems) {                 return tdItems;             });             if (accID != 'Search Results'){                 var filterTopic = tdItems.filter(function (e) {                     return e.Categories.toUpperCase() == accID;                 });             }else{                 var filterTopic = tdItems.filter(function (e) {                     var questions = e.Title.toLowerCase();                     return questions.includes(searchVal);                 });             }             var buildAcc = function () {                 var accID2 = accID.replace(/\s/g, '');                 var accBuild = '<div class="accordion" id="' + accID2 + '" role="tablist" aria-multiselectable="true""></div>'                 $  ("#accordionColumn").append(accBuild);             };             buildAcc();             var buildCards = function () {                 if(filterTopic.length !== 0){                     for (i = 0; i < filterTopic.length; i++) {                         var accID2 = accID.replace(/\s/g, '');                         var tdItems = filterTopic[i];                         var headerID = "heading" + tdItems.ID;                         var cardBodyID = "collapse" + tdItems.ID;                         var cardTitle = tdItems.Title;                         if (tdItems.Address){                             var cardAdd = '<p><strong>Address:</strong> ' + tdItems.Address + '</p>'                         }else{                             var cardAdd = ''                         }                         if(tdItems.Numbers){                             var cardNumbers = '<p><strong>Numbers:</strong><br/> ' + tdItems.Numbers + '</p>'                                            }else{                             var cardNumbers = ''                         }                         if (tdItems.Link){                             var cardWebsite = tdItems.Link.slice(0, -1);                             var website = '<p><strong>Website:</strong> <a href="'+ cardWebsite +'" target="_blank">'+ cardWebsite +'</a></p>'                          }else{                             var website = ''                         }                            var cardBuild = '<div class="card">' +                             '<div class="card-header pb-1 pl-0" role="tab" id="' + headerID + '">' +                             '<a class="collapsed" data-toggle="collapse" data-parent="#' + accID2 + '" href="#' + cardBodyID + '" aria-expanded="false" aria-controls="' + cardBodyID + '">' +                             '<h5 class="mb-0 font-thin">' + cardTitle + '<span class="rotate"></span></h5>' +                             '</a>' +                             '</div>' +                             '<div id="' + cardBodyID + '" class="collapse" role="tabpanel" aria-labelledby="' + headerID + '" data-parent="#' + accID + '">' +                              '<div class="card-body py-1 pl-0">' + cardAdd + cardNumbers + website + '</div>'+                             '</div>' +                             '</div>'                         $  (".accordion").append(cardBuild);                     };                     }else{                         var cardBuild = '<h4>There are no results matching your search.</div>'                         $  (".accordion").append(cardBuild);                     }                         //Accordion Icon Animation                     $  ('.accordion > div > div > a').on('click', function () {                         $  (this).find(".rotate").addClass("down");                     });                     $  ('.accordion > div > div > a').on('click', function () {                         $  (this).find(".rotate").addClass("down");                     });                 };             buildCards();          };         createAccordion();         $  ("#topicOptions > li:first-child > a").parent().css({             borderLeft: "solid medium #039BE5",             marginLeft: "-3px"         });          $  ("#topicOptions > li > a").on("click", function () {             event.returnValue = false;             accID = this.innerHTML.toUpperCase();             $  ("[data-search]")[0].value = '';             $  ("#topicOptions > li").css({                 borderLeft: "none",                 marginLeft: "0px"             });             $  (this).parent().css({                 borderLeft: "solid medium #039BE5",                 marginLeft: "-3px"             });             $  .when(effectOut()).done(function () {                 $  (".accordion").remove();                 createAccordion();                 effectIn();             });         });          function topicNav() {             // Create the dropdown base             $  ("<select style=\"border:none; height:50px;\" class=\"browser-default custom-select w-100 z-depth-1\" />").appendTo("#topicNav");             // Create default option "Go to..."             $  ("<option />", {                 "selected": "",                 "value": "Choose a Topic",                 "text": "Choose a Topic"             }).appendTo("#topicNav select");              // Populate dropdown with menu items             $  ("#topicNav > ul > li > a").each(function () {                 var topicsSelect = $  (this);                 $  ("<option />", {                     "value": topicsSelect.text(),                     "text": topicsSelect.text()                 }).appendTo("#topicNav select");             });              // To make dropdown actually work             // To make more unobtrusive: https://css-tricks.com/4064-unobtrusive-page-changer/             $  ("#topicNav select").change(function () {                 accID = $  (this).find("option:selected").val()                 $  .when(effectOut()).done(function () {                     $  (".accordion").remove();                     createAccordion();                     effectIn();                 });             });           };         topicNav();          //Search Function         $  ('[data-search]').keypress(function(event) {             if (event.which == 13){             event.preventDefault();             event.returnValue = false;             accID = 'Search Results';              searchVal = $  (this).val().toLowerCase();                 $  .when(effectOut()).done(function () {                     $  ("#topicOptions > li").css({                         borderLeft: "none",                         marginLeft: "0px"                     });                      $  (".accordion").remove();                     createAccordion();                     effectIn();                 });             }         });         $  ('[data-search-button]').on('click', function(event) {             event.preventDefault();             event.returnValue = false;             accID = 'Search Results';              $  ("#topicOptions > li").css({                 borderLeft: "none",                 marginLeft: "0px"             });              searchVal = $  ('#tdSearch').val().toLowerCase();                 $  .when(effectOut()).done(function () {                     $  ("#topicOptions > li").css({                         borderLeft: "none",                         marginLeft: "0px"                     });                      $  (".accordion").remove();                     createAccordion();                     effectIn();                 });         });     }); });     webpartMove = $  ("#td")     webpartMove.detach();     webpartMove.appendTo("#fullPageContent");     $  ("#fullPageContent > div > div.row.pt-3.mb-r").removeClass('mb-r pt-3');  </script> </body> </html>]]></Content> </WebPart> 

This is what I have done so far.

var accID = 'AIRLINES'; var searchVal = '';  var tdResults = $  .ajax({     url: apiUrl1,     method: 'GET',     headers: {         'Accept': 'application/json; odata=verbose'     },     success: function (data) {          var items = data.d.results;          for (var i = 0; i < items.length; i++) {              var title = items[i].Title;             var address = items[i].Address;             var number = items[i].Numbers;             var categories = items[i].Categories;             var id = items[i].ID;             var link = items[i].Link;          } // this ends for loop          /*mappingOverrides: null,         debug: false*/      }, // this ends success function      error: function(data) {         console.log('Error: ' + data);     } }); //end of ajax      $  .when(tdResults).done(function () {         var thistdResults = this.data;         function onlyUnique(value, index, self) {             return self.indexOf(value) === index;         }         var tdItems = $  .each(thistdResults, function (ind, tdItems) {             return tdItems;         });          var allTopics = [];         for (i = 0; i < tdItems.length; i++) {             var filterTopics = tdItems[i];             allTopics.push(filterTopics.Categories);         };         allTopics.sort();          var topicList = allTopics.filter(onlyUnique);         for (i = 0; i < topicList.length; i++) {             var topicName = topicList[i]             $  ('#topicOptions').append('<li class="py-1 pl-3"><a href="#" class="text-dark">' + topicName + '</a></li>');         }         var effectIn = function () {             $  ('#tdTopicTitle').html(accID).fadeTo(500, 1);             return $  ("#accordionColumn").fadeTo(500, 1);         };          var effectOut = function () {             $  ('#tdTopicTitle').fadeTo(500, 0);             return $  ("#accordionColumn").fadeTo(500, 0);         };         //includes Polyfill         if (!String.prototype.includes) {           Object.defineProperty(String.prototype, 'includes', {             value: function(search, start) {               if (typeof start !== 'number') {                 start = 0               }                if (start + search.length > this.length) {                 return false               } else {                 return this.indexOf(search, start) !== -1               }             }           })         }         function createAccordion() {             var tdItems = $  .each(thistdResults, function (ind, tdItems) {                 return tdItems;             });             if (accID != 'Search Results'){                 var filterTopic = tdItems.filter(function (e) {                     return e.Categories.toUpperCase() == accID;                 });             }else{                 var filterTopic = tdItems.filter(function (e) {                     var questions = e.Title.toLowerCase();                     return questions.includes(searchVal);                 });             }             var buildAcc = function () {                 var accID2 = accID.replace(/\s/g, '');                 var accBuild = '<div class="accordion" id="' + accID2 + '" role="tablist" aria-multiselectable="true""></div>'                 $  ("#accordionColumn").append(accBuild);             };             buildAcc();             var buildCards = function () {                 if(filterTopic.length !== 0){                     for (i = 0; i < filterTopic.length; i++) {                         var accID2 = accID.replace(/\s/g, '');                         var tdItems = filterTopic[i];                         var headerID = "heading" + tdItems.ID;                         var cardBodyID = "collapse" + tdItems.ID;                         var cardTitle = tdItems.Title;                         if (tdItems.Address){                             var cardAdd = '<p><strong>Address:</strong> ' + tdItems.Address + '</p>'                         }else{                             var cardAdd = ''                         }                         if(tdItems.Numbers){                             var cardNumbers = '<p><strong>Numbers:</strong><br/> ' + tdItems.Numbers + '</p>'                                            }else{                             var cardNumbers = ''                         }                         if (tdItems.Link){                             var cardWebsite = tdItems.Link.slice(0, -1);                             var website = '<p><strong>Website:</strong> <a href="'+ cardWebsite +'" target="_blank">'+ cardWebsite +'</a></p>'                          }else{                             var website = ''                         }                            var cardBuild = '<div class="card">' +                             '<div class="card-header pb-1 pl-0" role="tab" id="' + headerID + '">' +                             '<a class="collapsed" data-toggle="collapse" data-parent="#' + accID2 + '" href="#' + cardBodyID + '" aria-expanded="false" aria-controls="' + cardBodyID + '">' +                             '<h5 class="mb-0 font-thin">' + cardTitle + '<span class="rotate"></span></h5>' +                             '</a>' +                             '</div>' +                             '<div id="' + cardBodyID + '" class="collapse" role="tabpanel" aria-labelledby="' + headerID + '" data-parent="#' + accID + '">' +                              '<div class="card-body py-1 pl-0">' + cardAdd + cardNumbers + website + '</div>'+                             '</div>' +                             '</div>'                         $  (".accordion").append(cardBuild);                     };                     }else{                         var cardBuild = '<h4>There are no results matching your search.</div>'                         $  (".accordion").append(cardBuild);                     }                         //Accordion Icon Animation                     $  ('.accordion > div > div > a').on('click', function () {                         $  (this).find(".rotate").addClass("down");                     });                     $  ('.accordion > div > div > a').on('click', function () {                         $  (this).find(".rotate").addClass("down");                     });                 };             buildCards();          };         createAccordion();         $  ("#topicOptions > li:first-child > a").parent().css({             borderLeft: "solid medium #039BE5",             marginLeft: "-3px"         });          $  ("#topicOptions > li > a").on("click", function () {             event.returnValue = false;             accID = this.innerHTML.toUpperCase();             $  ("[data-search]")[0].value = '';             $  ("#topicOptions > li").css({                 borderLeft: "none",                 marginLeft: "0px"             });             $  (this).parent().css({                 borderLeft: "solid medium #039BE5",                 marginLeft: "-3px"             });             $  .when(effectOut()).done(function () {                 $  (".accordion").remove();                 createAccordion();                 effectIn();             });         });          function topicNav() {             // Create the dropdown base             $  ("<select style=\"border:none; height:50px;\" class=\"browser-default custom-select w-100 z-depth-1\" />").appendTo("#topicNav");             // Create default option "Go to..."             $  ("<option />", {                 "selected": "",                 "value": "Choose a Topic",                 "text": "Choose a Topic"             }).appendTo("#topicNav select");              // Populate dropdown with menu items             $  ("#topicNav > ul > li > a").each(function () {                 var topicsSelect = $  (this);                 $  ("<option />", {                     "value": topicsSelect.text(),                     "text": topicsSelect.text()                 }).appendTo("#topicNav select");             });              // To make dropdown actually work             // To make more unobtrusive: https://css-tricks.com/4064-unobtrusive-page-changer/             $  ("#topicNav select").change(function () {                 accID = $  (this).find("option:selected").val()                 $  .when(effectOut()).done(function () {                     $  (".accordion").remove();                     createAccordion();                     effectIn();                 });             });           };         topicNav();          //Search Function         $  ('[data-search]').keypress(function(event) {             if (event.which == 13){             event.preventDefault();             event.returnValue = false;             accID = 'Search Results';              searchVal = $  (this).val().toLowerCase();                 $  .when(effectOut()).done(function () {                     $  ("#topicOptions > li").css({                         borderLeft: "none",                         marginLeft: "0px"                     });                      $  (".accordion").remove();                     createAccordion();                     effectIn();                 });             }         });         $  ('[data-search-button]').on('click', function(event) {             event.preventDefault();             event.returnValue = false;             accID = 'Search Results';              $  ("#topicOptions > li").css({                 borderLeft: "none",                 marginLeft: "0px"             });              searchVal = $  ('#tdSearch').val().toLowerCase();                 $  .when(effectOut()).done(function () {                     $  ("#topicOptions > li").css({                         borderLeft: "none",                         marginLeft: "0px"                     });                      $  (".accordion").remove();                     createAccordion();                     effectIn();                 });         });     });      webpartMove = $  ("#td")     webpartMove.detach();     webpartMove.appendTo("#fullPageContent");     $  ("#fullPageContent > div > div.row.pt-3.mb-r").removeClass('mb-r pt-3');  </script>