Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- $(document).ready(function () {
- var feed = "/feeds/posts/default?alt=rss";
- $.ajax(feed, {
- accepts: {
- xml: "application/rss+xml"
- },
- dataType: "xml",
- success: function (data) {
- var contentsDiv = $("#contents");
- var quotesList = $("<ol></ol>").text("");
- contentsDiv.empty();
- contentsDiv.append(quotesList);
- $(data).find("item").each(function () {
- var el = $(this);
- var title = el.find("title").text();
- var link = el.find("link").text();
- var description = el.find("description").text();
- var tag_regex = /(<([^>]+)>)/ig
- var description2 = description.replace(/<br>/ig, '\n').replace(/<br\/>/ig, '\n').replace(/<br \/>/ig, '\n').replace(tag_regex, '');
- var all_lines = description2.split("\n");
- var lines = $.map(all_lines, function (v) {
- return v === "" ? null : v;
- });
- if (lines.length > 0) {
- var last_line_index = lines.length - 1;
- var last_line = lines[last_line_index];
- var has_quotes = false;
- var quote_lines = "";
- while (last_line_index >= 0 && last_line != null && last_line.charAt(0) == "\"") {
- quote_lines = last_line + "<br/><br/>" + quote_lines;
- last_line_index--;
- last_line = lines[last_line_index];
- has_quotes = true;
- }
- if (quote_lines.length > 0) {
- var quoteContent = "<b><a href=\"" + link + "\">" + title + "</a></b><br/>" + quote_lines;
- var quoteItem = $("<li></li>").html(quoteContent);
- quotesList.append(quoteItem);
- }
- }
- });
- }
- });
- });
- </script>
- <div id="contents">Loading...</div>
Add Comment
Please, Sign In to add comment