forked from Atrus7/tag-the-wall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraffiti_display.js
executable file
·107 lines (94 loc) · 3.11 KB
/
graffiti_display.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
100
101
102
103
104
105
106
107
function loadPublic() {
viewPrivate = false;
var Graffiti = Parse.Object.extend("Graffiti");
var query = new Parse.Query(Graffiti);
var path = location.hostname;
if (window.location.pathname.length > 1) path = path + window.location.pathname;
if (path.slice(-1) === "/") path = path.substring(0, path.length - 1);
// setting the query criteria
query.equalTo("urlString", path);
query.descending("upVotes");
query.descending("updatedAt");
query.limit(3);
var css = jQuery('<link href="overlay.css" rel="stylesheet" type="text/css">');
var all_pictures = [];
query.find({
success: function(results) {
// Do something with the returned Parse.Object values
for (var i = 0; i < results.length; i++) {
//CODE TO loop inserting all of the pictures
var graffiti = results[i];
var title = graffiti.get('title');
var imagePath = chrome.extension.getURL(title);
var pngUrl = graffiti.get('png').url();
var left = graffiti.get('left');
var top = graffiti.get('top');
var votes = graffiti.get('upVotes') - graffiti.get('downVotes');
var one_picture = {
x: left,
y: top,
name: title,
vote: votes,
data: pngUrl
};
if (graffiti.get('isPrivate') !== true) all_pictures.push(one_picture);
}
draw();
},
error: function(error) {
//alert("Error: " + error.code + " " + error.message);
}
});
function draw() {
for (var i = 0; i < all_pictures.length; i++) {
var pic = jQuery('<img class="graffiti" style = "left:' + all_pictures[i]["x"] +
'px; top: ' + all_pictures[i]["y"] + 'px; z-index: 23881273489127348971234897128935709813475094235788;" src ="' + all_pictures[i]["data"] + '"> </img>');
pic.appendTo(document.body);
}
}
setOverlaySize();
function setOverlaySize() {
$(".graffiti").css("z-index", 19238478239742349870000);
}
function getURL() {
var x = location.hostname;
return x;
}
}
function loadPrivate() {
viewPrivate = true;
if (passed_id == "") console.log("Can't lookup blank field");
else {
// console.log(passed_id);
var Graffiti = Parse.Object.extend("Graffiti");
var query = new Parse.Query(Graffiti);
// setting the query criteria
query.get(passed_id, {
success: function(result) {
//console.log("download is successfull");
// Do something with the returned Parse.Object values
var graffiti = result;
var title = graffiti.get('title');
var imagePath = chrome.extension.getURL(title);
var pngUrl = graffiti.get('png').url();
var left = graffiti.get('left');
var top = graffiti.get('top');
var votes = graffiti.get('upVotes') - graffiti.get('downVotes');
var one_picture = {
x: left,
y: top,
name: title,
vote: votes,
data: pngUrl
};
var pic = jQuery('<img class="graffiti" style = "left:' + one_picture["x"] +
'px; top: ' + one_picture["y"] + 'px; z-index: 23881273489127348971234897128935709813475094235788;" src ="' + one_picture["data"] + '"> </img>');
pic.appendTo(document.body);
// console.log(pngUrl);
},
error: function(error) {
//alert("Error: " + error.code + " " + error.message);
}
});
}
}