This repository was archived by the owner on May 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathindex.html
More file actions
145 lines (120 loc) · 5.21 KB
/
index.html
File metadata and controls
145 lines (120 loc) · 5.21 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html>
<head>
<title>Your prismic.io project</title>
<!-- Scripts -->
<script src="js/vendor/jquery-2.1.1.min.js"></script>
<script src="js/vendor/prismic.io-1.0.28.min.js"></script>
<script src="js/prismic-configuration.js"></script>
<script src="js/prismic-helpers.js"></script>
<script src="js/prismic-templates.js"></script>
</head>
<body>
<!-- View: bits of templates that are triggered in the controller (at the bottom) -->
<h1 id="title">
<script type="text/template">
<a href="index.html?<%= ctx.maybeRefParam %>">
Your prismic.io project
</a>
</script>
</h1>
<form action="search.html" method="GET">
<script type="text/template">
<input type="hidden" name="ref" value="<%= ctx.maybeRef %>">
<input type="text" name="q" value="">
<input type="submit" value="Search">
</script>
</form>
<hr>
<h2 id="subtitle">
<script type="text/template">
<% if(docs.total_results_size > 0) { %>
<%= docs.total_results_size %> documents
<% } else { %>
No documents found
<% } %>
</script>
</h2>
<ul id="list">
<script type="text/template">
<% for(var i=0; i<docs.results.length; i++) { %>
<li>
<a href="<%= ctx.linkResolver(ctx, docs.results[i]) %>">
<%= docs.results[i].slug %>
</a>
</li>
<% } %>
</script>
</ul>
<div id="pagination">
<script type="text/template">
<% if(docs.total_pages > 1) { %>
<hr>
<ul>
<% if (docs.page != 1) { %>
<li>
<a href="#<%= docs.page - 1 %>" data-forcereload="true">previous page</a>
</li>
<% } %>
<% for (var i = 1; i <= docs.total_pages; i++) { %>
<li>
<% if (docs.page == i) { %>
<span><%= i %></span>
<% } else { %>
<a href="#<%= i %>" data-forcereload="true"><%= i %></a>
<% } %>
</li>
<% } %>
<% if (docs.page != docs.total_pages) { %>
<li>
<a href="#<%= docs.page + 1 %>" data-forcereload="true">next page</a>
</li>
<% } %>
</ul>
<% } %>
</script>
</div>
<!-- your google analytics tracker here -->
<!-- <script> -->
<!-- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ -->
<!-- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), -->
<!-- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) -->
<!-- })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); -->
<!-- ga('create', '', 'auto'); -->
<!-- ga('send', 'pageview'); -->
<!-- </script> -->
<script src="//static.cdn.prismic.io/prismic.js"></script>
<div id="experiment">
<script type="text/template">
<% if(ctx.api.experiments.current()) { %>
<script>Helpers.loadExperimentJs("<%= ctx.api.experiments.currentGoogleId() %>");<%= closeScript %>
<% } %>
</script>
</div>
<!-- Controller (logic) -->
<script type="text/javascript">
$(function() {
Helpers.withPrismic(function(ctx) {
ctx.api.form("everything").set('page', parseInt(window.location.hash.substring(1)) || 1 ).ref(ctx.ref).submit(function(err, docs) {
if (err) { Configuration.onPrismicError(err); return; }
// Feed the templates
$('header, form, #title, #subtitle, #list, #pagination, footer, #experiment').render(
{
docs: docs,
ctx: ctx,
closeScript: '</sc' + 'ript>'
},
// Useful for pagination: refresh on some links even when only anchor changed
function() {
$('[data-forcereload=true]').click(function(e){
window.location = $(this).attr('href');
window.location.reload();
});
}
);
});
});
});
</script>
</body>
</html>