HTML Sitemap Widget (all posts link modify)

Créé Le diff n'expire jamais
4 suppressions
360 lignes
15 ajouts
367 lignes
<div id="bp_toc">読込中...</div>
<div id="bp_toc">読込中...</div>
<script type="text/javascript">
<script type="text/javascript">
// ---------------------------------------------------
// ---------------------------------------------------
// BLOGTOC
// BLOGTOC
// ---------------------------------------------------
// ---------------------------------------------------
// BlogToc creates a clickable Table Of Contents for
// BlogToc creates a clickable Table Of Contents for
// Blogger Blogs.
// Blogger Blogs.
// It uses the JSON post feed, and create a ToC of it.
// It uses the JSON post feed, and create a ToC of it.
// The ToC can be sorted by title or by date, both
// The ToC can be sorted by title or by date, both
// ascending and descending, and can be filtered by
// ascending and descending, and can be filtered by
// label.
// label.
// ---------------------------------------------------
// ---------------------------------------------------
// Author: Syed Faizan Ali
// Author: Syed Faizan Ali
// Url: https://www.mybloggerlab.com
// Url: https://www.mybloggerlab.com
// Version: 2
// Version: 2
// Date: 2007-04-12
// Date: 2007-04-12
// ---------------------------------------------------
// ---------------------------------------------------
// Japanese Localization by Fujiyan.
// Japanese Localization by Fujiyan.
// Url: https://fujilogic.blogspot.com/2019/05/sitemap.html
// Url: https://fujilogic.blogspot.com/2019/05/sitemap.html
// ---------------------------------------------------
// ---------------------------------------------------
// global arrays
// global arrays
var postTitle = new Array(); // array of posttitles
var postTitle = new Array(); // array of posttitles
var postUrl = new Array(); // array of posturls
var postUrl = new Array(); // array of posturls
var postDate = new Array(); // array of post publish dates
var postDate = new Array(); // array of post publish dates
var postSum = new Array(); // array of post summaries
var postSum = new Array(); // array of post summaries
var postLabels = new Array();// array of post labels
var postLabels = new Array();// array of post labels
// global variables
// global variables
var sortBy = "datenewest"; // default value for sorting ToC
var sortBy = "datenewest"; // default value for sorting ToC
var tocLoaded = false; // true if feed is read and ToC can be displayed
var tocLoaded = false; // true if feed is read and ToC can be displayed
var numChars = 250; // マウスオン時にツールチップ表示する概要文字数
var numChars = 250; // マウスオン時にツールチップ表示する概要文字数
var postFilter = ''; // デフォルトで表示するラベル名
var postFilter = ''; // デフォルトで表示するラベル名
var tocdiv = document.getElementById("bp_toc"); //the toc container
var tocdiv = document.getElementById("bp_toc"); //the toc container
var totalEntires =0; //Entries grabbed till now
var totalEntires =0; //Entries grabbed till now
var totalPosts =0; //Total number of posts in the blog.
var totalPosts =0; //Total number of posts in the blog.
// main callback function
// main callback function
function loadtoc(json) {
function loadtoc(json) {
function getPostData() {
function getPostData() {
// this functions reads all postdata from the json-feed and stores it in arrays
// this functions reads all postdata from the json-feed and stores it in arrays
if ("entry" in json.feed) {
if ("entry" in json.feed) {
var numEntries = json.feed.entry.length;
var numEntries = json.feed.entry.length;
totalEntires = totalEntires + numEntries;
totalEntires = totalEntires + numEntries;
totalPosts=json.feed.openSearch$totalResults.$t
totalPosts=json.feed.openSearch$totalResults.$t
if(totalPosts>totalEntires)
if(totalPosts>totalEntires)
{
{
var nextjsoncall = document.createElement('script');
var nextjsoncall = document.createElement('script');
nextjsoncall.type = 'text/javascript';
nextjsoncall.type = 'text/javascript';
startindex=totalEntires+1;
startindex=totalEntires+1;
nextjsoncall.setAttribute("src", "/feeds/posts/summary?start-index=" + startindex + "&max-results=50&alt=json-in-script&callback=loadtoc");
nextjsoncall.setAttribute("src", "/feeds/posts/summary?start-index=" + startindex + "&max-results=50&alt=json-in-script&callback=loadtoc");
tocdiv.appendChild(nextjsoncall);
tocdiv.appendChild(nextjsoncall);
}
}
// main loop gets all the entries from the feed
// main loop gets all the entries from the feed
for (var i = 0; i < numEntries; i++) {
for (var i = 0; i < numEntries; i++) {
// get the entry from the feed
// get the entry from the feed
var entry = json.feed.entry[i];
var entry = json.feed.entry[i];
// get the posttitle from the entry
// get the posttitle from the entry
var posttitle = entry.title.$t;
var posttitle = entry.title.$t;
// get the post date from the entry
// get the post date from the entry
var postdate = entry.published.$t.substring(0,10).replace(/-/g,"/");
var postdate = entry.published.$t.substring(0,10).replace(/-/g,"/");
// get the post url from the entry
// get the post url from the entry
var posturl;
var posturl;
for (var k = 0; k < entry.link.length; k++) {
for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'alternate') {
if (entry.link[k].rel == 'alternate') {
posturl = entry.link[k].href;
posturl = entry.link[k].href;
break;
break;
}
}
}
}
// get the post contents from the entry
// get the post contents from the entry
// strip all html-characters, and reduce it to a summary
// strip all html-characters, and reduce it to a summary
if ("content" in entry) {
if ("content" in entry) {
var postcontent = entry.content.$t;}
var postcontent = entry.content.$t;}
else
else
if ("summary" in entry) {
if ("summary" in entry) {
var postcontent = entry.summary.$t;}
var postcontent = entry.summary.$t;}
else var postcontent = "";
else var postcontent = "";
// strip off all html-tags
// strip off all html-tags
var re = /<\S[^>]*>/g;
var re = /<\S[^>]*>/g;
postcontent = postcontent.replace(re, "");
postcontent = postcontent.replace(re, "");
// reduce postcontent to numchar characters, and then cut it off at the last whole word
// reduce postcontent to numchar characters, and then cut it off at the last whole word
if (postcontent.length > numChars) {
if (postcontent.length > numChars) {
postcontent = postcontent.substring(0,numChars);
postcontent = postcontent.substring(0,numChars);
var quoteEnd = postcontent.lastIndexOf(" ");
var quoteEnd = postcontent.lastIndexOf(" ");
postcontent = postcontent.substring(0,quoteEnd) + '...';
postcontent = postcontent.substring(0,quoteEnd) + '...';
}
}
// get the post labels from the entry
// get the post labels from the entry
var pll = '';
var pll = '';
if ("category" in entry) {
if ("category" in entry) {
for (var k = 0; k < entry.category.length; k++) {
for (var k = 0; k < entry.category.length; k++) {
pll += '<a href="javascript:filterPosts(\'' + entry.category[k].term + '\');" title="ラベル 「' + entry.category[k].term + '」 の記事を表示">' + entry.category[k].term + '</a>, ';
pll += '<a href="javascript:filterPosts(\'' + entry.category[k].term + '\');" title="ラベル 「' + entry.category[k].term + '」 の記事を表示">' + entry.category[k].term + '</a>, ';
}
}
var l = pll.lastIndexOf(',');
var l = pll.lastIndexOf(',');