Codepen fails to function properly after being uploaded to a server

I have encountered an issue with my code on CodePen. After exporting it as a .zip file and attempting to run it on a local server, it failed to work. I am unsure of the exact reason behind this. I made sure to include all the necessary dependencies in the HTML file by choosing to export as .zip, which should have done it automatically. Here is the code snippet:

$(function() {
  // JavaScript code here
});
@charset "UTF-8";
  /* CSS code here */
}
<script src="https://example.com/script.js"></script>
<link href="https://example.com/style.css" rel="stylesheet" />
<div class="container">
  <!-- HTML code here -->
</div>

If you want to view the actual pen, you can access it through this link:

https://codepen.io/example

Answer №1

The content delivery network (cdn) is currently unavailable. It is also necessary to ensure that jquery is loaded before the date-format script.

$(function() {
  var $content = $('#jsonContent');
  var data = {
    rss_url: 'https://medium.com/feed/@SwachhCoin'
  };
  $.get('https://api.rss2json.com/v1/api.json', data, function(response) {
    if (response.status == 'ok') {
      var output = '';
      $.each(response.items, function(k, item) {
        var visibleSm;
        if (k < 3) {
          visibleSm = '';
        } else {
          visibleSm = ' visible-sm';
        }
        output += '<div class="col-sm-6 col-md-4' + visibleSm + '">';
        output += '<div class="blog-post"><header>';
        output += '<h4 class="date">' + $.format.date(item.pubDate, "dd<br>MMM") + "</h4>";
        var tagIndex = item.description.indexOf('<img'); // Find where the img tag starts
        var srcIndex = item.description.substring(tagIndex).indexOf('src=') + tagIndex; // Find where the src attribute starts
        var srcStart = srcIndex + 5; // Find where the actual image URL starts; 5 for the length of 'src="'
        var srcEnd = item.description.substring(srcStart).indexOf('"') + srcStart; // Find where the URL ends
        var src = item.description.substring(srcStart, srcEnd); // Extract just the URL
        output += '<div class="blog-element"><img class="img-responsive col-12" src="' + src + '" style="padding:1px!important"></div></header>';
        output += '<div class="blog-content"><h4><a href="' + item.link + '">' + item.title + '</a></h4>';
        output += '<div class="post-meta"><span>By ' + item.author + '</span></div>';
        var yourString = item.description.replace(/<img[^>]*>/g, ""); //replace with your string.
        var maxLength = 120 // maximum number of characters to extract
        //trim the string to the maximum length
        var trimmedString = yourString.substr(0, maxLength);
        //re-trim if we are in the middle of a word
        trimmedString = trimmedString.substr(0, Math.min(trimmedString.length, trimmedString.lastIndexOf(" ")))
        output += '<p>' + trimmedString + '...</p>';
        output += '</div></div></div>';
        return k < 3;
      });
      $content.html(output);
    }
  });
});
@charset "UTF-8";
/* CSS styles here... */
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-dateFormat/1.0/jquery.dateFormat.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
<section class="section blog" id="blog">
  <div class="container">
    <!---->
    <header class="section-heading">
      <h2>From The Blog</h2><span>Awesome articles from the blog</span>
    </header>
    <!---->
    <div class="section-content" id="blogContent">
      <div class="row" id="jsonContent"></div>
    </div>
    <div class="text-center"><a class="btn btn-dark" id="loadBlogPosts" href="//medium.com/@SwachhCoin">View All<span class="fa fa-angle-double-right"></span></a></div>
  </div>
  </section>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a customized SelectField component for Material-UI v1.0.0-alpha.21 with a fix for the Menu anchorEl problem

Currently, Material-UI v1.0.0 does not have a selectField implemented yet so I am attempting to create my own version using TextField, Menu, and MenuItem Components. Below is the code for my custom selectField: export default class SelectField extends Rea ...

Place the divs over the background image by using relative positioning

I am working on a project where I have a full-width div with a background image containing people. I want to display a tooltip when hovering over each person, but I am facing challenges in aligning the divs properly. Image maps with % widths do not seem t ...

Achieve an exceptional design by organizing the elements to gracefully drift from the left side to the right, seamlessly cascading from

I am currently working on a CSS and HTML layout, and I have a specific vision for how I want the layout to be displayed. It should appear from left to right and top to bottom, as shown in this image: https://i.stack.imgur.com/Q0VmR.jpg Each box within the ...

Can you tell me the name of the scrolling effect used for the background on this website?

