-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFeedEk.js
59 lines (54 loc) · 1.82 KB
/
FeedEk.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*! FeedEk jQuery RSS/ATOM Feed Plugin v3.1.1
* https://jquery-plugins.net/FeedEk/FeedEk.html https://github.com/enginkizil/FeedEk
* Author : Engin KIZIL */
(function ($) {
$.fn.FeedEk = function (opt) {
var def = $.extend({
MaxCount: 5,
ShowDesc: true,
ShowPubDate: true,
DescCharacterLimit: 0,
TitleLinkTarget: "_blank",
DateFormat: "",
DateFormatLang: "en"
}, opt);
var id = $(this).attr("id"), s = "", dt;
$("#" + id).empty();
if (def.FeedUrl == undefined) return;
$("#" + id).append('<img src="https://1.bp.blogspot.com/-4SO0aHC4-hw/XvuKZtWeZ-I/AAAAAAAALT8/O2FqB5T9PM0f8LF59ig6TgQnsYwW9580wCK4BGAsYHg/s32/loader.gif" />');
$.ajax({
url: "https://feed.jquery-plugins.net/load?url=" + encodeURIComponent(def.FeedUrl) + "&maxCount=" + def.MaxCount + "&dateCulture=" + def.DateFormatLang + "&dateFormat=" + def.DateFormat,
dataType: "json",
success: function (result) {
$("#" + id).empty();
if (result.data == null)
return;
$.each(result.data, function (e, itm) {
s += '<li><div class="itemTitle"><a href="' + itm.link + '" target="' + def.TitleLinkTarget + '" >' + itm.title + '</a></div>';
if (def.ShowPubDate) {
dt = new Date(itm.publishDate);
s += '<div class="itemDate">';
if ($.trim(def.DateFormat).length > 0) {
s += itm.publishDateFormatted;
}
else {
s += dt.toLocaleDateString();
}
s += '</div>';
}
if (def.ShowDesc) {
s += '<div class="itemContent">';
if (def.DescCharacterLimit > 0 && itm.description.length > def.DescCharacterLimit) {
s += itm.description.substring(0, def.DescCharacterLimit) + '...';
}
else {
s += itm.description;
}
s += '</div>';
}
});
$("#" + id).append('<ul class="feedEkList">' + s + '</ul>');
}
});
};
})(jQuery);