2

Hello I've just changed the domain from tecnoriales.win to tecnoriales.com and started using SSL (HTTPS).

I have a script that creates an archive of all my post but is not working anymore. I know very little about coding, so I have no clue.

Heres the page where the code should load: https://www.tecnoriales.com/p/sitemap.html

Already took a look to a VERY similar question: Blogger from http to https (SSL problems) Tried what they said (or so i think) but I was not able to fix the problem.

<div style="text-align: justify;">
<span style="font-family: &quot;trebuchet ms&quot; , sans-serif;">A 
continuación tienes la lista de todas las entradas del blog. Recuerda 
que también puedes utilizar la opción Buscar este blog que se encuentra 
en la esquina superior izquierda para indagar.</span><br />
<span style="font-family: &quot;trebuchet ms&quot; , sans-serif;">
</span></div>
<br />
<script type="text/javascript">
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">
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=151&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=301&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=451&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=601&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=851&alt=json-in-script&callback=LoadTheArchive"/>
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=1001&alt=json-in-script&callback=LoadTheArchive"/>

<!--CUSTOMIZATION-->
<style type="text/css">
.dateStyle {
     color:#000;
     font-weight:bold;
     font-size: 15px;
     font-family: Trebuchet MS, sans-serif;
     margin: 0;
}

.dayStyle {
     color:#000;
     font-weight:bold;
     font-family: Trebuchet MS, sans-serif;
     display: inline-block;
}

</style></script>```

It should load the full list of all the blog post I've made categorized by month and year but it loads nothing.

2 Answers2

1

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

Prayag Verma
  • 5,500
  • 3
  • 27
  • 53
0

The actual problem was that your callback function was not defined.

So, define your functions as function expression. This way the function definition exists for the callback to work.

var LoadTheArchive = function (TotalFeed)

var DisplaytheTOC = function (

Run the snippet below to see it work. Loading links takes a while. So, please wait patiently.

<div style="text-align: justify;">
  <span style="font-family: &quot;trebuchet ms&quot; , sans-serif;">A 
continuación tienes la lista de todas las entradas del blog. Recuerda 
que también puedes utilizar la opción Buscar este blog que se encuentra 
en la esquina superior izquierda para indagar.</span><br />
  <span style="font-family: &quot;trebuchet ms&quot; , sans-serif;">
</span></div>
<br />

<script>
  var LoadTheArchive = function(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);
  }

  var DisplaytheTOC = function(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" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=151&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=301&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=451&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=601&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=851&alt=json-in-script&callback=LoadTheArchive" />
<script src="https://tecnoriales.com/feeds/posts/default?max-results=150&start-index=1001&alt=json-in-script&callback=LoadTheArchive" />

<!--CUSTOMIZATION-->
<style type="text/css">
  .dateStyle {
    color: #000;
    font-weight: bold;
    font-size: 15px;
    font-family: Trebuchet MS, sans-serif;
    margin: 0;
  }
  
  .dayStyle {
    color: #000;
    font-weight: bold;
    font-family: Trebuchet MS, sans-serif;
    display: inline-block;
  }
</style>
Rakesh Gupta
  • 827
  • 7
  • 12
  • Thanks now it loads, howver text has no format, the CSS part is not working. – Tecnoriales Blog Apr 05 '19 at 10:39
  • I had separated the CSS to the CSS section for clarity. I just put the CSS – Rakesh Gupta Apr 05 '19 at 13:09
  • Yeah i realized that, so that wasnt the problem, is just not applying the style part at the end. Now your edited script does not load the style either when i click on run snippet, however your first one, where you had things separated it did, i worked as it should. – Tecnoriales Blog Apr 06 '19 at 22:07