No regular expressions were active.
|
|
1 |
|
/* jFeed :
jQuery fe
ed parser
plugin
|
|
|
2 |
|
* Copyrig
ht (C) 200
7 Jean-Fra
nГ§ois Hov
inne - htt
p://www.ho
vinne.com/
|
|
|
3 |
|
* Dual li
censed und
er the MIT
(MIT-lice
nse.txt)
|
|
|
4 |
|
* and GPL
(GPL-lice
nse.txt) l
icenses.
|
|
|
5 |
|
*/
|
|
|
6 |
|
|
|
|
7 |
|
jQuery.get
Feed = fun
ction(opti
ons) {
|
|
|
8 |
|
|
|
|
9 |
|
option
s = jQuery
.extend({
|
|
|
10 |
|
|
|
|
11 |
|
ur
l: null,
|
|
|
12 |
|
da
ta: null,
|
|
|
13 |
|
su
ccess: nul
l
|
|
|
14 |
|
|
|
|
15 |
|
}, opt
ions);
|
|
|
16 |
|
|
|
|
17 |
|
if(opt
ions.url)
{
|
|
|
18 |
|
|
|
|
19 |
|
$.
ajax({
|
|
|
20 |
|
type: 'G
ET',
|
|
|
21 |
|
url: opt
ions.url,
|
|
|
22 |
|
data: op
tions.data
,
|
|
|
23 |
|
dataType
: 'xml',
|
|
|
24 |
|
success:
function(
xml) {
|
|
|
25 |
|
var
feed = new
JFeed(xml
);
|
|
|
26 |
|
if(j
Query.isFu
nction(opt
ions.succe
ss)) optio
ns.success
(feed);
|
|
|
27 |
|
}
|
|
|
28 |
|
})
;
|
|
|
29 |
|
}
|
|
|
30 |
|
};
|
|
|
31 |
|
|
|
|
32 |
|
function J
Feed(xml)
{
|
|
|
33 |
|
if(xml
) this.par
se(xml);
|
|
|
34 |
|
};
|
|
|
35 |
|
|
|
|
36 |
|
JFeed.prot
otype = {
|
|
|
37 |
|
|
|
|
38 |
|
type:
'',
|
|
|
39 |
|
versio
n: '',
|
|
|
40 |
|
title:
'',
|
|
|
41 |
|
link:
'',
|
|
|
42 |
|
descri
ption: '',
|
|
|
43 |
|
parse:
function(
xml) {
|
|
|
44 |
|
|
|
|
45 |
|
if
(jQuery('c
hannel', x
ml).length
== 1) {
|
|
|
46 |
|
|
|
|
47 |
|
this.typ
e = 'rss';
|
|
|
48 |
|
var feed
Class = ne
w JRss(xml
);
|
|
|
49 |
|
|
|
|
50 |
|
}
else if(jQ
uery('feed
', xml).le
ngth == 1)
{
|
|
|
51 |
|
|
|
|
52 |
|
this.typ
e = 'atom'
;
|
|
|
53 |
|
var feed
Class = ne
w JAtom(xm
l);
|
|
|
54 |
|
}
|
|
|
55 |
|
|
|
|
56 |
|
if
(feedClass
) jQuery.e
xtend(this
, feedClas
s);
|
|
|
57 |
|
}
|
|
|
58 |
|
};
|
|
|
59 |
|
|
|
|
60 |
|
function J
FeedItem()
{};
|
|
|
61 |
|
|
|
|
62 |
|
JFeedItem.
prototype
= {
|
|
|
63 |
|
|
|
|
64 |
|
title:
'',
|
|
|
65 |
|
link:
'',
|
|
|
66 |
|
descri
ption: '',
|
|
|
67 |
|
update
d: '',
|
|
|
68 |
|
id: ''
|
|
|
69 |
|
};
|
|
|
70 |
|
|
|
|
71 |
|
function J
Atom(xml)
{
|
|
|
72 |
|
this._
parse(xml)
;
|
|
|
73 |
|
};
|
|
|
74 |
|
|
|
|
75 |
|
JAtom.prot
otype = {
|
|
|
76 |
|
|
|
|
77 |
|
_parse
: function
(xml) {
|
|
|
78 |
|
|
|
|
79 |
|
va
r channel
= jQuery('
feed', xml
).eq(0);
|
|
|
80 |
|
|
|
|
81 |
|
th
is.version
= '1.0';
|
|
|
82 |
|
th
is.title =
jQuery(ch
annel).fin
d('title:f
irst').tex
t();
|
|
|
83 |
|
th
is.link =
jQuery(cha
nnel).find
('link:fir
st').attr(
'href');
|
|
|
84 |
|
th
is.descrip
tion = jQu
ery(channe
l).find('s
ubtitle:fi
rst').text
();
|
|
|
85 |
|
th
is.languag
e = jQuery
(channel).
attr('xml:
lang');
|
|
|
86 |
|
th
is.updated
= jQuery(
channel).f
ind('updat
ed:first')
.text();
|
|
|
87 |
|
|
|
|
88 |
|
th
is.items =
new Array
();
|
|
|
89 |
|
|
|
|
90 |
|
va
r feed = t
his;
|
|
|
91 |
|
|
|
|
92 |
|
jQ
uery('entr
y', xml).e
ach( funct
ion() {
|
|
|
93 |
|
|
|
|
94 |
|
var item
= new JFe
edItem();
|
|
|
95 |
|
|
|
|
96 |
|
item.tit
le = jQuer
y(this).fi
nd('title'
).eq(0).te
xt();
|
|
|
97 |
|
item.lin
k = jQuery
(this).fin
d('link').
eq(0).attr
('href');
|
|
|
98 |
|
item.des
cription =
jQuery(th
is).find('
content').
eq(0).text
();
|
|
|
99 |
|
item.upd
ated = jQu
ery(this).
find('upda
ted').eq(0
).text();
|
|
|
100 |
|
item.id
= jQuery(t
his).find(
'id').eq(0
).text();
|
|
|
101 |
|
|
|
|
102 |
|
feed.ite
ms.push(it
em);
|
|
|
103 |
|
})
;
|
|
|
104 |
|
}
|
|
|
105 |
|
};
|
|
|
106 |
|
|
|
|
107 |
|
function J
Rss(xml) {
|
|
|
108 |
|
this._
parse(xml)
;
|
|
|
109 |
|
};
|
|
|
110 |
|
|
|
|
111 |
|
JRss.proto
type = {
|
|
|
112 |
|
|
|
|
113 |
|
_parse
: function
(xml) {
|
|
|
114 |
|
|
|
|
115 |
|
if
(jQuery('r
ss', xml).
length ==
0) this.ve
rsion = '1
.0';
|
|
|
116 |
|
el
se this.ve
rsion = jQ
uery('rss'
, xml).eq(
0).attr('v
ersion');
|
|
|
117 |
|
|
|
|
118 |
|
va
r channel
= jQuery('
channel',
xml).eq(0)
;
|
|
|
119 |
|
|
|
|
120 |
|
th
is.title =
jQuery(ch
annel).fin
d('title:f
irst').tex
t();
|
|
|
121 |
|
th
is.link =
jQuery(cha
nnel).find
('link:fir
st').text(
);
|
|
|
122 |
|
th
is.descrip
tion = jQu
ery(channe
l).find('d
escription
:first').t
ext();
|
|
|
123 |
|
th
is.languag
e = jQuery
(channel).
find('lang
uage:first
').text();
|
|
|
124 |
|
th
is.updated
= jQuery(
channel).f
ind('lastB
uildDate:f
irst').tex
t();
|
|
|
125 |
|
|
|
|
126 |
|
th
is.items =
new Array
();
|
|
|
127 |
|
|
|
|
128 |
|
va
r feed = t
his;
|
|
|
129 |
|
|
|
|
130 |
|
jQ
uery('item
', xml).ea
ch( functi
on() {
|
|
|
131 |
|
|
|
|
132 |
|
var item
= new JFe
edItem();
|
|
|
133 |
|
|
|
|
134 |
|
item.tit
le = jQuer
y(this).fi
nd('title'
).eq(0).te
xt();
|
|
|
135 |
|
item.lin
k = jQuery
(this).fin
d('link').
eq(0).text
();
|
|
|
136 |
|
item.des
cription =
jQuery(th
is).find('
descriptio
n').eq(0).
text();
|
|
|
137 |
|
item.upd
ated = jQu
ery(this).
find('pubD
ate').eq(0
).text();
|
|
|
138 |
|
item.id
= jQuery(t
his).find(
'guid').eq
(0).text()
;
|
|
|
139 |
|
|
|
|
140 |
|
feed.ite
ms.push(it
em);
|
|
|
141 |
|
})
;
|
|
|
142 |
|
}
|
|
|
143 |
|
};
|
|
|
144 |
|
|