Quantcast
Channel: User Prayag Verma - Stack Overflow
Viewing all articles
Browse latest Browse all 39

Answer by Prayag Verma for Blogger javascript not working http to https

$
0
0

Linebreaks within the JavaScript code leads to Syntax errors. Also PostEntries variable was referenced as postentries. Change the Javascript as follows -

<script>function LoadTheArchive(TotalFeed) {    var PostTitles = new Array();    var PostURLs = new Array();    var PostYears = new Array();    var PostMonths = new Array();    var PostDays = new Array();    if("entry" in TotalFeed.feed)     { var PostEntries=TotalFeed.feed.entry.length; for(var PostNum=0; PostNum<PostEntries ; PostNum++)  {     var ThisPost = TotalFeed.feed.entry[PostNum];     PostTitles.push(ThisPost.title.$t);     PostYears.push(ThisPost.published.$t.substring(0,4));     PostMonths.push(ThisPost.published.$t.substring(5,7));     PostDays.push(ThisPost.published.$t.substring(8,10));     var ThisPostURL;     for(var LinkNum=0; LinkNum < ThisPost.link.length; LinkNum++)      {  if(ThisPost.link[LinkNum].rel == "alternate")   {      ThisPostURL = ThisPost.link[LinkNum].href;      break  }     }     PostURLs.push(ThisPostURL); }    }    DisplaytheTOC(PostTitles,PostURLs,PostYears,PostMonths,PostDays);}function DisplaytheTOC(PostTitles,PostURLs,PostYears,PostMonths,PostDays){    var MonthNames=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"];    var NumberOfEntries=PostTitles.length;    var currentMonth = "";    var currentYear = "";    for(var EntryNum = 0; EntryNum < NumberOfEntries; EntryNum++)    { NameOfMonth = MonthNames[parseInt(PostMonths[EntryNum],10)-1] if (currentMonth != NameOfMonth || currentYear != PostYears[EntryNum]) {  currentMonth = NameOfMonth;  currentYear = PostYears[EntryNum];  document.write("<div class='dateStyle'><br />"+ currentMonth+""+currentYear+"</div>"); }  document.write('<a href ="'+PostURLs[EntryNum]+'"><div class=dayStyle>'+parseInt(PostDays[EntryNum],10)+":&nbsp;&nbsp;</div>"+PostTitles[EntryNum]+"</a><br />");    }}</script><script src="https://tecnoriales.com/feeds/posts/default?max-results=500&amp;alt=json-in-script&amp;callback=LoadTheArchive" />

You will notice that last 2 document.write statements have the linebreaks removed


Viewing all articles
Browse latest Browse all 39

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>