Hello everyone, I have a question to ask. Be gentle with me as this is my first time posting here. I've been learning CSS3 and recently came across an effect that caught my eye. I'm not sure if it falls under the category of parallax scrolling or ...

Create a duplicate of the table and remove specific rows

Hi there, I have a query about duplicating a table. I am looking to extract specific results and display only those results. To illustrate, here is an example in HTML code: <table class="table table-striped" id="ProfileList2"> <tbody> ...

Seeking out the correct method for structuring loops and callbacks within nodejs with an emphasis on asynchronous operations

I've been researching multiple posts and articles on this topic, but I'm still struggling to grasp it. In my Mongoose model, there's a piece of code dedicated to inviting people to a project. When given a list of invitees, the code checks i ...

Updating a specific property for each object within an array of objects in MongoDB, and inserting the object if it does not already exist

I am looking for a solution to update a property for each object in an array of objects. If some of the objects do not exist, I want to insert the missing objects instead. Currently, I have been using "upsert", which creates a new document when no documen ...

When the filter feGaussianBlur is applied to an SVG circle, it disappears on Safari but not on Chrome

While implementing the filter with feGaussianBlur to an SVG circle, I encountered a peculiar issue. It works perfectly on Chrome, but unfortunately, the circle disappears when viewed on Safari. https://i.sstatic.net/k916B.png https://i.sstatic.net/5Bfp9. ...

Refining Calculated Attributes

I am currently creating a list where you can add and remove elements while specifying the count of each added element. I have included all elements in my data: Example: [ { "rowID": "21", "rowAnzahl": 1, "elementID": "127", "elementNam ...

Is there a way to place two input fields from different forms side by side on the same line?

Here are two forms extracted from an html page: <form method="get" action="search/s" id="number"> <div style="text-align: center;"> <input type="text" id="regNo" name="regNo" size="30" maxLength="50" > or ...

What is the best way to flip the direction of the text input for a Calculator?

I am currently working on creating a basic calculator from scratch using HTML, CSS, and JavaScript. I have been trying to figure out how to align the numbers to the right side of the input element. Can anyone provide me with guidance on how to achieve thi ...

``There seems to be an issue with the alignment of items in the

I am fairly new to using css and bootstrap and I am currently working on integrating a carousel into my angular web app. I copied the code from the bootstrap site but I am facing challenges in aligning everything properly. Additionally, the image slides do ...

AngularJS Dropdown in ASP.NET MVC 3

I want to create a DropDownList using @Html.DropDownList and connect it with AngularJS. Below is the code snippet: @Html.DropDownList("LessonID", (SelectList)ViewBag.LessonList, "choose one", new { ng_model = "LessonID" }) Here's an example of ...

The Image component in a test within Next.js was not wrapped in an act(...) during an update

After setting up a basic NextJS app with create-next-app and integrating Jest for testing, I encountered an error message stating "An update to Image inside a test was not wrapped in act(...)". The issue seems to be related to the Image component in NextJS ...

Making several fadeToggle functions with the same class name operate independently from each other

Trying to create a profile with a fadeToggle effect that activates when clicking on a trigger/button. The issue is, it works perfectly for the first profile on the page, but all subsequent profiles do not respond to the fadeToggle effect. Unfortunately, du ...

Struggling to display AJAX GET results on my webpage, although they are visible in the Google Element Inspector

I'm working on a basic invoice page where I need to populate a dropdown box from my MySQL database. The issue I'm facing is that when I select an item, the description box doesn't get prepopulated as expected. I've checked in the networ ...

Utilizing custom links for AJAX to showcase targeted pages: a beginner's guide

I am putting the final touches on my website and realized that it may be difficult to promote specific sections of the site because the browser address never changes. When visitors click on links, they open in a div using Ajax coding. However, if I want to ...

The absence of a property map within String Flowtype has caused an issue

There is an issue with Flowtype when it comes to arrays. type Properties = { films?: Array<any> } render() { const { movies } = this.props; return ( <React.Fragment> <main className="moviedata-container"> { ...

What is the best way to align a search box within a Bootstrap navbar?

Seeking assistance to center the search box within my Bootstrap navbar without disrupting alignment. I am aiming for a similar look as seen on linkedin.com. Any suggestions on how to achieve this? Here is a JSFiddle link to my navbar: https://jsfiddle.ne ...

Getting information from a JSON file with several variables: A guide for using node.js, express, and jQuery

In order to minimize the number of Ajax calls, I am attempting to send three variables in a single Ajax response. However, I am facing difficulties when trying to process the data on the client side. Let me elaborate on my issue and if sending multiple var ...