/
rss.html
131 lines (103 loc) · 3.23 KB
/
rss.html
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<script type="text/javascript">
// pageChanged & sizeChanged functions are needed in every model file
// other functions for model should also be in here to avoid conflicts
var rss = new function() {
// function called every time the page is viewed after it has initially loaded
this.pageChanged = function() {
}
// function called every time the size of the LO is changed
this.sizeChanged = function() {
}
this.listFeed = function(data) {
clearTimeout(errorTimer);
$("#loadingSpinner").hide();
var resultsString = "";
if (data.responseData.feed.entries == 0) {
resultsString = '<div><p>No results returned!!</p></div>'; // ** Need to take this from the language file
} else {
$pageContents.find("#headerHolder").html("<p>" + data.responseData.feed.description + "</p>"); // ** Need to take this from the language file
$.each(data.responseData.feed.entries, function (index, item) {
resultsString += '<div><a target="_blank" href="' + item.link + '">' + item.title + '</a><p>"' + item.contentSnippet + '"</p></div>';
});
}
$resultsHolder
.html(resultsString)
.find("div:even").addClass("shadedDiv");
}
}
var $pageContents = $("#pageContents");
var $textHolder = $("#textHolder");
var $panel = $("#pageContents .panel");
var $resultsHolder = $pageContents.find("#resultsHolder");
var rssURL = x_currentPageXML.getAttribute("url");
var googleFeedURL = document.location.protocol + "//ajax.googleapis.com/ajax/services/feed/load";
var errorTimer = setTimeout(function() { alert("error");
$("#loadingSpinner").hide();
$resultsTable
.html('<div><p>There was an error loading the results!!</p></div>') // ** Need to take this from the language file
.find("div:even").addClass("shadedDiv");
}, 5000);
$.ajax({
beforeSend: function() {
$('#loadingSpinner').show();
},
url: googleFeedURL,
data: {
"q" : encodeURI(rssURL),
"num" : 10,
"v" : "1.0"
},
dataType: 'jsonp',
jsonpCallback: "rss.listFeed",
cache:false
});
$panel.addClass("width60");
if (x_currentPageXML.getAttribute("align") == "Right") {
$panel.addClass("x_floatLeft");
} else {
$panel.addClass("x_floatRight");
}
$textHolder.html(x_addLineBreaks(x_currentPageXML.getAttribute("text")));
// call this function in every model once everything's loaded
x_pageLoaded();
</script>
<style type="text/css">
#headerHolder {
text-align: center;
font-weight: bold;
}
#resultsHolder {
width: 100%;
}
#resultsHolder div {
width: 100%;
padding: 2px 2px 2px 2px;
box-sizing: border-box; *behavior: url(/scripts/boxsizing.htc);
}
#resultsHolder div p {
margin: 0;
}
.shadedDiv {
background-color: #E3FFD6;
}
#loadingSpinner {
display: none;
text-align: center;
font-weight: bold;
}
#loadingSpinner img {
margin-right: 20px;
vertical-align: middle;
}
</style>
<div id="pageContents">
<div id="rssHolder" class="mobileAlign"> <!-- this tag is only used when viewed on mobiles to change layout -->
<div class="panel inline">
<div id="headerHolder"></div>
<div id="resultsHolder"></div>
<div id="loadingSpinner"><img src="media/spinner.gif" alt="Fetching results" /><p>Fetching results...</p></div>
</div>
</div>
<div id="textHolder">
</div>
</div>