Skip to content

Commit c742f52

Browse files
committed
Gallery test page per #64
1 parent 5410a01 commit c742f52

File tree

3 files changed

+663
-0
lines changed

3 files changed

+663
-0
lines changed

gallery/index.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
layout: default
3+
title: Gallery
4+
class: gallery
5+
---
6+
7+
{% include header.html %}
8+
9+
<script id="template" type="text/html">
10+
{% raw %}
11+
<div id="galleryImage">
12+
<a href="{{link}}"><img src="{{image}}" /></a>
13+
</div>
14+
{% endraw %}
15+
</script>
16+
17+
<div id="galleryView">
18+
19+
20+
</div>
21+
22+
<footer id="galleryFooter">
23+
Processing Hour of Code // Computer Science Education Week // Code.org
24+
</footer>
25+
26+
<script src="//www.parsecdn.com/js/parse-1.3.1.min.js"></script>
27+
<script src="/js/vendor/mustache.min.js" type="text/javascript"></script>
28+
29+
<script src="/js/gallery.js" type="text/javascript"></script>

js/gallery.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"use strict";
2+
3+
/**
4+
* Singleton for gallery page
5+
*/
6+
var helloGallery = {
7+
pageNumber: 0,
8+
itemsPerPage: 16,
9+
/**
10+
* Initialize gallery page
11+
*/
12+
init: function () {
13+
14+
// Get the gistID from the URL and display it
15+
16+
if (document.URL.indexOf('#') >= 0) {
17+
helloGallery.pageNumber = document.URL.split('#')[1];
18+
}
19+
20+
Parse.initialize("x8FmMInL8BbVeBqonPzgvS8WNKbPro65Li5DzTI0", "Y7PPNnhLPhCdFMAKgw7amBxGerz67gAnG3UKb53s");
21+
22+
var GalleryObject = Parse.Object.extend("Gallery");
23+
var query = new Parse.Query(GalleryObject);
24+
query.limit(helloGallery.itemsPerPage);
25+
query.skip(helloGallery.pageNumber * helloGallery.itemsPerPage);
26+
query.descending("createdAt");
27+
28+
query.find({
29+
success: function(results) {
30+
//alert("Successfully retrieved " + results.length + " scores.");
31+
// Do something with the returned Parse.Object values
32+
for (var i = 0; i < results.length; i++) {
33+
var object = results[i];
34+
//alert(object.id + ' - ' + object.get('playerName'));
35+
36+
var data = {
37+
link: "http://" + $(location).attr('hostname') + (($(location).attr('port') !== "") ? ":" + $(location).attr('port') : "") + "/display/#@" + object.id,
38+
image: object.get("image").url()
39+
}
40+
41+
var template = $('#template').html();
42+
Mustache.parse(template);
43+
var rendered = Mustache.render(template, data);
44+
$('#galleryView').append(rendered);
45+
46+
47+
}
48+
},
49+
error: function(error) {
50+
//alert("Error: " + error.code + " " + error.message);
51+
}
52+
});
53+
54+
55+
}
56+
};

0 commit comments

Comments
 (0)