-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
executable file
·121 lines (100 loc) · 3.28 KB
/
demo.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
<html>
<head>
<title>NPR API Plugin for JQuery </title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.npr.js"></script>
<script type="text/javascript">
// function to get a named parameter from the url
getUrlParameter = function( pname, pdefault ) {
try {
// From this page: http://www.netlobo.com/url_query_string_javascript.html
pname = pname.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+pname+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results === null ) {
return pdefault;
}
else {
return results[1];
}
} catch (e) {
alert(e);
}
};
$(document).ready(function() {
var apiKeyFromUrl = getUrlParameter('apiKey', null);
$('.nprtopic').npr({apiKey : apiKeyFromUrl,
cloneToFit : true,
callback : function(topicId) {
$('.nprstory:first').siblings('.nprstory').remove();
$('.nprstory').npr({apiKey : apiKeyFromUrl,
cloneToFit : true,
content : 'title',
onload : function() {
$('#nprtopiclist').slideUp();
$('#nprlist').slideDown();
},
callback : function(storyId) {
$('#summary').npr({apiKey : apiKeyFromUrl, content : 'summary'}).loadStory(
{
nprId : storyId,
onload : function () {
$('#nprlist').slideUp();
$('#nprsummary').slideDown();
},
callback : function(storyId) {
$('#fullStory').npr({apiKey : apiKeyFromUrl, content : 'full'}).loadStory(
{
nprId : storyId,
onload : function () {
$('#nprsummary').slideUp();
$('#nprfullstory').slideDown();
}
});
}
}
);
}
}).loadStory({nprId : topicId});
}}).loadNewsTopics();
$('#listBack').click(function(e) {
e.preventDefault();
$('#nprlist').slideUp();
$('#nprtopiclist').slideDown();
});
$('#summaryBack').click(function(e) {
e.preventDefault();
$('#nprsummary').slideUp();
$('#nprlist').slideDown();
});
$('#fullBack').click(function(e) {
e.preventDefault();
$('#nprfullstory').slideUp();
$('#nprsummary').slideDown();
});
});
</script>
</head>
<div id="nprtopiclist">
<div class="nprtopic" style="width:624px;"></div>
</div>
<div id="nprlist" style="display:none;">
<p>
<a href="#" id="listBack"><< back</a>
</p>
<div class="nprstory" style="width:624px;"></div>
</div>
<div id="nprsummary" style="display:none;">
<p>
<a href="#" id="summaryBack"><< back</a>
</p>
<div id="summary"></div>
</div>
<div id="nprfullstory" style="display:none;">
<p>
<a href="#" id="fullBack"><< back</a>
</p>
<div id="fullStory"></div>
</div>
</html>