-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
63 lines (54 loc) · 1.89 KB
/
main.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
goog.provide('uservoice.main');
goog.require('goog.array');
goog.require('goog.dom');
goog.require('goog.net.Jsonp');
/**
* Display the suggestions via UserVoice Public API JSON
*/
uservoice.main = function() {
var parent = goog.dom.getElement('uv_suggestion_list');
var jsonp = new goog.net.Jsonp('http://georeferencer.uservoice.com/' +
'api/v1/forums/41573/suggestions.json?client=1G82AJU6opl9DNtnBXPAwA');
jsonp.send({},
function(data) {
// console.log(data['suggestions']);
var all = goog.array.slice(data['suggestions'], 0, 5);
goog.array.forEach( all,
function(item) {
// Create DOM structure to represent the note.
var newSuggestion = goog.dom.createDom('li', {
'class': 'uv_suggestion'
},
goog.dom.createDom('div', {
'class': 'uv_votes'
},
goog.dom.createDom('div', {
'class': 'uv_num_votes'
},
item['vote_count'].toString()),
goog.dom.createTextNode('votes')),
goog.dom.createDom('a', {
'target': '_blank',
'href': item['url']
},
item['title'])
/* goog.dom.createDom('a', {
'target': '_blank',
'href': item['url'],
'class': 'uv_comments'
},
item['title']), */
);
// Add the note's DOM structure to the document.
goog.dom.appendChild(parent, newSuggestion);
});
});
/*
<li class="uv_suggestion">
<div class="uv_votes"><div class="uv_num_votes">1243</div>votes</div>
<a href="http://link/" target="_blank">This is the title of a suggestion</a>
<a href="http://link/" class="uv_comments">5 comments</a>
</li>
*/
};
window['main'] = uservoice.main;