Setelah sebelumnya saya membagikan cara membuat sitemap rapi, kali ini saya akan memberikan cara membuat sitemap atau daftar isi blogger yang canggih dan juga keren. Untuk sitemap yang ini bisa di lihat dulu
disini.
Caranya seperti biasa, login ke blogger kemudian buat posting atau halaman baru.
Kemudian tempelkan kode di bawah ini pada isi postingan
<div style="padding: 10px; text-align: left;">
<div id="cl_option">
<img alt="Loading...." src="https://www.google.com/webmasters/tools/images/progress_spinner_24x24.gif" /> </div>
<div id="cl_content_list">
</div>
<script type="text/javascript">
var madjongke = 500;
<script>
var cl_summlen = madjongke;
var all_entries; var entries; var all_labels = []; var json;
function createEntries(json){
var entries_obj_list = [];
var entries = json.feed.entry;
for(var i=0; i<entries.length; i++){
var entry = entries[i];
var entry_obj = new Object;
entry_obj.id = entry.id.$t;
entry_obj.title = entry.title.$t;
entry_obj.href = getEntryHref(entry);
entry_obj.content = getEntryContent(entry);
entry_obj.labels = getEntryLabels(entry);
entry_obj.published = entry.published.$t.substr(0, 10);
entries_obj_list.push(entry_obj);
}
return entries_obj_list;
}
function getEntryById(id){
for(var i=0; i<all_entries.length; i++){
if(all_entries[i].id == id){return all_entries[i];}
} return null;
}
function getEntryContent(entry){
return entry.content ? entry.content.$t : entry.summary.$t;
}
function getEntryHref(entry){
var links = entry.link;
for(var i=0; i<links.length; i++){
if(links[i].rel == "alternate"){return links[i].href;}
}
return null;
}
function getEntryLabels(entry){
var labels = [];
var categories = entry.category;
if(!categories){return labels;}
for(var i=0; i<categories.length; i++){
var label = categories[i].term;
if(!isExists(all_labels, label)){all_labels.push(label);} // while collecting all labels
labels.push(label);
}
return labels;
}
function getSomeEntries(cmp){
entries = [];
for(var i=0; i<all_entries.length; i++){
var entry = all_entries[i];
if(cmp(entry)){entries.push(entry);}
}
return entries;
}
function isExists(array, val){
for(var i=0; i<array.length; i++){
if(array[i] == val){return true;}
} return false;
}
function onLoadFeed(json_arg){
json = json_arg;
setTimeout("onLoadFeedTimeout()", 100);
}
function onLoadFeedTimeout(){
entries = createEntries(json);
all_entries = entries;
showHeaderOption();
showEntries(entries);
}
function showEntries(entries){
var s = "";
for(var i=0; i<entries.length; i++){
var entry = entries[i];
s += "
";
s += titleCode(entry);
s += "<span style='font-size:90%'>Label: " + labelsCode(entry);
s += " Pada " + publishedDateCode(entry) + "</span>";
s += "
";
}
s += "
";
s += "<div style='text-align:left; margin-top:10px; font-family:Verdana; font-size:70%'>
";
s += "<a href='http://www.madjongke.com/2012/05/membuat-sitemapdaftar-isi-canggih-keren.html' title='Buat sitemap'>SITEMAP</a>";
s += "</div>
";
document.getElementById("cl_content_list").innerHTML = s;
}
function showHeaderOption(){
var s = "";
s += "<table>";
s += "
<tr>";
s += "<td style='text-align:right'>Lihat Dengan : ";
s += "<td><select onchange='sortBy(this.value.substr(1), this.value.substr(0,1))'>";
s += "<option value='0published'/>Tanggal";
s += "<option value='1title'/>Judul";
s += "</select>";
s += "
<tr>";
s += "<td style='text-align:right'>Pilih Label : ";
s += "<td><select onchange='showPostsWLabel(this.value)' id='cl_labels'>";
s += "<option value='*'/>Semua Label";
for(var i=0; i<all_labels.length; i++){
var label = all_labels[i];
s += "<option value='"+label+"'/>" + label;
}
s += "</select>";
s += "</table>
";
document.getElementById("cl_option").innerHTML = s;
}
function shortenContent(entry){
var content = entry.content;
content = stripHTML(content);
if(content.length > cl_summlen){
content = content.substr(0, cl_summlen);
if(content.charAt(content.length-1) != " "){content = content.substr(0, content.lastIndexOf(" ")+1);}
content += "...";
}
entry.content = content;
return content;
}
function showHideSummary(obj){
var p = obj.nextSibling;
while(p.className != "cl_content"){p = p.nextSibling;}
var id = p.id;
var entry = getEntryById(id);
var content = shortenContent(entry);
if(p.innerHTML == ""){
p.innerHTML = content + "
";
obj.innerHTML = "▼";
obj.title = "Tutup ringkasan";
} else {
p.innerHTML = "";
obj.innerHTML = "►";
obj.title = "buka ringkasan";
}
}
function sortBy(attribute, asc){
var cmp = function(entry1, entry2){
if(entry1[attribute] == entry2[attribute]){return 0;}
else if(asc=='1'){return entry1[attribute].toLowerCase() > entry2[attribute].toLowerCase();}
else{return entry1[attribute].toLowerCase() < entry2[attribute].toLowerCase();}
}
entries.sort(cmp);
showEntries(entries);
}
function stripHTML(s) {
var c;
var intag = false; var newstr = "";
for(var i=0; i<s.length; i++){
c = s.charAt(i);
if(c=="<"){intag = true;}
else if(c==">"){intag = false;}
if(c == ">"){newstr += " ";}
else if(!intag){newstr += c;}
}
return newstr;
}
// --------------------- functions returning HTML code -------------------- \
function labelsCode(entry){
var s = "";
if(entry.labels.length == 0){return " (tidak berlabel) ";}
for(var j=0; j<entry.labels.length; j++){
var label = entry.labels[j];
s += "<a href='javascript:showPostsWLabel(""+label+"")' ";
s += "title='Tampilkan semua pada label ""+label+""'>" + label + "</a>";
s += (j != entry.labels.length-1) ? ", " : "";
}
return s;
}
function publishedDateCode(entry){
var y = entry.published.substr(0, 4);
var m = entry.published.substr(5, 2);
var d = entry.published.substr(8, 2);
var s = "<a href='javascript:showPostsInDate(""+y+"")' title='Tampilkan semua saat "+y+"'>" + y + "</a>/";
s += "<a href='javascript:showPostsInDate(""+y+"-"+m+"")' title='Tampilkan semua saat "+y+"/"+m+"'>" + m + "</a>/";
s += "<a href='javascript:showPostsInDate(""+y+"-"+m+"-"+d+"")'title='Tampilkan semua saat "+y+"/"+m+"/"+d+"'>" + d + "</a>";
return s;
}
function titleCode(entry){
var s = "<span title='Buka ringkasan' onclick='showHideSummary(this)' style='cursor:pointer'>►</span> ";
s += "<b><a href='"+entry.href+"'>" + entry.title + "</a></b>
";
s += "<span class='cl_content' id='"+entry.id+"'></span>";
return s;
}
// ----------------------- selection functions ------------------------------ \
function showPostsInDate(date){
var cmp = function(entry){return entry.published.indexOf(date) == 0;}
var entries = getSomeEntries(cmp);
showEntries(entries);
}
function showPostsWLabel(label){
var cmp = function(entry){
if(label == "*"){return true;}
for(var i=0; i<entry.labels.length; i++){
if(entry.labels[i] == label){return true;}
}
return false;
}
var entries = getSomeEntries(cmp);
showEntries(entries);
document.getElementById("cl_labels").value = label;
}
</script>
<script src="http://
www.madjongke.com/feeds/posts/default?alt=json-in-script&callback=onLoadFeed&max-results=9999">
</script> </div>
<div style="clear: both;">
</div>
Hal penting yang perlu di perhatikan adalah kode yang berwarna merah rubah dengan alamat blog kamu.
Jika sudah lihatlah hasilnya. Semoga bermanfaat.