//totalEntires) { var nextjsoncall = document.createElement(‘script’); nextjsoncall.type = ‘text/javascript’; startindex=totalEntires+1; nextjsoncall.setAttribute(“src”, “/feeds/posts/summary?start-index=” + startindex + “&max-results=500&alt=json-in-script&callback=loadtoc”); tocdiv.appendChild(nextjsoncall); } // main loop gets all the entries from the feed for (var i = 0; i < numEntries; i++) { // get the entry from the feed var entry = json.feed.entry[i]; // get the posttitle from the entry var posttitle = entry.title.$t; // get the post date from the entry var postdate = entry.published.$t.substring(0,10); // get the post url from the entry var posturl; for (var k = 0; k < entry.link.length; k++) { if (entry.link[k].rel == 'alternate') { posturl = entry.link[k].href; break; } } // get the post contents from the entry // strip all html-characters, and reduce it to a summary if ("content" in entry) { var postcontent = entry.content.$t;} else if ("summary" in entry) { var postcontent = entry.summary.$t;} else var postcontent = ""; // strip off all html-tags var re = /]*>/g; postcontent = postcontent.replace(re, “”); // reduce postcontent to numchar characters, and then cut it off at the last whole word if (postcontent.length > numChars) { postcontent = postcontent.substring(0,numChars); var quoteEnd = postcontent.lastIndexOf(” “); postcontent = postcontent.substring(0,quoteEnd) + ‘…’; } // get the post labels from the entry var pll = ”; if (“category” in entry) { for (var k = 0; k < entry.category.length; k++) { pll += '‘ + entry.category[k].term + ‘, ‘; } var l = pll.lastIndexOf(‘,’); if (l != -1) { pll = pll.substring(0,l); } } // add the post data to the arrays postTitle.push(posttitle); postDate.push(postdate); postUrl.push(posturl); postSum.push(postcontent); postLabels.push(pll); } } if(totalEntires==totalPosts) {tocLoaded=true;showToc();} } // end of getPostData // start of showtoc function body // get the number of entries that are in the feed // numEntries = json.feed.entry.length; // get the postdata from the feed getPostData(); // sort the arrays sortPosts(sortBy); tocLoaded = true; } // filter and sort functions function filterPosts(filter) { // This function changes the filter // and displays the filtered list of posts // document.getElementById(“bp_toc”).scrollTop = document.getElementById(“bp_toc”).offsetTop;; postFilter = filter; displayToc(postFilter); } // end filterPosts function allPosts() { // This function resets the filter // and displays all posts postFilter = ”; displayToc(postFilter); } // end allPosts function sortPosts(sortBy) { // This function is a simple bubble-sort routine // that sorts the posts function swapPosts(x,y) { // Swaps 2 ToC-entries by swapping all array-elements var temp = postTitle[x]; postTitle[x] = postTitle[y]; postTitle[y] = temp; var temp = postDate[x]; postDate[x] = postDate[y]; postDate[y] = temp; var temp = postUrl[x]; postUrl[x] = postUrl[y]; postUrl[y] = temp; var temp = postSum[x]; postSum[x] = postSum[y]; postSum[y] = temp; var temp = postLabels[x]; postLabels[x] = postLabels[y]; postLabels[y] = temp; } // end swapPosts for (var i=0; i < postTitle.length-1; i++) { for (var j=i+1; j postTitle[j]) { swapPosts(i,j); } } if (sortBy == “titledesc”) { if (postTitle[i] postDate[j]) { swapPosts(i,j); } } if (sortBy == “datenewest”) { if (postDate[i] < postDate[j]) { swapPosts(i,j); } } } } } // end sortPosts // displaying the toc function displayToc(filter) { // this function creates a three-column table and adds it to the screen var numDisplayed = 0; var tocTable = ''; var tocHead1 = 'Titolo del Post'; var tocTool1 = 'Clicca per ordinare per titolo'; var tocHead2 = 'Data'; var tocTool2 = 'Clicca per ordinare per data'; var tocHead3 = 'Etichette'; var tocTool3 = ''; if (sortBy == "titleasc") { tocTool1 += ' (scendi)'; tocTool2 += ' (nuovi)'; } if (sortBy == "titledesc") { tocTool1 += ' (scendi)'; tocTool2 += ' (prima nuovi post)'; } if (sortBy == "dateoldest") { tocTool1 += ' (sali)'; tocTool2 += ' (prima nuovi post)'; } if (sortBy == "datenewest") { tocTool1 += ' (sali)'; tocTool2 += ' (prima vecchi post)'; } if (postFilter != '') { tocTool3 = 'Clicca per vedere tutti i post'; } tocTable += '
‘; tocTable += ‘‘ + tocHead1 + ‘‘; tocTable += ‘ | ‘; tocTable += ‘‘ + tocHead2 + ‘‘; tocTable += ‘ | ‘; tocTable += ‘‘ + tocHead3 + ‘‘; tocTable += ‘ |
‘ + postTitle[i] + ‘ | ‘ + postDate[i] + ‘ | ‘ + postLabels[i] + ‘ |
‘ + postTitle[i] + ‘ | ‘ + postDate[i] + ‘ | ‘ + postLabels[i] + ‘ |
‘; if (numDisplayed == postTitle.length) { var tocNote = ‘Elenco di tutti i ‘ + postTitle.length + ‘ posts<
‘; } tocdiv.innerHTML = tocNote + tocTable; } // end of displayToc function toggleTitleSort() { if (sortBy == “titleasc”) { sortBy = “titledesc”; } else { sortBy = “titleasc”; } sortPosts(sortBy); displayToc(postFilter); } // end toggleTitleSort function toggleDateSort() { if (sortBy == “datenewest”) { sortBy = “dateoldest”; } else { sortBy = “datenewest”; } sortPosts(sortBy); displayToc(postFilter); } // end toggleTitleSort function showToc() { if (tocLoaded) { displayToc(postFilter); var toclink = document.getElementById(“toclink”); } else { alert(“Just wait… TOC is loading”); } } function hideToc() { var tocdiv = document.getElementById(“toc”); tocdiv.innerHTML = ”; var toclink = document.getElementById(“toclink”); toclink.innerHTML = ‘» Show Table of Contents ‘; } //]]>
#comments {display:none;}
#bp_toc {background:#F95B5B;color:#420202;margin:0 auto;padding:5px;} span.toc-note {padding:20px;margin:0 auto;display:block;text-align:center;color:#fedede;font-family:’Georgia’;font-weight:bold;text-transform:uppercase;font-size:30px;line-height:normal;} .toc-header-col1 {padding:10px;background-color:#fff;width:250px;} .toc-header-col2 {padding:10px;background-color:#fff;width:75px;} .toc-header-col3 {padding:10px;background-color:#fff;width:125px;} .toc-header-col1 a:link, .toc-header-col1 a:visited, .toc-header-col2 a:link, .toc-header-col2 a:visited, .toc-header-col3 a:link, .toc-header-col3 a:visited {font-size:13px; text-decoration:none;color:#f60909;font-family:’Georgia’;font-weight:bold;letter-spacing: 0.5px;} .toc-header-col1 a:hover, .toc-header-col2 a:hover, .toc-header-col3 a:hover { text-decoration:none;} .toc-entry-col1, .toc-entry-col2, .toc-entry-col3 {background:#fff;padding:5px;padding-left:5px;font-size:89%} .toc-entry-col1 a, .toc-entry-col2 a, .toc-entry-col3 a{color:#555;font-size:13px;} .toc-entry-col1 a:hover, .toc-entry-col2 a:hover, .toc-entry-col3 a:hover{color:#f60909;} #bp_toc table {width:100%;margin:0 auto;counter-reset:rowNumber;} .toc-entry-col1 {counter-increment:rowNumber;} #bp_toc table tr td.toc-entry-col1:first-child::before {content: counter(rowNumber);min-width:1em;margin-right:0.5em;} td.toc-entry-col2 {background:#fdfdfd;}