-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.JQuery.html
73 lines (65 loc) · 2.63 KB
/
index2.JQuery.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
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery-1.4.4.js"></script>
<script type="text/javascript" src="jquery.tmpl.js"></script>
<title>Super Yahoo pipes</title>
</head>
<body>
<h1>Super Yahoo pipes</h1>
<div id="news"></div>
<script type="text/javascript">
'use strict';
var myApp = (function(){
// -----------------------------------------------------------------------------------
// Show/hide elements on click in parent div
// -----------------------------------------------------------------------------------
var processDivOnClick = function (elem) {
elem.find('.toggling').toggle();
};
// -----------------------------------------------------------------------------------------
// receive news from yahoo server
// -----------------------------------------------------------------------------------------
var onload = function () {
//Create a SCRIPT element.
var script = document.createElement("script");
//Set the Type.
script.type = "text/javascript";
//Set the source to the URL the JSON Service.
script.src = "http://pipes.yahoo.com/pipes/pipe.run?_id=e9a2e77dffb3205d035c4e311d77bbe6&_render=json&_callback=displayNews";
//Append the script element to the HEAD section.
$('head')[0].appendChild(script);
};
// -----------------------------------------------------------------------------------------
// Display all received news on the page
// -----------------------------------------------------------------------------------------
window.displayNews = function (response) {
$("#bookTemplate").tmpl(response.value.items).appendTo("#news");
delete window.displayNews;
delete window.onload;
};
return {
onload: onload,
processDivOnClick: processDivOnClick
};
})();
window.onload = myApp.onload;
</script>
<script id="bookTemplate" type="text/x-jquery-tmpl">
<div id="article" onclick="myApp.processDivOnClick($(this));">
<div id="img">
<img height="50" id="image" src="${enclosure.url}" width="50">
</div>
<div id="title">
${title}
</div>
<div id="summary" class="toggling">
${description}
</div>
<div id="lnk" class="toggling">
<a href="${link}" id="article-link">-></a>
</div>
</div>
</script>
</body>
</html>