This repository has been archived by the owner on May 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
index.html
128 lines (104 loc) · 4.58 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>JavaScript starter</title>
<link href="css/main.css" media="all" rel="stylesheet" type="text/css">
<script src="vendor/jquery-2.0.3.min.js"></script>
<script src="scripts/fragments.js"></script>
<script src="scripts/api.js"></script>
<script src="scripts/prismic-configuration.js"></script>
<script src="scripts/prismic-helpers.js"></script>
</head>
<body class="loading">
<header>
<script type="text/template">
<% if($.prismic.oauth().hasPrivilegedAccess) { %>
<div id="toolbar">
<form method="GET">
<label for="releaseSelector">See this website: </label>
<select id="releaseSelector" name="ref" onchange="this.form.submit()">
<option value="" <% if(ref == api.data.master.ref) { %> selected="selected" <% } %> >As currently seen by guest visitors</option>
<optgroup label="Or preview the website in a future release:">
<% for(var i=0; i<api.data.refs.length; i++) { %>
<% if(!api.data.refs[i].isMaster) { %>
<option value="<%= api.data.refs[i].ref %>" <% if(ref == api.data.refs[i].ref) { %> selected="selected" <% } %>>As <%= api.data.refs[i].label %></option>
<% } %>
<% } %>
</optgroup>
</select>
</form>
<form action="signout.html" method="GET">
<input type="submit" value="Disconnect">
</form>
<hr>
</div>
<% } %>
<a href="index.html?ref=<%= ref %>">
<h1>Your prismic.io project</h1>
</a>
</script>
</header>
<form action="search.html" method="GET">
<script type="text/template">
<input type="hidden" name="ref" value="<%= ref %>">
<input type="text" name="q" value="">
<input type="submit" value="Search">
</script>
</form>
<hr>
<h2 id="title">
<script type="text/template">
<% if(docs.length > 0) { %>
<%= docs.length %> documents
<% } else { %>
No documents found
<% } %>
</script>
</h2>
<ul id="list">
<script type="text/template">
<% for(var i=0; i<docs.length; i++) { %>
<li>
<a href="detail.html?id=<%= docs[i].id %>&slug=<%= docs[i].slug %>&ref=<%= ref %>">
<%= docs[i].slug %>
</a>
</li>
<% } %>
</script>
</ul>
<footer>
<script type="text/template">
<% if(!$.prismic.oauth().hasPrivilegedAccess) { %>
<hr><a href="signin.html">Sign in to preview changes</a>
<% } %>
</script>
</footer>
<!-- Logic -->
<script type="text/javascript">
$(function() {
// Retrieve the prismic API
$.prismic.api().then(
function(api) {
console.log(api)
// Retrieve the ref from the QueryString or use the Master ref
var ref = $.prismic.queryString['ref'] || api.data.master.ref;
// Links resolver
var linkResolver = $.prismic.linkResolver(api, ref);
// Query All documents
return api.forms("everything").ref(ref).submit().then(function(docs) {
// Feed the templates
$('header, form, #title, #list, footer').render({
docs: docs,
ref: ref == api.data.master.ref ? '' : ref,
linkResolver: linkResolver,
api: api
});
});
}
).then(function() {
$(document.body).removeClass('loading')
});
});
</script>
</body>
</html>