JSFiddle - React, Tailwind, and code Playground

by Joey Hernandez

HTML

<ul class="liveblog_entries"></ul>
<div class="liveblog_nav"></div>

JavaScript

var x = 0;
      if (window.location.search.indexOf('tumblrpage=') > -1) {
          var url = $(location).attr('href');
          url = url.split('=');
          x = url[1] * 5 - 5;
          currentpage = url[1];
      } else {
          currentpage = 1;
      }

      repeatAjax();

      function repeatAjax() {
          $.ajax({
              url: '<?php echo get_bloginfo("stylesheet_directory"); ?>/tumblr/api.php',
              type: 'post',
              dataType: 'json',
              data: {
                  'tag': '<?php echo $liveblog_tag; ?>',
                  'offset': x
              },

              success: function (posts) {
                  var postings = posts.response.posts;
                  console.log(postings);
                  var text = '';
                  for (var i in postings) {
                      var p = postings[i];
                      text += '<li>';
                      var taglength = p.tags.length;
                      var author = ''
                      var authorfound = 0;
                      var title = '';
                      var social_title = '';
                      var social_handle = '';
                      var titlefound = 0;
                      for (var i = 0; i < taglength; i++) {
                          if (p.tags[i].search(/author/i) != -1) {
                              author = p.tags[i].replace('author:', '');
                              authorfound = 1;
                          } else if ((p.tags[i].search(/author/i) == -1 && (authorfound != 1))) {
                              author = 'Guest Poster';
                              authorfound = 0;
                          }
                          if (p.tags[i].search(/title/i) != -1) {
                              title = p.tags[i].replace('title:', '');
                              titlefound = 1;
                          } else if ((p.tags[i].search(/title/i) == -1 && (titlefound != 1))) {
                             ...