-
Notifications
You must be signed in to change notification settings - Fork 0
/
js.js
99 lines (60 loc) · 1.71 KB
/
js.js
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
singleCol = "";
$(document).ready( function() {
number = Math.floor(window.innerWidth / 340);
// console.log(($(window).width()/340).floor);
console.log(number);
// console.log(number);
subs = ["", "r/pics/", "r/funny", "r/aww/", "r/gif"];
columns = [];
// loadColumns();
// function loadColumn(sub) {
// this.loadArticles
for (var i = 0; i < number ; i++) {
subReddit = "http://reddit.com/" + subs[i] + ".json?jsonp=?";
$.getJSON( subReddit, function(column){
array = [];
for (var n = 0, len = column.data.children.length; n < len; n++) {
var article = { "data": {
"index" : n,
"title" : column.data.children[n].data.title,
"permalink" : column.data.children[n].data.permalink,
"url" : column.data.children[n].data.url,
"id" : column.data.children[n].data.id,
"domain" : column.data.children[n].data.domain,
"over_18" : column.data.children[n].data.over_18
}
};
article.data.url = fix(article.data.url, article.data.domain);
html = Mustache.render(articleTemplate, article.data);
array.push(html);
singleCol = Mustache.render(colTemplate, {"articles" : array });
$(singleCol).appendTo("#wrapper");
}
};
// $(columns).appendTo('#wrapper');
// loadColumn(subs[i]);
// console.log(array);
// loadColumn("wtf");
function fix(url, domain) {
// console.log(object);
if (domain == "i.imgur.com")
{
return url;
}
else if (domain == "imgur.com")
{
return "http://i.imgur.com/" + url.slice(17) + "m.jpg";
}
else
{
return "";
}
}
// object = "blah.com";
// return object;
// console.log(object);
// test = $.getJSON(front);
// console.log(info);
// console.log(json);
// console.log(front);
});